This commit is contained in:
Fire-Head
2020-12-19 22:33:17 +03:00
98 changed files with 2783 additions and 2201 deletions

View File

@ -45,7 +45,7 @@ CEntity *CAnimViewer::pTarget = nil;
void
CAnimViewer::Render(void) {
if (pTarget) {
// pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
// pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f); // Only on Mobile
if (pTarget) {
#ifdef FIX_BUGS
#ifdef PED_SKIN
@ -61,7 +61,9 @@ CAnimViewer::Render(void) {
void
CAnimViewer::Initialise(void) {
LoadingScreen("Loading the ModelViewer", "", GetRandomSplashScreen());
// we need messages, messages needs hud, hud needs this
CHud::m_Wants_To_Draw_Hud = false;
animTxdSlot = CTxdStore::AddTxdSlot("generic");
CTxdStore::Create(animTxdSlot);
int hudSlot = CTxdStore::AddTxdSlot("hud");
@ -75,9 +77,6 @@ CAnimViewer::Initialise(void) {
TheCamera.SetRwCamera(Scene.camera);
TheCamera.Cams[TheCamera.ActiveCam].Distance = 5.0f;
gbModelViewer = true;
CHud::m_Wants_To_Draw_Hud = false;
ThePaths.Init();
ThePaths.AllocatePathFindInfoMem(4500);
CCollision::Init();
@ -113,7 +112,7 @@ CAnimViewer::Initialise(void) {
CTimeCycle::Initialise();
CCarCtrl::Init();
CPlayerPed *player = new CPlayerPed();
player->SetPosition(0.0f, 0.0f, 0.0f);
player->SetPosition(0.0f, 0.0f, 0.0f); // This is 1000.f for all axes on Xbox, but 0.f on mobile?
CWorld::Players[0].m_pPed = player;
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
@ -222,8 +221,7 @@ CAnimViewer::Update(void)
{
static int modelId = 0;
static int animId = 0;
// Please don't make this bool, static bool's are problematic on my side.
static int reloadIFP = 0;
static bool reloadIFP = false;
AssocGroupId animGroup = ASSOCGRP_STD;
int nextModelId = modelId;
@ -248,7 +246,7 @@ CAnimViewer::Update(void)
CAnimManager::Initialise();
CAnimManager::LoadAnimFiles();
reloadIFP = 0;
reloadIFP = false;
}
} else {
animGroup = ASSOCGRP_STD;
@ -302,6 +300,7 @@ CAnimViewer::Update(void)
pTarget->GetMatrix().GetPosition().z = 10.0f;
#else
pTarget->GetMatrix().GetPosition().z = 0.0f;
#endif
if (modelInfo->GetModelType() == MITYPE_PED) {
@ -309,7 +308,7 @@ CAnimViewer::Update(void)
// Triangle in mobile
if (pad->GetSquareJustDown()) {
reloadIFP = 1;
reloadIFP = true;
AsciiToUnicode("IFP reloaded", gUString);
CMessages::AddMessage(gUString, 1000, 0);

View File

@ -2472,7 +2472,7 @@ CCam::Process_Rocket(const CVector &CameraTarget, float, float, float)
ResetStatics = false;
}
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@ -2573,7 +2573,7 @@ CCam::Process_M16_1stPerson(const CVector &CameraTarget, float, float, float)
}
#if GTA_VERSION < GTA3_PC_11
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@ -2611,7 +2611,7 @@ CCam::Process_M16_1stPerson(const CVector &CameraTarget, float, float, float)
HeadPos.x = 0.0f;
HeadPos.y = 0.0f;
HeadPos.z = 0.0f;
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f * Cos(m_fInitialPlayerOrientation);
@ -2700,7 +2700,7 @@ CCam::Process_1stPerson(const CVector &CameraTarget, float TargetOrientation, fl
ResetStatics = false;
}
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@ -2868,7 +2868,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float,
Source = HeadPos;
// unused:
// ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&MidPos, PED_MID);
// ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(MidPos, PED_MID);
// Source - MidPos;
// Look around
@ -2963,7 +2963,7 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float
ResetStatics = false;
}
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD);
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos;
Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@ -3003,8 +3003,7 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float
UseMouse = false;
int ZoomInButton = ControlsManager.GetMouseButtonAssociatedWithAction(PED_SNIPER_ZOOM_IN);
int ZoomOutButton = ControlsManager.GetMouseButtonAssociatedWithAction(PED_SNIPER_ZOOM_OUT);
// TODO: enum? this should be mouse wheel up and down
if(ZoomInButton == 4 || ZoomInButton == 5 || ZoomOutButton == 4 || ZoomOutButton == 5){
if(ZoomInButton == rsMOUSEWHEELUPBUTTON || ZoomInButton == rsMOUSEWHEELDOWNBUTTON || ZoomOutButton == rsMOUSEWHEELUPBUTTON || ZoomOutButton == rsMOUSEWHEELDOWNBUTTON){
if(CPad::GetPad(0)->GetMouseWheelUp() || CPad::GetPad(0)->GetMouseWheelDown()){
if(CPad::GetPad(0)->SniperZoomIn()){
TargetFOV = FOV - 10.0f;
@ -4894,13 +4893,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
if (FOV > DefaultFOV)
// 0.98f: CAR_FOV_FADE_MULT
FOV = pow(0.98f, CTimer::GetTimeStep()) * (FOV - DefaultFOV) + DefaultFOV;
FOV = Pow(0.98f, CTimer::GetTimeStep()) * (FOV - DefaultFOV) + DefaultFOV;
if (FOV <= DefaultFOV + 30.0f) {
if (FOV < DefaultFOV)
FOV = DefaultFOV;
} else
FOV = DefaultFOV + 30.0f;
FOV = clamp(FOV, DefaultFOV, DefaultFOV + 30.0f);
}
// WORKAROUND: I still don't know how looking behind works (m_bCamDirectlyInFront is unused in III, they seem to use m_bUseTransitionBeta)
@ -5030,7 +5025,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
targetAlpha = maxAlphaAllowed;
}
float maxAlphaBlendAmount = CTimer::GetTimeStep() * CARCAM_SET[camSetArrPos][6];
float targetAlphaBlendAmount = (1.0f - pow(CARCAM_SET[camSetArrPos][5], CTimer::GetTimeStep())) * (targetAlpha - Alpha);
float targetAlphaBlendAmount = (1.0f - Pow(CARCAM_SET[camSetArrPos][5], CTimer::GetTimeStep())) * (targetAlpha - Alpha);
if (targetAlphaBlendAmount <= maxAlphaBlendAmount) {
if (targetAlphaBlendAmount < -maxAlphaBlendAmount)
targetAlphaBlendAmount = -maxAlphaBlendAmount;
@ -5042,9 +5037,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float stickX = -(pad->GetCarGunLeftRight());
float stickY = pad->GetCarGunUpDown();
// In SA this checks for m_bUseMouse3rdPerson so num2/num8 do not move camera when Keyboard & Mouse controls are used.
if (CCamera::m_bUseMouse3rdPerson)
stickY = 0.0f;
// In SA this is for not let num2/num8 move camera when Keyboard & Mouse controls are used.
// if (CCamera::m_bUseMouse3rdPerson)
// stickY = 0.0f;
float xMovement = Abs(stickX) * (FOV / 80.0f * 5.f / 70.f) * stickX * 0.007f * 0.007f;
float yMovement = Abs(stickY) * (FOV / 80.0f * 3.f / 70.f) * stickY * 0.007f * 0.007f;
@ -5122,7 +5117,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float betaSpeedFromStickX = xMovement * CARCAM_SET[camSetArrPos][12];
float newAngleSpeedMaxBlendAmount = CARCAM_SET[camSetArrPos][9];
float angleChangeStep = pow(CARCAM_SET[camSetArrPos][8], CTimer::GetTimeStep());
float angleChangeStep = Pow(CARCAM_SET[camSetArrPos][8], CTimer::GetTimeStep());
float targetBetaWithStickBlendAmount = betaSpeedFromStickX + (targetBeta - Beta) / Max(CTimer::GetTimeStep(), 1.0f);
if (targetBetaWithStickBlendAmount < -newAngleSpeedMaxBlendAmount)
@ -5234,69 +5229,78 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// SA calls SetColVarsVehicle in here
if (nextDirectionIsForward) {
// This is new in LCS!
// LCS uses exactly the same collision code as FollowPedWithMouse, so we will do so.
// This is only in LCS!
float timestepFactor = Pow(0.99f, CTimer::GetTimeStep());
dontCollideWithCars = (timestepFactor * dontCollideWithCars) + ((1.0f - timestepFactor) * car->m_vecMoveSpeed.Magnitude());
// Move cam if on collision
CColPoint foundCol;
CEntity* foundEnt;
// Our addition
#define IS_TRAFFIC_LIGHT(ent) (ent->IsObject() && (IsStreetLight(ent->GetModelIndex())))
// Clip Source and fix near clip
CColPoint colPoint;
CEntity* entity;
CWorld::pIgnoreEntity = CamTargetEntity;
if (CWorld::ProcessLineOfSight(TargetCoors, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
float obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
float obstacleCamDist = newDistance - obstacleTargetDist;
if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) {
Source = foundCol.point;
if (obstacleTargetDist < 1.2f) {
RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f));
}
} else {
if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
float lessClip = obstacleCamDist - 0.35f;
if (lessClip <= DEFAULT_NEAR)
RwCameraSetNearClipPlane(Scene.camera, lessClip);
else
RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
} else {
obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
Source = foundCol.point;
if (obstacleTargetDist < 1.2f) {
float lessClip = obstacleTargetDist - 0.3f;
if (lessClip >= 0.05f)
RwCameraSetNearClipPlane(Scene.camera, lessClip);
else
RwCameraSetNearClipPlane(Scene.camera, 0.05f);
}
if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, true, dontCollideWithCars < 0.1f, false, true, false, true, true) && !IS_TRAFFIC_LIGHT(entity)){
float PedColDist = (TargetCoors - colPoint.point).Magnitude();
float ColCamDist = newDistance - PedColDist;
if(entity->IsPed() && ColCamDist > DEFAULT_NEAR + 0.1f){
// Ped in the way but not clipping through
if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, dontCollideWithCars < 0.1f, false, true, false, true, true) || IS_TRAFFIC_LIGHT(entity)){
PedColDist = (TargetCoors - colPoint.point).Magnitude();
Source = colPoint.point;
if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
}else{
RwCameraSetNearClipPlane(Scene.camera, Min(ColCamDist-0.35f, DEFAULT_NEAR));
}
}else{
Source = colPoint.point;
if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f));
}
}
CWorld::pIgnoreEntity = nil;
float nearClip = RwCameraGetNearClipPlane(Scene.camera);
float radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
// If we're seeing blue hell due to camera intersects some surface, fix it.
// SA and LCS have this unrolled.
for (int i = 0;
i <= 5 && CWorld::TestSphereAgainstWorld((nearClip * Front) + Source, radius * nearClip, nil, true, true, false, true, false, false);
i++) {
CVector surfaceCamDist = gaTempSphereColPoints->point - Source;
CVector frontButInvertedIfTouchesSurface = DotProduct(surfaceCamDist, Front) * Front;
float newNearClip = (surfaceCamDist - frontButInvertedIfTouchesSurface).Magnitude() / radius;
float ViewPlaneHeight = Tan(DEGTORAD(FOV) / 2.0f);
float ViewPlaneWidth = ViewPlaneHeight * CDraw::FindAspectRatio() * fTweakFOV;
float Near = RwCameraGetNearClipPlane(Scene.camera);
float radius = ViewPlaneWidth*Near;
entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, true);
int i = 0;
while(entity){
if (newNearClip > nearClip)
newNearClip = nearClip;
if (newNearClip < 0.1f)
newNearClip = 0.1f;
if (nearClip > newNearClip)
RwCameraSetNearClipPlane(Scene.camera, newNearClip);
if (IS_TRAFFIC_LIGHT(entity))
break;
if (newNearClip == 0.1f)
Source += (TargetCoors - Source) * 0.3f;
CVector CamToCol = gaTempSphereColPoints[0].point - Source;
float frontDist = DotProduct(CamToCol, Front);
float dist = (CamToCol - Front*frontDist).Magnitude() / ViewPlaneWidth;
nearClip = RwCameraGetNearClipPlane(Scene.camera);
radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
// Try to decrease near clip
dist = Max(Min(Near, dist), 0.1f);
if(dist < Near)
RwCameraSetNearClipPlane(Scene.camera, dist);
// Move forward a bit
if(dist == 0.1f)
Source += (TargetCoors - Source)*0.3f;
// Keep testing
Near = RwCameraGetNearClipPlane(Scene.camera);
radius = ViewPlaneWidth*Near;
entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, true);
i++;
if(i > 5)
entity = nil;
}
#undef IS_TRAFFIC_LIGHT
}
TheCamera.m_bCamDirectlyBehind = false;
TheCamera.m_bCamDirectlyInFront = false;

View File

@ -1065,7 +1065,7 @@ CFileLoader::LoadMLOInstance(int id, const char *line)
&rot.x, &rot.y, &rot.z,
&angle);
float rad = Acos(angle) * 2.0f;
CInstance *inst = CModelInfo::GetMloInstanceStore().alloc();
CInstance *inst = CModelInfo::GetMloInstanceStore().Alloc();
minfo->lastInstance++;
RwMatrix *matrix = RwMatrixCreate();
@ -1305,7 +1305,7 @@ CFileLoader::Load2dEffect(const char *line)
CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("particle"));
mi = CModelInfo::GetModelInfo(id);
effect = CModelInfo::Get2dEffectStore().alloc();
effect = CModelInfo::Get2dEffectStore().Alloc();
mi->Add2dEffect(effect);
effect->pos = CVector(x, y, z);
effect->col = CRGBA(r, g, b, a);

View File

@ -90,7 +90,11 @@ CFire::ProcessFire(void)
}
}
}
if (!FindPlayerVehicle() && !FindPlayerPed()->m_pFire && !(FindPlayerPed()->bFireProof)
if (!FindPlayerVehicle() &&
#ifdef FIX_BUGS
FindPlayerPed() &&
#endif
!FindPlayerPed()->m_pFire && !(FindPlayerPed()->bFireProof)
&& ((FindPlayerPed()->GetPosition() - m_vecPos).MagnitudeSqr() < 2.0f)) {
FindPlayerPed()->DoStuffToGoOnFire();
gFireManager.StartFire(FindPlayerPed(), m_pSource, 0.8f, 1);
@ -224,7 +228,7 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength
ped->bDrawLast = false;
ped->SetMoveState(PEDMOVE_SPRINT);
ped->SetMoveAnim();
ped->m_nPedState = PED_ON_FIRE;
ped->SetPedState(PED_ON_FIRE);
}
if (fleeFrom) {
if (ped->m_nPedType == PEDTYPE_COP) {
@ -397,7 +401,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt
CVector2D pos = target->GetPosition();
ped->SetFlee(pos, 10000);
ped->SetMoveAnim();
ped->m_nPedState = PED_ON_FIRE;
ped->SetPedState(PED_ON_FIRE);
}
} else if (target->IsVehicle()) {
veh->m_pCarFire = fire;

File diff suppressed because it is too large Load Diff

View File

@ -25,15 +25,18 @@
#define MENUSLIDER_X 256.0f
#define MENUSLIDER_UNK 256.0f
#define BIGTEXT_X_SCALE 0.75f
#define BIGTEXT_X_SCALE 0.75f // For FONT_HEADING
#define BIGTEXT_Y_SCALE 0.9f
#define MEDIUMTEXT_X_SCALE 0.55f
#define MEDIUMTEXT_X_SCALE 0.55f // For FONT_HEADING
#define MEDIUMTEXT_Y_SCALE 0.8f
#define SMALLTEXT_X_SCALE 0.45f
#define SMALLTEXT_X_SCALE 0.45f // used for FONT_HEADING and FONT_BANK, but looks off for HEADING
#define SMALLTEXT_Y_SCALE 0.7f
#define SMALLESTTEXT_X_SCALE 0.4f
#define SMALLESTTEXT_X_SCALE 0.4f // used for both FONT_HEADING and FONT_BANK
#define SMALLESTTEXT_Y_SCALE 0.6f
#define HELPER_TEXT_LEFT_MARGIN 320.0f
#define HELPER_TEXT_BOTTOM_MARGIN 120.0f
#define PLAYERSETUP_LIST_TOP 28.0f
#define PLAYERSETUP_LIST_BOTTOM 125.0f
#define PLAYERSETUP_LIST_LEFT 200.0f
@ -45,8 +48,6 @@
#endif
#define PLAYERSETUP_SCROLLBUTTON_HEIGHT 17.0f
#define PLAYERSETUP_SCROLLBUTTON_TXD_DIMENSION 64
#define PLAYERSETUP_ROW_TEXT_X_SCALE 0.4f
#define PLAYERSETUP_ROW_TEXT_Y_SCALE 0.6f
#define PLAYERSETUP_SKIN_COLUMN_LEFT 220.0f
#define PLAYERSETUP_DATE_COLUMN_RIGHT 56.0f
#define PLAYERSETUP_LIST_BODY_TOP 47
@ -241,8 +242,6 @@ enum eMenuScreen
#ifdef GRAPHICS_MENU_OPTIONS
MENUPAGE_GRAPHICS_SETTINGS,
#else
MENUPAGE_ADVANCED_DISPLAY_SETTINGS,
#endif
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
MENUPAGE_DETECT_JOYSTICK,
@ -697,8 +696,6 @@ public:
#ifdef MENU_MAP
static bool bMenuMapActive;
static bool bMapMouseShownOnce;
static bool bMapLoaded;
static float fMapSize;
static float fMapCenterY;
static float fMapCenterX;

View File

@ -5,7 +5,8 @@ enum eLevelName {
LEVEL_GENERIC = 0,
LEVEL_INDUSTRIAL,
LEVEL_COMMERCIAL,
LEVEL_SUBURBAN
LEVEL_SUBURBAN,
NUM_LEVELS
};
class CGame

View File

@ -399,7 +399,12 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
VIDEOMODE_SELECTOR
MULTISAMPLING_SELECTOR
MENUACTION_CHANGEMENU, "FET_ADV", { nil, SAVESLOT_NONE, MENUPAGE_ADVANCED_DISPLAY_SETTINGS },
ISLAND_LOADING_SELECTOR
DUALPASS_SELECTOR
CUTSCENE_BORDERS_TOGGLE
FREE_CAM_TOGGLE
POSTFX_SELECTORS
PIPELINES_SELECTOR
MENUACTION_RESTOREDEF, "FET_DEF", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
@ -829,31 +834,12 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
#else
MENUACTION_TRAILS, "FED_TRA", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
#endif
#ifdef EXTENDED_PIPELINES
PIPELINES_SELECTOR
#endif
ISLAND_LOADING_SELECTOR
DUALPASS_SELECTOR
MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefGraphics) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#else
// MENUPAGE_ADVANCED_DISPLAY_SETTINGS
{ "FET_ADV", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS,
new CCustomScreenLayout({MENUSPRITE_MAINMENU, 50, 0, 20, FONT_HEADING, FESCREEN_LEFT_ALIGN, true, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), nil,
ISLAND_LOADING_SELECTOR
DUALPASS_SELECTOR
CUTSCENE_BORDERS_TOGGLE
FREE_CAM_TOGGLE
#ifdef EXTENDED_COLOURFILTER
POSTFX_SELECTORS
#endif
#ifdef EXTENDED_PIPELINES
PIPELINES_SELECTOR
#endif
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#endif
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS

View File

@ -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"
@ -31,83 +32,6 @@
#include "ZoneCull.h"
#include "main.h"
void
CPlayerInfo::SetPlayerSkin(char *skin)
{
strncpy(m_aSkinName, skin, 32);
LoadPlayerSkin();
}
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();
}
void
CPlayerInfo::LoadPlayerSkin()
{
DeletePlayerSkin();
m_pSkinTexture = CPlayerSkin::GetSkinTexture(m_aSkinName);
if (!m_pSkinTexture)
m_pSkinTexture = CPlayerSkin::GetSkinTexture(DEFAULT_SKIN_NAME);
}
void
CPlayerInfo::DeletePlayerSkin()
{
if (m_pSkinTexture) {
RwTextureDestroy(m_pSkinTexture);
m_pSkinTexture = nil;
}
}
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();
CDarkel::ResetOnPlayerDeath();
CMessages::AddBigMessage(TheText.Get("BUSTED"), 5000, 2);
CStats::TimesArrested++;
}
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();
}
void
CPlayerInfo::Clear(void)
@ -146,197 +70,6 @@ CPlayerInfo::Clear(void)
m_nExplosionsSinceLastReward = 0;
}
void
CPlayerInfo::BlowUpRCBuggy(void)
{
if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
return;
CRemote::TakeRemoteControlledCarFromPlayer();
m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
}
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) {
CTheScripts::ResetCountdownToMakePlayerUnsafe();
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 if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) {
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();
}
}
bool
CPlayerInfo::IsRestartingAfterDeath()
{
return m_WBState == WBSTATE_WASTED;
}
bool
CPlayerInfo::IsRestartingAfterArrest()
{
return m_WBState == WBSTATE_BUSTED;
}
// 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;
}
}
// There is something unfinished in here... Sadly all IDBs we have have it unfinished.
void
CPlayerInfo::AwardMoneyForExplosion(CVehicle *wreckedCar)
{
if (CTimer::GetTimeInMilliseconds() - m_nPreviousTimeRewardedForExplosion < 6000)
++m_nExplosionsSinceLastReward;
else
m_nExplosionsSinceLastReward = 1;
m_nPreviousTimeRewardedForExplosion = CTimer::GetTimeInMilliseconds();
int award = wreckedCar->pHandling->nMonetaryValue * 0.002f;
sprintf(gString, "$%d", award);
#ifdef MONEY_MESSAGES
// This line is a leftover from PS2, I don't know what it was meant to be.
// CVector sth(TheCamera.GetPosition() * 4.0f);
CMoneyMessages::RegisterOne(wreckedCar->GetPosition() + CVector(0.0f, 0.0f, 2.0f), gString, 0, 255, 0, 2.0f, 0.5f);
#endif
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
for (int i = m_nExplosionsSinceLastReward; i > 1; --i) {
CGeneral::GetRandomNumber();
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
}
}
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_bGetOutOfJailFree);
CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
#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_bGetOutOfJailFree);
CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName)
#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) {
float dist = (ped->GetPosition() - carCentre).Magnitude2D();
if (dist <= 10.0f && !CCranes::IsThisCarBeingCarriedByAnyCrane(car)) {
EvaluateCarPosition(car, ped, dist, lastCloseness, closestCarOutput);
}
}
}
}
}
}
void
CPlayerInfo::Process(void)
{
@ -419,7 +152,7 @@ CPlayerInfo::Process(void)
if (found)
sth.z = 1.0f + groundZ;
m_pPed->m_nPedState = PED_IDLE;
m_pPed->SetPedState(PED_IDLE);
m_pPed->SetMoveState(PEDMOVE_STILL);
CPed::PedSetOutCarCB(0, m_pPed);
CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
@ -503,13 +236,13 @@ CPlayerInfo::Process(void)
uint32 timeWithoutRemoteCar = CTimer::GetTimeInMilliseconds() - m_nTimeLostRemoteCar;
if (CTimer::GetPreviousTimeInMilliseconds() - m_nTimeLostRemoteCar < 1000 && timeWithoutRemoteCar >= 1000 && m_WBState == WBSTATE_PLAYING) {
TheCamera.SetFadeColour(0, 0, 0);
TheCamera.Fade(1.0f, 0);
TheCamera.Fade(1.0f, FADE_OUT);
}
if (timeWithoutRemoteCar > 2000) {
if (m_WBState == WBSTATE_PLAYING) {
TheCamera.RestoreWithJumpCut();
TheCamera.SetFadeColour(0, 0, 0);
TheCamera.Fade(1.0f, 1);
TheCamera.Fade(1.0f, FADE_IN);
TheCamera.Process();
CTimer::Stop();
CCullZones::ForceCullZoneCoors(TheCamera.GetPosition());
@ -560,3 +293,370 @@ CPlayerInfo::Process(void)
CStats::DistanceTravelledOnFoot += FindPlayerPed()->m_fDistanceTravelled;
}
}
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_bGetOutOfJailFree);
CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
#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_bGetOutOfJailFree);
CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName)
#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) {
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();
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) {
CTheScripts::ResetCountdownToMakePlayerUnsafe();
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 if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) {
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(void)
{
if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
return;
CRemote::TakeRemoteControlledCarFromPlayer();
m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
}
// There is something unfinished in here... Sadly all IDBs we have have it unfinished.
void
CPlayerInfo::AwardMoneyForExplosion(CVehicle *wreckedCar)
{
if (CTimer::GetTimeInMilliseconds() - m_nPreviousTimeRewardedForExplosion < 6000)
++m_nExplosionsSinceLastReward;
else
m_nExplosionsSinceLastReward = 1;
m_nPreviousTimeRewardedForExplosion = CTimer::GetTimeInMilliseconds();
int award = wreckedCar->pHandling->nMonetaryValue * 0.002f;
sprintf(gString, "$%d", award);
#ifdef MONEY_MESSAGES
// This line is a leftover from PS2, I don't know what it was meant to be.
// CVector sth(TheCamera.GetPosition() * 4.0f);
CMoneyMessages::RegisterOne(wreckedCar->GetPosition() + CVector(0.0f, 0.0f, 2.0f), gString, 0, 255, 0, 2.0f, 0.5f);
#endif
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
for (int i = m_nExplosionsSinceLastReward; i > 1; --i) {
CGeneral::GetRandomNumber();
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += award;
}
}
#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);
if (!m_pSkinTexture)
m_pSkinTexture = CPlayerSkin::GetSkinTexture(DEFAULT_SKIN_NAME);
}
void
CPlayerInfo::DeletePlayerSkin()
{
if (m_pSkinTexture) {
RwTextureDestroy(m_pSkinTexture);
m_pSkinTexture = nil;
}
}
#endif

View File

@ -54,14 +54,13 @@ public:
bool m_bFastReload;
bool m_bGetOutOfJailFree;
bool m_bGetOutOfHospitalFree;
#ifdef GTA_PC
char m_aSkinName[32];
RwTexture *m_pSkinTexture;
#endif
void MakePlayerSafe(bool);
void LoadPlayerSkin();
void DeletePlayerSkin();
void AwardMoneyForExplosion(CVehicle *vehicle);
void SetPlayerSkin(char* skin);
const CVector &GetPos();
void Process(void);
void KillPlayer(void);
@ -78,7 +77,21 @@ 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);
VALIDATE_SIZE(CPlayerInfo, 0x13C);

View File

@ -33,7 +33,7 @@
CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
CPtrList CWorld::ms_bigBuildingsList[4];
CPtrList CWorld::ms_bigBuildingsList[NUM_LEVELS];
CPtrList CWorld::ms_listMovingEntityPtrs;
CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
uint16 CWorld::ms_nCurrentScanCode;
@ -1361,102 +1361,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)
{
@ -1537,7 +1441,7 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList &list, float x1, float y1
if(pVehicle->m_scanCode != GetCurrentScanCode()) {
pVehicle->m_scanCode = GetCurrentScanCode();
const CVector &vehiclePos = pVehicle->GetPosition();
eCarMission carMission = pVehicle->AutoPilot.m_nCarMission;
uint8 carMission = pVehicle->AutoPilot.m_nCarMission;
if(pVehicle != FindPlayerVehicle() && vehiclePos.x > fStartX && vehiclePos.x < fEndX &&
vehiclePos.y > fStartY && vehiclePos.y < fEndY && pVehicle->bIsLawEnforcer &&
(carMission == MISSION_RAMPLAYER_FARAWAY || carMission == MISSION_RAMPLAYER_CLOSE ||
@ -1745,13 +1649,13 @@ CWorld::ShutDown(void)
pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush();
#endif
}
for(int32 i = 0; i < 4; i++) {
for(CPtrNode *pNode = GetBigBuildingList((eLevelName)i).first; pNode; pNode = pNode->next) {
for(int32 i = 0; i < NUM_LEVELS; i++) {
for(CPtrNode *pNode = ms_bigBuildingsList[i].first; pNode; pNode = pNode->next) {
CEntity *pEntity = (CEntity *)pNode->item;
// Maybe remove from world here?
delete pEntity;
}
GetBigBuildingList((eLevelName)i).Flush();
ms_bigBuildingsList[i].Flush();
}
for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) {
CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y);
@ -1955,12 +1859,11 @@ CWorld::Process(void)
} else {
for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity *movingEnt = (CEntity *)node->item;
#ifdef SQUEEZE_PERFORMANCE
if (movingEnt->bRemoveFromWorld) {
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else
#endif
#ifdef FIX_BUGS // from VC
if(!movingEnt->bRemoveFromWorld && movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
#else
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
#endif
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(),
0.02f * (movingEnt->IsObject()

View File

@ -55,7 +55,7 @@ struct CStoredCollPoly;
class CWorld
{
static CPtrList ms_bigBuildingsList[4];
static CPtrList ms_bigBuildingsList[NUM_LEVELS];
static CPtrList ms_listMovingEntityPtrs;
static CSector ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
static uint16 ms_nCurrentScanCode;
@ -157,14 +157,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);

View File

@ -274,8 +274,14 @@ void re3_usererror(const char *format, ...);
#define DEBUGBREAK() __debugbreak();
#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
// Switch to enable development messages.
#if 1
#define DEV(f, ...)
#else
#define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__)
#endif
#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__)
#define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__)

View File

@ -300,7 +300,7 @@ enum Config {
# define CUSTOM_FRONTEND_OPTIONS
# ifdef CUSTOM_FRONTEND_OPTIONS
# define GRAPHICS_MENU_OPTIONS // otherwise Advanced Options menu will appear if Display is full
# define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable
# define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
# define CUTSCENE_BORDERS_SWITCH
# define MULTISAMPLING // adds MSAA option

View File

@ -415,6 +415,63 @@ PluginAttach(void)
return TRUE;
}
#ifdef GTA_PS2
#define NUM_PREALLOC_ATOMICS 3245
#define NUM_PREALLOC_CLUMPS 101
#define NUM_PREALLOC_FRAMES 2821
#define NUM_PREALLOC_GEOMETRIES 1404
#define NUM_PREALLOC_TEXDICTS 106
#define NUM_PREALLOC_TEXTURES 1900
#define NUM_PREALLOC_MATERIALS 3300
bool preAlloc;
void
PreAllocateRwObjects(void)
{
int i;
void **tmp = new void*[0x8000];
preAlloc = true;
for(i = 0; i < NUM_PREALLOC_ATOMICS; i++)
tmp[i] = RpAtomicCreate();
for(i = 0; i < NUM_PREALLOC_ATOMICS; i++)
RpAtomicDestroy((RpAtomic*)tmp[i]);
for(i = 0; i < NUM_PREALLOC_CLUMPS; i++)
tmp[i] = RpClumpCreate();
for(i = 0; i < NUM_PREALLOC_CLUMPS; i++)
RpClumpDestroy((RpClump*)tmp[i]);
for(i = 0; i < NUM_PREALLOC_FRAMES; i++)
tmp[i] = RwFrameCreate();
for(i = 0; i < NUM_PREALLOC_FRAMES; i++)
RwFrameDestroy((RwFrame*)tmp[i]);
for(i = 0; i < NUM_PREALLOC_GEOMETRIES; i++)
tmp[i] = RpGeometryCreate(0, 0, 0);
for(i = 0; i < NUM_PREALLOC_GEOMETRIES; i++)
RpGeometryDestroy((RpGeometry*)tmp[i]);
for(i = 0; i < NUM_PREALLOC_TEXDICTS; i++)
tmp[i] = RwTexDictionaryCreate();
for(i = 0; i < NUM_PREALLOC_TEXDICTS; i++)
RwTexDictionaryDestroy((RwTexDictionary*)tmp[i]);
for(i = 0; i < NUM_PREALLOC_TEXTURES; i++)
tmp[i] = RwTextureCreate(RwRasterCreate(0, 0, 0, 0));
for(i = 0; i < NUM_PREALLOC_TEXDICTS; i++)
RwTextureDestroy((RwTexture*)tmp[i]);
for(i = 0; i < NUM_PREALLOC_MATERIALS; i++)
tmp[i] = RpMaterialCreate();
for(i = 0; i < NUM_PREALLOC_MATERIALS; i++)
RpMaterialDestroy((RpMaterial*)tmp[i]);
delete[] tmp;
preAlloc = false;
}
#endif
static RwBool
Initialise3D(void *param)
{
@ -621,8 +678,10 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
AsciiToUnicode(str1, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr);
vpos += 22*yscale;
AsciiToUnicode(str2, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr);
if (str2) {
AsciiToUnicode(str2, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr);
}
#endif
}
@ -1581,15 +1640,6 @@ AppEventHandler(RsEvent event, void *param)
return rsEVENTPROCESSED;
}
#ifndef MASTER
case rsANIMVIEWER:
{
TheModelViewer();
return rsEVENTPROCESSED;
}
#endif
default:
{
return rsEVENTNOTPROCESSED;
@ -1604,8 +1654,11 @@ TheModelViewer(void)
#if (defined(GTA_PS2) || defined(GTA_XBOX))
//TODO
#else
// This is III Mobile code. III Xbox code run it like main function, which is impossible to implement on PC's state machine implementation.
// Also we want 2D things initialized in here to print animation ids etc., our additions for that marked with X
#ifdef ASPECT_RATIO_SCALE
CDraw::SetAspectRatio(CDraw::FindAspectRatio());
CDraw::SetAspectRatio(CDraw::FindAspectRatio()); // X
#endif
CAnimViewer::Update();
CTimer::Update();
@ -1615,12 +1668,12 @@ TheModelViewer(void)
CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
255);
CSprite2d::InitPerFrame();
CFont::InitPerFrame();
CSprite2d::InitPerFrame(); // X
CFont::InitPerFrame(); // X
DefinedState();
CVisibilityPlugins::InitAlphaEntityList();
CAnimViewer::Render();
Render2dStuff();
Render2dStuff(); // X
DoRWStuffEndOfFrame();
#endif
}

View File

@ -29,6 +29,7 @@ class CSprite2d;
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void);
void PreAllocateRwObjects(void);
void InitialiseGame(void);
void LoadingScreen(const char *str1, const char *str2, const char *splashscreen);
void LoadingIslandScreen(const char *levelName);

View File

@ -1,31 +1,31 @@
#pragma once
template<typename T, int n>
template<typename T, int32 n>
class CStore
{
public:
int allocPtr;
int32 allocPtr;
T store[n];
T *alloc(void){
if(this->allocPtr >= n){
T *Alloc(void){
if(allocPtr >= n){
printf("Size of this thing:%d needs increasing\n", n);
assert(0);
}
return &this->store[this->allocPtr++];
return &store[allocPtr++];
}
void clear(void){
this->allocPtr = 0;
void Clear(void){
allocPtr = 0;
}
int getIndex(T *item){
assert(item >= &this->store[0]);
assert(item < &this->store[n]);
return item - this->store;
int32 GetIndex(T *item){
assert(item >= &store[0]);
assert(item < &store[n]);
return item - store;
}
T *getItem(int index){
T *GetItem(int32 index){
assert(index >= 0);
assert(index < n);
return &this->store[index];
return &store[index];
}
};
@ -40,12 +40,11 @@ class CPool
};
uint8 u;
} *m_flags;
int m_size;
int m_allocPtr;
int32 m_size;
int32 m_allocPtr;
public:
CPool(int size){
// TODO: use new here
CPool(int32 size){
m_entries = (U*)new uint8[sizeof(U)*size];
m_flags = (Flags*)new uint8[sizeof(Flags)*size];
m_size = size;
@ -69,7 +68,7 @@ public:
m_allocPtr = 0;
}
}
int GetSize(void) const { return m_size; }
int32 GetSize(void) const { return m_size; }
T *New(void){
bool wrapped = false;
do
@ -93,12 +92,12 @@ public:
m_flags[m_allocPtr].id++;
return (T*)&m_entries[m_allocPtr];
}
T *New(int handle){
T *New(int32 handle){
T *entry = (T*)&m_entries[handle>>8];
SetNotFreeAt(handle);
return entry;
}
void SetNotFreeAt(int handle){
void SetNotFreeAt(int32 handle){
int idx = handle>>8;
m_flags[idx].free = 0;
m_flags[idx].id = handle & 0x7F;
@ -123,21 +122,21 @@ public:
return m_flags[handle>>8].u == (handle & 0xFF) ?
(T*)&m_entries[handle >> 8] : nil;
}
int GetIndex(T *entry){
int32 GetIndex(T *entry){
int i = GetJustIndex_NoFreeAssert(entry);
return m_flags[i].u + (i<<8);
}
int GetJustIndex(T *entry){
int32 GetJustIndex(T *entry){
int index = GetJustIndex_NoFreeAssert(entry);
assert(!IsFreeSlot(index));
return index;
}
int GetJustIndex_NoFreeAssert(T* entry){
int32 GetJustIndex_NoFreeAssert(T* entry){
int index = ((U*)entry - m_entries);
assert((U*)entry == (U*)&m_entries[index]); // cast is unsafe - check required
return index;
}
int GetNoOfUsedSpaces(void) const{
int32 GetNoOfUsedSpaces(void) const{
int i;
int n = 0;
for(i = 0; i < m_size; i++)
@ -241,7 +240,7 @@ public:
link->Remove(); // remove from list
freeHead.Insert(link); // insert into free list
}
int Count(void){
int32 Count(void){
int n = 0;
CLink<T> *lnk;
for(lnk = head.next; lnk != &tail; lnk = lnk->next)