summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/animation/AnimBlendAssociation.cpp8
-rw-r--r--src/animation/AnimBlendClumpData.h2
-rw-r--r--src/animation/AnimBlendHierarchy.cpp19
-rw-r--r--src/animation/AnimBlendHierarchy.h4
-rw-r--r--src/animation/AnimBlendNode.cpp127
-rw-r--r--src/animation/AnimBlendNode.h4
-rw-r--r--src/animation/AnimBlendSequence.cpp114
-rw-r--r--src/animation/AnimBlendSequence.h46
-rw-r--r--src/animation/AnimManager.cpp143
-rw-r--r--src/animation/AnimManager.h4
-rw-r--r--src/animation/CutsceneMgr.cpp21
-rw-r--r--src/animation/FrameUpdate.cpp222
-rw-r--r--src/animation/RpAnimBlend.cpp14
-rw-r--r--src/animation/RpAnimBlend.h3
-rw-r--r--src/audio/AudioLogic.cpp54
-rw-r--r--src/audio/AudioManager.cpp4
-rw-r--r--src/audio/AudioManager.h2
-rw-r--r--src/audio/MusicManager.cpp10
-rw-r--r--src/audio/PoliceRadio.cpp2
-rw-r--r--src/buildings/Building.cpp (renamed from src/entities/Building.cpp)0
-rw-r--r--src/buildings/Building.h (renamed from src/entities/Building.h)0
-rw-r--r--src/buildings/Solid.h (renamed from src/entities/Solid.h)0
-rw-r--r--src/buildings/Treadable.cpp (renamed from src/entities/Treadable.cpp)0
-rw-r--r--src/buildings/Treadable.h (renamed from src/entities/Treadable.h)0
-rw-r--r--src/control/Garages.cpp5
-rw-r--r--src/core/Cam.cpp4
-rw-r--r--src/core/Camera.cpp8
-rw-r--r--src/core/Directory.cpp2
-rw-r--r--src/core/EventList.cpp4
-rw-r--r--src/core/EventList.h2
-rw-r--r--src/core/FileLoader.cpp8
-rw-r--r--src/core/FileMgr.cpp14
-rw-r--r--src/core/FileMgr.h6
-rw-r--r--src/core/Fire.cpp32
-rw-r--r--src/core/Frontend.cpp8
-rw-r--r--src/core/Game.cpp45
-rw-r--r--src/core/MenuScreens.cpp2
-rw-r--r--src/core/MenuScreensCustom.cpp2
-rw-r--r--src/core/Pad.cpp44
-rw-r--r--src/core/Pools.cpp1
-rw-r--r--src/core/Streaming.cpp32
-rw-r--r--src/core/Streaming.h6
-rw-r--r--src/core/Zones.cpp6
-rw-r--r--src/core/common.h5
-rw-r--r--src/core/config.h8
-rw-r--r--src/core/main.cpp446
-rw-r--r--src/core/re3.cpp2
-rw-r--r--src/extras/debugmenu.h2
-rw-r--r--src/extras/screendroplets.cpp13
-rw-r--r--src/math/Quaternion.h5
-rw-r--r--src/peds/Ped.cpp84
-rw-r--r--src/peds/PedAI.cpp16
-rw-r--r--src/peds/PedAttractor.cpp19
-rw-r--r--src/peds/PedType.cpp10
-rw-r--r--src/peds/PlayerPed.cpp20
-rw-r--r--src/render/PlayerSkin.cpp2
-rw-r--r--src/render/Weather.cpp2
-rw-r--r--src/rw/MemoryHeap.cpp2
-rw-r--r--src/rw/MemoryHeap.h1
-rw-r--r--src/rw/VisibilityPlugins.cpp6
-rw-r--r--src/rw/VisibilityPlugins.h6
-rw-r--r--src/skel/skeleton.cpp4
-rw-r--r--src/text/Text.cpp6
-rw-r--r--src/weapons/WeaponInfo.cpp2
64 files changed, 1227 insertions, 468 deletions
diff --git a/src/animation/AnimBlendAssociation.cpp b/src/animation/AnimBlendAssociation.cpp
index 2f4739a6..b91b35ee 100644
--- a/src/animation/AnimBlendAssociation.cpp
+++ b/src/animation/AnimBlendAssociation.cpp
@@ -139,11 +139,15 @@ CAnimBlendAssociation::SetCurrentTime(float time)
}
CAnimManager::UncompressAnimation(hierarchy);
- if(hierarchy->compressed2){
+#ifdef ANIM_COMPRESSION
+ // strangely PC has this but android doesn't
+ if(hierarchy->keepCompressed){
for(i = 0; i < numNodes; i++)
if(nodes[i].sequence)
nodes[i].SetupKeyFrameCompressed();
- }else{
+ }else
+#endif
+ {
for(i = 0; i < numNodes; i++)
if(nodes[i].sequence)
nodes[i].FindKeyFrame(currentTime);
diff --git a/src/animation/AnimBlendClumpData.h b/src/animation/AnimBlendClumpData.h
index 315cbd8a..633fc7b9 100644
--- a/src/animation/AnimBlendClumpData.h
+++ b/src/animation/AnimBlendClumpData.h
@@ -12,7 +12,7 @@ struct AnimBlendFrameData
VELOCITY_EXTRACTION = 8,
VELOCITY_EXTRACTION_3D = 0x10,
UPDATE_KEYFRAMES = 0x20,
- UNK_COMPRESSED = 0x40,
+ COMPRESSED = 0x40
};
uint8 flag;
diff --git a/src/animation/AnimBlendHierarchy.cpp b/src/animation/AnimBlendHierarchy.cpp
index f3e90818..cc7c7de8 100644
--- a/src/animation/AnimBlendHierarchy.cpp
+++ b/src/animation/AnimBlendHierarchy.cpp
@@ -65,10 +65,10 @@ CAnimBlendHierarchy::CalcTotalTimeCompressed(void)
continue;
#endif
- totalLength = Max(totalLength, sequences[i].GetKeyFrameCompressed(sequences[i].numFrames-1)->deltaTime/60.0f);
+ totalLength = Max(totalLength, sequences[i].GetKeyFrameCompressed(sequences[i].numFrames-1)->GetDeltaTime());
for(j = sequences[i].numFrames-1; j >= 1; j--){
- KeyFrame *kf1 = sequences[i].GetKeyFrameCompressed(j);
- KeyFrame *kf2 = sequences[i].GetKeyFrameCompressed(j-1);
+ KeyFrameCompressed *kf1 = sequences[i].GetKeyFrameCompressed(j);
+ KeyFrameCompressed *kf2 = sequences[i].GetKeyFrameCompressed(j-1);
kf1->deltaTime -= kf2->deltaTime;
}
}
@@ -94,6 +94,12 @@ CAnimBlendHierarchy::RemoveAnimSequences(void)
void
CAnimBlendHierarchy::Uncompress(void)
{
+#ifdef ANIM_COMPRESSION
+ int i;
+ assert(compressed);
+ for(i = 0; i < numSequences; i++)
+ sequences[i].Uncompress();
+#endif
compressed = 0;
if(totalLength == 0.0f){
RemoveQuaternionFlips();
@@ -104,7 +110,12 @@ CAnimBlendHierarchy::Uncompress(void)
void
CAnimBlendHierarchy::RemoveUncompressedData(void)
{
- // useless
+#ifdef ANIM_COMPRESSION
+ int i;
+ assert(!compressed);
+ for(i = 0; i < numSequences; i++)
+ sequences[i].RemoveUncompressedData();
+#endif
compressed = 1;
}
diff --git a/src/animation/AnimBlendHierarchy.h b/src/animation/AnimBlendHierarchy.h
index 424a925d..4838c4f8 100644
--- a/src/animation/AnimBlendHierarchy.h
+++ b/src/animation/AnimBlendHierarchy.h
@@ -15,8 +15,8 @@ public:
char name[24];
CAnimBlendSequence *sequences;
int16 numSequences;
- bool compressed; // not really used
- bool compressed2; // not really used
+ bool compressed;
+ bool keepCompressed;
float totalLength;
CLink<CAnimBlendHierarchy*> *linkPtr;
diff --git a/src/animation/AnimBlendNode.cpp b/src/animation/AnimBlendNode.cpp
index ac1328eb..d2a8dd41 100644
--- a/src/animation/AnimBlendNode.cpp
+++ b/src/animation/AnimBlendNode.cpp
@@ -48,6 +48,44 @@ CAnimBlendNode::Update(CVector &trans, CQuaternion &rot, float weight)
}
bool
+CAnimBlendNode::UpdateCompressed(CVector &trans, CQuaternion &rot, float weight)
+{
+ bool looped = false;
+
+ trans = CVector(0.0f, 0.0f, 0.0f);
+ rot = CQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
+
+ if(association->IsRunning()){
+ remainingTime -= association->timeStep;
+ if(remainingTime <= 0.0f)
+ looped = NextKeyFrameCompressed();
+ }
+
+ float blend = association->GetBlendAmount(weight);
+ if(blend > 0.0f){
+ KeyFrameTransCompressed *kfA = (KeyFrameTransCompressed*)sequence->GetKeyFrameCompressed(frameA);
+ KeyFrameTransCompressed *kfB = (KeyFrameTransCompressed*)sequence->GetKeyFrameCompressed(frameB);
+ float t = kfA->deltaTime == 0 ? 0.0f : (kfA->GetDeltaTime() - remainingTime)/kfA->GetDeltaTime();
+ if(sequence->type & CAnimBlendSequence::KF_TRANS){
+ CVector transA, transB;
+ kfA->GetTranslation(&transA);
+ kfB->GetTranslation(&transB);
+ trans = transB + t*(transA - transB);
+ trans *= blend;
+ }
+ if(sequence->type & CAnimBlendSequence::KF_ROT){
+ CQuaternion rotA, rotB;
+ kfA->GetRotation(&rotA);
+ kfB->GetRotation(&rotB);
+ rot.Slerp(rotB, rotA, theta, invSin, t);
+ rot *= blend;
+ }
+ }
+
+ return looped;
+}
+
+bool
CAnimBlendNode::NextKeyFrame(void)
{
bool looped;
@@ -84,6 +122,43 @@ CAnimBlendNode::NextKeyFrame(void)
return looped;
}
+bool
+CAnimBlendNode::NextKeyFrameCompressed(void)
+{
+ bool looped;
+
+ if(sequence->numFrames <= 1)
+ return false;
+
+ looped = false;
+ frameB = frameA;
+
+ // Advance as long as we have to
+ while(remainingTime <= 0.0f){
+ frameA++;
+
+ if(frameA >= sequence->numFrames){
+ // reached end of animation
+ if(!association->IsRepeating()){
+ frameA--;
+ remainingTime = 0.0f;
+ return false;
+ }
+ looped = true;
+ frameA = 0;
+ }
+
+ remainingTime += sequence->GetKeyFrameCompressed(frameA)->GetDeltaTime();
+ }
+
+ frameB = frameA - 1;
+ if(frameB < 0)
+ frameB += sequence->numFrames;
+
+ CalcDeltasCompressed();
+ return looped;
+}
+
// Set animation to time t
bool
CAnimBlendNode::FindKeyFrame(float t)
@@ -132,7 +207,7 @@ CAnimBlendNode::SetupKeyFrameCompressed(void)
frameA = 0;
remainingTime = 0.0f;
}else
- remainingTime = sequence->GetKeyFrameCompressed(frameA)->deltaTime/60.0f;
+ remainingTime = sequence->GetKeyFrameCompressed(frameA)->GetDeltaTime();
CalcDeltasCompressed();
return true;
@@ -157,9 +232,17 @@ CAnimBlendNode::CalcDeltasCompressed(void)
{
if((sequence->type & CAnimBlendSequence::KF_ROT) == 0)
return;
- KeyFrame *kfA = sequence->GetKeyFrameCompressed(frameA);
- KeyFrame *kfB = sequence->GetKeyFrameCompressed(frameB);
- float cos = DotProduct(kfA->rotation, kfB->rotation);
+ KeyFrameCompressed *kfA = sequence->GetKeyFrameCompressed(frameA);
+ KeyFrameCompressed *kfB = sequence->GetKeyFrameCompressed(frameB);
+ CQuaternion rotA, rotB;
+ kfA->GetRotation(&rotA);
+ kfB->GetRotation(&rotB);
+ float cos = DotProduct(rotA, rotB);
+ if(cos < 0.0f){
+ rotB *= -1.0f;
+ kfB->SetRotation(rotB);
+ }
+ cos = DotProduct(rotA, rotB);
if(cos > 1.0f)
cos = 1.0f;
theta = Acos(cos);
@@ -184,6 +267,26 @@ CAnimBlendNode::GetCurrentTranslation(CVector &trans, float weight)
}
void
+CAnimBlendNode::GetCurrentTranslationCompressed(CVector &trans, float weight)
+{
+ trans = CVector(0.0f, 0.0f, 0.0f);
+
+ float blend = association->GetBlendAmount(weight);
+ if(blend > 0.0f){
+ KeyFrameTransCompressed *kfA = (KeyFrameTransCompressed*)sequence->GetKeyFrameCompressed(frameA);
+ KeyFrameTransCompressed *kfB = (KeyFrameTransCompressed*)sequence->GetKeyFrameCompressed(frameB);
+ float t = kfA->deltaTime == 0 ? 0.0f : (kfA->GetDeltaTime() - remainingTime)/kfA->GetDeltaTime();
+ if(sequence->type & CAnimBlendSequence::KF_TRANS){
+ CVector transA, transB;
+ kfA->GetTranslation(&transA);
+ kfB->GetTranslation(&transB);
+ trans = transB + t*(transA - transB);
+ trans *= blend;
+ }
+ }
+}
+
+void
CAnimBlendNode::GetEndTranslation(CVector &trans, float weight)
{
trans = CVector(0.0f, 0.0f, 0.0f);
@@ -195,3 +298,19 @@ CAnimBlendNode::GetEndTranslation(CVector &trans, float weight)
trans = kf->translation * blend;
}
}
+
+void
+CAnimBlendNode::GetEndTranslationCompressed(CVector &trans, float weight)
+{
+ trans = CVector(0.0f, 0.0f, 0.0f);
+
+ float blend = association->GetBlendAmount(weight);
+ if(blend > 0.0f){
+ KeyFrameTransCompressed *kf = (KeyFrameTransCompressed*)sequence->GetKeyFrameCompressed(sequence->numFrames-1);
+ if(sequence->type & CAnimBlendSequence::KF_TRANS){
+ CVector pos;
+ kf->GetTranslation(&pos);
+ trans = pos * blend;
+ }
+ }
+}
diff --git a/src/animation/AnimBlendNode.h b/src/animation/AnimBlendNode.h
index 9446e1ae..99a657ac 100644
--- a/src/animation/AnimBlendNode.h
+++ b/src/animation/AnimBlendNode.h
@@ -20,13 +20,17 @@ public:
void Init(void);
bool Update(CVector &trans, CQuaternion &rot, float weight);
+ bool UpdateCompressed(CVector &trans, CQuaternion &rot, float weight);
bool NextKeyFrame(void);
+ bool NextKeyFrameCompressed(void);
bool FindKeyFrame(float t);
bool SetupKeyFrameCompressed(void);
void CalcDeltas(void);
void CalcDeltasCompressed(void);
void GetCurrentTranslation(CVector &trans, float weight);
+ void GetCurrentTranslationCompressed(CVector &trans, float weight);
void GetEndTranslation(CVector &trans, float weight);
+ void GetEndTranslationCompressed(CVector &trans, float weight);
};
diff --git a/src/animation/AnimBlendSequence.cpp b/src/animation/AnimBlendSequence.cpp
index 3c675d4e..93cce91d 100644
--- a/src/animation/AnimBlendSequence.cpp
+++ b/src/animation/AnimBlendSequence.cpp
@@ -67,6 +67,119 @@ CAnimBlendSequence::RemoveQuaternionFlips(void)
}
}
+void
+CAnimBlendSequence::Uncompress(void)
+{
+ int i;
+
+ if(numFrames == 0)
+ return;
+
+ PUSH_MEMID(MEMID_ANIMATION);
+
+ float rotScale = 1.0f/4096.0f;
+ float timeScale = 1.0f/60.0f;
+ float transScale = 1.0f/1024.0f;
+ if(type & KF_TRANS){
+ void *newKfs = RwMalloc(numFrames * sizeof(KeyFrameTrans));
+ KeyFrameTransCompressed *ckf = (KeyFrameTransCompressed*)keyFramesCompressed;
+ KeyFrameTrans *kf = (KeyFrameTrans*)newKfs;
+ for(i = 0; i < numFrames; i++){
+ kf->rotation.x = ckf->rot[0]*rotScale;
+ kf->rotation.y = ckf->rot[1]*rotScale;
+ kf->rotation.z = ckf->rot[2]*rotScale;
+ kf->rotation.w = ckf->rot[3]*rotScale;
+ kf->deltaTime = ckf->deltaTime*timeScale;
+ kf->translation.x = ckf->trans[0]*transScale;
+ kf->translation.y = ckf->trans[1]*transScale;
+ kf->translation.z = ckf->trans[2]*transScale;
+ kf++;
+ ckf++;
+ }
+ keyFrames = newKfs;
+ }else{
+ void *newKfs = RwMalloc(numFrames * sizeof(KeyFrame));
+ KeyFrameCompressed *ckf = (KeyFrameCompressed*)keyFramesCompressed;
+ KeyFrame *kf = (KeyFrame*)newKfs;
+ for(i = 0; i < numFrames; i++){
+ kf->rotation.x = ckf->rot[0]*rotScale;
+ kf->rotation.y = ckf->rot[1]*rotScale;
+ kf->rotation.z = ckf->rot[2]*rotScale;
+ kf->rotation.w = ckf->rot[3]*rotScale;
+ kf->deltaTime = ckf->deltaTime*timeScale;
+ kf++;
+ ckf++;
+ }
+ keyFrames = newKfs;
+ }
+ REGISTER_MEMPTR(&keyFrames);
+
+ RwFree(keyFramesCompressed);
+ keyFramesCompressed = nil;
+
+ POP_MEMID();
+}
+
+void
+CAnimBlendSequence::CompressKeyframes(void)
+{
+ int i;
+
+ if(numFrames == 0)
+ return;
+
+ PUSH_MEMID(MEMID_ANIMATION);
+
+ float rotScale = 4096.0f;
+ float timeScale = 60.0f;
+ float transScale = 1024.0f;
+ if(type & KF_TRANS){
+ void *newKfs = RwMalloc(numFrames * sizeof(KeyFrameTransCompressed));
+ KeyFrameTransCompressed *ckf = (KeyFrameTransCompressed*)newKfs;
+ KeyFrameTrans *kf = (KeyFrameTrans*)keyFrames;
+ for(i = 0; i < numFrames; i++){
+ ckf->rot[0] = kf->rotation.x*rotScale;
+ ckf->rot[1] = kf->rotation.y*rotScale;
+ ckf->rot[2] = kf->rotation.z*rotScale;
+ ckf->rot[3] = kf->rotation.w*rotScale;
+ ckf->deltaTime = kf->deltaTime*timeScale + 0.5f;
+ ckf->trans[0] = kf->translation.x*transScale;
+ ckf->trans[1] = kf->translation.y*transScale;
+ ckf->trans[2] = kf->translation.z*transScale;
+ kf++;
+ ckf++;
+ }
+ keyFramesCompressed = newKfs;
+ }else{
+ void *newKfs = RwMalloc(numFrames * sizeof(KeyFrameCompressed));
+ KeyFrameCompressed *ckf = (KeyFrameCompressed*)newKfs;
+ KeyFrame *kf = (KeyFrame*)keyFrames;
+ for(i = 0; i < numFrames; i++){
+ ckf->rot[0] = kf->rotation.x*rotScale;
+ ckf->rot[1] = kf->rotation.y*rotScale;
+ ckf->rot[2] = kf->rotation.z*rotScale;
+ ckf->rot[3] = kf->rotation.w*rotScale;
+ ckf->deltaTime = kf->deltaTime*timeScale + 0.5f;
+ kf++;
+ ckf++;
+ }
+ keyFramesCompressed = newKfs;
+ }
+ REGISTER_MEMPTR(&keyFramesCompressed);
+
+ POP_MEMID();
+}
+
+void
+CAnimBlendSequence::RemoveUncompressedData(void)
+{
+ if(numFrames == 0)
+ return;
+ CompressKeyframes();
+ RwFree(keyFrames);
+ keyFrames = nil;
+}
+
#ifdef USE_CUSTOM_ALLOCATOR
bool
CAnimBlendSequence::MoveMemory(void)
@@ -87,4 +200,3 @@ CAnimBlendSequence::MoveMemory(void)
return false;
}
#endif
-
diff --git a/src/animation/AnimBlendSequence.h b/src/animation/AnimBlendSequence.h
index 1c2531ce..67118b2f 100644
--- a/src/animation/AnimBlendSequence.h
+++ b/src/animation/AnimBlendSequence.h
@@ -16,6 +16,43 @@ struct KeyFrameTrans : KeyFrame {
CVector translation;
};
+struct KeyFrameCompressed {
+ int16 rot[4]; // 4096
+ int16 deltaTime; // 60
+
+ void GetRotation(CQuaternion *quat){
+ float scale = 1.0f/4096.0f;
+ quat->x = rot[0]*scale;
+ quat->y = rot[1]*scale;
+ quat->z = rot[2]*scale;
+ quat->w = rot[3]*scale;
+ }
+ void SetRotation(const CQuaternion &quat){
+ rot[0] = quat.x * 4096.0f;
+ rot[1] = quat.y * 4096.0f;
+ rot[2] = quat.z * 4096.0f;
+ rot[3] = quat.w * 4096.0f;
+ }
+ float GetDeltaTime(void) { return deltaTime/60.0f; }
+ void SetTime(float t) { deltaTime = t*60.0f + 0.5f; }
+};
+
+struct KeyFrameTransCompressed : KeyFrameCompressed {
+ int16 trans[3]; // 1024
+
+ void GetTranslation(CVector *vec) {
+ float scale = 1.0f/1024.0f;
+ vec->x = trans[0]*scale;
+ vec->y = trans[1]*scale;
+ vec->z = trans[2]*scale;
+ }
+ void SetTranslation(const CVector &vec){
+ trans[0] = vec.x*1024.0f;
+ trans[1] = vec.y*1024.0f;
+ trans[2] = vec.z*1024.0f;
+ }
+};
+
// The sequence of key frames of one animated node
class CAnimBlendSequence
@@ -42,12 +79,15 @@ public:
&((KeyFrameTrans*)keyFrames)[n] :
&((KeyFrame*)keyFrames)[n];
}
- KeyFrame *GetKeyFrameCompressed(int n) {
+ KeyFrameCompressed *GetKeyFrameCompressed(int n) {
return type & KF_TRANS ?
- &((KeyFrameTrans*)keyFramesCompressed)[n] :
- &((KeyFrame*)keyFramesCompressed)[n];
+ &((KeyFrameTransCompressed*)keyFramesCompressed)[n] :
+ &((KeyFrameCompressed*)keyFramesCompressed)[n];
}
bool HasTranslation(void) { return !!(type & KF_TRANS); }
+ void Uncompress(void);
+ void CompressKeyframes(void);
+ void RemoveUncompressedData(void);
bool MoveMemory(void);
void SetBoneTag(int tag) { boneTag = tag; }
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp
index 0aa6486b..9fc54654 100644
--- a/src/animation/AnimManager.cpp
+++ b/src/animation/AnimManager.cpp
@@ -287,6 +287,7 @@ AnimAssocDesc aStripAnimDescs[] = {
{ ANIM_STRIP_F, ASSOC_REPEAT | ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_STRIP_G, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
};
+#ifdef PC_PLAYER_CONTROLS
AnimAssocDesc aStdAnimDescsSide[] = {
{ ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION | ASSOC_WALK },
{ ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION | ASSOC_WALK },
@@ -294,7 +295,7 @@ AnimAssocDesc aStdAnimDescsSide[] = {
{ ANIM_IDLE_STANCE, ASSOC_REPEAT },
{ ANIM_WALK_START, ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION },
};
-
+#endif
char const* aStdAnimations[] = {
"walk_civi",
"run_civi",
@@ -834,6 +835,7 @@ char const* aSkateAnimations[] = {
"skate_sprint",
"skate_idle",
};
+#ifdef PC_PLAYER_CONTROLS
char const* aPlayerStrafeBackAnimations[] = {
"walk_back",
"run_back",
@@ -897,7 +899,7 @@ char const* aChainsawStrafeRightAnimations[] = {
"idle_csaw",
"walkst_csaw_right",
};
-
+#endif
#define awc(a) ARRAY_SIZE(a), a
const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = {
@@ -953,6 +955,7 @@ const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_
{ "jogwoman", "ped", MI_COP, awc(aJoggerWomanAnimations), aStdAnimDescs },
{ "panicchunky", "ped", MI_COP, awc(aPanicChunkyAnimations), aStdAnimDescs },
{ "skate", "skate", MI_COP, awc(aSkateAnimations), aStdAnimDescs },
+#ifdef PC_PLAYER_CONTROLS
{ "playerback", "ped", MI_COP, awc(aPlayerStrafeBackAnimations), aStdAnimDescs },
{ "playerleft", "ped", MI_COP, awc(aPlayerStrafeLeftAnimations), aStdAnimDescsSide },
{ "playerright", "ped", MI_COP, awc(aPlayerStrafeRightAnimations), aStdAnimDescsSide },
@@ -962,6 +965,7 @@ const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_
{ "csawback", "ped", MI_COP, awc(aChainsawStrafeBackAnimations), aStdAnimDescs },
{ "csawleft", "ped", MI_COP, awc(aChainsawStrafeLeftAnimations), aStdAnimDescsSide },
{ "csawright", "ped", MI_COP, awc(aChainsawStrafeRightAnimations), aStdAnimDescsSide },
+#endif
};
#undef awc
@@ -992,7 +996,7 @@ CAnimManager::Shutdown(void)
void
CAnimManager::UncompressAnimation(CAnimBlendHierarchy *hier)
{
- if(hier->compressed2){
+ if(hier->keepCompressed){
if(hier->totalLength == 0.0f)
hier->CalcTotalTimeCompressed();
}else{
@@ -1275,7 +1279,7 @@ CAnimManager::LoadAnimFile(const char *filename)
//--MIAMI: done
void
-CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32])
+CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedAnims)[32])
{
#define ROUNDSIZE(x) if((x) & 3) (x) += 4 - ((x)&3)
struct IfpHeader {
@@ -1320,16 +1324,22 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
RwStreamRead(stream, buf, name.size);
hier->SetName(buf);
- // Unimplemented uncompressed anim thing
- if (somename) {
- for (int i = 0; somename[i][0]; i++) {
- if (!CGeneral::faststricmp(somename[i], hier->name))
+#ifdef ANIM_COMPRESSION
+ bool compressHier = compress;
+#else
+ bool compressHier = false;
+#endif
+ if (uncompressedAnims) {
+ for (int i = 0; uncompressedAnims[i][0]; i++) {
+ if (!CGeneral::faststricmp(uncompressedAnims[i], hier->name)){
debug("Loading %s uncompressed\n", hier->name);
+ compressHier = false;
+ }
}
}
- hier->compressed = false;
- hier->compressed2 = false;
+ hier->compressed = compressHier;
+ hier->keepCompressed = false;
// DG info has number of nodes/sequences
RwStreamRead(stream, (char*)&dgan, sizeof(IfpHeader));
@@ -1349,67 +1359,86 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
ROUNDSIZE(anim.size);
RwStreamRead(stream, buf, anim.size);
int numFrames = *(int*)(buf+28);
+ seq->SetName(buf);
if(anim.size == 44)
seq->SetBoneTag(*(int*)(buf+40));
- seq->SetName(buf);
if(numFrames == 0)
continue;
+ bool hasScale = false;
+ bool hasTranslation = false;
RwStreamRead(stream, &info, sizeof(info));
- if(strncmp(info.ident, "KR00", 4) == 0){
- seq->SetNumFrames(numFrames, false, false);
- KeyFrame *kf = seq->GetKeyFrame(0);
- if (strstr(seq->name, "L Toe"))
- debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
-
- for(l = 0; l < numFrames; l++, kf++){
- RwStreamRead(stream, buf, 0x14);
- kf->rotation.x = -fbuf[0];
- kf->rotation.y = -fbuf[1];
- kf->rotation.z = -fbuf[2];
- kf->rotation.w = fbuf[3];
- kf->deltaTime = fbuf[4]; // absolute time here
- }
+ if(strncmp(info.ident, "KRTS", 4) == 0){
+ hasScale = true;
+ seq->SetNumFrames(numFrames, true, compressHier);
}else if(strncmp(info.ident, "KRT0", 4) == 0){
- seq->SetNumFrames(numFrames, true, false);
- KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
- if (strstr(seq->name, "L Toe"))
- debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
+ hasTranslation = true;
+ seq->SetNumFrames(numFrames, true, compressHier);
+ }else if(strncmp(info.ident, "KR00", 4) == 0){
+ seq->SetNumFrames(numFrames, false, compressHier);
+ }
+ if(strstr(seq->name, "L Toe"))
+ debug("anim %s has toe keyframes\n", hier->name); // BUG: seq->name
- for(l = 0; l < numFrames; l++, kf++){
+ for(l = 0; l < numFrames; l++){
+ if(hasScale){
+ RwStreamRead(stream, buf, 0x2C);
+ CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
+ rot.Invert();
+ CVector trans(fbuf[4], fbuf[5], fbuf[6]);
+
+ if(compressHier){
+ KeyFrameTransCompressed *kf = (KeyFrameTransCompressed*)seq->GetKeyFrameCompressed(l);
+ kf->SetRotation(rot);
+ kf->SetTranslation(trans);
+ // scaling ignored
+ kf->SetTime(fbuf[10]); // absolute time here
+ }else{
+ KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
+ kf->rotation = rot;
+ kf->translation = trans;
+ // scaling ignored
+ kf->deltaTime = fbuf[10]; // absolute time here
+ }
+ }else if(hasTranslation){
RwStreamRead(stream, buf, 0x20);
- kf->rotation.x = -fbuf[0];
- kf->rotation.y = -fbuf[1];
- kf->rotation.z = -fbuf[2];
- kf->rotation.w = fbuf[3];
- kf->translation.x = fbuf[4];
- kf->translation.y = fbuf[5];
- kf->translation.z = fbuf[6];
- kf->deltaTime = fbuf[7]; // absolute time here
- }
- }else if(strncmp(info.ident, "KRTS", 4) == 0){
- seq->SetNumFrames(numFrames, true, false);
- KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
- if (strstr(seq->name, "L Toe"))
- debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
+ CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
+ rot.Invert();
+ CVector trans(fbuf[4], fbuf[5], fbuf[6]);
- for(l = 0; l < numFrames; l++, kf++){
- RwStreamRead(stream, buf, 0x2C);
- kf->rotation.x = -fbuf[0];
- kf->rotation.y = -fbuf[1];
- kf->rotation.z = -fbuf[2];
- kf->rotation.w = fbuf[3];
- kf->translation.x = fbuf[4];
- kf->translation.y = fbuf[5];
- kf->translation.z = fbuf[6];
- // scaling ignored
- kf->deltaTime = fbuf[10]; // absolute time here
+ if(compressHier){
+ KeyFrameTransCompressed *kf = (KeyFrameTransCompressed*)seq->GetKeyFrameCompressed(l);
+ kf->SetRotation(rot);
+ kf->SetTranslation(trans);
+ kf->SetTime(fbuf[7]); // absolute time here
+ }else{
+ KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
+ kf->rotation = rot;
+ kf->translation = trans;
+ kf->deltaTime = fbuf[7]; // absolute time here
+ }
+ }else{
+ RwStreamRead(stream, buf, 0x14);
+ CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
+ rot.Invert();
+
+ if(compressHier){
+ KeyFrameCompressed *kf = (KeyFrameCompressed*)seq->GetKeyFrameCompressed(l);
+ kf->SetRotation(rot);
+ kf->SetTime(fbuf[4]); // absolute time here
+ }else{
+ KeyFrame *kf = (KeyFrame*)seq->GetKeyFrame(l);
+ kf->rotation = rot;
+ kf->deltaTime = fbuf[4]; // absolute time here
+ }
}
}
}
- hier->RemoveQuaternionFlips();
- hier->CalcTotalTime();
+ if(!compressHier){
+ hier->RemoveQuaternionFlips();
+ hier->CalcTotalTime();
+ }
}
if(animIndex > ms_numAnimations)
ms_numAnimations = animIndex;
diff --git a/src/animation/AnimManager.h b/src/animation/AnimManager.h
index a55577b1..213326b6 100644
--- a/src/animation/AnimManager.h
+++ b/src/animation/AnimManager.h
@@ -57,6 +57,7 @@ enum AssocGroupId
ASSOCGRP_JOGWOMAN,
ASSOCGRP_PANICCHUNKY,
ASSOCGRP_SKATE,
+#ifdef PC_PLAYER_CONTROLS
ASSOCGRP_PLAYERBACK,
ASSOCGRP_PLAYERLEFT,
ASSOCGRP_PLAYERRIGHT,
@@ -66,6 +67,7 @@ enum AssocGroupId
ASSOCGRP_CHAINSAWBACK,
ASSOCGRP_CHAINSAWLEFT,
ASSOCGRP_CHAINSAWRIGHT,
+#endif
NUM_ANIM_ASSOC_GROUPS
};
@@ -136,7 +138,7 @@ public:
static CAnimBlendAssociation *BlendAnimation(RpClump *clump, AssocGroupId groupId, AnimationId animId, float delta);
static void LoadAnimFiles(void);
static void LoadAnimFile(const char *filename);
- static void LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32] = nil);
+ static void LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedAnims)[32] = nil);
static void CreateAnimAssocGroups(void);
static void RemoveLastAnimFile(void);
static CAnimBlendAssocGroup* GetAnimAssocGroups(void) { return ms_aAnimAssocGroups; }
diff --git a/src/animation/CutsceneMgr.cpp b/src/animation/CutsceneMgr.cpp
index 64951a87..b312236b 100644
--- a/src/animation/CutsceneMgr.cpp
+++ b/src/animation/CutsceneMgr.cpp
@@ -291,12 +291,15 @@ CCutsceneMgr::SetupCutsceneToStart(void)
if (ms_pCutsceneObjects[i]->m_pAttachTo != nil) {
pAnimBlendAssoc->flags &= (~ASSOC_HAS_TRANSLATION);
} else {
- KeyFrameTrans* keyFrames;
- if (pAnimBlendAssoc->hierarchy->IsCompressed())
- keyFrames = ((KeyFrameTrans*)pAnimBlendAssoc->hierarchy->sequences[0].GetKeyFrameCompressed(0));
- else
- keyFrames = ((KeyFrameTrans*)pAnimBlendAssoc->hierarchy->sequences[0].GetKeyFrame(0));
- ms_pCutsceneObjects[i]->SetPosition(ms_cutsceneOffset + keyFrames->translation);
+ if (pAnimBlendAssoc->hierarchy->IsCompressed()){
+ KeyFrameTransCompressed *keyFrames = ((KeyFrameTransCompressed*)pAnimBlendAssoc->hierarchy->sequences[0].GetKeyFrameCompressed(0));
+ CVector trans;
+ keyFrames->GetTranslation(&trans);
+ ms_pCutsceneObjects[i]->SetPosition(ms_cutsceneOffset + trans);
+ }else{
+ KeyFrameTrans *keyFrames = ((KeyFrameTrans*)pAnimBlendAssoc->hierarchy->sequences[0].GetKeyFrame(0));
+ ms_pCutsceneObjects[i]->SetPosition(ms_cutsceneOffset + keyFrames->translation);
+ }
}
pAnimBlendAssoc->SetRun();
} else {
@@ -331,7 +334,7 @@ CCutsceneMgr::SetCutsceneAnim(const char *animName, CObject *pObject)
}
if (pNewAnim->hierarchy->IsCompressed())
- pNewAnim->hierarchy->compressed2 = true;
+ pNewAnim->hierarchy->keepCompressed = true;
CStreaming::ImGonnaUseStreamingMemory();
pNewAnim = ms_cutsceneAssociations.CopyAnimation(animName);
@@ -344,8 +347,8 @@ CCutsceneMgr::SetCutsceneAnim(const char *animName, CObject *pObject)
pAnimBlendClumpData = *RPANIMBLENDCLUMPDATA(pObject->m_rwObject);
pAnimBlendClumpData->link.Prepend(&pNewAnim->link);
- if (pNewAnim->hierarchy->compressed2)
- pAnimBlendClumpData->frames->flag |= AnimBlendFrameData::UNK_COMPRESSED;
+ if (pNewAnim->hierarchy->keepCompressed)
+ pAnimBlendClumpData->frames->flag |= AnimBlendFrameData::COMPRESSED;
}
void
diff --git a/src/animation/FrameUpdate.cpp b/src/animation/FrameUpdate.cpp
index faeea709..a085fd4b 100644
--- a/src/animation/FrameUpdate.cpp
+++ b/src/animation/FrameUpdate.cpp
@@ -19,6 +19,9 @@ void FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackWithVelocityExtractionSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackWith3dVelocityExtractionSkinned(AnimBlendFrameData *frame, void *arg);
+void FrameUpdateCallBackNonSkinnedCompressed(AnimBlendFrameData *frame, void *arg);
+void FrameUpdateCallBackSkinnedCompressed(AnimBlendFrameData *frame, void *arg);
+
void
FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg)
{
@@ -446,3 +449,222 @@ FrameUpdateCallBackOffscreen(AnimBlendFrameData *frame, void *arg)
if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION && gpAnimBlendClump->velocity)
FrameUpdateCallBackWithVelocityExtractionSkinned(frame, arg);
}
+
+
+void
+FrameUpdateCallBackNonSkinnedCompressed(AnimBlendFrameData *frame, void *arg)
+{
+ CVector vec, pos(0.0f, 0.0f, 0.0f);
+ CQuaternion q, rot(0.0f, 0.0f, 0.0f, 0.0f);
+ float totalBlendAmount = 0.0f;
+ CVector trans(0.0f, 0.0f, 0.0f);
+ CVector cur(0.0f, 0.0f, 0.0f);
+ CVector end(0.0f, 0.0f, 0.0f);
+ bool looped = false;
+ RwMatrix *mat = RwFrameGetMatrix(frame->frame);
+ CAnimBlendNode **node;
+ AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg;
+
+ if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION &&
+ gpAnimBlendClump->velocity){
+ if(updateData->foobar)
+ for(node = updateData->nodes; *node; node++)
+ if((*node)->sequence && (*node)->association->IsPartial())
+ totalBlendAmount += (*node)->association->blendAmount;
+
+ for(node = updateData->nodes; *node; node++)
+ if((*node)->sequence && (*node)->sequence->HasTranslation()){
+ if((*node)->association->HasTranslation()){
+ (*node)->GetCurrentTranslationCompressed(vec, 1.0f-totalBlendAmount);
+ cur += vec;
+ }
+ }
+
+ for(node = updateData->nodes; *node; node++){
+ if((*node)->sequence){
+ bool nodelooped = (*node)->UpdateCompressed(vec, q, 1.0f-totalBlendAmount);
+#ifdef FIX_BUGS
+ if(DotProduct(rot, q) < 0.0f)
+ rot -= q;
+ else
+#endif
+ rot += q;
+ if((*node)->sequence->HasTranslation()){
+ pos += vec;
+ if((*node)->association->HasTranslation()){
+ trans += vec;
+ looped |= nodelooped;
+ if(nodelooped){
+ (*node)->GetEndTranslationCompressed(vec, 1.0f-totalBlendAmount);
+ end += vec;
+ }
+ }
+ }
+ }
+ ++*node;
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_ROTATION) == 0){
+ RwMatrixSetIdentity(mat);
+ rot.Normalise();
+ rot.Get(mat);
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
+ *gpAnimBlendClump->velocity = trans - cur;
+ if(looped)
+ *gpAnimBlendClump->velocity += end;
+ mat->pos.x = (pos - trans).x + frame->resetPos.x;
+ mat->pos.y = (pos - trans).y + frame->resetPos.y;
+ mat->pos.z = (pos - trans).z + frame->resetPos.z;
+ }
+ RwMatrixUpdate(mat);
+ }else{
+ if(updateData->foobar)
+ for(node = updateData->nodes; *node; node++)
+ if((*node)->sequence && (*node)->association->IsPartial())
+ totalBlendAmount += (*node)->association->blendAmount;
+
+ for(node = updateData->nodes; *node; node++){
+ if((*node)->sequence){
+ (*node)->UpdateCompressed(vec, q, 1.0f-totalBlendAmount);
+ if((*node)->sequence->HasTranslation())
+ pos += vec;
+#ifdef FIX_BUGS
+ if(DotProduct(rot, q) < 0.0f)
+ rot -= q;
+ else
+#endif
+ rot += q;
+ }
+ ++*node;
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_ROTATION) == 0){
+ RwMatrixSetIdentity(mat);
+ rot.Normalise();
+ rot.Get(mat);
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
+ mat->pos.x = pos.x;
+ mat->pos.y = pos.y;
+ mat->pos.z = pos.z;
+ mat->pos.x += frame->resetPos.x;
+ mat->pos.y += frame->resetPos.y;
+ mat->pos.z += frame->resetPos.z;
+ }
+ RwMatrixUpdate(mat);
+ }
+}
+
+void
+FrameUpdateCallBackSkinnedCompressed(AnimBlendFrameData *frame, void *arg)
+{
+ CVector vec, pos(0.0f, 0.0f, 0.0f);
+ CQuaternion q, rot(0.0f, 0.0f, 0.0f, 0.0f);
+ float totalBlendAmount = 0.0f;
+ CVector trans(0.0f, 0.0f, 0.0f);
+ CVector cur(0.0f, 0.0f, 0.0f);
+ CVector end(0.0f, 0.0f, 0.0f);
+ bool looped = false;
+ RpHAnimStdInterpFrame *xform = frame->hanimFrame;
+ CAnimBlendNode **node;
+ AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg;
+
+ if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION &&
+ gpAnimBlendClump->velocity){
+ if(updateData->foobar)
+ for(node = updateData->nodes; *node; node++)
+ if((*node)->sequence && (*node)->association->IsPartial())
+ totalBlendAmount += (*node)->association->blendAmount;
+
+ for(node = updateData->nodes; *node; node++)
+ if((*node)->sequence && (*node)->sequence->HasTranslation()){
+ if((*node)->association->HasTranslation()){
+ (*node)->GetCurrentTranslationCompressed(vec, 1.0f-totalBlendAmount);
+ cur += vec;
+ }
+ }
+
+ for(node = updateData->nodes; *node; node++){
+ if((*node)->sequence){
+ bool nodelooped = (*node)->UpdateCompressed(vec, q, 1.0f-totalBlendAmount);
+#ifdef FIX_BUGS
+ if(DotProduct(rot, q) < 0.0f)
+ rot -= q;
+ else
+#endif
+ rot += q;
+ if((*node)->sequence->HasTranslation()){
+ pos += vec;
+ if((*node)->association->HasTranslation()){
+ trans += vec;
+ looped |= nodelooped;
+ if(nodelooped){
+ (*node)->GetEndTranslationCompressed(vec, 1.0f-totalBlendAmount);
+ end += vec;
+ }
+ }
+ }
+ }
+ ++*node;
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_ROTATION) == 0){
+ rot.Normalise();
+ xform->q.imag.x = rot.x;
+ xform->q.imag.y = rot.y;
+ xform->q.imag.z = rot.z;
+ xform->q.real = rot.w;
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
+ *gpAnimBlendClump->velocity = trans - cur;
+ if(looped)
+ *gpAnimBlendClump->velocity += end;
+ xform->t.x = (pos - trans).x + frame->resetPos.x;
+ xform->t.y = (pos - trans).y + frame->resetPos.y;
+ xform->t.z = (pos - trans).z + frame->resetPos.z;
+ }
+ }else{
+ float transBlendAmount = 0.0f;
+
+ if(updateData->foobar)
+ for(node = updateData->nodes; *node; node++)
+ if((*node)->sequence && (*node)->association->IsPartial())
+ totalBlendAmount += (*node)->association->blendAmount;
+
+ for(node = updateData->nodes; *node; node++){
+ if((*node)->sequence){
+ (*node)->UpdateCompressed(vec, q, 1.0f-totalBlendAmount);
+ if((*node)->sequence->HasTranslation()){
+ pos += vec;
+ transBlendAmount += (*node)->association->blendAmount;
+ }
+ if(DotProduct(rot, q) < 0.0f)
+ rot -= q;
+ else
+ rot += q;
+ }
+ ++*node;
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_ROTATION) == 0){
+ rot.Normalise();
+ xform->q.imag.x = rot.x;
+ xform->q.imag.y = rot.y;
+ xform->q.imag.z = rot.z;
+ xform->q.real = rot.w;
+ }
+
+ if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
+ xform->t.x = transBlendAmount*pos.x;
+ xform->t.y = transBlendAmount*pos.y;
+ xform->t.z = transBlendAmount*pos.z;
+ xform->t.x += (1.0f-transBlendAmount)*frame->resetPos.x;
+ xform->t.y += (1.0f-transBlendAmount)*frame->resetPos.y;
+ xform->t.z += (1.0f-transBlendAmount)*frame->resetPos.z;
+ }
+ }
+}
diff --git a/src/animation/RpAnimBlend.cpp b/src/animation/RpAnimBlend.cpp
index e93615b7..c4103dbf 100644
--- a/src/animation/RpAnimBlend.cpp
+++ b/src/animation/RpAnimBlend.cpp
@@ -8,6 +8,7 @@
#include "AnimBlendClumpData.h"
#include "AnimBlendHierarchy.h"
#include "AnimBlendAssociation.h"
+#include "AnimManager.h"
#include "RpAnimBlend.h"
#include "PedModelInfo.h"
@@ -443,6 +444,9 @@ RpAnimBlendNodeUpdateKeyframes(AnimBlendFrameData *frames, AnimBlendFrameUpdateD
}
}
+// TODO:
+// CAnimBlendClumpData::LoadFramesIntoSPR
+// CAnimBlendClumpData::ForAllFramesInSPR
void
RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta, bool doRender)
{
@@ -466,7 +470,7 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta, bool doRender)
assoc = CAnimBlendAssociation::FromLink(link);
if(assoc->UpdateBlend(timeDelta)){
if(assoc->hierarchy->sequences){
- //CAnimManager::UncompressAnimation(v6->hierarchy)
+ CAnimManager::UncompressAnimation(assoc->hierarchy);
if(i < 11)
updateData.nodes[i++] = assoc->GetNode(0);
if(assoc->flags & ASSOC_MOVEMENT){
@@ -486,6 +490,14 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta, bool doRender)
updateData.nodes[i] = nil;
+#ifdef ANIM_COMPRESSION
+ if(clumpData->frames[0].flag & AnimBlendFrameData::COMPRESSED){
+ if(IsClumpSkinned(clump))
+ clumpData->ForAllFrames(FrameUpdateCallBackSkinnedCompressed, &updateData);
+ else
+ clumpData->ForAllFrames(FrameUpdateCallBackNonSkinnedCompressed, &updateData);
+ }else
+#endif
if(doRender){
if(clumpData->frames[0].flag & AnimBlendFrameData::UPDATE_KEYFRAMES)
RpAnimBlendNodeUpdateKeyframes(clumpData->frames, &updateData, clumpData->numFrames);
diff --git a/src/animation/RpAnimBlend.h b/src/animation/RpAnimBlend.h
index d0f7a114..6e9e0f0f 100644
--- a/src/animation/RpAnimBlend.h
+++ b/src/animation/RpAnimBlend.h
@@ -43,3 +43,6 @@ extern CAnimBlendClumpData *gpAnimBlendClump;
void FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackOffscreen(AnimBlendFrameData *frame, void *arg);
+
+void FrameUpdateCallBackNonSkinnedCompressed(AnimBlendFrameData *frame, void *arg);
+void FrameUpdateCallBackSkinnedCompressed(AnimBlendFrameData *frame, void *arg);
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index be8ab269..5b2fb75c 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -123,39 +123,39 @@ cAudioManager::PostInitialiseGameSpecificSetup()
{
m_nFireAudioEntity = CreateEntity(AUDIOTYPE_FIRE, &gFireManager);
if (m_nFireAudioEntity >= 0)
- SetEntityStatus(m_nFireAudioEntity, 1);
+ SetEntityStatus(m_nFireAudioEntity, true);
m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (void *)1);
if (m_nCollisionEntity >= 0)
- SetEntityStatus(m_nCollisionEntity, 1);
+ SetEntityStatus(m_nCollisionEntity, true);
m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (void *)1);
if (m_nFrontEndEntity >= 0)
- SetEntityStatus(m_nFrontEndEntity, 1);
+ SetEntityStatus(m_nFrontEndEntity, true);
m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (void *)1);
if (m_nProjectileEntity >= 0)
- SetEntityStatus(m_nProjectileEntity, 1);
+ SetEntityStatus(m_nProjectileEntity, true);
m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (void *)1);
if (m_nWaterCannonEntity >= 0)
- SetEntityStatus(m_nWaterCannonEntity, 1);
+ SetEntityStatus(m_nWaterCannonEntity, true);
m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (void *)1);
if (m_nPoliceChannelEntity >= 0)
- SetEntityStatus(m_nPoliceChannelEntity, 1);
+ SetEntityStatus(m_nPoliceChannelEntity, true);
#ifdef GTA_BRIDGE
m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (void*)1);
if (m_nBridgeEntity >= 0)
- SetEntityStatus(m_nBridgeEntity, 1);
+ SetEntityStatus(m_nBridgeEntity, true);
#endif // GTA_BRIDGE
m_nEscalatorEntity = CreateEntity(AUDIOTYPE_ESCALATOR, (void*)1);
if (m_nEscalatorEntity >= 0)
- SetEntityStatus(m_nEscalatorEntity, 1);
+ SetEntityStatus(m_nEscalatorEntity, true);
m_nExtraSoundsEntity = CreateEntity(AUDIOTYPE_EXTRA_SOUNDS, (void*)1);
if (m_nExtraSoundsEntity >= 0)
- SetEntityStatus(m_nExtraSoundsEntity, 1);
+ SetEntityStatus(m_nExtraSoundsEntity, true);
m_sMissionAudio.m_nSampleIndex[0] = NO_SAMPLE;
@@ -261,7 +261,7 @@ cAudioManager::ProcessReverb() const
if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) {
for (uint32 i = 0; i < numChannels; i++) {
if (m_asActiveSamples[i].m_bReverbFlag)
- SampleManager.SetChannelReverbFlag(i, 1);
+ SampleManager.SetChannelReverbFlag(i, true);
}
}
}
@@ -349,7 +349,7 @@ cAudioManager::ProcessSpecial()
if (playerPed != nil) {
if (playerPed->m_audioEntityId >= 0 && m_asAudioEntities[playerPed->m_audioEntityId].m_bIsUsed) {
if (playerPed->EnteringCar()) {
- if(!playerPed->bInVehicle&& CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle == nil)
+ if(!playerPed->bInVehicle && CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle == nil)
SampleManager.StopChannel(m_nActiveSamples);
}
}
@@ -360,7 +360,7 @@ cAudioManager::ProcessSpecial()
void
cAudioManager::ProcessEntity(int32 id)
{
- if (m_asAudioEntities[id].m_nStatus != STATUS_PLAYER) {
+ if (m_asAudioEntities[id].m_bStatus) {
m_sQueueSample.m_nEntityIndex = id;
switch (m_asAudioEntities[id].m_nType) {
case AUDIOTYPE_PHYSICAL:
@@ -1980,27 +1980,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
}
} else {
nCruising = 1;
- params.m_pVehicle->bAudioChangingGear = true;
- bAccelSampleStopped = true;
- SampleManager.StopChannel(m_nActiveSamples);
- if (isMoped || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params.m_pVehicle->bIsHandbrakeOn
- && !lostTraction && currentGear >= params.m_pTransmission->nNumberOfGears - 1) {
- if (accelerateState >= 220 && params.m_fVelocityChange + 0.001f >= velocityChangeForAudio) {
- if (nCruising < 800)
- ++nCruising;
- } else if (nCruising > 3) {
- --nCruising;
- }
- freq = 27 * nCruising + freqModifier + 22050;
- if (engineSoundType == SFX_BANK_TRUCK)
- freq /= 2;
- AudioManager.AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, true);
- } else {
- nCruising = 0;
- }
+ goto PlayCruising;
}
}
} else {
+PlayCruising:
bAccelSampleStopped = true;
SampleManager.StopChannel(m_nActiveSamples);
if (isMoped || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params.m_pVehicle->bIsHandbrakeOn
@@ -2014,7 +1998,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
freq = 27 * nCruising + freqModifier + 22050;
if (engineSoundType == SFX_BANK_TRUCK)
freq /= 2;
- AudioManager.AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, true);
+ AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, true);
} else {
nCruising = 0;
}
@@ -2210,7 +2194,6 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params)
if (veh->m_modelIndex == MI_MRWHOOP)
return true;
- veh->m_nAlarmState;
if (veh->IsAlarmOn())
return true;
@@ -4433,8 +4416,6 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
m_sQueueSample.m_bRequireReflection = true;
break;
}
- // TODO: breaks the game right now, probably needs AudioManager.cpp to be done first
- /*
case SOUND_WEAPON_CHAINSAW_ATTACK:
if (FindVehicleOfPlayer())
continue;
@@ -4469,7 +4450,7 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
m_sQueueSample.m_nLoopCount = 0;
emittingVol = 100;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_CAR_AFTER_ACCEL_13);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopStartOffset(SFX_CAR_AFTER_ACCEL_13);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_CAR_AFTER_ACCEL_13);
m_sQueueSample.m_nEmittingVolume = 100;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -4491,13 +4472,12 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
m_sQueueSample.m_nLoopCount = 0;
emittingVol = 100;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_CAR_AFTER_ACCEL_13);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopStartOffset(SFX_CAR_AFTER_ACCEL_13);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_CAR_AFTER_ACCEL_13);
m_sQueueSample.m_nEmittingVolume = 100;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 5;
break;
- */
case SOUND_WEAPON_SHOT_FIRED:
weapon = ped->GetWeapon();
if (!weapon)
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 949d8bfb..d441b750 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -128,7 +128,7 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) {
if (!m_asAudioEntities[i].m_bIsUsed) {
m_asAudioEntities[i].m_bIsUsed = true;
- m_asAudioEntities[i].m_nStatus = 0;
+ m_asAudioEntities[i].m_bStatus = false;
m_asAudioEntities[i].m_nType = type;
m_asAudioEntities[i].m_pEntity = entity;
m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_NO_SOUND;
@@ -163,7 +163,7 @@ void
cAudioManager::SetEntityStatus(int32 id, uint8 status)
{
if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed)
- m_asAudioEntities[id].m_nStatus = status;
+ m_asAudioEntities[id].m_bStatus = status;
}
void
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index d0f11427..378e16d3 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -49,7 +49,7 @@ public:
eAudioType m_nType;
void *m_pEntity;
bool m_bIsUsed;
- uint8 m_nStatus;
+ uint8 m_bStatus;
int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS];
float m_afVolume[NUM_AUDIOENTITY_EVENTS];
uint8 m_AudioEvents;
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index 8aedf306..c4abf351 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -223,8 +223,8 @@ void
cMusicManager::SetRadioChannelByScript(uint32 station, int32 pos)
{
if (m_bIsInitialised) {
- if (station == USERTRACK)
- station = RADIO_OFF;
+ if (station == STREAMED_SOUND_RADIO_MP3_PLAYER)
+ station = STREAMED_SOUND_CITY_AMBIENT;
if (station <= STREAMED_SOUND_RADIO_POLICE) {
m_bRadioSetByScript = true;
m_nRadioStation = station;
@@ -512,7 +512,7 @@ cMusicManager::ServiceGameMode()
gRetuneCounter = 0;
field_2 = false;
} else if (ped) {
- if (ped->m_objective != OBJECTIVE_WAIT_ON_FOOT_AT_ICE_CREAM_VAN && ped->m_objective != OBJ_55) {
+ if(!ped->DyingOrDead()) {
#ifdef GTA_PC
if (SampleManager.IsMP3RadioChannelAvailable()
&& vehicle->m_nRadioStation < USERTRACK
@@ -564,8 +564,8 @@ cMusicManager::ServiceGameMode()
gRetuneCounter = 0;
return;
}
- if (m_nAnnouncement == NO_TRACK)
- {
+ if(m_nAnnouncement == NO_TRACK) {
+ m_nStreamedTrack = NO_TRACK;
m_nFrontendTrack = GetCarTuning();
field_2 = false;
gRetuneCounter = 0;
diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp
index 781040d6..30fcbde0 100644
--- a/src/audio/PoliceRadio.cpp
+++ b/src/audio/PoliceRadio.cpp
@@ -67,7 +67,7 @@ cAudioManager::InitialisePoliceRadio()
for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++)
m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE;
- SampleManager.SetChannelReverbFlag(policeChannel, 0);
+ SampleManager.SetChannelReverbFlag(policeChannel, false);
gSpecialSuspectLastSeenReport = false;
for (int32 i = 0; i < ARRAY_SIZE(gMinTimeToNextReport); i++)
gMinTimeToNextReport[i] = m_FrameCounter;
diff --git a/src/entities/Building.cpp b/src/buildings/Building.cpp
index 8035cf25..8035cf25 100644
--- a/src/entities/Building.cpp
+++ b/src/buildings/Building.cpp
diff --git a/src/entities/Building.h b/src/buildings/Building.h
index 2c2dfb1f..2c2dfb1f 100644
--- a/src/entities/Building.h
+++ b/src/buildings/Building.h
diff --git a/src/entities/Solid.h b/src/buildings/Solid.h
index 4ca800c2..4ca800c2 100644
--- a/src/entities/Solid.h
+++ b/src/buildings/Solid.h
diff --git a/src/entities/Treadable.cpp b/src/buildings/Treadable.cpp
index 00abbe13..00abbe13 100644
--- a/src/entities/Treadable.cpp
+++ b/src/buildings/Treadable.cpp
diff --git a/src/entities/Treadable.h b/src/buildings/Treadable.h
index c3ab755e..c3ab755e 100644
--- a/src/entities/Treadable.h
+++ b/src/buildings/Treadable.h
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index 61c1a8fc..876840c4 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -152,7 +152,7 @@ void CGarages::Init(void)
}
hGarages = DMAudio.CreateEntity(AUDIOTYPE_GARAGE, (void*)1);
if (hGarages >= 0)
- DMAudio.SetEntityStatus(hGarages, 1);
+ DMAudio.SetEntityStatus(hGarages, true);
}
void CGarages::Shutdown(void)
@@ -1094,6 +1094,7 @@ void CGarage::Update()
m_eGarageState = GS_CLOSING;
m_bClosingWithoutTargetCar = false;
}
+ break;
case GS_CLOSING:
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
@@ -1101,6 +1102,8 @@ void CGarage::Update()
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
}
+ UpdateDoorsHeight();
+ break;
case GS_FULLYCLOSED:
break;
case GS_OPENING:
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 9b4715b2..2cf1748c 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -180,9 +180,11 @@ CCam::Process(void)
Process_BehindCar(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break;
case MODE_FOLLOWPED:
+#ifdef PC_PLAYER_CONTROLS
if(CCamera::m_bUseMouse3rdPerson)
Process_FollowPedWithMouse(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else
+#endif
#ifdef FREE_CAM
if(CCamera::bFreeCam)
Process_FollowPed_Rotation(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
@@ -3735,6 +3737,7 @@ CCam::Process_Fixed(const CVector &CameraTarget, float, float, float)
}
}
+#ifdef PC_PLAYER_CONTROLS
if(FrontEndMenuManager.m_ControlMethod == CONTROL_STANDARD && Using3rdPersonMouseCam()){
CPed *player = FindPlayerPed();
if(player && player->CanStrafeOrMouseControl()){
@@ -3745,6 +3748,7 @@ CCam::Process_Fixed(const CVector &CameraTarget, float, float, float)
TheCamera.pTargetEntity->GetMatrix().UpdateRW();
}
}
+#endif
}
void
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 531c3417..9c0da263 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -69,7 +69,11 @@ enum
// NB: removed explicit TheCamera from all functions
CCamera TheCamera;
+#ifdef PC_PLAYER_CONTROLS
bool CCamera::m_bUseMouse3rdPerson = true;
+#else
+bool CCamera::m_bUseMouse3rdPerson = false;
+#endif
bool bDidWeProcessAnyCinemaCam;
static bool bSwitchedToObbeCam;
float CCamera::m_fMouseAccelHorzntl;
@@ -3391,12 +3395,12 @@ CCamera::LoadTrainCamNodes(char const *name)
char token[16] = { 0 };
char filename[16] = { 0 };
uint8 *buf;
- size_t bufpos = 0;
+ ssize_t bufpos = 0;
int field = 0;
int tokpos = 0;
char c;
int i;
- size_t len;
+ ssize_t len;
strcpy(filename, name);
len = (int)strlen(filename);
diff --git a/src/core/Directory.cpp b/src/core/Directory.cpp
index 05344065..046c999d 100644
--- a/src/core/Directory.cpp
+++ b/src/core/Directory.cpp
@@ -31,7 +31,7 @@ bool
CDirectory::WriteDirFile(const char *filename)
{
int fd;
- size_t n;
+ ssize_t n;
fd = CFileMgr::OpenFileForWriting(filename);
n = CFileMgr::Write(fd, (char*)entries, numEntries*sizeof(DirectoryInfo));
CFileMgr::CloseFile(fd);
diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp
index fc345163..8e639656 100644
--- a/src/core/EventList.cpp
+++ b/src/core/EventList.cpp
@@ -120,7 +120,7 @@ CEventList::RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent
}
if(criminal == FindPlayerPed())
- ReportCrimeForEvent(type, (uintptr)ent, copsDontCare);
+ ReportCrimeForEvent(type, (intptr)ent, copsDontCare);
}
void
@@ -198,7 +198,7 @@ CEventList::FindClosestEvent(eEventType type, CVector posn, int32 *event)
}
void
-CEventList::ReportCrimeForEvent(eEventType type, size_t crimeId, bool copsDontCare)
+CEventList::ReportCrimeForEvent(eEventType type, intptr crimeId, bool copsDontCare)
{
eCrimeType crime;
switch(type){
diff --git a/src/core/EventList.h b/src/core/EventList.h
index dcca1270..3e9d8fd4 100644
--- a/src/core/EventList.h
+++ b/src/core/EventList.h
@@ -62,7 +62,7 @@ public:
static bool GetEvent(eEventType type, int32 *event);
static void ClearEvent(int32 event);
static bool FindClosestEvent(eEventType type, CVector posn, int32 *event);
- static void ReportCrimeForEvent(eEventType type, size_t, bool);
+ static void ReportCrimeForEvent(eEventType type, intptr, bool);
};
extern CEvent gaEvent[NUMEVENTS]; \ No newline at end of file
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index d66a1b88..dd313f79 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -98,10 +98,13 @@ CFileLoader::LoadLevel(const char *filename)
}else if(strncmp(line, "IPL", 3) == 0){
if(!objectsLoaded){
LoadingScreenLoadingFile("Collision");
- POP_MEMID();
+ PUSH_MEMID(MEMID_WORLD);
CObjectData::Initialise("DATA\\OBJECT.DAT");
CStreaming::Init();
+ POP_MEMID();
+ PUSH_MEMID(MEMID_COLLISION);
CColStore::LoadAllCollision();
+ POP_MEMID();
for(int i = 0; i < MODELINFOSIZE; i++)
if(CModelInfo::GetModelInfo(i))
CModelInfo::GetModelInfo(i)->ConvertAnimFileIndex();
@@ -110,12 +113,15 @@ CFileLoader::LoadLevel(const char *filename)
PUSH_MEMID(MEMID_WORLD);
LoadingScreenLoadingFile(line + 4);
LoadScene(line + 4);
+ POP_MEMID();
}else if(strncmp(line, "SPLASH", 6) == 0){
#ifndef DISABLE_LOADING_SCREEN
LoadSplash(GetRandomSplashScreen());
#endif
+#ifndef GTA_PS2
}else if(strncmp(line, "CDIMAGE", 7) == 0){
CdStreamAddImage(line + 8);
+#endif
}
}
diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp
index d3695cb4..99923ddf 100644
--- a/src/core/FileMgr.cpp
+++ b/src/core/FileMgr.cpp
@@ -240,20 +240,22 @@ CFileMgr::SetDirMyDocuments(void)
mychdir(_psGetUserFilesFolder());
}
-size_t
+ssize_t
CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode)
{
int fd;
- size_t n, len;
+ ssize_t n, len;
fd = myfopen(file, mode);
if(fd == 0)
- return 0;
+ return -1;
len = 0;
do{
n = myfread(buf + len, 1, 0x4000, fd);
- if(n < 0)
+#ifndef FIX_BUGS
+ if (n < 0)
return -1;
+#endif
len += n;
}while(n == 0x4000);
buf[len] = 0;
@@ -274,13 +276,13 @@ CFileMgr::OpenFileForWriting(const char *file)
}
size_t
-CFileMgr::Read(int fd, const char *buf, size_t len)
+CFileMgr::Read(int fd, const char *buf, ssize_t len)
{
return myfread((void*)buf, 1, len, fd);
}
size_t
-CFileMgr::Write(int fd, const char *buf, size_t len)
+CFileMgr::Write(int fd, const char *buf, ssize_t len)
{
return myfwrite((void*)buf, 1, len, fd);
}
diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h
index 8278953b..98a78360 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 size_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
+ static ssize_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 size_t Read(int fd, const char *buf, size_t len);
- static size_t Write(int fd, const char *buf, size_t len);
+ static size_t Read(int fd, const char *buf, ssize_t len);
+ static size_t Write(int fd, const char *buf, ssize_t 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 e73ffea1..c4c39b1f 100644
--- a/src/core/Fire.cpp
+++ b/src/core/Fire.cpp
@@ -46,7 +46,7 @@ CFire::ProcessFire(void)
float fDamagePlayer;
float fDamagePeds;
float fDamageVehicle;
- int8 nRandNumber;
+ int16 nRandNumber;
float fGreen;
float fRed;
CVector lightpos;
@@ -152,11 +152,10 @@ CFire::ProcessFire(void)
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;
+ fGreen = nRandNumber / 128.f;
+ fRed = nRandNumber / 128.f;
- CPointLights::AddLight(0, m_vecPos, CVector(0.0f, 0.0f, 0.0f),
- 12.0f, fRed, fGreen, 0, 0, 0);
+ CPointLights::AddLight(CPointLights::LIGHT_POINT, m_vecPos, CVector(0.0f, 0.0f, 0.0f), 12.0f, fRed, fGreen, 0.0f, 0, 0);
} else {
Extinguish();
}
@@ -395,19 +394,16 @@ CFireManager::ExtinguishPoint(CVector point, float range)
bool
CFireManager::ExtinguishPointWithWater(CVector point, float range)
{
- int fireI = 0;
- for (int i = 0; i < NUM_FIRES; i++) {
- if (m_aFires[i].m_bIsOngoing) {
- if ((point - m_aFires[i].m_vecPos).MagnitudeSqr() < sq(range)) {
- fireI = i;
- break;
- }
- }
- }
- if (fireI == NUM_FIRES)
- return false;
-
- CFire *fireToExtinguish = &m_aFires[fireI];
+ int i;
+ for (i = 0; i < NUM_FIRES;) {
+ if (m_aFires[i].m_bIsOngoing && (point - m_aFires[i].m_vecPos).MagnitudeSqr() < sq(range)) {
+ break;
+ }
+ if (++i >= NUM_FIRES)
+ return false;
+ }
+
+ CFire *fireToExtinguish = &m_aFires[i];
fireToExtinguish->m_fWaterExtinguishCountdown -= 0.012f * CTimer::GetTimeStep();
CVector steamPos = fireToExtinguish->m_vecPos +
CVector((CGeneral::GetRandomNumber() - 128) * 3.1f / 200.f,
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 18554a4d..95f3de86 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -493,7 +493,11 @@ CMenuManager::CMenuManager()
m_PrefsDMA = 1;
OS_Language = LANG_ENGLISH;
m_ControlMethod = CONTROL_STANDARD;
+#ifdef PC_PLAYER_CONTROLS
CCamera::m_bUseMouse3rdPerson = true;
+#else
+ CCamera::m_bUseMouse3rdPerson = false;
+#endif
m_lastWorking3DAudioProvider = 0;
m_nFirstVisibleRowOnList = 0;
m_nScrollbarTopMargin = 0.0f;
@@ -2474,7 +2478,7 @@ CMenuManager::DrawPlayerSetupScreen(bool activeScreen)
strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "(", 1);
if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "}", 1))
strncpy(&m_pSelectedSkin->skinNameDisplayed[k], ")", 1);
- if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "�", 1))
+ if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "£", 1))
strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "$", 1);
}
@@ -3019,7 +3023,9 @@ CMenuManager::LoadSettings()
CFileMgr::CloseFile(fileHandle);
CFileMgr::SetDir("");
+#ifdef PC_PLAYER_CONTROLS
CCamera::m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD;
+#endif
#ifdef LEGACY_MENU_OPTIONS
m_PrefsVsync = m_PrefsVsyncDisp;
#endif
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 679dd823..630bbd07 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -191,8 +191,6 @@ CGame::InitialiseRenderWare(void)
CTxdStore::Initialise();
CVisibilityPlugins::Initialise();
- //InitialiseScene(Scene); // PS2 only, only clears Scene.camera
-
#ifdef GTA_PS2
RpSkySelectTrueTSClipper(TRUE);
RpSkySelectTrueTLClipper(TRUE);
@@ -211,7 +209,7 @@ CGame::InitialiseRenderWare(void)
return (false);
}
- RwCameraSetFarClipPlane(Scene.camera, 2000.0f); // 250.0f on PS2 but who cares
+ RwCameraSetFarClipPlane(Scene.camera, 2000.0f);
RwCameraSetNearClipPlane(Scene.camera, 0.9f);
CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
@@ -255,14 +253,12 @@ CGame::InitialiseRenderWare(void)
PUSH_MEMID(MEMID_TEXTURES);
CFont::Initialise();
CHud::Initialise();
+ CPlayerSkin::Initialise();
POP_MEMID();
- CPlayerSkin::Initialise();
-
return (true);
}
-// missing altogether on PS2
void CGame::ShutdownRenderWare(void)
{
DestroySplashScreen();
@@ -272,7 +268,6 @@ void CGame::ShutdownRenderWare(void)
for ( int32 i = 0; i < NUMPLAYERS; i++ )
CWorld::Players[i].DeletePlayerSkin();
- // TODO: define
CPlayerSkin::Shutdown();
DestroyDebugFont();
@@ -295,7 +290,6 @@ void CGame::ShutdownRenderWare(void)
#endif
}
-// missing altogether on PS2
bool CGame::InitialiseOnceAfterRW(void)
{
TheText.Load();
@@ -305,7 +299,12 @@ bool CGame::InitialiseOnceAfterRW(void)
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
CPedStats::Initialise();
CTimeCycle::Initialise();
+#ifdef GTA_PS2
+ LoadingScreen("Loading the Game", "Initialising audio", GetRandomSplashScreen());
+#endif
DMAudio.Initialise();
+
+#ifndef GTA_PS2
if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = NO_AUDIO_PROVIDER;
@@ -322,10 +321,10 @@ bool CGame::InitialiseOnceAfterRW(void)
DMAudio.SetEffectsMasterVolume(FrontEndMenuManager.m_PrefsSfxVolume);
DMAudio.SetEffectsFadeVol(127);
DMAudio.SetMusicFadeVol(127);
+#endif
return true;
}
-// missing altogether on PS2
void
CGame::FinalShutdown(void)
{
@@ -336,12 +335,13 @@ CGame::FinalShutdown(void)
bool CGame::Initialise(const char* datFile)
{
+ ResetLoadingScreenBar();
+ strcpy(aDatFile, datFile);
+
#ifdef GTA_PS2
// TODO: upload VU0 collision code here
#endif
- ResetLoadingScreenBar();
- strcpy(aDatFile, datFile);
CPools::Initialise();
#ifndef GTA_PS2
@@ -408,9 +408,8 @@ bool CGame::Initialise(const char* datFile)
CCarCtrl::Init();
POP_MEMID();
- InitModelIndices();
-
PUSH_MEMID(MEMID_DEF_MODELS);
+ InitModelIndices();
CModelInfo::Initialise();
CPickups::Init();
CTheCarGenerators::Init();
@@ -428,17 +427,21 @@ bool CGame::Initialise(const char* datFile)
CVehicleModelInfo::LoadVehicleColours();
CVehicleModelInfo::LoadEnvironmentMaps();
CTheZones::PostZoneCreation();
+ POP_MEMID();
+
LoadingScreen("Loading the Game", "Setup paths", nil);
ThePaths.PreparePathData();
for (int i = 0; i < NUMPLAYERS; i++)
CWorld::Players[i].Clear();
CWorld::Players[0].LoadPlayerSkin();
TestModelIndices();
+
LoadingScreen("Loading the Game", "Setup water", nil);
WaterLevelInitialise("DATA\\WATER.DAT");
TheConsole.Init();
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
+
LoadingScreen("Loading the Game", "Setup streaming", nil);
CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds();
@@ -446,10 +449,12 @@ bool CGame::Initialise(const char* datFile)
CStreaming::LoadAllRequestedModels(false);
CStreaming::RemoveIslandsNotUsed(currLevel);
printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d
- LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
+ LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
PUSH_MEMID(MEMID_ANIMATION);
CAnimManager::LoadAnimFiles();
+ POP_MEMID();
+
CStreaming::LoadInitialWeapons();
CStreaming::LoadAllRequestedModels(0);
CPed::Initialise();
@@ -483,6 +488,7 @@ bool CGame::Initialise(const char* datFile)
#ifdef GTA_SCENE_EDIT
CSceneEdit::Initialise();
#endif
+
LoadingScreen("Loading the Game", "Load scripts", nil);
PUSH_MEMID(MEMID_SCRIPT);
CTheScripts::Init();
@@ -514,11 +520,11 @@ bool CGame::Initialise(const char* datFile)
CRecordDataForChase::Init();
CReplay::Init();
+ LoadingScreen("Loading the Game", "Start script", nil);
#ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad )
#endif
{
- LoadingScreen("Loading the Game", "Start script", nil);
CTheScripts::StartTestScript();
CTheScripts::Process();
TheCamera.Process();
@@ -752,8 +758,7 @@ void CGame::InitialiseWhenRestarting(void)
if ( FrontEndMenuManager.m_bWantToLoad == true )
{
FrontEndMenuManager.m_bWantToLoad = false;
- // TODO(Miami)
- //InitRadioStationPositionList();
+ InitRadioStationPositionList();
if ( GenericLoad() == true )
{
DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds());
@@ -801,9 +806,9 @@ void CGame::Process(void)
#endif
CCutsceneMgr::Update();
- PUSH_MEMID(MEMID_FRONTEND);
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
FrontEndMenuManager.Process();
+
CTheZones::Update();
// DRM call in here
uint32 startTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
@@ -884,11 +889,13 @@ void CGame::Process(void)
gPhoneInfo.Update();
if (!CReplay::IsPlayingBack())
{
+ PUSH_MEMID(MEMID_CARS);
if (processTime < 2)
CCarCtrl::GenerateRandomCars();
CRoadBlocks::GenerateRoadBlocks();
CCarCtrl::RemoveDistantCars();
CCarCtrl::RemoveCarsIfThePoolGetsFull();
+ POP_MEMID();
}
}
#ifdef GTA_PS2
@@ -898,6 +905,8 @@ void CGame::Process(void)
#ifdef USE_CUSTOM_ALLOCATOR
+// TODO(MIAMI)
+
int32 gNumMemMoved;
bool
diff --git a/src/core/MenuScreens.cpp b/src/core/MenuScreens.cpp
index d4d028c9..173de805 100644
--- a/src/core/MenuScreens.cpp
+++ b/src/core/MenuScreens.cpp
@@ -215,7 +215,9 @@ CMenuScreen aScreens[] = {
// MENUPAGE_CONTROLLER_PC = 26
{ "FET_CTL", MENUPAGE_OPTIONS, 0,
+#ifdef PC_PLAYER_CONTROLS
MENUACTION_CTRLMETHOD, "FET_STI", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, 320, 150, MENUALIGN_CENTER,
+#endif
MENUACTION_KEYBOARDCTRLS,"FEC_RED", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, 0, 0, MENUALIGN_CENTER,
MENUACTION_CHANGEMENU, "FEC_MOU", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, 0, 0, MENUALIGN_CENTER,
MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, 0, 0, MENUALIGN_CENTER,
diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp
index c14f938b..e35a7751 100644
--- a/src/core/MenuScreensCustom.cpp
+++ b/src/core/MenuScreensCustom.cpp
@@ -566,7 +566,9 @@ CMenuScreenCustom aScreens[] = {
// MENUPAGE_CONTROLLER_PC = 26
{ "FET_CTL", MENUPAGE_OPTIONS, new CCustomScreenLayout({0, 0, MENU_DEFAULT_LINE_HEIGHT, false, false, 150}), nil,
+#ifdef PC_PLAYER_CONTROLS
MENUACTION_CTRLMETHOD, "FET_STI", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC}, 320, 150, MENUALIGN_CENTER,
+#endif
MENUACTION_KEYBOARDCTRLS,"FEC_RED", {nil, SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS}, 0, 0, MENUALIGN_CENTER,
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
MENUACTION_CHANGEMENU, "FEC_JOD", {nil, SAVESLOT_NONE, MENUPAGE_DETECT_JOYSTICK}, 0, 0, MENUALIGN_CENTER,
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 91e2d704..7d53009d 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -1213,14 +1213,46 @@ void CPad::AddToCheatString(char c)
int Cheat_strncmp(char* sourceStr, char* origCheatStr)
{
- char cheatCodeVals[] = { 3,5,7,1,13,27,3,7,1,11,13,8,7,32,13,6,28,19,10,3,3,5,7,1,13,27,3,7 };
-
- for (uint32 i = 0; i < strlen(origCheatStr); i++) {
- if ((sourceStr[i] != origCheatStr[i] - cheatCodeVals[i]) || i >= ARRAY_SIZE(cheatCodeVals)) {
- return 1;
- }
+#define ccmp(n) if((uint8)sourceStr[i] != (uint8)origCheatStr[i] - n) return 1;
+ int i = 0;
+ while(origCheatStr[i])
+ {
+ switch(i)
+ {
+ case 0: ccmp(3); break;
+ case 1: ccmp(5); break;
+ case 2: ccmp(7); break;
+ case 3: ccmp(1); break;
+ case 4: ccmp(13); break;
+ case 5: ccmp(27); break;
+ case 6: ccmp(3); break;
+ case 7: ccmp(7); break;
+ case 8: ccmp(1); break;
+ case 9: ccmp(11); break;
+ case 10: ccmp(13); break;
+ case 11: ccmp(8); break;
+ case 12: ccmp(7); break;
+ case 13: ccmp(32); break;
+ case 14: ccmp(13); break;
+ case 15: ccmp(6); break;
+ case 16: ccmp(28); break;
+ case 17: ccmp(19); break;
+ case 18: ccmp(10); break;
+ case 19: ccmp(3); break;
+ case 20: ccmp(3); break;
+ case 21: ccmp(5); break;
+ case 22: ccmp(7); break;
+ case 23: ccmp(1); break;
+ case 24: ccmp(13); break;
+ case 25: ccmp(27); break;
+ case 26: ccmp(3); break;
+ case 27: ccmp(7); break;
+ default: return 1;
+ }
+ i++;
}
return 0;
+#undef ccmp
}
// TODO(Miami): Mobile has changed some of the cheats to include debugging things
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index f3aeda8c..dfc7a82f 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -29,6 +29,7 @@ CAudioScriptObjectPool *CPools::ms_pAudioScriptObjectPool;
CColModelPool *CPools::ms_pColModelPool;
#if defined GTA_PS2 && !defined MASTER // or USE_CUSTOM_ALLOCATOR
+// not in VC. perhaps ifdef'ed away
#define CHECKMEM(msg) CMemCheck::AllocateMemCheckBlock(msg)
#else
#define CHECKMEM(msg)
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index afc6704d..8c1b839c 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -480,6 +480,14 @@ GetObjectName(int streamId)
return objname;
}
+#ifdef USE_CUSTOM_ALLOCATOR
+RpAtomic*
+RegisterAtomicMemPtrsCB(RpAtomic *atomic, void *data)
+{
+ // empty because we expect models to be pre-instanced
+ return atomic;
+}
+#endif
bool
CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
@@ -514,9 +522,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
// Set Txd and anims to use
CTxdStore::AddRef(mi->GetTxdSlot());
+#if GTA_VERSION > GTAVC_PS2
if(animId != -1)
CAnimManager::AddAnimBlockRef(animId);
- CTxdStore::SetCurrentTxd(mi->GetTxdSlot());
+#endif
PUSH_MEMID(MEMID_STREAM_MODELS);
CTxdStore::SetCurrentTxd(mi->GetTxdSlot());
@@ -542,8 +551,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
// Txd and anims no longer needed unless we only read part of the file
if(ms_aInfoForModel[streamId].m_loadState != STREAMSTATE_STARTED){
CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot());
+#if GTA_VERSION > GTAVC_PS2
if(animId != -1)
CAnimManager::RemoveAnimBlockRefWithoutDelete(animId);
+#endif
}
if(!success){
@@ -580,7 +591,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
return false;
}
}else if(streamId >= STREAM_OFFSET_COL && streamId < STREAM_OFFSET_ANIM){
- if(!CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length)){
+ PUSH_MEMID(MEMID_STREAM_COLLISION);
+ bool success = CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length);
+ POP_MEMID();
+ if(!success){
debug("Failed to load %s.col\n", CColStore::GetColName(streamId - STREAM_OFFSET_COL));
RemoveModel(streamId);
ReRequestModel(streamId);
@@ -595,8 +609,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
RwStreamClose(stream, &mem);
return false;
}
+ PUSH_MEMID(MEMID_STREAM_ANIMATION);
CAnimManager::LoadAnimFile(stream, true, nil);
CAnimManager::CreateAnimAssocGroups();
+ POP_MEMID();
}
RwStreamClose(stream, &mem);
@@ -678,8 +694,10 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
POP_MEMID();
mi->RemoveRef();
CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot());
+#if GTA_VERSION > GTAVC_PS2
if(mi->GetAnimFileIndex() != -1)
CAnimManager::RemoveAnimBlockRefWithoutDelete(mi->GetAnimFileIndex());
+#endif
}else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){
// Txd
CTxdStore::AddRef(streamId - STREAM_OFFSET_TXD);
@@ -693,7 +711,7 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
RwStreamClose(stream, &mem);
- ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; // only done if success on PS2
+ ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED;
#ifndef USE_CUSTOM_ALLOCATOR
ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE;
#endif
@@ -701,11 +719,11 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
if(!success){
RemoveModel(streamId);
ReRequestModel(streamId);
- UpdateMemoryUsed(); // directly after pop on PS2
+ UpdateMemoryUsed();
return false;
}
- UpdateMemoryUsed(); // directly after pop on PS2
+ UpdateMemoryUsed();
endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond();
timeDiff = endTime - startTime;
@@ -2471,7 +2489,9 @@ CStreaming::UpdateMemoryUsed(void)
ms_memoryUsed =
gMainHeap.GetMemoryUsed(MEMID_STREAM) +
gMainHeap.GetMemoryUsed(MEMID_STREAM_MODELS) +
- gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES);
+ gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES) +
+ gMainHeap.GetMemoryUsed(MEMID_STREAM_COLLISION) +
+ gMainHeap.GetMemoryUsed(MEMID_STREAM_ANIMATION);
#endif
}
diff --git a/src/core/Streaming.h b/src/core/Streaming.h
index 510da7a0..a67384f6 100644
--- a/src/core/Streaming.h
+++ b/src/core/Streaming.h
@@ -197,11 +197,11 @@ public:
static void DeleteFarAwayRwObjects(const CVector &pos);
static void DeleteAllRwObjects(void);
static void DeleteRwObjectsAfterDeath(const CVector &pos);
- static void DeleteRwObjectsBehindCamera(size_t mem);
+ static void DeleteRwObjectsBehindCamera(size_t mem); // originally signed
static void DeleteRwObjectsInSectorList(CPtrList &list);
static void DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y);
- static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem);
- static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem);
+ static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem); // originally signed
+ static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem); // originally signed
static void LoadScene(const CVector &pos);
static void LoadSceneCollision(const CVector &pos);
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 8abe0f1e..55b43c10 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -209,6 +209,9 @@ CTheZones::PostZoneCreation(void)
for(i = 1; i < TotalNumberOfNavigationZones; i++)
InsertZoneIntoZoneHierarchy(&NavigationZoneArray[i]);
InitialiseAudioZoneArray();
+#ifndef MASTER
+ CheckZonesForOverlap();
+#endif
}
void
@@ -222,8 +225,7 @@ CTheZones::CheckZonesForOverlap(void)
for(j = 1; j < TotalNumberOfInfoZones; j++)
if(i != j && ZoneIsEntirelyContainedWithinOtherZone(&InfoZoneArray[i], &InfoZoneArray[j]))
- sprintf(str, "Info zone %s contains %s\n",
- &InfoZoneArray[j].name, &InfoZoneArray[i].name);
+ sprintf(str, "Info zone %s contains %s\n", InfoZoneArray[j].name, InfoZoneArray[i].name);
}
}
diff --git a/src/core/common.h b/src/core/common.h
index 882e2fae..155b5dba 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -73,11 +73,16 @@ typedef int16_t int16;
typedef uint32_t uint32;
typedef int32_t int32;
typedef uintptr_t uintptr;
+typedef intptr_t intptr;
typedef uint64_t uint64;
typedef int64_t int64;
// hardcode ucs-2
typedef uint16_t wchar;
+#if defined(_MSC_VER)
+typedef ptrdiff_t ssize_t;
+#endif
+
#ifndef nil
#define nil NULL
#endif
diff --git a/src/core/config.h b/src/core/config.h
index c46adcd8..ae2189e2 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -7,7 +7,7 @@ enum Config {
MAX_CDIMAGES = 8, // additional cdimages
MAX_CDCHANNELS = 5,
- MODELINFOSIZE = 6500,
+ MODELINFOSIZE = 6500, // 4900 on PS2
TXDSTORESIZE = 1385,
COLSTORESIZE = 31,
EXTRADIRSIZE = 256,
@@ -192,6 +192,11 @@ enum Config {
// those infamous texts
#define DRAW_GAME_VERSION_TEXT
+// Memory allocation and compression
+// #define USE_CUSTOM_ALLOCATOR // use CMemoryHeap for allocation. use with care, not finished yet
+//#define COMPRESSED_COL_VECTORS // use compressed vectors for collision vertices
+//#define ANIM_COMPRESSION // only keep most recently used anims uncompressed
+
#if defined GTA_PS2
# define GTA_PS2_STUFF
# define RANDOMSPLASH
@@ -203,6 +208,7 @@ enum Config {
# define RANDOMSPLASH // use random splash as on PS2
# define PS2_MATFX
# endif
+# define PC_PLAYER_CONTROLS // mouse player/cam mode
# define GTA_REPLAY
# define GTA_SCENE_EDIT
#elif defined GTA_XBOX
diff --git a/src/core/main.cpp b/src/core/main.cpp
index 91ad7fc1..f21bec34 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -90,7 +90,7 @@ bool gbModelViewer;
bool gbShowTimebars;
#endif
-int32 frameCount;
+volatile int32 frameCount;
RwRGBA gColourTop;
@@ -406,19 +406,21 @@ PluginAttach(void)
}
#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
+#define NUM_PREALLOC_ATOMICS 1800
+#define NUM_PREALLOC_CLUMPS 80
+#define NUM_PREALLOC_FRAMES 2600
+#define NUM_PREALLOC_GEOMETRIES 850
+#define NUM_PREALLOC_TEXDICTS 121
+#define NUM_PREALLOC_TEXTURES 1700
+#define NUM_PREALLOC_MATERIALS 2600
bool preAlloc;
void
PreAllocateRwObjects(void)
{
int i;
+
+ PUSH_MEMID(MEMID_PRE_ALLOC);
void **tmp = new void*[0x8000];
preAlloc = true;
@@ -459,24 +461,29 @@ PreAllocateRwObjects(void)
delete[] tmp;
preAlloc = false;
+ POP_MEMID();
}
#endif
static RwBool
Initialise3D(void *param)
{
+ PUSH_MEMID(MEMID_RENDER);
+
if (RsRwInitialize(param))
{
+ POP_MEMID();
+
#ifdef DEBUGMENU
DebugMenuInit();
DebugMenuPopulate();
#endif // !DEBUGMENU
#ifdef CUSTOM_FRONTEND_OPTIONS
- // Apparently this func. can be run multiple times at the start.
- if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) {
- // needs stored language and TheText to be loaded, and last TheText reload is at the start of here
- CustomFrontendOptionsPopulate();
- }
+ // Apparently this func. can be run multiple times at the start.
+ if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) {
+ // needs stored language and TheText to be loaded, and last TheText reload is at the start of here
+ CustomFrontendOptionsPopulate();
+ }
#endif
bool ret = CGame::InitialiseRenderWare();
#ifdef EXTENDED_PIPELINES
@@ -485,8 +492,10 @@ Initialise3D(void *param)
#ifdef SCREEN_DROPLETS
ScreenDroplets::InitDraw();
#endif
+
return ret;
}
+ POP_MEMID();
return (FALSE);
}
@@ -882,7 +891,7 @@ return;
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
- sprintf(gString, "Render List: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_RENDERLIST), gMainHeap.GetMemoryUsed(MEMID_RENDERLIST));
+ sprintf(gString, "PreAlloc: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_PRE_ALLOC), gMainHeap.GetMemoryUsed(MEMID_PRE_ALLOC));
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
@@ -907,11 +916,31 @@ return;
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
+ sprintf(gString, "Streamed LODs: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_LODS), gMainHeap.GetMemoryUsed(MEMID_STREAM_LODS));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
sprintf(gString, "Streamed Textures: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_TEXUTRES), gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES));
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
+ sprintf(gString, "Streamed Collision: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_COLLISION), gMainHeap.GetMemoryUsed(MEMID_STREAM_COLLISION));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
+ sprintf(gString, "Streamed Animation: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_STREAM_ANIMATION), gMainHeap.GetMemoryUsed(MEMID_STREAM_ANIMATION));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
+ sprintf(gString, "Ped Attr: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_PED_ATTR), gMainHeap.GetMemoryUsed(MEMID_PED_ATTR));
+ AsciiToUnicode(gString, gUString);
+ CFont::PrintString(24.0f, y, gUString);
+ y += 12.0f;
+
sprintf(gString, "Animation: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_ANIMATION), gMainHeap.GetMemoryUsed(MEMID_ANIMATION));
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
@@ -941,11 +970,6 @@ return;
AsciiToUnicode(gString, gUString);
CFont::PrintString(24.0f, y, gUString);
y += 12.0f;
-
- sprintf(gString, "Frontend: %d blocks, %d bytes", gMainHeap.GetBlocksUsed(MEMID_FRONTEND), gMainHeap.GetMemoryUsed(MEMID_FRONTEND));
- AsciiToUnicode(gString, gUString);
- CFont::PrintString(24.0f, y, gUString);
- y += 12.0f;
#endif
y = 132.0f;
@@ -1372,9 +1396,7 @@ RenderMenus(void)
{
if (FrontEndMenuManager.m_bMenuActive)
{
- PUSH_MEMID(MEMID_FRONTEND);
FrontEndMenuManager.DrawFrontEnd();
- POP_MEMID();
}
}
@@ -1716,17 +1738,14 @@ void TheGame(void)
CTimer::Initialise();
-#ifdef GTA_PS2
- CGame::Initialise();
-#else
CGame::Initialise("DATA\\GTA3.DAT");
-#endif
Const char *splash = GetRandomSplashScreen(); // inlined here
LoadingScreen("Starting Game", NULL, splash);
#ifdef GTA_PS2
+ // TODO(MIAMI): not checked yet
if ( TheMemoryCard.CheckCardInserted(CARD_ONE) == CMemoryCard::NO_ERR_SUCCESS
&& TheMemoryCard.ChangeDirectory(CARD_ONE, TheMemoryCard.Cards[CARD_ONE].dir)
&& TheMemoryCard.FindMostRecentFileName(CARD_ONE, TheMemoryCard.MostRecentFile) == true
@@ -1750,7 +1769,7 @@ void TheGame(void)
while (true)
{
- if (WANT_TO_LOAD)
+ if (FOUND_GAME_TO_LOAD)
{
Const char *splash1 = GetLevelSplashScreen(CGame::currLevel);
LoadSplash(splash1);
@@ -1786,14 +1805,18 @@ void TheGame(void)
PUSH_MEMID(MEMID_RENDER);
- // m_bRenderGameInMenu is there in III PS2 but I don't know about VC PS2.
- if (!FrontEndMenuManager.m_bMenuActive || /*FrontEndMenuManager.m_bRenderGameInMenu == true && */TheCamera.GetScreenFadeStatus() != FADE_2 )
- {
+ CRenderer::ConstructRenderList();
- PUSH_MEMID(MEMID_RENDERLIST);
- CRenderer::ConstructRenderList();
+ if ((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu == true) && TheCamera.GetScreenFadeStatus() != FADE_2 )
+ {
CRenderer::PreRender();
- POP_MEMID();
+ // TODO(MIAMI): something ps2all specific
+
+#ifdef FIX_BUGS
+ // This has to be done BEFORE RwCameraBeginUpdate
+ RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip());
+ RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart());
+#endif
if (CWeather::LightningFlash && !CCullZones::CamNoRain())
DoRWStuffStartOfFrame_Horizon(255, 255, 255, 255, 255, 255, 255);
@@ -1801,8 +1824,10 @@ void TheGame(void)
DoRWStuffStartOfFrame_Horizon(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(), CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(), 255);
DefinedState();
+#ifndef FIX_BUGS
RwCameraSetFarClipPlane(Scene.camera, CTimeCycle::GetFarClip());
RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart());
+#endif
RenderScene();
RenderDebugShit();
@@ -1819,8 +1844,7 @@ void TheGame(void)
CameraSize(Scene.camera, NULL, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
- if (!RsCameraBeginUpdate(Scene.camera))
- break;
+ RsCameraBeginUpdate(Scene.camera);
}
RenderMenus();
@@ -1880,10 +1904,6 @@ void TheGame(void)
void SystemInit()
{
-#ifdef __MWERKS__
- mwInit();
-#endif
-
#ifdef USE_CUSTOM_ALLOCATOR
InitMemoryMgr();
#endif
@@ -1893,7 +1913,7 @@ void SystemInit()
char path[256];
- sprintf(path, "cdrom0:\\%s%s;1", "SYSTEM\\", "IOPRP23.IMG");
+ sprintf(path, "cdrom0:\\%s%s;1", "SYSTEM\\", "IOPRP241.IMG");
sceSifInitRpc(0);
@@ -1907,11 +1927,7 @@ void SystemInit()
CFileMgr::InitCdSystem();
sceFsReset();
-#endif
- CFileMgr::Initialise();
-
-#ifdef GTA_PS2
CFileMgr::InitCd();
char modulepath[256];
@@ -1945,6 +1961,16 @@ void SystemInit()
strcat(modulepath, "SYSTEM\\");
strcat(modulepath, "MCSERV.IRX");
LoadModule(modulepath);
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "CDSTREAM.IRX");
+ LoadModule(modulepath);
+
+ strcpy(modulepath, "cdrom0:\\");
+ strcat(modulepath, "SYSTEM\\");
+ strcat(modulepath, "SAMPMAN2.IRX");
+ LoadModule(modulepath);
#endif
@@ -1974,6 +2000,7 @@ void SystemInit()
FrontEndMenuManager.m_PrefsAllowNastyGame = true;
#ifdef GTA_PS2
+ // TODO(MIAMI): this code probably went elsewhere?
int32 lang = sceScfGetLanguage();
if ( lang == SCE_ITALIAN_LANGUAGE )
FrontEndMenuManager.m_PrefsLanguage = LANGUAGE_ITALIAN;
@@ -2006,54 +2033,155 @@ void SystemInit()
#endif
}
-void GameInit()
+int VBlankCounter(int ca)
+{
+ frameCount++;
+ ExitHandler();
+ return 0;
+}
+
+// linked against by RW!
+extern "C" void WaitVBlank(void)
{
- if ( !gameAlreadyInitialised )
+ int32 startFrame = frameCount;
+ while(startFrame == frameCount);
+}
+
+void GameInit(bool onlyRW)
+{
+ if(onlyRW)
{
#ifdef GTA_PS2
- char path[256];
-
- strcpy(path, "cdrom0:\\");
- strcat(path, "SYSTEM\\");
- strcat(path, "CDSTREAM.IRX");
- LoadModule(path);
-
- strcpy(path, "cdrom0:\\");
- strcat(path, "SYSTEM\\");
- strcat(path, "SAMPMAN.IRX");
- LoadModule(path);
-
- strcpy(path, "cdrom0:\\");
- strcat(path, "SYSTEM\\");
- strcat(path, "MUSICSTR.IRX");
- LoadModule(path);
+ Initialise3D(nil);
+#else
+ Initialise3D(nil); //TODO: window parameter
#endif
- CdStreamInit(MAX_CDCHANNELS);
-
+ gameAlreadyInitialised = true;
+ }
+ else
+ {
+ if ( !gameAlreadyInitialised )
#ifdef GTA_PS2
- Initialise3D(); //no params
+ Initialise3D(nil);
#else
- //TODO
+ Initialise3D(nil); //TODO: window parameter
#endif
-
+ }
+
#ifdef GTA_PS2
char *files[] =
{
"\\ANIM\\CUTS.IMG;1",
"\\ANIM\\CUTS.DIR;1",
"\\ANIM\\PED.IFP;1",
- "\\MODELS\\FRONTEND.TXD;1",
+ "\\MODELS\\FRONTEN1.TXD;1",
+ "\\MODELS\\FRONTEN2.TXD;1",
"\\MODELS\\FONTS.TXD;1",
"\\MODELS\\HUD.TXD;1",
"\\MODELS\\PARTICLE.TXD;1",
"\\MODELS\\MISC.TXD;1",
"\\MODELS\\GENERIC.TXD;1",
"\\MODELS\\GTA3.DIR;1",
+ // TODO: japanese?
+#ifdef GTA_PAL
"\\TEXT\\ENGLISH.GXT;1",
"\\TEXT\\FRENCH.GXT;1",
"\\TEXT\\GERMAN.GXT;1",
"\\TEXT\\ITALIAN.GXT;1",
"\\TEXT\\SPANISH.GXT;1",
+#else
+ "\\TEXT\\AMERICAN.GXT;1",
+#endif
+ "\\MODELS\\COLL\\GENERIC.COL;1",
+ "\\MODELS\\COLL\\VEHICLES.COL;1",
+ "\\MODELS\\COLL\\PEDS.COL;1",
+ "\\MODELS\\COLL\\WEAPONS.COL;1",
+ "\\MODELS\\GENERIC\\AIR_VLO.DFF;1",
+ "\\MODELS\\GENERIC\\WHEELS.DFF;1",
+ "\\MODELS\\GENERIC\\ARROW.DFF;1",
+ "\\MODELS\\GENERIC\\ZONECYLB.DFF;1",
+ "\\DATA\\HANDLING.CFG;1",
+ "\\DATA\\SURFACE.DAT;1",
+ "\\DATA\\PEDSTATS.DAT;1",
+ "\\DATA\\TIMECYC.DAT;1",
+ "\\DATA\\PARTICLE.CFG;1",
+ "\\DATA\\DEFAULT.DAT;1",
+ "\\DATA\\DEFAULT.IDE;1",
+ "\\DATA\\GTA_VC.DAT;1",
+ "\\DATA\\OBJECT.DAT;1",
+ "\\DATA\\MAP.ZON;1",
+ "\\DATA\\NAVIG.ZON;1",
+ "\\DATA\\INFO.ZON;1",
+ "\\DATA\\WATERPRO.DAT;1",
+ "\\DATA\\MAIN.SCM;1",
+ "\\DATA\\CARCOLS.DAT;1",
+ "\\DATA\\PED.DAT;1",
+ "\\DATA\\FISTFITE.DAT;1",
+ "\\DATA\\WEAPON.DAT;1",
+ "\\DATA\\PEDGRP.DAT;1",
+ "\\DATA\\PATHS\\FLIGHT.DAT;1",
+ "\\DATA\\PATHS\\FLIGHT2.DAT;1",
+ "\\DATA\\PATHS\\FLIGHT3.DAT;1",
+ "\\DATA\\PATHS\\SPATH0.DAT;1",
+ "\\DATA\\MAPS\\LITTLEHA\\LITTLEHA.IDE;1",
+ "\\DATA\\MAPS\\DOWNTOWN\\DOWNTOWN.IDE;1",
+ "\\DATA\\MAPS\\DOWNTOWS\\DOWNTOWS.IDE;1",
+ "\\DATA\\MAPS\\DOCKS\\DOCKS.IDE;1",
+ "\\DATA\\MAPS\\WASHINTN\\WASHINTN.IDE;1",
+ "\\DATA\\MAPS\\WASHINTS\\WASHINTS.IDE;1",
+ "\\DATA\\MAPS\\OCEANDRV\\OCEANDRV.IDE;1",
+ "\\DATA\\MAPS\\OCEANDN\\OCEANDN.IDE;1",
+ "\\DATA\\MAPS\\GOLF\\GOLF.IDE;1",
+ "\\DATA\\MAPS\\BRIDGE\\BRIDGE.IDE;1",
+ "\\DATA\\MAPS\\STARISL\\STARISL.IDE;1",
+ "\\DATA\\MAPS\\NBEACHBT\\NBEACHBT.IDE;1",
+ "\\DATA\\MAPS\\NBEACHW\\NBEACHW.IDE;1",
+ "\\DATA\\MAPS\\NBEACH\\NBEACH.IDE;1",
+ "\\DATA\\MAPS\\BANK\\BANK.IDE;1",
+ "\\DATA\\MAPS\\MALL\\MALL.IDE;1",
+ "\\DATA\\MAPS\\YACHT\\YACHT.IDE;1",
+ "\\DATA\\MAPS\\CISLAND\\CISLAND.IDE;1",
+ "\\DATA\\MAPS\\CLUB\\CLUB.IDE;1",
+ "\\DATA\\MAPS\\HOTEL\\HOTEL.IDE;1",
+ "\\DATA\\MAPS\\LAWYERS\\LAWYERS.IDE;1",
+ "\\DATA\\MAPS\\STRIPCLB\\STRIPCLB.IDE;1",
+ "\\DATA\\MAPS\\AIRPORT\\AIRPORT.IDE;1",
+ "\\DATA\\MAPS\\HAITI\\HAITI.IDE;1",
+ "\\DATA\\MAPS\\HAITIN\\HAITIN.IDE;1",
+ "\\DATA\\MAPS\\CONCERTH\\CONCERTH.IDE;1",
+ "\\DATA\\MAPS\\MANSION\\MANSION.IDE;1",
+ "\\DATA\\MAPS\\ISLANDSF\\ISLANDSF.IDE;1",
+ "\\DATA\\MAPS\\LITTLEHA\\LITTLEHA.IPL;1",
+ "\\DATA\\MAPS\\DOWNTOWN\\DOWNTOWN.IPL;1",
+ "\\DATA\\MAPS\\DOWNTOWS\\DOWNTOWS.IPL;1",
+ "\\DATA\\MAPS\\DOCKS\\DOCKS.IPL;1",
+ "\\DATA\\MAPS\\WASHINTN\\WASHINTN.IPL;1",
+ "\\DATA\\MAPS\\WASHINTS\\WASHINTS.IPL;1",
+ "\\DATA\\MAPS\\OCEANDRV\\OCEANDRV.IPL;1",
+ "\\DATA\\MAPS\\OCEANDN\\OCEANDN.IPL;1",
+ "\\DATA\\MAPS\\GOLF\\GOLF.IPL;1",
+ "\\DATA\\MAPS\\BRIDGE\\BRIDGE.IPL;1",
+ "\\DATA\\MAPS\\STARISL\\STARISL.IPL;1",
+ "\\DATA\\MAPS\\NBEACHBT\\NBEACHBT.IPL;1",
+ "\\DATA\\MAPS\\NBEACH\\NBEACH.IPL;1",
+ "\\DATA\\MAPS\\NBEACHW\\NBEACHW.IPL;1",
+ "\\DATA\\MAPS\\CISLAND\\CISLAND.IPL;1",
+ "\\DATA\\MAPS\\AIRPORT\\AIRPORT.IPL;1",
+ "\\DATA\\MAPS\\HAITI\\HAITI.IPL;1",
+ "\\DATA\\MAPS\\HAITIN\\HAITIN.IPL;1",
+ "\\DATA\\MAPS\\ISLANDSF\\ISLANDSF.IPL;1",
+ "\\DATA\\MAPS\\BANK\\BANK.IPL;1",
+ "\\DATA\\MAPS\\MALL\\MALL.IPL;1",
+ "\\DATA\\MAPS\\YACHT\\YACHT.IPL;1",
+ "\\DATA\\MAPS\\CLUB\\CLUB.IPL;1",
+ "\\DATA\\MAPS\\HOTEL\\HOTEL.IPL;1",
+ "\\DATA\\MAPS\\LAWYERS\\LAWYERS.IPL;1",
+ "\\DATA\\MAPS\\STRIPCLB\\STRIPCLB.IPL;1",
+ "\\DATA\\MAPS\\CONCERTH\\CONCERTH.IPL;1",
+ "\\DATA\\MAPS\\MANSION\\MANSION.IPL;1",
+ "\\DATA\\MAPS\\GENERIC.IDE;1",
+ "\\DATA\\OCCLU.IPL;1",
+ "\\DATA\\MAPS\\PATHS.IPL;1",
"\\TXD\\LOADSC0.TXD;1",
"\\TXD\\LOADSC1.TXD;1",
"\\TXD\\LOADSC2.TXD;1",
@@ -2068,90 +2196,17 @@ void GameInit()
"\\TXD\\LOADSC11.TXD;1",
"\\TXD\\LOADSC12.TXD;1",
"\\TXD\\LOADSC13.TXD;1",
- "\\TXD\\LOADSC14.TXD;1",
- "\\TXD\\LOADSC15.TXD;1",
- "\\TXD\\LOADSC16.TXD;1",
- "\\TXD\\LOADSC17.TXD;1",
- "\\TXD\\LOADSC18.TXD;1",
- "\\TXD\\LOADSC19.TXD;1",
- "\\TXD\\LOADSC20.TXD;1",
- "\\TXD\\LOADSC21.TXD;1",
- "\\TXD\\LOADSC22.TXD;1",
- "\\TXD\\LOADSC23.TXD;1",
- "\\TXD\\LOADSC24.TXD;1",
- "\\TXD\\LOADSC25.TXD;1",
- "\\TXD\\NEWS.TXD;1",
- "\\MODELS\\COLL\\GENERIC.COL;1",
- "\\MODELS\\COLL\\INDUST.COL;1",
- "\\MODELS\\COLL\\COMMER.COL;1",
- "\\MODELS\\COLL\\SUBURB.COL;1",
- "\\MODELS\\COLL\\WEAPONS.COL;1",
- "\\MODELS\\COLL\\VEHICLES.COL;1",
- "\\MODELS\\COLL\\PEDS.COL;1",
- "\\MODELS\\GENERIC\\AIR_VLO.DFF;1",
- "\\MODELS\\GENERIC\\WEAPONS.DFF;1",
- "\\MODELS\\GENERIC\\WHEELS.DFF;1",
- "\\MODELS\\GENERIC\\LOPLYGUY.DFF;1",
- "\\MODELS\\GENERIC\\ARROW.DFF;1",
- "\\MODELS\\GENERIC\\ZONECYLB.DFF;1",
- "\\DATA\\MAPS\\COMNTOP.IPL;1",
- "\\DATA\\MAPS\\COMNBTM.IPL;1",
- "\\DATA\\MAPS\\COMSE.IPL;1",
- "\\DATA\\MAPS\\COMSW.IPL;1",
- "\\DATA\\MAPS\\CULL.IPL;1",
- "\\DATA\\MAPS\\INDUSTNE.IPL;1",
- "\\DATA\\MAPS\\INDUSTNW.IPL;1",
- "\\DATA\\MAPS\\INDUSTSE.IPL;1",
- "\\DATA\\MAPS\\INDUSTSW.IPL;1",
- "\\DATA\\MAPS\\SUBURBNE.IPL;1",
- "\\DATA\\MAPS\\SUBURBSW.IPL;1",
- "\\DATA\\MAPS\\OVERVIEW.IPL;1",
- "\\DATA\\MAPS\\PROPS.IPL;1",
- "\\DATA\\MAPS\\GTA3.IDE;1",
- "\\DATA\\PATHS\\FLIGHT.DAT;1",
- "\\DATA\\PATHS\\FLIGHT2.DAT;1",
- "\\DATA\\PATHS\\FLIGHT3.DAT;1",
- "\\DATA\\PATHS\\FLIGHT4.DAT;1",
- "\\DATA\\PATHS\\TRACKS.DAT;1",
- "\\DATA\\PATHS\\TRACKS2.DAT;1",
- "\\DATA\\PATHS\\CHASE0.DAT;1",
- "\\DATA\\PATHS\\CHASE1.DAT;1",
- "\\DATA\\PATHS\\CHASE2.DAT;1",
- "\\DATA\\PATHS\\CHASE3.DAT;1",
- "\\DATA\\PATHS\\CHASE4.DAT;1",
- "\\DATA\\PATHS\\CHASE5.DAT;1",
- "\\DATA\\PATHS\\CHASE6.DAT;1",
- "\\DATA\\PATHS\\CHASE7.DAT;1",
- "\\DATA\\PATHS\\CHASE10.DAT;1",
- "\\DATA\\PATHS\\CHASE11.DAT;1",
- "\\DATA\\PATHS\\CHASE14.DAT;1",
- "\\DATA\\PATHS\\CHASE16.DAT;1",
- "\\DATA\\PATHS\\CHASE18.DAT;1",
- "\\DATA\\PATHS\\CHASE19.DAT;1"
+ "\\TXD\\SPLASH1.TXD;1"
};
for ( int32 i = 0; i < ARRAY_SIZE(files); i++ )
SkyRegisterFileOnCd([i]);
#endif
- CreateDebugFont();
-
#ifdef GTA_PS2
AddIntcHandler(INTC_VBLANK_S, VBlankCounter, 0);
#endif
- CameraSize(Scene.camera, NULL, DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
-
- CSprite2d::SetRecipNearClip();
- CTxdStore::Initialise();
-
- PUSH_MEMID(MEMID_TEXTURES);
- CFont::Initialise();
- CHud::Initialise();
- POP_MEMID();
-
- ValidateVersion();
-
#ifdef GTA_PS2
sceCdCLOCK rtc;
sceCdReadClock(&rtc);
@@ -2163,10 +2218,59 @@ void GameInit()
//TODO: mysrand();
#endif
- gameAlreadyInitialised = true;
+ // gameAlreadyInitialised = true; // why is this gone?
}
}
+int32 SkipAllMPEGs;
+int32 gMemoryStickLoadOK;
+
+void PlayIntroMPEGs()
+{
+#ifdef GTA_PS2
+ if (gameAlreadyInitialised)
+ RpSkySuspend();
+
+ InitMPEGPlayer();
+
+ float skipTime; // wrong type, should be int
+#ifdef GTA_PAL
+ if(gMemoryStickLoadOK)
+ skipTime = 2500000;
+ else
+ skipTime = 5300000;
+
+ if(!SkipAllMPEGs)
+ PlayMPEG("cdrom0:\\MOVIES\\VCPAL.PSS;1", false, unk);
+
+ if(!SkipAllMPEGs){
+ SkipAllMPEGs = true;
+ PlayMPEG("cdrom0:\\MOVIES\\VICEPAL.PSS;1", true, 0);
+ }
+#else
+ if(gMemoryStickLoadOK)
+ skipTime = 2750000;
+ else
+ skipTime = 5500000;
+
+ if(!SkipAllMPEGs)
+ PlayMPEG("cdrom0:\\MOVIES\\VCNTSC.PSS;1", false, unk);
+
+ if(!SkipAllMPEGs){
+ SkipAllMPEGs = true;
+ PlayMPEG("cdrom0:\\MOVIES\\VICE.PSS;1", true, 0);
+ }
+#endif
+
+ ShutdownMPEGPlayer();
+
+ if ( gameAlreadyInitialised )
+ RpSkyResume();
+#else
+ //TODO
+#endif
+}
+
int
main(int argc, char *argv[])
{
@@ -2175,13 +2279,16 @@ main(int argc, char *argv[])
#endif
SystemInit();
-
+
+ if(RsEventHandler(rsINITIALIZE, nil) == rsEVENTERROR)
+ return 0;
+
#ifdef GTA_PS2
int32 r = TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE);
if ( r == CMemoryCard::ERR_DIRNOENTRY || r == CMemoryCard::ERR_NOFORMAT )
{
- GameInit();
+ GameInit(true);
TheText.Unload();
TheText.Load();
@@ -2189,51 +2296,24 @@ main(int argc, char *argv[])
CFont::Initialise();
FrontEndMenuManager.DrawMemoryCardStartUpMenus();
- }else if(r == CMemoryCard::ERR_OPENNOENTRY || r == CMemoryCard::ERR_NONE){
- // eh?
- }
+ }else if(r == CMemoryCard::ERR_OPENNOENTRY)
+ gMemoryStickLoadOK = false;
+ else if(r == CMemoryCard::ERR_NONE)
+ gMemoryStickLoadOK = true;
#endif
-
-#ifdef GTA_PS2
- {
- if (gameAlreadyInitialised)
- RpSkySuspend();
- InitMPEGPlayer();
+ PlayIntroMPEGs();
-#ifdef GTA_PAL
- PlayMPEG("cdrom0:\\MOVIES\\DMAPAL.PSS;1", false);
-
- if (CGame::frenchGame || CGame::germanGame)
- PlayMPEG("cdrom0:\\MOVIES\\INTROPAF.PSS;1", true);
- else
- PlayMPEG("cdrom0:\\MOVIES\\INTROPAL.PSS;1", true);
-#else
- PlayMPEG("cdrom0:\\MOVIES\\DMANTSC.PSS;1", false);
+ GameInit(false);
- PlayMPEG("cdrom0:\\MOVIES\\INTRNTSC.PSS;1", true);
-#endif
+ frameCount = 0;
+ while(frameCount < 100);
- ShutdownMPEGPlayer();
+ CGame::InitialiseOnceAfterRW();
- if ( gameAlreadyInitialised )
- RpSkyResume();
- }
-#else
- //TODO
-#endif
-
- GameInit();
-
- if ( CGame::frenchGame || CGame::germanGame )
- LoadingScreen(NULL, version_name, "loadsc24");
- else
- LoadingScreen(NULL, version_name, "loadsc0");
-
- DMAudio.Initialise();
-
TheGame();
-
+
+#if 0 // maybe ifndef FINAL or MASTER?
CGame::ShutDown();
RwEngineStop();
@@ -2243,7 +2323,7 @@ main(int argc, char *argv[])
#ifdef __MWERKS__
mwExit(); // metrowerks shutdown
#endif
-
+#endif
return 0;
}
#endif
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 3f5e8f7d..d51e50ba 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -421,7 +421,7 @@ void CTweakVars::Add(CTweakVar *var)
TweakVarsListSize = 0;
}
if(TweakVarsListSize > 63)
- TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(var));
+ TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(*var));
TweakVarsList[TweakVarsListSize++] = var;
// TweakVarsList.push_back(var);
diff --git a/src/extras/debugmenu.h b/src/extras/debugmenu.h
index eb56c8f9..c2198aca 100644
--- a/src/extras/debugmenu.h
+++ b/src/extras/debugmenu.h
@@ -15,7 +15,7 @@ struct MenuEntry
Menu *menu;
MenuEntry(const char *name);
- virtual ~MenuEntry(void) {}
+ virtual ~MenuEntry(void) { free((void*)name); }
};
typedef MenuEntry DebugMenuEntry;
diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp
index 3f91a754..54866bea 100644
--- a/src/extras/screendroplets.cpp
+++ b/src/extras/screendroplets.cpp
@@ -79,8 +79,10 @@ ScreenDroplets::Initialise(void)
void
ScreenDroplets::InitDraw(void)
{
- if(CustomPipes::neoTxd)
- ms_maskTex = CustomPipes::neoTxd->find("dropmask");
+ if(CustomPipes::neoTxd == nil)
+ return;
+
+ ms_maskTex = CustomPipes::neoTxd->find("dropmask");
ms_screenTex = RwTextureCreate(nil);
RwTextureSetFilterMode(ms_screenTex, rwFILTERLINEAR);
@@ -136,6 +138,10 @@ ScreenDroplets::Shutdown(void)
void
ScreenDroplets::Process(void)
{
+ // no need to do anything if we can't render
+ if(CustomPipes::neoTxd == nil)
+ return;
+
ProcessCameraMovement();
SprayDrops();
ProcessMoving();
@@ -173,6 +179,9 @@ ScreenDroplets::Render(void)
{
ScreenDrop *drop;
+ if(CustomPipes::neoTxd == nil)
+ return;
+
DefinedState();
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(ms_maskTex));
RwRenderStateSet(rwRENDERSTATEFOGENABLE, FALSE);
diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h
index a5a34626..47c94f7c 100644
--- a/src/math/Quaternion.h
+++ b/src/math/Quaternion.h
@@ -12,6 +12,11 @@ public:
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
void Normalise(void);
void Multiply(const CQuaternion &q1, const CQuaternion &q2);
+ void Invert(void){ // Conjugate would have been a better name
+ x = -x;
+ y = -y;
+ z = -z;
+ }
const CQuaternion &operator+=(CQuaternion const &right) {
x += right.x;
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 392ee1d4..020b2eac 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -319,7 +319,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
bCanGiveUpSunbathing = true;
m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this);
- DMAudio.SetEntityStatus(m_audioEntityId, 1);
+ DMAudio.SetEntityStatus(m_audioEntityId, true);
m_fearFlags = CPedType::GetThreats(m_nPedType);
m_threatEntity = nil;
m_eventOrThreat = CVector2D(0.0f, 0.0f);
@@ -2583,6 +2583,48 @@ CPed::ProcessControl(void)
if (m_nWaitState != WAITSTATE_FALSE)
Wait();
+#ifdef CANCELLABLE_CAR_ENTER
+ static bool cancelJack = false;
+ if (IsPlayer()) {
+ if (EnteringCar() && m_pVehicleAnim) {
+ CPad *pad = CPad::GetPad(0);
+
+ if (!pad->ArePlayerControlsDisabled()) {
+ int vehAnim = m_pVehicleAnim->animId;
+
+ int16 padWalkX = pad->GetPedWalkLeftRight();
+ int16 padWalkY = pad->GetPedWalkUpDown();
+ if (Abs(padWalkX) > 0.0f || Abs(padWalkY) > 0.0f) {
+ if (vehAnim == ANIM_CAR_OPEN_LHS || vehAnim == ANIM_CAR_OPEN_RHS || vehAnim == ANIM_COACH_OPEN_L || vehAnim == ANIM_COACH_OPEN_R ||
+ vehAnim == ANIM_VAN_OPEN_L || vehAnim == ANIM_VAN_OPEN) {
+
+ if (!m_pMyVehicle->pDriver) {
+ cancelJack = false;
+ bCancelEnteringCar = true;
+ } else
+ cancelJack = true;
+ } else if (vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f) {
+ cancelJack = true;
+ } else if (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS) {
+ bCancelEnteringCar = true;
+ cancelJack = false;
+ }
+ }
+ if (cancelJack && vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f && m_pVehicleAnim->GetTimeLeft() < 0.78f) {
+ cancelJack = false;
+ QuitEnteringCar();
+ RestorePreviousObjective();
+ }
+ if (cancelJack && (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS)) {
+ cancelJack = false;
+ bCancelEnteringCar = true;
+ }
+ }
+ } else
+ cancelJack = false;
+ }
+#endif
+
switch (m_nPedState) {
case PED_IDLE:
Idle();
@@ -2604,46 +2646,6 @@ CPed::ProcessControl(void)
case PED_ENTER_CAR:
case PED_CARJACK:
{
-#ifdef CANCELLABLE_CAR_ENTER
- if (!IsPlayer() || !m_pVehicleAnim)
- break;
-
- CPad *pad = CPad::GetPad(0);
-
- if (pad->ArePlayerControlsDisabled())
- break;
-
- int vehAnim = m_pVehicleAnim->animId;
-
- static bool cancelJack = false;
- int16 padWalkX = pad->GetPedWalkLeftRight();
- int16 padWalkY = pad->GetPedWalkUpDown();
- if (Abs(padWalkX) > 0.0f || Abs(padWalkY) > 0.0f) {
- if (vehAnim == ANIM_CAR_OPEN_LHS || vehAnim == ANIM_CAR_OPEN_RHS || vehAnim == ANIM_COACH_OPEN_L || vehAnim == ANIM_COACH_OPEN_R ||
- vehAnim == ANIM_VAN_OPEN_L || vehAnim == ANIM_VAN_OPEN) {
-
- if (!m_pMyVehicle->pDriver) {
- cancelJack = false;
- bCancelEnteringCar = true;
- } else
- cancelJack = true;
- } else if (vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f) {
- cancelJack = true;
- } else if (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS) {
- bCancelEnteringCar = true;
- cancelJack = false;
- }
- }
- if (cancelJack && vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f && m_pVehicleAnim->GetTimeLeft() < 0.78f) {
- cancelJack = false;
- QuitEnteringCar();
- RestorePreviousObjective();
- }
- if (cancelJack && (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS)) {
- cancelJack = false;
- bCancelEnteringCar = true;
- }
-#endif
break;
}
case PED_FLEE_POS:
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index d5705a2f..364e18d8 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -5899,17 +5899,21 @@ CPed::Duck(void)
ClearDuck();
else if (bIsDucking && bCrouchWhenShooting) {
CWeaponInfo *weapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
- CAnimBlendAssociation *attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCH);
- if (!attackAssoc) {
+ CAnimBlendAssociation *crouchAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCH);
+ if (!crouchAnim) {
if(GetCrouchFireAnim(weapon))
- attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon));
+ crouchAnim = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon));
}
- if (!attackAssoc) {
+ if (!crouchAnim) {
if(GetCrouchReloadAnim(weapon))
- attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(weapon));
+ crouchAnim = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(weapon));
}
- if (!attackAssoc) {
+ if (!crouchAnim) {
bIsDucking = false;
+#if defined FIX_BUGS || defined FREE_CAM
+ if (IsPlayer())
+ bCrouchWhenShooting = false;
+#endif
}
}
}
diff --git a/src/peds/PedAttractor.cpp b/src/peds/PedAttractor.cpp
index 05e72ed3..eeb65398 100644
--- a/src/peds/PedAttractor.cpp
+++ b/src/peds/PedAttractor.cpp
@@ -4,6 +4,7 @@
#include "General.h"
#include "Vehicle.h"
#include "World.h"
+#include "MemoryHeap.h"
const int gcMaxSizeOfAtmQueue = 1;
const int gcMaxSizeOfSeatQueue = 1;
@@ -18,8 +19,18 @@ std::vector<CVector> CPedShelterAttractor::ms_displacements;
CPedAttractorManager* GetPedAttractorManager()
{
- static CPedAttractorManager manager;
- return &manager;
+// mobile just has a static here:
+/*
+ static CPedAttractorManager pedAttrMgr;
+ return &pedAttrMgr;
+*/
+ static CPedAttractorManager *pedAttrMgr;
+ if(pedAttrMgr == nil){
+ PUSH_MEMID(MEMID_PED_ATTR);
+ pedAttrMgr = new CPedAttractorManager;
+ POP_MEMID();
+ }
+ return pedAttrMgr;
}
CVehicleToEffect::CVehicleToEffect(CVehicle* pVehicle) : m_pVehicle(pVehicle)
@@ -100,8 +111,10 @@ const C2dEffect* CPedAttractorManager::GetEffectForIceCreamVan(CVehicle* pVehicl
return assoc->ChooseEffect(pos);
}
}
+ PUSH_MEMID(MEMID_PED_ATTR);
CVehicleToEffect effect(pVehicle);
vVehicleToEffect.push_back(effect);
+ POP_MEMID();
return effect.ChooseEffect(pos);
}
@@ -645,6 +658,7 @@ CPedAttractor* CPedAttractorManager::RegisterPed(CPed* pPed, C2dEffect* pEffect,
pRegisteredAttractor->RegisterPed(pPed);
return pRegisteredAttractor;
}
+ PUSH_MEMID(MEMID_PED_ATTR);
switch (pEffect->pedattr.type) {
case ATTRACTOR_ATM: vecAttractors.push_back(new CPedAtmAttractor(pEffect, matrix, gcMaxSizeOfAtmQueue, 1.0f, 30000.0f, 3000.0f, 0.2f, 0.15f, 0.1f, 0.1f)); break;
case ATTRACTOR_SEAT: vecAttractors.push_back(new CPedSeatAttractor(pEffect, matrix, gcMaxSizeOfSeatQueue, 1.0f, 30000.0f, 3000.0f, 0.125f, 0.1f, 0.1f, 0.1f)); break;
@@ -653,6 +667,7 @@ CPedAttractor* CPedAttractorManager::RegisterPed(CPed* pPed, C2dEffect* pEffect,
case ATTRACTOR_SHELTER: vecAttractors.push_back(new CPedShelterAttractor(pEffect, matrix, gcMaxSizeOfShelterQueue, 1.0f, 30000.0f, 3000.0f, 0.5f, 6.28f, 0.1f, 0.1f)); break;
case ATTRACTOR_ICECREAM: vecAttractors.push_back(new CPedIceCreamAttractor(pEffect, matrix, gcMaxSizeOfIceCreamQueue, 1.0f, 30000.0f, 3000.0f, 0.2f, 0.3f, 0.1f, 0.1f)); break;
}
+ POP_MEMID();
if (pRegisteredAttractor)
pRegisteredAttractor->RegisterPed(pPed);
return pRegisteredAttractor;
diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp
index e16fcee6..746eb3a5 100644
--- a/src/peds/PedType.cpp
+++ b/src/peds/PedType.cpp
@@ -47,7 +47,7 @@ CPedType::LoadPedData(void)
char *buf;
char line[256];
char word[32];
- size_t bp, buflen;
+ ssize_t bp, buflen;
int lp, linelen;
int type;
uint32 flags;
@@ -56,9 +56,9 @@ CPedType::LoadPedData(void)
type = NUM_PEDTYPES;
buf = new char[16 * 1024];
- CFileMgr::SetDir("DATA");
- buflen = CFileMgr::LoadFile("PED.DAT", (uint8*)buf, 16 * 1024, "r");
- CFileMgr::SetDir("");
+ CFileMgr::SetDir("DATA");
+ buflen = CFileMgr::LoadFile("PED.DAT", (uint8*)buf, 16 * 1024, "r");
+ CFileMgr::SetDir("");
for(bp = 0; bp < buflen; ){
// read file line by line
@@ -248,7 +248,7 @@ CPedStats::LoadPedStats(void)
char *buf;
char line[256];
char name[32];
- size_t bp, buflen;
+ ssize_t bp, buflen;
int lp, linelen;
int type;
float fleeDist, headingChangeRate, attackStrength, defendWeakness;
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 74db3055..c84ed4b4 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -1159,6 +1159,7 @@ void
CPlayerPed::ProcessAnimGroups(void)
{
AssocGroupId groupToSet;
+#ifdef PC_PLAYER_CONTROLS
if ((m_fWalkAngle <= -DEGTORAD(50.0f) || m_fWalkAngle >= DEGTORAD(50.0f))
&& TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam()
&& CanStrafeOrMouseControl()) {
@@ -1193,7 +1194,9 @@ CPlayerPed::ProcessAnimGroups(void)
else
groupToSet = ASSOCGRP_PLAYERBACK;
}
- } else {
+ } else
+#endif
+ {
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER) {
groupToSet = ASSOCGRP_PLAYERROCKET;
} else {
@@ -1331,7 +1334,9 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
#ifdef FREE_CAM
static int8 changedHeadingRate = 0;
+ static int8 pointedGun = 0;
if (changedHeadingRate == 2) changedHeadingRate = 1;
+ if (pointedGun == 2) pointedGun = 1;
// Rotate player/arm when shooting. We don't have auto-rotation anymore
if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam &&
@@ -1346,14 +1351,14 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
// On this one we can rotate arm.
if (CAN_AIM_WITH_ARM) {
if (!padUsed->GetWeapon()) { // making this State != ATTACK still stops it after attack. Re-start it immediately!
- SetWeaponLockOnTarget(nil);
+ SetPointGunAt(nil);
bIsPointingGunAt = false; // to not stop after attack
}
-
+ pointedGun = 2;
SetLookFlag(limitedCam, true);
SetAimFlag(limitedCam);
SetLookTimer(INT32_MAX); // removing this makes head move for real, but I experinced some bugs.
-
+
} else {
m_fRotationDest = limitedCam;
changedHeadingRate = 2;
@@ -1373,8 +1378,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2;
}
}
- } else if (CAN_AIM_WITH_ARM && m_nPedState != PED_ATTACK)
- ClearPointGunAt();
+ }
}
#undef CAN_AIM_WITH_ARM
}
@@ -1382,6 +1386,10 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
changedHeadingRate = 0;
RestoreHeadingRate();
}
+ if (pointedGun == 1 && m_nPedState != PED_ATTACK) {
+ pointedGun = 0;
+ ClearPointGunAt();
+ }
#endif
if (padUsed->GetTarget() && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT && !TheCamera.Using1stPersonWeaponMode() && weaponInfo->m_bCanAim) {
diff --git a/src/render/PlayerSkin.cpp b/src/render/PlayerSkin.cpp
index b385a62c..1626716f 100644
--- a/src/render/PlayerSkin.cpp
+++ b/src/render/PlayerSkin.cpp
@@ -76,6 +76,7 @@ LoadPlayerDff(void)
void
CPlayerSkin::Initialise(void)
{
+ // empty on PS2
m_txdSlot = CTxdStore::AddTxdSlot("skin");
CTxdStore::Create(m_txdSlot);
CTxdStore::AddRef(m_txdSlot);
@@ -84,6 +85,7 @@ CPlayerSkin::Initialise(void)
void
CPlayerSkin::Shutdown(void)
{
+ // empty on PS2
CTxdStore::RemoveTxdSlot(m_txdSlot);
}
diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp
index 3f242362..52e93951 100644
--- a/src/render/Weather.cpp
+++ b/src/render/Weather.cpp
@@ -139,7 +139,7 @@ void CWeather::Init(void)
ForcedWeatherType = WEATHER_RANDOM;
SoundHandle = DMAudio.CreateEntity(AUDIOTYPE_WEATHER, (void*)1);
if (SoundHandle >= 0)
- DMAudio.SetEntityStatus(SoundHandle, 1);
+ DMAudio.SetEntityStatus(SoundHandle, true);
}
void CWeather::Update(void)
diff --git a/src/rw/MemoryHeap.cpp b/src/rw/MemoryHeap.cpp
index 45dd1fc2..285a7c70 100644
--- a/src/rw/MemoryHeap.cpp
+++ b/src/rw/MemoryHeap.cpp
@@ -341,7 +341,7 @@ CMemoryHeap::TidyHeap(void)
}
}
-//
+// MIAMI: this is empty
void
CMemoryHeap::RegisterMemPointer(void *ptr)
{
diff --git a/src/rw/MemoryHeap.h b/src/rw/MemoryHeap.h
index 38a8ba2b..1a9a51f8 100644
--- a/src/rw/MemoryHeap.h
+++ b/src/rw/MemoryHeap.h
@@ -17,7 +17,6 @@
enum {
MEMID_FREE,
- // IDs from LCS:
MEMID_GAME = 1, // "Game"
MEMID_WORLD = 2, // "World"
MEMID_ANIMATION = 3, // "Animation"
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index aa4bdcc0..83c3c5bc 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -872,12 +872,12 @@ CVisibilityPlugins::FrameCopyConstructor(void *dst, const void *src, int32, int3
}
void
-CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, uintptr id)
+CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, intptr id)
{
FRAMEEXT(frame)->id = id;
}
-uintptr
+intptr
CVisibilityPlugins::GetFrameHierarchyId(RwFrame *frame)
{
return FRAMEEXT(frame)->id;
@@ -914,7 +914,7 @@ void
CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo)
{
CVehicleModelInfo *vmi;
- SetFrameHierarchyId(RpClumpGetFrame(clump), (uintptr)modelInfo);
+ SetFrameHierarchyId(RpClumpGetFrame(clump), (intptr)modelInfo);
// Unused
switch (modelInfo->GetModelType()) {
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index 03833c9c..13365c7a 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -115,10 +115,10 @@ public:
struct FrameExt
{
// BUG: this is abused to hold a pointer by SetClumpModelInfo
- uintptr id;
+ intptr id;
};
- static void SetFrameHierarchyId(RwFrame *frame, uintptr id);
- static uintptr GetFrameHierarchyId(RwFrame *frame);
+ static void SetFrameHierarchyId(RwFrame *frame, intptr id);
+ static intptr GetFrameHierarchyId(RwFrame *frame);
static void *FrameConstructor(void *object, int32 offset, int32 len);
static void *FrameDestructor(void *object, int32 offset, int32 len);
diff --git a/src/skel/skeleton.cpp b/src/skel/skeleton.cpp
index 0d70f27d..6f6b3744 100644
--- a/src/skel/skeleton.cpp
+++ b/src/skel/skeleton.cpp
@@ -307,8 +307,6 @@ RsRwInitialize(void *displayID)
{
RwEngineOpenParams openParams;
- PUSH_MEMID(MEMID_RENDER); // NB: not popped on failed return
-
/*
* Start RenderWare...
*/
@@ -376,8 +374,6 @@ RsRwInitialize(void *displayID)
RwTextureSetAutoMipmapping(TRUE);
RwTextureSetMipmapping(FALSE);
- POP_MEMID();
-
return TRUE;
}
diff --git a/src/text/Text.cpp b/src/text/Text.cpp
index e23369fb..5f7a07cc 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -318,7 +318,7 @@ CKeyArray::Load(size_t length, int file, size_t* offset)
entries = new CKeyEntry[numEntries];
rawbytes = (char*)entries;
-#if DUMB
+#if THIS_IS_STUPID
for (uint32 i = 0; i < length; i++) {
CFileMgr::Read(file, &rawbytes[i], 1);
(*offset)++;
@@ -412,7 +412,7 @@ CData::Load(size_t length, int file, size_t * offset)
chars = new wchar[numChars];
rawbytes = (char*)chars;
-#if DUMB
+#if THIS_IS_STUPID
for(uint32 i = 0; i < length; i++){
CFileMgr::Read(file, &rawbytes[i], 1);
(*offset)++;
@@ -434,7 +434,7 @@ CData::Unload(void)
void
CMissionTextOffsets::Load(size_t table_size, int file, size_t *offset, int)
{
-#if DUMB
+#if THIS_IS_STUPID
size_t num_of_entries = table_size / sizeof(CMissionTextOffsets::Entry);
for (size_t mi = 0; mi < num_of_entries; mi++) {
for (uint32 i = 0; i < sizeof(data[mi].szMissionName); i++) {
diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp
index b911805d..4a61e42c 100644
--- a/src/weapons/WeaponInfo.cpp
+++ b/src/weapons/WeaponInfo.cpp
@@ -105,7 +105,6 @@ CWeaponInfo::GetWeaponInfo(eWeaponType weaponType)
return &ms_apWeaponInfos[weaponType];
}
-// --MIAMI: done except WEAPONTYPE_TOTALWEAPONS value
void
CWeaponInfo::Initialise(void)
{
@@ -142,7 +141,6 @@ CWeaponInfo::Initialise(void)
debug("CWeaponInfo ready\n");
}
-// --MIAMI: Done, commented parts wait for weapons port
void
CWeaponInfo::LoadWeaponData(void)
{