summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Camera.cpp45
-rw-r--r--src/core/Camera.h6
-rw-r--r--src/core/Frontend.cpp16
-rw-r--r--src/core/Game.cpp13
-rw-r--r--src/core/Pad.cpp2
-rw-r--r--src/core/Pools.cpp2
-rw-r--r--src/core/Radar.cpp6
-rw-r--r--src/core/templates.h71
8 files changed, 117 insertions, 44 deletions
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 951b7c41..1390d5f2 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -4056,9 +4056,17 @@ CCamera::CalculateDerivedValues(void)
bool
CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
{
- RwV3d c;
- c = center;
- RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
+#ifdef GTA_PS2
+ CVuVector c;
+ TransformPoint(c, *mat, center);
+#else
+ CVector c = center;
+ #ifdef FIX_BUGS
+ c = *mat * center;
+ #else
+ RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
+ #endif
+#endif
if(c.y < CDraw::GetNearClipZ()) return false;
if(c.y > CDraw::GetFarClipZ()) return false;
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > 0.0f) return false;
@@ -4071,9 +4079,17 @@ CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
bool
CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat)
{
- RwV3d c;
- c = center;
- RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
+#ifdef GTA_PS2
+ CVuVector c;
+ TransformPoint(c, *mat, center);
+#else
+ CVector c = center;
+ #ifdef FIX_BUGS
+ c = *mat * center;
+ #else
+ RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
+ #endif
+#endif
if(c.y + radius < CDraw::GetNearClipZ()) return false;
if(c.y - radius > CDraw::GetFarClipZ()) return false;
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > radius) return false;
@@ -4091,11 +4107,24 @@ CCamera::IsSphereVisible(const CVector &center, float radius)
}
bool
-CCamera::IsBoxVisible(RwV3d *box, const CMatrix *mat)
+#ifdef GTA_PS2
+CCamera::IsBoxVisible(CVuVector *box, const CMatrix *mat)
+#else
+CCamera::IsBoxVisible(CVector *box, const CMatrix *mat)
+#endif
{
int i;
int frustumTests[6] = { 0 };
- RwV3dTransformPoints(box, box, 8, &mat->m_matrix);
+#ifdef GTA_PS2
+ TransformPoints(box, 8, *mat, box);
+#else
+ #ifdef FIX_BUGS
+ for (i = 0; i < 8; i++)
+ box[i] = *mat * box[i];
+ #else
+ RwV3dTransformPoints(box, box, 8, (RwMatrix*)mat);
+ #endif
+#endif
for(i = 0; i < 8; i++){
if(box[i].y < CDraw::GetNearClipZ()) frustumTests[0]++;
diff --git a/src/core/Camera.h b/src/core/Camera.h
index 4da7b499..538ff067 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -633,7 +633,11 @@ public:
bool IsPointVisible(const CVector &center, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius);
- bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
+#ifdef GTA_PS2
+ bool IsBoxVisible(CVuVector *box, const CMatrix *mat);
+#else
+ bool IsBoxVisible(CVector *box, const CMatrix *mat);
+#endif
};
VALIDATE_SIZE(CCamera, 0xE9D8);
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 613d56fe..4f6da8ef 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -3250,7 +3250,9 @@ CMenuManager::PrintBriefs()
void
CMenuManager::PrintStats()
{
- static uint8 pirateCheck = 0;
+#ifdef SECUROM
+ static uint8 statsPirateCheck = 0;
+#endif
static float scrollY = 0;
int rowNum = CStats::ConstructStatLine(99999);
@@ -3263,11 +3265,13 @@ CMenuManager::PrintStats()
CFont::SetPropOn();
CFont::SetDropShadowPosition(0);
- if (pirateCheck == 0)
+#ifdef SECUROM
+ if (statsPirateCheck == 0)
// if not pirated game
- pirateCheck = 46;
+ // statsPirateCheck = 46;
// else
- // pirateCheck = 45;
+ statsPirateCheck = 45;
+#endif
if (m_PrefsLanguage == LANGUAGE_AMERICAN)
CFont::SetScale(MENU_X(0.43f), MENU_Y(0.75f));
@@ -3287,8 +3291,10 @@ CMenuManager::PrintStats()
lastCheck = CTimer::GetTimeInMillisecondsPauseMode();
}
- if (pirateCheck == 45)
+#ifdef SECUROM
+ if (statsPirateCheck == 45)
return;
+#endif
float nextYChange, y, alpha;
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 43e5856c..b8a5bd7a 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -121,6 +121,10 @@ bool8 CGame::VarUpdatePlayerCoords;
int gameTxdSlot;
+#ifdef SECUROM
+uint8 gameProcessPirateCheck = 0;
+#endif
+
// --MIAMI: File done
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
@@ -846,7 +850,14 @@ void CGame::Process(void)
FrontEndMenuManager.Process();
CTheZones::Update();
- // DRM call in here
+#ifdef SECUROM
+ if (CTimer::GetTimeInMilliseconds() >= (35 * 60 * 1000) && gameProcessPirateCheck == 0){
+ // if game not pirated
+ // gameProcessPirateCheck = 1;
+ // else
+ gameProcessPirateCheck = 2;
+ }
+#endif
uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
CStreaming::Update();
uint32 processTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond() - startTime;
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 1e4f48f4..2548e70d 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -153,7 +153,7 @@ void PickUpChicksCheat()
if ( FindPlayerVehicle() && (FindPlayerVehicle()->IsCar() || FindPlayerVehicle()->IsBike()) )
{
CVehicle *vehicle = FindPlayerVehicle();
- if ( FindPlayerVehicle()->m_vehType == 5 )
+ if ( FindPlayerVehicle()->IsBike() )
{
if ( vehicle->pPassengers[0] )
vehicle->pPassengers[0]->SetObjective(OBJECTIVE_LEAVE_CAR, vehicle);
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index ee60f316..bd246b71 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -111,7 +111,7 @@ CPools::CheckPoolsEmpty()
void
CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
{
- if (ms_pObjectPool->IsFreeSlot(slot)) return;
+ if (ms_pObjectPool->GetIsFree(slot)) return;
CObject *object = ms_pObjectPool->GetSlot(slot);
if (object->ObjectCreatedBy == TEMP_OBJECT) {
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index d9802acc..50a8652a 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -481,6 +481,10 @@ void CRadar::Draw3dMarkers()
void CRadar::DrawBlips()
{
if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
+#ifdef SECUROM
+ extern uint8 roadBlocksPirateCheck;
+ if (roadBlocksPirateCheck == 2) return;
+#endif
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
@@ -680,7 +684,7 @@ void CRadar::DrawRadarMask()
CVector2D(-1.0, -1.0f)
};
- RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)nil);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
diff --git a/src/core/templates.h b/src/core/templates.h
index 19881219..7bc85ee6 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -29,38 +29,58 @@ public:
}
};
+#define POOLFLAG_ID 0x7f
+#define POOLFLAG_ISFREE 0x80
+
template<typename T, typename U = T>
class CPool
{
U *m_entries;
- union Flags {
- struct {
- uint8 id : 7;
- uint8 free : 1;
- };
- uint8 u;
- } *m_flags;
+ uint8 *m_flags;
int32 m_size;
int32 m_allocPtr;
public:
CPool(int32 size, const char *name){
m_entries = (U*)new uint8[sizeof(U)*size];
- m_flags = (Flags*)new uint8[sizeof(Flags)*size];
+ m_flags = new uint8[size];
m_size = size;
m_allocPtr = -1;
for(int i = 0; i < size; i++){
- m_flags[i].id = 0;
- m_flags[i].free = 1;
+ SetId(i, 0);
+ SetIsFree(i, true);
}
}
+
+ int GetId(int i) const
+ {
+ return m_flags[i] & POOLFLAG_ID;
+ }
+
+ bool GetIsFree(int i) const
+ {
+ return !!(m_flags[i] & POOLFLAG_ISFREE);
+ }
+
+ void SetId(int i, int id)
+ {
+ m_flags[i] = (m_flags[i] & POOLFLAG_ISFREE) | (id & POOLFLAG_ID);
+ }
+
+ void SetIsFree(int i, bool isFree)
+ {
+ if (isFree)
+ m_flags[i] |= POOLFLAG_ISFREE;
+ else
+ m_flags[i] &= ~POOLFLAG_ISFREE;
+ }
~CPool() {
Flush();
}
void Flush() {
if (m_size > 0) {
delete[] (uint8*)m_entries;
- delete[] (uint8*)m_flags;
+ delete[] m_flags;
m_entries = nil;
m_flags = nil;
m_size = 0;
@@ -86,9 +106,9 @@ public:
m_allocPtr = 0;
}
#endif
- while(!m_flags[m_allocPtr].free);
- m_flags[m_allocPtr].free = 0;
- m_flags[m_allocPtr].id++;
+ while(!GetIsFree(m_allocPtr));
+ SetIsFree(m_allocPtr, false);
+ SetId(m_allocPtr, GetId(m_allocPtr)+1);
return (T*)&m_entries[m_allocPtr];
}
T *New(int32 handle){
@@ -98,37 +118,37 @@ public:
}
void SetNotFreeAt(int32 handle){
int idx = handle>>8;
- m_flags[idx].free = 0;
- m_flags[idx].id = handle & 0x7F;
+ SetIsFree(idx, false);
+ SetId(idx, handle & POOLFLAG_ID);
for(m_allocPtr = 0; m_allocPtr < m_size; m_allocPtr++)
- if(m_flags[m_allocPtr].free)
+ if(GetIsFree(m_allocPtr))
return;
}
void Delete(T *entry){
int i = GetJustIndex(entry);
- m_flags[i].free = 1;
+ SetIsFree(i, true);
if(i < m_allocPtr)
m_allocPtr = i;
}
T *GetSlot(int i){
- return m_flags[i].free ? nil : (T*)&m_entries[i];
+ return GetIsFree(i) ? nil : (T*)&m_entries[i];
}
T *GetAt(int handle){
#ifdef FIX_BUGS
if (handle == -1)
return nil;
#endif
- return m_flags[handle>>8].u == (handle & 0xFF) ?
+ return m_flags[handle>>8] == (handle & 0xFF) ?
(T*)&m_entries[handle >> 8] : nil;
}
int32 GetIndex(T* entry) {
int i = GetJustIndex_NoFreeAssert(entry);
- return m_flags[i].u + (i << 8);
+ return m_flags[i] + (i<<8);
}
int32 GetJustIndex(T* entry) {
int index = GetJustIndex_NoFreeAssert(entry);
assert((U*)entry == (U*)&m_entries[index]); // cast is unsafe - check required
- assert(!IsFreeSlot(index));
+ assert(!GetIsFree(index));
return index;
}
int32 GetJustIndex_NoFreeAssert(T* entry) {
@@ -140,13 +160,12 @@ public:
int i;
int n = 0;
for(i = 0; i < m_size; i++)
- if(!m_flags[i].free)
+ if(!GetIsFree(i))
n++;
return n;
}
- bool IsFreeSlot(int i) { return !!m_flags[i].free; }
void ClearStorage(uint8 *&flags, U *&entries){
- delete[] (uint8*)flags;
+ delete[] flags;
delete[] (uint8*)entries;
flags = nil;
entries = nil;
@@ -155,7 +174,7 @@ public:
void CopyBack(uint8 *&flags, U *&entries){
memcpy(m_flags, flags, sizeof(uint8)*m_size);
memcpy(m_entries, entries, sizeof(U)*m_size);
- debug("Size copied:%d (%d)\n", sizeof(U)*m_size, sizeof(Flags)*m_size);
+ debug("Size copied:%d (%d)\n", sizeof(U)*m_size, m_size);
m_allocPtr = 0;
ClearStorage(flags, entries);
debug("CopyBack:%d (/%d)\n", GetNoOfUsedSpaces(), m_size); /* Assumed inlining */