summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/Cam.cpp4
-rw-r--r--src/core/Camera.cpp14
-rw-r--r--src/core/CdStreamPosix.cpp16
-rw-r--r--src/core/Collision.cpp233
-rw-r--r--src/core/Collision.h32
-rw-r--r--src/core/Directory.cpp3
-rw-r--r--src/core/FileLoader.cpp12
-rw-r--r--src/core/FileMgr.cpp49
-rw-r--r--src/core/FileMgr.h6
-rw-r--r--src/core/Fire.cpp7
-rw-r--r--src/core/Frontend.cpp43
-rw-r--r--src/core/Frontend.h6
-rw-r--r--src/core/Game.cpp24
-rw-r--r--src/core/Game.h2
-rw-r--r--src/core/General.h2
-rw-r--r--src/core/Pad.cpp29
-rw-r--r--src/core/Pad.h2
-rw-r--r--src/core/PlayerInfo.cpp4
-rw-r--r--src/core/Radar.cpp6
-rw-r--r--src/core/Stats.cpp4
-rw-r--r--src/core/Stats.h4
-rw-r--r--src/core/Streaming.cpp37
-rw-r--r--src/core/Streaming.h12
-rw-r--r--src/core/SurfaceTable.h10
-rw-r--r--src/core/TempColModels.cpp6
-rw-r--r--src/core/Wanted.cpp36
-rw-r--r--src/core/World.cpp2
-rw-r--r--src/core/Zones.cpp8
-rw-r--r--src/core/common.h5
-rw-r--r--src/core/config.h15
-rw-r--r--src/core/main.cpp18
-rw-r--r--src/core/patcher.cpp94
-rw-r--r--src/core/patcher.h144
-rw-r--r--src/core/re3.cpp22
34 files changed, 424 insertions, 487 deletions
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index d038c423..fcffce9b 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -1688,7 +1688,7 @@ CCam::Process_BehindCar(const CVector &CameraTarget, float TargetOrientation, fl
if(Length < 0.002f)
Length = 0.002f;
Beta = CGeneral::GetATanOfXY(TargetCoors.x - Source.x, TargetCoors.y - Source.y);
-#ifdef TOGGLEABLE_BETA_FEATURES
+#if 1
// This is completely made up but Bill's cam manipulates an angle before calling this
// and otherwise calculating Beta doesn't make much sense.
Beta += fBillsBetaOffset;
@@ -5060,7 +5060,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// This is not working on cars as SA
// Because III/VC doesn't have any buttons tied to LeftStick if you're not in Classic Configuration, using Dodo or using GInput/Pad, so :shrug:
if (Abs(pad->GetSteeringUpDown()) > 120.0f) {
- if (car->pDriver && car->pDriver->m_objective != OBJECTIVE_LEAVE_VEHICLE) {
+ if (car->pDriver && car->pDriver->m_objective != OBJECTIVE_LEAVE_CAR) {
yMovement += Abs(pad->GetSteeringUpDown()) * (FOV / 80.0f * 3.f / 70.f) * pad->GetSteeringUpDown() * 0.007f * 0.007f * 0.5;
}
}
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 340dbaee..abe0833e 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -2978,15 +2978,15 @@ CCamera::LoadTrainCamNodes(char const *name)
char token[16] = { 0 };
char filename[16] = { 0 };
uint8 *buf;
- int bufpos = 0;
+ size_t bufpos = 0;
int field = 0;
int tokpos = 0;
char c;
int i;
- int len;
+ size_t len;
strcpy(filename, name);
- len = strlen(filename);
+ len = (int)strlen(filename);
filename[len] = '.';
filename[len+1] = 'd';
filename[len+2] = 'a';
@@ -3587,8 +3587,8 @@ CCamera::CalculateDerivedValues(void)
m_cameraMatrix = Invert(m_matrix);
float hfov = DEGTORAD(CDraw::GetScaledFOV()/2.0f);
- float c = cos(hfov);
- float s = sin(hfov);
+ float c = Cos(hfov);
+ float s = Sin(hfov);
// right plane
m_vecFrustumNormals[0] = CVector(c, -s, 0.0f);
@@ -3622,7 +3622,7 @@ bool
CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
{
RwV3d c;
- c = *(RwV3d*)&center;
+ c = center;
RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
if(c.y < CDraw::GetNearClipZ()) return false;
if(c.y > CDraw::GetFarClipZ()) return false;
@@ -3637,7 +3637,7 @@ bool
CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat)
{
RwV3d c;
- c = *(RwV3d*)&center;
+ c = center;
RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
if(c.y + radius < CDraw::GetNearClipZ()) return false;
if(c.y - radius > CDraw::GetFarClipZ()) return false;
diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp
index 4d6bcdab..45fd9832 100644
--- a/src/core/CdStreamPosix.cpp
+++ b/src/core/CdStreamPosix.cpp
@@ -189,10 +189,11 @@ GetGTA3ImgSize(void)
realpath(gImgNames[0], path);
if (stat(path, &statbuf) == -1) {
// Try case-insensitivity
- char *r = (char*)alloca(strlen(gImgNames[0]) + 2);
- if (casepath(gImgNames[0], r))
+ char* real = casepath(gImgNames[0], false);
+ if (real)
{
- realpath(r, path);
+ realpath(real, path);
+ free(real);
if (stat(path, &statbuf) != -1)
goto ok;
}
@@ -210,7 +211,6 @@ CdStreamShutdown(void)
{
// Destroying semaphores and free(gpReadInfo) will be done at threads
#ifndef ONE_THREAD_PER_CHANNEL
- free(gChannelRequestQ.items);
gCdStreamThreadStatus = 2;
sem_post(&gCdStreamSema);
#endif
@@ -442,6 +442,7 @@ void *CdStreamThread(void *param)
sem_destroy(&gpReadInfo[i].pDoneSemaphore);
}
sem_destroy(&gCdStreamSema);
+ free(gChannelRequestQ.items);
#else
sem_destroy(&gpReadInfo[channel].pStartSemaphore);
sem_destroy(&gpReadInfo[channel].pDoneSemaphore);
@@ -460,10 +461,11 @@ CdStreamAddImage(char const *path)
// Fix case sensitivity and backslashes.
if (gImgFiles[gNumImages] == -1) {
- char *r = (char*)alloca(strlen(path) + 2);
- if (casepath(path, r))
+ char* real = casepath(path, false);
+ if (real)
{
- gImgFiles[gNumImages] = open(r, _gdwCdStreamFlags);
+ gImgFiles[gNumImages] = open(real, _gdwCdStreamFlags);
+ free(real);
}
}
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp
index 23eaa8dd..99be816f 100644
--- a/src/core/Collision.cpp
+++ b/src/core/Collision.cpp
@@ -38,7 +38,7 @@ void
CCollision::Init(void)
{
ms_colModelCache.Init(NUMCOLCACHELINKS);
- ms_collisionInMemory = LEVEL_NONE;
+ ms_collisionInMemory = LEVEL_GENERIC;
}
void
@@ -59,7 +59,7 @@ CCollision::Update(void)
return;
// hardcode a level if there are no zones
- if(level == LEVEL_NONE){
+ if(level == LEVEL_GENERIC){
if(CGame::currLevel == LEVEL_INDUSTRIAL &&
playerCoors.x < 400.0f){
level = LEVEL_COMMERCIAL;
@@ -78,7 +78,7 @@ CCollision::Update(void)
}
}
}
- if(level != LEVEL_NONE && level != CGame::currLevel)
+ if(level != LEVEL_GENERIC && level != CGame::currLevel)
CGame::currLevel = level;
if(ms_collisionInMemory != CGame::currLevel)
LoadCollisionWhenINeedIt(forceLevelChange);
@@ -95,10 +95,10 @@ GetCollisionInSectorList(CPtrList &list)
for(node = list.first; node; node = node->next){
e = (CEntity*)node->item;
level = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel()->level;
- if(level != LEVEL_NONE)
+ if(level != LEVEL_GENERIC)
return (eLevelName)level;
}
- return LEVEL_NONE;
+ return LEVEL_GENERIC;
}
// Get a level this sector is in based on collision models
@@ -108,15 +108,15 @@ GetCollisionInSector(CSector &sect)
int level;
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_BUILDINGS]);
- if(level == LEVEL_NONE)
+ if(level == LEVEL_GENERIC)
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_BUILDINGS_OVERLAP]);
- if(level == LEVEL_NONE)
+ if(level == LEVEL_GENERIC)
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_OBJECTS]);
- if(level == LEVEL_NONE)
+ if(level == LEVEL_GENERIC)
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_OBJECTS_OVERLAP]);
- if(level == LEVEL_NONE)
+ if(level == LEVEL_GENERIC)
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_DUMMIES]);
- if(level == LEVEL_NONE)
+ if(level == LEVEL_GENERIC)
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_DUMMIES_OVERLAP]);
return (eLevelName)level;
}
@@ -133,7 +133,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
int xmin, xmax, ymin, ymax;
int x, y;
- level = LEVEL_NONE;
+ level = LEVEL_GENERIC;
playerCoors = FindPlayerCoors();
sx = CWorld::GetSectorIndexX(playerCoors.x);
@@ -161,8 +161,8 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
for(x = xmin; x <= xmax; x++)
for(y = ymin; y <= ymax; y++){
l = GetCollisionInSector(*CWorld::GetSector(x, y));
- if(l != LEVEL_NONE){
- if(level == LEVEL_NONE)
+ if(l != LEVEL_GENERIC){
+ if(level == LEVEL_GENERIC)
level = l;
if(level != l)
multipleLevels = true;
@@ -173,19 +173,23 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
if(multipleLevels && veh && veh->IsBoat())
for(ei = veh->m_entryInfoList.first; ei; ei = ei->next){
level = GetCollisionInSector(*ei->sector);
- if(level != LEVEL_NONE)
+ if(level != LEVEL_GENERIC)
break;
}
}
if(level == CGame::currLevel || forceChange){
CTimer::Stop();
+#ifndef NO_ISLAND_LOADING
DMAudio.SetEffectsFadeVol(0);
CPad::StopPadsShaking();
LoadCollisionScreen(CGame::currLevel);
DMAudio.Service();
+#endif
CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false);
+
+#ifndef NO_ISLAND_LOADING
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
@@ -196,19 +200,27 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
CStreaming::RemoveUnusedModelsInLoadedList();
CGame::TidyUpMemory(true, true);
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
+#endif
+
ms_collisionInMemory = CGame::currLevel;
CReplay::EmptyReplayBuffer();
- if(CGame::currLevel != LEVEL_NONE)
+#ifndef NO_ISLAND_LOADING
+ if(CGame::currLevel != LEVEL_GENERIC)
LoadSplash(GetLevelSplashScreen(CGame::currLevel));
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
CStreaming::RequestBigBuildings(CGame::currLevel);
+#endif
CStreaming::LoadAllRequestedModels(true);
+#ifndef NO_ISLAND_LOADING
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
CGame::TidyUpMemory(true, true);
+#endif
CTimer::Update();
+#ifndef NO_ISLAND_LOADING
DMAudio.SetEffectsFadeVol(127);
+#endif
}
}
@@ -217,10 +229,23 @@ CCollision::SortOutCollisionAfterLoad(void)
{
if(ms_collisionInMemory == CGame::currLevel)
return;
-
+#ifndef NO_ISLAND_LOADING
CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel);
- if(CGame::currLevel != LEVEL_NONE){
+#endif
+ if (CGame::currLevel != LEVEL_GENERIC) {
+#ifdef NO_ISLAND_LOADING
+ static bool bAlreadyLoaded = false;
+ if (bAlreadyLoaded) {
+ ms_collisionInMemory = CGame::currLevel;
+ return;
+ }
+ bAlreadyLoaded = true;
+ CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL);
+ CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL);
+ CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN);
+#else
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
+#endif
if(!CGame::playingIntro)
LoadSplash(GetLevelSplashScreen(CGame::currLevel));
}
@@ -370,7 +395,7 @@ CCollision::TestVerticalLineBox(const CColLine &line, const CColBox &box)
}
bool
-CCollision::TestLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane)
+CCollision::TestLineTriangle(const CColLine &line, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane)
{
float t;
CVector normal;
@@ -385,9 +410,9 @@ CCollision::TestLineTriangle(const CColLine &line, const CVector *verts, const C
// find point of intersection
CVector p = line.p0 + (line.p1-line.p0)*t;
- const CVector &va = verts[tri.a];
- const CVector &vb = verts[tri.b];
- const CVector &vc = verts[tri.c];
+ const CVector &va = verts[tri.a].Get();
+ const CVector &vb = verts[tri.b].Get();
+ const CVector &vc = verts[tri.c].Get();
CVector2D vec1, vec2, vec3, vect;
// We do the test in 2D. With the plane direction we
@@ -480,15 +505,16 @@ CCollision::TestLineSphere(const CColLine &line, const CColSphere &sph)
bool
CCollision::TestSphereTriangle(const CColSphere &sphere,
- const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane)
+ const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane)
{
// If sphere and plane don't intersect, no collision
- if(Abs(plane.CalcPoint(sphere.center)) > sphere.radius)
+ float planedist = plane.CalcPoint(sphere.center);
+ if(Abs(planedist) > sphere.radius)
return false;
- const CVector &va = verts[tri.a];
- const CVector &vb = verts[tri.b];
- const CVector &vc = verts[tri.c];
+ const CVector &va = verts[tri.a].Get();
+ const CVector &vb = verts[tri.b].Get();
+ const CVector &vc = verts[tri.c].Get();
// calculate two orthogonal basis vectors for the triangle
CVector vec2 = vb - va;
@@ -512,23 +538,29 @@ CCollision::TestSphereTriangle(const CColSphere &sphere,
int testcase = insideAB + insideAC + insideBC;
float dist = 0.0f;
- if(testcase == 1){
+ switch(testcase){
+ case 1:
// closest to a vertex
if(insideAB) dist = (sphere.center - vc).Magnitude();
else if(insideAC) dist = (sphere.center - vb).Magnitude();
else if(insideBC) dist = (sphere.center - va).Magnitude();
else assert(0);
- }else if(testcase == 2){
+ break;
+ case 2:
// closest to an edge
+ // looks like original game as DistToLine manually inlined
if(!insideAB) dist = DistToLine(&va, &vb, &sphere.center);
else if(!insideAC) dist = DistToLine(&va, &vc, &sphere.center);
else if(!insideBC) dist = DistToLine(&vb, &vc, &sphere.center);
else assert(0);
- }else if(testcase == 3){
+ break;
+ case 3:
// center is in triangle
- return true;
- }else
- assert(0); // front fell off
+ dist = Abs(planedist);
+ break;
+ default:
+ assert(0);
+ }
return dist < sphere.radius;
}
@@ -547,21 +579,24 @@ CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColMod
if(!TestLineBox(newline, model.boundingBox))
return false;
- for(i = 0; i < model.numSpheres; i++)
- if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_TRANSPARENT_CLOTH)
- if(TestLineSphere(newline, model.spheres[i]))
- return true;
+ for(i = 0; i < model.numSpheres; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue;
+ if(TestLineSphere(newline, model.spheres[i]))
+ return true;
+ }
- for(i = 0; i < model.numBoxes; i++)
- if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_TRANSPARENT_CLOTH)
- if(TestLineBox(newline, model.boxes[i]))
- return true;
+ for(i = 0; i < model.numBoxes; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue;
+ if(TestLineBox(newline, model.boxes[i]))
+ return true;
+ }
CalculateTrianglePlanes(&model);
- for(i = 0; i < model.numTriangles; i++)
- if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_TRANSPARENT_CLOTH)
- if(TestLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i]))
- return true;
+ for(i = 0; i < model.numTriangles; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue;
+ if(TestLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i]))
+ return true;
+ }
return false;
}
@@ -836,16 +871,16 @@ CCollision::ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CC
bool
CCollision::ProcessVerticalLineTriangle(const CColLine &line,
- const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane,
+ const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane,
CColPoint &point, float &mindist, CStoredCollPoly *poly)
{
float t;
CVector normal;
const CVector &p0 = line.p0;
- const CVector &va = verts[tri.a];
- const CVector &vb = verts[tri.b];
- const CVector &vc = verts[tri.c];
+ const CVector &va = verts[tri.a].Get();
+ const CVector &vb = verts[tri.b].Get();
+ const CVector &vc = verts[tri.c].Get();
// early out bound rect test
if(p0.x < va.x && p0.x < vb.x && p0.x < vc.x) return false;
@@ -910,6 +945,7 @@ CCollision::ProcessVerticalLineTriangle(const CColLine &line,
if(CrossProduct2D(vec2-vec1, vect-vec1) < 0.0f) return false;
if(CrossProduct2D(vec3-vec1, vect-vec1) > 0.0f) return false;
if(CrossProduct2D(vec3-vec2, vect-vec2) < 0.0f) return false;
+ if(t >= mindist) return false;
point.point = p;
point.normal = normal;
point.surfaceA = 0;
@@ -935,16 +971,12 @@ CCollision::IsStoredPolyStillValidVerticalLine(const CVector &pos, float z, CCol
return false;
// maybe inlined?
- CColTriangle tri;
- tri.a = 0;
- tri.b = 1;
- tri.c = 2;
CColTrianglePlane plane;
- plane.Set(poly->verts, tri);
+ plane.Set(poly->verts[0], poly->verts[1], poly->verts[2]);
- const CVector &va = poly->verts[tri.a];
- const CVector &vb = poly->verts[tri.b];
- const CVector &vc = poly->verts[tri.c];
+ const CVector &va = poly->verts[0];
+ const CVector &vb = poly->verts[1];
+ const CVector &vc = poly->verts[2];
CVector p0 = pos;
CVector p1(pos.x, pos.y, z);
@@ -1009,7 +1041,7 @@ CCollision::IsStoredPolyStillValidVerticalLine(const CVector &pos, float z, CCol
bool
CCollision::ProcessLineTriangle(const CColLine &line ,
- const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane,
+ const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane,
CColPoint &point, float &mindist)
{
float t;
@@ -1028,9 +1060,9 @@ CCollision::ProcessLineTriangle(const CColLine &line ,
// find point of intersection
CVector p = line.p0 + (line.p1-line.p0)*t;
- const CVector &va = verts[tri.a];
- const CVector &vb = verts[tri.b];
- const CVector &vc = verts[tri.c];
+ const CVector &va = verts[tri.a].Get();
+ const CVector &vb = verts[tri.b].Get();
+ const CVector &vc = verts[tri.c].Get();
CVector2D vec1, vec2, vec3, vect;
switch(plane.dir){
@@ -1076,6 +1108,7 @@ CCollision::ProcessLineTriangle(const CColLine &line ,
if(CrossProduct2D(vec2-vec1, vect-vec1) < 0.0f) return false;
if(CrossProduct2D(vec3-vec1, vect-vec1) > 0.0f) return false;
if(CrossProduct2D(vec3-vec2, vect-vec2) < 0.0f) return false;
+ if(t >= mindist) return false;
point.point = p;
point.normal = normal;
point.surfaceA = 0;
@@ -1088,7 +1121,7 @@ CCollision::ProcessLineTriangle(const CColLine &line ,
bool
CCollision::ProcessSphereTriangle(const CColSphere &sphere,
- const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane,
+ const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane,
CColPoint &point, float &mindistsq)
{
// If sphere and plane don't intersect, no collision
@@ -1097,9 +1130,9 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere,
if(Abs(planedist) > sphere.radius || distsq > mindistsq)
return false;
- const CVector &va = verts[tri.a];
- const CVector &vb = verts[tri.b];
- const CVector &vc = verts[tri.c];
+ const CVector &va = verts[tri.a].Get();
+ const CVector &vb = verts[tri.b].Get();
+ const CVector &vc = verts[tri.c].Get();
// calculate two orthogonal basis vectors for the triangle
CVector normal;
@@ -1126,25 +1159,31 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere,
int testcase = insideAB + insideAC + insideBC;
float dist = 0.0f;
CVector p;
- if(testcase == 1){
+ switch(testcase){
+ case 1:
// closest to a vertex
if(insideAB) p = vc;
else if(insideAC) p = vb;
else if(insideBC) p = va;
else assert(0);
dist = (sphere.center - p).Magnitude();
- }else if(testcase == 2){
+ break;
+ case 2:
// closest to an edge
+ // looks like original game as DistToLine manually inlined
if(!insideAB) dist = DistToLine(&va, &vb, &sphere.center, p);
else if(!insideAC) dist = DistToLine(&va, &vc, &sphere.center, p);
else if(!insideBC) dist = DistToLine(&vb, &vc, &sphere.center, p);
else assert(0);
- }else if(testcase == 3){
+ break;
+ case 3:
// center is in triangle
dist = Abs(planedist);
p = sphere.center - normal*planedist;
- }else
- assert(0); // front fell off
+ break;
+ default:
+ assert(0);
+ }
if(dist >= sphere.radius || dist*dist >= mindistsq)
return false;
@@ -1178,18 +1217,21 @@ CCollision::ProcessLineOfSight(const CColLine &line,
return false;
float coldist = mindist;
- for(i = 0; i < model.numSpheres; i++)
- if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_TRANSPARENT_CLOTH)
- ProcessLineSphere(newline, model.spheres[i], point, coldist);
+ for(i = 0; i < model.numSpheres; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue;
+ ProcessLineSphere(newline, model.spheres[i], point, coldist);
+ }
- for(i = 0; i < model.numBoxes; i++)
- if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_TRANSPARENT_CLOTH)
- ProcessLineBox(newline, model.boxes[i], point, coldist);
+ for(i = 0; i < model.numBoxes; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue;
+ ProcessLineBox(newline, model.boxes[i], point, coldist);
+ }
CalculateTrianglePlanes(&model);
- for(i = 0; i < model.numTriangles; i++)
- if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_TRANSPARENT_CLOTH)
- ProcessLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist);
+ for(i = 0; i < model.numTriangles; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue;
+ ProcessLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist);
+ }
if(coldist < mindist){
point.point = matrix * point.point;
@@ -1218,24 +1260,27 @@ CCollision::ProcessVerticalLine(const CColLine &line,
return false;
float coldist = mindist;
- for(i = 0; i < model.numSpheres; i++)
- if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_TRANSPARENT_CLOTH)
- ProcessLineSphere(newline, model.spheres[i], point, coldist);
+ for(i = 0; i < model.numSpheres; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue;
+ ProcessLineSphere(newline, model.spheres[i], point, coldist);
+ }
- for(i = 0; i < model.numBoxes; i++)
- if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_TRANSPARENT_CLOTH)
- ProcessLineBox(newline, model.boxes[i], point, coldist);
+ for(i = 0; i < model.numBoxes; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue;
+ ProcessLineBox(newline, model.boxes[i], point, coldist);
+ }
CalculateTrianglePlanes(&model);
TempStoredPoly.valid = false;
- for(i = 0; i < model.numTriangles; i++)
- if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_TRANSPARENT_CLOTH)
- ProcessVerticalLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist, &TempStoredPoly);
+ for(i = 0; i < model.numTriangles; i++){
+ if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue;
+ ProcessVerticalLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist, &TempStoredPoly);
+ }
if(coldist < mindist){
point.point = matrix * point.point;
point.normal = Multiply3x3(matrix, point.normal);
- if(poly && TempStoredPoly.valid){
+ if(TempStoredPoly.valid && poly){
*poly = TempStoredPoly;
poly->verts[0] = matrix * poly->verts[0];
poly->verts[1] = matrix * poly->verts[1];
@@ -1934,7 +1979,7 @@ CColLine::Set(const CVector &p0, const CVector &p1)
}
void
-CColTriangle::Set(const CVector *, int a, int b, int c, uint8 surf, uint8 piece)
+CColTriangle::Set(const CompressedVector *, int a, int b, int c, uint8 surf, uint8 piece)
{
this->a = a;
this->b = b;
@@ -1943,12 +1988,8 @@ CColTriangle::Set(const CVector *, int a, int b, int c, uint8 surf, uint8 piece)
}
void
-CColTrianglePlane::Set(const CVector *v, CColTriangle &tri)
+CColTrianglePlane::Set(const CVector &va, const CVector &vb, const CVector &vc)
{
- const CVector &va = v[tri.a];
- const CVector &vb = v[tri.b];
- const CVector &vc = v[tri.c];
-
normal = CrossProduct(vc-va, vb-va);
normal.Normalise();
dist = DotProduct(normal, va);
@@ -2038,7 +2079,7 @@ CColModel::GetLinkPtr(void)
void
CColModel::GetTrianglePoint(CVector &v, int i) const
{
- v = vertices[i];
+ v = vertices[i].Get();
}
CColModel&
@@ -2117,7 +2158,7 @@ CColModel::operator=(const CColModel &other)
if(vertices)
RwFree(vertices);
if(numVerts){
- vertices = (CVector*)RwMalloc(numVerts*sizeof(CVector));
+ vertices = (CompressedVector*)RwMalloc(numVerts*sizeof(CompressedVector));
for(i = 0; i < numVerts; i++)
vertices[i] = other.vertices[i];
}
diff --git a/src/core/Collision.h b/src/core/Collision.h
index 895f012a..d988f0c2 100644
--- a/src/core/Collision.h
+++ b/src/core/Collision.h
@@ -10,6 +10,19 @@
#define MAX_COLLISION_POINTS 32
#endif
+struct CompressedVector
+{
+#ifdef COMPRESSED_COL_VECTORS
+ int16 x, y, z;
+ CVector Get(void) const { return CVector(x, y, z)/128.0f; };
+ void Set(float x, float y, float z) { this->x = x*128.0f; this->y = y*128.0f; this->z = z*128.0f; };
+#else
+ float x, y, z;
+ CVector Get(void) const { return CVector(x, y, z); };
+ void Set(float x, float y, float z) { this->x = x; this->y = y; this->z = z; };
+#endif
+};
+
struct CColSphere
{
CVector center;
@@ -51,7 +64,7 @@ struct CColTriangle
uint16 c;
uint8 surface;
- void Set(const CVector *v, int a, int b, int c, uint8 surf, uint8 piece);
+ void Set(const CompressedVector *v, int a, int b, int c, uint8 surf, uint8 piece);
};
struct CColTrianglePlane
@@ -60,7 +73,8 @@ struct CColTrianglePlane
float dist;
uint8 dir;
- void Set(const CVector *v, CColTriangle &tri);
+ void Set(const CVector &va, const CVector &vb, const CVector &vc);
+ void Set(const CompressedVector *v, CColTriangle &tri) { Set(v[tri.a].Get(), v[tri.b].Get(), v[tri.c].Get()); }
void GetNormal(CVector &n) const { n = normal; }
float CalcPoint(const CVector &v) const { return DotProduct(normal, v) - dist; };
};
@@ -94,11 +108,11 @@ struct CColModel
int16 numBoxes;
int16 numTriangles;
int32 level;
- bool ownsCollisionVolumes;
+ bool ownsCollisionVolumes; // missing on PS2
CColSphere *spheres;
CColLine *lines;
CColBox *boxes;
- CVector *vertices;
+ CompressedVector *vertices;
CColTriangle *triangles;
CColTrianglePlane *trianglePlanes;
@@ -136,18 +150,18 @@ public:
static bool TestSphereBox(const CColSphere &sph, const CColBox &box);
static bool TestLineBox(const CColLine &line, const CColBox &box);
static bool TestVerticalLineBox(const CColLine &line, const CColBox &box);
- static bool TestLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane);
+ static bool TestLineTriangle(const CColLine &line, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane);
static bool TestLineSphere(const CColLine &line, const CColSphere &sph);
- static bool TestSphereTriangle(const CColSphere &sphere, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane);
+ static bool TestSphereTriangle(const CColSphere &sphere, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane);
static bool TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, bool ignoreSeeThrough);
static bool ProcessSphereSphere(const CColSphere &s1, const CColSphere &s2, CColPoint &point, float &mindistsq);
static bool ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoint &point, float &mindistsq);
static bool ProcessLineBox(const CColLine &line, const CColBox &box, CColPoint &point, float &mindist);
- static bool ProcessVerticalLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist, CStoredCollPoly *poly);
- static bool ProcessLineTriangle(const CColLine &line , const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist);
+ static bool ProcessVerticalLineTriangle(const CColLine &line, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist, CStoredCollPoly *poly);
+ static bool ProcessLineTriangle(const CColLine &line , const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist);
static bool ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CColPoint &point, float &mindist);
- static bool ProcessSphereTriangle(const CColSphere &sph, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq);
+ static bool ProcessSphereTriangle(const CColSphere &sph, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq);
static bool ProcessLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough);
static bool ProcessVerticalLine(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough, CStoredCollPoly *poly);
static int32 ProcessColModels(const CMatrix &matrixA, CColModel &modelA, const CMatrix &matrixB, CColModel &modelB, CColPoint *spherepoints, CColPoint *linepoints, float *linedists);
diff --git a/src/core/Directory.cpp b/src/core/Directory.cpp
index cc4d65d8..05344065 100644
--- a/src/core/Directory.cpp
+++ b/src/core/Directory.cpp
@@ -30,7 +30,8 @@ CDirectory::ReadDirFile(const char *filename)
bool
CDirectory::WriteDirFile(const char *filename)
{
- int fd, n;
+ int fd;
+ size_t n;
fd = CFileMgr::OpenFileForWriting(filename);
n = CFileMgr::Write(fd, (char*)entries, numEntries*sizeof(DirectoryInfo));
CFileMgr::CloseFile(fd);
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index 3c4ed040..b4da1a5e 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -104,7 +104,9 @@ CFileLoader::LoadLevel(const char *filename)
LoadingScreenLoadingFile(line + 8);
LoadMapZones(line + 8);
}else if(strncmp(line, "SPLASH", 6) == 0){
+#ifndef DISABLE_LOADING_SCREEN
LoadSplash(GetRandomSplashScreen());
+#endif
}else if(strncmp(line, "CDIMAGE", 7) == 0){
CdStreamAddImage(line + 8);
}
@@ -262,12 +264,12 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
int32 numVertices = *(int16*)buf;
buf += 4;
if(numVertices > 0){
- model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
+ model.vertices = (CompressedVector*)RwMalloc(numVertices*sizeof(CompressedVector));
for(i = 0; i < numVertices; i++){
- model.vertices[i] = *(CVector*)buf;
- if(Abs(model.vertices[i].x) >= 256.0f ||
- Abs(model.vertices[i].y) >= 256.0f ||
- Abs(model.vertices[i].z) >= 256.0f)
+ model.vertices[i].Set(*(float*)buf, *(float*)(buf+4), *(float*)(buf+8));
+ if(Abs(*(float*)buf) >= 256.0f ||
+ Abs(*(float*)(buf+4)) >= 256.0f ||
+ Abs(*(float*)(buf+8)) >= 256.0f)
printf("%s:Collision volume too big\n", modelname);
buf += 12;
}
diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp
index 1939c861..ac51f8de 100644
--- a/src/core/FileMgr.cpp
+++ b/src/core/FileMgr.cpp
@@ -4,6 +4,7 @@
#include <direct.h>
#endif
#include "common.h"
+#include "crossplatform.h"
#include "FileMgr.h"
@@ -31,19 +32,16 @@ static myFILE myfiles[NUMFILES];
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
-#include "crossplatform.h"
#define _getcwd getcwd
// Case-insensitivity on linux (from https://github.com/OneSadCookie/fcaseopen)
void mychdir(char const *path)
{
- char *r = (char*)alloca(strlen(path) + 2);
- if (casepath(path, r))
- {
+ char* r = casepath(path, false);
+ if (r) {
chdir(r);
- }
- else
- {
+ free(r);
+ } else {
errno = ENOENT;
}
}
@@ -73,30 +71,7 @@ found:
*p++ = 'b';
*p = '\0';
-#if !defined(_WIN32)
- char *newPath = strdup(filename);
- // Normally casepath() fixes backslashes, but if the mode is sth other than r/rb it will create new file with backslashes on linux, so fix backslashes here
- char *nextBs;
- while(nextBs = strstr(newPath, "\\")){
- *nextBs = '/';
- }
-#else
- const char *newPath = filename;
-#endif
-
- myfiles[fd].file = fopen(newPath, realmode);
-// Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/)
-#if !defined(_WIN32)
- if (!myfiles[fd].file) {
- char *r = (char*)alloca(strlen(newPath) + 2);
- if (casepath(newPath, r))
- {
- myfiles[fd].file = fopen(r, realmode);
- }
- }
-
- free(newPath);
-#endif
+ myfiles[fd].file = fcaseopen(filename, realmode);
if(myfiles[fd].file == nil)
return 0;
return fd;
@@ -163,7 +138,7 @@ myfgets(char *buf, int len, int fd)
return buf;
}
-static int
+static size_t
myfread(void *buf, size_t elt, size_t n, int fd)
{
if(myfiles[fd].isText){
@@ -184,7 +159,7 @@ myfread(void *buf, size_t elt, size_t n, int fd)
return fread(buf, elt, n, myfiles[fd].file);
}
-static int
+static size_t
myfwrite(void *buf, size_t elt, size_t n, int fd)
{
if(myfiles[fd].isText){
@@ -265,11 +240,11 @@ CFileMgr::SetDirMyDocuments(void)
mychdir(_psGetUserFilesFolder());
}
-int
+size_t
CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode)
{
int fd;
- int n, len;
+ size_t n, len;
fd = myfopen(file, mode);
if(fd == 0)
@@ -298,13 +273,13 @@ CFileMgr::OpenFileForWriting(const char *file)
return OpenFile(file, "wb");
}
-int
+size_t
CFileMgr::Read(int fd, const char *buf, int len)
{
return myfread((void*)buf, 1, len, fd);
}
-int
+size_t
CFileMgr::Write(int fd, const char *buf, int len)
{
return myfwrite((void*)buf, 1, len, fd);
diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h
index 1d0faf50..0ad9daa7 100644
--- a/src/core/FileMgr.h
+++ b/src/core/FileMgr.h
@@ -9,12 +9,12 @@ public:
static void ChangeDir(const char *dir);
static void SetDir(const char *dir);
static void SetDirMyDocuments(void);
- static int LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
+ static size_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
static int OpenFile(const char *file, const char *mode);
static int OpenFile(const char *file) { return OpenFile(file, "rb"); }
static int OpenFileForWriting(const char *file);
- static int Read(int fd, const char *buf, int len);
- static int Write(int fd, const char *buf, int len);
+ static size_t Read(int fd, const char *buf, int len);
+ static size_t Write(int fd, const char *buf, int len);
static bool Seek(int fd, int offset, int whence);
static bool ReadLine(int fd, char *buf, int len);
static int CloseFile(int fd);
diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp
index 933c73da..c6dece6a 100644
--- a/src/core/Fire.cpp
+++ b/src/core/Fire.cpp
@@ -128,11 +128,8 @@ CFire::ProcessFire(void)
lightpos.z = m_vecPos.z + 5.0f;
if (!m_pEntity) {
- CShadows::StoreStaticShadow((uintptr)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos,
- 7.0f, 0.0f, 0.0f, -7.0f,
- 255, // this is 0 on PC which results in no shadow
- nRandNumber / 2, nRandNumber / 2, 0,
- 10.0f, 1.0f, 40.0f, 0, 0.0f);
+ CShadows::StoreStaticShadow((uintptr)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, 7.0f, 0.0f, 0.0f, -7.0f, 0, nRandNumber / 2,
+ nRandNumber / 2, 0, 10.0f, 1.0f, 40.0f, 0, 0.0f);
}
fGreen = nRandNumber / 128;
fRed = nRandNumber / 128;
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 3aefa005..95d5f6e6 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -112,6 +112,10 @@ int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt;
int32 CMenuManager::m_PrefsMusicVolume = 102;
int32 CMenuManager::m_PrefsSfxVolume = 102;
+#ifdef CUTSCENE_BORDERS_SWITCH
+bool CMenuManager::m_PrefsCutsceneBorders = true;
+#endif
+
char CMenuManager::m_PrefsSkinFile[256] = DEFAULT_SKIN_NAME;
int32 CMenuManager::m_KeyPressedCode = -1;
@@ -952,10 +956,10 @@ CMenuManager::Draw()
CFont::SetDropShadowPosition(0);
if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) {
m_nHoverOption = HOVEROPTION_NOT_HOVERING;
- m_nCurrOption = m_nPrevOption = 0;
+ m_nCurrOption = m_nOptionMouseHovering = 0;
} else {
m_nHoverOption = HOVEROPTION_RANDOM_ITEM;
- m_nCurrOption = m_nPrevOption = 1;
+ m_nCurrOption = m_nOptionMouseHovering = 1;
}
return;
}
@@ -1217,8 +1221,10 @@ CMenuManager::Draw()
rightText = option.drawFunc(&isOptionDisabled);
}
}
- } else
+ } else {
+ debug("A- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, i, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu, option.screen, option.screenOptionOrder);
assert(0 && "Custom frontend options is borked");
+ }
break;
#endif
@@ -1250,7 +1256,7 @@ CMenuManager::Draw()
static int oldOption = -99;
static int oldScreen = m_nCurrScreen;
- m_nPrevOption = rowToCheck;
+ m_nOptionMouseHovering = rowToCheck;
if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) {
m_nCurrOption = rowToCheck;
m_bShowMouse = true;
@@ -1974,10 +1980,10 @@ CMenuManager::DrawControllerSetupScreen()
float curOptY = i * rowHeight + yStart;
if (m_nMousePosY > MENU_Y(curOptY) && m_nMousePosY < MENU_Y(rowHeight + curOptY)) {
- if (m_nPrevOption != i && m_nCurrExLayer == HOVEROPTION_LIST)
+ if (m_nOptionMouseHovering != i && m_nCurrExLayer == HOVEROPTION_LIST)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0);
- m_nPrevOption = i;
+ m_nOptionMouseHovering = i;
if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) {
m_nCurrExLayer = HOVEROPTION_LIST;
m_nSelectedListRow = i;
@@ -2598,7 +2604,7 @@ CMenuManager::DrawPlayerSetupScreen()
char nameTemp[256];
for (m_pSelectedSkin = m_pSkinListHead.nextSkin; m_pSelectedSkin; m_pSelectedSkin = m_pSelectedSkin->nextSkin) {
// Drop extension
- int oldLength = strlen(m_pSelectedSkin->skinNameDisplayed);
+ int oldLength = (int)strlen(m_pSelectedSkin->skinNameDisplayed);
m_pSelectedSkin->skinNameDisplayed[oldLength - 4] = '\0';
m_pSelectedSkin->skinNameOriginal[oldLength - 4] = '\0';
@@ -2688,7 +2694,7 @@ CMenuManager::DrawPlayerSetupScreen()
if (m_nMousePosX > MENU_X_LEFT_ALIGNED(PLAYERSETUP_LIST_LEFT) && m_nMousePosX < MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT)) {
if (m_nMousePosY > MENU_Y(rowStartY) && m_nMousePosY < MENU_Y(rowEndY)) {
- m_nPrevOption = rowIdx;
+ m_nOptionMouseHovering = rowIdx;
if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) {
m_nCurrExLayer = HOVEROPTION_LIST;
}
@@ -3066,7 +3072,6 @@ CMenuManager::InitialiseChangedLanguageSettings()
}
#ifdef CUSTOM_FRONTEND_OPTIONS
- RemoveCustomFrontendOptions();
CustomFrontendOptionsPopulate();
#endif
}
@@ -3217,6 +3222,9 @@ CMenuManager::LoadSettings()
#ifdef FREE_CAM
CFileMgr::Read(fileHandle, (char*)&TheCamera.bFreeCam, 1);
#endif
+#ifdef CUTSCENE_BORDERS_SWITCH
+ CFileMgr::Read(fileHandle, (char *)&CMenuManager::m_PrefsCutsceneBorders, 1);
+#endif
}
}
@@ -3310,6 +3318,9 @@ CMenuManager::SaveSettings()
#ifdef FREE_CAM
CFileMgr::Write(fileHandle, (char*)&TheCamera.bFreeCam, 1);
#endif
+#ifdef CUTSCENE_BORDERS_SWITCH
+ CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_PrefsCutsceneBorders, 1);
+#endif
}
CFileMgr::CloseFile(fileHandle);
@@ -4014,7 +4025,7 @@ CMenuManager::ProcessButtonPresses(void)
if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_RESUME &&
#endif
(m_nHoverOption == HOVEROPTION_RANDOM_ITEM)) {
- m_nCurrOption = m_nPrevOption;
+ m_nCurrOption = m_nOptionMouseHovering;
optionSelected = true;
}
} else if (CPad::GetPad(0)->GetLeftMouseJustDown()) {
@@ -4028,7 +4039,7 @@ CMenuManager::ProcessButtonPresses(void)
OutputDebugString("FRONTEND RADIO STATION CHANGED");
} else if (m_nHoverOption == HOVEROPTION_RANDOM_ITEM
&& aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) {
- m_nCurrOption = m_nPrevOption;
+ m_nCurrOption = m_nOptionMouseHovering;
optionSelected = true;
}
#else
@@ -4115,7 +4126,7 @@ CMenuManager::ProcessButtonPresses(void)
break;
case HOVEROPTION_RANDOM_ITEM:
if (((m_nCurrOption != 0) || (m_nCurrScreen != MENUPAGE_PAUSE_MENU)) {
- m_nCurrOption = m_nPrevOption;
+ m_nCurrOption = m_nOptionMouseHovering;
optionSelected = true;
}
break;
@@ -4775,8 +4786,10 @@ CMenuManager::ProcessButtonPresses(void)
} else if (option.type == FEOPTION_GOBACK) {
goBack = true;
}
- } else
+ } else {
+ debug("B- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, m_nCurrOption, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, option.screen, option.screenOptionOrder);
assert(0 && "Custom frontend options are borked");
+ }
break;
#endif
@@ -4998,8 +5011,10 @@ CMenuManager::ProcessButtonPresses(void)
}
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
}
- else
+ else {
+ debug("C- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, m_nCurrOption, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, option.screen, option.screenOptionOrder);
assert(0 && "Custom frontend options are borked");
+ }
break;
#endif
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index b07f7260..7b0e2f4b 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -518,7 +518,7 @@ public:
int32 m_nHoverOption;
int32 m_nCurrScreen;
int32 m_nCurrOption;
- int32 m_nPrevOption;
+ int32 m_nOptionMouseHovering;
int32 m_nPrevScreen;
uint32 field_558;
int32 m_nCurrSaveSlot;
@@ -582,6 +582,10 @@ public:
static uint8 m_PrefsPlayerGreen;
static uint8 m_PrefsPlayerBlue;
+#ifdef CUTSCENE_BORDERS_SWITCH
+ static bool m_PrefsCutsceneBorders;
+#endif
+
#ifndef MASTER
static bool m_PrefsMarketing;
static bool m_PrefsDisableTutorials;
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 4c8aaa72..82e6992d 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -149,6 +149,15 @@ CGame::InitialiseOnceBeforeRW(void)
return true;
}
+#ifndef LIBRW
+#ifdef PS2_MATFX
+void ReplaceMatFxCallback();
+#endif // PS2_MATFX
+#ifdef PS2_ALPHA_TEST
+void ReplaceAtomicPipeCallback();
+#endif // PS2_ALPHA_TEST
+#endif // !LIBRW
+
bool
CGame::InitialiseRenderWare(void)
{
@@ -199,7 +208,14 @@ CGame::InitialiseRenderWare(void)
#else
rw::MatFX::modulateEnvMap = false;
#endif
-#endif
+#else
+#ifdef PS2_MATFX
+ ReplaceMatFxCallback();
+#endif // PS2_MATFX
+#ifdef PS2_ALPHA_TEST
+ ReplaceAtomicPipeCallback();
+#endif // PS2_ALPHA_TEST
+#endif // LIBRW
CFont::Initialise();
CHud::Initialise();
@@ -357,9 +373,9 @@ bool CGame::Initialise(const char* datFile)
CStreaming::Init();
CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds();
- CStreaming::RequestBigBuildings(LEVEL_NONE);
+ CStreaming::RequestBigBuildings(LEVEL_GENERIC);
CStreaming::LoadAllRequestedModels(false);
- printf("Streaming uses %dK of its memory", CStreaming::ms_memoryUsed / 1024);
+ printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
CAnimManager::LoadAnimFiles();
CPed::Initialise();
@@ -511,7 +527,7 @@ void CGame::ReInitGameObjectVariables(void)
CTimeCycle::Initialise();
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
- CStreaming::RequestBigBuildings(LEVEL_NONE);
+ CStreaming::RequestBigBuildings(LEVEL_GENERIC);
CStreaming::LoadAllRequestedModels(false);
CPed::Initialise();
CEventList::Initialise();
diff --git a/src/core/Game.h b/src/core/Game.h
index 48f31abc..46e8fc68 100644
--- a/src/core/Game.h
+++ b/src/core/Game.h
@@ -2,7 +2,7 @@
enum eLevelName {
LEVEL_IGNORE = -1, // beware, this is only used in CPhysical's m_nZoneLevel
- LEVEL_NONE = 0,
+ LEVEL_GENERIC = 0,
LEVEL_INDUSTRIAL,
LEVEL_COMMERCIAL,
LEVEL_SUBURBAN
diff --git a/src/core/General.h b/src/core/General.h
index 7ffa99de..dde43c0f 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -108,7 +108,7 @@ public:
if (angle >= TWOPI)
angle -= TWOPI;
- return (int)floorf(angle / DEGTORAD(45.0f));
+ return (int)Floor(angle / DEGTORAD(45.0f));
}
// Unlike usual string comparison functions, these don't care about greater or lesser
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 9065c8ca..7df548aa 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -8,6 +8,7 @@
#include "common.h"
#include "crossplatform.h"
+#include "platform.h"
#ifdef XINPUT
#include <xinput.h>
#pragma comment( lib, "Xinput9_1_0.lib" )
@@ -344,15 +345,14 @@ void AltDodoCheat(void)
#endif
bool
-CControllerState::IsAnyButtonPressed(void)
+CControllerState::CheckForInput(void)
{
return !!RightStickX || !!RightStickY || !!LeftStickX || !!LeftStickY
|| !!DPadUp || !!DPadDown || !!DPadLeft || !!DPadRight
|| !!Triangle || !!Cross || !!Circle || !!Square
|| !!Start || !!Select
|| !!LeftShoulder1 || !!LeftShoulder2 || !!RightShoulder1 || !!RightShoulder2
- || !!LeftShock || !!RightShock
- || !!NetworkTalk;
+ || !!LeftShock || !!RightShock;
}
void
@@ -545,9 +545,9 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
void CPad::UpdateMouse()
{
+#if defined RW_D3D9 || defined RWLIBS
if ( IsForegroundApp() )
{
-#if defined RW_D3D9 || defined RWLIBS
if ( PSGLOBAL(mouse) == nil )
_InputInitialiseMouse();
@@ -584,7 +584,10 @@ void CPad::UpdateMouse()
OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState;
}
+ }
#else
+ if ( IsForegroundApp() && PSGLOBAL(cursorIsInWindow) )
+ {
double xpos = 1.0f, ypos;
glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos);
if (xpos == 0.f)
@@ -622,8 +625,8 @@ void CPad::UpdateMouse()
OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState;
-#endif
}
+#endif
}
CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &State1, CControllerState const &State2)
@@ -1073,8 +1076,15 @@ void CPad::UpdatePads(void)
#else
CapturePad(0);
#endif
+
+ // Improve keyboard input latency part 1
+#ifdef FIX_BUGS
+ OldKeyState = NewKeyState;
+ NewKeyState = TempKeyState;
+#endif
+
#ifdef DETECT_PAD_INPUT_SWITCH
- if (GetPad(0)->PCTempJoyState.IsAnyButtonPressed())
+ if (GetPad(0)->PCTempJoyState.CheckForInput())
IsAffectedByController = true;
else {
#endif
@@ -1084,7 +1094,7 @@ void CPad::UpdatePads(void)
#ifdef DETECT_PAD_INPUT_SWITCH
}
- if (IsAffectedByController && (GetPad(0)->PCTempKeyState.IsAnyButtonPressed() || GetPad(0)->PCTempMouseState.IsAnyButtonPressed()))
+ if (IsAffectedByController && (GetPad(0)->PCTempKeyState.CheckForInput() || GetPad(0)->PCTempMouseState.CheckForInput()))
IsAffectedByController = false;
#endif
@@ -1102,8 +1112,11 @@ void CPad::UpdatePads(void)
GetPad(1)->OldState.Clear();
#endif
+ // Improve keyboard input latency part 2
+#ifndef FIX_BUGS
OldKeyState = NewKeyState;
NewKeyState = TempKeyState;
+#endif
}
void CPad::ProcessPCSpecificStuff(void)
@@ -2635,7 +2648,7 @@ void CPad::ResetCheats(void)
char *CPad::EditString(char *pStr, int32 nSize)
{
- int32 pos = strlen(pStr);
+ int32 pos = (int32)strlen(pStr);
// letters
for ( int32 i = 0; i < ('Z' - 'A' + 1); i++ )
diff --git a/src/core/Pad.h b/src/core/Pad.h
index 6f20571f..8c3bc752 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -29,7 +29,7 @@ public:
float GetRightStickX(void) { return RightStickX/32767.0f; };
float GetRightStickY(void) { return RightStickY/32767.0f; };
- bool IsAnyButtonPressed();
+ bool CheckForInput();
void Clear(void);
};
VALIDATE_SIZE(CControllerState, 0x2A);
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 128b22b4..09b3a499 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -409,7 +409,7 @@ CPlayerInfo::Process(void)
if (veh->m_vehType != VEHICLE_TYPE_BIKE || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
if (veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) {
if (veh->m_vecMoveSpeed.Magnitude() < 0.17f && CTimer::GetTimeScale() >= 0.5f && !veh->bIsInWater) {
- m_pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh);
+ m_pPed->SetObjective(OBJECTIVE_LEAVE_CAR, veh);
}
}
} else {
@@ -553,7 +553,7 @@ CPlayerInfo::Process(void)
veh->m_nZoneLevel = LEVEL_IGNORE;
for (int i = 0; i < ARRAY_SIZE(veh->pPassengers); i++) {
if (veh->pPassengers[i])
- veh->pPassengers[i]->m_nZoneLevel = LEVEL_NONE;
+ veh->pPassengers[i]->m_nZoneLevel = LEVEL_GENERIC;
}
CStats::DistanceTravelledInVehicle += veh->m_fDistanceTravelled;
} else {
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 9406f1bd..05002a3f 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -746,8 +746,8 @@ void CRadar::DrawRadarMap()
DrawRadarMask();
// top left ist (0, 0)
- int x = floorf((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE);
- int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE);
+ int x = Floor((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE);
+ int y = Ceil((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE);
StreamRadarSections(x, y);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
@@ -1251,7 +1251,7 @@ void CRadar::Shutdown()
void CRadar::StreamRadarSections(const CVector &posn)
{
- StreamRadarSections(floorf((2000.0f + posn.x) / 500.0f), ceilf(7.0f - (2000.0f + posn.y) / 500.0f));
+ StreamRadarSections(Floor((2000.0f + posn.x) / 500.0f), Ceil(7.0f - (2000.0f + posn.y) / 500.0f));
}
void CRadar::StreamRadarSections(int32 x, int32 y)
diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp
index 99274e04..9afd8ac3 100644
--- a/src/core/Stats.cpp
+++ b/src/core/Stats.cpp
@@ -16,8 +16,8 @@ int32 CStats::PedsKilledOfThisType[NUM_PEDTYPES];
int32 CStats::TimesDied;
int32 CStats::TimesArrested;
int32 CStats::KillsSinceLastCheckpoint;
-int32 CStats::DistanceTravelledInVehicle;
-int32 CStats::DistanceTravelledOnFoot;
+float CStats::DistanceTravelledInVehicle;
+float CStats::DistanceTravelledOnFoot;
int32 CStats::ProgressMade;
int32 CStats::TotalProgressInGame;
int32 CStats::CarsExploded;
diff --git a/src/core/Stats.h b/src/core/Stats.h
index ae3c0cb4..5dfcf803 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -21,8 +21,8 @@ public:
static int32 TimesDied;
static int32 TimesArrested;
static int32 KillsSinceLastCheckpoint;
- static int32 DistanceTravelledInVehicle;
- static int32 DistanceTravelledOnFoot;
+ static float DistanceTravelledInVehicle;
+ static float DistanceTravelledOnFoot;
static int32 CarsExploded;
static int32 PeopleKilledByPlayer;
static int32 ProgressMade;
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index c961f53d..40189844 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -45,7 +45,7 @@ int32 CStreaming::ms_oldSectorX;
int32 CStreaming::ms_oldSectorY;
int32 CStreaming::ms_streamingBufferSize;
int8 *CStreaming::ms_pStreamingBuffer[2];
-int32 CStreaming::ms_memoryUsed;
+size_t CStreaming::ms_memoryUsed;
CStreamingChannel CStreaming::ms_channel[2];
int32 CStreaming::ms_channelError;
int32 CStreaming::ms_numVehiclesLoaded;
@@ -62,7 +62,7 @@ uint16 CStreaming::ms_loadedGangCars;
int32 CStreaming::ms_imageOffsets[NUMCDIMAGES];
int32 CStreaming::ms_lastImageRead;
int32 CStreaming::ms_imageSize;
-uint32 CStreaming::ms_memoryAvailable;
+size_t CStreaming::ms_memoryAvailable;
int32 desiredNumVehiclesLoaded = 12;
@@ -202,14 +202,15 @@ CStreaming::Init2(void)
// PC only, figure out how much memory we got
#ifdef GTA_PC
#define MB (1024*1024)
- extern unsigned long _dwMemAvailPhys;
+
+ extern size_t _dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10*MB)/2;
if(ms_memoryAvailable < 50*MB)
ms_memoryAvailable = 50*MB;
- desiredNumVehiclesLoaded = (ms_memoryAvailable/MB - 50)/3 + 12;
+ desiredNumVehiclesLoaded = (int32)((ms_memoryAvailable / MB - 50) / 3 + 12);
if(desiredNumVehiclesLoaded > MAXVEHICLESLOADED)
desiredNumVehiclesLoaded = MAXVEHICLESLOADED;
- debug("Memory allocated to Streaming is %dMB", ms_memoryAvailable/MB);
+ debug("Memory allocated to Streaming is %zuMB", ms_memoryAvailable/MB); // original modifier was %d
#undef MB
#endif
@@ -725,7 +726,11 @@ CStreaming::RequestBigBuildings(eLevelName level)
n = CPools::GetBuildingPool()->GetSize()-1;
for(i = n; i >= 0; i--){
b = CPools::GetBuildingPool()->GetSlot(i);
- if(b && b->bIsBIGBuilding && b->m_level == level)
+ if(b && b->bIsBIGBuilding
+#ifndef NO_ISLAND_LOADING
+ && b->m_level == level
+#endif
+ )
RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS);
}
RequestIslands(level);
@@ -735,6 +740,7 @@ CStreaming::RequestBigBuildings(eLevelName level)
void
CStreaming::RequestIslands(eLevelName level)
{
+#ifndef NO_ISLAND_LOADING
switch(level){
case LEVEL_INDUSTRIAL:
RequestModel(islandLODcomInd, BIGBUILDINGFLAGS);
@@ -750,6 +756,7 @@ CStreaming::RequestIslands(eLevelName level)
break;
default: break;
}
+#endif
}
void
@@ -935,12 +942,14 @@ CStreaming::RemoveBuildings(eLevelName level)
void
CStreaming::RemoveUnusedBigBuildings(eLevelName level)
{
+#ifndef NO_ISLAND_LOADING
if(level != LEVEL_INDUSTRIAL)
RemoveBigBuildings(LEVEL_INDUSTRIAL);
if(level != LEVEL_COMMERCIAL)
RemoveBigBuildings(LEVEL_COMMERCIAL);
if(level != LEVEL_SUBURBAN)
RemoveBigBuildings(LEVEL_SUBURBAN);
+#endif
RemoveIslandsNotUsed(level);
}
@@ -960,6 +969,7 @@ DeleteIsland(CEntity *island)
void
CStreaming::RemoveIslandsNotUsed(eLevelName level)
{
+#ifndef NO_ISLAND_LOADING
switch(level){
case LEVEL_INDUSTRIAL:
DeleteIsland(pIslandLODindustEntity);
@@ -977,13 +987,16 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level)
DeleteIsland(pIslandLODcomIndEntity);
break;
default:
+#endif // !NO_ISLAND_LOADING
DeleteIsland(pIslandLODindustEntity);
DeleteIsland(pIslandLODcomIndEntity);
DeleteIsland(pIslandLODcomSubEntity);
DeleteIsland(pIslandLODsubIndEntity);
DeleteIsland(pIslandLODsubComEntity);
+#ifndef NO_ISLAND_LOADING
break;
}
+#endif // !NO_ISLAND_LOADING
}
void
@@ -1073,7 +1086,7 @@ CStreaming::RemoveAllUnusedModels(void)
}
bool
-CStreaming::RemoveReferencedTxds(int32 mem)
+CStreaming::RemoveReferencedTxds(size_t mem)
{
CStreamingInfo *si;
int streamId;
@@ -2189,7 +2202,7 @@ CStreaming::DeleteRwObjectsAfterDeath(const CVector &pos)
}
void
-CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
+CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
{
int ix, iy;
int x, y;
@@ -2370,7 +2383,7 @@ CStreaming::DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y)
}
bool
-CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem)
+CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem)
{
CPtrNode *node;
CEntity *e;
@@ -2391,7 +2404,7 @@ CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem)
}
bool
-CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem)
+CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem)
{
CPtrNode *node;
CEntity *e;
@@ -2418,7 +2431,7 @@ CStreaming::MakeSpaceFor(int32 size)
// the code still happens to work in that case because ms_memoryAvailable is unsigned
// but it's not nice....
- while((uint32)ms_memoryUsed >= ms_memoryAvailable - size)
+ while(ms_memoryUsed >= ms_memoryAvailable - size)
if(!RemoveLeastUsedModel()){
DeleteRwObjectsBehindCamera(ms_memoryAvailable - size);
return;
@@ -2480,7 +2493,7 @@ CStreaming::UpdateForAnimViewer(void)
if (CStreaming::ms_channelError == -1) {
CStreaming::AddModelsToRequestList(CVector(0.0f, 0.0f, 0.0f));
CStreaming::LoadRequestedModels();
- sprintf(gString, "Requested %d, memory size %dK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed);
+ sprintf(gString, "Requested %d, memory size %zuK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed); // original modifier was %d
}
else {
CStreaming::RetryLoadFile(CStreaming::ms_channelError);
diff --git a/src/core/Streaming.h b/src/core/Streaming.h
index 84434769..0b2ff124 100644
--- a/src/core/Streaming.h
+++ b/src/core/Streaming.h
@@ -86,7 +86,7 @@ public:
static int32 ms_oldSectorY;
static int32 ms_streamingBufferSize;
static int8 *ms_pStreamingBuffer[2];
- static int32 ms_memoryUsed;
+ static size_t ms_memoryUsed;
static CStreamingChannel ms_channel[2];
static int32 ms_channelError;
static int32 ms_numVehiclesLoaded;
@@ -103,7 +103,7 @@ public:
static int32 ms_imageOffsets[NUMCDIMAGES];
static int32 ms_lastImageRead;
static int32 ms_imageSize;
- static uint32 ms_memoryAvailable;
+ static size_t ms_memoryAvailable;
static void Init(void);
static void Init2(void);
@@ -140,7 +140,7 @@ public:
static bool RemoveLeastUsedModel(void);
static void RemoveAllUnusedModels(void);
static void RemoveUnusedModelsInLoadedList(void);
- static bool RemoveReferencedTxds(int32 mem);
+ static bool RemoveReferencedTxds(size_t mem);
static int32 GetAvailableVehicleSlot(void);
static bool IsTxdUsedByRequestedModels(int32 txdId);
static bool AddToLoadedVehiclesList(int32 modelId);
@@ -176,11 +176,11 @@ public:
static void DeleteFarAwayRwObjects(const CVector &pos);
static void DeleteAllRwObjects(void);
static void DeleteRwObjectsAfterDeath(const CVector &pos);
- static void DeleteRwObjectsBehindCamera(int32 mem);
+ static void DeleteRwObjectsBehindCamera(size_t mem);
static void DeleteRwObjectsInSectorList(CPtrList &list);
static void DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y);
- static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem);
- static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem);
+ static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem);
+ static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem);
static void LoadScene(const CVector &pos);
diff --git a/src/core/SurfaceTable.h b/src/core/SurfaceTable.h
index 25b5e57d..1f16843d 100644
--- a/src/core/SurfaceTable.h
+++ b/src/core/SurfaceTable.h
@@ -54,6 +54,16 @@ enum
struct CColPoint;
+inline bool
+IsSeeThrough(uint8 surfType)
+{
+ switch(surfType)
+ case SURFACE_GLASS:
+ case SURFACE_TRANSPARENT_CLOTH:
+ return true;
+ return false;
+}
+
class CSurfaceTable
{
static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS];
diff --git a/src/core/TempColModels.cpp b/src/core/TempColModels.cpp
index 1252e2c7..ab73631d 100644
--- a/src/core/TempColModels.cpp
+++ b/src/core/TempColModels.cpp
@@ -36,19 +36,19 @@ CTempColModels::Initialise(void)
#define SET_COLMODEL_SPHERES(colmodel, sphrs)\
colmodel.numSpheres = ARRAY_SIZE(sphrs);\
colmodel.spheres = sphrs;\
- colmodel.level = LEVEL_NONE;\
+ colmodel.level = LEVEL_GENERIC;\
colmodel.ownsCollisionVolumes = false;\
int i;
ms_colModelBBox.boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0);
ms_colModelBBox.boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f), SURFACE_DEFAULT, 0);
- ms_colModelBBox.level = LEVEL_NONE;
+ ms_colModelBBox.level = LEVEL_GENERIC;
for (i = 0; i < ARRAY_SIZE(ms_colModelCutObj); i++) {
ms_colModelCutObj[i].boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0);
ms_colModelCutObj[i].boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f), SURFACE_DEFAULT, 0);
- ms_colModelCutObj[i].level = LEVEL_NONE;
+ ms_colModelCutObj[i].level = LEVEL_GENERIC;
}
// Ped Spheres
diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp
index 7508c9f4..909674d0 100644
--- a/src/core/Wanted.cpp
+++ b/src/core/Wanted.cpp
@@ -161,7 +161,11 @@ CWanted::RegisterCrime(eCrimeType type, const CVector &coors, uint32 id, bool po
void
CWanted::RegisterCrime_Immediately(eCrimeType type, const CVector &coors, uint32 id, bool policeDoesntCare)
{
- if(!AddCrimeToQ(type, id, coors, false, policeDoesntCare))
+#if defined FIX_SIGNIFICANT_BUGS || defined PEDS_REPORT_CRIMES_ON_PHONE
+ if (!AddCrimeToQ(type, id, coors, true, policeDoesntCare))
+#else
+ if (!AddCrimeToQ(type, id, coors, false, policeDoesntCare))
+#endif
ReportCrimeNow(type, coors, policeDoesntCare);
}
@@ -219,6 +223,9 @@ CWanted::ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesnt
chaos *= 0.333f;
switch(type){
case CRIME_POSSESSION_GUN:
+#ifdef PEDS_REPORT_CRIMES_ON_PHONE
+ m_nChaos += 5.0f*chaos;
+#endif
break;
case CRIME_HIT_PED:
m_nChaos += 5.0f*chaos;
@@ -440,6 +447,30 @@ CWanted::Reset(void)
Initialise();
}
+#ifdef PEDS_REPORT_CRIMES_ON_PHONE
+bool
+CrimeShouldBeReportedOnPhone(eCrimeType crime)
+{
+ switch (crime) {
+ case CRIME_POSSESSION_GUN:
+ case CRIME_HIT_PED:
+ case CRIME_HIT_COP:
+ case CRIME_SHOOT_PED:
+ case CRIME_SHOOT_COP:
+ case CRIME_STEAL_CAR:
+ case CRIME_RECKLESS_DRIVING:
+ case CRIME_RUNOVER_PED:
+ case CRIME_RUNOVER_COP:
+ case CRIME_PED_BURNED:
+ case CRIME_COP_BURNED:
+ case CRIME_VEHICLE_BURNED:
+ return true;
+ default:
+ return false;
+ }
+}
+#endif
+
void
CWanted::UpdateCrimesQ(void)
{
@@ -447,6 +478,9 @@ CWanted::UpdateCrimesQ(void)
CCrimeBeingQd &crime = m_aCrimes[i];
if (crime.m_nType != CRIME_NONE) {
+#ifdef PEDS_REPORT_CRIMES_ON_PHONE
+ if (!CrimeShouldBeReportedOnPhone(crime.m_nType))
+#endif
if (CTimer::GetTimeInMilliseconds() > crime.m_nTime + 500 && !crime.m_bReported) {
ReportCrimeNow(crime.m_nType, crime.m_vecPosn, crime.m_bPoliceDoesntCare);
crime.m_bReported = true;
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 8bcce8e7..9f384048 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -1797,7 +1797,7 @@ CWorld::ClearForRestart(void)
CWorld::Remove(pEntity);
delete pEntity;
}
- for(CPtrNode *pNode = GetBigBuildingList(LEVEL_NONE).first; pNode; pNode = pNode->next) {
+ for(CPtrNode *pNode = GetBigBuildingList(LEVEL_GENERIC).first; pNode; pNode = pNode->next) {
CVehicle *pVehicle = (CVehicle *)pNode->item;
if(pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) {
CWorld::Remove(pVehicle);
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 4f491a49..1556731b 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -90,7 +90,7 @@ CTheZones::Init(void)
TotalNumberOfZoneInfos = 1; // why 1?
TotalNumberOfZones = 1;
- m_CurrLevel = LEVEL_NONE;
+ m_CurrLevel = LEVEL_GENERIC;
m_pPlayersZone = &ZoneArray[0];
strcpy(ZoneArray[0].name, "CITYZON");
@@ -100,7 +100,7 @@ CTheZones::Init(void)
ZoneArray[0].maxx = 4000.0f;
ZoneArray[0].maxy = 4000.0f;
ZoneArray[0].maxz = 500.0f;
- ZoneArray[0].level = LEVEL_NONE;
+ ZoneArray[0].level = LEVEL_GENERIC;
for(i = 0; i < NUMMAPZONES; i++){
memset(&MapZoneArray[i], 0, sizeof(CZone));
@@ -116,7 +116,7 @@ CTheZones::Init(void)
MapZoneArray[0].maxx = 4000.0f;
MapZoneArray[0].maxy = 4000.0f;
MapZoneArray[0].maxz = 500.0f;
- MapZoneArray[0].level = LEVEL_NONE;
+ MapZoneArray[0].level = LEVEL_GENERIC;
}
void
@@ -577,7 +577,7 @@ CTheZones::FindZoneForPoint(const CVector &pos)
return LEVEL_COMMERCIAL;
if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON"))))
return LEVEL_SUBURBAN;
- return LEVEL_NONE;
+ return LEVEL_GENERIC;
}
void
diff --git a/src/core/common.h b/src/core/common.h
index 4bf1aebd..ebb3acb0 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -17,7 +17,11 @@
#if defined _WIN32 && defined WITHD3D
#include <windows.h>
+#ifndef USE_D3D9
#include <d3d8types.h>
+#else
+#include <d3d9types.h>
+#endif
#endif
#include <rwcore.h>
@@ -37,6 +41,7 @@
#define HIERNODEINFO(hier) ((hier)->pNodeInfo)
#define HIERNODEID(hier, i) ((hier)->pNodeInfo[i].nodeID)
#define HANIMFRAME(anim, i) ((RwUInt8*)(anim)->pFrames + (i)*(anim)->interpInfo->keyFrameSize)
+#define RpHAnimStdInterpFrame RpHAnimStdKeyFrame
#endif
#ifdef RWHALFPIXEL
diff --git a/src/core/config.h b/src/core/config.h
index ed36a493..94a35782 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -158,6 +158,7 @@ enum Config {
#if defined GTA_PS2
# define GTA_PS2_STUFF
# define RANDOMSPLASH
+# define COMPRESSED_COL_VECTORS
#elif defined GTA_PC
# define GTA3_1_1_PATCH
//# define GTA3_STEAM_PATCH
@@ -190,7 +191,6 @@ enum Config {
#endif
#define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more
-#define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things
#define MORE_LANGUAGES // Add more translations to the game
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
@@ -198,8 +198,12 @@ enum Config {
#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
#define USE_TXD_CDIMAGE // generate and load textures from txd.img
+#define PS2_ALPHA_TEST // emulate ps2 alpha test
#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
+#define DISABLE_LOADING_SCREEN // disable the loading screen which vastly improves the loading time
+//#define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
//#define USE_TEXTURE_POOL
+#define CUTSCENE_BORDERS_SWITCH
// Particle
//#define PC_PARTICLE
@@ -264,11 +268,18 @@ enum Config {
// Peds
#define PED_SKIN // support for skinned geometry on peds
#define ANIMATE_PED_COL_MODEL
-#define VC_PED_PORTS // various ports from VC's CPed, mostly subtle
+// #define VC_PED_PORTS // various ports from VC's CPed, mostly subtle
// #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward
#define CANCELLABLE_CAR_ENTER
+//#define PEDS_REPORT_CRIMES_ON_PHONE
// Camera
//#define PS2_CAM_TRANSITION // old way of transitioning between cam modes
#define IMPROVED_CAMERA // Better Debug cam, and maybe more in the future
#define FREE_CAM // Rotating cam
+
+// Audio
+#ifndef AUDIO_OAL // is not working yet for openal
+#define AUDIO_CACHE // cache sound lengths to speed up the cold boot
+#endif
+//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS \ No newline at end of file
diff --git a/src/core/main.cpp b/src/core/main.cpp
index 1e26381a..a1c64a6d 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -254,7 +254,11 @@ DoFade(void)
fadeColor.a = alpha;
}
- if(TheCamera.m_WideScreenOn){
+ if(TheCamera.m_WideScreenOn
+#ifdef CUTSCENE_BORDERS_SWITCH
+ && CMenuManager::m_PrefsCutsceneBorders
+#endif
+ ){
// what's this?
float y = SCREEN_HEIGHT/2 * TheCamera.m_ScreenReductionPercentage/100.0f;
rect.left = 0.0f;
@@ -467,12 +471,16 @@ ResetLoadingScreenBar()
NumberOfChunksLoaded = 0.0f;
}
-// TODO: compare with PS2
void
LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
{
CSprite2d *splash;
+#ifdef DISABLE_LOADING_SCREEN
+ if (str1 && str2)
+ return;
+#endif
+
#ifndef RANDOMSPLASH
if(CGame::frenchGame || CGame::germanGame || !CGame::nastyGame)
splashscreen = "mainsc2";
@@ -858,7 +866,11 @@ Render2dStuff(void)
CReplay::Display();
CPickups::RenderPickUpText();
- if(TheCamera.m_WideScreenOn)
+ if(TheCamera.m_WideScreenOn
+#ifdef CUTSCENE_BORDERS_SWITCH
+ && CMenuManager::m_PrefsCutsceneBorders
+#endif
+ )
TheCamera.DrawBordersForWideScreen();
CPed *player = FindPlayerPed();
diff --git a/src/core/patcher.cpp b/src/core/patcher.cpp
deleted file mode 100644
index 83e06886..00000000
--- a/src/core/patcher.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#define WITHWINDOWS
-#include "common.h"
-#include "patcher.h"
-
-#include <algorithm>
-#include <vector>
-
-StaticPatcher *StaticPatcher::ms_head;
-
-StaticPatcher::StaticPatcher(Patcher func)
- : m_func(func)
-{
- m_next = ms_head;
- ms_head = this;
-}
-
-void
-StaticPatcher::Apply()
-{
- StaticPatcher *current = ms_head;
- while(current){
- current->Run();
- current = current->m_next;
- }
- ms_head = nil;
-}
-#ifdef _WIN32
-std::vector<uint32> usedAddresses;
-
-static DWORD protect[2];
-static uint32 protect_address;
-static uint32 protect_size;
-
-void
-Protect_internal(uint32 address, uint32 size)
-{
- protect_address = address;
- protect_size = size;
- VirtualProtect((void*)address, size, PAGE_EXECUTE_READWRITE, &protect[0]);
-}
-
-void
-Unprotect_internal(void)
-{
- VirtualProtect((void*)protect_address, protect_size, protect[0], &protect[1]);
-}
-
-void
-InjectHook_internal(uint32 address, uint32 hook, int type)
-{
- if(std::any_of(usedAddresses.begin(), usedAddresses.end(),
- [address](uint32 value) { return value == address; })) {
- debug("Used address %#06x twice when injecting hook\n", address);
- }
-
- usedAddresses.push_back(address);
-
-
- switch(type){
- case PATCH_JUMP:
- VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &protect[0]);
- *(uint8*)address = 0xE9;
- break;
- case PATCH_CALL:
- VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &protect[0]);
- *(uint8*)address = 0xE8;
- break;
- default:
- VirtualProtect((void*)(address + 1), 4, PAGE_EXECUTE_READWRITE, &protect[0]);
- break;
- }
-
- *(ptrdiff_t*)(address + 1) = hook - address - 5;
- if(type == PATCH_NOTHING)
- VirtualProtect((void*)(address + 1), 4, protect[0], &protect[1]);
- else
- VirtualProtect((void*)address, 5, protect[0], &protect[1]);
-}
-#else
-void
-Protect_internal(uint32 address, uint32 size)
-{
-}
-
-void
-Unprotect_internal(void)
-{
-}
-
-void
-InjectHook_internal(uint32 address, uint32 hook, int type)
-{
-}
-#endif
diff --git a/src/core/patcher.h b/src/core/patcher.h
deleted file mode 100644
index 2722b6fd..00000000
--- a/src/core/patcher.h
+++ /dev/null
@@ -1,144 +0,0 @@
-#pragma once
-
-#define WRAPPER __declspec(naked)
-#define DEPRECATED __declspec(deprecated)
-#define EAXJMP(a) { _asm mov eax, a _asm jmp eax }
-#define VARJMP(a) { _asm jmp a }
-#define WRAPARG(a) UNREFERENCED_PARAMETER(a)
-
-#include <string.h> //memset
-
-enum
-{
- PATCH_CALL,
- PATCH_JUMP,
- PATCH_NOTHING,
-};
-
-enum
-{
- III_10 = 1,
- III_11,
- III_STEAM,
- VC_10,
- VC_11,
- VC_STEAM
-};
-
-extern int gtaversion;
-
-class StaticPatcher
-{
-private:
- using Patcher = void(*)();
-
- Patcher m_func;
- StaticPatcher *m_next;
- static StaticPatcher *ms_head;
-
- void Run() { m_func(); }
-public:
- StaticPatcher(Patcher func);
- static void Apply();
-};
-
-template<typename T>
-inline T AddressByVersion(uint32_t addressIII10, uint32_t addressIII11, uint32_t addressIIISteam, uint32_t addressvc10, uint32_t addressvc11, uint32_t addressvcSteam)
-{
- if(gtaversion == -1){
- if(*(uint32_t*)0x5C1E75 == 0xB85548EC) gtaversion = III_10;
- else if(*(uint32_t*)0x5C2135 == 0xB85548EC) gtaversion = III_11;
- else if(*(uint32_t*)0x5C6FD5 == 0xB85548EC) gtaversion = III_STEAM;
- else if(*(uint32_t*)0x667BF5 == 0xB85548EC) gtaversion = VC_10;
- else if(*(uint32_t*)0x667C45 == 0xB85548EC) gtaversion = VC_11;
- else if(*(uint32_t*)0x666BA5 == 0xB85548EC) gtaversion = VC_STEAM;
- else gtaversion = 0;
- }
- switch(gtaversion){
- case III_10:
- return (T)addressIII10;
- case III_11:
- return (T)addressIII11;
- case III_STEAM:
- return (T)addressIIISteam;
- case VC_10:
- return (T)addressvc10;
- case VC_11:
- return (T)addressvc11;
- case VC_STEAM:
- return (T)addressvcSteam;
- default:
- return (T)0;
- }
-}
-
-inline bool
-is10(void)
-{
- return gtaversion == III_10 || gtaversion == VC_10;
-}
-
-inline bool
-isIII(void)
-{
- return gtaversion >= III_10 && gtaversion <= III_STEAM;
-}
-
-inline bool
-isVC(void)
-{
- return gtaversion >= VC_10 && gtaversion <= VC_STEAM;
-}
-
-#define PTRFROMCALL(addr) (uint32_t)(*(uint32_t*)((uint32_t)addr+1) + (uint32_t)addr + 5)
-#define INTERCEPT(saved, func, a) \
-{ \
- saved = PTRFROMCALL(a); \
- InjectHook(a, func); \
-}
-
-void InjectHook_internal(uint32 address, uint32 hook, int type);
-void Protect_internal(uint32 address, uint32 size);
-void Unprotect_internal(void);
-
-template<typename T, typename AT> inline void
-Patch(AT address, T value)
-{
- Protect_internal((uint32)address, sizeof(T));
- *(T*)address = value;
- Unprotect_internal();
-}
-
-template<typename AT> inline void
-Nop(AT address, unsigned int nCount)
-{
- Protect_internal((uint32)address, nCount);
- memset((void*)address, 0x90, nCount);
- Unprotect_internal();
-}
-
-template <typename T> inline void
-InjectHook(uintptr_t address, T hook, unsigned int nType = PATCH_NOTHING)
-{
- InjectHook_internal(address, reinterpret_cast<uintptr_t>((void *&)hook), nType);
-}
-
-inline void ExtractCall(void *dst, uint32_t a)
-{
- *(uint32_t*)dst = (uint32_t)(*(uint32_t*)(a+1) + a + 5);
-}
-template<typename T>
-inline void InterceptCall(void *dst, T func, uint32_t a)
-{
- ExtractCall(dst, a);
- InjectHook(a, func);
-}
-template<typename T>
-inline void InterceptVmethod(void *dst, T func, uint32_t a)
-{
- *(uint32_t*)dst = *(uint32_t*)a;
- Patch(a, func);
-}
-
-#define STARTPATCHES static StaticPatcher Patcher([](){
-#define ENDPATCHES });
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index b21bff58..8c0020d0 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -2,7 +2,6 @@
#define WITHWINDOWS
#include "common.h"
#include "crossplatform.h"
-#include "patcher.h"
#include "Renderer.h"
#include "Credits.h"
#include "Camera.h"
@@ -75,7 +74,6 @@ mysrand(unsigned int seed)
void ReloadFrontendOptions(void)
{
- RemoveCustomFrontendOptions();
CustomFrontendOptionsPopulate();
}
@@ -133,10 +131,20 @@ void ToggleFreeCam(int8 action)
}
#endif
+#ifdef CUTSCENE_BORDERS_SWITCH
+void BorderModeChange(int8 displayedValue)
+{
+ CMenuManager::m_PrefsCutsceneBorders = !!displayedValue;
+ FrontEndMenuManager.SaveSettings();
+}
+#endif
+
// Reloaded on language change, so you can use hardcoded wchar* and TheText.Get with peace of mind
void
CustomFrontendOptionsPopulate(void)
{
+ RemoveCustomFrontendOptions(); // if exist
+
#ifdef MORE_LANGUAGES
FrontendOptionSetPosition(MENUPAGE_LANGUAGE_SETTINGS);
FrontendOptionAddDynamic(TheText.Get("FEL_POL"), nil, LangPolSelect, nil);
@@ -160,6 +168,12 @@ CustomFrontendOptionsPopulate(void)
FrontendOptionSetPosition(MENUPAGE_CONTROLLER_PC, 1);
FrontendOptionAddDynamic(text, nil, ToggleFreeCam, nil);
#endif
+
+#ifdef CUTSCENE_BORDERS_SWITCH
+ static const wchar *off_on[] = { TheText.Get("FEM_OFF"), TheText.Get("FEM_ON") };
+ FrontendOptionSetPosition(MENUPAGE_GRAPHICS_SETTINGS, 9);
+ FrontendOptionAddSelect((const wchar *)L"CUTSCENE BORDERS", off_on, 2, (int8 *)&CMenuManager::m_PrefsCutsceneBorders, false, BorderModeChange, nil);
+#endif
}
#endif
@@ -484,11 +498,7 @@ DebugMenuPopulate(void)
#ifdef CUSTOM_FRONTEND_OPTIONS
DebugMenuAddCmd("Debug", "Reload custom frontend options", ReloadFrontendOptions);
#endif
-#ifdef TOGGLEABLE_BETA_FEATURES
DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil);
- DebugMenuAddVarBool8("Debug", "Toggle peds running to phones to report crimes", &CPed::bMakePedsRunToPhonesToReportCrimes, nil);
-#endif
-
DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start);
DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop);