summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/animation/AnimBlendAssocGroup.cpp5
-rw-r--r--src/animation/AnimBlendAssociation.cpp5
-rw-r--r--src/animation/AnimBlendAssociation.h19
-rw-r--r--src/animation/AnimBlendClumpData.h4
-rw-r--r--src/animation/AnimBlendHierarchy.h3
-rw-r--r--src/animation/AnimBlendList.h1
-rw-r--r--src/animation/AnimBlendNode.cpp4
-rw-r--r--src/animation/AnimBlendNode.h4
-rw-r--r--src/animation/AnimBlendSequence.h2
-rw-r--r--src/animation/AnimManager.cpp70
-rw-r--r--src/animation/AnimManager.h6
-rw-r--r--src/animation/CutsceneMgr.cpp4
-rw-r--r--src/audio/AudioCollision.cpp161
-rw-r--r--src/audio/AudioCollision.h6
-rw-r--r--src/audio/AudioManager.cpp6080
-rw-r--r--src/audio/AudioManager.h195
-rw-r--r--src/audio/AudioScriptObject.h2
-rw-r--r--src/audio/DMAudio.h173
-rw-r--r--src/audio/MusicManager.cpp13
-rw-r--r--src/audio/MusicManager.h2
-rw-r--r--src/audio/PoliceRadio.cpp22
-rw-r--r--src/audio/PoliceRadio.h4
-rw-r--r--src/audio/soundlist.h301
-rw-r--r--src/control/AutoPilot.cpp97
-rw-r--r--src/control/AutoPilot.h15
-rw-r--r--src/control/Bridge.cpp11
-rw-r--r--src/control/CarAI.cpp57
-rw-r--r--src/control/CarAI.h3
-rw-r--r--src/control/CarCtrl.cpp485
-rw-r--r--src/control/CarCtrl.h3
-rw-r--r--src/control/Curves.cpp2
-rw-r--r--src/control/GameLogic.cpp12
-rw-r--r--src/control/Garages.cpp59
-rw-r--r--src/control/Garages.h8
-rw-r--r--src/control/OnscreenTimer.h4
-rw-r--r--src/control/PathFind.cpp352
-rw-r--r--src/control/PathFind.h69
-rw-r--r--src/control/Phones.cpp4
-rw-r--r--src/control/Phones.h2
-rw-r--r--src/control/Pickups.cpp24
-rw-r--r--src/control/Pickups.h2
-rw-r--r--src/control/Record.cpp14
-rw-r--r--src/control/Remote.cpp6
-rw-r--r--src/control/Replay.cpp20
-rw-r--r--src/control/Replay.h19
-rw-r--r--src/control/Restart.cpp4
-rw-r--r--src/control/RoadBlocks.cpp45
-rw-r--r--src/control/SceneEdit.cpp33
-rw-r--r--src/control/Script.cpp198
-rw-r--r--src/control/Script.h18
-rw-r--r--src/control/TrafficLights.cpp30
-rw-r--r--src/core/AnimViewer.cpp32
-rw-r--r--src/core/Cam.cpp34
-rw-r--r--src/core/Camera.cpp40
-rw-r--r--src/core/Camera.h29
-rw-r--r--src/core/CdStream.cpp1
-rw-r--r--src/core/CdStream.h1
-rw-r--r--src/core/Collision.cpp2
-rw-r--r--src/core/Collision.h10
-rw-r--r--src/core/ControllerConfig.cpp10
-rw-r--r--src/core/FileLoader.cpp50
-rw-r--r--src/core/Frontend.cpp245
-rw-r--r--src/core/Frontend.h18
-rw-r--r--src/core/Game.cpp22
-rw-r--r--src/core/Game.h2
-rw-r--r--src/core/MenuScreens.h6
-rw-r--r--src/core/Pad.cpp169
-rw-r--r--src/core/Pad.h9
-rw-r--r--src/core/Placeable.cpp4
-rw-r--r--src/core/Placeable.h11
-rw-r--r--src/core/PlayerInfo.cpp20
-rw-r--r--src/core/PlayerInfo.h4
-rw-r--r--src/core/Pools.cpp92
-rw-r--r--src/core/Radar.cpp47
-rw-r--r--src/core/Radar.h2
-rw-r--r--src/core/Streaming.cpp131
-rw-r--r--src/core/Streaming.h10
-rw-r--r--src/core/Timer.h5
-rw-r--r--src/core/User.cpp12
-rw-r--r--src/core/Wanted.cpp2
-rw-r--r--src/core/Wanted.h2
-rw-r--r--src/core/World.cpp75
-rw-r--r--src/core/World.h11
-rw-r--r--src/core/ZoneCull.cpp11
-rw-r--r--src/core/Zones.cpp97
-rw-r--r--src/core/Zones.h15
-rw-r--r--src/core/common.h7
-rw-r--r--src/core/config.h8
-rw-r--r--src/core/main.cpp12
-rw-r--r--src/core/re3.cpp40
-rw-r--r--src/core/templates.h14
-rw-r--r--src/entities/Building.cpp2
-rw-r--r--src/entities/Building.h4
-rw-r--r--src/entities/Dummy.h4
-rw-r--r--src/entities/Entity.cpp114
-rw-r--r--src/entities/Entity.h25
-rw-r--r--src/entities/Physical.cpp90
-rw-r--r--src/entities/Physical.h5
-rw-r--r--src/entities/Treadable.h4
-rw-r--r--src/extras/debugmenu.cpp25
-rw-r--r--src/extras/debugmenu.h4
-rw-r--r--src/fakerw/fake.cpp46
-rw-r--r--src/fakerw/rwcore.h10
-rw-r--r--src/math/Rect.h19
-rw-r--r--src/math/Vector.h13
-rw-r--r--src/modelinfo/BaseModelInfo.cpp6
-rw-r--r--src/modelinfo/BaseModelInfo.h26
-rw-r--r--src/modelinfo/ClumpModelInfo.cpp27
-rw-r--r--src/modelinfo/ClumpModelInfo.h5
-rw-r--r--src/modelinfo/ModelIndices.h3
-rw-r--r--src/modelinfo/ModelInfo.cpp4
-rw-r--r--src/modelinfo/PedModelInfo.h5
-rw-r--r--src/modelinfo/SimpleModelInfo.cpp10
-rw-r--r--src/modelinfo/SimpleModelInfo.h7
-rw-r--r--src/modelinfo/TimeModelInfo.cpp2
-rw-r--r--src/modelinfo/TimeModelInfo.h3
-rw-r--r--src/modelinfo/VehicleModelInfo.h14
-rw-r--r--src/objects/CutsceneHead.cpp2
-rw-r--r--src/objects/CutsceneHead.h2
-rw-r--r--src/objects/CutsceneObject.cpp4
-rw-r--r--src/objects/CutsceneObject.h2
-rw-r--r--src/objects/DummyObject.h3
-rw-r--r--src/objects/Object.cpp32
-rw-r--r--src/objects/Object.h46
-rw-r--r--src/objects/ObjectData.h2
-rw-r--r--src/objects/ParticleObject.cpp5
-rw-r--r--src/peds/CivilianPed.h2
-rw-r--r--src/peds/CopPed.cpp16
-rw-r--r--src/peds/CopPed.h4
-rw-r--r--src/peds/DummyPed.h3
-rw-r--r--src/peds/EmergencyPed.h2
-rw-r--r--src/peds/Gangs.h2
-rw-r--r--src/peds/Ped.cpp392
-rw-r--r--src/peds/Ped.h22
-rw-r--r--src/peds/PedIK.cpp11
-rw-r--r--src/peds/PedIK.h3
-rw-r--r--src/peds/PedPlacement.cpp2
-rw-r--r--src/peds/PedPlacement.h2
-rw-r--r--src/peds/PedStats.h3
-rw-r--r--src/peds/PedType.h2
-rw-r--r--src/peds/PlayerPed.cpp41
-rw-r--r--src/peds/PlayerPed.h9
-rw-r--r--src/peds/Population.cpp49
-rw-r--r--src/render/2dEffect.h5
-rw-r--r--src/render/Coronas.h3
-rw-r--r--src/render/Font.cpp609
-rw-r--r--src/render/Font.h51
-rw-r--r--src/render/Glass.cpp2
-rw-r--r--src/render/Hud.cpp35
-rw-r--r--src/render/Particle.cpp2
-rw-r--r--src/render/Particle.h2
-rw-r--r--src/render/ParticleMgr.h6
-rw-r--r--src/render/PointLights.cpp2
-rw-r--r--src/render/PointLights.h4
-rw-r--r--src/render/Renderer.cpp61
-rw-r--r--src/render/Shadows.cpp4
-rw-r--r--src/render/Shadows.h12
-rw-r--r--src/render/Sprite.cpp12
-rw-r--r--src/render/WaterCannon.h2
-rw-r--r--src/render/WaterLevel.cpp5
-rw-r--r--src/rw/RwHelper.cpp2
-rw-r--r--src/rw/VisibilityPlugins.cpp14
-rw-r--r--src/save/GenericGameStorage.cpp17
-rw-r--r--src/save/PCSave.cpp10
-rw-r--r--src/skel/glfw/glfw.cpp278
-rw-r--r--src/skel/win/win.cpp129
-rw-r--r--src/text/Messages.cpp33
-rw-r--r--src/text/Text.cpp14
-rw-r--r--src/text/Text.h3
-rw-r--r--src/vehicles/Automobile.cpp128
-rw-r--r--src/vehicles/Automobile.h8
-rw-r--r--src/vehicles/Boat.cpp41
-rw-r--r--src/vehicles/Boat.h9
-rw-r--r--src/vehicles/CarGen.cpp10
-rw-r--r--src/vehicles/Cranes.cpp10
-rw-r--r--src/vehicles/Cranes.h2
-rw-r--r--src/vehicles/Heli.cpp18
-rw-r--r--src/vehicles/Heli.h4
-rw-r--r--src/vehicles/Plane.cpp30
-rw-r--r--src/vehicles/Plane.h3
-rw-r--r--src/vehicles/Train.cpp14
-rw-r--r--src/vehicles/Train.h3
-rw-r--r--src/vehicles/Vehicle.cpp141
-rw-r--r--src/vehicles/Vehicle.h12
-rw-r--r--src/weapons/BulletInfo.cpp10
-rw-r--r--src/weapons/ProjectileInfo.cpp4
-rw-r--r--src/weapons/Weapon.cpp68
-rw-r--r--src/weapons/Weapon.h5
-rw-r--r--src/weapons/WeaponInfo.h2
189 files changed, 7353 insertions, 5620 deletions
diff --git a/src/animation/AnimBlendAssocGroup.cpp b/src/animation/AnimBlendAssocGroup.cpp
index bdcca2f8..5a6d10b4 100644
--- a/src/animation/AnimBlendAssocGroup.cpp
+++ b/src/animation/AnimBlendAssocGroup.cpp
@@ -3,6 +3,7 @@
#include "ctype.h"
#include "General.h"
+#include "RwHelper.h"
#include "ModelInfo.h"
#include "AnimManager.h"
#include "RpAnimBlend.h"
@@ -131,6 +132,10 @@ CAnimBlendAssocGroup::CreateAssociations(const char *name)
assert(model);
printf("Associated anim %s with model %s\n", anim->name, model->GetName());
RpClump *clump = (RpClump*)model->CreateInstance();
+#ifdef PED_SKIN
+ if(IsClumpSkinned(clump))
+ RpClumpForAllAtomics(clump, AtomicRemoveAnimFromSkinCB, nil);
+#endif
RpAnimBlendClumpInit(clump);
assocList[i].Init(clump, anim);
RpClumpDestroy(clump);
diff --git a/src/animation/AnimBlendAssociation.cpp b/src/animation/AnimBlendAssociation.cpp
index daca7d68..8c99b694 100644
--- a/src/animation/AnimBlendAssociation.cpp
+++ b/src/animation/AnimBlendAssociation.cpp
@@ -147,11 +147,11 @@ CAnimBlendAssociation::Start(float time)
SetCurrentTime(time);
}
-void
+bool
CAnimBlendAssociation::UpdateTime(float timeDelta, float relSpeed)
{
if(!IsRunning())
- return;
+ return true;
timeStep = (flags & ASSOC_MOVEMENT ? relSpeed*hierarchy->totalLength : speed) * timeDelta;
currentTime += timeStep;
@@ -174,6 +174,7 @@ CAnimBlendAssociation::UpdateTime(float timeDelta, float relSpeed)
}
}
}
+ return true;
}
// return whether we still exist after this function
diff --git a/src/animation/AnimBlendAssociation.h b/src/animation/AnimBlendAssociation.h
index d35db1db..d0c60a88 100644
--- a/src/animation/AnimBlendAssociation.h
+++ b/src/animation/AnimBlendAssociation.h
@@ -5,7 +5,6 @@
#include "AnimBlendHierarchy.h"
enum {
- // TODO
ASSOC_RUNNING = 1,
ASSOC_REPEAT = 2,
ASSOC_DELETEFADEDOUT = 4,
@@ -13,13 +12,12 @@ enum {
ASSOC_PARTIAL = 0x10,
ASSOC_MOVEMENT = 0x20, // ???
ASSOC_HAS_TRANSLATION = 0x40,
- ASSOC_FLAG80 = 0x80, // used for footstep sound calculation
- ASSOC_FLAG100 = 0x100,
- ASSOC_FLAG200 = 0x200,
- ASSOC_FLAG400 = 0x400, // unused, blending it with move anims makes them stop. 0x800 in VC
- ASSOC_FLAG800 = 0x800, // anims that we fall to front. 0x1000 in VC
- ASSOC_HAS_X_TRANSLATION = 0x1000,
- // 0x2000 is vehicle anims in VC
+ ASSOC_WALK = 0x80, // for CPed::PlayFootSteps(void)
+ ASSOC_FLAG_XPRESS = 0x100, // only used by xpress scratch, see CPed::Chat(void)
+ ASSOC_NOWALK = 0x200, // see CPed::PlayFootSteps(void)
+ ASSOC_BLOCK = 0x400, // unused in assoc description, blocks other anims from being played
+ ASSOC_FRONTAL = 0x800, // anims that we fall to front
+ ASSOC_HAS_X_TRANSLATION = 0x1000, // for 2d velocity extraction
};
// Anim hierarchy associated with a clump
@@ -75,7 +73,7 @@ public:
void SetCurrentTime(float time);
void SyncAnimation(CAnimBlendAssociation *other);
void Start(float time);
- void UpdateTime(float timeDelta, float relSpeed);
+ bool UpdateTime(float timeDelta, float relSpeed);
bool UpdateBlend(float timeDelta);
void SetRun(void) { flags |= ASSOC_RUNNING; }
@@ -86,4 +84,5 @@ public:
return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link));
}
};
-static_assert(sizeof(CAnimBlendAssociation) == 0x40, "CAnimBlendAssociation: error");
+
+VALIDATE_SIZE(CAnimBlendAssociation, 0x40);
diff --git a/src/animation/AnimBlendClumpData.h b/src/animation/AnimBlendClumpData.h
index a537425a..5c511ab8 100644
--- a/src/animation/AnimBlendClumpData.h
+++ b/src/animation/AnimBlendClumpData.h
@@ -26,7 +26,7 @@ struct AnimBlendFrameData
#endif
};
#ifndef PED_SKIN
-static_assert(sizeof(AnimBlendFrameData) == 0x14, "AnimBlendFrameData: error");
+VALIDATE_SIZE(AnimBlendFrameData, 0x14);
#endif
@@ -51,5 +51,5 @@ public:
void ForAllFrames(void (*cb)(AnimBlendFrameData*, void*), void *arg);
};
#ifndef PED_SKIN
-static_assert(sizeof(CAnimBlendClumpData) == 0x14, "CAnimBlendClumpData: error");
+VALIDATE_SIZE(CAnimBlendClumpData, 0x14);
#endif
diff --git a/src/animation/AnimBlendHierarchy.h b/src/animation/AnimBlendHierarchy.h
index 917e1585..0144108d 100644
--- a/src/animation/AnimBlendHierarchy.h
+++ b/src/animation/AnimBlendHierarchy.h
@@ -24,4 +24,5 @@ public:
void Uncompress(void);
void RemoveUncompressedData(void);
};
-static_assert(sizeof(CAnimBlendHierarchy) == 0x28, "CAnimBlendHierarchy: error");
+
+VALIDATE_SIZE(CAnimBlendHierarchy, 0x28); \ No newline at end of file
diff --git a/src/animation/AnimBlendList.h b/src/animation/AnimBlendList.h
index d4b9a64a..018b5988 100644
--- a/src/animation/AnimBlendList.h
+++ b/src/animation/AnimBlendList.h
@@ -23,5 +23,6 @@ public:
prev->next = next;
if(next)
next->prev = prev;
+ Init();
}
};
diff --git a/src/animation/AnimBlendNode.cpp b/src/animation/AnimBlendNode.cpp
index 193e9176..df6cd1d5 100644
--- a/src/animation/AnimBlendNode.cpp
+++ b/src/animation/AnimBlendNode.cpp
@@ -6,8 +6,8 @@
void
CAnimBlendNode::Init(void)
{
- frameA = 0;
- frameB = 0;
+ frameA = -1;
+ frameB = -1;
remainingTime = 0.0f;
sequence = nil;
association = nil;
diff --git a/src/animation/AnimBlendNode.h b/src/animation/AnimBlendNode.h
index 361a4134..89924d6a 100644
--- a/src/animation/AnimBlendNode.h
+++ b/src/animation/AnimBlendNode.h
@@ -26,4 +26,6 @@ public:
void GetCurrentTranslation(CVector &trans, float weight);
void GetEndTranslation(CVector &trans, float weight);
};
-static_assert(sizeof(CAnimBlendNode) == 0x1C, "CAnimBlendNode: error");
+
+
+VALIDATE_SIZE(CAnimBlendNode, 0x1C);
diff --git a/src/animation/AnimBlendSequence.h b/src/animation/AnimBlendSequence.h
index 1246d7b4..44ac8886 100644
--- a/src/animation/AnimBlendSequence.h
+++ b/src/animation/AnimBlendSequence.h
@@ -51,5 +51,5 @@ public:
#endif
};
#ifndef PED_SKIN
-static_assert(sizeof(CAnimBlendSequence) == 0x2C, "CAnimBlendSequence: error");
+VALIDATE_SIZE(CAnimBlendSequence, 0x2C);
#endif
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp
index ebd2e1fb..8fb1576c 100644
--- a/src/animation/AnimManager.cpp
+++ b/src/animation/AnimManager.cpp
@@ -11,17 +11,17 @@
#include "AnimBlendAssocGroup.h"
#include "AnimManager.h"
-CAnimBlock CAnimManager::ms_aAnimBlocks[2];
-CAnimBlendHierarchy CAnimManager::ms_aAnimations[250];
+CAnimBlock CAnimManager::ms_aAnimBlocks[NUMANIMBLOCKS];
+CAnimBlendHierarchy CAnimManager::ms_aAnimations[NUMANIMATIONS];
int32 CAnimManager::ms_numAnimBlocks;
int32 CAnimManager::ms_numAnimations;
CAnimBlendAssocGroup *CAnimManager::ms_aAnimAssocGroups;
CLinkList<CAnimBlendHierarchy*> CAnimManager::ms_animCache;
AnimAssocDesc aStdAnimDescs[] = {
- { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 },
- { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 },
- { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 },
+ { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK },
+ { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK },
+ { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK },
{ ANIM_IDLE_STANCE, ASSOC_REPEAT },
{ ANIM_WALK_START, ASSOC_HAS_TRANSLATION },
{ ANIM_RUN_STOP, ASSOC_DELETEFADEDOUT | ASSOC_HAS_TRANSLATION },
@@ -32,26 +32,26 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_IDLE_ARMED, ASSOC_REPEAT | ASSOC_PARTIAL },
{ ANIM_IDLE_CHAT, ASSOC_REPEAT | ASSOC_PARTIAL },
{ ANIM_IDLE_TAXI, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
- { ANIM_KO_SHOT_FRONT1, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 },
- { ANIM_KO_SHOT_FRONT2, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 },
- { ANIM_KO_SHOT_FRONT3, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 },
- { ANIM_KO_SHOT_FRONT4, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 },
- { ANIM_KO_SHOT_FACE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 },
+ { ANIM_KO_SHOT_FRONT1, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL },
+ { ANIM_KO_SHOT_FRONT2, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL },
+ { ANIM_KO_SHOT_FRONT3, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL },
+ { ANIM_KO_SHOT_FRONT4, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL },
+ { ANIM_KO_SHOT_FACE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL },
{ ANIM_KO_SHOT_STOM, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
- { ANIM_KO_SHOT_ARML, ASSOC_PARTIAL | ASSOC_FLAG800 },
- { ANIM_KO_SHOT_ARMR, ASSOC_PARTIAL | ASSOC_FLAG800 },
+ { ANIM_KO_SHOT_ARML, ASSOC_PARTIAL | ASSOC_FRONTAL },
+ { ANIM_KO_SHOT_ARMR, ASSOC_PARTIAL | ASSOC_FRONTAL },
{ ANIM_KO_SHOT_LEGL, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_KO_SHOT_LEGR, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
- { ANIM_KD_LEFT, ASSOC_PARTIAL | ASSOC_FLAG800 },
- { ANIM_KD_RIGHT, ASSOC_PARTIAL | ASSOC_FLAG800 },
+ { ANIM_KD_LEFT, ASSOC_PARTIAL | ASSOC_FRONTAL },
+ { ANIM_KD_RIGHT, ASSOC_PARTIAL | ASSOC_FRONTAL },
{ ANIM_KO_SKID_FRONT, ASSOC_PARTIAL },
{ ANIM_KO_SPIN_R, ASSOC_PARTIAL },
- { ANIM_KO_SKID_BACK, ASSOC_PARTIAL | ASSOC_FLAG800 },
+ { ANIM_KO_SKID_BACK, ASSOC_PARTIAL | ASSOC_FRONTAL },
{ ANIM_KO_SPIN_L, ASSOC_PARTIAL },
- { ANIM_SHOT_FRONT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
- { ANIM_SHOT_LEFT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
- { ANIM_SHOT_BACK_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
- { ANIM_SHOT_RIGHT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
+ { ANIM_SHOT_FRONT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
+ { ANIM_SHOT_LEFT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
+ { ANIM_SHOT_BACK_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
+ { ANIM_SHOT_RIGHT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
{ ANIM_HIT_FRONT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_HIT_LEFT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_HIT_BACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
@@ -62,22 +62,22 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_HIT_HEAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_HIT_WALK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_HIT_WALL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
- { ANIM_FLOOR_HIT_F, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_FLAG800 },
+ { ANIM_FLOOR_HIT_F, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_FRONTAL },
{ ANIM_HIT_BEHIND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_PUNCH_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_KICK_FLOOR, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_WEAPON_BAT_H, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_WEAPON_BAT_V, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
- { ANIM_WEAPON_HGUN_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
+ { ANIM_WEAPON_HGUN_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
{ ANIM_WEAPON_AK_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_WEAPON_PUMP, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_WEAPON_SNIPER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_WEAPON_THROW, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_WEAPON_THROWU, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_WEAPON_START_THROW, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
- { ANIM_BOMBER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
- { ANIM_HGUN_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
- { ANIM_AK_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
+ { ANIM_BOMBER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
+ { ANIM_HGUN_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
+ { ANIM_AK_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
{ ANIM_FPS_PUNCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FPS_BAT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FPS_UZI, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
@@ -96,7 +96,7 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_FIGHT_PUNCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FIGHT_ROUNDHOUSE, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_FIGHT_LONGKICK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
- { ANIM_FIGHT_PPUNCH, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_FLAG200 },
+ { ANIM_FIGHT_PPUNCH, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_NOWALK },
{ ANIM_CAR_JACKED_RHS, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_CAR_LJACKED_RHS, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_CAR_JACKED_LHS, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
@@ -142,7 +142,7 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT },
- { ANIM_CAR_GETOUT_LHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
+ { ANIM_CAR_GETOUT_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_CAR_GETOUT_LOW_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_CAR_CLOSE_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_CAR_HOOKERTALK, ASSOC_REPEAT | ASSOC_PARTIAL },
@@ -175,8 +175,8 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_FALL_LAND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_FALL_COLLAPSE, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_EV_STEP, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
- { ANIM_EV_DIVE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 },
- { ANIM_XPRESS_SCRATCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG100 },
+ { ANIM_EV_DIVE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL },
+ { ANIM_XPRESS_SCRATCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG_XPRESS },
{ ANIM_ROAD_CROSS, ASSOC_REPEAT | ASSOC_PARTIAL },
{ ANIM_TURN_180, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_ARREST_GUN, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
@@ -185,18 +185,18 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_DUCK_DOWN, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_DUCK_LOW, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_RBLOCK_CSHOOT, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
- { ANIM_WEAPON_THROWU, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
+ { ANIM_WEAPON_THROWU2, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_HANDSUP, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_HANDSCOWER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
- { ANIM_FUCKU, ASSOC_DELETEFADEDOUT | ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 },
+ { ANIM_FUCKU, ASSOC_DELETEFADEDOUT | ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
{ ANIM_PHONE_IN, ASSOC_PARTIAL },
{ ANIM_PHONE_OUT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_PHONE_TALK, ASSOC_REPEAT | ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
};
AnimAssocDesc aStdAnimDescsSide[] = {
- { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 | ASSOC_HAS_X_TRANSLATION },
- { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 | ASSOC_HAS_X_TRANSLATION },
- { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 | ASSOC_HAS_X_TRANSLATION },
+ { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION },
+ { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION },
+ { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION },
{ ANIM_IDLE_STANCE, ASSOC_REPEAT },
{ ANIM_WALK_START, ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION },
};
@@ -750,8 +750,8 @@ CAnimManager::LoadAnimFiles(void)
CBaseModelInfo *mi = CModelInfo::GetModelInfo(ms_aAnimAssocDefinitions[i].modelIndex);
RpClump *clump = (RpClump*)mi->CreateInstance();
RpAnimBlendClumpInit(clump);
- CAnimBlendAssocGroup *group = &CAnimManager::ms_aAnimAssocGroups[i];
- const AnimAssocDefinition *def = &CAnimManager::ms_aAnimAssocDefinitions[i];
+ CAnimBlendAssocGroup *group = &ms_aAnimAssocGroups[i];
+ const AnimAssocDefinition *def = &ms_aAnimAssocDefinitions[i];
group->CreateAssociations(def->blockName, clump, def->animNames, def->numAnims);
for(j = 0; j < group->numAssociations; j++)
group->GetAnimation(j)->flags |= def->animDescs[j].flags;
diff --git a/src/animation/AnimManager.h b/src/animation/AnimManager.h
index 1b333b60..de15602c 100644
--- a/src/animation/AnimManager.h
+++ b/src/animation/AnimManager.h
@@ -22,7 +22,7 @@ enum AssocGroupId
ASSOCGRP_BUSYWOMAN,
ASSOCGRP_SEXYWOMAN,
ASSOCGRP_OLDWOMAN,
- ASSOCGRP_FARWOMAN,
+ ASSOCGRP_FATWOMAN,
ASSOCGRP_PANICCHUNKY,
ASSOCGRP_PLAYERBACK,
ASSOCGRP_PLAYERLEFT,
@@ -64,8 +64,8 @@ struct AnimAssocDefinition
class CAnimManager
{
static const AnimAssocDefinition ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS];
- static CAnimBlock ms_aAnimBlocks[2];
- static CAnimBlendHierarchy ms_aAnimations[250];
+ static CAnimBlock ms_aAnimBlocks[NUMANIMBLOCKS];
+ static CAnimBlendHierarchy ms_aAnimations[NUMANIMATIONS];
static int32 ms_numAnimBlocks;
static int32 ms_numAnimations;
static CAnimBlendAssocGroup *ms_aAnimAssocGroups;
diff --git a/src/animation/CutsceneMgr.cpp b/src/animation/CutsceneMgr.cpp
index 334fe471..0db54c4b 100644
--- a/src/animation/CutsceneMgr.cpp
+++ b/src/animation/CutsceneMgr.cpp
@@ -267,11 +267,11 @@ CCutsceneMgr::SetupCutsceneToStart(void)
assert(RwObjectGetType(ms_pCutsceneObjects[i]->m_rwObject) == rpCLUMP);
if (CAnimBlendAssociation *pAnimBlendAssoc = RpAnimBlendClumpGetFirstAssociation((RpClump*)ms_pCutsceneObjects[i]->m_rwObject)) {
assert(pAnimBlendAssoc->hierarchy->sequences[0].HasTranslation());
- ms_pCutsceneObjects[i]->GetPosition() = ms_cutsceneOffset + ((KeyFrameTrans*)pAnimBlendAssoc->hierarchy->sequences[0].GetKeyFrame(0))->translation;
+ ms_pCutsceneObjects[i]->SetPosition(ms_cutsceneOffset + ((KeyFrameTrans*)pAnimBlendAssoc->hierarchy->sequences[0].GetKeyFrame(0))->translation);
CWorld::Add(ms_pCutsceneObjects[i]);
pAnimBlendAssoc->SetRun();
} else {
- ms_pCutsceneObjects[i]->GetPosition() = ms_cutsceneOffset;
+ ms_pCutsceneObjects[i]->SetPosition(ms_cutsceneOffset);
}
}
diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp
index a963b293..ecd0299c 100644
--- a/src/audio/AudioCollision.cpp
+++ b/src/audio/AudioCollision.cpp
@@ -117,63 +117,59 @@ cAudioManager::GetCollisionRatio(float a, float b, float c, float d) const
}
uint32
-cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision)
+cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision)
{
- uint8 surface1 = audioCollision->m_bSurface1;
- uint8 surface2 = audioCollision->m_bSurface2;
+ uint8 surface1 = audioCollision.m_bSurface1;
+ uint8 surface2 = audioCollision.m_bSurface2;
int32 vol;
float ratio;
if(surface1 == SURFACE_GRASS || surface2 == SURFACE_GRASS || surface1 == SURFACE_HEDGE ||
surface2 == SURFACE_HEDGE) {
- ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
+ ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
m_sQueueSample.m_nSampleIndex = SFX_RAIN;
m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000;
vol = 50.f * ratio;
+ } else if(surface1 == SURFACE_PUDDLE || surface2 == SURFACE_PUDDLE) {
+ ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
+ m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP;
+ m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000;
+ vol = 30.f * ratio;
+ } else if(surface1 == SURFACE_DIRT || surface2 == SURFACE_DIRT || surface1 == SURFACE_DIRTTRACK ||
+ surface2 == SURFACE_DIRTTRACK || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) {
+ ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
+ m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID;
+ m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000;
+ vol = 50.f * ratio;
+ } else if(surface1 == SURFACE_FLESH || surface2 == SURFACE_FLESH) {
+ return 0;
} else {
- if(surface1 == SURFACE_PUDDLE || surface2 == SURFACE_PUDDLE) {
- ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
- m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP;
- m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000;
- vol = 30.f * ratio;
-
- } else {
- if(surface1 == SURFACE_DIRT || surface2 == SURFACE_DIRT || surface1 == SURFACE_DIRTTRACK ||
- surface2 == SURFACE_DIRTTRACK || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) {
- ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
- m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID;
- m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000;
- vol = 50.f * ratio;
- } else {
- if(surface1 == SURFACE_FLESH || surface2 == SURFACE_FLESH) { return 0; }
- ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
- m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1;
- m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000;
- vol = 40.f * ratio;
- }
- }
+ ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
+ m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1;
+ m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000;
+ vol = 40.f * ratio;
}
- if(audioCollision->m_nBaseVolume < 2) vol = audioCollision->m_nBaseVolume * vol / 2;
+ if(audioCollision.m_nBaseVolume < 2) vol = audioCollision.m_nBaseVolume * vol / 2;
return vol;
}
void
-cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
+cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter)
{
- if(col->m_fIntensity2 > 0.0016f) {
+ if(col.m_fIntensity2 > 0.0016f) {
uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col);
if(emittingVol) {
- m_sQueueSample.m_fDistance = Sqrt(col->m_fDistance);
- m_sQueueSample.m_bVolume =
+ m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance);
+ m_sQueueSample.m_nVolume =
ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if(m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = counter;
- m_sQueueSample.m_vecPos = col->m_vecPosition;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_vecPos = col.m_vecPosition;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 7;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart =
SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd =
@@ -189,22 +185,43 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
}
}
}
+static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1,
+ SFX_COL_TARMAC_1,
+ SFX_COL_GRASS_1,
+ SFX_COL_GRAVEL_1,
+ SFX_COL_MUD_1,
+ SFX_COL_TARMAC_1,
+ SFX_COL_CAR_1,
+ SFX_COL_GRASS_1,
+ SFX_COL_SCAFFOLD_POLE_1,
+ SFX_COL_GARAGE_DOOR_1,
+ SFX_COL_CAR_PANEL_1,
+ SFX_COL_THICK_METAL_PLATE_1,
+ SFX_COL_SCAFFOLD_POLE_1,
+ SFX_COL_LAMP_POST_1,
+ SFX_COL_HYDRANT_1,
+ SFX_COL_HYDRANT_1,
+ SFX_COL_METAL_CHAIN_FENCE_1,
+ SFX_COL_PED_1,
+ SFX_COL_SAND_1,
+ SFX_SPLASH_1,
+ SFX_COL_WOOD_CRATES_1,
+ SFX_COL_WOOD_BENCH_1,
+ SFX_COL_WOOD_SOLID_1,
+ SFX_COL_GRASS_1,
+ SFX_COL_GRASS_1,
+ SFX_COL_VEG_1,
+ SFX_COL_TARMAC_1,
+ SFX_COL_CONTAINER_1,
+ SFX_COL_NEWS_VENDOR_1,
+ SFX_TYRE_BUMP,
+ SFX_COL_CARDBOARD_1,
+ SFX_COL_TARMAC_1,
+ SFX_COL_GATE};
void
-cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
+cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
{
- static const int32 gOneShotCol[] = {
- SFX_COL_TARMAC_1, SFX_COL_TARMAC_1, SFX_COL_GRASS_1,
- SFX_COL_GRAVEL_1, SFX_COL_MUD_1, SFX_COL_TARMAC_1,
- SFX_COL_CAR_1, SFX_COL_GRASS_1, SFX_COL_SCAFFOLD_POLE_1,
- SFX_COL_GARAGE_DOOR_1, SFX_COL_CAR_PANEL_1, SFX_COL_THICK_METAL_PLATE_1,
- SFX_COL_SCAFFOLD_POLE_1, SFX_COL_LAMP_POST_1, SFX_COL_HYDRANT_1,
- SFX_COL_HYDRANT_1, SFX_COL_METAL_CHAIN_FENCE_1, SFX_COL_PED_1,
- SFX_COL_SAND_1, SFX_SPLASH_1, SFX_COL_WOOD_CRATES_1,
- SFX_COL_WOOD_BENCH_1, SFX_COL_WOOD_SOLID_1, SFX_COL_GRASS_1,
- SFX_COL_GRASS_1, SFX_COL_VEG_1, SFX_COL_TARMAC_1,
- SFX_COL_CONTAINER_1, SFX_COL_NEWS_VENDOR_1, SFX_TYRE_BUMP,
- SFX_COL_CARDBOARD_1, SFX_COL_TARMAC_1, SFX_COL_GATE};
int16 s1;
int16 s2;
@@ -216,24 +233,24 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
for(int32 i = 0; i < 2; i++) {
if(i) {
- s1 = col->m_bSurface2;
- s2 = col->m_bSurface1;
+ s1 = col.m_bSurface2;
+ s2 = col.m_bSurface1;
} else {
- s1 = col->m_bSurface1;
- s2 = col->m_bSurface2;
+ s1 = col.m_bSurface1;
+ s2 = col.m_bSurface2;
}
- ratio = GetCollisionOneShotRatio(s1, col->m_fIntensity1);
- if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio = 0.25f * ratio;
+ ratio = GetCollisionOneShotRatio(s1, col.m_fIntensity1);
+ if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio /= 4.0f;
if(s1 == SURFACE_METAL6 && ratio < 0.6f) {
s1 = SURFACE_BILLBOARD;
ratio = Min(1.f, 2.f * ratio);
}
emittingVol = 40.f * ratio;
if(emittingVol) {
- m_sQueueSample.m_fDistance = Sqrt(col->m_fDistance);
- m_sQueueSample.m_bVolume =
+ m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance);
+ m_sQueueSample.m_nVolume =
ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if(m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = gOneShotCol[s1];
switch(m_sQueueSample.m_nSampleIndex) {
case SFX_COL_TARMAC_1:
@@ -288,12 +305,12 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nCounter = counter++;
if(counter >= 255) counter = 28;
- m_sQueueSample.m_vecPos = col->m_vecPosition;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_vecPos = col.m_vecPosition;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 11;
m_sQueueSample.m_nLoopCount = 1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
@@ -311,13 +328,13 @@ void
cAudioManager::ServiceCollisions()
{
int i, j;
- bool someArr1[NUMAUDIOCOLLISIONS];
- bool someArr2[NUMAUDIOCOLLISIONS];
+ bool abRepeatedCollision1[NUMAUDIOCOLLISIONS];
+ bool abRepeatedCollision2[NUMAUDIOCOLLISIONS];
m_sQueueSample.m_nEntityIndex = m_nCollisionEntity;
for (int i = 0; i < NUMAUDIOCOLLISIONS; i++)
- someArr1[i] = someArr2[i] = false;
+ abRepeatedCollision1[i] = abRepeatedCollision2[i] = false;
for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) {
for (j = 0; j < NUMAUDIOCOLLISIONS; j++) {
@@ -327,17 +344,17 @@ cAudioManager::ServiceCollisions()
&& (m_sCollisionManager.m_asCollisions1[index].m_bSurface1 == m_sCollisionManager.m_asCollisions2[j].m_bSurface1)
&& (m_sCollisionManager.m_asCollisions1[index].m_bSurface2 == m_sCollisionManager.m_asCollisions2[j].m_bSurface2)
) {
- someArr1[index] = true;
- someArr2[j] = true;
+ abRepeatedCollision1[index] = true;
+ abRepeatedCollision2[j] = true;
m_sCollisionManager.m_asCollisions1[index].m_nBaseVolume = ++m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume;
- SetUpLoopingCollisionSound(&m_sCollisionManager.m_asCollisions1[index], j);
+ SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j);
break;
}
}
}
for (i = 0; i < NUMAUDIOCOLLISIONS; i++) {
- if (!someArr2[i]) {
+ if (!abRepeatedCollision2[i]) {
m_sCollisionManager.m_asCollisions2[i].m_pEntity1 = nil;
m_sCollisionManager.m_asCollisions2[i].m_pEntity2 = nil;
m_sCollisionManager.m_asCollisions2[i].m_bSurface1 = SURFACE_DEFAULT;
@@ -351,9 +368,9 @@ cAudioManager::ServiceCollisions()
for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) {
int index = m_sCollisionManager.m_bIndicesTable[i];
- if (!someArr1[index]) {
+ if (!abRepeatedCollision1[index]) {
for (j = 0; j < NUMAUDIOCOLLISIONS; j++) {
- if (someArr2[j]) {
+ if (!abRepeatedCollision2[j]) {
m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume = 1;
m_sCollisionManager.m_asCollisions2[j].m_pEntity1 = m_sCollisionManager.m_asCollisions1[index].m_pEntity1;
m_sCollisionManager.m_asCollisions2[j].m_pEntity2 = m_sCollisionManager.m_asCollisions1[index].m_pEntity2;
@@ -362,8 +379,8 @@ cAudioManager::ServiceCollisions()
break;
}
}
- SetUpOneShotCollisionSound(&m_sCollisionManager.m_asCollisions1[index]);
- SetUpLoopingCollisionSound(&m_sCollisionManager.m_asCollisions1[index], j);
+ SetUpOneShotCollisionSound(m_sCollisionManager.m_asCollisions1[index]);
+ SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j);
}
}
@@ -380,7 +397,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
CVector v1;
CVector v2;
- if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_bUserPause ||
+ if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause ||
(velocity < 0.0016f && collisionPower < 0.01f))
return;
@@ -393,7 +410,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
v2 = entity2->GetPosition();
}
CVector pos = (v1 + v2) * 0.5f;
- distSquared = GetDistanceSquared(&pos);
+ distSquared = GetDistanceSquared(pos);
if(distSquared < SQR(CollisionSoundIntensity)) {
m_sCollisionManager.m_sQueue.m_pEntity1 = entity1;
m_sCollisionManager.m_sQueue.m_pEntity2 = entity2;
diff --git a/src/audio/AudioCollision.h b/src/audio/AudioCollision.h
index a21bbfdc..0a058916 100644
--- a/src/audio/AudioCollision.h
+++ b/src/audio/AudioCollision.h
@@ -2,6 +2,8 @@
#define NUMAUDIOCOLLISIONS 10
+class CEntity;
+
class cAudioCollision
{
public:
@@ -18,7 +20,7 @@ public:
// no methods
};
-static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error");
+VALIDATE_SIZE(cAudioCollision, 40);
class cAudioCollisionManager
{
@@ -33,4 +35,4 @@ public:
void AddCollisionToRequestedQueue();
};
-static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); \ No newline at end of file
+VALIDATE_SIZE(cAudioCollisionManager, 852);
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 72d1fe30..b76c2cc3 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -1,8 +1,7 @@
#include "common.h"
-
-#include "audio_enums.h"
#include "AudioManager.h"
+#include "audio_enums.h"
#include "Automobile.h"
#include "Boat.h"
@@ -70,45 +69,28 @@ const int reverseGearIntensity = 30;
const int engineDamageIntensity = 40;
const bool hornPatternsArray[8][44] = {
- {false, false, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, false, false, false, false, false,
- false, true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, false, false, false, false},
- {false, false, true, true, true, true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true, true, true, false, false},
- {false, false, true, true, true, true, true, true, true, true, true,
- true, false, false, false, false, true, true, true, true, true, false,
- false, false, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true, false},
- {false, false, true, true, true, true, true, false, false, true, true,
- true, true, true, false, false, false, true, true, true, true, true,
- true, true, true, true, true, false, false, false, true, true, true,
- true, true, true, true, true, true, true, true, true, true, false},
- {false, false, true, true, true, true, true, true, true, true, true,
- false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false, false},
- {false, false, true, true, true, false, false, false, true, true, true,
- false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false, false},
- {false, false, true, true, true, true, false, false, false, false, true,
- true, true, false, false, true, true, true, false, false, true, true,
- true, true, true, true, false, false, false, false, false, true, true,
- true, true, true, true, true, true, true, true, true, false, false},
- {false, false, true, true, true, true, false, false, true, true, true,
- true, true, false, false, false, true, true, true, true, true, true,
- false, false, false, false, true, true, true, true, true, true, true,
- true, true, true, true, true, true, false, false, false, false, false},
+ {false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false,
+ false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false},
+ {false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false},
+ {false, false, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, true, true, true, true, false,
+ false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false},
+ {false, false, true, true, true, true, true, false, false, true, true, true, true, true, false, false, false, true, true, true, true, true,
+ true, true, true, true, true, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false},
+ {false, false, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
+ {false, false, true, true, true, false, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
+ {false, false, true, true, true, true, false, false, false, false, true, true, true, false, false, true, true, true, false, false, true, true,
+ true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, false, false},
+ {false, false, true, true, true, true, false, false, true, true, true, true, true, false, false, false, true, true, true, true, true, true,
+ false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false},
};
const int totalAudioEntitiesSlots = 200;
-const uint8 panTable[64]{0, 3, 8, 12, 16, 19, 22, 24, 26, 28, 30, 31, 33, 34, 36, 37,
- 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 53,
- 54, 55, 55, 56, 56, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 61,
- 61, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63};
+const uint8 panTable[64]{0, 3, 8, 12, 16, 19, 22, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 53,
+ 54, 55, 55, 56, 56, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63};
// TODO: where is this used? Is this the right file?
enum eVehicleModel {
@@ -184,11 +166,7 @@ enum eVehicleModel {
CAR159,
};
-enum PLAY_STATUS : uint8 {
- PLAY_STATUS_STOPPED = 0,
- PLAY_STATUS_PLAYING = 1,
- PLAY_STATUS_FINISHED = 2
-};
+enum PLAY_STATUS : uint8 { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING = 1, PLAY_STATUS_FINISHED = 2 };
enum LOADING_STATUS : uint8 { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED = 1 };
@@ -210,9 +188,10 @@ cPedComments::Add(tPedComment *com)
{
uint8 index;
- if(m_nCommentsInBank[m_nActiveBank] >= NUM_PED_COMMENTS_SLOTS) {
+ if (m_nCommentsInBank[m_nActiveBank] >= NUM_PED_COMMENTS_SLOTS) {
index = m_nIndexMap[m_nActiveBank][NUM_PED_COMMENTS_SLOTS - 1];
- if(m_asPedComments[m_nActiveBank][index].m_bVolume > com->m_bVolume) return;
+ if (m_asPedComments[m_nActiveBank][index].m_bVolume > com->m_bVolume)
+ return;
} else {
index = m_nCommentsInBank[m_nActiveBank]++;
}
@@ -224,17 +203,15 @@ cPedComments::Add(tPedComment *com)
m_asPedComments[m_nActiveBank][index].m_bVolume = com->m_bVolume;
uint32 i = 0;
- if(index != 0) {
- for(i = 0; i < index; i++) {
- if(m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][i]].m_bVolume <
- m_asPedComments[m_nActiveBank][index].m_bVolume) {
+ if (index != 0) {
+ for (i = 0; i < index; i++) {
+ if (m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][i]].m_bVolume < m_asPedComments[m_nActiveBank][index].m_bVolume) {
break;
}
}
- if(i < index)
- memmove(&m_nIndexMap[m_nActiveBank][i + 1], &m_nIndexMap[m_nActiveBank][i],
- NUM_PED_COMMENTS_SLOTS - 1 - i);
+ if (i < index)
+ memmove(&m_nIndexMap[m_nActiveBank][i + 1], &m_nIndexMap[m_nActiveBank][i], NUM_PED_COMMENTS_SLOTS - 1 - i);
}
m_nIndexMap[m_nActiveBank][i] = index;
@@ -250,31 +227,25 @@ cPedComments::Process()
static const int defaultIntensity = 50;
static const int policeHeliIntensity = 400;
- if(!AudioManager.m_bUserPause) {
- if(m_nCommentsInBank[m_nActiveBank]) {
- sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]]
- .m_nSampleIndex;
- if(!SampleManager.IsPedCommentLoaded(sampleIndex))
+ if (!AudioManager.m_nUserPause) {
+ if (m_nCommentsInBank[m_nActiveBank]) {
+ sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex;
+ if (!SampleManager.IsPedCommentLoaded(sampleIndex))
SampleManager.LoadPedComment(sampleIndex);
- AudioManager.m_sQueueSample.m_nEntityIndex =
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]]
- .m_nEntityIndex;
+ AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex;
AudioManager.m_sQueueSample.m_nCounter = 0;
AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
- AudioManager.m_sQueueSample.m_bBankIndex = SAMPLEBANK_PED;
+ AudioManager.m_sQueueSample.m_nBankIndex = SAMPLEBANK_PED;
AudioManager.m_sQueueSample.m_nReleasingVolumeModificator = 3;
- AudioManager.m_sQueueSample.m_bVolume =
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_bVolume;
- AudioManager.m_sQueueSample.m_fDistance =
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]]
- .m_fDistance;
+ AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_bVolume;
+ AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance;
AudioManager.m_sQueueSample.m_nLoopCount = 1;
AudioManager.m_sQueueSample.m_nLoopStart = 0;
AudioManager.m_sQueueSample.m_nLoopEnd = -1;
- AudioManager.m_sQueueSample.m_bEmittingVolume = maxVolume;
+ AudioManager.m_sQueueSample.m_nEmittingVolume = maxVolume;
AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f;
- switch(sampleIndex) {
+ switch (sampleIndex) {
case SFX_POLICE_HELI_1:
case SFX_POLICE_HELI_2:
case SFX_POLICE_HELI_3:
@@ -285,10 +256,9 @@ cPedComments::Process()
break;
}
AudioManager.m_sQueueSample.m_bReleasingSoundFlag = true;
- AudioManager.m_sQueueSample.m_vecPos =
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos;
+ AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos;
- if(sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) {
+ if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) {
AudioManager.m_sQueueSample.m_bReverbFlag = false;
AudioManager.m_sQueueSample.m_bRequireReflection = false;
} else {
@@ -298,18 +268,15 @@ cPedComments::Process()
AudioManager.m_sQueueSample.m_bIs2D = false;
AudioManager.m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(
- AudioManager.m_sQueueSample.m_nSampleIndex) +
- AudioManager.RandomDisplacement(750);
- if(CTimer::GetIsSlowMotionActive())
+ SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750);
+ if (CTimer::GetIsSlowMotionActive())
AudioManager.m_sQueueSample.m_nFrequency /= 2;
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess =
- -1;
+ m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
AudioManager.AddSampleToRequestedQueue();
}
// Switch bank
- if(m_nActiveBank) {
+ if (m_nActiveBank) {
actualUsedBank = SAMPLEBANK_PED;
m_nActiveBank = SAMPLEBANK_MAIN;
} else {
@@ -317,16 +284,14 @@ cPedComments::Process()
m_nActiveBank = SAMPLEBANK_PED;
}
comment = m_asPedComments[actualUsedBank];
- for(uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) {
- if(m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]]
- .m_nProcess > 0) {
- --m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]]
- .m_nProcess;
+ for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) {
+ if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) {
+ --m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess;
Add(&comment[m_nIndexMap[actualUsedBank][i]]);
}
}
- for(uint32 i = 0; i < NUM_PED_COMMENTS_SLOTS; i++) {
+ for (uint32 i = 0; i < NUM_PED_COMMENTS_SLOTS; i++) {
m_nIndexMap[actualUsedBank][i] = NUM_PED_COMMENTS_SLOTS;
}
m_nCommentsInBank[actualUsedBank] = 0;
@@ -338,18 +303,18 @@ cAudioManager::cAudioManager()
m_bIsInitialised = false;
field_1 = 1;
m_fSpeedOfSound = 6.86f;
- m_bTimeSpent = 50;
- m_bActiveSamples = NUM_SOUNDS_SAMPLES_SLOTS;
- m_bActiveSampleQueue = 1;
+ m_nTimeSpent = 50;
+ m_nActiveSamples = NUM_SOUNDS_SAMPLES_SLOTS;
+ m_nActiveSampleQueue = 1;
ClearRequestedQueue();
- m_bActiveSampleQueue = 0;
+ m_nActiveSampleQueue = 0;
ClearRequestedQueue();
ClearActiveSamples();
GenerateIntegerRandomNumberTable();
field_4 = 0;
m_bDynamicAcousticModelingStatus = 1;
- for(int i = 0; i < NUM_AUDIOENTITIES; i++) {
+ for (int i = 0; i < NUM_AUDIOENTITIES; i++) {
m_asAudioEntities[i].m_bIsUsed = false;
m_anAudioEntityIndices[i] = NUM_AUDIOENTITIES;
}
@@ -362,53 +327,47 @@ cAudioManager::cAudioManager()
cAudioManager::~cAudioManager()
{
- if(m_bIsInitialised) Terminate();
+ if (m_bIsInitialised)
+ Terminate();
}
void
cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
{
uint32 i = 0;
- if(sample != 0) {
- for(; i < sample; i++) {
- if(m_asSamples[m_bActiveSampleQueue]
- [m_abSampleQueueIndexTable[m_bActiveSampleQueue][i]]
- .m_nCalculatedVolume >
- m_asSamples[m_bActiveSampleQueue][sample].m_nCalculatedVolume)
+ if (sample != 0) {
+ for (; i < sample; i++) {
+ if (m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]].m_nCalculatedVolume >
+ m_asSamples[m_nActiveSampleQueue][sample].m_nCalculatedVolume)
break;
}
- if(i < sample) {
- memmove(&m_abSampleQueueIndexTable[m_bActiveSampleQueue][i + 1],
- &m_abSampleQueueIndexTable[m_bActiveSampleQueue][i],
- m_bActiveSamples - i - 1);
+ if (i < sample) {
+ memmove(&m_abSampleQueueIndexTable[m_nActiveSampleQueue][i + 1], &m_abSampleQueueIndexTable[m_nActiveSampleQueue][i], m_nActiveSamples - i - 1);
}
}
- m_abSampleQueueIndexTable[m_bActiveSampleQueue][i] = sample;
+ m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample;
}
void
-cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1,
- uint8 counter, bool notLooping)
+cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, uint8 counter, bool notLooping)
{
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = counter;
m_sQueueSample.m_nSampleIndex = sample;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
m_sQueueSample.m_nFrequency = freq;
- if(notLooping) {
+ if (notLooping) {
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nReleasingVolumeDivider = 8;
} else {
m_sQueueSample.m_nLoopCount = 1;
}
- m_sQueueSample.m_bEmittingVolume = emittingVolume;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVolume;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -423,25 +382,21 @@ cAudioManager::AddReflectionsToRequestedQueue()
{
float reflectionDistance;
int32 noise;
- uint8 emittingVolume = (m_sQueueSample.m_bVolume >> 1) + (m_sQueueSample.m_bVolume >> 3);
+ uint8 emittingVolume = (m_sQueueSample.m_nVolume / 2) + (m_sQueueSample.m_nVolume / 8);
- for(uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) {
+ for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) {
reflectionDistance = m_afReflectionsDistances[i];
- if(reflectionDistance > 0.0f && reflectionDistance < 100.f &&
- reflectionDistance < m_sQueueSample.m_fSoundIntensity) {
- m_sQueueSample.m_bLoopsRemaining = (reflectionDistance * 500.f / 1029.f);
- if(m_sQueueSample.m_bLoopsRemaining > 5) {
+ if (reflectionDistance > 0.0f && reflectionDistance < 100.f && reflectionDistance < m_sQueueSample.m_fSoundIntensity) {
+ m_sQueueSample.m_nLoopsRemaining = (reflectionDistance * 500.f / 1029.f);
+ if (m_sQueueSample.m_nLoopsRemaining > 5) {
m_sQueueSample.m_fDistance = m_afReflectionsDistances[i];
- m_sQueueSample.m_bEmittingVolume = emittingVolume;
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume > emittingVolume >> 4) {
- m_sQueueSample.m_nCounter += ((i + 1) << 8);
- if(m_sQueueSample.m_nLoopCount) {
- noise = RandomDisplacement(
- m_sQueueSample.m_nFrequency >> 5);
- if(noise <= 0)
+ m_sQueueSample.m_nEmittingVolume = emittingVolume;
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume > emittingVolume / 16) {
+ m_sQueueSample.m_nCounter += (i + 1) * 256;
+ if (m_sQueueSample.m_nLoopCount) {
+ noise = RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
+ if (noise <= 0)
m_sQueueSample.m_nFrequency += noise;
else
m_sQueueSample.m_nFrequency -= noise;
@@ -460,46 +415,40 @@ cAudioManager::AddReleasingSounds()
{
bool toProcess[44]; // why not 27?
- int8 queue = m_bActiveSampleQueue == 0;
+ int8 queue = m_nActiveSampleQueue == 0;
- for(int32 i = 0; i < m_bSampleRequestQueuesStatus[queue]; i++) {
+ for (int32 i = 0; i < m_SampleRequestQueuesStatus[queue]; i++) {
tSound &sample = m_asSamples[queue][m_abSampleQueueIndexTable[queue][i]];
- if(sample.m_bLoopEnded) continue;
+ if (sample.m_bLoopEnded)
+ continue;
toProcess[i] = false;
- for(int32 j = 0; j < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; j++) {
- if(sample.m_nEntityIndex ==
- m_asSamples[m_bActiveSampleQueue]
- [m_abSampleQueueIndexTable[m_bActiveSampleQueue][j]]
- .m_nEntityIndex &&
- sample.m_nCounter ==
- m_asSamples[m_bActiveSampleQueue]
- [m_abSampleQueueIndexTable[m_bActiveSampleQueue][j]]
- .m_nCounter) {
+ for (int32 j = 0; j < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; j++) {
+ if (sample.m_nEntityIndex == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nEntityIndex &&
+ sample.m_nCounter == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nCounter) {
toProcess[i] = true;
break;
}
}
- if(!toProcess[i]) {
- if(sample.m_nCounter <= 255 || !sample.m_bLoopsRemaining) {
- if(!sample.m_nReleasingVolumeDivider) continue;
- if(!sample.m_nLoopCount) {
- if(sample.m_nVolumeChange == -1) {
- sample.m_nVolumeChange =
- sample.m_bVolume /
- sample.m_nReleasingVolumeDivider;
- if(sample.m_nVolumeChange <= 0)
+ if (!toProcess[i]) {
+ if (sample.m_nCounter <= 255 || !sample.m_nLoopsRemaining) {
+ if (!sample.m_nReleasingVolumeDivider)
+ continue;
+ if (!sample.m_nLoopCount) {
+ if (sample.m_nVolumeChange == -1) {
+ sample.m_nVolumeChange = sample.m_nVolume / sample.m_nReleasingVolumeDivider;
+ if (sample.m_nVolumeChange <= 0)
sample.m_nVolumeChange = 1;
}
- if(sample.m_bVolume <= sample.m_nVolumeChange) {
+ if (sample.m_nVolume <= sample.m_nVolumeChange) {
sample.m_nReleasingVolumeDivider = 0;
continue;
}
- sample.m_bVolume -= sample.m_nVolumeChange;
+ sample.m_nVolume -= sample.m_nVolumeChange;
}
--sample.m_nReleasingVolumeDivider;
- if(m_bFifthFrameFlag) {
- if(sample.m_nReleasingVolumeModificator < 20)
+ if (m_bFifthFrameFlag) {
+ if (sample.m_nReleasingVolumeModificator < 20)
++sample.m_nReleasingVolumeModificator;
}
sample.m_bReleasingSoundFlag = 0;
@@ -517,46 +466,45 @@ cAudioManager::AddSampleToRequestedQueue()
uint8 sampleIndex;
bool bReflections;
- if(m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
- calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator *
- (maxVolume - m_sQueueSample.m_bVolume);
- sampleIndex = m_bSampleRequestQueuesStatus[m_bActiveSampleQueue];
- if(sampleIndex >= m_bActiveSamples) {
- sampleIndex =
- m_abSampleQueueIndexTable[m_bActiveSampleQueue][m_bActiveSamples - 1];
- if(m_asSamples[m_bActiveSampleQueue][sampleIndex].m_nCalculatedVolume <=
- calculatedVolume)
+ if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
+ calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator * (maxVolume - m_sQueueSample.m_nVolume);
+ sampleIndex = m_SampleRequestQueuesStatus[m_nActiveSampleQueue];
+ if (sampleIndex >= m_nActiveSamples) {
+ sampleIndex = m_abSampleQueueIndexTable[m_nActiveSampleQueue][m_nActiveSamples - 1];
+ if (m_asSamples[m_nActiveSampleQueue][sampleIndex].m_nCalculatedVolume <= calculatedVolume)
return;
} else {
- ++m_bSampleRequestQueuesStatus[m_bActiveSampleQueue];
+ ++m_SampleRequestQueuesStatus[m_nActiveSampleQueue];
}
m_sQueueSample.m_nCalculatedVolume = calculatedVolume;
m_sQueueSample.m_bLoopEnded = false;
- if(m_sQueueSample.m_bIs2D) {
+ if (m_sQueueSample.m_bIs2D) {
m_sQueueSample.m_bRequireReflection = false;
- m_sQueueSample.m_bLoopsRemaining = 0;
+ m_sQueueSample.m_nLoopsRemaining = 0;
}
- if(m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount) {
+ if (m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount) {
bReflections = m_sQueueSample.m_bRequireReflection;
} else {
bReflections = false;
- m_sQueueSample.m_bLoopsRemaining = 0;
+ m_sQueueSample.m_nLoopsRemaining = 0;
}
m_sQueueSample.m_bRequireReflection = false;
- if(!m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bReverbFlag = false;
+ if (!m_bDynamicAcousticModelingStatus)
+ m_sQueueSample.m_bReverbFlag = false;
- m_asSamples[m_bActiveSampleQueue][sampleIndex] = m_sQueueSample;
+ m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample;
AddDetailsToRequestedOrderList(sampleIndex);
- if(bReflections) AddReflectionsToRequestedQueue();
+ if (bReflections)
+ AddReflectionsToRequestedQueue();
}
}
void
cAudioManager::CalculateDistance(bool &distCalculated, float dist)
{
- if(!distCalculated) {
+ if (!distCalculated) {
m_sQueueSample.m_fDistance = Sqrt(dist);
distCalculated = true;
}
@@ -571,16 +519,16 @@ cAudioManager::CheckForAnAudioFileOnCD() const
void
cAudioManager::ClearActiveSamples()
{
- for(int32 i = 0; i < m_bActiveSamples; i++) {
+ for (int32 i = 0; i < m_nActiveSamples; i++) {
m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE;
m_asActiveSamples[i].m_nCounter = 0;
m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE;
- m_asActiveSamples[i].m_bBankIndex = SAMPLEBANK_INVALID;
+ m_asActiveSamples[i].m_nBankIndex = SAMPLEBANK_INVALID;
m_asActiveSamples[i].m_bIs2D = false;
m_asActiveSamples[i].m_nReleasingVolumeModificator = 5;
m_asActiveSamples[i].m_nFrequency = 0;
- m_asActiveSamples[i].m_bVolume = 0;
- m_asActiveSamples[i].m_bEmittingVolume = 0;
+ m_asActiveSamples[i].m_nVolume = 0;
+ m_asActiveSamples[i].m_nEmittingVolume = 0;
m_asActiveSamples[i].m_fDistance = 0.0f;
m_asActiveSamples[i].m_bIsProcessed = false;
m_asActiveSamples[i].m_bLoopEnded = false;
@@ -589,14 +537,14 @@ cAudioManager::ClearActiveSamples()
m_asActiveSamples[i].m_nLoopEnd = -1;
m_asActiveSamples[i].m_fSpeedMultiplier = 0.0f;
m_asActiveSamples[i].m_fSoundIntensity = 200.0f;
- m_asActiveSamples[i].m_bOffset = 63;
+ m_asActiveSamples[i].m_nOffset = 63;
m_asActiveSamples[i].m_bReleasingSoundFlag = false;
m_asActiveSamples[i].m_nCalculatedVolume = 0;
m_asActiveSamples[i].m_nReleasingVolumeDivider = 0;
m_asActiveSamples[i].m_nVolumeChange = -1;
m_asActiveSamples[i].m_vecPos = {0.0f, 0.0f, 0.0f};
m_asActiveSamples[i].m_bReverbFlag = false;
- m_asActiveSamples[i].m_bLoopsRemaining = 0;
+ m_asActiveSamples[i].m_nLoopsRemaining = 0;
m_asActiveSamples[i].m_bRequireReflection = false;
}
}
@@ -604,10 +552,10 @@ cAudioManager::ClearActiveSamples()
void
cAudioManager::ClearMissionAudio()
{
- if(m_bIsInitialised) {
+ if (m_bIsInitialised) {
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
- m_sMissionAudio.m_bLoadingStatus = LOADING_STATUS_NOT_LOADED;
- m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_STOPPED;
+ m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED;
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED;
m_sMissionAudio.field_22 = 0;
m_sMissionAudio.m_bIsPlayed = false;
m_sMissionAudio.m_bPredefinedProperties = 1;
@@ -618,29 +566,27 @@ cAudioManager::ClearMissionAudio()
void
cAudioManager::ClearRequestedQueue()
{
- for(int32 i = 0; i < m_bActiveSamples; i++) {
- m_abSampleQueueIndexTable[m_bActiveSampleQueue][i] = m_bActiveSamples;
+ for (int32 i = 0; i < m_nActiveSamples; i++) {
+ m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = m_nActiveSamples;
}
- m_bSampleRequestQueuesStatus[m_bActiveSampleQueue] = 0;
+ m_SampleRequestQueuesStatus[m_nActiveSampleQueue] = 0;
}
int32
-cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2,
- float speedMultiplier) const
+cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) const
{
uint32 newFreq = oldFreq;
- if(!TheCamera.Get_Just_Switched_Status() && speedMultiplier != 0.0f) {
+ if (!TheCamera.Get_Just_Switched_Status() && speedMultiplier != 0.0f) {
float dist = position2 - position1;
- if(dist != 0.0f) {
- float speedOfSource = (dist / m_bTimeSpent) * speedMultiplier;
- if(m_fSpeedOfSound > Abs(speedOfSource)) {
- if(speedOfSource < 0.0f) {
+ if (dist != 0.0f) {
+ float speedOfSource = (dist / m_nTimeSpent) * speedMultiplier;
+ if (m_fSpeedOfSound > Abs(speedOfSource)) {
+ if (speedOfSource < 0.0f) {
speedOfSource = Max(speedOfSource, -1.5f);
} else {
speedOfSource = Min(speedOfSource, 1.5f);
}
- newFreq =
- (oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound);
+ newFreq = (oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound);
}
}
}
@@ -652,7 +598,8 @@ cAudioManager::ComputePan(float dist, CVector *vec)
{
int32 index = Min(63, Abs(vec->x / (dist / 64.f)));
- if(vec->x > 0.f) return Max(20, 63 - panTable[index]);
+ if (vec->x > 0.f)
+ return Max(20, 63 - panTable[index]);
return Min(107, panTable[index] + 63);
}
@@ -660,27 +607,27 @@ uint8
cAudioManager::ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const
{
float newSoundIntensity;
- if(soundIntensity <= 0.0f) return 0;
- if((soundIntensity * 0.2f) <= distance) {
- newSoundIntensity = soundIntensity * 0.2f;
- emittingVolume =
- sq((soundIntensity - newSoundIntensity - (distance - newSoundIntensity)) /
- (soundIntensity - newSoundIntensity)) *
- emittingVolume;
- }
+ if (soundIntensity <= 0.0f)
+ return 0;
+ newSoundIntensity = soundIntensity / 5.0f;
+ if (newSoundIntensity <= distance)
+ emittingVolume = sq((soundIntensity - newSoundIntensity - (distance - newSoundIntensity)) / (soundIntensity - newSoundIntensity)) * emittingVolume;
return emittingVolume;
}
int32
cAudioManager::CreateEntity(int32 type, void *entity)
{
- if(!m_bIsInitialised) return AEHANDLE_ERROR_NOAUDIOSYS;
- if(!entity) return AEHANDLE_ERROR_NOENTITY;
- if(type >= TOTAL_AUDIO_TYPES) return AEHANDLE_ERROR_BADAUDIOTYPE;
- for(uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) {
- if(!m_asAudioEntities[i].m_bIsUsed) {
+ if (!m_bIsInitialised)
+ return AEHANDLE_ERROR_NOAUDIOSYS;
+ if (!entity)
+ return AEHANDLE_ERROR_NOENTITY;
+ if (type >= TOTAL_AUDIO_TYPES)
+ return AEHANDLE_ERROR_BADAUDIOTYPE;
+ 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_bStatus = 0;
+ m_asAudioEntities[i].m_nStatus = 0;
m_asAudioEntities[i].m_nType = (eAudioType)type;
m_asAudioEntities[i].m_pEntity = entity;
m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_TOTAL_PED_SOUNDS;
@@ -700,26 +647,28 @@ cAudioManager::DestroyAllGameCreatedEntities()
{
cAudioScriptObject *entity;
- if(m_bIsInitialised) {
- for(uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) {
- if(m_asAudioEntities[i].m_bIsUsed) {
- switch(m_asAudioEntities[i].m_nType) {
+ if (m_bIsInitialised) {
+ for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) {
+ if (m_asAudioEntities[i].m_bIsUsed) {
+ switch (m_asAudioEntities[i].m_nType) {
case AUDIOTYPE_PHYSICAL:
case AUDIOTYPE_EXPLOSION:
case AUDIOTYPE_WEATHER:
case AUDIOTYPE_CRANE:
case AUDIOTYPE_GARAGE:
- case AUDIOTYPE_FIREHYDRANT: DestroyEntity(i); break;
+ case AUDIOTYPE_FIREHYDRANT:
+ DestroyEntity(i);
+ break;
case AUDIOTYPE_SCRIPTOBJECT:
- entity =
- (cAudioScriptObject *)m_asAudioEntities[i].m_pEntity;
- if(entity) {
+ entity = (cAudioScriptObject *)m_asAudioEntities[i].m_pEntity;
+ if (entity) {
delete entity;
m_asAudioEntities[i].m_pEntity = nil;
}
DestroyEntity(i);
break;
- default: break;
+ default:
+ break;
}
}
}
@@ -730,18 +679,13 @@ cAudioManager::DestroyAllGameCreatedEntities()
void
cAudioManager::DestroyEntity(int32 id)
{
- if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots &&
- m_asAudioEntities[id].m_bIsUsed) {
+ if (m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots && m_asAudioEntities[id].m_bIsUsed) {
m_asAudioEntities[id].m_bIsUsed = false;
- for(int32 i = 0; i < m_nAudioEntitiesTotal; ++i) {
- if(id == m_anAudioEntityIndices[i]) {
- if(i < totalAudioEntitiesSlots - 1)
- memmove(&m_anAudioEntityIndices[i],
- &m_anAudioEntityIndices[i + 1],
- NUM_AUDIOENTITY_EVENTS *
- (m_nAudioEntitiesTotal - (i + 1)));
- m_anAudioEntityIndices[--m_nAudioEntitiesTotal] =
- totalAudioEntitiesSlots;
+ for (int32 i = 0; i < m_nAudioEntitiesTotal; ++i) {
+ if (id == m_anAudioEntityIndices[i]) {
+ if (i < totalAudioEntitiesSlots - 1)
+ memmove(&m_anAudioEntityIndices[i], &m_anAudioEntityIndices[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesTotal - (i + 1)));
+ m_anAudioEntityIndices[--m_nAudioEntitiesTotal] = totalAudioEntitiesSlots;
return;
}
}
@@ -751,7 +695,7 @@ cAudioManager::DestroyEntity(int32 id)
void
cAudioManager::DoJumboVolOffset() const
{
- if(!(m_FrameCounter % (m_anRandomTable[0] % 6 + 3)))
+ if (!(m_FrameCounter % (m_anRandomTable[0] % 6 + 3)))
gJumboVolOffsetPercentage = m_anRandomTable[1] % 60;
}
@@ -761,11 +705,19 @@ cAudioManager::GetPlayerTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_DAMAGE: GetPhrase(&sfx, &lastSfx, SFX_CLAUDE_HIGH_DAMAGE_GRUNT_1, 11); break;
- case SOUND_PED_HIT: GetPhrase(&sfx, &lastSfx, SFX_CLAUDE_LOW_DAMAGE_GRUNT_1, 10); break;
- case SOUND_PED_LAND: GetPhrase(&sfx, &lastSfx, SFX_CLAUDE_HIT_GROUND_GRUNT_1, 6); break;
- default: sfx = NO_SAMPLE; break;
+ switch (sound) {
+ case SOUND_PED_DAMAGE:
+ GetPhrase(&sfx, &lastSfx, SFX_CLAUDE_HIGH_DAMAGE_GRUNT_1, 11);
+ break;
+ case SOUND_PED_HIT:
+ GetPhrase(&sfx, &lastSfx, SFX_CLAUDE_LOW_DAMAGE_GRUNT_1, 10);
+ break;
+ case SOUND_PED_LAND:
+ GetPhrase(&sfx, &lastSfx, SFX_CLAUDE_HIT_GROUND_GRUNT_1, 6);
+ break;
+ default:
+ sfx = NO_SAMPLE;
+ break;
}
return sfx;
}
@@ -777,20 +729,20 @@ cAudioManager::GetCopTalkSfx(int16 sound)
PedState pedState;
static uint32 lastSfx = NO_SAMPLE;
- if(sound == SOUND_PED_ARREST_COP) {
+ if (sound == SOUND_PED_ARREST_COP) {
GetPhrase(&sfx, &lastSfx, SFX_COP_VOICE_1_ARREST_1, 6);
} else {
- if(sound != SOUND_PED_PURSUIT_COP) { return GetGenericMaleTalkSfx(sound); }
+ if (sound != SOUND_PED_PURSUIT_COP) {
+ return GetGenericMaleTalkSfx(sound);
+ }
pedState = FindPlayerPed()->m_nPedState;
- if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
+ if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
return NO_SAMPLE;
GetPhrase(&sfx, &lastSfx, SFX_COP_VOICE_1_CHASE_1, 7);
}
- return (SFX_COP_VOICE_2_ARREST_1 - SFX_COP_VOICE_1_ARREST_1) *
- (m_sQueueSample.m_nEntityIndex % 5) +
- sfx;
+ return (SFX_COP_VOICE_2_ARREST_1 - SFX_COP_VOICE_1_ARREST_1) * (m_sQueueSample.m_nEntityIndex % 5) + sfx;
}
uint32
@@ -800,20 +752,20 @@ cAudioManager::GetSwatTalkSfx(int16 sound)
PedState pedState;
static uint32 lastSfx = NO_SAMPLE;
- if(sound == SOUND_PED_ARREST_SWAT) {
+ if (sound == SOUND_PED_ARREST_SWAT) {
GetPhrase(&sfx, &lastSfx, SFX_SWAT_VOICE_1_CHASE_1, 6);
} else {
- if(sound != SOUND_PED_PURSUIT_SWAT) { return GetGenericMaleTalkSfx(sound); }
+ if (sound != SOUND_PED_PURSUIT_SWAT) {
+ return GetGenericMaleTalkSfx(sound);
+ }
pedState = FindPlayerPed()->m_nPedState;
- if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
+ if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
return NO_SAMPLE;
GetPhrase(&sfx, &lastSfx, SFX_SWAT_VOICE_1_CHASE_1, 6);
}
- return (SFX_SWAT_VOICE_2_CHASE_1 - SFX_SWAT_VOICE_1_CHASE_1) *
- (m_sQueueSample.m_nEntityIndex % 4) +
- sfx;
+ return (SFX_SWAT_VOICE_2_CHASE_1 - SFX_SWAT_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 4) + sfx;
}
uint32
@@ -823,20 +775,20 @@ cAudioManager::GetFBITalkSfx(int16 sound)
PedState pedState;
static uint32 lastSfx = NO_SAMPLE;
- if(sound == SOUND_PED_ARREST_FBI) {
+ if (sound == SOUND_PED_ARREST_FBI) {
GetPhrase(&sfx, &lastSfx, SFX_FBI_VOICE_1_CHASE_1, 6);
} else {
- if(sound != SOUND_PED_PURSUIT_FBI) { return GetGenericMaleTalkSfx(sound); }
+ if (sound != SOUND_PED_PURSUIT_FBI) {
+ return GetGenericMaleTalkSfx(sound);
+ }
pedState = FindPlayerPed()->m_nPedState;
- if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
+ if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
return NO_SAMPLE;
GetPhrase(&sfx, &lastSfx, SFX_FBI_VOICE_1_CHASE_1, 6);
}
- return (SFX_FBI_VOICE_2_CHASE_1 - SFX_FBI_VOICE_1_CHASE_1) *
- (m_sQueueSample.m_nEntityIndex % 3) +
- sfx;
+ return (SFX_FBI_VOICE_2_CHASE_1 - SFX_FBI_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 3) + sfx;
}
uint32
@@ -846,16 +798,16 @@ cAudioManager::GetArmyTalkSfx(int16 sound)
PedState pedState;
static uint32 lastSfx = NO_SAMPLE;
- if(sound != SOUND_PED_PURSUIT_ARMY) { return GetGenericMaleTalkSfx(sound); }
+ if (sound != SOUND_PED_PURSUIT_ARMY) {
+ return GetGenericMaleTalkSfx(sound);
+ }
pedState = FindPlayerPed()->m_nPedState;
- if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
+ if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE)
return NO_SAMPLE;
GetPhrase(&sfx, &lastSfx, SFX_ARMY_VOICE_1_CHASE_1, 15);
- return (SFX_ARMY_VOICE_2_CHASE_1 - SFX_ARMY_VOICE_1_CHASE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_ARMY_VOICE_2_CHASE_1 - SFX_ARMY_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -864,25 +816,26 @@ cAudioManager::GetMedicTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_MEDIC_VOICE_1_GUN_PANIC_1, 5);
break;
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_MEDIC_VOICE_1_CARJACKED_1, 5);
break;
- case SOUND_PED_HEALING: GetPhrase(&sfx, &lastSfx, SFX_MEDIC_VOICE_1_AT_VICTIM_1, 12); break;
+ case SOUND_PED_HEALING:
+ GetPhrase(&sfx, &lastSfx, SFX_MEDIC_VOICE_1_AT_VICTIM_1, 12);
+ break;
case SOUND_PED_LEAVE_VEHICLE:
GetPhrase(&sfx, &lastSfx, SFX_MEDIC_VOICE_1_GET_OUT_VAN_CHAT_1, 9);
break;
case SOUND_PED_FLEE_RUN:
GetPhrase(&sfx, &lastSfx, SFX_MEDIC_VOICE_1_RUN_FROM_FIGHT_1, 6);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- return (SFX_MEDIC_VOICE_2_GUN_PANIC_1 - SFX_MEDIC_VOICE_1_GUN_PANIC_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_MEDIC_VOICE_2_GUN_PANIC_1 - SFX_MEDIC_VOICE_1_GUN_PANIC_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -897,22 +850,33 @@ cAudioManager::GetNormalMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_GUN_PANIC_1, 7);
break;
- case SOUND_PED_CAR_JACKED: GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_CARJACKED_1, 7); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_DODGE_1, 9); break;
+ case SOUND_PED_CAR_JACKED:
+ GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_CARJACKED_1, 7);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_DODGE_1, 9);
+ break;
case SOUND_PED_FLEE_RUN:
GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_RUN_FROM_FIGHT_1, 5);
break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_DRIVER_ABUSE_1, 12);
break;
- case SOUND_PED_CHAT_SEXY: GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_EYING_1, 8); break;
- case SOUND_PED_CHAT_EVENT: GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_SHOCKED_1, 10); break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_CHAT_1, 25); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT_SEXY:
+ GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_EYING_1, 8);
+ break;
+ case SOUND_PED_CHAT_EVENT:
+ GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_SHOCKED_1, 10);
+ break;
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_NORMAL_MALE_CHAT_1, 25);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -923,16 +887,14 @@ cAudioManager::GetTaxiDriverTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- if(sound == SOUND_PED_CAR_JACKED) {
+ if (sound == SOUND_PED_CAR_JACKED) {
GetPhrase(&sfx, &lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_CARJACKED_1, 7);
} else {
- if(sound != SOUND_PED_CAR_COLLISION) return GetGenericMaleTalkSfx(sound);
+ if (sound != SOUND_PED_CAR_COLLISION)
+ return GetGenericMaleTalkSfx(sound);
GetPhrase(&sfx, &lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1, 6);
}
- return (SFX_ASIAN_TAXI_DRIVER_VOICE_2_DRIVER_ABUSE_1 -
- SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_ASIAN_TAXI_DRIVER_VOICE_2_DRIVER_ABUSE_1 - SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -941,15 +903,30 @@ cAudioManager::GetPimpTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_HANDS_UP: GetPhrase(&sfx, &lastSfx, SFX_PIMP_GUN_COOL_1, 7); break;
- case SOUND_PED_CAR_JACKED: GetPhrase(&sfx, &lastSfx, SFX_PIMP_CARJACKED_1, 4); break;
- case SOUND_PED_DEFEND: GetPhrase(&sfx, &lastSfx, SFX_PIMP_FIGHT_1, 9); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_PIMP_DODGE_1, 6); break;
- case SOUND_PED_CAR_COLLISION: GetPhrase(&sfx, &lastSfx, SFX_PIMP_DRIVER_ABUSE_1, 5); break;
- case SOUND_PED_CHAT_EVENT: GetPhrase(&sfx, &lastSfx, SFX_PIMP_SHOCKED_1, 2); break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_PIMP_CHAT_1, 17); break;
- default: return GetGenericMaleTalkSfx(sound);
+ switch (sound) {
+ case SOUND_PED_HANDS_UP:
+ GetPhrase(&sfx, &lastSfx, SFX_PIMP_GUN_COOL_1, 7);
+ break;
+ case SOUND_PED_CAR_JACKED:
+ GetPhrase(&sfx, &lastSfx, SFX_PIMP_CARJACKED_1, 4);
+ break;
+ case SOUND_PED_DEFEND:
+ GetPhrase(&sfx, &lastSfx, SFX_PIMP_FIGHT_1, 9);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_PIMP_DODGE_1, 6);
+ break;
+ case SOUND_PED_CAR_COLLISION:
+ GetPhrase(&sfx, &lastSfx, SFX_PIMP_DRIVER_ABUSE_1, 5);
+ break;
+ case SOUND_PED_CHAT_EVENT:
+ GetPhrase(&sfx, &lastSfx, SFX_PIMP_SHOCKED_1, 2);
+ break;
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_PIMP_CHAT_1, 17);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -960,27 +937,32 @@ cAudioManager::GetMafiaTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKING:
GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_CARJACKING_1, 2);
break;
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_FIGHT_1, 5); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_DODGE_1, 5); break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_FIGHT_1, 5);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_DODGE_1, 5);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_DRIVER_ABUSE_1, 6);
break;
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_EYING_1, 3);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_CHAT_1, 7); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_MAFIA_MALE_VOICE_1_CHAT_1, 7);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- return (SFX_MAFIA_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_MAFIA_MALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 3) +
- sfx;
+ return (SFX_MAFIA_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_MAFIA_MALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 3) + sfx;
}
uint32
@@ -989,7 +971,7 @@ cAudioManager::GetTriadTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_GUN_COOL_1, 3);
break;
@@ -999,16 +981,23 @@ cAudioManager::GetTriadTalkSfx(int16 sound)
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_FIGHT_1, 5); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_DODGE_1, 4); break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_FIGHT_1, 5);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_DODGE_1, 4);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_DRIVER_ABUSE_1, 7);
break;
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_EYING_1, 3);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_CHAT_1, 8); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_TRIAD_MALE_VOICE_1_CHAT_1, 8);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1019,7 +1008,7 @@ cAudioManager::GetDiabloTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_GUN_COOL_1, 4);
break;
@@ -1033,20 +1022,25 @@ cAudioManager::GetDiabloTalkSfx(int16 sound)
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_FIGHT_1, 4); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_DODGE_1, 4); break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_FIGHT_1, 4);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_DODGE_1, 4);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_DRIVER_ABUSE_1, 5);
break;
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_EYING_1, 4);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_DIABLO_MALE_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- return (SFX_DIABLO_MALE_VOICE_2_CHAT_1 - SFX_DIABLO_MALE_VOICE_1_CHAT_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_DIABLO_MALE_VOICE_2_CHAT_1 - SFX_DIABLO_MALE_VOICE_1_CHAT_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1055,24 +1049,29 @@ cAudioManager::GetYakuzaTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKING:
GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_CARJACKING_1, 2);
break;
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_FIGHT_1, 5); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_DODGE_1, 4); break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_FIGHT_1, 5);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_DODGE_1, 4);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_DRIVER_ABUSE_1, 6);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_YAKUZA_MALE_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- return (SFX_YAKUZA_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_YAKUZA_MALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_YAKUZA_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_YAKUZA_MALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1081,26 +1080,35 @@ cAudioManager::GetYardieTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_HANDS_UP: sfx = SFX_YARDIE_MALE_VOICE_1_GUN_COOL_1; break;
+ switch (sound) {
+ case SOUND_PED_HANDS_UP:
+ sfx = SFX_YARDIE_MALE_VOICE_1_GUN_COOL_1;
+ break;
case SOUND_PED_CAR_JACKING:
GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_CARJACKING_1, 2);
break;
- case SOUND_PED_CAR_JACKED: sfx = SFX_YARDIE_MALE_VOICE_1_CARJACKED_1; break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_FIGHT_1, 6); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_DODGE_1, 5); break;
+ case SOUND_PED_CAR_JACKED:
+ sfx = SFX_YARDIE_MALE_VOICE_1_CARJACKED_1;
+ break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_FIGHT_1, 6);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_DODGE_1, 5);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_DRIVER_ABUSE_1, 6);
break;
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_EYING_1, 2);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_CHAT_1, 8); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_YARDIE_MALE_VOICE_1_CHAT_1, 8);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- return (SFX_YARDIE_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_YARDIE_MALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_YARDIE_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_YARDIE_MALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1109,7 +1117,7 @@ cAudioManager::GetColumbianTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKING:
GetPhrase(&sfx, &lastSfx, SFX_COLUMBIAN_MALE_VOICE_1_CARJACKING_1, 2);
break;
@@ -1128,13 +1136,13 @@ cAudioManager::GetColumbianTalkSfx(int16 sound)
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_COLUMBIAN_MALE_VOICE_1_EYING_1, 2);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_COLUMBIAN_MALE_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_COLUMBIAN_MALE_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- return (SFX_COLUMBIAN_MALE_VOICE_2_DRIVER_ABUSE_1 -
- SFX_COLUMBIAN_MALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_COLUMBIAN_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_COLUMBIAN_MALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1143,7 +1151,7 @@ cAudioManager::GetHoodTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_GUN_COOL_1, 5);
break;
@@ -1153,21 +1161,27 @@ cAudioManager::GetHoodTalkSfx(int16 sound)
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_FIGHT_1, 6); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_DODGE_1, 5); break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_FIGHT_1, 6);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_DODGE_1, 5);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_DRIVER_ABUSE_1, 7);
break;
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_EYING_1, 2);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_CHAT_1, 6); break;
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_HOOD_MALE_VOICE_1_CHAT_1, 6);
+ break;
- default: return GetGenericMaleTalkSfx(sound); break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
+ break;
}
- return (SFX_HOOD_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_HOOD_MALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_HOOD_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_HOOD_MALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1176,11 +1190,13 @@ cAudioManager::GetBlackCriminalTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_CRIMINAL_VOICE_1_GUN_COOL_1, 4);
break;
- case SOUND_PED_CAR_JACKING: sfx = SFX_BLACK_CRIMINAL_VOICE_1_CARJACKING_1; break;
+ case SOUND_PED_CAR_JACKING:
+ sfx = SFX_BLACK_CRIMINAL_VOICE_1_CARJACKING_1;
+ break;
case SOUND_PED_MUGGING:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_CRIMINAL_VOICE_1_MUGGING_1, 2);
break;
@@ -1193,7 +1209,9 @@ cAudioManager::GetBlackCriminalTalkSfx(int16 sound)
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_CRIMINAL_VOICE_1_DRIVER_ABUSE_1, 5);
break;
- default: return GetGenericMaleTalkSfx(sound); break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
+ break;
}
return sfx;
}
@@ -1204,11 +1222,13 @@ cAudioManager::GetWhiteCriminalTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_CRIMINAL_VOICE_1_GUN_COOL_1, 3);
break;
- case SOUND_PED_CAR_JACKING: sfx = SFX_WHITE_CRIMINAL_VOICE_1_CARJACKING_1; break;
+ case SOUND_PED_CAR_JACKING:
+ sfx = SFX_WHITE_CRIMINAL_VOICE_1_CARJACKING_1;
+ break;
case SOUND_PED_MUGGING:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_CRIMINAL_VOICE_1_MUGGING_1, 2);
break;
@@ -1221,7 +1241,9 @@ cAudioManager::GetWhiteCriminalTalkSfx(int16 sound)
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_CRIMINAL_VOICE_1_DRIVER_ABUSE_1, 4);
break;
- default: return GetGenericMaleTalkSfx(sound); break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
+ break;
}
return sfx;
}
@@ -1232,7 +1254,7 @@ cAudioManager::GetMaleNo2TalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_CASUAL_MALE_OLD_VOICE_1_CARJACKED_1, 3);
break;
@@ -1254,7 +1276,8 @@ cAudioManager::GetMaleNo2TalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_CASUAL_MALE_OLD_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1265,7 +1288,7 @@ cAudioManager::GetBlackProjectMaleTalkSfx(int16 sound, int32 model)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_GUN_COOL_1, 3);
break;
@@ -1287,13 +1310,14 @@ cAudioManager::GetBlackProjectMaleTalkSfx(int16 sound, int32 model)
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_EYING_1, 3);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CHAT_1, 6);
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CHAT_1, 6);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- if(model == MI_P_MAN2)
- sfx += (SFX_BLACK_PROJECT_MALE_VOICE_2_DRIVER_ABUSE_1 -
- SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1);
+ if (model == MI_P_MAN2)
+ sfx += (SFX_BLACK_PROJECT_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1);
return sfx;
}
@@ -1303,7 +1327,7 @@ cAudioManager::GetWhiteFatMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CARJACKED_1, 3);
break;
@@ -1319,8 +1343,10 @@ cAudioManager::GetWhiteFatMaleTalkSfx(int16 sound)
case SOUND_PED_WAIT_DOUBLEBACK:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_LOST_1, 2);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CHAT_1, 9);
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CHAT_1, 9);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1331,7 +1357,7 @@ cAudioManager::GetBlackFatMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_CARJACKED_1, 4);
break;
@@ -1347,8 +1373,11 @@ cAudioManager::GetBlackFatMaleTalkSfx(int16 sound)
case SOUND_PED_WAIT_DOUBLEBACK:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_LOST_1, 3);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_CHAT_1, 8); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_CHAT_1, 8);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1359,15 +1388,19 @@ cAudioManager::GetBlackCasualFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_GUN_PANIC_1, 2);
break;
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_MUGGED_1, 3); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_DODGE_1, 6); break;
+ case SOUND_PED_ROBBED:
+ GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_MUGGED_1, 3);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_DODGE_1, 6);
+ break;
case SOUND_PED_FLEE_RUN:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_RUN_FROM_FIGHT_1, 2);
break;
@@ -1377,8 +1410,11 @@ cAudioManager::GetBlackCasualFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT_EVENT:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_SHOCKED_1, 4);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_CHAT_1, 8); break;
- default: return GetGenericFemaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_FEMALE_1_VOICE_1_CHAT_1, 8);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1389,14 +1425,16 @@ cAudioManager::GetWhiteCasualFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_CASUAL_FEMALE_VOICE_1_GUN_PANIC_1, 2);
break;
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_CASUAL_FEMALE_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ROBBED: sfx = SFX_WHITE_CASUAL_FEMALE_VOICE_1_MUGGED_1; break;
+ case SOUND_PED_ROBBED:
+ sfx = SFX_WHITE_CASUAL_FEMALE_VOICE_1_MUGGED_1;
+ break;
case SOUND_PED_EVADE:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_CASUAL_FEMALE_VOICE_1_DODGE_1, 3);
break;
@@ -1412,7 +1450,8 @@ cAudioManager::GetWhiteCasualFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_CASUAL_FEMALE_VOICE_1_CHAT_1, 4);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1423,15 +1462,19 @@ cAudioManager::GetFemaleNo3TalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_GUN_PANIC_1, 5);
break;
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_CARJACKED_1, 3);
break;
- case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_MUGGED_1, 3); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_DODGE_1, 6); break;
+ case SOUND_PED_ROBBED:
+ GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_MUGGED_1, 3);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_DODGE_1, 6);
+ break;
case SOUND_PED_FLEE_RUN:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_RUN_FROM_FIGHT_1, 4);
break;
@@ -1441,8 +1484,11 @@ cAudioManager::GetFemaleNo3TalkSfx(int16 sound)
case SOUND_PED_CHAT_EVENT:
GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_SHOCKED_1, 4);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericFemaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_FEMALE_3_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1453,7 +1499,7 @@ cAudioManager::GetBlackFatFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_FAT_FEMALE_VOICE_1_GUN_PANIC_1, 4);
break;
@@ -1475,7 +1521,8 @@ cAudioManager::GetBlackFatFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_FAT_FEMALE_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1486,7 +1533,7 @@ cAudioManager::GetWhiteFatFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_FEMALE_VOICE_1_CARJACKED_1, 2);
break;
@@ -1508,7 +1555,8 @@ cAudioManager::GetWhiteFatFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_FEMALE_VOICE_1_CHAT_1, 8);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1519,11 +1567,13 @@ cAudioManager::GetBlackFemaleProstituteTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROSTITUTE_VOICE_1_GUN_COOL_1, 4);
break;
- case SOUND_PED_ROBBED: sfx = SFX_BLACK_PROSTITUTE_VOICE_1_MUGGED_1; break;
+ case SOUND_PED_ROBBED:
+ sfx = SFX_BLACK_PROSTITUTE_VOICE_1_MUGGED_1;
+ break;
case SOUND_PED_ATTACK:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROSTITUTE_VOICE_1_FIGHT_1, 4);
break;
@@ -1539,11 +1589,10 @@ cAudioManager::GetBlackFemaleProstituteTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROSTITUTE_VOICE_1_CHAT_1, 4);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
- return (SFX_BLACK_PROSTITUTE_VOICE_2_CHAT_1 - SFX_BLACK_PROSTITUTE_VOICE_1_CHAT_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_BLACK_PROSTITUTE_VOICE_2_CHAT_1 - SFX_BLACK_PROSTITUTE_VOICE_1_CHAT_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1552,7 +1601,7 @@ cAudioManager::GetWhiteFemaleProstituteTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_ROBBED:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_PROSTITUTE_VOICE_1_MUGGED_1, 2);
break;
@@ -1571,11 +1620,10 @@ cAudioManager::GetWhiteFemaleProstituteTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_PROSTITUTE_VOICE_1_CHAT_1, 4);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
- return (SFX_WHITE_PROSTITUTE_VOICE_2_CHAT_1 - SFX_WHITE_PROSTITUTE_VOICE_1_CHAT_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_WHITE_PROSTITUTE_VOICE_2_CHAT_1 - SFX_WHITE_PROSTITUTE_VOICE_1_CHAT_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1584,7 +1632,7 @@ cAudioManager::GetBlackProjectFemaleOldTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_FEMALE_OLD_VOICE_1_CARJACKED_1, 6);
break;
@@ -1606,7 +1654,8 @@ cAudioManager::GetBlackProjectFemaleOldTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_FEMALE_OLD_VOICE_1_CHAT_1, 10);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1617,11 +1666,13 @@ cAudioManager::GetBlackProjectFemaleYoungTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_FEMALE_YOUNG_VOICE_1_GUN_PANIC_1, 4);
break;
- case SOUND_PED_CAR_JACKED: sfx = SFX_BLACK_PROJECT_FEMALE_YOUNG_VOICE_1_CARJACKED_1; break;
+ case SOUND_PED_CAR_JACKED:
+ sfx = SFX_BLACK_PROJECT_FEMALE_YOUNG_VOICE_1_CARJACKED_1;
+ break;
case SOUND_PED_ROBBED:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_FEMALE_YOUNG_VOICE_1_MUGGED_1, 2);
break;
@@ -1637,7 +1688,8 @@ cAudioManager::GetBlackProjectFemaleYoungTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_FEMALE_YOUNG_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1648,7 +1700,7 @@ cAudioManager::GetChinatownMaleOldTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_MALE_OLD_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -1670,7 +1722,8 @@ cAudioManager::GetChinatownMaleOldTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_MALE_OLD_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1681,7 +1734,7 @@ cAudioManager::GetChinatownMaleYoungTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_MALE_YOUNG_VOICE_1_GUN_PANIC_1, 2);
break;
@@ -1703,7 +1756,8 @@ cAudioManager::GetChinatownMaleYoungTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_MALE_YOUNG_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1714,7 +1768,7 @@ cAudioManager::GetChinatownFemaleOldTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_OLD_FEMALE_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -1727,11 +1781,14 @@ cAudioManager::GetChinatownFemaleOldTalkSfx(int16 sound)
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_OLD_FEMALE_VOICE_1_DRIVER_ABUSE_1, 5);
break;
- case SOUND_PED_CHAT_EVENT: sfx = SFX_CHINATOWN_OLD_FEMALE_VOICE_1_SHOCKED_1; break;
+ case SOUND_PED_CHAT_EVENT:
+ sfx = SFX_CHINATOWN_OLD_FEMALE_VOICE_1_SHOCKED_1;
+ break;
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_OLD_FEMALE_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1742,7 +1799,7 @@ cAudioManager::GetChinatownFemaleYoungTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_YOUNG_FEMALE_VOICE_1_CARJACKED_1, 2);
break;
@@ -1761,7 +1818,8 @@ cAudioManager::GetChinatownFemaleYoungTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_CHINATOWN_YOUNG_FEMALE_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1772,7 +1830,7 @@ cAudioManager::GetLittleItalyMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_LITTLE_ITALY_MALE_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -1794,12 +1852,10 @@ cAudioManager::GetLittleItalyMaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_LITTLE_ITALY_MALE_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- return (SFX_LITTLE_ITALY_MALE_VOICE_2_DRIVER_ABUSE_1 -
- SFX_LITTLE_ITALY_MALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_LITTLE_ITALY_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_LITTLE_ITALY_MALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -1808,7 +1864,7 @@ cAudioManager::GetLittleItalyFemaleOldTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_LITTLE_ITALY_OLD_FEMALE_VOICE_1_CARJACKED_1, 2);
break;
@@ -1827,7 +1883,8 @@ cAudioManager::GetLittleItalyFemaleOldTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_LITTLE_ITALY_OLD_FEMALE_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1838,7 +1895,7 @@ cAudioManager::GetLittleItalyFemaleYoungTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_LITTLE_ITALY_YOUNG_FEMALE_VOICE_1_CARJACKED_1, 2);
break;
@@ -1857,7 +1914,8 @@ cAudioManager::GetLittleItalyFemaleYoungTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_LITTLE_ITALY_YOUNG_FEMALE_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1868,7 +1926,7 @@ cAudioManager::GetWhiteDockerMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_DOCKER_MALE_VOICE_1_GUN_PANIC_1, 2);
break;
@@ -1887,7 +1945,8 @@ cAudioManager::GetWhiteDockerMaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_DOCKER_MALE_VOICE_1_CHAT_1, 5);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1898,22 +1957,27 @@ cAudioManager::GetBlackDockerMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_GUN_PANIC_1, 3);
break;
case SOUND_PED_ATTACK:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_FIGHT_1, 5);
break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_DODGE_1, 5); break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_DODGE_1, 5);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_DRIVER_ABUSE_1, 6);
break;
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_EYING_1, 3);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_BLACK_DOCKER_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1924,13 +1988,19 @@ cAudioManager::GetScumMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_GUN_PANIC_1, 5);
break;
- case SOUND_PED_ROBBED: sfx = SFX_SCUM_MALE_VOICE_1_MUGGED_1; break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_FIGHT_1, 10); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_DODGE_1, 5); break;
+ case SOUND_PED_ROBBED:
+ sfx = SFX_SCUM_MALE_VOICE_1_MUGGED_1;
+ break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_FIGHT_1, 10);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_DODGE_1, 5);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_DRIVER_ABUSE_1, 6);
break;
@@ -1940,8 +2010,11 @@ cAudioManager::GetScumMaleTalkSfx(int16 sound)
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_EYING_1, 5);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_CHAT_1, 9); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_SCUM_MALE_VOICE_1_CHAT_1, 9);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -1952,20 +2025,27 @@ cAudioManager::GetScumFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_GUN_PANIC_1, 4);
break;
case SOUND_PED_ROBBED:
GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_MUGGED_1, 2);
break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_FIGHT_1, 4); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_DODGE_1, 8); break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_FIGHT_1, 4);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_DODGE_1, 8);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_DRIVER_ABUSE_1, 5);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_CHAT_1, 13); break;
- default: return GetGenericFemaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_SCUM_FEMALE_VOICE_1_CHAT_1, 13);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -1976,7 +2056,7 @@ cAudioManager::GetWhiteWorkerMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_WORKER_MALE_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -1995,7 +2075,8 @@ cAudioManager::GetWhiteWorkerMaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_WORKER_MALE_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2006,7 +2087,7 @@ cAudioManager::GetBlackWorkerMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_WORKER_MALE_VOICE_1_GUN_PANIC_1, 4);
break;
@@ -2025,7 +2106,8 @@ cAudioManager::GetBlackWorkerMaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_WORKER_MALE_VOICE_1_CHAT_1, 4);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2036,7 +2118,7 @@ cAudioManager::GetBusinessMaleYoungTalkSfx(int16 sound, int32 model)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -2061,12 +2143,12 @@ cAudioManager::GetBusinessMaleYoungTalkSfx(int16 sound, int32 model)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- if(model == MI_B_MAN3)
- sfx += (SFX_BUSINESS_MALE_YOUNG_VOICE_2_DRIVER_ABUSE_1 -
- SFX_BUSINESS_MALE_YOUNG_VOICE_1_DRIVER_ABUSE_1);
+ if (model == MI_B_MAN3)
+ sfx += (SFX_BUSINESS_MALE_YOUNG_VOICE_2_DRIVER_ABUSE_1 - SFX_BUSINESS_MALE_YOUNG_VOICE_1_DRIVER_ABUSE_1);
return sfx;
}
@@ -2076,7 +2158,7 @@ cAudioManager::GetBusinessMaleOldTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -2101,7 +2183,8 @@ cAudioManager::GetBusinessMaleOldTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_CHAT_1, 5);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2112,7 +2195,7 @@ cAudioManager::GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_GUN_PANIC_1, 4);
break;
@@ -2137,12 +2220,12 @@ cAudioManager::GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
- if(model == MI_B_WOM2)
- sfx += (SFX_WHITE_BUSINESS_FEMALE_VOICE_2_DRIVER_ABUSE_1 -
- SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DRIVER_ABUSE_1);
+ if (model == MI_B_WOM2)
+ sfx += (SFX_WHITE_BUSINESS_FEMALE_VOICE_2_DRIVER_ABUSE_1 - SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DRIVER_ABUSE_1);
return sfx;
}
@@ -2152,7 +2235,7 @@ cAudioManager::GetBlackBusinessFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_BUSINESS_FEMALE_VOICE_1_GUN_PANIC_1, 5);
break;
@@ -2177,7 +2260,8 @@ cAudioManager::GetBlackBusinessFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_BUSINESS_FEMALE_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -2188,21 +2272,30 @@ cAudioManager::GetSupermodelMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_MUGGED_1, 2); break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_FIGHT_1, 5); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_DODGE_1, 6); break;
+ case SOUND_PED_ROBBED:
+ GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_MUGGED_1, 2);
+ break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_FIGHT_1, 5);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_DODGE_1, 6);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_DRIVER_ABUSE_1, 6);
break;
case SOUND_PED_CHAT_SEXY:
GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_EYING_1, 3);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_CHAT_1, 6); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_MODEL_MALE_VOICE_1_CHAT_1, 6);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2213,22 +2306,27 @@ cAudioManager::GetSupermodelFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_GUN_PANIC_1, 4);
break;
case SOUND_PED_ROBBED:
GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_MUGGED_1, 3);
break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_DODGE_1, 4); break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_DODGE_1, 4);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_DRIVER_ABUSE_1, 7);
break;
case SOUND_PED_CHAT_EVENT:
GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_SHOCKED_1, 5);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_CHAT_1, 8); break;
- default: return GetGenericFemaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_MODEL_FEMALE_VOICE_1_CHAT_1, 8);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -2239,19 +2337,24 @@ cAudioManager::GetStewardMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_STEWARD_MALE_VOICE_1_GUN_PANIC_1, 3);
break;
case SOUND_PED_ATTACK:
GetPhrase(&sfx, &lastSfx, SFX_STEWARD_MALE_VOICE_1_FIGHT_1, 4);
break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_STEWARD_MALE_VOICE_1_DODGE_1, 3); break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_STEWARD_MALE_VOICE_1_DODGE_1, 3);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_STEWARD_MALE_VOICE_1_DRIVER_ABUSE_1, 5);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_STEWARD_MALE_VOICE_1_CHAT_1, 4); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_STEWARD_MALE_VOICE_1_CHAT_1, 4);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2262,7 +2365,7 @@ cAudioManager::GetStewardFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_STEWARD_FEMALE_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -2272,13 +2375,13 @@ cAudioManager::GetStewardFemaleTalkSfx(int16 sound)
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_STEWARD_FEMALE_VOICE_1_DRIVER_ABUSE_1, 5);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_STEWARD_FEMALE_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericFemaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_STEWARD_FEMALE_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
- return (SFX_STEWARD_FEMALE_VOICE_2_DRIVER_ABUSE_1 -
- SFX_STEWARD_FEMALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_STEWARD_FEMALE_VOICE_2_DRIVER_ABUSE_1 - SFX_STEWARD_FEMALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -2287,7 +2390,7 @@ cAudioManager::GetFanMaleTalkSfx(int16 sound, int32 model)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_ATTACK:
GetPhrase(&sfx, &lastSfx, SFX_FOOTBALL_MALE_VOICE_1_FIGHT_1, 3);
break;
@@ -2300,13 +2403,15 @@ cAudioManager::GetFanMaleTalkSfx(int16 sound, int32 model)
case SOUND_PED_CHAT_EVENT:
GetPhrase(&sfx, &lastSfx, SFX_FOOTBALL_MALE_VOICE_1_SHOCKED_1, 2);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_FOOTBALL_MALE_VOICE_1_CHAT_1, 6); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_FOOTBALL_MALE_VOICE_1_CHAT_1, 6);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
- if(model == MI_FAN_MAN2)
- sfx += (SFX_FOOTBALL_MALE_VOICE_2_DRIVER_ABUSE_1 -
- SFX_FOOTBALL_MALE_VOICE_1_DRIVER_ABUSE_1);
+ if (model == MI_FAN_MAN2)
+ sfx += (SFX_FOOTBALL_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_FOOTBALL_MALE_VOICE_1_DRIVER_ABUSE_1);
return sfx;
}
@@ -2316,8 +2421,10 @@ cAudioManager::GetFanFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_ROBBED: sfx = SFX_FOOTBALL_FEMALE_VOICE_1_MUGGED_1; break;
+ switch (sound) {
+ case SOUND_PED_ROBBED:
+ sfx = SFX_FOOTBALL_FEMALE_VOICE_1_MUGGED_1;
+ break;
case SOUND_PED_EVADE:
GetPhrase(&sfx, &lastSfx, SFX_FOOTBALL_FEMALE_VOICE_1_DODGE_1, 4);
break;
@@ -2330,12 +2437,10 @@ cAudioManager::GetFanFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_FOOTBALL_FEMALE_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
- return (SFX_FOOTBALL_FEMALE_VOICE_2_DRIVER_ABUSE_1 -
- SFX_FOOTBALL_FEMALE_VOICE_1_DRIVER_ABUSE_1) *
- (m_sQueueSample.m_nEntityIndex % 2) +
- sfx;
+ return (SFX_FOOTBALL_FEMALE_VOICE_2_DRIVER_ABUSE_1 - SFX_FOOTBALL_FEMALE_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx;
}
uint32
@@ -2344,7 +2449,7 @@ cAudioManager::GetHospitalMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_HOSPITAL_MALE_VOICE_1_GUN_PANIC_1, 4);
break;
@@ -2357,8 +2462,11 @@ cAudioManager::GetHospitalMaleTalkSfx(int16 sound)
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_HOSPITAL_MALE_VOICE_1_DRIVER_ABUSE_1, 5);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_HOSPITAL_MALE_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_HOSPITAL_MALE_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2369,7 +2477,7 @@ cAudioManager::GetHospitalFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_EVADE:
GetPhrase(&sfx, &lastSfx, SFX_HOSPITAL_FEMALE_VOICE_1_DODGE_1, 5);
break;
@@ -2379,7 +2487,8 @@ cAudioManager::GetHospitalFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_HOSPITAL_FEMALE_VOICE_1_CHAT_1, 6);
break;
- default: return GetGenericFemaleTalkSfx(sound);
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -2390,11 +2499,13 @@ cAudioManager::GetWhiteConstructionWorkerTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_MALE_CONSTRUCTION_VOICE_1_GUN_PANIC_1, 3);
break;
- case SOUND_PED_CAR_JACKED: sfx = SFX_WHITE_MALE_CONSTRUCTION_VOICE_1_CARJACKED_1; break;
+ case SOUND_PED_CAR_JACKED:
+ sfx = SFX_WHITE_MALE_CONSTRUCTION_VOICE_1_CARJACKED_1;
+ break;
case SOUND_PED_ATTACK:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_MALE_CONSTRUCTION_VOICE_1_FIGHT_1, 5);
break;
@@ -2410,7 +2521,8 @@ cAudioManager::GetWhiteConstructionWorkerTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_WHITE_MALE_CONSTRUCTION_VOICE_1_CHAT_1, 7);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2421,7 +2533,7 @@ cAudioManager::GetBlackConstructionWorkerTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_CONSTRUCTION_MALE_VOICE_1_GUN_PANIC_1, 3);
break;
@@ -2443,7 +2555,8 @@ cAudioManager::GetBlackConstructionWorkerTalkSfx(int16 sound)
case SOUND_PED_CHAT:
GetPhrase(&sfx, &lastSfx, SFX_BLACK_CONSTRUCTION_MALE_VOICE_1_CHAT_1, 4);
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2454,25 +2567,32 @@ cAudioManager::GetShopperFemaleTalkSfx(int16 sound, int32 model)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_CAR_JACKED:
GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_CARJACKED_1, 2);
break;
- case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_MUGGED_1, 2); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_DODGE_1, 6); break;
+ case SOUND_PED_ROBBED:
+ GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_MUGGED_1, 2);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_DODGE_1, 6);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_DRIVER_ABUSE_1, 7);
break;
case SOUND_PED_CHAT_EVENT:
GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_SHOCKED_1, 4);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_CHAT_1, 7); break;
- default: return GetGenericFemaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_SHOPPER_VOICE_1_CHAT_1, 7);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
- if(model == MI_SHOPPER2) {
+ if (model == MI_SHOPPER2) {
sfx += (SFX_SHOPPER_VOICE_2_DRIVER_ABUSE_1 - SFX_SHOPPER_VOICE_1_DRIVER_ABUSE_1);
- } else if(model == MI_SHOPPER3) {
+ } else if (model == MI_SHOPPER3) {
sfx += (SFX_SHOPPER_VOICE_3_DRIVER_ABUSE_1 - SFX_SHOPPER_VOICE_1_DRIVER_ABUSE_1);
}
return sfx;
@@ -2484,7 +2604,7 @@ cAudioManager::GetStudentMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_GUN_PANIC_1, 2);
break;
@@ -2494,15 +2614,20 @@ cAudioManager::GetStudentMaleTalkSfx(int16 sound)
case SOUND_PED_ATTACK:
GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_FIGHT_1, 4);
break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_DODGE_1, 4); break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_DODGE_1, 4);
+ break;
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_DRIVER_ABUSE_1, 4);
break;
case SOUND_PED_CHAT_EVENT:
GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_SHOCKED_1, 3);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_CHAT_1, 5); break;
- default: return GetGenericMaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_STUDENT_MALE_VOICE_1_CHAT_1, 5);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2513,7 +2638,7 @@ cAudioManager::GetStudentFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_COWER:
GetPhrase(&sfx, &lastSfx, SFX_STUDENT_FEMALE_VOICE_1_GUN_PANIC_1, 4);
break;
@@ -2532,8 +2657,11 @@ cAudioManager::GetStudentFemaleTalkSfx(int16 sound)
case SOUND_PED_CHAT_EVENT:
GetPhrase(&sfx, &lastSfx, SFX_STUDENT_FEMALE_VOICE_1_SHOCKED_1, 2);
break;
- case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_STUDENT_FEMALE_VOICE_1_CHAT_1, 4); break;
- default: return GetGenericFemaleTalkSfx(sound);
+ case SOUND_PED_CHAT:
+ GetPhrase(&sfx, &lastSfx, SFX_STUDENT_FEMALE_VOICE_1_CHAT_1, 4);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
}
return sfx;
}
@@ -2548,21 +2676,36 @@ uint32
cAudioManager::GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound)
{
char *modelName = CModelInfo::GetModelInfo(modelIndex)->GetName();
- if(!CGeneral::faststricmp(modelName, "eight") ||
- !CGeneral::faststricmp(modelName, "eight2")) {
+ if (!CGeneral::faststricmp(modelName, "eight") || !CGeneral::faststricmp(modelName, "eight2")) {
return GetEightTalkSfx(sound);
}
- if(!CGeneral::faststricmp(modelName, "frankie")) { return GetFrankieTalkSfx(sound); }
- if(!CGeneral::faststricmp(modelName, "misty")) { return GetMistyTalkSfx(sound); }
- if(!CGeneral::faststricmp(modelName, "ojg") || !CGeneral::faststricmp(modelName, "ojg_p")) {
+ if (!CGeneral::faststricmp(modelName, "frankie")) {
+ return GetFrankieTalkSfx(sound);
+ }
+ if (!CGeneral::faststricmp(modelName, "misty")) {
+ return GetMistyTalkSfx(sound);
+ }
+ if (!CGeneral::faststricmp(modelName, "ojg") || !CGeneral::faststricmp(modelName, "ojg_p")) {
return GetOJGTalkSfx(sound);
}
- if(!CGeneral::faststricmp(modelName, "cat")) { return GetCatatalinaTalkSfx(sound); }
- if(!CGeneral::faststricmp(modelName, "bomber")) { return GetBomberTalkSfx(sound); }
- if(!CGeneral::faststricmp(modelName, "s_guard")) { return GetSecurityGuardTalkSfx(sound); }
- if(!CGeneral::faststricmp(modelName, "chunky")) { return GetChunkyTalkSfx(sound); }
- if(!CGeneral::faststricmp(modelName, "asuka")) { return GetGenericFemaleTalkSfx(sound); }
- if(!CGeneral::faststricmp(modelName, "maria")) { return GetGenericFemaleTalkSfx(sound); }
+ if (!CGeneral::faststricmp(modelName, "cat")) {
+ return GetCatatalinaTalkSfx(sound);
+ }
+ if (!CGeneral::faststricmp(modelName, "bomber")) {
+ return GetBomberTalkSfx(sound);
+ }
+ if (!CGeneral::faststricmp(modelName, "s_guard")) {
+ return GetSecurityGuardTalkSfx(sound);
+ }
+ if (!CGeneral::faststricmp(modelName, "chunky")) {
+ return GetChunkyTalkSfx(sound);
+ }
+ if (!CGeneral::faststricmp(modelName, "asuka")) {
+ return GetGenericFemaleTalkSfx(sound);
+ }
+ if (!CGeneral::faststricmp(modelName, "maria")) {
+ return GetGenericFemaleTalkSfx(sound);
+ }
return GetGenericMaleTalkSfx(sound);
}
@@ -2572,12 +2715,21 @@ cAudioManager::GetEightTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_HANDS_UP: GetPhrase(&sfx, &lastSfx, SFX_8BALL_GUN_COOL_1, 2); break;
- case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_8BALL_MUGGED_1, 2); break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_8BALL_FIGHT_1, 6); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_8BALL_DODGE_1, 7); break;
- default: return GetGenericMaleTalkSfx(sound);
+ switch (sound) {
+ case SOUND_PED_HANDS_UP:
+ GetPhrase(&sfx, &lastSfx, SFX_8BALL_GUN_COOL_1, 2);
+ break;
+ case SOUND_PED_ROBBED:
+ GetPhrase(&sfx, &lastSfx, SFX_8BALL_MUGGED_1, 2);
+ break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_8BALL_FIGHT_1, 6);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_8BALL_DODGE_1, 7);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2588,12 +2740,21 @@ cAudioManager::GetFrankieTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_HANDS_UP: GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_GUN_COOL_1, 4); break;
- case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_MUGGED_1, 2); break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_FIGHT_1, 6); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_DODGE_1, 3); break;
- default: return GetGenericMaleTalkSfx(sound);
+ switch (sound) {
+ case SOUND_PED_HANDS_UP:
+ GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_GUN_COOL_1, 4);
+ break;
+ case SOUND_PED_ROBBED:
+ GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_MUGGED_1, 2);
+ break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_FIGHT_1, 6);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_SALVATORE_DODGE_1, 3);
+ break;
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2604,13 +2765,25 @@ cAudioManager::GetMistyTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_HANDS_UP: GetPhrase(&sfx, &lastSfx, SFX_MISTY_GUN_COOL_1, 5); break;
- case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_MISTY_MUGGED_1, 2); break;
- case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_MISTY_FIGHT_1, 4); break;
- case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_MISTY_DODGE_1, 5); break;
- case SOUND_PED_TAXI_CALL: GetPhrase(&sfx, &lastSfx, SFX_MISTY_HERE_1, 4); break;
- default: return GetGenericFemaleTalkSfx(sound); break;
+ switch (sound) {
+ case SOUND_PED_HANDS_UP:
+ GetPhrase(&sfx, &lastSfx, SFX_MISTY_GUN_COOL_1, 5);
+ break;
+ case SOUND_PED_ROBBED:
+ GetPhrase(&sfx, &lastSfx, SFX_MISTY_MUGGED_1, 2);
+ break;
+ case SOUND_PED_ATTACK:
+ GetPhrase(&sfx, &lastSfx, SFX_MISTY_FIGHT_1, 4);
+ break;
+ case SOUND_PED_EVADE:
+ GetPhrase(&sfx, &lastSfx, SFX_MISTY_DODGE_1, 5);
+ break;
+ case SOUND_PED_TAXI_CALL:
+ GetPhrase(&sfx, &lastSfx, SFX_MISTY_HERE_1, 4);
+ break;
+ default:
+ return GetGenericFemaleTalkSfx(sound);
+ break;
}
return sfx;
}
@@ -2633,7 +2806,8 @@ cAudioManager::GetBomberTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- if(sound != SOUND_PED_BOMBER) return GetGenericMaleTalkSfx(sound);
+ if (sound != SOUND_PED_BOMBER)
+ return GetGenericMaleTalkSfx(sound);
GetPhrase(&sfx, &lastSfx, SFX_BOMBERMAN_1, 7);
return sfx;
@@ -2645,11 +2819,13 @@ cAudioManager::GetSecurityGuardTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HANDS_UP:
GetPhrase(&sfx, &lastSfx, SFX_SECURITY_GUARD_VOICE_1_GUN_COOL_1, 2);
break;
- case SOUND_PED_HANDS_COWER: sfx = SFX_SECURITY_GUARD_VOICE_1_GUN_PANIC_1; break;
+ case SOUND_PED_HANDS_COWER:
+ sfx = SFX_SECURITY_GUARD_VOICE_1_GUN_PANIC_1;
+ break;
case SOUND_PED_CAR_JACKED:
case SOUND_PED_CAR_COLLISION:
GetPhrase(&sfx, &lastSfx, SFX_SECURITY_GUARD_VOICE_1_DRIVER_ABUSE_1, 6);
@@ -2664,7 +2840,8 @@ cAudioManager::GetSecurityGuardTalkSfx(int16 sound)
GetPhrase(&sfx, &lastSfx, SFX_SECURITY_GUARD_VOICE_1_DRIVER_ABUSE_1, 12);
#endif
break;
- default: return GetGenericMaleTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
return sfx;
}
@@ -2675,9 +2852,11 @@ cAudioManager::GetChunkyTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- if(sound == SOUND_PED_DEATH) return SFX_CHUNKY_DEATH;
+ if (sound == SOUND_PED_DEATH)
+ return SFX_CHUNKY_DEATH;
- if(sound != SOUND_PED_FLEE_RUN) return GetGenericMaleTalkSfx(sound);
+ if (sound != SOUND_PED_FLEE_RUN)
+ return GetGenericMaleTalkSfx(sound);
GetPhrase(&sfx, &lastSfx, SFX_CHUNKY_RUN_1, 5);
return sfx;
@@ -2689,13 +2868,22 @@ cAudioManager::GetGenericMaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_DEATH: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_DEATH_1, 8); break;
+ switch (sound) {
+ case SOUND_PED_DEATH:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_DEATH_1, 8);
+ break;
case SOUND_PED_BULLET_HIT:
- case SOUND_PED_DEFEND: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_GRUNT_1, 15); break;
- case SOUND_PED_BURNING: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_FIRE_1, 8); break;
- case SOUND_PED_FLEE_SPRINT: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_PANIC_1, 6); break;
- default: return NO_SAMPLE;
+ case SOUND_PED_DEFEND:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_GRUNT_1, 15);
+ break;
+ case SOUND_PED_BURNING:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_FIRE_1, 8);
+ break;
+ case SOUND_PED_FLEE_SPRINT:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_MALE_PANIC_1, 6);
+ break;
+ default:
+ return NO_SAMPLE;
}
return sfx;
}
@@ -2706,13 +2894,22 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound)
uint32 sfx;
static uint32 lastSfx = NO_SAMPLE;
- switch(sound) {
- case SOUND_PED_DEATH: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_DEATH_1, 10); break;
+ switch (sound) {
+ case SOUND_PED_DEATH:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_DEATH_1, 10);
+ break;
case SOUND_PED_BULLET_HIT:
- case SOUND_PED_DEFEND: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_GRUNT_1, 11); break;
- case SOUND_PED_BURNING: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_FIRE_1, 9); break;
- case SOUND_PED_FLEE_SPRINT: GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_PANIC_1, 8); break;
- default: return NO_SAMPLE;
+ case SOUND_PED_DEFEND:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_GRUNT_1, 11);
+ break;
+ case SOUND_PED_BURNING:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_FIRE_1, 9);
+ break;
+ case SOUND_PED_FLEE_SPRINT:
+ GetPhrase(&sfx, &lastSfx, SFX_GENERIC_FEMALE_PANIC_1, 8);
+ break;
+ default:
+ return NO_SAMPLE;
}
return sfx;
}
@@ -2720,21 +2917,26 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound)
void
cAudioManager::GenerateIntegerRandomNumberTable()
{
- for(int32 i = 0; i < ARRAY_SIZE(m_anRandomTable); i++) { m_anRandomTable[i] = rand(); }
+ for (int32 i = 0; i < ARRAY_SIZE(m_anRandomTable); i++) {
+ m_anRandomTable[i] = rand();
+ }
}
char *
cAudioManager::Get3DProviderName(uint8 id) const
{
- if(!m_bIsInitialised) return nil;
- if(id >= SampleManager.GetNum3DProvidersAvailable()) return nil;
+ if (!m_bIsInitialised)
+ return nil;
+ if (id >= SampleManager.GetNum3DProvidersAvailable())
+ return nil;
return SampleManager.Get3DProviderName(id);
}
uint8
cAudioManager::GetCDAudioDriveLetter() const
{
- if(m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter();
+ if (m_bIsInitialised)
+ return SampleManager.GetCDAudioDriveLetter();
return 0;
}
@@ -2742,16 +2944,17 @@ cAudioManager::GetCDAudioDriveLetter() const
int8
cAudioManager::GetCurrent3DProviderIndex() const
{
- if(m_bIsInitialised) return SampleManager.GetCurrent3DProviderIndex();
+ if (m_bIsInitialised)
+ return SampleManager.GetCurrent3DProviderIndex();
return -1;
}
float
-cAudioManager::GetDistanceSquared(CVector *v) const
+cAudioManager::GetDistanceSquared(const CVector &v) const
{
const CVector &c = TheCamera.GetPosition();
- return sq(v->x - c.x) + sq(v->y - c.y) + sq((v->z - c.z) * 0.2f);
+ return sq(v.x - c.x) + sq(v.y - c.y) + sq((v.z - c.z) * 0.2f);
}
int32
@@ -2763,7 +2966,8 @@ cAudioManager::GetJumboTaxiFreq() const
bool
cAudioManager::GetMissionAudioLoadingStatus() const
{
- if(m_bIsInitialised) return m_sMissionAudio.m_bLoadingStatus;
+ if (m_bIsInitialised)
+ return m_sMissionAudio.m_nLoadingStatus;
return true;
}
@@ -2771,99 +2975,165 @@ cAudioManager::GetMissionAudioLoadingStatus() const
uint8
cAudioManager::GetNum3DProvidersAvailable() const
{
- if(m_bIsInitialised) return SampleManager.GetNum3DProvidersAvailable();
+ if (m_bIsInitialised)
+ return SampleManager.GetNum3DProvidersAvailable();
return 0;
}
int32
cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound)
{
- if(ped->IsPlayer()) return GetPlayerTalkSfx(sound);
-
- switch(ped->m_modelIndex) {
- case MI_COP: return GetCopTalkSfx(sound);
- case MI_SWAT: return GetSwatTalkSfx(sound);
- case MI_FBI: return GetFBITalkSfx(sound);
- case MI_ARMY: return GetArmyTalkSfx(sound);
- case MI_MEDIC: return GetMedicTalkSfx(sound);
- case MI_FIREMAN: return GetFiremanTalkSfx(sound);
- case MI_MALE01: return GetNormalMaleTalkSfx(sound);
- case MI_TAXI_D: return GetTaxiDriverTalkSfx(sound);
- case MI_PIMP: return GetPimpTalkSfx(sound);
+ if (ped->IsPlayer())
+ return GetPlayerTalkSfx(sound);
+
+ switch (ped->GetModelIndex()) {
+ case MI_COP:
+ return GetCopTalkSfx(sound);
+ case MI_SWAT:
+ return GetSwatTalkSfx(sound);
+ case MI_FBI:
+ return GetFBITalkSfx(sound);
+ case MI_ARMY:
+ return GetArmyTalkSfx(sound);
+ case MI_MEDIC:
+ return GetMedicTalkSfx(sound);
+ case MI_FIREMAN:
+ return GetFiremanTalkSfx(sound);
+ case MI_MALE01:
+ return GetNormalMaleTalkSfx(sound);
+ case MI_TAXI_D:
+ return GetTaxiDriverTalkSfx(sound);
+ case MI_PIMP:
+ return GetPimpTalkSfx(sound);
case MI_GANG01:
- case MI_GANG02: return GetMafiaTalkSfx(sound);
+ case MI_GANG02:
+ return GetMafiaTalkSfx(sound);
case MI_GANG03:
- case MI_GANG04: return GetTriadTalkSfx(sound);
+ case MI_GANG04:
+ return GetTriadTalkSfx(sound);
case MI_GANG05:
- case MI_GANG06: return GetDiabloTalkSfx(sound);
+ case MI_GANG06:
+ return GetDiabloTalkSfx(sound);
case MI_GANG07:
- case MI_GANG08: return GetYakuzaTalkSfx(sound);
+ case MI_GANG08:
+ return GetYakuzaTalkSfx(sound);
case MI_GANG09:
- case MI_GANG10: return GetYardieTalkSfx(sound);
+ case MI_GANG10:
+ return GetYardieTalkSfx(sound);
case MI_GANG11:
- case MI_GANG12: return GetColumbianTalkSfx(sound);
+ case MI_GANG12:
+ return GetColumbianTalkSfx(sound);
case MI_GANG13:
- case MI_GANG14: return GetHoodTalkSfx(sound);
- case MI_CRIMINAL01: return GetBlackCriminalTalkSfx(sound);
- case MI_CRIMINAL02: return GetWhiteCriminalTalkSfx(sound);
+ case MI_GANG14:
+ return GetHoodTalkSfx(sound);
+ case MI_CRIMINAL01:
+ return GetBlackCriminalTalkSfx(sound);
+ case MI_CRIMINAL02:
+ return GetWhiteCriminalTalkSfx(sound);
case MI_SPECIAL01:
case MI_SPECIAL02:
case MI_SPECIAL03:
- case MI_SPECIAL04: return GetSpecialCharacterTalkSfx(ped->m_modelIndex, sound);
- case MI_MALE02: return GetMaleNo2TalkSfx(sound);
+ case MI_SPECIAL04:
+ return GetSpecialCharacterTalkSfx(ped->GetModelIndex(), sound);
+ case MI_MALE02:
+ return GetMaleNo2TalkSfx(sound);
case MI_MALE03:
case MI_P_MAN1:
- case MI_P_MAN2: return GetBlackProjectMaleTalkSfx(sound, ped->m_modelIndex);
- case MI_FATMALE01: return GetWhiteFatMaleTalkSfx(sound);
- case MI_FATMALE02: return GetBlackFatMaleTalkSfx(sound);
- case MI_FEMALE01: return GetBlackCasualFemaleTalkSfx(sound);
+ case MI_P_MAN2:
+ return GetBlackProjectMaleTalkSfx(sound, ped->GetModelIndex());
+ case MI_FATMALE01:
+ return GetWhiteFatMaleTalkSfx(sound);
+ case MI_FATMALE02:
+ return GetBlackFatMaleTalkSfx(sound);
+ case MI_FEMALE01:
+ return GetBlackCasualFemaleTalkSfx(sound);
case MI_FEMALE02:
- case MI_CAS_WOM: return GetWhiteCasualFemaleTalkSfx(sound);
- case MI_FEMALE03: return GetFemaleNo3TalkSfx(sound);
- case MI_FATFEMALE01: return GetBlackFatFemaleTalkSfx(sound);
- case MI_FATFEMALE02: return GetWhiteFatFemaleTalkSfx(sound);
- case MI_PROSTITUTE: return GetBlackFemaleProstituteTalkSfx(sound);
- case MI_PROSTITUTE2: return GetWhiteFemaleProstituteTalkSfx(sound);
- case MI_P_WOM1: return GetBlackProjectFemaleOldTalkSfx(sound);
- case MI_P_WOM2: return GetBlackProjectFemaleYoungTalkSfx(sound);
- case MI_CT_MAN1: return GetChinatownMaleOldTalkSfx(sound);
- case MI_CT_MAN2: return GetChinatownMaleYoungTalkSfx(sound);
- case MI_CT_WOM1: return GetChinatownFemaleOldTalkSfx(sound);
- case MI_CT_WOM2: return GetChinatownFemaleYoungTalkSfx(sound);
+ case MI_CAS_WOM:
+ return GetWhiteCasualFemaleTalkSfx(sound);
+ case MI_FEMALE03:
+ return GetFemaleNo3TalkSfx(sound);
+ case MI_FATFEMALE01:
+ return GetBlackFatFemaleTalkSfx(sound);
+ case MI_FATFEMALE02:
+ return GetWhiteFatFemaleTalkSfx(sound);
+ case MI_PROSTITUTE:
+ return GetBlackFemaleProstituteTalkSfx(sound);
+ case MI_PROSTITUTE2:
+ return GetWhiteFemaleProstituteTalkSfx(sound);
+ case MI_P_WOM1:
+ return GetBlackProjectFemaleOldTalkSfx(sound);
+ case MI_P_WOM2:
+ return GetBlackProjectFemaleYoungTalkSfx(sound);
+ case MI_CT_MAN1:
+ return GetChinatownMaleOldTalkSfx(sound);
+ case MI_CT_MAN2:
+ return GetChinatownMaleYoungTalkSfx(sound);
+ case MI_CT_WOM1:
+ return GetChinatownFemaleOldTalkSfx(sound);
+ case MI_CT_WOM2:
+ return GetChinatownFemaleYoungTalkSfx(sound);
case MI_LI_MAN1:
- case MI_LI_MAN2: return GetLittleItalyMaleTalkSfx(sound);
- case MI_LI_WOM1: return GetLittleItalyFemaleOldTalkSfx(sound);
- case MI_LI_WOM2: return GetLittleItalyFemaleYoungTalkSfx(sound);
- case MI_DOCKER1: return GetWhiteDockerMaleTalkSfx(sound);
- case MI_DOCKER2: return GetBlackDockerMaleTalkSfx(sound);
- case MI_SCUM_MAN: return GetScumMaleTalkSfx(sound);
- case MI_SCUM_WOM: return GetScumFemaleTalkSfx(sound);
- case MI_WORKER1: return GetWhiteWorkerMaleTalkSfx(sound);
- case MI_WORKER2: return GetBlackWorkerMaleTalkSfx(sound);
+ case MI_LI_MAN2:
+ return GetLittleItalyMaleTalkSfx(sound);
+ case MI_LI_WOM1:
+ return GetLittleItalyFemaleOldTalkSfx(sound);
+ case MI_LI_WOM2:
+ return GetLittleItalyFemaleYoungTalkSfx(sound);
+ case MI_DOCKER1:
+ return GetWhiteDockerMaleTalkSfx(sound);
+ case MI_DOCKER2:
+ return GetBlackDockerMaleTalkSfx(sound);
+ case MI_SCUM_MAN:
+ return GetScumMaleTalkSfx(sound);
+ case MI_SCUM_WOM:
+ return GetScumFemaleTalkSfx(sound);
+ case MI_WORKER1:
+ return GetWhiteWorkerMaleTalkSfx(sound);
+ case MI_WORKER2:
+ return GetBlackWorkerMaleTalkSfx(sound);
case MI_B_MAN1:
- case MI_B_MAN3: return GetBusinessMaleYoungTalkSfx(sound, ped->m_modelIndex);
- case MI_B_MAN2: return GetBusinessMaleOldTalkSfx(sound);
+ case MI_B_MAN3:
+ return GetBusinessMaleYoungTalkSfx(sound, ped->GetModelIndex());
+ case MI_B_MAN2:
+ return GetBusinessMaleOldTalkSfx(sound);
case MI_B_WOM1:
- case MI_B_WOM2: return GetWhiteBusinessFemaleTalkSfx(sound, ped->m_modelIndex);
- case MI_B_WOM3: return GetBlackBusinessFemaleTalkSfx(sound);
- case MI_MOD_MAN: return GetSupermodelMaleTalkSfx(sound);
- case MI_MOD_WOM: return GetSupermodelFemaleTalkSfx(sound);
- case MI_ST_MAN: return GetStewardMaleTalkSfx(sound);
- case MI_ST_WOM: return GetStewardFemaleTalkSfx(sound);
+ case MI_B_WOM2:
+ return GetWhiteBusinessFemaleTalkSfx(sound, ped->GetModelIndex());
+ case MI_B_WOM3:
+ return GetBlackBusinessFemaleTalkSfx(sound);
+ case MI_MOD_MAN:
+ return GetSupermodelMaleTalkSfx(sound);
+ case MI_MOD_WOM:
+ return GetSupermodelFemaleTalkSfx(sound);
+ case MI_ST_MAN:
+ return GetStewardMaleTalkSfx(sound);
+ case MI_ST_WOM:
+ return GetStewardFemaleTalkSfx(sound);
case MI_FAN_MAN1:
- case MI_FAN_MAN2: return GetFanMaleTalkSfx(sound, ped->m_modelIndex);
- case MI_FAN_WOM: return GetFanFemaleTalkSfx(sound);
- case MI_HOS_MAN: return GetHospitalMaleTalkSfx(sound);
- case MI_HOS_WOM: return GetHospitalFemaleTalkSfx(sound);
- case MI_CONST1: return GetWhiteConstructionWorkerTalkSfx(sound);
- case MI_CONST2: return GetBlackConstructionWorkerTalkSfx(sound);
+ case MI_FAN_MAN2:
+ return GetFanMaleTalkSfx(sound, ped->GetModelIndex());
+ case MI_FAN_WOM:
+ return GetFanFemaleTalkSfx(sound);
+ case MI_HOS_MAN:
+ return GetHospitalMaleTalkSfx(sound);
+ case MI_HOS_WOM:
+ return GetHospitalFemaleTalkSfx(sound);
+ case MI_CONST1:
+ return GetWhiteConstructionWorkerTalkSfx(sound);
+ case MI_CONST2:
+ return GetBlackConstructionWorkerTalkSfx(sound);
case MI_SHOPPER1:
case MI_SHOPPER2:
- case MI_SHOPPER3: return GetShopperFemaleTalkSfx(sound, ped->m_modelIndex);
- case MI_STUD_MAN: return GetStudentMaleTalkSfx(sound);
- case MI_STUD_WOM: return GetStudentFemaleTalkSfx(sound);
- case MI_CAS_MAN: return GetCasualMaleOldTalkSfx(sound);
- default: return GetGenericMaleTalkSfx(sound);
+ case MI_SHOPPER3:
+ return GetShopperFemaleTalkSfx(sound, ped->GetModelIndex());
+ case MI_STUD_MAN:
+ return GetStudentMaleTalkSfx(sound);
+ case MI_STUD_WOM:
+ return GetStudentFemaleTalkSfx(sound);
+ case MI_CAS_MAN:
+ return GetCasualMaleOldTalkSfx(sound);
+ default:
+ return GetGenericMaleTalkSfx(sound);
}
}
@@ -2874,13 +3144,13 @@ cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint
// check if the same sfx like last time, if yes, then try use next one,
// if exceeded range, then choose first available sample
- if(*phrase == *prevPhrase && ++*phrase >= sample + maxOffset) *phrase = sample;
+ if (*phrase == *prevPhrase && ++*phrase >= sample + maxOffset)
+ *phrase = sample;
*prevPhrase = *phrase;
}
float
-cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
- cTransmission *transmission, float velocityChange)
+cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange)
{
tWheelState wheelState;
float relativeVelChange;
@@ -2890,26 +3160,28 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil
float relativeVel;
wheelState = automobile->m_aWheelState[wheel];
- if(wheelState == WHEEL_STATE_SPINNING && gasPedalAudio > 0.4f) {
+ if (wheelState == WHEEL_STATE_SPINNING && gasPedalAudio > 0.4f) {
relativeVelChange = (gasPedalAudio - 0.4f) * 1.25f;
- } else if(wheelState == WHEEL_STATE_SKIDDING) {
+ } else if (wheelState == WHEEL_STATE_SKIDDING) {
relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
- } else if(wheelState == WHEEL_STATE_FIXED) {
+ } else if (wheelState == WHEEL_STATE_FIXED) {
modificator = 0.4f;
relativeVelChange = gasPedalAudio;
- if(relativeVelChange > 0.4f) {
+ if (relativeVelChange > 0.4f) {
relativeVelChange = relativeVelChange - 0.4f;
modificator = 5.f / 3.f;
}
velChange = Abs(velocityChange);
- if(relativeVelChange > 0.4f) relativeVelChange = relativeVelChange * modificator;
- if(velChange > 0.04f) {
+ if (relativeVelChange > 0.4f)
+ relativeVelChange = relativeVelChange * modificator;
+ if (velChange > 0.04f) {
relativeVel = Min(1.0f, velChange / transmission->fMaxVelocity);
} else {
relativeVel = 0.0f;
}
- if(relativeVel >= relativeVelChange) relativeVelChange = relativeVel;
+ if (relativeVel >= relativeVelChange)
+ relativeVelChange = relativeVel;
} else {
relativeVelChange = 0.0f;
}
@@ -2918,12 +3190,11 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil
}
float
-cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile,
- cTransmission *transmission, float velocityChange)
+cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange)
{
float relativeVelChange;
- if(automobile->m_aWheelState[wheel] == 2) {
+ if (automobile->m_aWheelState[wheel] == 2) {
relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity);
} else {
relativeVelChange = 0.0f;
@@ -2935,22 +3206,21 @@ cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automo
bool
cAudioManager::HasAirBrakes(int32 model) const
{
- return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS ||
- model == COACH;
+ return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH;
}
void
cAudioManager::Initialise()
{
- if(!m_bIsInitialised) {
+ if (!m_bIsInitialised) {
PreInitialiseGameSpecificSetup();
m_bIsInitialised = SampleManager.Initialise();
- if(m_bIsInitialised) {
- m_bActiveSamples = SampleManager.GetMaximumSupportedChannels();
- if(m_bActiveSamples <= 1) {
+ if (m_bIsInitialised) {
+ m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
+ if (m_nActiveSamples <= 1) {
Terminate();
} else {
- --m_bActiveSamples;
+ --m_nActiveSamples;
PostInitialiseGameSpecificSetup();
InitialisePoliceRadioZones();
InitialisePoliceRadio();
@@ -2963,7 +3233,7 @@ cAudioManager::Initialise()
void
cAudioManager::InterrogateAudioEntities()
{
- for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
+ for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
ProcessEntity(m_anAudioEntityIndices[i]);
m_asAudioEntities[m_anAudioEntityIndices[i]].m_AudioEvents = 0;
}
@@ -2978,7 +3248,8 @@ cAudioManager::IsAudioInitialised() const
bool
cAudioManager::IsMissionAudioSampleFinished()
{
- if(m_bIsInitialised) return m_sMissionAudio.m_bPlayStatus == PLAY_STATUS_FINISHED;
+ if (m_bIsInitialised)
+ return m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_FINISHED;
static int32 cPretendFrame = 1;
@@ -2988,7 +3259,8 @@ cAudioManager::IsMissionAudioSampleFinished()
bool
cAudioManager::IsMP3RadioChannelAvailable() const
{
- if(m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable();
+ if (m_bIsInitialised)
+ return SampleManager.IsMP3RadioChannelAvailable();
return false;
}
@@ -2996,7 +3268,7 @@ cAudioManager::IsMP3RadioChannelAvailable() const
bool
cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const
{
- switch(soundMission) {
+ switch (soundMission) {
case STREAMED_SOUND_MISSION_J6_D:
case STREAMED_SOUND_MISSION_T4_A:
case STREAMED_SOUND_MISSION_S1_H:
@@ -3008,17 +3280,18 @@ cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const
case STREAMED_SOUND_MISSION_R1_A:
case STREAMED_SOUND_MISSION_R5_A:
case STREAMED_SOUND_MISSION_LO2_A:
- case STREAMED_SOUND_MISSION_LO6_A: return true;
- default: return false;
+ case STREAMED_SOUND_MISSION_LO6_A:
+ return true;
+ default:
+ return false;
}
}
void
cAudioManager::PlayLoadedMissionAudio()
{
- if(m_bIsInitialised && m_sMissionAudio.m_nSampleIndex != NO_SAMPLE &&
- m_sMissionAudio.m_bLoadingStatus == LOADING_STATUS_LOADED &&
- !m_sMissionAudio.m_bPlayStatus) {
+ if (m_bIsInitialised && m_sMissionAudio.m_nSampleIndex != NO_SAMPLE && m_sMissionAudio.m_nLoadingStatus == LOADING_STATUS_LOADED &&
+ !m_sMissionAudio.m_nPlayStatus) {
m_sMissionAudio.m_bIsPlayed = true;
}
}
@@ -3026,61 +3299,45 @@ cAudioManager::PlayLoadedMissionAudio()
void
cAudioManager::PlayOneShot(int32 index, int16 sound, float vol)
{
- static const uint8 OneShotPriority[] = {
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 3, 5, 2, 2, 1, 1, 3, 1, 3, 3, 1, 1,
- 1, 4, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 3, 2, 2, 2, 2, 0, 0, 6,
- 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 3, 1, 1, 1, 9, 2, 2, 0, 0, 0, 0, 3, 3, 5, 1,
- 1, 1, 1, 3, 4, 7, 6, 6, 6, 6, 1, 3, 4, 3, 4, 2, 1, 3, 5, 4, 6, 6, 1, 3, 1, 1, 1, 0,
- 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ static const uint8 OneShotPriority[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 3, 5, 2, 2, 1, 1, 3, 1, 3, 3, 1, 1, 1, 4, 4, 3, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 3, 2, 2, 2, 2, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 3, 1, 1, 1, 9,
+ 2, 2, 0, 0, 0, 0, 3, 3, 5, 1, 1, 1, 1, 3, 4, 7, 6, 6, 6, 6, 1, 3, 4, 3, 4, 2, 1, 3, 5, 4, 6, 6, 1, 3,
+ 1, 1, 1, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- if(m_bIsInitialised) {
- if(index >= 0 && index < totalAudioEntitiesSlots) {
+ if (m_bIsInitialised) {
+ if (index >= 0 && index < totalAudioEntitiesSlots) {
tAudioEntity &entity = m_asAudioEntities[index];
- if(entity.m_bIsUsed) {
- if(sound < SOUND_TOTAL_SOUNDS) {
- if(entity.m_nType == AUDIOTYPE_SCRIPTOBJECT) {
- if(m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal <
- ARRAY_SIZE(m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices)) {
+ if (entity.m_bIsUsed) {
+ if (sound < SOUND_TOTAL_SOUNDS) {
+ if (entity.m_nType == AUDIOTYPE_SCRIPTOBJECT) {
+ if (m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal < ARRAY_SIZE(m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices)) {
entity.m_awAudioEvent[0] = sound;
entity.m_AudioEvents = 1;
- m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices
- [m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal++] = index;
+ m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal++] = index;
}
} else {
int32 i = 0;
- while(true) {
- if(i >= entity.m_AudioEvents) {
- if(entity.m_AudioEvents <
- ARRAY_SIZE(
- entity.m_awAudioEvent)) {
- entity.m_awAudioEvent[i] =
- sound;
+ while (true) {
+ if (i >= entity.m_AudioEvents) {
+ if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) {
+ entity.m_awAudioEvent[i] = sound;
entity.m_afVolume[i] = vol;
++entity.m_AudioEvents;
}
return;
}
- if(OneShotPriority[entity
- .m_awAudioEvent[i]] >
- OneShotPriority[sound])
+ if (OneShotPriority[entity.m_awAudioEvent[i]] > OneShotPriority[sound])
break;
++i;
}
- if(i < NUM_AUDIOENTITY_EVENTS - 1) {
- memmove(&entity.m_awAudioEvent[i + 1],
- &entity.m_awAudioEvent[i],
- (NUM_AUDIOENTITY_EVENTS - 1 - i) *
- NUM_AUDIOENTITY_EVENTS / 2);
- memmove(&entity.m_afVolume[i + 1],
- &entity.m_afVolume[i],
- (NUM_AUDIOENTITY_EVENTS - 1 - i) *
- NUM_AUDIOENTITY_EVENTS);
+ if (i < NUM_AUDIOENTITY_EVENTS - 1) {
+ memmove(&entity.m_awAudioEvent[i + 1], &entity.m_awAudioEvent[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * NUM_AUDIOENTITY_EVENTS / 2);
+ memmove(&entity.m_afVolume[i + 1], &entity.m_afVolume[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * NUM_AUDIOENTITY_EVENTS);
}
entity.m_awAudioEvent[i] = sound;
entity.m_afVolume[i] = vol;
- if(entity.m_AudioEvents <
- ARRAY_SIZE(entity.m_awAudioEvent))
+ if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent))
++entity.m_AudioEvents;
}
}
@@ -3092,7 +3349,9 @@ cAudioManager::PlayOneShot(int32 index, int16 sound, float vol)
void
cAudioManager::PlayerJustGotInCar() const
{
- if(m_bIsInitialised) { bPlayerJustEnteredCar = true; }
+ if (m_bIsInitialised) {
+ bPlayerJustEnteredCar = true;
+ }
}
void
@@ -3105,29 +3364,36 @@ void
cAudioManager::PostInitialiseGameSpecificSetup()
{
m_nFireAudioEntity = CreateEntity(AUDIOTYPE_FIRE, &gFireManager);
- if(m_nFireAudioEntity >= 0) SetEntityStatus(m_nFireAudioEntity, 1);
+ if (m_nFireAudioEntity >= 0)
+ SetEntityStatus(m_nFireAudioEntity, 1);
m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (void *)1);
- if(m_nCollisionEntity >= 0) SetEntityStatus(m_nCollisionEntity, 1);
+ if (m_nCollisionEntity >= 0)
+ SetEntityStatus(m_nCollisionEntity, 1);
m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (void *)1);
- if(m_nFrontEndEntity >= 0) SetEntityStatus(m_nFrontEndEntity, 1);
+ if (m_nFrontEndEntity >= 0)
+ SetEntityStatus(m_nFrontEndEntity, 1);
m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (void *)1);
- if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1);
+ if (m_nProjectileEntity >= 0)
+ SetEntityStatus(m_nProjectileEntity, 1);
m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (void *)1);
- if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1);
+ if (m_nWaterCannonEntity >= 0)
+ SetEntityStatus(m_nWaterCannonEntity, 1);
m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (void *)1);
- if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1);
+ if (m_nPoliceChannelEntity >= 0)
+ SetEntityStatus(m_nPoliceChannelEntity, 1);
m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (void *)1);
- if(m_nBridgeEntity >= 0) SetEntityStatus(m_nBridgeEntity, 1);
+ if (m_nBridgeEntity >= 0)
+ SetEntityStatus(m_nBridgeEntity, 1);
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
- m_sMissionAudio.m_bLoadingStatus = LOADING_STATUS_NOT_LOADED;
- m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_STOPPED;
+ m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED;
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED;
m_sMissionAudio.field_22 = 0;
m_sMissionAudio.m_bIsPlayed = false;
m_sMissionAudio.m_bPredefinedProperties = 1;
@@ -3154,63 +3420,46 @@ struct MissionAudioData {
};
const MissionAudioData MissionAudioNameSfxAssoc[] = {
- {"lib_a1", STREAMED_SOUND_MISSION_LIB_A1}, {"lib_a2", STREAMED_SOUND_MISSION_LIB_A2},
- {"lib_a", STREAMED_SOUND_MISSION_LIB_A}, {"lib_b", STREAMED_SOUND_MISSION_LIB_B},
- {"lib_c", STREAMED_SOUND_MISSION_LIB_C}, {"lib_d", STREAMED_SOUND_MISSION_LIB_D},
- {"l2_a", STREAMED_SOUND_MISSION_L2_A}, {"j4t_1", STREAMED_SOUND_MISSION_J4T_1},
- {"j4t_2", STREAMED_SOUND_MISSION_J4T_2}, {"j4t_3", STREAMED_SOUND_MISSION_J4T_3},
- {"j4t_4", STREAMED_SOUND_MISSION_J4T_4}, {"j4_a", STREAMED_SOUND_MISSION_J4_A},
- {"j4_b", STREAMED_SOUND_MISSION_J4_B}, {"j4_c", STREAMED_SOUND_MISSION_J4_C},
- {"j4_d", STREAMED_SOUND_MISSION_J4_D}, {"j4_e", STREAMED_SOUND_MISSION_J4_E},
- {"j4_f", STREAMED_SOUND_MISSION_J4_F}, {"j6_1", STREAMED_SOUND_MISSION_J6_1},
- {"j6_a", STREAMED_SOUND_MISSION_J6_A}, {"j6_b", STREAMED_SOUND_MISSION_J6_B},
- {"j6_c", STREAMED_SOUND_MISSION_J6_C}, {"j6_d", STREAMED_SOUND_MISSION_J6_D},
- {"t4_a", STREAMED_SOUND_MISSION_T4_A}, {"s1_a", STREAMED_SOUND_MISSION_S1_A},
- {"s1_a1", STREAMED_SOUND_MISSION_S1_A1}, {"s1_b", STREAMED_SOUND_MISSION_S1_B},
- {"s1_c", STREAMED_SOUND_MISSION_S1_C}, {"s1_c1", STREAMED_SOUND_MISSION_S1_C1},
- {"s1_d", STREAMED_SOUND_MISSION_S1_D}, {"s1_e", STREAMED_SOUND_MISSION_S1_E},
- {"s1_f", STREAMED_SOUND_MISSION_S1_F}, {"s1_g", STREAMED_SOUND_MISSION_S1_G},
- {"s1_h", STREAMED_SOUND_MISSION_S1_H}, {"s1_i", STREAMED_SOUND_MISSION_S1_I},
- {"s1_j", STREAMED_SOUND_MISSION_S1_J}, {"s1_k", STREAMED_SOUND_MISSION_S1_K},
- {"s1_l", STREAMED_SOUND_MISSION_S1_L}, {"s3_a", STREAMED_SOUND_MISSION_S3_A},
- {"s3_b", STREAMED_SOUND_MISSION_S3_B}, {"el3_a", STREAMED_SOUND_MISSION_EL3_A},
- {"mf1_a", STREAMED_SOUND_MISSION_MF1_A}, {"mf2_a", STREAMED_SOUND_MISSION_MF2_A},
- {"mf3_a", STREAMED_SOUND_MISSION_MF3_A}, {"mf3_b", STREAMED_SOUND_MISSION_MF3_B},
- {"mf3_b1", STREAMED_SOUND_MISSION_MF3_B1}, {"mf3_c", STREAMED_SOUND_MISSION_MF3_C},
- {"mf4_a", STREAMED_SOUND_MISSION_MF4_A}, {"mf4_b", STREAMED_SOUND_MISSION_MF4_B},
- {"mf4_c", STREAMED_SOUND_MISSION_MF4_C}, {"a1_a", STREAMED_SOUND_MISSION_A1_A},
- {"a3_a", STREAMED_SOUND_MISSION_A3_A}, {"a5_a", STREAMED_SOUND_MISSION_A5_A},
- {"a4_a", STREAMED_SOUND_MISSION_A4_A}, {"a4_b", STREAMED_SOUND_MISSION_A4_B},
- {"a4_c", STREAMED_SOUND_MISSION_A4_C}, {"a4_d", STREAMED_SOUND_MISSION_A4_D},
- {"k1_a", STREAMED_SOUND_MISSION_K1_A}, {"k3_a", STREAMED_SOUND_MISSION_K3_A},
- {"r1_a", STREAMED_SOUND_MISSION_R1_A}, {"r2_a", STREAMED_SOUND_MISSION_R2_A},
- {"r2_b", STREAMED_SOUND_MISSION_R2_B}, {"r2_c", STREAMED_SOUND_MISSION_R2_C},
- {"r2_d", STREAMED_SOUND_MISSION_R2_D}, {"r2_e", STREAMED_SOUND_MISSION_R2_E},
- {"r2_f", STREAMED_SOUND_MISSION_R2_F}, {"r2_g", STREAMED_SOUND_MISSION_R2_G},
- {"r2_h", STREAMED_SOUND_MISSION_R2_H}, {"r5_a", STREAMED_SOUND_MISSION_R5_A},
- {"r6_a", STREAMED_SOUND_MISSION_R6_A}, {"r6_a1", STREAMED_SOUND_MISSION_R6_A1},
- {"r6_b", STREAMED_SOUND_MISSION_R6_B}, {"lo2_a", STREAMED_SOUND_MISSION_LO2_A},
- {"lo6_a", STREAMED_SOUND_MISSION_LO6_A}, {"yd2_a", STREAMED_SOUND_MISSION_YD2_A},
- {"yd2_b", STREAMED_SOUND_MISSION_YD2_B}, {"yd2_c", STREAMED_SOUND_MISSION_YD2_C},
- {"yd2_c1", STREAMED_SOUND_MISSION_YD2_C1}, {"yd2_d", STREAMED_SOUND_MISSION_YD2_D},
- {"yd2_e", STREAMED_SOUND_MISSION_YD2_E}, {"yd2_f", STREAMED_SOUND_MISSION_YD2_F},
- {"yd2_g", STREAMED_SOUND_MISSION_YD2_G}, {"yd2_h", STREAMED_SOUND_MISSION_YD2_H},
- {"yd2_ass", STREAMED_SOUND_MISSION_YD2_ASS}, {"yd2_ok", STREAMED_SOUND_MISSION_YD2_OK},
- {"h5_a", STREAMED_SOUND_MISSION_H5_A}, {"h5_b", STREAMED_SOUND_MISSION_H5_B},
- {"h5_c", STREAMED_SOUND_MISSION_H5_C}, {"ammu_a", STREAMED_SOUND_MISSION_AMMU_A},
- {"ammu_b", STREAMED_SOUND_MISSION_AMMU_B}, {"ammu_c", STREAMED_SOUND_MISSION_AMMU_C},
- {"door_1", STREAMED_SOUND_MISSION_DOOR_1}, {"door_2", STREAMED_SOUND_MISSION_DOOR_2},
- {"door_3", STREAMED_SOUND_MISSION_DOOR_3}, {"door_4", STREAMED_SOUND_MISSION_DOOR_4},
- {"door_5", STREAMED_SOUND_MISSION_DOOR_5}, {"door_6", STREAMED_SOUND_MISSION_DOOR_6},
- {"t3_a", STREAMED_SOUND_MISSION_T3_A}, {"t3_b", STREAMED_SOUND_MISSION_T3_B},
- {"t3_c", STREAMED_SOUND_MISSION_T3_C}, {"k1_b", STREAMED_SOUND_MISSION_K1_B},
- {"c_1", STREAMED_SOUND_MISSION_CAT1}};
+ {"lib_a1", STREAMED_SOUND_MISSION_LIB_A1}, {"lib_a2", STREAMED_SOUND_MISSION_LIB_A2}, {"lib_a", STREAMED_SOUND_MISSION_LIB_A},
+ {"lib_b", STREAMED_SOUND_MISSION_LIB_B}, {"lib_c", STREAMED_SOUND_MISSION_LIB_C}, {"lib_d", STREAMED_SOUND_MISSION_LIB_D},
+ {"l2_a", STREAMED_SOUND_MISSION_L2_A}, {"j4t_1", STREAMED_SOUND_MISSION_J4T_1}, {"j4t_2", STREAMED_SOUND_MISSION_J4T_2},
+ {"j4t_3", STREAMED_SOUND_MISSION_J4T_3}, {"j4t_4", STREAMED_SOUND_MISSION_J4T_4}, {"j4_a", STREAMED_SOUND_MISSION_J4_A},
+ {"j4_b", STREAMED_SOUND_MISSION_J4_B}, {"j4_c", STREAMED_SOUND_MISSION_J4_C}, {"j4_d", STREAMED_SOUND_MISSION_J4_D},
+ {"j4_e", STREAMED_SOUND_MISSION_J4_E}, {"j4_f", STREAMED_SOUND_MISSION_J4_F}, {"j6_1", STREAMED_SOUND_MISSION_J6_1},
+ {"j6_a", STREAMED_SOUND_MISSION_J6_A}, {"j6_b", STREAMED_SOUND_MISSION_J6_B}, {"j6_c", STREAMED_SOUND_MISSION_J6_C},
+ {"j6_d", STREAMED_SOUND_MISSION_J6_D}, {"t4_a", STREAMED_SOUND_MISSION_T4_A}, {"s1_a", STREAMED_SOUND_MISSION_S1_A},
+ {"s1_a1", STREAMED_SOUND_MISSION_S1_A1}, {"s1_b", STREAMED_SOUND_MISSION_S1_B}, {"s1_c", STREAMED_SOUND_MISSION_S1_C},
+ {"s1_c1", STREAMED_SOUND_MISSION_S1_C1}, {"s1_d", STREAMED_SOUND_MISSION_S1_D}, {"s1_e", STREAMED_SOUND_MISSION_S1_E},
+ {"s1_f", STREAMED_SOUND_MISSION_S1_F}, {"s1_g", STREAMED_SOUND_MISSION_S1_G}, {"s1_h", STREAMED_SOUND_MISSION_S1_H},
+ {"s1_i", STREAMED_SOUND_MISSION_S1_I}, {"s1_j", STREAMED_SOUND_MISSION_S1_J}, {"s1_k", STREAMED_SOUND_MISSION_S1_K},
+ {"s1_l", STREAMED_SOUND_MISSION_S1_L}, {"s3_a", STREAMED_SOUND_MISSION_S3_A}, {"s3_b", STREAMED_SOUND_MISSION_S3_B},
+ {"el3_a", STREAMED_SOUND_MISSION_EL3_A}, {"mf1_a", STREAMED_SOUND_MISSION_MF1_A}, {"mf2_a", STREAMED_SOUND_MISSION_MF2_A},
+ {"mf3_a", STREAMED_SOUND_MISSION_MF3_A}, {"mf3_b", STREAMED_SOUND_MISSION_MF3_B}, {"mf3_b1", STREAMED_SOUND_MISSION_MF3_B1},
+ {"mf3_c", STREAMED_SOUND_MISSION_MF3_C}, {"mf4_a", STREAMED_SOUND_MISSION_MF4_A}, {"mf4_b", STREAMED_SOUND_MISSION_MF4_B},
+ {"mf4_c", STREAMED_SOUND_MISSION_MF4_C}, {"a1_a", STREAMED_SOUND_MISSION_A1_A}, {"a3_a", STREAMED_SOUND_MISSION_A3_A},
+ {"a5_a", STREAMED_SOUND_MISSION_A5_A}, {"a4_a", STREAMED_SOUND_MISSION_A4_A}, {"a4_b", STREAMED_SOUND_MISSION_A4_B},
+ {"a4_c", STREAMED_SOUND_MISSION_A4_C}, {"a4_d", STREAMED_SOUND_MISSION_A4_D}, {"k1_a", STREAMED_SOUND_MISSION_K1_A},
+ {"k3_a", STREAMED_SOUND_MISSION_K3_A}, {"r1_a", STREAMED_SOUND_MISSION_R1_A}, {"r2_a", STREAMED_SOUND_MISSION_R2_A},
+ {"r2_b", STREAMED_SOUND_MISSION_R2_B}, {"r2_c", STREAMED_SOUND_MISSION_R2_C}, {"r2_d", STREAMED_SOUND_MISSION_R2_D},
+ {"r2_e", STREAMED_SOUND_MISSION_R2_E}, {"r2_f", STREAMED_SOUND_MISSION_R2_F}, {"r2_g", STREAMED_SOUND_MISSION_R2_G},
+ {"r2_h", STREAMED_SOUND_MISSION_R2_H}, {"r5_a", STREAMED_SOUND_MISSION_R5_A}, {"r6_a", STREAMED_SOUND_MISSION_R6_A},
+ {"r6_a1", STREAMED_SOUND_MISSION_R6_A1}, {"r6_b", STREAMED_SOUND_MISSION_R6_B}, {"lo2_a", STREAMED_SOUND_MISSION_LO2_A},
+ {"lo6_a", STREAMED_SOUND_MISSION_LO6_A}, {"yd2_a", STREAMED_SOUND_MISSION_YD2_A}, {"yd2_b", STREAMED_SOUND_MISSION_YD2_B},
+ {"yd2_c", STREAMED_SOUND_MISSION_YD2_C}, {"yd2_c1", STREAMED_SOUND_MISSION_YD2_C1}, {"yd2_d", STREAMED_SOUND_MISSION_YD2_D},
+ {"yd2_e", STREAMED_SOUND_MISSION_YD2_E}, {"yd2_f", STREAMED_SOUND_MISSION_YD2_F}, {"yd2_g", STREAMED_SOUND_MISSION_YD2_G},
+ {"yd2_h", STREAMED_SOUND_MISSION_YD2_H}, {"yd2_ass", STREAMED_SOUND_MISSION_YD2_ASS}, {"yd2_ok", STREAMED_SOUND_MISSION_YD2_OK},
+ {"h5_a", STREAMED_SOUND_MISSION_H5_A}, {"h5_b", STREAMED_SOUND_MISSION_H5_B}, {"h5_c", STREAMED_SOUND_MISSION_H5_C},
+ {"ammu_a", STREAMED_SOUND_MISSION_AMMU_A}, {"ammu_b", STREAMED_SOUND_MISSION_AMMU_B}, {"ammu_c", STREAMED_SOUND_MISSION_AMMU_C},
+ {"door_1", STREAMED_SOUND_MISSION_DOOR_1}, {"door_2", STREAMED_SOUND_MISSION_DOOR_2}, {"door_3", STREAMED_SOUND_MISSION_DOOR_3},
+ {"door_4", STREAMED_SOUND_MISSION_DOOR_4}, {"door_5", STREAMED_SOUND_MISSION_DOOR_5}, {"door_6", STREAMED_SOUND_MISSION_DOOR_6},
+ {"t3_a", STREAMED_SOUND_MISSION_T3_A}, {"t3_b", STREAMED_SOUND_MISSION_T3_B}, {"t3_c", STREAMED_SOUND_MISSION_T3_C},
+ {"k1_b", STREAMED_SOUND_MISSION_K1_B}, {"c_1", STREAMED_SOUND_MISSION_CAT1}};
int32
FindMissionAudioSfx(const char *name)
{
- for(uint32 i = 0; i < ARRAY_SIZE(MissionAudioNameSfxAssoc); ++i) {
- if(!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name))
+ for (uint32 i = 0; i < ARRAY_SIZE(MissionAudioNameSfxAssoc); ++i) {
+ if (!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name))
return MissionAudioNameSfxAssoc[i].m_nId;
}
debug("Can't find mission audio %s", name);
@@ -3220,16 +3469,14 @@ FindMissionAudioSfx(const char *name)
void
cAudioManager::PreloadMissionAudio(const char *name)
{
- if(m_bIsInitialised) {
+ if (m_bIsInitialised) {
int32 missionAudioSfx = FindMissionAudioSfx(name);
- if(missionAudioSfx != NO_SAMPLE) {
+ if (missionAudioSfx != NO_SAMPLE) {
m_sMissionAudio.m_nSampleIndex = missionAudioSfx;
- m_sMissionAudio.m_bLoadingStatus = LOADING_STATUS_NOT_LOADED;
- m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_STOPPED;
+ m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED;
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED;
m_sMissionAudio.field_22 = 0;
- m_sMissionAudio.m_nMissionAudioCounter =
- m_bTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) /
- 1000;
+ m_sMissionAudio.m_nMissionAudioCounter = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000;
m_sMissionAudio.m_nMissionAudioCounter *= 4;
m_sMissionAudio.m_bIsPlayed = false;
m_sMissionAudio.m_bPredefinedProperties = 1;
@@ -3240,31 +3487,31 @@ cAudioManager::PreloadMissionAudio(const char *name)
void
cAudioManager::PreTerminateGameSpecificShutdown()
{
- if(m_nBridgeEntity >= 0) {
+ if (m_nBridgeEntity >= 0) {
DestroyEntity(m_nBridgeEntity);
m_nBridgeEntity = AEHANDLE_NONE;
}
- if(m_nPoliceChannelEntity >= 0) {
+ if (m_nPoliceChannelEntity >= 0) {
DestroyEntity(m_nPoliceChannelEntity);
m_nPoliceChannelEntity = AEHANDLE_NONE;
}
- if(m_nWaterCannonEntity >= 0) {
+ if (m_nWaterCannonEntity >= 0) {
DestroyEntity(m_nWaterCannonEntity);
m_nWaterCannonEntity = AEHANDLE_NONE;
}
- if(m_nFireAudioEntity >= 0) {
+ if (m_nFireAudioEntity >= 0) {
DestroyEntity(m_nFireAudioEntity);
m_nFireAudioEntity = AEHANDLE_NONE;
}
- if(m_nCollisionEntity >= 0) {
+ if (m_nCollisionEntity >= 0) {
DestroyEntity(m_nCollisionEntity);
m_nCollisionEntity = AEHANDLE_NONE;
}
- if(m_nFrontEndEntity >= 0) {
+ if (m_nFrontEndEntity >= 0) {
DestroyEntity(m_nFrontEndEntity);
m_nFrontEndEntity = AEHANDLE_NONE;
}
- if(m_nProjectileEntity >= 0) {
+ if (m_nProjectileEntity >= 0) {
DestroyEntity(m_nProjectileEntity);
m_nProjectileEntity = AEHANDLE_NONE;
}
@@ -3289,227 +3536,145 @@ cAudioManager::ProcessActiveQueues()
uint8 emittingVol;
CVector position;
- for(int32 i = 0; i < m_bActiveSamples; i++) {
- m_asSamples[m_bActiveSampleQueue][i].m_bIsProcessed = false;
+ for (int32 i = 0; i < m_nActiveSamples; i++) {
+ m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = false;
m_asActiveSamples[i].m_bIsProcessed = false;
}
- for(int32 i = 0; i < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; ++i) {
- tSound &sample = m_asSamples[m_bActiveSampleQueue]
- [m_abSampleQueueIndexTable[m_bActiveSampleQueue][i]];
- if(sample.m_nSampleIndex != NO_SAMPLE) {
- for(int32 j = 0; j < m_bActiveSamples; ++j) {
- if(sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex &&
- sample.m_nCounter == m_asActiveSamples[j].m_nCounter &&
- sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) {
- if(sample.m_nLoopCount) {
- if(m_FrameCounter & 1) {
+ for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; ++i) {
+ tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
+ if (sample.m_nSampleIndex != NO_SAMPLE) {
+ for (int32 j = 0; j < m_nActiveSamples; ++j) {
+ if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && sample.m_nCounter == m_asActiveSamples[j].m_nCounter &&
+ sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) {
+ if (sample.m_nLoopCount) {
+ if (m_FrameCounter & 1) {
flag = !!(j & 1);
} else {
flag = !(j & 1);
}
- if(flag && !SampleManager.GetChannelUsedFlag(j)) {
+ if (flag && !SampleManager.GetChannelUsedFlag(j)) {
sample.m_bLoopEnded = true;
m_asActiveSamples[j].m_bLoopEnded = true;
- m_asActiveSamples[j].m_nSampleIndex =
- NO_SAMPLE;
- m_asActiveSamples[j].m_nEntityIndex =
- AEHANDLE_NONE;
+ m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE;
+ m_asActiveSamples[j].m_nEntityIndex = AEHANDLE_NONE;
continue;
}
}
sample.m_bIsProcessed = true;
m_asActiveSamples[j].m_bIsProcessed = true;
sample.m_nVolumeChange = -1;
- if(!sample.m_bReleasingSoundFlag) {
- if(sample.m_bIs2D) {
- if(field_4) {
- emittingVol =
- 2 *
- Min(63,
- sample.m_bEmittingVolume);
+ if (!sample.m_bReleasingSoundFlag) {
+ if (sample.m_bIs2D) {
+ if (field_4) {
+ emittingVol = 2 * Min(63, sample.m_nEmittingVolume);
} else {
- emittingVol =
- sample.m_bEmittingVolume;
+ emittingVol = sample.m_nEmittingVolume;
}
- SampleManager.SetChannelFrequency(
- j, sample.m_nFrequency);
- SampleManager.SetChannelEmittingVolume(
- j, emittingVol);
+ SampleManager.SetChannelFrequency(j, sample.m_nFrequency);
+ SampleManager.SetChannelEmittingVolume(j, emittingVol);
} else {
- m_asActiveSamples[j].m_fDistance =
- sample.m_fDistance;
+ m_asActiveSamples[j].m_fDistance = sample.m_fDistance;
position2 = sample.m_fDistance;
- position1 =
- m_asActiveSamples[j].m_fDistance;
- sample.m_nFrequency =
- ComputeDopplerEffectedFrequency(
- sample.m_nFrequency, position1,
- position2,
- sample.m_fSpeedMultiplier);
- if(sample.m_nFrequency !=
- m_asActiveSamples[j].m_nFrequency) {
+ position1 = m_asActiveSamples[j].m_fDistance;
+ sample.m_nFrequency = ComputeDopplerEffectedFrequency(sample.m_nFrequency, position1, position2, sample.m_fSpeedMultiplier);
+ if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) {
int32 freq;
- if(sample.m_nFrequency <=
- m_asActiveSamples[j]
- .m_nFrequency) {
- freq = Max(
- sample.m_nFrequency,
- m_asActiveSamples[j]
- .m_nFrequency -
- 6000);
+ if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) {
+ freq = Max(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency - 6000);
} else {
- freq = Min(
- sample.m_nFrequency,
- m_asActiveSamples[j]
- .m_nFrequency +
- 6000);
+ freq = Min(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency + 6000);
}
- m_asActiveSamples[j].m_nFrequency =
- freq;
- SampleManager.SetChannelFrequency(
- j, freq);
+ m_asActiveSamples[j].m_nFrequency = freq;
+ SampleManager.SetChannelFrequency(j, freq);
}
- if(sample.m_bEmittingVolume !=
- m_asActiveSamples[j].m_bEmittingVolume) {
- if(sample.m_bEmittingVolume <=
- m_asActiveSamples[j]
- .m_bEmittingVolume) {
- vol = Max(
- m_asActiveSamples[j]
- .m_bEmittingVolume -
- 10,
- sample
- .m_bEmittingVolume);
+ if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
+ if (sample.m_nEmittingVolume <= m_asActiveSamples[j].m_nEmittingVolume) {
+ vol = Max(m_asActiveSamples[j].m_nEmittingVolume - 10, sample.m_nEmittingVolume);
} else {
- vol = Min(
- m_asActiveSamples[j]
- .m_bEmittingVolume +
- 10,
- sample
- .m_bEmittingVolume);
+ vol = Min(m_asActiveSamples[j].m_nEmittingVolume + 10, sample.m_nEmittingVolume);
}
uint8 emittingVol;
- if(field_4) {
- emittingVol =
- 2 * Min(63, vol);
+ if (field_4) {
+ emittingVol = 2 * Min(63, vol);
} else {
emittingVol = vol;
}
- SampleManager
- .SetChannelEmittingVolume(
- j, emittingVol);
- m_asActiveSamples[j]
- .m_bEmittingVolume = vol;
+ SampleManager.SetChannelEmittingVolume(j, emittingVol);
+ m_asActiveSamples[j].m_nEmittingVolume = vol;
}
- TranslateEntity(&sample.m_vecPos,
- &position);
- SampleManager.SetChannel3DPosition(
- j, position.x, position.y, position.z);
- SampleManager.SetChannel3DDistances(
- j, sample.m_fSoundIntensity,
- 0.25f * sample.m_fSoundIntensity);
+ TranslateEntity(&sample.m_vecPos, &position);
+ SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z);
+ SampleManager.SetChannel3DDistances(j, sample.m_fSoundIntensity, 0.25f * sample.m_fSoundIntensity);
}
- SampleManager.SetChannelReverbFlag(
- j, sample.m_bReverbFlag);
- continue;
+ SampleManager.SetChannelReverbFlag(j, sample.m_bReverbFlag);
+ break;
}
sample.m_bIsProcessed = false;
m_asActiveSamples[j].m_bIsProcessed = false;
- break;
}
}
}
}
- for(int32 i = 0; i < m_bActiveSamples; i++) {
- if(m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE &&
- !m_asActiveSamples[i].m_bIsProcessed) {
+ for (int32 i = 0; i < m_nActiveSamples; i++) {
+ if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsProcessed) {
SampleManager.StopChannel(i);
m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE;
m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE;
}
}
- for(int32 i = 0; i < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; ++i) {
- tSound &sample = m_asSamples[m_bActiveSampleQueue]
- [m_abSampleQueueIndexTable[m_bActiveSampleQueue][i]];
- if(!sample.m_bIsProcessed && !sample.m_bLoopEnded &&
- m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed &&
- sample.m_nSampleIndex < NO_SAMPLE) {
- if(sample.m_nCounter > 255 && sample.m_nLoopCount &&
- sample.m_bLoopsRemaining) {
- --sample.m_bLoopsRemaining;
+ for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; ++i) {
+ tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
+ if (!sample.m_bIsProcessed && !sample.m_bLoopEnded && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) {
+ if (sample.m_nCounter > 255 && sample.m_nLoopCount && sample.m_nLoopsRemaining) {
+ --sample.m_nLoopsRemaining;
sample.m_nReleasingVolumeDivider = 1;
} else {
- for(int32 j = 0; j < m_bActiveSamples; ++j) {
- if(!m_asActiveSamples[j].m_bIsProcessed) {
- if(sample.m_nLoopCount) {
- v28 = sample.m_nFrequency / m_bTimeSpent;
- v29 = sample.m_nLoopCount *
- SampleManager.GetSampleLength(
- sample.m_nSampleIndex);
- if(v28 == 0) continue;
- sample.m_nReleasingVolumeDivider =
- v29 / v28 + 1;
+ for (uint8 j = 0; j < m_nActiveSamples; ++j) {
+ if (!m_asActiveSamples[j].m_bIsProcessed) {
+ if (sample.m_nLoopCount) {
+ v28 = sample.m_nFrequency / m_nTimeSpent;
+ v29 = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex);
+ if (v28 == 0)
+ continue;
+ sample.m_nReleasingVolumeDivider = v29 / v28 + 1;
}
- memcpy(&m_asActiveSamples[j], &sample,
- sizeof(tSound));
- if(!m_asActiveSamples[j].m_bIs2D)
- TranslateEntity(
- &m_asActiveSamples[j].m_vecPos,
- &position);
- if(field_4) {
- emittingVol =
- 2 * Min(63, m_asActiveSamples[j]
- .m_bEmittingVolume);
+ memcpy(&m_asActiveSamples[j], &sample, sizeof(tSound));
+ if (!m_asActiveSamples[j].m_bIs2D)
+ TranslateEntity(&m_asActiveSamples[j].m_vecPos, &position);
+ if (field_4) {
+ emittingVol = 2 * Min(63, m_asActiveSamples[j].m_nEmittingVolume);
} else {
- emittingVol =
- m_asActiveSamples[j].m_bEmittingVolume;
+ emittingVol = m_asActiveSamples[j].m_nEmittingVolume;
}
- if(SampleManager.InitialiseChannel(
- j, m_asActiveSamples[j].m_nSampleIndex,
- m_asActiveSamples[j].m_bBankIndex)) {
- SampleManager.SetChannelFrequency(
- j, m_asActiveSamples[j].m_nFrequency);
- SampleManager.SetChannelEmittingVolume(
- j, emittingVol);
- SampleManager.SetChannelLoopPoints(
- j, m_asActiveSamples[j].m_nLoopStart,
- m_asActiveSamples[j].m_nLoopEnd);
- SampleManager.SetChannelLoopCount(
- j, m_asActiveSamples[j].m_nLoopCount);
- SampleManager.SetChannelReverbFlag(
- j, m_asActiveSamples[j].m_bReverbFlag);
- if(m_asActiveSamples[j].m_bIs2D) {
- uint8 offset =
- m_asActiveSamples[j].m_bOffset;
- if(offset == 63) {
+ if (SampleManager.InitialiseChannel(j, m_asActiveSamples[j].m_nSampleIndex, m_asActiveSamples[j].m_nBankIndex)) {
+ SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency);
+ SampleManager.SetChannelEmittingVolume(j, emittingVol);
+ SampleManager.SetChannelLoopPoints(j, m_asActiveSamples[j].m_nLoopStart, m_asActiveSamples[j].m_nLoopEnd);
+ SampleManager.SetChannelLoopCount(j, m_asActiveSamples[j].m_nLoopCount);
+ SampleManager.SetChannelReverbFlag(j, m_asActiveSamples[j].m_bReverbFlag);
+ if (m_asActiveSamples[j].m_bIs2D) {
+ uint8 offset = m_asActiveSamples[j].m_nOffset;
+ if (offset == 63) {
x = 0.f;
- } else if(offset >= 63) {
- x = (offset - 63) * 1000.f /
- 63;
+ } else if (offset >= 63) {
+ x = (offset - 63) * 1000.f / 63;
} else {
- x = -(63 - offset) *
- 1000.f / 63;
+ x = -(63 - offset) * 1000.f / 63;
}
usedX = x;
usedY = 0.f;
usedZ = 0.f;
- m_asActiveSamples[j]
- .m_fSoundIntensity = 100000.0f;
+ m_asActiveSamples[j].m_fSoundIntensity = 100000.0f;
} else {
usedX = position.x;
usedY = position.y;
usedZ = position.z;
}
- SampleManager.SetChannel3DPosition(
- j, usedX, usedY, usedZ);
- SampleManager.SetChannel3DDistances(
- j,
- m_asActiveSamples[j].m_fSoundIntensity,
- 0.25f * m_asActiveSamples[j]
- .m_fSoundIntensity);
+ SampleManager.SetChannel3DPosition(j, usedX, usedY, usedZ);
+ SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_fSoundIntensity, 0.25f * m_asActiveSamples[j].m_fSoundIntensity);
SampleManager.StartChannel(j);
}
m_asActiveSamples[j].m_bIsProcessed = true;
@@ -3529,28 +3694,29 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params)
CAutomobile *automobile;
uint8 rand;
- if(params->m_fDistance > 900.0f) return false;
+ if (params->m_fDistance > 900.0f)
+ return false;
automobile = (CAutomobile *)params->m_pVehicle;
- if(!automobile->bEngineOn) return true;
+ if (!automobile->bEngineOn)
+ return true;
- if((automobile->m_fVelocityChangeForAudio < 0.025f ||
- params->m_fVelocityChange >= 0.025f) &&
- (automobile->m_fVelocityChangeForAudio > -0.025f || params->m_fVelocityChange <= 0.025f))
+ if ((automobile->m_fVelocityChangeForAudio < 0.025f || params->m_fVelocityChange >= 0.025f) &&
+ (automobile->m_fVelocityChangeForAudio > -0.025f || params->m_fVelocityChange <= 0.025f))
return true;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
rand = m_anRandomTable[0] % 10 + 70;
- m_sQueueSample.m_bVolume = ComputeVolume(rand, 30.0f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(rand, 30.0f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 13;
m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AIR_BRAKES);
- m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4);
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 10;
m_sQueueSample.m_nLoopCount = 1;
- m_sQueueSample.m_bEmittingVolume = rand;
+ m_sQueueSample.m_nEmittingVolume = rand;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
@@ -3570,34 +3736,32 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound)
static uint8 counter = 0;
uint32 time = CTimer::GetTimeInMilliseconds();
- if(time > gAirportNextTime) {
- switch(sound) {
+ if (time > gAirportNextTime) {
+ switch (sound) {
case SCRIPT_SOUND_AIRPORT_LOOP_S:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_AIRPORT_LOOP_L:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
- default: return;
+ default:
+ return;
}
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume = ComputeVolume(
- 110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- m_sQueueSample.m_nSampleIndex =
- (m_anRandomTable[1] & 3) + SFX_AIRPORT_ANNOUNCEMENT_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
+ m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_AIRPORT_ANNOUNCEMENT_1;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nCounter = counter++;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = 110;
+ m_sQueueSample.m_nEmittingVolume = 110;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -3624,28 +3788,23 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
static const int intensity = 50;
- if(params->m_fDistance < SQR(intensity)) {
+ if (params->m_fDistance < SQR(intensity)) {
boat = (CBoat *)params->m_pVehicle;
- if(params->m_nIndex == REEFER) {
+ if (params->m_nIndex == REEFER) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume =
- ComputeVolume(80, 50.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(80, 50.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 39;
m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE;
m_sQueueSample.m_nFrequency = 10386;
- m_sQueueSample.m_nFrequency +=
- (m_sQueueSample.m_nEntityIndex << 16) % 1000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 80;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 80;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -3654,45 +3813,41 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
- if(FindPlayerVehicle() == params->m_pVehicle) {
- if(Pads[0].GetAccelerate() <= Pads[0].GetBrake())
+ if (FindPlayerVehicle() == params->m_pVehicle) {
+ if (Pads[0].GetAccelerate() <= Pads[0].GetBrake())
padAccelerate = Pads[0].GetBrake();
else
padAccelerate = Pads[0].GetAccelerate();
padRelativeAccerate = padAccelerate / 255;
emittingVol = (100.f * padRelativeAccerate) + 15;
m_sQueueSample.m_nFrequency = (3000.f * padRelativeAccerate) + 6000;
- if(!boat->m_bIsAnchored)
- m_sQueueSample.m_nFrequency =
- 11 * m_sQueueSample.m_nFrequency / 10;
+ if (!boat->m_bIsAnchored)
+ m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10;
} else {
gasPedal = Abs(boat->m_fGasPedal);
- if(gasPedal > 0.0f) {
+ if (gasPedal > 0.0f) {
m_sQueueSample.m_nFrequency = 6000;
emittingVol = 15;
} else {
emittingVol = (100.f * gasPedal) + 15;
m_sQueueSample.m_nFrequency = (3000.f * gasPedal) + 6000;
- if(!boat->m_bIsAnchored)
- m_sQueueSample.m_nFrequency =
- 11 * m_sQueueSample.m_nFrequency / 10;
+ if (!boat->m_bIsAnchored)
+ m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10;
}
}
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance);
- if(!m_sQueueSample.m_bVolume) return true;
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance);
+ if (!m_sQueueSample.m_nVolume)
+ return true;
m_sQueueSample.m_nCounter = 40;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL;
- m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -3700,28 +3855,25 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
} else {
- if(FindPlayerVehicle() == params->m_pVehicle) {
- if(Pads[0].GetAccelerate() <= Pads[0].GetBrake())
+ if (FindPlayerVehicle() == params->m_pVehicle) {
+ if (Pads[0].GetAccelerate() <= Pads[0].GetBrake())
padAccelerate = Pads[0].GetBrake();
else
padAccelerate = Pads[0].GetAccelerate();
- if(padAccelerate <= 20) {
+ if (padAccelerate <= 20) {
emittingVol = 45 - 45 * padAccelerate / 40;
m_sQueueSample.m_nFrequency = 100 * padAccelerate + 11025;
m_sQueueSample.m_nCounter = 39;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_IDLE;
- if(LastAccel > 20) {
+ if (LastAccel > 20) {
oneShotVol = LastVol;
- PlayOneShot(m_sQueueSample.m_nEntityIndex, SOUND_17,
- oneShotVol);
+ PlayOneShot(m_sQueueSample.m_nEntityIndex, SOUND_17, oneShotVol);
}
} else {
emittingVol = 105 * padAccelerate / 255 + 15;
- m_sQueueSample.m_nFrequency =
- 4000 * padAccelerate / 255 + 8000;
- if(!boat->m_bIsAnchored)
- m_sQueueSample.m_nFrequency =
- 11 * m_sQueueSample.m_nFrequency / 10;
+ m_sQueueSample.m_nFrequency = 4000 * padAccelerate / 255 + 8000;
+ if (!boat->m_bIsAnchored)
+ m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10;
m_sQueueSample.m_nCounter = 40;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL;
}
@@ -3729,7 +3881,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
LastAccel = padAccelerate;
} else {
gasPedal = Abs(boat->m_fGasPedal);
- if(gasPedal > 0.0f) {
+ if (gasPedal > 0.0f) {
m_sQueueSample.m_nFrequency = 11025;
emittingVol = 45;
m_sQueueSample.m_nCounter = 39;
@@ -3737,27 +3889,24 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params)
} else {
emittingVol = (105.f * gasPedal) + 15;
m_sQueueSample.m_nFrequency = (4000.f * gasPedal) + 8000;
- if(!boat->m_bIsAnchored)
- m_sQueueSample.m_nFrequency =
- 11 * m_sQueueSample.m_nFrequency / 10;
+ if (!boat->m_bIsAnchored)
+ m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10;
m_sQueueSample.m_nCounter = 40;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL;
}
}
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance);
- if(!m_sQueueSample.m_bVolume) return true;
- m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance);
+ if (!m_sQueueSample.m_nVolume)
+ return true;
+ m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -3778,29 +3927,29 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params)
int32 vol;
float multiplier;
- if(params->m_fDistance > 2500.f) return false;
+ if (params->m_fDistance > 2500.f)
+ return false;
velocityChange = Abs(params->m_fVelocityChange);
- if(velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) return true;
+ if (velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y)
+ return true;
velocityChange = Min(0.75f, velocityChange);
multiplier = (velocityChange - 0.0005f) * 1.3342f;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
vol = (30.f * multiplier);
- m_sQueueSample.m_bVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 38;
m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nFrequency = (6050.f * multiplier) + 16000;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = vol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = vol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -3819,21 +3968,24 @@ cAudioManager::ProcessBridge()
float dist;
bool distCalculated = false;
- if(CBridge::pLiftRoad) {
+ if (CBridge::pLiftRoad) {
m_sQueueSample.m_vecPos = CBridge::pLiftRoad->GetPosition();
- dist = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(dist < 202500.0f) {
+ dist = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (dist < 202500.0f) {
CalculateDistance(distCalculated, dist);
- switch(CBridge::State) {
+ switch (CBridge::State) {
case STATE_BRIDGE_LOCKED:
case STATE_LIFT_PART_IS_UP:
- case STATE_LIFT_PART_ABOUT_TO_MOVE_UP: ProcessBridgeWarning(); break;
+ case STATE_LIFT_PART_ABOUT_TO_MOVE_UP:
+ ProcessBridgeWarning();
+ break;
case STATE_LIFT_PART_MOVING_DOWN:
case STATE_LIFT_PART_MOVING_UP:
ProcessBridgeWarning();
ProcessBridgeMotor();
break;
- default: break;
+ default:
+ break;
}
ProcessBridgeOneShots();
}
@@ -3843,23 +3995,19 @@ cAudioManager::ProcessBridge()
void
cAudioManager::ProcessBridgeMotor()
{
- if(m_sQueueSample.m_fDistance < bridgeIntensity) {
- m_sQueueSample.m_bVolume =
- ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (m_sQueueSample.m_fDistance < bridgeIntensity) {
+ m_sQueueSample.m_nVolume = ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 1;
- m_sQueueSample.m_nSampleIndex =
- SFX_FISHING_BOAT_IDLE; // todo check sfx name
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; // todo check sfx name
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_nFrequency = 5500;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = maxVolume;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = maxVolume;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = bridgeIntensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -3873,34 +4021,32 @@ cAudioManager::ProcessBridgeMotor()
void
cAudioManager::ProcessBridgeOneShots()
{
- if(CBridge::State == STATE_LIFT_PART_IS_UP && CBridge::OldState == STATE_LIFT_PART_MOVING_UP) {
+ if (CBridge::State == STATE_LIFT_PART_IS_UP && CBridge::OldState == STATE_LIFT_PART_MOVING_UP) {
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else {
- if(CBridge::State == STATE_LIFT_PART_IS_DOWN && CBridge::OldState == STATE_LIFT_PART_MOVING_DOWN) {
+ if (CBridge::State == STATE_LIFT_PART_IS_DOWN && CBridge::OldState == STATE_LIFT_PART_MOVING_DOWN) {
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else {
- if(CBridge::State == STATE_LIFT_PART_MOVING_UP && CBridge::OldState == STATE_LIFT_PART_ABOUT_TO_MOVE_UP) {
+ if (CBridge::State == STATE_LIFT_PART_MOVING_UP && CBridge::OldState == STATE_LIFT_PART_ABOUT_TO_MOVE_UP) {
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else {
- if(CBridge::State == STATE_LIFT_PART_MOVING_DOWN && CBridge::OldState == STATE_LIFT_PART_IS_UP) {
+ if (CBridge::State == STATE_LIFT_PART_MOVING_DOWN && CBridge::OldState == STATE_LIFT_PART_IS_UP) {
m_sQueueSample.m_nSampleIndex = SFX_COL_CONTAINER_1;
} else
return;
}
}
}
- if(m_sQueueSample.m_fDistance < bridgeIntensity) {
- m_sQueueSample.m_bVolume =
- ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (m_sQueueSample.m_fDistance < bridgeIntensity) {
+ m_sQueueSample.m_nVolume = ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopCount = 1;
- m_sQueueSample.m_bEmittingVolume = maxVolume;
+ m_sQueueSample.m_nEmittingVolume = maxVolume;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -3916,22 +4062,19 @@ cAudioManager::ProcessBridgeOneShots()
void
cAudioManager::ProcessBridgeWarning()
{
- if(CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) {
- m_sQueueSample.m_bVolume = ComputeVolume(100, 450.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) {
+ m_sQueueSample.m_nVolume = ComputeVolume(100, 450.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_nSampleIndex = SFX_BRIDGE_OPEN_WARNING;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_BRIDGE_OPEN_WARNING);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BRIDGE_OPEN_WARNING);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 100;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 100;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = 450.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -3948,25 +4091,23 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params)
{
CAutomobile *automobile;
- if(params->m_fDistance >= SQR(40.f)) return false;
+ if (params->m_fDistance >= SQR(40.f))
+ return false;
automobile = (CAutomobile *)params->m_pVehicle;
- if(automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) {
+ if (automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(60, 40.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(60, 40.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 35;
m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 60;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 60;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = 40.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -3986,37 +4127,34 @@ cAudioManager::ProcessCesna(cVehicleParams *params)
//((CAutomobile *)params->m_pVehicle)->Damage.GetEngineStatus();
- if(FindPlayerVehicle() == params->m_pVehicle) {
- if(params->m_nIndex == DODO) {
- if(Pads[0].GetAccelerate() <= 0) {
- if(nAccel) --nAccel;
- } else if(nAccel < 60) {
+ if (FindPlayerVehicle() == params->m_pVehicle) {
+ if (params->m_nIndex == DODO) {
+ if (Pads[0].GetAccelerate() <= 0) {
+ if (nAccel)
+ --nAccel;
+ } else if (nAccel < 60) {
++nAccel;
}
- AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000,
- SFX_CESNA_IDLE, 0, 52, 1);
- AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000,
- SFX_CESNA_REV, 0, 2, 1);
+ AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, 0, 52, 1);
+ AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, 0, 2, 1);
}
- } else if(params->m_nIndex == DODO) {
+ } else if (params->m_nIndex == DODO) {
AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, 0, 52, 1);
- } else if(params->m_fDistance < 40000.f) {
+ } else if (params->m_fDistance < 40000.f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(80, 200.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(80, 200.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 52;
m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
m_sQueueSample.m_nFrequency = 12500;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nReleasingVolumeDivider = 8;
- m_sQueueSample.m_bEmittingVolume = 80;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 80;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 8.0f;
m_sQueueSample.m_fSoundIntensity = 200.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -4024,24 +4162,20 @@ cAudioManager::ProcessCesna(cVehicleParams *params)
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
- if(params->m_fDistance < 8100.f) {
- m_sQueueSample.m_bVolume =
- ComputeVolume(80, 90.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (params->m_fDistance < 8100.f) {
+ m_sQueueSample.m_nVolume = ComputeVolume(80, 90.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 2;
m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
m_sQueueSample.m_nFrequency = 25000;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
- m_sQueueSample.m_bEmittingVolume = 80;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 80;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 8.0f;
m_sQueueSample.m_fSoundIntensity = 90.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -4061,36 +4195,34 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound)
static uint8 counter = 0;
uint32 time = CTimer::GetTimeInMilliseconds();
- if(time > gCinemaNextTime) {
- switch(sound) {
+ if (time > gCinemaNextTime) {
+ switch (sound) {
case SCRIPT_SOUND_CINEMA_LOOP_S:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_CINEMA_LOOP_L:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
- default: return;
+ default:
+ return;
}
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
rand = m_anRandomTable[0] % 90 + 30;
- m_sQueueSample.m_bVolume = ComputeVolume(
- rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = counter % 3 + SFX_CINEMA_BASS_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency / 4);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 4);
m_sQueueSample.m_nCounter = counter++;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = rand;
+ m_sQueueSample.m_nEmittingVolume = rand;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -4110,30 +4242,25 @@ cAudioManager::ProcessCrane()
bool distCalculated = false;
static const int intensity = 80;
- if(crane) {
- if(crane->m_nCraneStatus == CCrane::ACTIVATED) {
- if(crane->m_nCraneState != CCrane::IDLE) {
+ if (crane) {
+ if (crane->m_nCraneStatus == CCrane::ACTIVATED) {
+ if (crane->m_nCraneState != CCrane::IDLE) {
m_sQueueSample.m_vecPos = crane->m_pCraneEntity->GetPosition();
- distSquared = GetDistanceSquared(&this->m_sQueueSample.m_vecPos);
- if(distSquared < SQR(intensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(intensity)) {
CalculateDistance(distCalculated, distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_nFrequency = 6000;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 100;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 100;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -4142,13 +4269,10 @@ cAudioManager::ProcessCrane()
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
- if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex]
- .m_AudioEvents) {
+ if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents) {
m_sQueueSample.m_nCounter = 1;
m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_2;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(
- SFX_COL_CAR_2);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COL_CAR_2);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bReverbFlag = true;
@@ -4171,36 +4295,34 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound)
static uint32 counter = 0;
time = CTimer::GetTimeInMilliseconds();
- if(time > gDocksNextTime) {
- switch(sound) {
+ if (time > gDocksNextTime) {
+ switch (sound) {
case SCRIPT_SOUND_DOCKS_LOOP_S:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_DOCKS_LOOP_L:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
- default: return;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
rand = m_anRandomTable[0] % 60 + 40;
- m_sQueueSample.m_bVolume = ComputeVolume(
- rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_DOCKS_FOGHORN;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_DOCKS_FOGHORN);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 3);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOCKS_FOGHORN);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8);
m_sQueueSample.m_nCounter = counter++;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = rand;
+ m_sQueueSample.m_nEmittingVolume = rand;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -4219,12 +4341,14 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params)
uint8 engineStatus;
uint8 emittingVolume;
- if(params->m_fDistance >= SQR(engineDamageIntensity)) return false;
+ if (params->m_fDistance >= SQR(engineDamageIntensity))
+ return false;
veh = (CAutomobile *)params->m_pVehicle;
- if(veh->bEngineOn) {
+ if (veh->bEngineOn) {
engineStatus = veh->Damage.GetEngineStatus();
- if(engineStatus > 250 || engineStatus < 100) return true;
- if(engineStatus < 225) {
+ if (engineStatus > 250 || engineStatus < 100)
+ return true;
+ if (engineStatus < 225) {
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI;
emittingVolume = 6;
m_sQueueSample.m_nReleasingVolumeModificator = 7;
@@ -4233,22 +4357,18 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params)
emittingVolume = 60;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
m_sQueueSample.m_nReleasingVolumeModificator = 7;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
}
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, engineDamageIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 28;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVolume;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVolume;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = engineDamageIntensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -4264,47 +4384,47 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params)
void
cAudioManager::ProcessEntity(int32 id)
{
- if(m_asAudioEntities[id].m_bStatus) {
+ if (m_asAudioEntities[id].m_nStatus) {
m_sQueueSample.m_nEntityIndex = id;
- switch(m_asAudioEntities[id].m_nType) {
+ switch (m_asAudioEntities[id].m_nType) {
case AUDIOTYPE_PHYSICAL:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessPhysical(id);
}
break;
case AUDIOTYPE_EXPLOSION:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessExplosions(id);
}
break;
case AUDIOTYPE_FIRE:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessFires(id);
}
break;
case AUDIOTYPE_WEATHER:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessWeather(id);
}
break;
case AUDIOTYPE_CRANE:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessCrane();
}
break;
case AUDIOTYPE_SCRIPTOBJECT:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessScriptObject(id);
}
break;
case AUDIOTYPE_BRIDGE:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessBridge();
}
@@ -4314,27 +4434,29 @@ cAudioManager::ProcessEntity(int32 id)
ProcessFrontEnd();
break;
case AUDIOTYPE_PROJECTILE:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessProjectiles();
}
break;
case AUDIOTYPE_GARAGE:
- if(!m_bUserPause) ProcessGarages();
+ if (!m_nUserPause)
+ ProcessGarages();
break;
case AUDIOTYPE_FIREHYDRANT:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessFireHydrant();
}
break;
case AUDIOTYPE_WATERCANNON:
- if(!m_bUserPause) {
+ if (!m_nUserPause) {
m_sQueueSample.m_bReverbFlag = true;
ProcessWaterCannon(id);
}
break;
- default: return;
+ default:
+ return;
}
}
}
@@ -4346,11 +4468,11 @@ cAudioManager::ProcessExplosions(int32 explosion)
CVector *pos;
float distSquared;
- for(uint8 i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
- if(CExplosion::GetExplosionActiveCounter(i) == 1) {
+ for (uint8 i = 0; i < ARRAY_SIZE(gaExplosion); i++) {
+ if (CExplosion::GetExplosionActiveCounter(i) == 1) {
CExplosion::ResetExplosionActiveCounter(i);
type = CExplosion::GetExplosionType(i);
- switch(type) {
+ switch (type) {
case EXPLOSION_GRENADE:
case EXPLOSION_ROCKET:
case EXPLOSION_BARREL:
@@ -4359,14 +4481,14 @@ cAudioManager::ProcessExplosions(int32 explosion)
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2;
m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
break;
case EXPLOSION_MOLOTOV:
m_sQueueSample.m_fSoundIntensity = 200.0f;
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_3;
m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 19000;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
break;
case EXPLOSION_MINE:
case EXPLOSION_HELI_BOMB:
@@ -4374,35 +4496,32 @@ cAudioManager::ProcessExplosions(int32 explosion)
m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT;
m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 12347;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
break;
default:
m_sQueueSample.m_fSoundIntensity = 400.0f;
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1;
m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000;
- if(type == EXPLOSION_HELI)
- m_sQueueSample.m_nFrequency =
- 8 * m_sQueueSample.m_nFrequency / 10;
+ if (type == EXPLOSION_HELI)
+ m_sQueueSample.m_nFrequency = 8 * m_sQueueSample.m_nFrequency / 10;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
break;
}
pos = CExplosion::GetExplosionPosition(i);
m_sQueueSample.m_vecPos = *pos;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = i;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bReverbFlag = true;
- m_sQueueSample.m_bEmittingVolume = maxVolume;
+ m_sQueueSample.m_nEmittingVolume = maxVolume;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -4421,25 +4540,22 @@ cAudioManager::ProcessFireHydrant()
bool distCalculated = false;
static const int intensity = 35;
- m_sQueueSample.m_vecPos =
- ((CEntity *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)->GetPosition();
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(intensity)) {
+ m_sQueueSample.m_vecPos = ((CEntity *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)->GetPosition();
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(intensity)) {
CalculateDistance(distCalculated, distSquared);
- m_sQueueSample.m_bVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 4;
m_sQueueSample.m_nFrequency = 15591;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 40;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 40;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = intensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -4457,75 +4573,59 @@ void cAudioManager::ProcessFires(int32)
uint8 emittingVol;
float distSquared;
- for(uint8 i = 0; i < NUM_FIRES; i++) {
- if(gFireManager.m_aFires[i].m_bIsOngoing && gFireManager.m_aFires[i].m_bAudioSet) {
+ for (uint8 i = 0; i < NUM_FIRES; i++) {
+ if (gFireManager.m_aFires[i].m_bIsOngoing && gFireManager.m_aFires[i].m_bAudioSet) {
entity = gFireManager.m_aFires[i].m_pEntity;
- if(entity) {
- switch(entity->m_type & 7) {
+ if (entity) {
+ switch (entity->GetType()) {
case ENTITY_TYPE_BUILDING:
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
emittingVol = 100;
- m_sQueueSample.m_nFrequency =
- 8 *
- SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE) /
- 10;
- m_sQueueSample.m_nFrequency +=
- i * ((uint32)m_sQueueSample.m_nFrequency >> 6);
+ m_sQueueSample.m_nFrequency = 8 * SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE) / 10;
+ m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64);
m_sQueueSample.m_nReleasingVolumeModificator = 6;
break;
case ENTITY_TYPE_PED:
m_sQueueSample.m_fSoundIntensity = 25.0f;
m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE);
emittingVol = 60;
- m_sQueueSample.m_nFrequency +=
- i * ((uint32)m_sQueueSample.m_nFrequency >> 6);
+ m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64);
m_sQueueSample.m_nReleasingVolumeModificator = 10;
break;
default:
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
- m_sQueueSample.m_nFrequency +=
- i * ((uint32)m_sQueueSample.m_nFrequency >> 6);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
+ m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64);
emittingVol = 80;
m_sQueueSample.m_nReleasingVolumeModificator = 8;
}
} else {
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
- m_sQueueSample.m_nFrequency +=
- i * ((uint32)m_sQueueSample.m_nFrequency >> 6);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
+ m_sQueueSample.m_nFrequency += i * (m_sQueueSample.m_nFrequency / 64);
emittingVol = 80;
m_sQueueSample.m_nReleasingVolumeModificator = 8;
}
m_sQueueSample.m_vecPos = gFireManager.m_aFires[i].m_vecPos;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = i;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_nReleasingVolumeDivider = 10;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
@@ -4547,11 +4647,11 @@ cAudioManager::ProcessFrontEnd()
static uint32 cPickupNextFrame = 0;
static uint32 cPartMisComNextFrame = 0;
- for(uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) {
+ for (uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) {
processedPickup = false;
stereo = false;
processedMission = false;
- switch(m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]) {
+ switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]) {
case SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM:
m_sQueueSample.m_nSampleIndex = SFX_ERROR_FIRE_RIFLE;
break;
@@ -4602,11 +4702,15 @@ cAudioManager::ProcessFrontEnd()
processedPickup = true;
stereo = true;
break;
- case SOUND_PAGER: m_sQueueSample.m_nSampleIndex = SFX_PAGER; break;
+ case SOUND_PAGER:
+ m_sQueueSample.m_nSampleIndex = SFX_PAGER;
+ break;
case SOUND_RACE_START_3:
case SOUND_RACE_START_2:
case SOUND_RACE_START_1:
- case SOUND_CLOCK_TICK: m_sQueueSample.m_nSampleIndex = SFX_TIMER_BEEP; break;
+ case SOUND_CLOCK_TICK:
+ m_sQueueSample.m_nSampleIndex = SFX_TIMER_BEEP;
+ break;
case SOUND_RACE_START_GO:
m_sQueueSample.m_nSampleIndex = SFX_PART_MISSION_COMPLETE;
break;
@@ -4638,7 +4742,9 @@ cAudioManager::ProcessFrontEnd()
m_sQueueSample.m_nSampleIndex = SFX_STEREO_LEFT;
stereo = true;
break;
- case SOUND_9B: m_sQueueSample.m_nSampleIndex = SFX_MONO; break;
+ case SOUND_9B:
+ m_sQueueSample.m_nSampleIndex = SFX_MONO;
+ break;
case SOUND_FRONTEND_AUDIO_TEST:
m_sQueueSample.m_nSampleIndex = m_anRandomTable[0] % 3 + SFX_NOISE_BURST_1;
break;
@@ -4650,51 +4756,55 @@ cAudioManager::ProcessFrontEnd()
case SOUND_FRONTEND_RADIO_CHANGE:
m_sQueueSample.m_nSampleIndex = SFX_RADIO_CLICK;
break;
- case SOUND_A0: m_sQueueSample.m_nSampleIndex = SFX_INFO; break;
- default: continue;
+ case SOUND_A0:
+ m_sQueueSample.m_nSampleIndex = SFX_INFO;
+ break;
+ default:
+ continue;
}
- if(processedPickup) {
- if(m_FrameCounter <= cPickupNextFrame) continue;
+ if (processedPickup) {
+ if (m_FrameCounter <= cPickupNextFrame)
+ continue;
cPickupNextFrame = m_FrameCounter + 5;
- } else if(processedMission) {
- if(m_FrameCounter <= cPartMisComNextFrame) continue;
+ } else if (processedMission) {
+ if (m_FrameCounter <= cPartMisComNextFrame)
+ continue;
cPartMisComNextFrame = m_FrameCounter + 5;
}
sample = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i];
- if(sample == SFX_RAIN) {
+ if (sample == SFX_RAIN) {
m_sQueueSample.m_nFrequency = 28509;
- } else if(sample == SFX_PICKUP_1_LEFT) {
- if(1.f == m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])
+ } else if (sample == SFX_PICKUP_1_LEFT) {
+ if (1.f == m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])
m_sQueueSample.m_nFrequency = 32000;
else
m_sQueueSample.m_nFrequency = 48000;
} else {
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
}
- m_sQueueSample.m_bVolume = 110;
+ m_sQueueSample.m_nVolume = 110;
m_sQueueSample.m_nCounter = counter++;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
m_sQueueSample.m_bIs2D = true;
- m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume;
+ m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
- if(stereo)
- m_sQueueSample.m_bOffset = m_anRandomTable[0] & 31;
+ if (stereo)
+ m_sQueueSample.m_nOffset = m_anRandomTable[0] & 31;
else
- m_sQueueSample.m_bOffset = 63;
+ m_sQueueSample.m_nOffset = 63;
m_sQueueSample.m_bReverbFlag = false;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
- if(stereo) {
+ if (stereo) {
++m_sQueueSample.m_nSampleIndex;
m_sQueueSample.m_nCounter = counter++;
- m_sQueueSample.m_bOffset = maxVolume - m_sQueueSample.m_bOffset;
+ m_sQueueSample.m_nOffset = maxVolume - m_sQueueSample.m_nOffset;
AddSampleToRequestedQueue();
}
}
@@ -4712,109 +4822,91 @@ cAudioManager::ProcessGarages()
static uint8 iSound = 32;
-#define LOOP_HELPER \
- for(j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) { \
- switch(m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) { \
- case SOUND_GARAGE_DOOR_CLOSED: \
- case SOUND_GARAGE_DOOR_OPENED: \
- if(distSquared < 6400.f) { \
- CalculateDistance(distCalculated, distSquared); \
- m_sQueueSample.m_bVolume = \
- ComputeVolume(60, 80.f, m_sQueueSample.m_fDistance); \
- if(m_sQueueSample.m_bVolume) { \
- if(CGarages::aGarages[i].m_eGarageType == \
- GARAGE_CRUSHER) { \
- m_sQueueSample.m_nSampleIndex = \
- SFX_COL_CAR_PANEL_2; \
- m_sQueueSample.m_nFrequency = 6735; \
- } else if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex] \
- .m_awAudioEvent[j] == 69) { \
- m_sQueueSample.m_nSampleIndex = \
- SFX_COL_CAR_PANEL_2; \
- m_sQueueSample.m_nFrequency = 22000; \
- } else { \
- m_sQueueSample.m_nSampleIndex = \
- SFX_COL_GARAGE_DOOR_1; \
- m_sQueueSample.m_nFrequency = 18000; \
- } \
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; \
- m_sQueueSample.m_nReleasingVolumeModificator = 4; \
- m_sQueueSample.m_bEmittingVolume = 60; \
- m_sQueueSample.m_fSpeedMultiplier = 0.0f; \
- m_sQueueSample.m_fSoundIntensity = 80.0f; \
- /*m_sQueueSample.m_nReleasingVolumeModificator = 4;*/ \
- m_sQueueSample.m_bReverbFlag = true; \
- /*m_sQueueSample.m_bReverbFlag = true;*/ \
- m_sQueueSample.m_bIs2D = false; \
- m_sQueueSample.m_bReleasingSoundFlag = true; \
- m_sQueueSample.m_nLoopCount = 1; \
- m_sQueueSample.m_nLoopStart = 0; \
- m_sQueueSample.m_nLoopEnd = -1; \
- m_sQueueSample.m_nCounter = iSound++; \
- if(iSound < 32) iSound = 32; \
- m_sQueueSample.m_bRequireReflection = true; \
- AddSampleToRequestedQueue(); \
- } \
- } \
- break; \
- default: continue; \
- } \
- }
-
- for(uint32 i = 0; i < CGarages::NumGarages; ++i) {
- if(CGarages::aGarages[i].m_eGarageType == GARAGE_NONE) continue;
+#define LOOP_HELPER \
+ for (j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) { \
+ switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) { \
+ case SOUND_GARAGE_DOOR_CLOSED: \
+ case SOUND_GARAGE_DOOR_OPENED: \
+ if (distSquared < 6400.f) { \
+ CalculateDistance(distCalculated, distSquared); \
+ m_sQueueSample.m_nVolume = ComputeVolume(60, 80.f, m_sQueueSample.m_fDistance); \
+ if (m_sQueueSample.m_nVolume) { \
+ if (CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { \
+ m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; \
+ m_sQueueSample.m_nFrequency = 6735; \
+ } else if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j] == 69) { \
+ m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; \
+ m_sQueueSample.m_nFrequency = 22000; \
+ } else { \
+ m_sQueueSample.m_nSampleIndex = SFX_COL_GARAGE_DOOR_1; \
+ m_sQueueSample.m_nFrequency = 18000; \
+ } \
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; \
+ m_sQueueSample.m_nReleasingVolumeModificator = 4; \
+ m_sQueueSample.m_nEmittingVolume = 60; \
+ m_sQueueSample.m_fSpeedMultiplier = 0.0f; \
+ m_sQueueSample.m_fSoundIntensity = 80.0f; \
+ /*m_sQueueSample.m_nReleasingVolumeModificator = 4;*/ \
+ m_sQueueSample.m_bReverbFlag = true; \
+ /*m_sQueueSample.m_bReverbFlag = true;*/ \
+ m_sQueueSample.m_bIs2D = false; \
+ m_sQueueSample.m_bReleasingSoundFlag = true; \
+ m_sQueueSample.m_nLoopCount = 1; \
+ m_sQueueSample.m_nLoopStart = 0; \
+ m_sQueueSample.m_nLoopEnd = -1; \
+ m_sQueueSample.m_nCounter = iSound++; \
+ if (iSound < 32) \
+ iSound = 32; \
+ m_sQueueSample.m_bRequireReflection = true; \
+ AddSampleToRequestedQueue(); \
+ } \
+ } \
+ break; \
+ default: \
+ continue; \
+ } \
+ }
+
+ for (uint32 i = 0; i < CGarages::NumGarages; ++i) {
+ if (CGarages::aGarages[i].m_eGarageType == GARAGE_NONE)
+ continue;
entity = CGarages::aGarages[i].m_pDoor1;
- if(!entity) continue;
+ if (!entity)
+ continue;
m_sQueueSample.m_vecPos = entity->GetPosition();
distCalculated = false;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < 6400.f) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < 6400.f) {
state = CGarages::aGarages[i].m_eGarageState;
- if(state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) {
+ if (state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) {
CalculateDistance(distCalculated, distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(90, 80.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- if(CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) {
- if(CGarages::aGarages[i].m_eGarageState ==
- GS_AFTERDROPOFF) {
- if(!(m_FrameCounter & 1)) {
+ m_sQueueSample.m_nVolume = ComputeVolume(90, 80.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
+ if (CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) {
+ if (CGarages::aGarages[i].m_eGarageState == GS_AFTERDROPOFF) {
+ if (!(m_FrameCounter & 1)) {
LOOP_HELPER
continue;
}
- if(m_anRandomTable[1] & 1) {
- sampleIndex =
- m_anRandomTable[2] % 5 +
- SFX_COL_CAR_1;
+ if (m_anRandomTable[1] & 1) {
+ sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_CAR_1;
} else {
- sampleIndex =
- m_anRandomTable[2] % 6 +
- SFX_COL_CAR_PANEL_1;
+ sampleIndex = m_anRandomTable[2] % 6 + SFX_COL_CAR_PANEL_1;
}
m_sQueueSample.m_nSampleIndex = sampleIndex;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex) >>
- 1;
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(
- m_sQueueSample.m_nFrequency >> 4);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2;
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_nCounter = iSound++;
- if(iSound < 32) iSound = 32;
- m_sQueueSample.m_bBankIndex =
- SAMPLEBANK_MAIN;
+ if (iSound < 32)
+ iSound = 32;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
- m_sQueueSample
- .m_nReleasingVolumeModificator = 3;
- m_sQueueSample.m_bEmittingVolume = 90;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nReleasingVolumeModificator = 3;
+ m_sQueueSample.m_nEmittingVolume = 90;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_bReverbFlag = true;
@@ -4823,28 +4915,22 @@ cAudioManager::ProcessGarages()
LOOP_HELPER
continue;
}
- m_sQueueSample.m_nSampleIndex =
- SFX_FISHING_BOAT_IDLE;
+ m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE;
m_sQueueSample.m_nFrequency = 6543;
} else {
- m_sQueueSample.m_nSampleIndex =
- SFX_GARAGE_DOOR_LOOP;
+ m_sQueueSample.m_nSampleIndex = SFX_GARAGE_DOOR_LOOP;
m_sQueueSample.m_nFrequency = 13961;
}
m_sQueueSample.m_nCounter = i;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bReleasingSoundFlag = false;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
- m_sQueueSample.m_bEmittingVolume = 90;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 90;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_bReverbFlag = true;
@@ -4872,43 +4958,36 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params)
float dist;
float baseDist;
int32 emittingVol;
- static const tHelicopterSampleData gHeliSfxRanges[3] = {
- {400.f, 380.f, 100}, {100.f, 70.f, maxVolume}, {60.f, 30.f, maxVolume}};
+ static const tHelicopterSampleData gHeliSfxRanges[3] = {{400.f, 380.f, 100}, {100.f, 70.f, maxVolume}, {60.f, 30.f, maxVolume}};
- if(gHeliSfxRanges[0].m_fMaxDistance * gHeliSfxRanges[0].m_fMaxDistance <=
- params->m_fDistance)
+ if (gHeliSfxRanges[0].m_fMaxDistance * gHeliSfxRanges[0].m_fMaxDistance <= params->m_fDistance)
return false;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
heli = (CHeli *)params->m_pVehicle;
- for(uint32 i = 0; i < ARRAY_SIZE(gHeliSfxRanges); i++) {
+ for (uint32 i = 0; i < ARRAY_SIZE(gHeliSfxRanges); i++) {
MaxDist = gHeliSfxRanges[i].m_fMaxDistance;
dist = m_sQueueSample.m_fDistance;
- if(dist >= MaxDist) return true;
+ if (dist >= MaxDist)
+ return true;
baseDist = gHeliSfxRanges[i].m_fBaseDistance;
- if(dist < baseDist)
- emittingVol = (gHeliSfxRanges[i].m_bBaseVolume *
- ((MaxDist - dist) / (MaxDist - baseDist)));
+ if (dist < baseDist)
+ emittingVol = (gHeliSfxRanges[i].m_bBaseVolume * ((MaxDist - dist) / (MaxDist - baseDist)));
else
emittingVol = gHeliSfxRanges[i].m_bBaseVolume;
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVol, gHeliSfxRanges[i].m_fMaxDistance, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, gHeliSfxRanges[i].m_fMaxDistance, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = i + 65;
m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_nFrequency =
- 1200 * heli->m_nHeliId +
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -4931,36 +5010,34 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound)
static uint8 counter = 0;
time = CTimer::GetTimeInMilliseconds();
- if(time > gHomeNextTime) {
- switch(sound) {
+ if (time > gHomeNextTime) {
+ switch (sound) {
case SCRIPT_SOUND_HOME_LOOP_S:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_HOME_LOOP_L:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
- default: return;
+ default:
+ return;
}
- dist = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(dist < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ dist = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (dist < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(dist);
rand = m_anRandomTable[0] % 30 + 40;
- m_sQueueSample.m_bVolume = ComputeVolume(
- rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = m_anRandomTable[0] % 5 + SFX_HOME_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nCounter = counter++;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_bEmittingVolume = rand;
+ m_sQueueSample.m_nEmittingVolume = rand;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -4978,25 +5055,25 @@ cAudioManager::ProcessJumbo(cVehicleParams *params)
CPlane *plane;
float position;
- if(params->m_fDistance < 193600.0f) {
+ if (params->m_fDistance < 193600.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
plane = (CPlane *)params->m_pVehicle;
DoJumboVolOffset();
position = PlanePathPosition[plane->m_nPlaneId];
- if(position <= TakeOffPoint) {
- if(plane->m_fSpeed <= 0.10334f) {
+ if (position <= TakeOffPoint) {
+ if (plane->m_fSpeed <= 0.10334f) {
ProcessJumboTaxi();
return;
}
ProcessJumboAccel(plane);
- } else if(300.0f + TakeOffPoint >= position) {
+ } else if (300.0f + TakeOffPoint >= position) {
ProcessJumboTakeOff(plane);
- } else if(LandingPoint - 350.0f >= position) {
+ } else if (LandingPoint - 350.0f >= position) {
ProcessJumboFlying();
} else {
- if(position > LandingPoint) {
- if(plane->m_fSpeed > 0.10334f) {
+ if (position > LandingPoint) {
+ if (plane->m_fSpeed > 0.10334f) {
ProcessJumboDecel(plane);
return;
}
@@ -5016,12 +5093,12 @@ cAudioManager::ProcessJumboAccel(CPlane *plane)
float whineSoundFreq;
float modificator;
- if(SetupJumboFlySound(20)) {
+ if (SetupJumboFlySound(20)) {
modificator = (plane->m_fSpeed - 0.10334f) * 1.676f;
- if(modificator > 1.0f) modificator = 1.0f;
- if(SetupJumboRumbleSound(maxVolume * modificator) &&
- SetupJumboTaxiSound((1.0f - modificator) * 75.f)) {
- if(modificator < 0.2f) {
+ if (modificator > 1.0f)
+ modificator = 1.0f;
+ if (SetupJumboRumbleSound(maxVolume * modificator) && SetupJumboTaxiSound((1.0f - modificator) * 75.f)) {
+ if (modificator < 0.2f) {
whineSoundFreq = modificator * 5.f * 14600.0f + 29500;
vol = modificator * 5.f * maxVolume;
engineFreq = modificator * 5.f * 6050.f + 16000;
@@ -5039,7 +5116,7 @@ cAudioManager::ProcessJumboAccel(CPlane *plane)
void
cAudioManager::ProcessJumboDecel(CPlane *plane)
{
- if(SetupJumboFlySound(20) && SetupJumboTaxiSound(75)) {
+ if (SetupJumboFlySound(20) && SetupJumboTaxiSound(75)) {
const float modificator = Min(1.f, (plane->m_fSpeed - 0.10334f) * 1.676f);
SetupJumboEngineSound(maxVolume * modificator, 6050.f * modificator + 16000);
SetupJumboWhineSound(18, 29500);
@@ -5049,18 +5126,18 @@ cAudioManager::ProcessJumboDecel(CPlane *plane)
void
cAudioManager::ProcessJumboFlying()
{
- if(SetupJumboFlySound(maxVolume)) SetupJumboEngineSound(63, 22050);
+ if (SetupJumboFlySound(maxVolume))
+ SetupJumboEngineSound(63, 22050);
}
void
cAudioManager::ProcessJumboLanding(CPlane *plane)
{
const float modificator = (LandingPoint - PlanePathPosition[plane->m_nPlaneId]) / 350.f;
- if(SetupJumboFlySound(107.f * modificator + 20)) {
- if(SetupJumboTaxiSound(75.f * (1.f - modificator))) {
+ if (SetupJumboFlySound(107.f * modificator + 20)) {
+ if (SetupJumboTaxiSound(75.f * (1.f - modificator))) {
SetupJumboEngineSound(maxVolume, 22050);
- SetupJumboWhineSound(18.f * (1.f - modificator),
- 14600.f * modificator + 29500);
+ SetupJumboWhineSound(18.f * (1.f - modificator), 14600.f * modificator + 29500);
}
}
}
@@ -5070,9 +5147,8 @@ cAudioManager::ProcessJumboTakeOff(CPlane *plane)
{
const float modificator = (PlanePathPosition[plane->m_nPlaneId] - TakeOffPoint) / 300.f;
- if(SetupJumboFlySound((107.f * modificator) + 20) &&
- SetupJumboRumbleSound(maxVolume * (1.f - modificator))) {
- if(SetupJumboEngineSound(maxVolume, 22050))
+ if (SetupJumboFlySound((107.f * modificator) + 20) && SetupJumboRumbleSound(maxVolume * (1.f - modificator))) {
+ if (SetupJumboEngineSound(maxVolume, 22050))
SetupJumboWhineSound(18.f * (1.f - modificator), 44100);
}
}
@@ -5080,62 +5156,58 @@ cAudioManager::ProcessJumboTakeOff(CPlane *plane)
void
cAudioManager::ProcessJumboTaxi()
{
- if(SetupJumboFlySound(20)) {
- if(SetupJumboTaxiSound(75)) SetupJumboWhineSound(18, 29500);
+ if (SetupJumboFlySound(20)) {
+ if (SetupJumboTaxiSound(75))
+ SetupJumboWhineSound(18, 29500);
}
}
void
cAudioManager::ProcessLaunderetteScriptObject(uint8 sound)
{
- switch(sound) {
+ switch (sound) {
case SCRIPT_SOUND_LAUNDERETTE_LOOP_S:
- case SCRIPT_SOUND_LAUNDERETTE_LOOP_L: m_sQueueSample.m_fSoundIntensity = 30.0f; break;
- default: return;
+ case SCRIPT_SOUND_LAUNDERETTE_LOOP_L:
+ m_sQueueSample.m_fSoundIntensity = 30.0f;
+ break;
+ default:
+ return;
}
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(45, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_LOOP);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_LOOP);
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = 45;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 45;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
- m_sQueueSample.m_bVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_SONG_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_SONG_LOOP);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_SONG_LOOP);
m_sQueueSample.m_nCounter = 1;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = 110;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 110;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
@@ -5149,11 +5221,11 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
uint8 emittingVolume;
float distSquared;
- switch(sound) {
+ switch (sound) {
case SCRIPT_SOUND_PARTY_1_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5163,7 +5235,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_1_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5173,7 +5245,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_2_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5183,7 +5255,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_2_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5193,7 +5265,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_3_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_3;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5203,7 +5275,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_3_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_3;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5213,7 +5285,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_4_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_4;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5223,7 +5295,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_4_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_4;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5233,7 +5305,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_5_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_5;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_5);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5243,7 +5315,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_5_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_5;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_5);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5253,7 +5325,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_6_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_6;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_6);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5263,7 +5335,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_6_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_6;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_6);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5273,7 +5345,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_7_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_7;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_7);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5283,7 +5355,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_7_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_7;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_7);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5293,7 +5365,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_8_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_8;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_8);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5303,7 +5375,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_8_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_8;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_8);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5313,7 +5385,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_9_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_9;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_9);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5323,7 +5395,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_9_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_9;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_9);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5333,7 +5405,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_10_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_10;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_10);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5343,7 +5415,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_10_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_10;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_10);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5353,7 +5425,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_11_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_11;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_11);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5363,7 +5435,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_11_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_11;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_11);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5373,7 +5445,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_12_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_12;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_12);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5383,7 +5455,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_12_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_12;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_12);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5393,7 +5465,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_13_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_RAGGA);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5403,7 +5475,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_13_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_RAGGA);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5413,10 +5485,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5424,10 +5495,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5435,10 +5505,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5446,25 +5515,27 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
break;
case SCRIPT_SOUND_WORK_SHOP_LOOP_S:
- case SCRIPT_SOUND_WORK_SHOP_LOOP_L: ProcessWorkShopScriptObject(sound); return;
+ case SCRIPT_SOUND_WORK_SHOP_LOOP_L:
+ ProcessWorkShopScriptObject(sound);
+ return;
case SCRIPT_SOUND_SAWMILL_LOOP_S:
- case SCRIPT_SOUND_SAWMILL_LOOP_L: ProcessSawMillScriptObject(sound); return;
+ case SCRIPT_SOUND_SAWMILL_LOOP_L:
+ ProcessSawMillScriptObject(sound);
+ return;
case SCRIPT_SOUND_38:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY);
m_sQueueSample.m_nReleasingVolumeModificator = 6;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5472,23 +5543,23 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_39:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY);
m_sQueueSample.m_nReleasingVolumeModificator = 6;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
break;
case SCRIPT_SOUND_LAUNDERETTE_LOOP_S:
- case SCRIPT_SOUND_LAUNDERETTE_LOOP_L: ProcessLaunderetteScriptObject(sound); return;
+ case SCRIPT_SOUND_LAUNDERETTE_LOOP_L:
+ ProcessLaunderetteScriptObject(sound);
+ return;
case SCRIPT_SOUND_CHINATOWN_RESTAURANT_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5496,10 +5567,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_CHINATOWN_RESTAURANT_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5507,10 +5577,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_CIPRIANI_RESAURANT_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5518,10 +5587,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_CIPRIANI_RESAURANT_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5529,10 +5597,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_46_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5540,10 +5607,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_47_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5551,10 +5617,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_MARCO_BISTRO_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5562,28 +5627,37 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_MARCO_BISTRO_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 110;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
break;
case SCRIPT_SOUND_AIRPORT_LOOP_S:
- case SCRIPT_SOUND_AIRPORT_LOOP_L: ProcessAirportScriptObject(sound); return;
+ case SCRIPT_SOUND_AIRPORT_LOOP_L:
+ ProcessAirportScriptObject(sound);
+ return;
case SCRIPT_SOUND_SHOP_LOOP_S:
- case SCRIPT_SOUND_SHOP_LOOP_L: ProcessShopScriptObject(sound); return;
+ case SCRIPT_SOUND_SHOP_LOOP_L:
+ ProcessShopScriptObject(sound);
+ return;
case SCRIPT_SOUND_CINEMA_LOOP_S:
- case SCRIPT_SOUND_CINEMA_LOOP_L: ProcessCinemaScriptObject(sound); return;
+ case SCRIPT_SOUND_CINEMA_LOOP_L:
+ ProcessCinemaScriptObject(sound);
+ return;
case SCRIPT_SOUND_DOCKS_LOOP_S:
- case SCRIPT_SOUND_DOCKS_LOOP_L: ProcessDocksScriptObject(sound); return;
+ case SCRIPT_SOUND_DOCKS_LOOP_L:
+ ProcessDocksScriptObject(sound);
+ return;
case SCRIPT_SOUND_HOME_LOOP_S:
- case SCRIPT_SOUND_HOME_LOOP_L: ProcessHomeScriptObject(sound); return;
+ case SCRIPT_SOUND_HOME_LOOP_L:
+ ProcessHomeScriptObject(sound);
+ return;
case SCRIPT_SOUND_FRANKIE_PIANO:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_PIANO_BAR_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PIANO_BAR_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5593,7 +5667,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PARTY_1_LOOP:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_CLUB_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -5607,14 +5681,15 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PORN_CINEMA_3_S:
case SCRIPT_SOUND_PORN_CINEMA_3_L:
case SCRIPT_SOUND_MISTY_SEX_S:
- case SCRIPT_SOUND_MISTY_SEX_L: ProcessPornCinema(sound); return;
+ case SCRIPT_SOUND_MISTY_SEX_L:
+ ProcessPornCinema(sound);
+ return;
case SCRIPT_SOUND_BANK_ALARM_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 90;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1);
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5622,10 +5697,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_BANK_ALARM_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 90;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1);
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5633,10 +5707,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_POLICE_BALL_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1);
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5644,10 +5717,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_POLICE_BALL_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1);
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5655,10 +5727,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5666,10 +5737,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5682,10 +5752,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_RAVE_2_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5694,10 +5763,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_RAVE_2_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5705,10 +5773,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_RAVE_3_LOOP_S:
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5716,10 +5783,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_RAVE_3_LOOP_L:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
@@ -5727,32 +5793,30 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
case SCRIPT_SOUND_PRETEND_FIRE_LOOP:
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 80;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE);
m_sQueueSample.m_nReleasingVolumeModificator = 8;
m_sQueueSample.m_nReleasingVolumeDivider = 10;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
break;
- default: return;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_bReverbFlag = true;
- m_sQueueSample.m_bEmittingVolume = emittingVolume;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVolume;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
@@ -5772,146 +5836,113 @@ cAudioManager::ProcessMissionAudio()
static uint8 nFramesUntilFailedLoad = 0;
static uint8 nFramesForPretendPlaying = 0;
- if(m_bIsInitialised) {
- if(m_sMissionAudio.m_nSampleIndex != NO_SAMPLE) {
- switch(m_sMissionAudio.m_bLoadingStatus) {
+ if (m_bIsInitialised) {
+ if (m_sMissionAudio.m_nSampleIndex != NO_SAMPLE) {
+ switch (m_sMissionAudio.m_nLoadingStatus) {
case LOADING_STATUS_NOT_LOADED:
- SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex,
- 1);
- m_sMissionAudio.m_bLoadingStatus = LOADING_STATUS_LOADED;
+ SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex, 1);
+ m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_LOADED;
nFramesUntilFailedLoad = 0;
return;
case LOADING_STATUS_LOADED:
- if(!m_sMissionAudio.m_bIsPlayed) return;
- if(g_bMissionAudioLoadFailed) {
- if(m_bTimerJustReset) {
+ if (!m_sMissionAudio.m_bIsPlayed)
+ return;
+ if (g_bMissionAudioLoadFailed) {
+ if (m_bTimerJustReset) {
ClearMissionAudio();
SampleManager.StopStreamedFile(1);
nFramesForPretendPlaying = 0;
nCheckPlayingDelay = 0;
nFramesUntilFailedLoad = 0;
- } else if(!m_bUserPause) {
- if(++nFramesForPretendPlaying < 120) {
- m_sMissionAudio.m_bPlayStatus =
- PLAY_STATUS_PLAYING;
+ } else if (!m_nUserPause) {
+ if (++nFramesForPretendPlaying < 120) {
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_PLAYING;
} else {
- m_sMissionAudio.m_bPlayStatus =
- PLAY_STATUS_FINISHED;
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED;
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
}
}
} else {
- if(m_sMissionAudio.m_bPlayStatus) {
- if(m_sMissionAudio.m_bPlayStatus !=
- PLAY_STATUS_PLAYING)
+ if (m_sMissionAudio.m_nPlayStatus) {
+ if (m_sMissionAudio.m_nPlayStatus != PLAY_STATUS_PLAYING)
return;
- if(m_bTimerJustReset) {
+ if (m_bTimerJustReset) {
ClearMissionAudio();
SampleManager.StopStreamedFile(1);
return;
}
- if(MissionScriptAudioUsesPoliceChannel(
- m_sMissionAudio.m_nSampleIndex)) {
- if(!m_bUserPause) {
- if(nCheckPlayingDelay) {
+ if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex)) {
+ if (!m_nUserPause) {
+ if (nCheckPlayingDelay) {
--nCheckPlayingDelay;
- } else if(
- GetMissionScriptPoliceAudioPlayingStatus() ==
- PLAY_STATUS_FINISHED ||
- m_sMissionAudio
- .m_nMissionAudioCounter-- ==
- 0) {
- m_sMissionAudio
- .m_bPlayStatus =
- PLAY_STATUS_FINISHED;
- m_sMissionAudio
- .m_nSampleIndex =
- NO_SAMPLE;
- SampleManager
- .StopStreamedFile(1);
- m_sMissionAudio
- .m_nMissionAudioCounter =
- 0;
+ } else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED ||
+ m_sMissionAudio.m_nMissionAudioCounter-- == 0) {
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED;
+ m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
+ SampleManager.StopStreamedFile(1);
+ m_sMissionAudio.m_nMissionAudioCounter = 0;
}
}
- } else if(m_sMissionAudio.field_22) {
- if(SampleManager.IsStreamPlaying(1) ||
- m_bUserPause || m_bPreviousUserPause) {
- if(m_bUserPause)
- SampleManager.PauseStream(
- 1, 1);
+ } else if (m_sMissionAudio.field_22) {
+ if (SampleManager.IsStreamPlaying(1) || m_nUserPause || m_nPreviousUserPause) {
+ if (m_nUserPause)
+ SampleManager.PauseStream(1, 1);
else
- SampleManager.PauseStream(
- 0, 1);
+ SampleManager.PauseStream(0, 1);
} else {
- m_sMissionAudio.m_bPlayStatus =
- PLAY_STATUS_FINISHED;
- m_sMissionAudio.m_nSampleIndex =
- NO_SAMPLE;
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED;
+ m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
SampleManager.StopStreamedFile(1);
- m_sMissionAudio
- .m_nMissionAudioCounter = 0;
+ m_sMissionAudio.m_nMissionAudioCounter = 0;
}
} else {
- if(m_bUserPause) return;
- if(nCheckPlayingDelay--) {
- if(!SampleManager.IsStreamPlaying(
- 1))
+ if (m_nUserPause)
+ return;
+ if (nCheckPlayingDelay--) {
+ if (!SampleManager.IsStreamPlaying(1))
return;
nCheckPlayingDelay = 0;
}
m_sMissionAudio.field_22 = 1;
}
} else {
- if(MissionScriptAudioUsesPoliceChannel(
- m_sMissionAudio.m_nSampleIndex)) {
- SetMissionScriptPoliceAudio(
- m_sMissionAudio.m_nSampleIndex);
+ if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex)) {
+ SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex);
} else {
- if(m_bUserPause)
+ if (m_nUserPause)
SampleManager.PauseStream(1, 1);
- if(m_sMissionAudio
- .m_bPredefinedProperties) {
- SampleManager
- .SetStreamedVolumeAndPan(80, 63,
- 1, 1);
+ if (m_sMissionAudio.m_bPredefinedProperties) {
+ SampleManager.SetStreamedVolumeAndPan(80, 63, 1, 1);
} else {
- distSquared = GetDistanceSquared(
- &m_sMissionAudio.m_vecPos);
- if(distSquared >= 2500.f) {
+ distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos);
+ if (distSquared >= 2500.f) {
emittingVol = 0;
pan = 63;
} else {
dist = Sqrt(distSquared);
- emittingVol = ComputeVolume(
- 80, 50.0f, dist);
- TranslateEntity(
- &m_sMissionAudio
- .m_vecPos,
- &vec);
- pan =
- ComputePan(50.f, &vec);
+ emittingVol = ComputeVolume(80, 50.0f, dist);
+ TranslateEntity(&m_sMissionAudio.m_vecPos, &vec);
+ pan = ComputePan(50.f, &vec);
}
- SampleManager
- .SetStreamedVolumeAndPan(
- emittingVol, pan, 1, 1);
+ SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, 1, 1);
}
SampleManager.StartPreloadedStreamedFile(1);
}
- m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_PLAYING;
+ m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_PLAYING;
nCheckPlayingDelay = 30;
}
}
break;
case 2:
- if(++nFramesUntilFailedLoad >= 90) {
+ if (++nFramesUntilFailedLoad >= 90) {
nFramesForPretendPlaying = 0;
g_bMissionAudioLoadFailed = true;
nFramesUntilFailedLoad = 0;
- m_sMissionAudio.m_bLoadingStatus = LOADING_STATUS_LOADED;
+ m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_LOADED;
}
return;
- default: return;
+ default:
+ return;
}
}
}
@@ -5925,48 +5956,36 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params)
int32 emittingVol;
float velocityChange;
- if(params->m_fDistance < 900.f) {
+ if (params->m_fDistance < 900.f) {
automobile = (CAutomobile *)params->m_pVehicle;
- if(automobile->bEngineOn) {
- if(automobile->m_nWheelsOnGround) {
+ if (automobile->bEngineOn) {
+ if (automobile->m_nWheelsOnGround) {
velocityChange = Abs(params->m_fVelocityChange);
} else {
- if(automobile->m_nDriveWheelsOnGround)
- automobile->m_fGasPedalAudio =
- automobile->m_fGasPedalAudio * 0.4f;
- velocityChange = automobile->m_fGasPedalAudio *
- params->m_pTransmission->fMaxVelocity;
+ if (automobile->m_nDriveWheelsOnGround)
+ automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.4f;
+ velocityChange = automobile->m_fGasPedalAudio * params->m_pTransmission->fMaxVelocity;
}
- if(velocityChange > 0.001f) {
+ if (velocityChange > 0.001f) {
allowedVelocity = 0.5f * params->m_pTransmission->fMaxVelocity;
- if(velocityChange < allowedVelocity)
+ if (velocityChange < allowedVelocity)
emittingVol = (90.f * velocityChange / allowedVelocity);
else
emittingVol = 90;
- if(emittingVol) {
- CalculateDistance(params->m_bDistanceCalculated,
- params->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVol, 30.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (emittingVol) {
+ CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 2;
- m_sQueueSample.m_nSampleIndex =
- SFX_REMOTE_CONTROLLED_CAR;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
- m_sQueueSample.m_nFrequency =
- (11025.f * velocityChange /
- params->m_pTransmission->fMaxVelocity +
- 11025.f);
+ m_sQueueSample.m_nFrequency = (11025.f * velocityChange / params->m_pTransmission->fMaxVelocity + 11025.f);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 3.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -5993,27 +6012,27 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
static uint8 iSound = 0;
- switch(sound) {
+ switch (sound) {
case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_S:
case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L:
male.m_pPed = nil;
male.m_bDistanceCalculated = false;
- male.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ male.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
SetupPedComments(&male, SOUND_INJURED_PED_MALE_OUCH);
return;
case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S:
case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L:
female.m_pPed = nil;
female.m_bDistanceCalculated = false;
- female.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ female.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
SetupPedComments(&female, SOUND_INJURED_PED_FEMALE);
return;
case SCRIPT_SOUND_GATE_START_CLUNK:
case SCRIPT_SOUND_GATE_STOP_CLUNK:
m_sQueueSample.m_fSoundIntensity = 40.0f;
m_sQueueSample.m_nSampleIndex = SFX_COL_GATE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- if(sound == SCRIPT_SOUND_GATE_START_CLUNK)
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ if (sound == SCRIPT_SOUND_GATE_START_CLUNK)
m_sQueueSample.m_nFrequency = 10600;
else
m_sQueueSample.m_nFrequency = 9000;
@@ -6028,10 +6047,9 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_BULLET_HIT_GROUND_3:
m_sQueueSample.m_fSoundIntensity = 50.0f;
m_sQueueSample.m_nSampleIndex = m_anRandomTable[iSound % 5] % 3 + SFX_BULLET_WALL_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 9;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_bIs2D = false;
@@ -6039,13 +6057,13 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
break;
case SCRIPT_SOUND_110:
case SCRIPT_SOUND_111:
- if(SampleManager.IsSampleBankLoaded(0) != 1) return;
+ if (SampleManager.IsSampleBankLoaded(0) != 1)
+ return;
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_TRAIN_STATION_ANNOUNCE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = maxVolume;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_TRAIN_STATION_ANNOUNCE);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_STATION_ANNOUNCE);
m_sQueueSample.m_nReleasingVolumeModificator = 0;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_bIs2D = false;
@@ -6053,7 +6071,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_PAYPHONE_RINGING:
m_sQueueSample.m_fSoundIntensity = 80.0f;
m_sQueueSample.m_nSampleIndex = SFX_PHONE_RING;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 80;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PHONE_RING);
m_sQueueSample.m_nReleasingVolumeModificator = 1;
@@ -6064,7 +6082,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_GLASS_BREAK_L:
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 70;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -6074,7 +6092,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_GLASS_BREAK_S:
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 60;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -6084,7 +6102,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_GLASS_CRACK:
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
emittingVolume = 70;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
@@ -6095,7 +6113,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_GLASS_LIGHT_BREAK:
m_sQueueSample.m_fSoundIntensity = 55.0f;
m_sQueueSample.m_nSampleIndex = (m_anRandomTable[4] & 3) + SFX_GLASS_SHARD_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 19000;
m_sQueueSample.m_nReleasingVolumeModificator = 9;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
@@ -6105,7 +6123,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_BOX_DESTROYED_1:
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_WOODEN_BOX_SMASH;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
@@ -6116,7 +6134,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_BOX_DESTROYED_2:
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_CARDBOARD_BOX_SMASH;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
@@ -6127,10 +6145,9 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_METAL_COLLISION:
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = m_anRandomTable[3] % 5 + SFX_COL_CAR_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_bIs2D = false;
@@ -6140,10 +6157,9 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_TIRE_COLLISION:
m_sQueueSample.m_fSoundIntensity = 60.0f;
m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_bIs2D = false;
@@ -6152,8 +6168,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
break;
case SCRIPT_SOUND_GUNSHELL_DROP:
playerPed = FindPlayerPed();
- if(playerPed) {
- switch(playerPed->m_nSurfaceTouched) {
+ if (playerPed) {
+ switch (playerPed->m_nSurfaceTouched) {
case SURFACE_GRASS:
case SURFACE_DIRT:
case SURFACE_DIRTTRACK:
@@ -6166,21 +6182,19 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000;
m_sQueueSample.m_nReleasingVolumeModificator = 18;
m_sQueueSample.m_fSoundIntensity = 20.0f;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_bIs2D = false;
emittingVolume = m_anRandomTable[2] % 20 + 30;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVolume, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = iSound++;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
- m_sQueueSample.m_bEmittingVolume = emittingVolume;
+ m_sQueueSample.m_nEmittingVolume = emittingVolume;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -6188,15 +6202,17 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
}
}
return;
- case SURFACE_PUDDLE: return;
- default: break;
+ case SURFACE_PUDDLE:
+ return;
+ default:
+ break;
}
}
m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_1;
m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000;
m_sQueueSample.m_nReleasingVolumeModificator = 15;
m_sQueueSample.m_fSoundIntensity = 20.0f;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_bIs2D = false;
emittingVolume = m_anRandomTable[2] % 20 + 30;
@@ -6206,24 +6222,24 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000;
m_sQueueSample.m_nReleasingVolumeModificator = 18;
m_sQueueSample.m_fSoundIntensity = 20.0f;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_bIs2D = false;
emittingVolume = m_anRandomTable[2] % 20 + 30;
break;
- default: return;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = iSound++;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
- m_sQueueSample.m_bEmittingVolume = emittingVolume;
+ m_sQueueSample.m_nEmittingVolume = emittingVolume;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -6245,8 +6261,9 @@ cAudioManager::ProcessPed(CPhysical *ped)
// params.m_bDistanceCalculated = false;
params.m_pPed = (CPed *)ped;
- params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(ped->m_modelIndex == MI_FATMALE02) ProcessPedHeadphones(&params);
+ params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (ped->GetModelIndex() == MI_FATMALE02)
+ ProcessPedHeadphones(&params);
ProcessPedOneShots(&params);
}
@@ -6257,17 +6274,16 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params)
CAutomobile *veh;
uint8 emittingVol;
- if(params->m_fDistance < 49.f) {
+ if (params->m_fDistance < 49.f) {
ped = params->m_pPed;
- if(!ped->bIsAimingGun || ped->m_bodyPartBleeding != PED_HEAD) {
+ if (!ped->bIsAimingGun || ped->m_bodyPartBleeding != PED_HEAD) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- if(ped->bInVehicle && ped->m_nPedState == PED_DRIVING) {
+ if (ped->bInVehicle && ped->m_nPedState == PED_DRIVING) {
emittingVol = 10;
veh = (CAutomobile *)ped->m_pMyVehicle;
- if(veh && veh->IsCar()) {
- for(int32 i = 2; i < ARRAY_SIZE(veh->Doors); i++) {
- if(!veh->IsDoorClosed((eDoors)i) ||
- veh->IsDoorMissing((eDoors)i)) {
+ if (veh && veh->IsCar()) {
+ for (int32 i = 2; i < ARRAY_SIZE(veh->Doors); i++) {
+ if (!veh->IsDoorClosed((eDoors)i) || veh->IsDoorMissing((eDoors)i)) {
emittingVol = 42;
break;
}
@@ -6277,23 +6293,18 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params)
emittingVol = 42;
}
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 7.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 7.f, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 64;
m_sQueueSample.m_nSampleIndex = SFX_HEADPHONES;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_HEADPHONES);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_HEADPHONES);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = 7.0f;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -6324,28 +6335,26 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
static uint8 iSound = 21;
weapon = params->m_pPed->GetWeapon();
- for(uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) {
+ for (uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) {
noReflection = false;
stereo = false;
m_sQueueSample.m_bRequireReflection = false;
sound = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i];
- switch(sound) {
+ switch (sound) {
case SOUND_STEP_START:
case SOUND_STEP_END:
- if(!params->m_pPed->bIsLooking) {
+ if (!params->m_pPed->bIsLooking) {
emittingVol = m_anRandomTable[3] % 15 + 45;
- if(FindPlayerPed() !=
- m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)
- emittingVol >>= 1;
+ if (FindPlayerPed() != m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)
+ emittingVol /= 2;
maxDist = 400.f;
- switch(params->m_pPed->m_nSurfaceTouched) {
+ switch (params->m_pPed->m_nSurfaceTouched) {
case SURFACE_GRASS:
sampleIndex = m_anRandomTable[1] % 5 + SFX_FOOTSTEP_GRASS_1;
break;
case SURFACE_DIRT:
case SURFACE_DIRTTRACK:
- sampleIndex =
- m_anRandomTable[4] % 5 + SFX_FOOTSTEP_GRAVEL_1;
+ sampleIndex = m_anRandomTable[4] % 5 + SFX_FOOTSTEP_GRAVEL_1;
break;
case SURFACE_METAL6:
case SURFACE_METAL_DOOR:
@@ -6361,12 +6370,10 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
sampleIndex = m_anRandomTable[0] % 5 + SFX_FOOTSTEP_METAL_1;
break;
case SURFACE_SAND:
- sampleIndex =
- (m_anRandomTable[4] & 3) + SFX_FOOTSTEP_SAND_1;
+ sampleIndex = (m_anRandomTable[4] & 3) + SFX_FOOTSTEP_SAND_1;
break;
case SURFACE_PUDDLE:
- sampleIndex =
- (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
+ sampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
break;
case SURFACE_WOOD:
case SURFACE_WOOD_BOX:
@@ -6377,36 +6384,28 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_VEG_1;
break;
default:
- sampleIndex =
- m_anRandomTable[2] % 5 + SFX_FOOTSTEP_CONCRETE_1;
+ sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_CONCRETE_1;
break;
}
m_sQueueSample.m_nSampleIndex = sampleIndex;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nCounter =
- m_asAudioEntities[m_sQueueSample.m_nEntityIndex]
- .m_awAudioEvent[i] -
- 28;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
- switch(params->m_pPed->m_nMoveState) {
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] - 28;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
+ switch (params->m_pPed->m_nMoveState) {
case PEDMOVE_WALK:
- emittingVol >>= 2;
- m_sQueueSample.m_nFrequency =
- 9 * m_sQueueSample.m_nFrequency / 10;
+ emittingVol /= 4;
+ m_sQueueSample.m_nFrequency = 9 * m_sQueueSample.m_nFrequency / 10;
break;
case PEDMOVE_RUN:
- emittingVol >>= 1;
- m_sQueueSample.m_nFrequency =
- 11 * m_sQueueSample.m_nFrequency / 10;
+ emittingVol /= 2;
+ m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10;
break;
case PEDMOVE_SPRINT:
- m_sQueueSample.m_nFrequency =
- 12 * m_sQueueSample.m_nFrequency / 10;
+ m_sQueueSample.m_nFrequency = 12 * m_sQueueSample.m_nFrequency / 10;
+ break;
+ default:
break;
- default: break;
}
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
@@ -6414,7 +6413,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6422,30 +6421,27 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
break;
case SOUND_FALL_LAND:
case SOUND_FALL_COLLAPSE:
- if(!ped->bIsLooking) {
+ if (!ped->bIsLooking) {
maxDist = SQR(30);
emittingVol = m_anRandomTable[3] % 20 + 80;
- if(ped->m_nSurfaceTouched == SURFACE_PUDDLE) {
- m_sQueueSample.m_nSampleIndex =
- (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
- } else if(sound == SOUND_FALL_LAND) {
+ if (ped->m_nSurfaceTouched == SURFACE_PUDDLE) {
+ m_sQueueSample.m_nSampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
+ } else if (sound == SOUND_FALL_LAND) {
m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND;
} else {
m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND_AND_FALL;
}
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 1;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6454,7 +6450,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_PUNCH_33:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1;
m_sQueueSample.m_nFrequency = 18000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6466,7 +6462,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6474,7 +6470,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_KICK_34:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1;
m_sQueueSample.m_nFrequency = 16500;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6486,7 +6482,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6494,7 +6490,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_HEADBUTT_35:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1;
m_sQueueSample.m_nFrequency = 20000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6506,7 +6502,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6514,7 +6510,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_PUNCH_36:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2;
m_sQueueSample.m_nFrequency = 18000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6526,7 +6522,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6534,7 +6530,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_PUNCH_37:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2;
m_sQueueSample.m_nFrequency = 16500;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6546,7 +6542,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6554,7 +6550,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_CLOSE_PUNCH_38:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2;
m_sQueueSample.m_nFrequency = 20000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6566,7 +6562,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6574,7 +6570,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_PUNCH_39:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4;
m_sQueueSample.m_nFrequency = 18000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6586,7 +6582,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6594,7 +6590,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4;
m_sQueueSample.m_nFrequency = 16500;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6606,7 +6602,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6614,7 +6610,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_PUNCH_41:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4;
m_sQueueSample.m_nFrequency = 20000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6626,7 +6622,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6634,7 +6630,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_PUNCH_FROM_BEHIND_42:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5;
m_sQueueSample.m_nFrequency = 18000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6646,7 +6642,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6654,7 +6650,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_KNEE_OR_KICK_43:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5;
m_sQueueSample.m_nFrequency = 16500;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6666,7 +6662,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6674,7 +6670,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_FIGHT_KICK_44:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5;
m_sQueueSample.m_nFrequency = 20000;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound;
stereo = true;
++iSound;
@@ -6686,14 +6682,14 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 26 + 100;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
break;
case SOUND_WEAPON_BAT_ATTACK:
m_sQueueSample.m_nSampleIndex = SFX_BAT_HIT_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 22000;
@@ -6705,26 +6701,24 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
emittingVol = m_anRandomTable[2] % 20 + 100;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
- if(m_bDynamicAcousticModelingStatus)
+ if (m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bRequireReflection = true;
else
noReflection = true;
break;
case SOUND_WEAPON_SHOT_FIRED:
weapon = &ped->m_weapons[ped->m_currentWeapon];
- switch(weapon->m_eWeaponType) {
+ switch (weapon->m_eWeaponType) {
case WEAPONTYPE_COLT45:
m_sQueueSample.m_nSampleIndex = SFX_COLT45_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_COLT45_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COLT45_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 50.0f;
@@ -6733,23 +6727,21 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
emittingVol = m_anRandomTable[1] % 10 + 90;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
- if(m_bDynamicAcousticModelingStatus)
+ if (m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bRequireReflection = true;
else
noReflection = true;
break;
case WEAPONTYPE_UZI:
m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
@@ -6758,19 +6750,17 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[3] % 15 + 70;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
break;
case WEAPONTYPE_SHOTGUN:
m_sQueueSample.m_nSampleIndex = SFX_SHOTGUN_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_SHOTGUN_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOTGUN_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
@@ -6779,23 +6769,21 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
emittingVol = m_anRandomTable[2] % 10 + 100;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
- if(m_bDynamicAcousticModelingStatus)
+ if (m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bRequireReflection = true;
else
noReflection = true;
break;
case WEAPONTYPE_AK47:
m_sQueueSample.m_nSampleIndex = SFX_AK47_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_AK47_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AK47_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
@@ -6804,19 +6792,17 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[1] % 15 + 70;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
break;
case WEAPONTYPE_M16:
m_sQueueSample.m_nSampleIndex = SFX_M16_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_M16_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_M16_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
@@ -6825,19 +6811,17 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[4] % 15 + 70;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
break;
case WEAPONTYPE_SNIPERRIFLE:
m_sQueueSample.m_nSampleIndex = SFX_SNIPER_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_SNIPER_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SNIPER_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
@@ -6846,23 +6830,21 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
emittingVol = m_anRandomTable[4] % 10 + 110;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
- if(m_bDynamicAcousticModelingStatus)
+ if (m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bRequireReflection = true;
else
noReflection = true;
break;
case WEAPONTYPE_ROCKETLAUNCHER:
m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_ROCKET_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 90.0f;
@@ -6871,53 +6853,47 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
emittingVol = m_anRandomTable[0] % 20 + 80;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
- if(m_bDynamicAcousticModelingStatus)
+ if (m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bRequireReflection = true;
else
noReflection = true;
break;
case WEAPONTYPE_FLAMETHROWER:
m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 9;
emittingVol = 90;
- m_sQueueSample.m_nFrequency =
- (10 * m_sQueueSample.m_nEntityIndex & 2047) +
- SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_LEFT);
+ m_sQueueSample.m_nFrequency = (10 * m_sQueueSample.m_nEntityIndex & 2047) + SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_LEFT);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
maxDist = 3600.f;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_bEmittingVolume = 90;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 90;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 6;
- if(m_bDynamicAcousticModelingStatus)
+ if (m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bRequireReflection = true;
else
noReflection = true;
break;
- default: continue;
+ default:
+ continue;
}
break;
case SOUND_WEAPON_RELOAD:
weapon = &ped->m_weapons[ped->m_currentWeapon];
- switch(weapon->m_eWeaponType) {
+ switch (weapon->m_eWeaponType) {
case WEAPONTYPE_COLT45:
m_sQueueSample.m_nSampleIndex = SFX_PISTOL_RELOAD;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_PISTOL_RELOAD) +
- RandomDisplacement(300);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PISTOL_RELOAD) + RandomDisplacement(300);
break;
case WEAPONTYPE_UZI:
m_sQueueSample.m_nSampleIndex = SFX_M16_RELOAD;
@@ -6929,31 +6905,28 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
break;
case WEAPONTYPE_AK47:
m_sQueueSample.m_nSampleIndex = SFX_AK47_RELOAD;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_AK47_RELOAD);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AK47_RELOAD);
break;
case WEAPONTYPE_M16:
m_sQueueSample.m_nSampleIndex = SFX_M16_RELOAD;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_M16_RELOAD);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_M16_RELOAD);
break;
case WEAPONTYPE_SNIPERRIFLE:
m_sQueueSample.m_nSampleIndex = SFX_RIFLE_RELOAD;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_RIFLE_RELOAD);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RIFLE_RELOAD);
break;
case WEAPONTYPE_ROCKETLAUNCHER:
m_sQueueSample.m_nSampleIndex = SFX_ROCKET_RELOAD;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_ROCKET_RELOAD);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_RELOAD);
break;
- default: continue;
+ default:
+ continue;
}
emittingVol = 75;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
m_sQueueSample.m_nFrequency += RandomDisplacement(300);
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
@@ -6961,7 +6934,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = 75;
+ m_sQueueSample.m_nEmittingVolume = 75;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -6970,13 +6943,11 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
case SOUND_WEAPON_UZI_BULLET_ECHO:
case SOUND_WEAPON_M16_BULLET_ECHO:
m_sQueueSample.m_nSampleIndex = SFX_UZI_END_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_UZI_END_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 4);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_END_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 80.0f;
@@ -6985,22 +6956,20 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
emittingVol = m_anRandomTable[4] % 10 + 40;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
- if(m_bDynamicAcousticModelingStatus)
+ if (m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bRequireReflection = true;
else
noReflection = true;
break;
case SOUND_WEAPON_FLAMETHROWER_FIRE:
m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_START_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_START_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 4);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_START_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = 60.0f;
@@ -7009,19 +6978,17 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
emittingVol = 70;
- m_sQueueSample.m_bEmittingVolume = 70;
+ m_sQueueSample.m_nEmittingVolume = 70;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
break;
case SOUND_WEAPON_HIT_PED:
m_sQueueSample.m_nSampleIndex = SFX_BULLET_PED;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_BULLET_PED);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 3);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BULLET_PED);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8);
m_sQueueSample.m_nReleasingVolumeModificator = 7;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 30.0f;
@@ -7030,13 +6997,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[0] % 20 + 90;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
break;
case SOUND_SPLASH:
m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iSound++;
stereo = true;
m_sQueueSample.m_nFrequency = RandomDisplacement(1400) + 20000;
@@ -7048,40 +7015,40 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_nLoopStart = 0;
emittingVol = m_anRandomTable[2] % 30 + 70;
m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true;
break;
- default: SetupPedComments(params, sound); continue;
+ default:
+ SetupPedComments(params, sound);
+ continue;
}
- if(stereo && iSound > 60) iSound = 21;
- if(params->m_fDistance < maxDist) {
+ if (stereo && iSound > 60)
+ iSound = 21;
+ if (params->m_fDistance < maxDist) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- if(noReflection) {
- if(0.2f * m_sQueueSample.m_fSoundIntensity <=
- m_sQueueSample.m_fDistance) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
+ if (noReflection) {
+ if (0.2f * m_sQueueSample.m_fSoundIntensity <= m_sQueueSample.m_fDistance) {
noReflection = 0;
} else {
m_sQueueSample.m_bIs2D = true;
- m_sQueueSample.m_bOffset = 0;
+ m_sQueueSample.m_nOffset = 0;
}
}
m_sQueueSample.m_bReverbFlag = true;
AddSampleToRequestedQueue();
- if(noReflection) {
- m_sQueueSample.m_bOffset = 127;
+ if (noReflection) {
+ m_sQueueSample.m_nOffset = 127;
++m_sQueueSample.m_nSampleIndex;
- if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex]
- .m_awAudioEvent[i] != SOUND_WEAPON_SHOT_FIRED ||
- weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) {
+ if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] != SOUND_WEAPON_SHOT_FIRED ||
+ weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) {
m_sQueueSample.m_nCounter = iSound++;
- if(iSound > 60) iSound = 21;
+ if (iSound > 60)
+ iSound = 21;
} else {
++m_sQueueSample.m_nCounter;
}
@@ -7096,15 +7063,16 @@ void
cAudioManager::ProcessPhysical(int32 id)
{
CPhysical *entity = (CPhysical *)m_asAudioEntities[id].m_pEntity;
- if(entity) {
- switch(entity->m_type) {
+ if (entity) {
+ switch (entity->GetType()) {
case ENTITY_TYPE_VEHICLE:
ProcessVehicle((CVehicle *)m_asAudioEntities[id].m_pEntity);
break;
case ENTITY_TYPE_PED:
ProcessPed((CPhysical *)m_asAudioEntities[id].m_pEntity);
break;
- default: return;
+ default:
+ return;
}
}
}
@@ -7112,10 +7080,16 @@ cAudioManager::ProcessPhysical(int32 id)
void
cAudioManager::ProcessPlane(cVehicleParams *params)
{
- switch(params->m_nIndex) {
- case AIRTRAIN: ProcessJumbo(params); break;
- case DEADDODO: ProcessCesna(params); break;
- default: debug("Plane Model Id is %d\n, ", params->m_pVehicle->m_modelIndex); break;
+ switch (params->m_nIndex) {
+ case AIRTRAIN:
+ ProcessJumbo(params);
+ break;
+ case DEADDODO:
+ ProcessCesna(params);
+ break;
+ default:
+ debug("Plane Model Id is %d\n, ", params->m_pVehicle->GetModelIndex());
+ break;
}
}
@@ -7129,82 +7103,81 @@ struct tVehicleSampleData {
uint8 m_bDoorType;
};
-const tVehicleSampleData aVehicleSettings[70] = {
- {SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 10928, 1},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, 2},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_ALARM_1, 8941, 0},
- {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_ALARM_1, 11922, 1},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 7948, 2},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 11556, 2},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_ALARM_1, 8941, 2},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_ALARM_1, 12220, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_3, 3, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 22295, SFX_CAR_ALARM_1, 12200, 1},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, 1},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, 2},
- {SFX_CAR_REV_3, 3, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 13600, 1},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 8795, 2},
- {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 16168, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_ALARM_1, 8000, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BUS2, 12345, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_2, 2, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_ALARM_1, 8543, 1},
- {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, 0},
- {SFX_CAR_REV_7, 7, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 10000, 0},
- {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 13596, 1},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 13000, 2},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 9935, 2},
- {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_ALARM_1, 10123, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 13596, 0},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_ALARM_1, 10554, 3},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 8000, 2},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, 2},
- {SFX_CAR_REV_1, 0, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, 3},
- {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CESNA_IDLE, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS, 16291, SFX_CAR_ALARM_1, 7500, 3},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_ALARM_1, 8935, 0},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 8935, 0},
- {SFX_CAR_REV_1, 0, SFX_CAR_HORN_PICKUP, 2000, SFX_CAR_ALARM_1, 17000, 0},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_ALARM_1, 9935, 1},
- {SFX_CAR_REV_7, 7, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_7, 7, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 2},
- {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 20143, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9000, 0},
- {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, 2},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, 2},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, 1},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
- {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0}};
+const tVehicleSampleData aVehicleSettings[70] = {{SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 10928, 1},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, 2},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_ALARM_1, 8941, 0},
+ {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_ALARM_1, 11922, 1},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 7948, 2},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 11556, 2},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_ALARM_1, 8941, 2},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_ALARM_1, 12220, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_3, 3, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 22295, SFX_CAR_ALARM_1, 12200, 1},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, 1},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, 2},
+ {SFX_CAR_REV_3, 3, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 13600, 1},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 8795, 2},
+ {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 16168, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_ALARM_1, 8000, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BUS2, 12345, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_2, 2, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_ALARM_1, 8543, 1},
+ {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, 0},
+ {SFX_CAR_REV_7, 7, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 10000, 0},
+ {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 13596, 1},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 13000, 2},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 9935, 2},
+ {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_ALARM_1, 10123, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 13596, 0},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_ALARM_1, 10554, 3},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 8000, 2},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, 2},
+ {SFX_CAR_REV_1, 0, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, 3},
+ {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CESNA_IDLE, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS, 16291, SFX_CAR_ALARM_1, 7500, 3},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_ALARM_1, 8935, 0},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 8935, 0},
+ {SFX_CAR_REV_1, 0, SFX_CAR_HORN_PICKUP, 2000, SFX_CAR_ALARM_1, 17000, 0},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_ALARM_1, 9935, 1},
+ {SFX_CAR_REV_7, 7, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_7, 7, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 2},
+ {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 20143, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9000, 0},
+ {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, 2},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, 2},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, 1},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0},
+ {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, 0}};
void
cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile)
{
- static int32 GearFreqAdj[] = { 6000, 6000, 3400, 1200, 0, -1000 };
+ static int32 GearFreqAdj[] = {6000, 6000, 3400, 1200, 0, -1000};
cTransmission *transmission;
float velocityChange;
@@ -7238,7 +7211,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
lostTraction = 0;
processedAccelSampleStopped = 0;
- if(bPlayerJustEnteredCar) {
+ if (bPlayerJustEnteredCar) {
bAccelSampleStopped = true;
bPlayerJustEnteredCar = false;
nCruising = 0;
@@ -7248,12 +7221,12 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
bHandbrakeOnLastFrame = 0;
CurrentPretendGear = 1;
}
- if(CReplay::IsPlayingBack()) {
+ if (CReplay::IsPlayingBack()) {
accelerateState = 255.f * Max(0.0f, Min(1.0f, automobile->m_fGasPedal));
} else {
accelerateState = Pads->GetAccelerate();
}
- channelUsed = SampleManager.GetChannelUsedFlag(m_bActiveSamples);
+ channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples);
transmission = params->m_pTransmission;
velocityChange = params->m_fVelocityChange;
relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity;
@@ -7262,76 +7235,70 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
gasPedalAudio = accelerationMultipler;
currentGear = params->m_pVehicle->m_nCurrentGear;
- if(transmission->nDriveType == '4') {
+ if (transmission->nDriveType == '4') {
wheelInUseCounter = 0;
- for(uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
- if(automobile->m_aWheelState[i]) ++wheelInUseCounter;
+ for (uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
+ if (automobile->m_aWheelState[i])
+ ++wheelInUseCounter;
}
- if(wheelInUseCounter > 2) lostTraction = 1;
- } else if(transmission->nDriveType == 'F') {
- if((automobile->m_aWheelState[0] || automobile->m_aWheelState[2]) &&
- (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) {
+ if (wheelInUseCounter > 2)
+ lostTraction = 1;
+ } else if (transmission->nDriveType == 'F') {
+ if ((automobile->m_aWheelState[0] || automobile->m_aWheelState[2]) && (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) {
lostTraction = 1;
}
- } else if(transmission->nDriveType == 'R' &&
- (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) {
+ } else if (transmission->nDriveType == 'R' && (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) {
lostTraction = 1;
}
- if(0.0f != velocityChange) {
+ if (0.0f != velocityChange) {
time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange;
- if(time <= 0.0f) {
+ if (time <= 0.0f) {
freqModifier = Max(-0.2f, time) * -15000.f;
} else {
freqModifier = -(Min(0.2f, time) * 15000.f);
}
- if(params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier;
+ if (params->m_fVelocityChange < -0.001f)
+ freqModifier = -freqModifier;
} else {
freqModifier = 0;
}
engineSoundType = aVehicleSettings[params->m_nIndex].m_bEngineSoundType;
soundOffset = 3 * (engineSoundType - 1);
- if(accelerateState <= 0) {
- if(params->m_fVelocityChange < -0.001f) {
- if(channelUsed) {
- SampleManager.StopChannel(m_bActiveSamples);
+ if (accelerateState <= 0) {
+ if (params->m_fVelocityChange < -0.001f) {
+ if (channelUsed) {
+ SampleManager.StopChannel(m_nActiveSamples);
bAccelSampleStopped = true;
}
- if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn ||
- lostTraction) {
+ if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) {
gasPedalAudio = automobile->m_fGasPedalAudio;
} else {
- gasPedalAudio =
- Min(1.0f, params->m_fVelocityChange /
- params->m_pTransmission->fMaxReverseVelocity);
+ gasPedalAudio = Min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity);
}
gasPedalAudio = Max(0.0f, gasPedalAudio);
automobile->m_fGasPedalAudio = gasPedalAudio;
- } else if(LastAccel > 0) {
- if(channelUsed) {
- SampleManager.StopChannel(m_bActiveSamples);
+ } else if (LastAccel > 0) {
+ if (channelUsed) {
+ SampleManager.StopChannel(m_nActiveSamples);
bAccelSampleStopped = true;
}
nCruising = 0;
- if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn ||
- lostTraction ||
- params->m_fVelocityChange >= 0.01f &&
- automobile->m_fGasPedalAudio > 0.2f) {
+ if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction ||
+ params->m_fVelocityChange >= 0.01f && automobile->m_fGasPedalAudio > 0.2f) {
automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.6f;
gasPedalAudio = automobile->m_fGasPedalAudio;
}
- if(gasPedalAudio > 0.05f) {
+ if (gasPedalAudio > 0.05f) {
freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000;
- if(engineSoundType == 6) freq /= 2;
- AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) +
- 40,
- freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1),
- engineSoundType, 63, 0);
+ if (engineSoundType == 6)
+ freq /= 2;
+ AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63, 0);
}
}
freq = (10000.f * gasPedalAudio) + 22050;
- if(engineSoundType == 6) freq >>= 1;
- AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq,
- (engineSoundType + SFX_CAR_REV_10), 0, 52, 1);
+ if (engineSoundType == 6)
+ freq /= 2;
+ AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType + SFX_CAR_REV_10), 0, 52, 1);
CurrentPretendGear = Max(1, currentGear);
LastAccel = accelerateState;
@@ -7340,20 +7307,13 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
bLostTractionLastFrame = lostTraction;
return;
}
- if(!nCruising) {
- if(accelerateState < 150 || !automobile->m_nWheelsOnGround ||
- automobile->bIsHandbrakeOn || lostTraction ||
- currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio <
- 0.01f) { // here could be used abs
- if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn ||
- lostTraction) {
- if(!automobile->m_nWheelsOnGround &&
- automobile->m_nDriveWheelsOnGround ||
- (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame ||
- lostTraction && !bLostTractionLastFrame) &&
- automobile->m_nWheelsOnGround) {
- automobile->m_fGasPedalAudio =
- automobile->m_fGasPedalAudio * 0.6f;
+ if (!nCruising) {
+ if (accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction ||
+ currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs
+ if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) {
+ if (!automobile->m_nWheelsOnGround && automobile->m_nDriveWheelsOnGround ||
+ (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround) {
+ automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.6f;
}
freqModifier = 0;
baseFreq = (15000.f * automobile->m_fGasPedalAudio) + 14000;
@@ -7364,9 +7324,10 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
automobile->m_fGasPedalAudio = accelerationMultipler;
}
freq = freqModifier + baseFreq;
- if(engineSoundType == 6) freq /= 2;
- if(channelUsed) {
- SampleManager.StopChannel(m_bActiveSamples);
+ if (engineSoundType == 6)
+ freq /= 2;
+ if (channelUsed) {
+ SampleManager.StopChannel(m_nActiveSamples);
bAccelSampleStopped = true;
}
AddPlayerCarSample(vol, freq, (engineSoundType + SFX_PHONE_RING), 0, 2, 1);
@@ -7377,29 +7338,28 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
return;
}
TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
- if(bAccelSampleStopped) {
- if(CurrentPretendGear != 1 || currentGear != 2) {
+ if (bAccelSampleStopped) {
+ if (CurrentPretendGear != 1 || currentGear != 2) {
gearNr = currentGear - 1;
- if(gearNr < 1) gearNr = 1;
+ if (gearNr < 1)
+ gearNr = 1;
CurrentPretendGear = gearNr;
}
processedAccelSampleStopped = 1;
bAccelSampleStopped = false;
}
- if(channelUsed) {
- SampleManager.SetChannelEmittingVolume(m_bActiveSamples, 85);
- SampleManager.SetChannel3DPosition(m_bActiveSamples, pos.x, pos.y, pos.z);
- SampleManager.SetChannel3DDistances(m_bActiveSamples, 50.f, 12.5f);
- if(engineSoundType == 6)
- freq =
- (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050) >> 1;
+ if (channelUsed) {
+ SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85);
+ SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z);
+ SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f);
+ if (engineSoundType == 6)
+ freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050) / 2;
else
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
- SampleManager.SetChannelFrequency(m_bActiveSamples, freq);
- if(!channelUsed) {
- SampleManager.SetChannelReverbFlag(
- m_bActiveSamples, m_bDynamicAcousticModelingStatus != 0);
- SampleManager.StartChannel(m_bActiveSamples);
+ SampleManager.SetChannelFrequency(m_nActiveSamples, freq);
+ if (!channelUsed) {
+ SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != 0);
+ SampleManager.StartChannel(m_nActiveSamples);
}
LastAccel = accelerateState;
@@ -7407,22 +7367,21 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
bLostTractionLastFrame = lostTraction;
return;
}
- if(processedAccelSampleStopped) {
- if(!SampleManager.InitialiseChannel(m_bActiveSamples, soundOffset + 345, 0))
+ if (processedAccelSampleStopped) {
+ if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + 345, 0))
return;
- SampleManager.SetChannelLoopCount(m_bActiveSamples, 1);
- SampleManager.SetChannelLoopPoints(m_bActiveSamples, 0, -1);
- SampleManager.SetChannelEmittingVolume(m_bActiveSamples, 85);
- SampleManager.SetChannel3DPosition(m_bActiveSamples, pos.x, pos.y, pos.z);
- SampleManager.SetChannel3DDistances(m_bActiveSamples, 50.f, 12.5f);
+ SampleManager.SetChannelLoopCount(m_nActiveSamples, 1);
+ SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1);
+ SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85);
+ SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z);
+ SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f);
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
if (engineSoundType == 6)
freq /= 2;
- SampleManager.SetChannelFrequency(m_bActiveSamples, freq);
- if(!channelUsed) {
- SampleManager.SetChannelReverbFlag(
- m_bActiveSamples, m_bDynamicAcousticModelingStatus != 0);
- SampleManager.StartChannel(m_bActiveSamples);
+ SampleManager.SetChannelFrequency(m_nActiveSamples, freq);
+ if (!channelUsed) {
+ SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != 0);
+ SampleManager.StartChannel(m_nActiveSamples);
}
LastAccel = accelerateState;
@@ -7430,23 +7389,22 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
bLostTractionLastFrame = lostTraction;
return;
}
- if(CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) {
+ if (CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) {
++CurrentPretendGear;
- if(!SampleManager.InitialiseChannel(m_bActiveSamples, soundOffset + 345, 0))
+ if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + 345, 0))
return;
- SampleManager.SetChannelLoopCount(m_bActiveSamples, 1);
- SampleManager.SetChannelLoopPoints(m_bActiveSamples, 0, -1);
- SampleManager.SetChannelEmittingVolume(m_bActiveSamples, 85);
- SampleManager.SetChannel3DPosition(m_bActiveSamples, pos.x, pos.y, pos.z);
- SampleManager.SetChannel3DDistances(m_bActiveSamples, 50.f, 12.5f);
+ SampleManager.SetChannelLoopCount(m_nActiveSamples, 1);
+ SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1);
+ SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85);
+ SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z);
+ SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f);
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
- if(engineSoundType == 6)
+ if (engineSoundType == 6)
freq /= 2;
- SampleManager.SetChannelFrequency(m_bActiveSamples, freq);
- if(!channelUsed) {
- SampleManager.SetChannelReverbFlag(
- m_bActiveSamples, m_bDynamicAcousticModelingStatus != 0);
- SampleManager.StartChannel(m_bActiveSamples);
+ SampleManager.SetChannelFrequency(m_nActiveSamples, freq);
+ if (!channelUsed) {
+ SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != 0);
+ SampleManager.StartChannel(m_nActiveSamples);
}
LastAccel = accelerateState;
@@ -7457,20 +7415,20 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
nCruising = 1;
}
bAccelSampleStopped = true;
- if(accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn ||
- lostTraction || currentGear < params->m_pTransmission->nNumberOfGears - 1) {
+ if (accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction ||
+ currentGear < params->m_pTransmission->nNumberOfGears - 1) {
nCruising = 0;
} else {
- if(accelerateState >= 220 &&
- 0.001f + params->m_fVelocityChange < automobile->m_fVelocityChangeForAudio) {
- if(nCruising < 800) ++nCruising;
- } else if(nCruising > 3) {
+ if (accelerateState >= 220 && 0.001f + params->m_fVelocityChange < automobile->m_fVelocityChangeForAudio) {
+ if (nCruising < 800)
+ ++nCruising;
+ } else if (nCruising > 3) {
--nCruising;
}
freq = 27 * nCruising + freqModifier + 22050;
- if(engineSoundType == 6) freq /= 2;
- AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType,
- 64, 1);
+ if (engineSoundType == 6)
+ freq /= 2;
+ AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, 1);
}
LastAccel = accelerateState;
@@ -7489,41 +7447,38 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound)
static uint8 counter = 0;
- if(time > gCellNextTime) {
- switch(sound) {
+ if (time > gCellNextTime) {
+ switch (sound) {
case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityL;
break;
- default: return;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- if(m_FrameCounter & 1)
+ if (m_FrameCounter & 1)
sampleIndex = (m_anRandomTable[1] & 3) + SFX_FIGHT_1;
else
sampleIndex = (m_anRandomTable[3] & 1) + SFX_BAT_HIT_LEFT;
m_sQueueSample.m_nSampleIndex = sampleIndex;
emittingVol = m_anRandomTable[0] % 50 + 55;
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nCounter = counter++;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -7532,7 +7487,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound)
params.m_bDistanceCalculated = true;
params.m_fDistance = distSquared;
params.m_pPed = nil;
- SetupPedComments(&params, SOUND_8A);
+ SetupPedComments(&params, SOUND_INJURED_PED_MALE_PRISON);
}
gCellNextTime = time + 500 + m_anRandomTable[3] % 1500;
}
@@ -7548,69 +7503,64 @@ cAudioManager::ProcessPornCinema(uint8 sound)
int32 rand;
float distSquared;
- switch(sound) {
+ switch (sound) {
case SCRIPT_SOUND_PORN_CINEMA_1_S:
case SCRIPT_SOUND_MISTY_SEX_S:
m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
sample = SFX_PORN_1_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 20.0f;
break;
case SCRIPT_SOUND_PORN_CINEMA_1_L:
case SCRIPT_SOUND_MISTY_SEX_L:
m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
sample = SFX_PORN_1_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 80.0f;
break;
case SCRIPT_SOUND_PORN_CINEMA_2_S:
m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
sample = SFX_PORN_2_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 20.0f;
break;
case SCRIPT_SOUND_PORN_CINEMA_2_L:
m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
sample = SFX_PORN_2_GROAN_1;
m_sQueueSample.m_fSoundIntensity = 80.0f;
break;
case SCRIPT_SOUND_PORN_CINEMA_3_S:
m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_fSoundIntensity = 20.0f;
sample = SFX_PORN_3_GROAN_1;
break;
case SCRIPT_SOUND_PORN_CINEMA_3_L:
m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_fSoundIntensity = 80.0f;
sample = SFX_PORN_3_GROAN_1;
break;
- default: return;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- if(sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) {
- m_sQueueSample.m_bVolume =
- ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
+ if (sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) {
+ m_sQueueSample.m_nVolume = ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = maxVolume;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = maxVolume;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
@@ -7618,10 +7568,9 @@ cAudioManager::ProcessPornCinema(uint8 sound)
}
time = CTimer::GetTimeInMilliseconds();
- if(time > gPornNextTime) {
- m_sQueueSample.m_bVolume = ComputeVolume(
- 90, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (time > gPornNextTime) {
+ m_sQueueSample.m_nVolume = ComputeVolume(90, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
rand = m_anRandomTable[1] & 1;
m_sQueueSample.m_nSampleIndex = rand + sample;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
@@ -7648,50 +7597,42 @@ cAudioManager::ProcessProjectiles()
{
uint8 emittingVol;
- for(int32 i = 0; i < NUM_PROJECTILES; i++) {
- if(CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
- switch(CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
+ for (int32 i = 0; i < NUM_PROJECTILES; i++) {
+ if (CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
+ switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
case WEAPONTYPE_ROCKETLAUNCHER:
emittingVol = maxVolume;
m_sQueueSample.m_fSoundIntensity = rocketLauncherIntensity;
m_sQueueSample.m_nSampleIndex = SFX_ROCKET_FLY;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
break;
case WEAPONTYPE_MOLOTOV:
emittingVol = molotovVolume;
m_sQueueSample.m_fSoundIntensity = molotovIntensity;
m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- 32 * SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE) / 25;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = 32 * SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE) / 25;
m_sQueueSample.m_nReleasingVolumeModificator = 7;
break;
- default: return;
+ default:
+ return;
}
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
- m_sQueueSample.m_vecPos =
- CProjectileInfo::ms_apProjectile[i]->GetPosition();
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ m_sQueueSample.m_vecPos = CProjectileInfo::ms_apProjectile[i]->GetPosition();
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = i;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
@@ -7705,27 +7646,25 @@ cAudioManager::ProcessProjectiles()
void
cAudioManager::ProcessRainOnVehicle(cVehicleParams *params)
{
- if(params->m_fDistance < SQR(rainOnVehicleIntensity) && CWeather::Rain > 0.01f &&
- (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) {
+ if (params->m_fDistance < SQR(rainOnVehicleIntensity) && CWeather::Rain > 0.01f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) {
CVehicle *veh = params->m_pVehicle;
++veh->m_bRainAudioCounter;
- if(veh->m_bRainAudioCounter >= 2) {
+ if (veh->m_bRainAudioCounter >= 2) {
veh->m_bRainAudioCounter = 0;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
float emittingVol = 30.f * CWeather::Rain;
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVol, rainOnVehicleIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, rainOnVehicleIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = veh->m_bRainSamplesCounter++;
- if(veh->m_bRainSamplesCounter > 4) veh->m_bRainSamplesCounter = 68;
- m_sQueueSample.m_nSampleIndex =
- (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ if (veh->m_bRainSamplesCounter > 4)
+ veh->m_bRainSamplesCounter = 68;
+ m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 9;
m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000;
m_sQueueSample.m_nLoopCount = 1;
- m_sQueueSample.m_bEmittingVolume = (uint8)emittingVol;
+ m_sQueueSample.m_nEmittingVolume = (uint8)emittingVol;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
@@ -7742,16 +7681,16 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params)
void
cAudioManager::ProcessReverb() const
{
- if(SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) {
- for(uint32 i = 0; i <
+ if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) {
+ for (uint32 i = 0; i <
#ifdef FIX_BUGS
- channels
+ channels
#else
- 28
+ 28
#endif
- ;
- i++) {
- if(m_asActiveSamples[i].m_bReverbFlag)
+ ;
+ i++) {
+ if (m_asActiveSamples[i].m_bReverbFlag)
SampleManager.SetChannelReverbFlag(i, 1);
}
}
@@ -7765,41 +7704,38 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params)
int32 emittingVol;
float modificator;
- if(params->m_fDistance >= SQR(reverseGearIntensity)) return false;
+ if (params->m_fDistance >= SQR(reverseGearIntensity))
+ return false;
veh = params->m_pVehicle;
- if(veh->bEngineOn && (veh->m_fGasPedal < 0.0f || !veh->m_nCurrentGear)) {
+ if (veh->bEngineOn && (veh->m_fGasPedal < 0.0f || !veh->m_nCurrentGear)) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
automobile = (CAutomobile *)params->m_pVehicle;
- if(automobile->m_nWheelsOnGround) {
- modificator = params->m_fVelocityChange /
- params->m_pTransmission->fMaxReverseVelocity;
+ if (automobile->m_nWheelsOnGround) {
+ modificator = params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity;
} else {
- if(automobile->m_nDriveWheelsOnGround)
+ if (automobile->m_nDriveWheelsOnGround)
automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.4f;
modificator = automobile->m_fGasPedalAudio;
}
modificator = Abs(modificator);
emittingVol = (24.f * modificator);
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- if(params->m_pVehicle->m_fGasPedal >= 0.0f) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
+ if (params->m_pVehicle->m_fGasPedal >= 0.0f) {
m_sQueueSample.m_nCounter = 62;
m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR_2;
} else {
m_sQueueSample.m_nCounter = 61;
m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR;
}
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 3.0f;
m_sQueueSample.m_fSoundIntensity = reverseGearIntensity;
m_sQueueSample.m_bReleasingSoundFlag = false;
@@ -7818,47 +7754,42 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound)
uint32 time;
float distSquared;
- switch(sound) {
+ switch (sound) {
case SCRIPT_SOUND_SAWMILL_LOOP_S:
case SCRIPT_SOUND_SAWMILL_LOOP_L:
m_sQueueSample.m_fSoundIntensity = scriptObjectIntensityS;
break;
- default: return;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_SAWMILL_LOOP);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SAWMILL_LOOP);
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = 30;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 30;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
time = CTimer::GetTimeInMilliseconds();
- if(time > gSawMillNextTime) {
- m_sQueueSample.m_bVolume = ComputeVolume(
- 70, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (time > gSawMillNextTime) {
+ m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_CUT_WOOD;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nCounter = 1;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
@@ -7880,9 +7811,9 @@ void
cAudioManager::ProcessScriptObject(int32 id)
{
cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity;
- if(entity) {
+ if (entity) {
m_sQueueSample.m_vecPos = entity->Posn;
- if(m_asAudioEntities[id].m_AudioEvents == 1)
+ if (m_asAudioEntities[id].m_AudioEvents == 1)
ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]);
else
ProcessLoopingScriptObject(entity->AudioId);
@@ -7896,53 +7827,50 @@ cAudioManager::ProcessShopScriptObject(uint8 sound)
int32 rand;
float distSquared;
- switch(sound) {
+ switch (sound) {
case SCRIPT_SOUND_SHOP_LOOP_S:
- case SCRIPT_SOUND_SHOP_LOOP_L: m_sQueueSample.m_fSoundIntensity = 30.0f; break;
- default: return;
+ case SCRIPT_SOUND_SHOP_LOOP_L:
+ m_sQueueSample.m_fSoundIntensity = 30.0f;
+ break;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_SHOP_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_SHOP_LOOP);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOP_LOOP);
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = 30;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 30;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
time = CTimer::GetTimeInMilliseconds();
- if(time > gShopNextTime) {
- m_sQueueSample.m_bVolume = ComputeVolume(
- 70, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (time > gShopNextTime) {
+ m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
rand = m_anRandomTable[1] & 1;
m_sQueueSample.m_nSampleIndex = rand + SFX_SHOP_TILL_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nCounter = rand + 1;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = 70;
+ m_sQueueSample.m_nEmittingVolume = 70;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = true;
@@ -7957,23 +7885,22 @@ cAudioManager::ProcessShopScriptObject(uint8 sound)
void
cAudioManager::ProcessSpecial()
{
- if(m_bUserPause) {
- if(!m_bPreviousUserPause) {
+ if (m_nUserPause) {
+ if (!m_nPreviousUserPause) {
MusicManager.ChangeMusicMode(MUSICMODE_FRONTEND);
SampleManager.SetEffectsFadeVolume(maxVolume);
SampleManager.SetMusicFadeVolume(maxVolume);
}
} else {
- if(m_bPreviousUserPause) {
+ if (m_nPreviousUserPause) {
MusicManager.StopFrontEndTrack();
MusicManager.ChangeMusicMode(MUSICMODE_GAME);
}
CPlayerPed *playerPed = FindPlayerPed();
- if(playerPed) {
+ if (playerPed) {
const PedState &state = playerPed->m_nPedState;
- if(state != PED_ENTER_CAR && state != PED_STEAL_CAR &&
- !playerPed->bInVehicle)
- SampleManager.StopChannel(m_bActiveSamples);
+ if (state != PED_ENTER_CAR && state != PED_STEAL_CAR && !playerPed->bInVehicle)
+ SampleManager.StopChannel(m_nActiveSamples);
}
}
}
@@ -7981,37 +7908,35 @@ cAudioManager::ProcessSpecial()
bool
cAudioManager::ProcessTrainNoise(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 300.0f;
+
CTrain *train;
uint8 emittingVol;
float speedMultipler;
- if(params->m_fDistance >= 90000.f) return false;
+ if (params->m_fDistance >= SQR(SOUND_INTENSITY))
+ return false;
- if(params->m_fVelocityChange > 0.0f) {
+ if (params->m_fVelocityChange > 0.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
train = (CTrain *)params->m_pVehicle;
speedMultipler = Min(1.0f, train->m_fSpeed * 250.f / 51.f);
emittingVol = (75.f * speedMultipler);
- if(train->m_fWagonPosition == 0.0f) {
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 300.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (train->m_fWagonPosition == 0.0f) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 32;
m_sQueueSample.m_nSampleIndex = SFX_TRAIN_FAR;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 2;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_TRAIN_FAR);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_FAR);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 3.0f;
- m_sQueueSample.m_fSoundIntensity = 300.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bReverbFlag = true;
@@ -8019,27 +7944,22 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params)
AddSampleToRequestedQueue();
}
}
- if(params->m_fDistance < 4900.f) {
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 70.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ const float SOUND_INTENSITY = 70.0f;
+ if (params->m_fDistance < SQR(SOUND_INTENSITY)) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 33;
m_sQueueSample.m_nSampleIndex = SFX_TRAIN_NEAR;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_TRAIN_NEAR) +
- 100 * m_sQueueSample.m_nEntityIndex % 987;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_NEAR) + 100 * m_sQueueSample.m_nEntityIndex % 987;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
- m_sQueueSample.m_fSoundIntensity = 70.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bReverbFlag = true;
@@ -8060,57 +7980,58 @@ cAudioManager::ProcessVehicle(CVehicle *veh)
m_sQueueSample.m_vecPos = veh->GetPosition();
params.m_bDistanceCalculated = false;
- params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
params.m_pVehicle = veh;
params.m_pTransmission = nil;
params.m_nIndex = 0;
params.m_fVelocityChange = 0.0f;
- if(handling) params.m_pTransmission = &handling->Transmission;
+ if (handling)
+ params.m_pTransmission = &handling->Transmission;
- params.m_nIndex = veh->m_modelIndex - 90;
- if(params.m_pVehicle->m_status == STATUS_SIMPLE)
+ params.m_nIndex = veh->GetModelIndex() - MI_FIRST_VEHICLE;
+ if (params.m_pVehicle->GetStatus() == STATUS_SIMPLE)
velChange = params.m_pVehicle->AutoPilot.m_fMaxTrafficSpeed * 0.02f;
else
- velChange =
- DotProduct(params.m_pVehicle->m_vecMoveSpeed, params.m_pVehicle->GetForward());
+ velChange = DotProduct(params.m_pVehicle->m_vecMoveSpeed, params.m_pVehicle->GetForward());
params.m_fVelocityChange = velChange;
- switch(params.m_pVehicle->m_vehType) {
+ switch (params.m_pVehicle->m_vehType) {
case VEHICLE_TYPE_CAR:
UpdateGasPedalAudio((CAutomobile *)veh);
- if(params.m_nIndex == RCBANDIT) {
+ if (params.m_nIndex == RCBANDIT) {
ProcessModelCarEngine(&params);
ProcessVehicleOneShots(&params);
((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange;
ProcessRainOnVehicle(&params);
break;
}
- if(params.m_nIndex == DODO) {
- if(!ProcessVehicleRoadNoise(&params)) {
+ if (params.m_nIndex == DODO) {
+ if (!ProcessVehicleRoadNoise(&params)) {
ProcessVehicleOneShots(&params);
- ((CAutomobile *)veh)->m_fVelocityChangeForAudio =
- params.m_fVelocityChange;
+ ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange;
ProcessRainOnVehicle(&params);
break;
}
- if(CWeather::WetRoads > 0.f) ProcessWetRoadNoise(&params);
+ if (CWeather::WetRoads > 0.f)
+ ProcessWetRoadNoise(&params);
ProcessVehicleSkidding(&params);
} else {
- if(!ProcessVehicleRoadNoise(&params)) {
+ if (!ProcessVehicleRoadNoise(&params)) {
ProcessVehicleOneShots(&params);
- ((CAutomobile *)veh)->m_fVelocityChangeForAudio =
- params.m_fVelocityChange;
+ ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange;
ProcessRainOnVehicle(&params);
break;
}
ProcessReverseGear(&params);
- if(CWeather::WetRoads > 0.f) ProcessWetRoadNoise(&params);
+ if (CWeather::WetRoads > 0.f)
+ ProcessWetRoadNoise(&params);
ProcessVehicleSkidding(&params);
ProcessVehicleHorn(&params);
ProcessVehicleSirenOrAlarm(&params);
- if(UsesReverseWarning(params.m_nIndex))
+ if (UsesReverseWarning(params.m_nIndex))
ProcessVehicleReverseWarning(&params);
- if(HasAirBrakes(params.m_nIndex)) ProcessAirBrakes(&params);
+ if (HasAirBrakes(params.m_nIndex))
+ ProcessAirBrakes(&params);
}
ProcessCarBombTick(&params);
ProcessVehicleEngine(&params);
@@ -8141,48 +8062,48 @@ cAudioManager::ProcessVehicle(CVehicle *veh)
ProcessVehicleOneShots(&params);
ProcessRainOnVehicle(&params);
break;
- default: ProcessRainOnVehicle(&params); break;
+ default:
+ ProcessRainOnVehicle(&params);
+ break;
}
}
bool
cAudioManager::ProcessVehicleDoors(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 40.0f;
+
CAutomobile *automobile;
int8 doorState;
int32 emittingVol;
float velocity;
- if(params->m_fDistance >= 1600.f) return false;
+ if (params->m_fDistance >= SQR(SOUND_INTENSITY))
+ return false;
automobile = (CAutomobile *)params->m_pVehicle;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- for(int32 i = 0; i < ARRAY_SIZE(automobile->Doors); i++) {
- if(automobile->Damage.GetDoorStatus(i) == DOOR_STATUS_SWINGING) {
+ for (int32 i = 0; i < ARRAY_SIZE(automobile->Doors); i++) {
+ if (automobile->Damage.GetDoorStatus(i) == DOOR_STATUS_SWINGING) {
doorState = automobile->Doors[i].m_nDoorState;
- if(doorState == DOOR_STATUS_SMASHED || doorState == DOOR_STATUS_SWINGING) {
+ if (doorState == DOOR_STATUS_SMASHED || doorState == DOOR_STATUS_SWINGING) {
velocity = Min(0.3f, Abs(automobile->Doors[i].m_fAngVel));
- if(velocity > 0.0035f) {
+ if (velocity > 0.0035f) {
emittingVol = (100.f * velocity * 10.f / 3.f);
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVol, 40.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = i + 6;
- m_sQueueSample.m_nSampleIndex =
- m_anRandomTable[1] % 6 + SFX_COL_CAR_PANEL_1;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(
- m_sQueueSample.m_nSampleIndex) +
- RandomDisplacement(1000);
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nSampleIndex = m_anRandomTable[1] % 6 + SFX_COL_CAR_PANEL_1;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) + RandomDisplacement(1000);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 10;
m_sQueueSample.m_nLoopCount = 1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_fSpeedMultiplier = 1.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = true;
@@ -8198,13 +8119,14 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params)
void
cAudioManager::ProcessVehicleEngine(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 50.0f;
+
CVehicle *playerVeh;
CVehicle *veh;
CAutomobile *automobile;
float relativeGearChange;
float relativeChange;
uint8 volume;
- eSfxSample accelerationSample;
int32 freq = 0; // uinitialized variable
uint8 emittingVol;
cTransmission *transmission;
@@ -8212,167 +8134,128 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params)
float modificator;
float traction = 0.f;
- if(params->m_fDistance < SQR(50.f)) {
+ if (params->m_fDistance < SQR(SOUND_INTENSITY)) {
playerVeh = FindPlayerVehicle();
veh = params->m_pVehicle;
- if(playerVeh == veh && veh->m_status == STATUS_WRECKED) {
- SampleManager.StopChannel(m_bActiveSamples);
+ if (playerVeh == veh && veh->GetStatus() == STATUS_WRECKED) {
+ SampleManager.StopChannel(m_nActiveSamples);
return;
}
- if(veh->bEngineOn) {
+ if (veh->bEngineOn) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
automobile = (CAutomobile *)params->m_pVehicle;
- if(params->m_nIndex == DODO) {
+ if (params->m_nIndex == DODO) {
ProcessCesna(params);
return;
}
- if(FindPlayerVehicle() == veh) {
+ if (FindPlayerVehicle() == veh) {
ProcessPlayersVehicleEngine(params, automobile);
return;
}
transmission = params->m_pTransmission;
- if(transmission) {
+ if (transmission) {
currentGear = params->m_pVehicle->m_nCurrentGear;
- if(automobile->m_nWheelsOnGround) {
- if(automobile->bIsHandbrakeOn) {
- if(params->m_fVelocityChange == 0.0f)
+ if (automobile->m_nWheelsOnGround) {
+ if (automobile->bIsHandbrakeOn) {
+ if (params->m_fVelocityChange == 0.0f)
traction = 0.9f;
- } else if(params->m_pVehicle->m_status == STATUS_SIMPLE) {
+ } else if (params->m_pVehicle->GetStatus() == STATUS_SIMPLE) {
traction = 0.0f;
} else {
- switch(transmission->nDriveType) {
+ switch (transmission->nDriveType) {
case '4':
- for(int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
- if(automobile->m_aWheelState[i] == WHEEL_STATE_SPINNING)
+ for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
+ if (automobile->m_aWheelState[i] == WHEEL_STATE_SPINNING)
traction += 0.05f;
}
break;
case 'F':
- if(automobile->m_aWheelState[0] == WHEEL_STATE_SPINNING)
+ if (automobile->m_aWheelState[0] == WHEEL_STATE_SPINNING)
traction += 0.1f;
- if(automobile->m_aWheelState[2] == WHEEL_STATE_SPINNING)
+ if (automobile->m_aWheelState[2] == WHEEL_STATE_SPINNING)
traction += 0.1f;
break;
case 'R':
- if(automobile->m_aWheelState[1] == WHEEL_STATE_SPINNING)
+ if (automobile->m_aWheelState[1] == WHEEL_STATE_SPINNING)
traction += 0.1f;
- if(automobile->m_aWheelState[3] == WHEEL_STATE_SPINNING)
+ if (automobile->m_aWheelState[3] == WHEEL_STATE_SPINNING)
traction += 0.1f;
break;
}
}
- if(transmission->fMaxVelocity <= 0.f) {
+ if (transmission->fMaxVelocity <= 0.f) {
relativeChange = 0.f;
- } else if(currentGear) {
- relativeGearChange = Min(1.0f, (params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f);
- if(traction == 0.0f && automobile->m_status != STATUS_SIMPLE && params->m_fVelocityChange >= transmission->Gears[1].fShiftUpVelocity) {
+ } else if (currentGear) {
+ relativeGearChange =
+ Min(1.0f, (params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f);
+ if (traction == 0.0f && automobile->GetStatus() != STATUS_SIMPLE &&
+ params->m_fVelocityChange >= transmission->Gears[1].fShiftUpVelocity) {
traction = 0.7f;
}
relativeChange = traction * automobile->m_fGasPedalAudio * 0.95f + (1.0f - traction) * relativeGearChange;
} else
- relativeChange = Min(1.0f, 1.0f - Abs((params->m_fVelocityChange - transmission->Gears[0].fShiftDownVelocity) / transmission->fMaxReverseVelocity));
+ relativeChange =
+ Min(1.0f, 1.0f - Abs((params->m_fVelocityChange - transmission->Gears[0].fShiftDownVelocity) / transmission->fMaxReverseVelocity));
} else {
- if(automobile->m_nDriveWheelsOnGround)
+ if (automobile->m_nDriveWheelsOnGround)
automobile->m_fGasPedalAudio *= 0.4f;
relativeChange = automobile->m_fGasPedalAudio;
}
modificator = relativeChange;
- if(currentGear || !automobile->m_nWheelsOnGround)
+ if (currentGear || !automobile->m_nWheelsOnGround)
freq = 1200 * currentGear + 18000.f * modificator + 14000;
else
freq = 13000.f * modificator + 14000;
- if(modificator >= 0.75f) {
+ if (modificator >= 0.75f) {
emittingVol = 120;
- volume =
- ComputeVolume(120, 50.f, m_sQueueSample.m_fDistance);
+ volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
} else {
emittingVol = modificator * 4.0f / 3.0f * 40.f + 80.f;
- volume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance);
+ volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
}
} else {
modificator = 0.f;
emittingVol = 80;
- volume = ComputeVolume(80, 50.f, m_sQueueSample.m_fDistance);
+ volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
}
- m_sQueueSample.m_bVolume = volume;
- if(m_sQueueSample.m_bVolume) {
- if(automobile->m_status == STATUS_SIMPLE) {
- if(modificator < 0.02f) {
- m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_bEngineSoundType + SFX_CAR_REV_10;
- freq = 10000.f * modificator + 22050;
+ m_sQueueSample.m_nVolume = volume;
+ if (m_sQueueSample.m_nVolume) {
+ if (automobile->GetStatus() == STATUS_SIMPLE) {
+ if (modificator < 0.02f) {
+ m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_bEngineSoundType - 1 + SFX_CAR_IDLE_1;
+ freq = modificator * 10000 + 22050;
m_sQueueSample.m_nCounter = 52;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_bIs2D = false;
- m_sQueueSample.m_nReleasingVolumeModificator = 3;
- m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000;
- if(m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_6 || m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_6)
- m_sQueueSample.m_nFrequency /= 2;
- m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_fSpeedMultiplier = 6.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
- m_sQueueSample.m_bReleasingSoundFlag = false;
- m_sQueueSample.m_nReleasingVolumeDivider = 8;
- m_sQueueSample.m_bReverbFlag = true;
- m_sQueueSample.m_bRequireReflection = false;
- AddSampleToRequestedQueue();
- return;
+ } else {
+ m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex;
+ m_sQueueSample.m_nCounter = 2;
}
- accelerationSample =
- aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex;
} else {
- if(automobile->m_fGasPedal < 0.05f) {
- m_sQueueSample.m_nSampleIndex =
- aVehicleSettings[params->m_nIndex].m_bEngineSoundType +
- SFX_CAR_REV_10; // to recheck idle sounds start
- // 1 postion later
- freq = 10000.f * modificator + 22050;
+ if (automobile->m_fGasPedal < 0.05f) {
+ m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_bEngineSoundType - 1 + SFX_CAR_IDLE_1;
+ freq = modificator * 10000 + 22050;
m_sQueueSample.m_nCounter = 52;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_bIs2D = false;
- m_sQueueSample.m_nReleasingVolumeModificator = 3;
- m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000;
- if(m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_6 ||
- m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_6)
- m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency >> 1;
- m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset( m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_fSpeedMultiplier = 6.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
- m_sQueueSample.m_bReleasingSoundFlag = false;
- m_sQueueSample.m_nReleasingVolumeDivider = 8;
- m_sQueueSample.m_bReverbFlag = true;
- m_sQueueSample.m_bRequireReflection = false;
- AddSampleToRequestedQueue();
- return;
+ } else {
+ m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex;
+ m_sQueueSample.m_nCounter = 2;
}
- accelerationSample = aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex;
}
- m_sQueueSample.m_nSampleIndex = accelerationSample;
- m_sQueueSample.m_nCounter = 2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000;
- if(m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_6 ||
- m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_6)
+ if (m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_6 || m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_6)
m_sQueueSample.m_nFrequency /= 2;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 8;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
- return;
}
}
}
@@ -8381,49 +8264,37 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params)
void
cAudioManager::ProcessVehicleHorn(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 40.0f;
+
CAutomobile *automobile;
- if(params->m_fDistance < 1600.f) {
+ if (params->m_fDistance < SQR(SOUND_INTENSITY)) {
automobile = (CAutomobile *)params->m_pVehicle;
- if((!automobile->m_bSirenOrAlarm || !UsesSirenSwitching(params->m_nIndex)) &&
- automobile->m_modelIndex != MI_MRWHOOP) {
- if(automobile->m_nCarHornTimer) {
- if(params->m_pVehicle->m_status) {
- if(automobile->m_nCarHornTimer > 44)
- automobile->m_nCarHornTimer = 44;
- if(automobile->m_nCarHornTimer == 44)
- automobile->field_22D =
- (uint8(m_FrameCounter) +
- uint8(m_sQueueSample.m_nEntityIndex)) &
- 7;
- if(!hornPatternsArray[automobile->field_22D]
- [44 - automobile->m_nCarHornTimer])
+ if ((!automobile->m_bSirenOrAlarm || !UsesSirenSwitching(params->m_nIndex)) && automobile->GetModelIndex() != MI_MRWHOOP) {
+ if (automobile->m_nCarHornTimer) {
+ if (params->m_pVehicle->GetStatus() != STATUS_PLAYER) {
+ automobile->m_nCarHornTimer = Min(44, automobile->m_nCarHornTimer);
+ if (automobile->m_nCarHornTimer == 44)
+ automobile->m_nCarHornPattern = (m_FrameCounter + m_sQueueSample.m_nEntityIndex) & 7;
+ if (!hornPatternsArray[automobile->m_nCarHornPattern][44 - automobile->m_nCarHornTimer])
return;
}
- CalculateDistance(params->m_bDistanceCalculated,
- params->m_fDistance);
- m_sQueueSample.m_bVolume =
- ComputeVolume(80, 40.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
+ m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 4;
- m_sQueueSample.m_nSampleIndex =
- aVehicleSettings[params->m_nIndex].m_nHornSample;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nHornSample;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 2;
- m_sQueueSample.m_nFrequency =
- aVehicleSettings[params->m_nIndex].m_nHornFrequency;
+ m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nHornFrequency;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 80;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 80;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 5.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bReverbFlag = true;
@@ -8451,306 +8322,343 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params)
static uint8 iWheelIndex = 82;
static uint8 CrunchOffset = 0;
- for(int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) {
+ for (int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) {
noReflections = 0;
m_sQueueSample.m_bRequireReflection = false;
event = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i];
- switch(event) {
+ switch (event) {
case SOUND_CAR_DOOR_CLOSE_BONNET:
case SOUND_CAR_DOOR_CLOSE_BUMPER:
case SOUND_CAR_DOOR_CLOSE_FRONT_LEFT:
case SOUND_CAR_DOOR_CLOSE_FRONT_RIGHT:
case SOUND_CAR_DOOR_CLOSE_BACK_LEFT:
case SOUND_CAR_DOOR_CLOSE_BACK_RIGHT:
- maxDist = 2500.f;
+ {
+ const float SOUND_INTENSITY = 50.0f;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[2] % 5 + 122;
- switch(aVehicleSettings[params->m_nIndex].m_bDoorType) {
- case 0: m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_CLOSE; break;
- case 2: m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_CLOSE; break;
- case 3: m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break;
- default: m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_CLOSE; break;
+ switch (aVehicleSettings[params->m_nIndex].m_bDoorType) {
+ case 0:
+ m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_CLOSE;
+ break;
+ case 2:
+ m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_CLOSE;
+ break;
+ case 3:
+ m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES;
+ break;
+ default:
+ m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_CLOSE;
+ break;
}
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nCounter =
- m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 22;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 22;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bRequireReflection = true;
break;
+ }
case SOUND_CAR_DOOR_OPEN_BONNET:
case SOUND_CAR_DOOR_OPEN_BUMPER:
case SOUND_CAR_DOOR_OPEN_FRONT_LEFT:
case SOUND_CAR_DOOR_OPEN_FRONT_RIGHT:
case SOUND_CAR_DOOR_OPEN_BACK_LEFT:
case SOUND_CAR_DOOR_OPEN_BACK_RIGHT:
- maxDist = 2500.f;
+ {
+ const float SOUND_INTENSITY = 50.0f;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[1] % 10 + 117;
- switch(aVehicleSettings[params->m_nIndex].m_bDoorType) {
- case 0: m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_OPEN; break;
- case 2: m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_OPEN; break;
- case 3: m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break;
- default: m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_OPEN; break;
+ switch (aVehicleSettings[params->m_nIndex].m_bDoorType) {
+ case 0:
+ m_sQueueSample.m_nSampleIndex = SFX_OLD_CAR_DOOR_OPEN;
+ break;
+ case 2:
+ m_sQueueSample.m_nSampleIndex = SFX_TRUCK_DOOR_OPEN;
+ break;
+ case 3:
+ m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES;
+ break;
+ default:
+ m_sQueueSample.m_nSampleIndex = SFX_NEW_CAR_DOOR_OPEN;
+ break;
}
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nCounter =
- m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 10;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 10;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bRequireReflection = true;
break;
+ }
case SOUND_CAR_WINDSHIELD_CRACK:
- maxDist = 900.f;
+ {
+ const float SOUND_INTENSITY = 30.0f;
+ maxDist = SQR(SOUND_INTENSITY);
m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 68;
emittingVol = m_anRandomTable[1] % 30 + 60;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK);
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
- break;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ } break;
case SOUND_CAR_JUMP:
- emittingVol = Max(
- 80.f,
- 2 * (100.f *
- m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]));
- maxDist = 1225.f;
+ {
+ const float SOUND_INTENSITY = 35.0f;
+ emittingVol = Max(80.f, 2 * (100.f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]));
+ maxDist = SQR(SOUND_INTENSITY);
m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = iWheelIndex++;
- if(iWheelIndex > 85) iWheelIndex = 82;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_TYRE_BUMP);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 4);
- if(params->m_nIndex == 41) {
+ if (iWheelIndex > 85)
+ iWheelIndex = 82;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TYRE_BUMP);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
+ if (params->m_nIndex == 41) {
m_sQueueSample.m_nFrequency *= 2;
- emittingVol = emittingVol >> 1;
+ emittingVol /= 2;
}
m_sQueueSample.m_nReleasingVolumeModificator = 6;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 35.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
break;
+ }
case SOUND_CAR_ENGINE_START:
+ {
+ const float SOUND_INTENSITY = 40.0f;
emittingVol = 60;
- maxDist = 1600.f;
+ maxDist = SQR(SOUND_INTENSITY);
m_sQueueSample.m_nSampleIndex = SFX_CAR_STARTER;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 33;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_CAR_STARTER);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_STARTER);
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bRequireReflection = true;
break;
+ }
case SOUND_CAR_LIGHT_BREAK:
+ {
+ const float SOUND_INTENSITY = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_GLASS_SHARD_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 37;
- m_sQueueSample.m_nFrequency =
- 9 * SampleManager.GetSampleBaseFrequency(SFX_GLASS_SHARD_1) / 10;
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 3);
+ m_sQueueSample.m_nFrequency = 9 * SampleManager.GetSampleBaseFrequency(SFX_GLASS_SHARD_1) / 10;
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8);
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[4] % 10 + 30;
break;
+ }
case SOUND_CAR_HYDRAULIC_1:
case SOUND_CAR_HYDRAULIC_2:
- if(event == MOONBEAM) // todo check
+ {
+ const float SOUND_INTENSITY = 35.0f;
+ if (event == MOONBEAM) // todo check
m_sQueueSample.m_nFrequency = 15600;
else
m_sQueueSample.m_nFrequency = 13118;
m_sQueueSample.m_nSampleIndex = SFX_SUSPENSION_FAST_MOVE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 51;
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 3);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8);
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 35.0f;
- maxDist = 1225.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[0] % 15 + 55;
break;
+ }
case SOUND_CAR_HYDRAULIC_3:
+ {
+ const float SOUND_INTENSITY = 35.0f;
m_sQueueSample.m_nSampleIndex = SFX_SUSPENSION_SLOW_MOVE_LOOP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 86;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_SUSPENSION_SLOW_MOVE_LOOP);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SUSPENSION_SLOW_MOVE_LOOP);
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 35.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_nReleasingVolumeDivider = 7;
noReflections = true;
- maxDist = 1225.f;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[0] % 15 + 55;
break;
+ }
case SOUND_CAR_JERK:
+ {
+ const float SOUND_INTENSITY = 35.0f;
m_sQueueSample.m_nSampleIndex = SFX_SHAG_SUSPENSION;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 87;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_SHAG_SUSPENSION);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 3);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHAG_SUSPENSION);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8);
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 35.0f;
- maxDist = 1225.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[1] % 15 + 55;
break;
+ }
case SOUND_CAR_SPLASH:
+ {
+ const float SOUND_INTENSITY = 40.0f;
vol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i];
- if(vol <= 300.f) continue;
- if(vol > 1200.f)
- m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] =
- 1200.0f;
- relVol = (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] -
- 300.f) /
- 900.f;
- m_sQueueSample.m_nSampleIndex =
- (m_anRandomTable[0] & 1) + SFX_BOAT_SPLASH_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ if (vol <= 300.f)
+ continue;
+ if (vol > 1200.f)
+ m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] = 1200.0f;
+ relVol = (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] - 300.f) / 900.f;
+ m_sQueueSample.m_nSampleIndex = (m_anRandomTable[0] & 1) + SFX_BOAT_SPLASH_1;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = WaveIndex++;
- if(WaveIndex > 46) WaveIndex = 41;
+ if (WaveIndex > 46)
+ WaveIndex = 41;
m_sQueueSample.m_nFrequency = (7000.f * relVol) + 6000;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
emittingVol = (55.f * relVol);
- maxDist = 1600.f;
+ maxDist = SQR(SOUND_INTENSITY);
break;
+ }
case SOUND_17:
+ {
+ const float SOUND_INTENSITY = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_THUMB_OFF;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 47;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_POLICE_BOAT_THUMB_OFF) +
- RandomDisplacement(600);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BOAT_THUMB_OFF) + RandomDisplacement(600);
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
- emittingVol =
- m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i];
- maxDist = 2500.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ emittingVol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i];
+ maxDist = SQR(SOUND_INTENSITY);
break;
+ }
case SOUND_18:
case SOUND_19:
+ {
+ const float SOUND_INTENSITY = 35.0f;
m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 59;
m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 11025;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 5.0f;
- m_sQueueSample.m_fSoundIntensity = 35.0f;
- maxDist = 1225.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[1] % 20 + 70;
break;
+ }
case SOUND_CAR_TANK_TURRET_ROTATE:
+ {
+ const float SOUND_INTENSITY = 40.0f;
vol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i];
- if(vol > 0.038400002f) vol = 0.038400002f;
+ if (vol > 96.0f / 2500.0f)
+ vol = 96.0f / 2500.0f;
m_sQueueSample.m_nSampleIndex = SFX_TANK_TURRET;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 79;
- m_sQueueSample.m_nFrequency = (3000.f * vol * 26.041666f) + 9000;
+ m_sQueueSample.m_nFrequency = (3000.f * vol * 2500.0f / 96.0f) + 9000;
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
- emittingVol = (37.f * vol * 26.041666f) + 90;
- maxDist = 1600.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ emittingVol = (37.f * vol * 2500.0f / 96.0f) + 90;
+ maxDist = SQR(SOUND_INTENSITY);
noReflections = true;
break;
+ }
case SOUND_CAR_BOMB_TICK:
+ {
+ const float SOUND_INTENSITY = 30.0f;
m_sQueueSample.m_nSampleIndex = SFX_BOMB_BEEP;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 80;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_BOMB_BEEP);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BOMB_BEEP);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
- maxDist = 900.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
m_sQueueSample.m_bRequireReflection = true;
emittingVol = 60;
break;
+ }
case SOUND_PLANE_ON_GROUND:
+ {
+ const float SOUND_INTENSITY = 180.0f;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_LAND_WHEELS;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 81;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_JUMBO_LAND_WHEELS);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_LAND_WHEELS);
m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 180.0f;
- maxDist = 32400.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[4] % 25 + 75;
break;
+ }
case SOUND_WEAPON_SHOT_FIRED:
+ {
+ const float SOUND_INTENSITY = 120.0f;
emittingVol = m_anRandomTable[2];
- maxDist = 14400.f;
+ maxDist = SQR(SOUND_INTENSITY);
m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = GunIndex++;
emittingVol = emittingVol % 15 + 65;
- if(GunIndex > 58) GunIndex = 53;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 4);
+ if (GunIndex > 58)
+ GunIndex = 53;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 120.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
break;
+ }
case SOUND_WEAPON_HIT_VEHICLE:
- m_sQueueSample.m_nSampleIndex =
- m_anRandomTable[m_sQueueSample.m_nEntityIndex %
- ARRAY_SIZE(m_anRandomTable)] %
- 6 +
- SFX_BULLET_CAR_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ {
+ const float SOUND_INTENSITY = 40.0f;
+ m_sQueueSample.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % ARRAY_SIZE(m_anRandomTable)] % 6 + SFX_BULLET_CAR_1;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 34;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency +=
- RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
m_sQueueSample.m_nReleasingVolumeModificator = 7;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
- maxDist = 1600.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[3] % 20 + 90;
break;
+ }
case SOUND_BOMB_TIMED_ACTIVATED:
case SOUND_55:
case SOUND_BOMB_ONIGNITION_ACTIVATED:
case SOUND_BOMB_TICK:
+ {
+ const float SOUND_INTENSITY = 50.0f;
m_sQueueSample.m_nSampleIndex = SFX_ARM_BOMB;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 36;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_ARM_BOMB);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARM_BOMB);
m_sQueueSample.m_nReleasingVolumeModificator = 0;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bRequireReflection = true;
emittingVol = 50;
- maxDist = 2500.f;
+ maxDist = SQR(SOUND_INTENSITY);
break;
+ }
case SOUND_PED_HELI_PLAYER_FOUND:
pedParams.m_pPed = nil;
pedParams.m_bDistanceCalculated = false;
@@ -8768,69 +8676,72 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params)
SetupPedComments(&pedParams, SOUND_PED_BODYCAST_HIT);
continue;
case SOUND_WATER_FALL:
+ {
+ const float SOUND_INTENSITY = 40.0f;
m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 15;
m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 16000;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
- maxDist = 1600.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
m_sQueueSample.m_bRequireReflection = true;
emittingVol = m_anRandomTable[4] % 20 + 90;
break;
+ }
case SOUND_SPLATTER:
+ {
+ const float SOUND_INTENSITY = 40.0f;
m_sQueueSample.m_nSampleIndex = CrunchOffset + SFX_PED_CRUNCH_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 48;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_PED_CRUNCH_1) +
- RandomDisplacement(600);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PED_CRUNCH_1) + RandomDisplacement(600);
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_fSoundIntensity = 40.0f;
++CrunchOffset;
- maxDist = 1600.f;
+ maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[4] % 20 + 55;
- CrunchOffset &= 1u;
+ CrunchOffset %= 2;
m_sQueueSample.m_bRequireReflection = true;
break;
+ }
case SOUND_CAR_PED_COLLISION:
- vol = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i];
- if(20.f < vol) vol = 20.f;
+ {
+ const float SOUND_INTENSITY = 40.0f;
+ vol = Min(20.0f, m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]);
emittingVol = (vol / 20.0f * 127.f);
- if(!emittingVol) continue;
+ if (!emittingVol)
+ continue;
m_sQueueSample.m_nSampleIndex = (m_anRandomTable[2] & 3) + SFX_FIGHT_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nCounter = 50;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
- maxDist = 1600.f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
+ maxDist = SQR(SOUND_INTENSITY);
break;
- default: continue;
}
- if(params->m_fDistance < maxDist) {
+ default:
+ continue;
+ }
+ if (params->m_fDistance < maxDist) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- if(noReflections) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume != 0) {
+ if (noReflections) {
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
} else {
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
}
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bIs2D = false;
AddSampleToRequestedQueue();
@@ -8842,30 +8753,29 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params)
bool
cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 50.0f;
+
CVehicle *veh = params->m_pVehicle;
- if(params->m_fDistance >= 2500.f) return false;
+ if (params->m_fDistance >= SQR(SOUND_INTENSITY))
+ return false;
- if(veh->bEngineOn && veh->m_fGasPedal < 0.0f) {
+ if (veh->bEngineOn && veh->m_fGasPedal < 0.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(60, 50.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(60, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 12;
m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 2;
- m_sQueueSample.m_nFrequency =
- (100 * m_sQueueSample.m_nEntityIndex & 1023) +
- SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING);
+ m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 60;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 60;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 3.0f;
- m_sQueueSample.m_fSoundIntensity = 50.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bReverbFlag = true;
@@ -8879,53 +8789,44 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params)
bool
cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 95.0f;
+
int32 emittingVol;
uint32 freq;
float modificator;
int sampleFreq;
float velocity;
- if(params->m_fDistance >= 9025.f) return false;
- if(params->m_pTransmission) {
- if(params->m_pVehicle->m_vecMoveSpeed.z) {
+ if (params->m_fDistance >= SQR(SOUND_INTENSITY))
+ return false;
+ if (params->m_pTransmission) {
+ if (params->m_pVehicle->m_vecMoveSpeed.z) {
velocity = Abs(params->m_fVelocityChange);
- if(velocity > 0.0f) {
- CalculateDistance(params->m_bDistanceCalculated,
- params->m_fDistance);
- emittingVol =
- 30.f *
- Min(1.f,
- velocity / (0.5f * params->m_pTransmission->fMaxVelocity));
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (velocity > 0.0f) {
+ CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
+ emittingVol = 30.f * Min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity));
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 0;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
- if(params->m_pVehicle->m_nSurfaceTouched ==
- SURFACE_PUDDLE) {
+ if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_PUDDLE) {
m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP;
freq = 6050 * emittingVol / 30 + 16000;
} else {
m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE;
modificator = m_sQueueSample.m_fDistance / 190.f;
- sampleFreq = SampleManager.GetSampleBaseFrequency(
- SFX_ROAD_NOISE);
- freq = (sampleFreq * modificator) +
- ((3 * sampleFreq) >> 2);
+ sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
+ freq = (sampleFreq * modificator) + ((3 * sampleFreq) / 4);
}
m_sQueueSample.m_nFrequency = freq;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
- m_sQueueSample.m_fSoundIntensity = 95.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
m_sQueueSample.m_bReverbFlag = true;
@@ -8941,51 +8842,48 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
void
cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params)
{
- if(params->m_fDistance < 12100.f) {
+ const float SOUND_INTENSITY = 110.0f;
+
+ if (params->m_fDistance < SQR(SOUND_INTENSITY)) {
CVehicle *veh = params->m_pVehicle;
- if(veh->m_bSirenOrAlarm == 0 && veh->m_nAlarmState <= 0) return;
+ if (veh->m_bSirenOrAlarm == 0 && veh->m_nAlarmState <= 0)
+ return;
#ifdef FIX_BUGS
- if (params->m_pVehicle->m_status == STATUS_WRECKED) return;
+ if (params->m_pVehicle->GetStatus() == STATUS_WRECKED)
+ return;
#endif
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- m_sQueueSample.m_bVolume = ComputeVolume(80, 110.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 5;
- if(UsesSiren(params->m_nIndex)) {
- if(params->m_pVehicle->m_status == STATUS_ABANDONED) return;
- if(veh->m_nCarHornTimer && params->m_nIndex != FIRETRUK) {
+ if (UsesSiren(params->m_nIndex)) {
+ if (params->m_pVehicle->GetStatus() == STATUS_ABANDONED)
+ return;
+ if (veh->m_nCarHornTimer && params->m_nIndex != FIRETRUK) {
m_sQueueSample.m_nSampleIndex = SFX_SIREN_FAST;
- if(params->m_nIndex == FBICAR)
+ if (params->m_nIndex == FBICAR)
m_sQueueSample.m_nFrequency = 16113;
else
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(
- SFX_SIREN_FAST);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SIREN_FAST);
m_sQueueSample.m_nCounter = 60;
} else {
- m_sQueueSample.m_nSampleIndex =
- aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample;
- m_sQueueSample.m_nFrequency =
- aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency;
+ m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample;
+ m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency;
}
} else {
- m_sQueueSample.m_nSampleIndex =
- aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample;
- m_sQueueSample.m_nFrequency =
- aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency;
+ m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample;
+ m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency;
}
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = 80;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 80;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 7.0f;
- m_sQueueSample.m_fSoundIntensity = 110.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 5;
m_sQueueSample.m_bReverbFlag = true;
@@ -8999,67 +8897,59 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params)
void
cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 40.0f;
+
CAutomobile *automobile;
cTransmission *transmission;
int32 emittingVol;
- float newSkidVal = 0.f;
- float skidVal = 0.f;
+ float newSkidVal = 0.0f;
+ float skidVal = 0.0f;
- if(params->m_fDistance >= 1600.f) return;
+ if (params->m_fDistance >= SQR(SOUND_INTENSITY))
+ return;
automobile = (CAutomobile *)params->m_pVehicle;
- if(!automobile->m_nWheelsOnGround) return;
+ if (!automobile->m_nWheelsOnGround)
+ return;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- for(int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
- if(!automobile->m_aWheelState[i] ||
- automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING)
+ for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
+ if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING)
continue;
transmission = params->m_pTransmission;
- if(transmission->nDriveType == '4') {
- newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission,
- params->m_fVelocityChange);
- if(newSkidVal > skidVal) skidVal = newSkidVal;
- continue;
- }
- if(transmission->nDriveType != 'F') {
- if(transmission->nDriveType != 'R') {
- if(newSkidVal > skidVal) skidVal = newSkidVal;
- continue;
- }
- if(i != 1 && i != 3) {
- newSkidVal = GetVehicleNonDriveWheelSkidValue(
- i, automobile, transmission, params->m_fVelocityChange);
- if(newSkidVal > skidVal) skidVal = newSkidVal;
- continue;
- }
- newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission,
- params->m_fVelocityChange);
- if(newSkidVal > skidVal) skidVal = newSkidVal;
- continue;
- }
- if(i == 0 || i == 2) {
- newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission,
- params->m_fVelocityChange);
- if(newSkidVal > skidVal) skidVal = newSkidVal;
- continue;
+ switch (transmission->nDriveType)
+ {
+ case '4':
+ newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange);
+ break;
+ case 'F':
+ if (i == CARWHEEL_FRONT_LEFT || i == CARWHEEL_FRONT_RIGHT)
+ newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange);
+ else
+ newSkidVal = GetVehicleNonDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange);
+ break;
+ case 'R':
+ if (i == CARWHEEL_REAR_LEFT || i == CARWHEEL_REAR_RIGHT)
+ newSkidVal = GetVehicleDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange);
+ else
+ newSkidVal = GetVehicleNonDriveWheelSkidValue(i, automobile, transmission, params->m_fVelocityChange);
+ break;
+ default:
+ break;
}
- newSkidVal = GetVehicleNonDriveWheelSkidValue(i, automobile, transmission,
- params->m_fVelocityChange);
- if(newSkidVal > skidVal) skidVal = newSkidVal;
+ skidVal = Max(skidVal, newSkidVal);
}
- if(skidVal > 0.0f) {
+ if (skidVal > 0.0f) {
emittingVol = 50.f * skidVal;
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 40.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 3;
- switch(params->m_pVehicle->m_nSurfaceTouched) {
+ switch (params->m_pVehicle->m_nSurfaceTouched) {
case SURFACE_GRASS:
case SURFACE_HEDGE:
m_sQueueSample.m_nSampleIndex = SFX_RAIN;
emittingVol /= 4;
m_sQueueSample.m_nFrequency = 13000.f * skidVal + 35000.f;
- m_sQueueSample.m_bVolume /= 4;
+ m_sQueueSample.m_nVolume /= 4;
break;
case SURFACE_DIRT:
case SURFACE_DIRTTRACK:
@@ -9075,17 +8965,15 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
break;
}
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 8;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 3.0f;
- m_sQueueSample.m_fSoundIntensity = 40.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bReverbFlag = true;
@@ -9097,20 +8985,19 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params)
void cAudioManager::ProcessWaterCannon(int32)
{
- for(int32 i = 0; i < NUM_WATERCANNONS; i++) {
- if(CWaterCannons::aCannons[i].m_nId) {
- m_sQueueSample.m_vecPos =
- CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < 900.f) {
+ const float SOUND_INTENSITY = 900.0f;
+
+ for (int32 i = 0; i < NUM_WATERCANNONS; i++) {
+ if (CWaterCannons::aCannons[i].m_nId) {
+ m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SOUND_INTENSITY) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(50, m_sQueueSample.m_fSoundIntensity,
- m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
- m_sQueueSample.m_fSoundIntensity = 900.0f;
+ m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency = 15591;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_nCounter = i;
@@ -9119,13 +9006,9 @@ void cAudioManager::ProcessWaterCannon(int32)
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
- m_sQueueSample.m_bEmittingVolume = 50;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 50;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
@@ -9141,53 +9024,52 @@ cAudioManager::ProcessWeather(int32 id)
uint8 vol;
static uint8 counter = 0;
- if(m_asAudioEntities[id].m_AudioEvents &&
- m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) {
- if(m_asAudioEntities[id].m_afVolume[0] >= 10.f) {
+ if (m_asAudioEntities[id].m_AudioEvents && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) {
+ if (m_asAudioEntities[id].m_afVolume[0] >= 10.f) {
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000;
vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40;
} else {
m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000;
vol = (m_asAudioEntities[id].m_afVolume[0]) + 35;
}
- m_sQueueSample.m_bVolume = vol;
- if(TheCamera.SoundDistUp < 20.f) m_sQueueSample.m_bVolume /= 2;
- if(counter == 4) counter = 0;
+ m_sQueueSample.m_nVolume = vol;
+ if (TheCamera.SoundDistUp < 20.f)
+ m_sQueueSample.m_nVolume /= 2;
+ if (counter == 4)
+ counter = 0;
m_sQueueSample.m_nCounter = counter++;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_bOffset = (m_anRandomTable[2] & 15) + 55;
+ m_sQueueSample.m_nOffset = (m_anRandomTable[2] & 15) + 55;
m_sQueueSample.m_bIs2D = true;
m_sQueueSample.m_nLoopCount = 1;
m_sQueueSample.m_bReleasingSoundFlag = true;
- m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume;
+ m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume;
m_sQueueSample.m_nLoopStart = 0;
m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_bReverbFlag = false;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
- if(CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) {
+ if (CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) {
m_sQueueSample.m_nSampleIndex = SFX_RAIN;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAIN);
- m_sQueueSample.m_bVolume = (int32)(25.f * CWeather::Rain);
+ m_sQueueSample.m_nVolume = (int32)(25.f * CWeather::Rain);
m_sQueueSample.m_nCounter = 4;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_nReleasingVolumeModificator = 0;
- m_sQueueSample.m_bOffset = 63;
+ m_sQueueSample.m_nOffset = 63;
m_sQueueSample.m_bIs2D = true;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 30;
m_sQueueSample.m_bReverbFlag = false;
- m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
}
@@ -9196,44 +9078,39 @@ cAudioManager::ProcessWeather(int32 id)
bool
cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
{
+ const float SOUND_INTENSITY = 30.0f;
+
float relativeVelocity;
int32 emittingVol;
float modificator;
int freq;
float velChange;
- if(params->m_fDistance >= 900.f) return false;
- if(params->m_pTransmission) {
- if(params->m_pVehicle->m_vecMoveSpeed.z) {
+ if (params->m_fDistance >= SQR(SOUND_INTENSITY))
+ return false;
+ if (params->m_pTransmission) {
+ if (params->m_pVehicle->m_vecMoveSpeed.z) {
velChange = Abs(params->m_fVelocityChange);
- if(velChange > 0.f) {
- CalculateDistance(params->m_bDistanceCalculated,
- params->m_fDistance);
- relativeVelocity =
- Min(1.0f,
- velChange / (0.5f * params->m_pTransmission->fMaxVelocity));
+ if (velChange > 0.f) {
+ CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
+ relativeVelocity = Min(1.0f, velChange / (0.5f * params->m_pTransmission->fMaxVelocity));
emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads;
- m_sQueueSample.m_bVolume =
- ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 1;
m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
modificator = m_sQueueSample.m_fDistance / 6.f;
freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
m_sQueueSample.m_nFrequency = freq + freq * modificator;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(
- m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(
- m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
m_sQueueSample.m_bReverbFlag = true;
@@ -9251,32 +9128,31 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound)
{
float distSquared;
- switch(sound) {
+ switch (sound) {
case SCRIPT_SOUND_WORK_SHOP_LOOP_S:
- case SCRIPT_SOUND_WORK_SHOP_LOOP_L: m_sQueueSample.m_fSoundIntensity = 20.0f; break;
- default: return;
+ case SCRIPT_SOUND_WORK_SHOP_LOOP_L:
+ m_sQueueSample.m_fSoundIntensity = 20.0f;
+ break;
+ default:
+ return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
- if(distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
+ if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
- m_sQueueSample.m_bVolume =
- ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_WORKSHOP_1;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_WORKSHOP_1);
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_WORKSHOP_1);
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_fSpeedMultiplier = 2.0f;
- m_sQueueSample.m_bEmittingVolume = 30;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = 30;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
@@ -9292,26 +9168,34 @@ cAudioManager::RandomDisplacement(uint32 seed) const
static bool bIsEven = true;
static uint32 base = 0;
- if(!seed) return 0;
+ if (!seed)
+ return 0;
value = m_anRandomTable[(base + seed) % 5] % seed;
base += value;
- if(value % 2) { bIsEven = !bIsEven; }
- if(!bIsEven) value = -value;
+ if (value % 2) {
+ bIsEven = !bIsEven;
+ }
+ if (!bIsEven)
+ value = -value;
return value;
}
void
cAudioManager::ReacquireDigitalHandle() const
{
- if(m_bIsInitialised) { SampleManager.ReacquireDigitalHandle(); }
+ if (m_bIsInitialised) {
+ SampleManager.ReacquireDigitalHandle();
+ }
}
void
cAudioManager::ReleaseDigitalHandle() const
{
- if(m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); }
+ if (m_bIsInitialised) {
+ SampleManager.ReleaseDigitalHandle();
+ }
}
void
@@ -9326,10 +9210,10 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer)
gAirportNextTime = timer;
gDocksNextTime = timer;
gCinemaNextTime = timer;
- for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
- if(m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) {
+ for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
+ if (m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) {
CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity;
- if(ped->IsPed()) {
+ if (ped->IsPed()) {
ped->m_lastSoundStart = timer;
ped->m_soundStart = timer + m_anRandomTable[0] % 3000;
}
@@ -9342,18 +9226,18 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer)
void
cAudioManager::ResetTimers(uint32 time)
{
- if(m_bIsInitialised) {
- m_bTimerJustReset = 1;
+ if (m_bIsInitialised) {
+ m_bTimerJustReset = true;
m_nTimer = time;
ClearRequestedQueue();
- if(m_bActiveSampleQueue) {
- m_bActiveSampleQueue = 0;
+ if (m_nActiveSampleQueue) {
+ m_nActiveSampleQueue = 0;
ClearRequestedQueue();
- m_bActiveSampleQueue = 1;
+ m_nActiveSampleQueue = 1;
} else {
- m_bActiveSampleQueue = 1;
+ m_nActiveSampleQueue = 1;
ClearRequestedQueue();
- m_bActiveSampleQueue = 0;
+ m_nActiveSampleQueue = 0;
}
ClearActiveSamples();
ClearMissionAudio();
@@ -9371,14 +9255,14 @@ void
cAudioManager::Service()
{
GenerateIntegerRandomNumberTable();
- if(m_bTimerJustReset) {
+ if (m_bTimerJustReset) {
ResetAudioLogicTimers(m_nTimer);
MusicManager.ResetTimers(m_nTimer);
- m_bTimerJustReset = 0;
+ m_bTimerJustReset = false;
}
- if(m_bIsInitialised) {
- m_bPreviousUserPause = m_bUserPause;
- m_bUserPause = CTimer::GetIsUserPaused();
+ if (m_bIsInitialised) {
+ m_nPreviousUserPause = m_nUserPause;
+ m_nUserPause = CTimer::GetIsUserPaused();
UpdateReflections();
ServiceSoundEffects();
MusicManager.Service();
@@ -9388,26 +9272,24 @@ cAudioManager::Service()
void
cAudioManager::ServiceSoundEffects()
{
- if(m_FrameCounter++ % 5)
- m_bFifthFrameFlag = false;
- else
- m_bFifthFrameFlag = true;
- if(m_bUserPause && !m_bPreviousUserPause) {
- for(int32 i = 0; i < allChannels; i++) SampleManager.StopChannel(i);
+ m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0;
+ if (m_nUserPause && !m_nPreviousUserPause) {
+ for (int32 i = 0; i < allChannels; i++)
+ SampleManager.StopChannel(i);
ClearRequestedQueue();
- if(m_bActiveSampleQueue) {
- m_bActiveSampleQueue = 0;
+ if (m_nActiveSampleQueue) {
+ m_nActiveSampleQueue = 0;
ClearRequestedQueue();
- m_bActiveSampleQueue = 1;
+ m_nActiveSampleQueue = 1;
} else {
- m_bActiveSampleQueue = 1;
+ m_nActiveSampleQueue = 1;
ClearRequestedQueue();
- m_bActiveSampleQueue = 0;
+ m_nActiveSampleQueue = 0;
}
ClearActiveSamples();
}
- m_bActiveSampleQueue = m_bActiveSampleQueue != 1;
+ m_nActiveSampleQueue = m_nActiveSampleQueue != 1;
ProcessReverb();
ProcessSpecial();
ClearRequestedQueue();
@@ -9422,10 +9304,8 @@ cAudioManager::ServiceSoundEffects()
#ifdef AUDIO_OAL
SampleManager.Service();
#endif
- for(int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; ++i) {
- cAudioScriptObject *object =
- (cAudioScriptObject *)m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]]
- .m_pEntity;
+ for (int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; ++i) {
+ cAudioScriptObject *object = (cAudioScriptObject *)m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity;
delete object;
m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity = nil;
DestroyEntity(m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]);
@@ -9436,19 +9316,22 @@ cAudioManager::ServiceSoundEffects()
int8
cAudioManager::SetCurrent3DProvider(uint8 which)
{
- if(!m_bIsInitialised) return -1;
- for(uint8 i = 0; i < m_bActiveSamples + 1; ++i) SampleManager.StopChannel(i);
+ if (!m_bIsInitialised)
+ return -1;
+ for (uint8 i = 0; i < m_nActiveSamples + 1; ++i)
+ SampleManager.StopChannel(i);
ClearRequestedQueue();
- if(m_bActiveSampleQueue)
- m_bActiveSampleQueue = 0;
+ if (m_nActiveSampleQueue == 0)
+ m_nActiveSampleQueue = 1;
else
- m_bActiveSampleQueue = 1;
+ m_nActiveSampleQueue = 0;
ClearRequestedQueue();
ClearActiveSamples();
int8 current = SampleManager.SetCurrent3DProvider(which);
- if(current > 0) {
- m_bActiveSamples = SampleManager.GetMaximumSupportedChannels();
- if(m_bActiveSamples > 1) --m_bActiveSamples;
+ if (current > 0) {
+ m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
+ if (m_nActiveSamples > 1)
+ --m_nActiveSamples;
}
return current;
}
@@ -9474,18 +9357,16 @@ cAudioManager::SetEffectsMasterVolume(uint8 volume) const
void
cAudioManager::SetEntityStatus(int32 id, uint8 status)
{
- if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots &&
- m_asAudioEntities[id].m_bIsUsed) {
- m_asAudioEntities[id].m_bStatus = status;
- }
+ if (m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots && m_asAudioEntities[id].m_bIsUsed)
+ m_asAudioEntities[id].m_nStatus = status;
}
void
cAudioManager::SetMissionAudioLocation(float x, float y, float z)
{
- if(m_bIsInitialised) {
- m_sMissionAudio.m_bPredefinedProperties = 0;
- m_sMissionAudio.m_vecPos = {x, y, z};
+ if (m_bIsInitialised) {
+ m_sMissionAudio.m_bPredefinedProperties = false;
+ m_sMissionAudio.m_vecPos = CVector(x, y, z);
}
}
@@ -9510,25 +9391,25 @@ cAudioManager::SetSpeakerConfig(int32 conf) const
bool
cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq)
{
- if(m_sQueueSample.m_fDistance >= 180.f) return false;
+ const float SOUND_INTENSITY = 180.0f;
+ if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY)
+ return false;
uint8 emittingVol = vol - gJumboVolOffsetPercentage / 100;
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 3;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_ENGINE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_nFrequency = freq;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
- m_sQueueSample.m_fSoundIntensity = 180.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
m_sQueueSample.m_bReverbFlag = true;
@@ -9541,29 +9422,28 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq)
bool
cAudioManager::SetupJumboFlySound(uint8 emittingVol)
{
- if(m_sQueueSample.m_fDistance >= 440.0f) return false;
+ const float SOUND_INTENSITY = 440.0f;
+ if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY)
+ return false;
- int32 vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance);
- m_sQueueSample.m_bVolume = vol;
- if(m_sQueueSample.m_bVolume) {
+ int32 vol = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_nVolume = vol;
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY;
m_sQueueSample.m_nCounter = 0;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_JUMBO_DIST_FLY);
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_fSoundIntensity = 440.0f;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_DIST_FLY);
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_nReleasingVolumeDivider = 5;
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
AddSampleToRequestedQueue();
}
return true;
@@ -9572,36 +9452,35 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol)
bool
cAudioManager::SetupJumboRumbleSound(uint8 emittingVol)
{
- if(m_sQueueSample.m_fDistance >= 240.f) return false;
+ const float SOUND_INTENSITY = 240.0f;
+ if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY)
+ return false;
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 240.f, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 5;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = true;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
- m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(SFX_JUMBO_RUMBLE);
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_RUMBLE);
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
- m_sQueueSample.m_fSoundIntensity = 240.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 12;
- m_sQueueSample.m_bOffset = 0;
+ m_sQueueSample.m_nOffset = 0;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
m_sQueueSample.m_nCounter = 6;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE;
m_sQueueSample.m_nFrequency += 200;
- m_sQueueSample.m_bOffset = maxVolume;
+ m_sQueueSample.m_nOffset = maxVolume;
AddSampleToRequestedQueue();
}
return true;
@@ -9610,29 +9489,29 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol)
bool
cAudioManager::SetupJumboTaxiSound(uint8 vol)
{
- if(m_sQueueSample.m_fDistance >= 180.f) return false;
+ const float SOUND_INTENSITY = 180.0f;
+ if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY)
+ return false;
- uint8 emittingVol = (vol >> 1) + ((vol >> 1) * m_sQueueSample.m_fDistance / 180);
+ uint8 emittingVol = (vol / 2) + ((vol / 2) * m_sQueueSample.m_fDistance / SOUND_INTENSITY);
- if(m_sQueueSample.m_fDistance / 180 < 0.7f)
+ if (m_sQueueSample.m_fDistance / SOUND_INTENSITY < 0.7f)
emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100;
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 1;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_nFrequency = GetJumboTaxiFreq();
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
- m_sQueueSample.m_fSoundIntensity = 180.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
m_sQueueSample.m_bReverbFlag = true;
@@ -9645,25 +9524,26 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol)
bool
cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq)
{
- if(m_sQueueSample.m_fDistance >= 170.f) return false;
+ const float SOUND_INTENSITY = 170.0f;
+
+ if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY)
+ return false;
- m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 170.f, m_sQueueSample.m_fDistance);
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
- if(m_sQueueSample.m_bVolume) {
+ if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 2;
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_WHINE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_nFrequency = freq;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = emittingVol;
- m_sQueueSample.m_nLoopStart =
- SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nLoopEnd =
- SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
- m_sQueueSample.m_fSoundIntensity = 170.0f;
+ m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
m_sQueueSample.m_bReverbFlag = true;
@@ -9681,107 +9561,76 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound)
float soundIntensity;
tPedComment pedComment;
- if(ped) {
- switch(sound) {
- case SOUND_AMMUNATION_WELCOME_1: pedComment.m_nSampleIndex = SFX_AMMU_D; break;
- case SOUND_AMMUNATION_WELCOME_2: pedComment.m_nSampleIndex = SFX_AMMU_E; break;
- case SOUND_AMMUNATION_WELCOME_3: pedComment.m_nSampleIndex = SFX_AMMU_F; break;
+ if (ped != nil) {
+ switch (sound) {
+ case SOUND_AMMUNATION_WELCOME_1:
+ pedComment.m_nSampleIndex = SFX_AMMU_D;
+ break;
+ case SOUND_AMMUNATION_WELCOME_2:
+ pedComment.m_nSampleIndex = SFX_AMMU_E;
+ break;
+ case SOUND_AMMUNATION_WELCOME_3:
+ pedComment.m_nSampleIndex = SFX_AMMU_F;
+ break;
default:
pedComment.m_nSampleIndex = GetPedCommentSfx(ped, sound);
- if(pedComment.m_nSampleIndex == NO_SAMPLE) return;
+ if (pedComment.m_nSampleIndex == NO_SAMPLE)
+ return;
break;
}
- soundIntensity = 50.f;
-
- if(params->m_fDistance < SQR(soundIntensity)) {
- CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- if(sound != SOUND_PAGER) {
- switch(sound) {
- case SOUND_AMMUNATION_WELCOME_1:
- case SOUND_AMMUNATION_WELCOME_2:
- case SOUND_AMMUNATION_WELCOME_3: emittingVol = maxVolume; break;
- default:
- if(CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(),
- m_sQueueSample.m_vecPos, 1,
- 0, 0, 0, 0, 0, 0)) {
- emittingVol = maxVolume;
- } else {
- emittingVol = 31;
- }
- break;
- }
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVol, soundIntensity, m_sQueueSample.m_fDistance);
- pedComment.m_nProcess = 10;
- if(m_sQueueSample.m_bVolume) {
- pedComment.m_nEntityIndex = m_sQueueSample.m_nEntityIndex;
- pedComment.m_vecPos = m_sQueueSample.m_vecPos;
- pedComment.m_fDistance = m_sQueueSample.m_fDistance;
- pedComment.m_bVolume = m_sQueueSample.m_bVolume;
- m_sPedComments.Add(&pedComment);
- }
- }
- }
+ soundIntensity = 50.0f;
} else {
- switch(sound) {
+ switch (sound) {
case SOUND_PED_HELI_PLAYER_FOUND:
- soundIntensity = 400.f;
- pedComment.m_nSampleIndex =
- m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 29 +
- SFX_POLICE_HELI_1;
+ soundIntensity = 400.0f;
+ pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_POLICE_HELI_1, SFX_POLICE_HELI_29);
break;
case SOUND_PED_BODYCAST_HIT:
- if(CTimer::GetTimeInMilliseconds() <= gNextCryTime) return;
- soundIntensity = 50.f;
+ if (CTimer::GetTimeInMilliseconds() <= gNextCryTime)
+ return;
+ soundIntensity = 50.0f;
gNextCryTime = CTimer::GetTimeInMilliseconds() + 500;
- pedComment.m_nSampleIndex =
- (m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] & 3) +
- SFX_PLASTER_BLOKE_1;
+ pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_PLASTER_BLOKE_1, SFX_PLASTER_BLOKE_4);
break;
case SOUND_INJURED_PED_MALE_OUCH:
- case SOUND_8A:
- soundIntensity = 50.f;
- pedComment.m_nSampleIndex =
- m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 15 +
- SFX_GENERIC_MALE_GRUNT_1;
+ case SOUND_INJURED_PED_MALE_PRISON:
+ soundIntensity = 50.0f;
+ pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_GENERIC_MALE_GRUNT_1, SFX_GENERIC_MALE_GRUNT_15);
break;
case SOUND_INJURED_PED_FEMALE:
- soundIntensity = 50.f;
- pedComment.m_nSampleIndex =
- m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 11 +
- SFX_GENERIC_FEMALE_GRUNT_1;
+ soundIntensity = 50.0f;
+ pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_GENERIC_FEMALE_GRUNT_1, SFX_GENERIC_FEMALE_GRUNT_11);
break;
- default: return;
+ default:
+ return;
}
+ }
- if(params->m_fDistance < SQR(soundIntensity)) {
- CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
- if(sound != SOUND_PAGER) {
- switch(sound) {
- case SOUND_AMMUNATION_WELCOME_1:
- case SOUND_AMMUNATION_WELCOME_2:
- case SOUND_AMMUNATION_WELCOME_3: emittingVol = maxVolume; break;
- default:
- if(CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(),
- m_sQueueSample.m_vecPos, 1,
- 0, 0, 0, 0, 0, 0)) {
- emittingVol = maxVolume;
- } else {
- emittingVol = 31;
- }
- break;
- }
- m_sQueueSample.m_bVolume = ComputeVolume(
- emittingVol, soundIntensity, m_sQueueSample.m_fDistance);
- pedComment.m_nProcess = 10;
- if(m_sQueueSample.m_bVolume) {
- pedComment.m_nEntityIndex = m_sQueueSample.m_nEntityIndex;
- pedComment.m_vecPos = m_sQueueSample.m_vecPos;
- pedComment.m_fDistance = m_sQueueSample.m_fDistance;
- pedComment.m_bVolume = m_sQueueSample.m_bVolume;
- m_sPedComments.Add(&pedComment);
- }
+ if (params->m_fDistance < SQR(soundIntensity)) {
+ CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
+ if (sound != SOUND_PAGER) {
+ switch (sound) {
+ case SOUND_AMMUNATION_WELCOME_1:
+ case SOUND_AMMUNATION_WELCOME_2:
+ case SOUND_AMMUNATION_WELCOME_3:
+ emittingVol = maxVolume;
+ break;
+ default:
+ if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), m_sQueueSample.m_vecPos, true, false, false, false, false, false))
+ emittingVol = maxVolume;
+ else
+ emittingVol = 31;
+ break;
+ }
+ m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, soundIntensity, m_sQueueSample.m_fDistance);
+ pedComment.m_nProcess = 10;
+ if (m_sQueueSample.m_nVolume != 0) {
+ pedComment.m_nEntityIndex = m_sQueueSample.m_nEntityIndex;
+ pedComment.m_vecPos = m_sQueueSample.m_vecPos;
+ pedComment.m_fDistance = m_sQueueSample.m_fDistance;
+ pedComment.m_bVolume = m_sQueueSample.m_nVolume;
+ m_sPedComments.Add(&pedComment);
}
}
}
@@ -9790,10 +9639,10 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound)
void
cAudioManager::Terminate()
{
- if(m_bIsInitialised) {
+ if (m_bIsInitialised) {
MusicManager.Terminate();
- for(uint32 i = 0; i < totalAudioEntitiesSlots; i++) {
+ for (uint32 i = 0; i < totalAudioEntitiesSlots; i++) {
m_asAudioEntities[i].m_bIsUsed = false;
m_anAudioEntityIndices[i] = ARRAY_SIZE(m_anAudioEntityIndices);
}
@@ -9802,8 +9651,9 @@ cAudioManager::Terminate()
m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0;
PreTerminateGameSpecificShutdown();
- for(uint32 i = 0; i < MAX_SAMPLEBANKS; i++) {
- if(SampleManager.IsSampleBankLoaded(i)) SampleManager.UnloadSampleBank(i);
+ for (uint32 i = 0; i < MAX_SAMPLEBANKS; i++) {
+ if (SampleManager.IsSampleBankLoaded(i))
+ SampleManager.UnloadSampleBank(i);
}
SampleManager.Terminate();
@@ -9814,7 +9664,7 @@ cAudioManager::Terminate()
}
void
-cAudioManager::TranslateEntity(CVector *in, CVector *out) const
+cAudioManager::TranslateEntity(Const CVector *in, CVector *out) const
{
*out = MultiplyInverse(TheCamera.GetMatrix(), *in);
}
@@ -9827,12 +9677,14 @@ cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile)
float gasPedal = Abs(automobile->m_fGasPedal);
float gasPedalAudio = automobile->m_fGasPedalAudio;
- if(gasPedalAudio < gasPedal) {
+ if (gasPedalAudio < gasPedal) {
newGasPedalAudio = gasPedalAudio + 0.09f;
- if(gasPedal <= newGasPedalAudio) newGasPedalAudio = gasPedal;
+ if (gasPedal <= newGasPedalAudio)
+ newGasPedalAudio = gasPedal;
} else {
newGasPedalAudio = gasPedalAudio - 0.07f;
- if(gasPedal >= newGasPedalAudio) newGasPedalAudio = gasPedal;
+ if (gasPedal >= newGasPedalAudio)
+ newGasPedalAudio = gasPedal;
}
automobile->m_fGasPedalAudio = newGasPedalAudio;
}
@@ -9844,115 +9696,88 @@ cAudioManager::UpdateReflections()
CColPoint colpoint;
CEntity *ent;
- if(m_FrameCounter & 7) {
- if(((uint8)m_FrameCounter + 1) & 7) {
- if(((uint8)m_FrameCounter + 2) & 7) {
- if(((uint8)m_FrameCounter + 3) & 7) {
- if(!(((uint8)m_FrameCounter + 4) & 7)) {
- m_avecReflectionsPos[4] = camPos;
- m_avecReflectionsPos[4].z += 50.f;
- if(CWorld::ProcessVerticalLine(
- camPos, m_avecReflectionsPos[4].z, colpoint,
- ent, true, false, false, false, true, false,
- nil)) {
- m_afReflectionsDistances[4] =
- colpoint.point.z - camPos.z;
- } else {
- m_afReflectionsDistances[4] = 50.0f;
- }
- }
- } else {
- m_avecReflectionsPos[3] = camPos;
- m_avecReflectionsPos[3].x += 50.f;
- if(CWorld::ProcessLineOfSight(
- camPos, m_avecReflectionsPos[3], colpoint, ent, true,
- false, false, true, false, true, true)) {
- m_afReflectionsDistances[3] =
- Distance(camPos, colpoint.point);
- } else {
- m_afReflectionsDistances[3] = 50.0f;
- }
- }
- } else {
- m_avecReflectionsPos[2] = camPos;
- m_avecReflectionsPos[2].x -= 50.f;
- if(CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[2],
- colpoint, ent, true, false, false,
- true, false, true, true)) {
- m_afReflectionsDistances[2] =
- Distance(camPos, colpoint.point);
- } else {
- m_afReflectionsDistances[2] = 50.0f;
- }
- }
- } else {
- m_avecReflectionsPos[1] = camPos;
- m_avecReflectionsPos[1].y -= 50.f;
- if(CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[1], colpoint,
- ent, true, false, false, true, false, true,
- true)) {
- m_afReflectionsDistances[1] = Distance(camPos, colpoint.point);
- } else {
- m_afReflectionsDistances[1] = 50.0f;
- }
- }
- } else {
+ if (m_FrameCounter % 8 == 0) {
m_avecReflectionsPos[0] = camPos;
m_avecReflectionsPos[0].y += 50.f;
- if(CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[0], colpoint, ent, true,
- false, false, true, false, true, true)) {
+ if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[0], colpoint, ent, true, false, false, true, false, true, true))
m_afReflectionsDistances[0] = Distance(camPos, colpoint.point);
- } else {
+ else
m_afReflectionsDistances[0] = 50.0f;
- }
+ } else if ((m_FrameCounter + 1) % 8 == 0) {
+ m_avecReflectionsPos[1] = camPos;
+ m_avecReflectionsPos[1].y -= 50.0f;
+ if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[1], colpoint, ent, true, false, false, true, false, true, true))
+ m_afReflectionsDistances[1] = Distance(camPos, colpoint.point);
+ else
+ m_afReflectionsDistances[1] = 50.0f;
+ } else if ((m_FrameCounter + 2) % 8 == 0) {
+ m_avecReflectionsPos[2] = camPos;
+ m_avecReflectionsPos[2].x -= 50.0f;
+ if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[2], colpoint, ent, true, false, false, true, false, true, true))
+ m_afReflectionsDistances[2] = Distance(camPos, colpoint.point);
+ else
+ m_afReflectionsDistances[2] = 50.0f;
+ } else if ((m_FrameCounter + 3) % 8 == 0) {
+ m_avecReflectionsPos[3] = camPos;
+ m_avecReflectionsPos[3].x += 50.0f;
+ if (CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[3], colpoint, ent, true, false, false, true, false, true, true))
+ m_afReflectionsDistances[3] = Distance(camPos, colpoint.point);
+ else
+ m_afReflectionsDistances[3] = 50.0f;
+ } else if ((m_FrameCounter + 4) % 8 == 0) {
+ m_avecReflectionsPos[4] = camPos;
+ m_avecReflectionsPos[4].z += 50.0f;
+ if (CWorld::ProcessVerticalLine(camPos, m_avecReflectionsPos[4].z, colpoint, ent, true, false, false, false, true, false, nil))
+ m_afReflectionsDistances[4] = colpoint.point.z - camPos.z;
+ else
+ m_afReflectionsDistances[4] = 50.0f;
}
}
bool
cAudioManager::UsesReverseWarning(int32 model) const
{
- return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS ||
- model == COACH;
+ return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH;
}
bool
cAudioManager::UsesSiren(int32 model) const
{
- switch(model) {
+ switch (model) {
case FIRETRUK:
case AMBULAN:
case FBICAR:
case POLICE:
case ENFORCER:
- case PREDATOR: return true;
- default: return false;
+ case PREDATOR:
+ return true;
+ default:
+ return false;
}
}
bool
cAudioManager::UsesSirenSwitching(int32 model) const
{
- switch(model) {
+ switch (model) {
case AMBULAN:
case POLICE:
case ENFORCER:
- case PREDATOR: return true;
- default: return false;
+ case PREDATOR:
+ return true;
+ default:
+ return false;
}
}
void
cAudioManager::AdjustSamplesVolume()
{
- for(int i = 0; i < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; i++) {
- tSound *pSample =
- &m_asSamples[m_bActiveSampleQueue]
- [m_abSampleQueueIndexTable[m_bActiveSampleQueue][i] + 1];
+ for (int i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
+ tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] + 1];
- if(!pSample->m_bIs2D)
- pSample->m_bEmittingVolume =
- ComputeEmittingVolume(pSample->m_bEmittingVolume,
- pSample->m_fSoundIntensity, pSample->m_fDistance);
+ if (!pSample->m_bIs2D)
+ pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_fSoundIntensity, pSample->m_fDistance);
}
}
@@ -9961,8 +9786,7 @@ cAudioManager::ComputeEmittingVolume(uint8 emittingVolume, float intensity, floa
{
float quatIntensity = intensity / 4.0f;
float diffIntensity = intensity - quatIntensity;
- if(dist > diffIntensity)
- return (quatIntensity - (dist - diffIntensity)) * (float)emittingVolume /
- quatIntensity;
+ if (dist > diffIntensity)
+ return (quatIntensity - (dist - diffIntensity)) * (float)emittingVolume / quatIntensity;
return emittingVolume;
}
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 8fc13ed8..99d67444 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -1,164 +1,33 @@
#pragma once
-#include "common.h"
-#include "config.h"
-
-#include "DMAudio.h"
-
+#include "audio_enums.h"
#include "AudioCollision.h"
#include "PoliceRadio.h"
-enum eScriptSounds : int16 {
- SCRIPT_SOUND_0 = 0,
- SCRIPT_SOUND_1 = 1,
- SCRIPT_SOUND_2 = 2,
- SCRIPT_SOUND_3 = 3,
- SCRIPT_SOUND_PARTY_1_LOOP_S = 4,
- SCRIPT_SOUND_PARTY_1_LOOP_L = 5,
- SCRIPT_SOUND_PARTY_2_LOOP_S = 6,
- SCRIPT_SOUND_PARTY_2_LOOP_L = 7,
- SCRIPT_SOUND_PARTY_3_LOOP_S = 8,
- SCRIPT_SOUND_PARTY_3_LOOP_L = 9,
- SCRIPT_SOUND_PARTY_4_LOOP_S = 10,
- SCRIPT_SOUND_PARTY_4_LOOP_L = 11,
- SCRIPT_SOUND_PARTY_5_LOOP_S = 12,
- SCRIPT_SOUND_PARTY_5_LOOP_L = 13,
- SCRIPT_SOUND_PARTY_6_LOOP_S = 14,
- SCRIPT_SOUND_PARTY_6_LOOP_L = 15,
- SCRIPT_SOUND_PARTY_7_LOOP_S = 16,
- SCRIPT_SOUND_PARTY_7_LOOP_L = 17,
- SCRIPT_SOUND_PARTY_8_LOOP_S = 18,
- SCRIPT_SOUND_PARTY_8_LOOP_L = 19,
- SCRIPT_SOUND_PARTY_9_LOOP_S = 20,
- SCRIPT_SOUND_PARTY_9_LOOP_L = 21,
- SCRIPT_SOUND_PARTY_10_LOOP_S = 22,
- SCRIPT_SOUND_PARTY_10_LOOP_L = 23,
- SCRIPT_SOUND_PARTY_11_LOOP_S = 24,
- SCRIPT_SOUND_PARTY_11_LOOP_L = 25,
- SCRIPT_SOUND_PARTY_12_LOOP_S = 26,
- SCRIPT_SOUND_PARTY_12_LOOP_L = 27,
- SCRIPT_SOUND_PARTY_13_LOOP_S = 28,
- SCRIPT_SOUND_PARTY_13_LOOP_L = 29,
- SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S = 30,
- SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L = 31,
- SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S = 32,
- SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L = 33,
- SCRIPT_SOUND_WORK_SHOP_LOOP_S = 34,
- SCRIPT_SOUND_WORK_SHOP_LOOP_L = 35,
- SCRIPT_SOUND_SAWMILL_LOOP_S = 36,
- SCRIPT_SOUND_SAWMILL_LOOP_L = 37,
- SCRIPT_SOUND_38 = 38,
- SCRIPT_SOUND_39 = 39,
- SCRIPT_SOUND_LAUNDERETTE_LOOP_S = 40,
- SCRIPT_SOUND_LAUNDERETTE_LOOP_L = 41,
- SCRIPT_SOUND_CHINATOWN_RESTAURANT_S = 42,
- SCRIPT_SOUND_CHINATOWN_RESTAURANT_L = 43,
- SCRIPT_SOUND_CIPRIANI_RESAURANT_S = 44,
- SCRIPT_SOUND_CIPRIANI_RESAURANT_L = 45,
- SCRIPT_SOUND_46_S = 46,
- SCRIPT_SOUND_47_L = 47,
- SCRIPT_SOUND_MARCO_BISTRO_S = 48,
- SCRIPT_SOUND_MARCO_BISTRO_L = 49,
- SCRIPT_SOUND_AIRPORT_LOOP_S = 50,
- SCRIPT_SOUND_AIRPORT_LOOP_L = 51,
- SCRIPT_SOUND_SHOP_LOOP_S = 52,
- SCRIPT_SOUND_SHOP_LOOP_L = 53,
- SCRIPT_SOUND_CINEMA_LOOP_S = 54,
- SCRIPT_SOUND_CINEMA_LOOP_L = 55,
- SCRIPT_SOUND_DOCKS_LOOP_S = 56,
- SCRIPT_SOUND_DOCKS_LOOP_L = 57,
- SCRIPT_SOUND_HOME_LOOP_S = 58,
- SCRIPT_SOUND_HOME_LOOP_L = 59,
- SCRIPT_SOUND_FRANKIE_PIANO = 60,
- SCRIPT_SOUND_PARTY_1_LOOP = 61,
- SCRIPT_SOUND_PORN_CINEMA_1_S = 62,
- SCRIPT_SOUND_PORN_CINEMA_1_L = 63,
- SCRIPT_SOUND_PORN_CINEMA_2_S = 64,
- SCRIPT_SOUND_PORN_CINEMA_2_L = 65,
- SCRIPT_SOUND_PORN_CINEMA_3_S = 66,
- SCRIPT_SOUND_PORN_CINEMA_3_L = 67,
- SCRIPT_SOUND_BANK_ALARM_LOOP_S = 68,
- SCRIPT_SOUND_BANK_ALARM_LOOP_L = 69,
- SCRIPT_SOUND_POLICE_BALL_LOOP_S = 70,
- SCRIPT_SOUND_POLICE_BALL_LOOP_L = 71,
- SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S = 72,
- SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L = 73,
- SCRIPT_SOUND_74 = 74,
- SCRIPT_SOUND_75 = 75,
- SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S = 76,
- SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L = 77,
- SCRIPT_SOUND_INJURED_PED_MALE_OUCH_S = 78,
- SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L = 79,
- SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S = 80,
- SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L = 81,
- SCRIPT_SOUND_EVIDENCE_PICKUP = 82,
- SCRIPT_SOUND_UNLOAD_GOLD = 83,
- SCRIPT_SOUND_RAVE_1_LOOP_S = 84,
- SCRIPT_SOUND_RAVE_1_LOOP_L = 85,
- SCRIPT_SOUND_RAVE_2_LOOP_S = 86,
- SCRIPT_SOUND_RAVE_2_LOOP_L = 87,
- SCRIPT_SOUND_RAVE_3_LOOP_S = 88,
- SCRIPT_SOUND_RAVE_3_LOOP_L = 89,
- SCRIPT_SOUND_MISTY_SEX_S = 90,
- SCRIPT_SOUND_MISTY_SEX_L = 91,
- SCRIPT_SOUND_GATE_START_CLUNK = 92,
- SCRIPT_SOUND_GATE_STOP_CLUNK = 93,
- SCRIPT_SOUND_PART_MISSION_COMPLETE = 94,
- SCRIPT_SOUND_CHUNKY_RUN_SHOUT = 95,
- SCRIPT_SOUND_SECURITY_GUARD_AWAY_SHOUT = 96,
- SCRIPT_SOUND_RACE_START_3 = 97,
- SCRIPT_SOUND_RACE_START_2 = 98,
- SCRIPT_SOUND_RACE_START_1 = 99,
- SCRIPT_SOUND_RACE_START_GO = 100,
- SCRIPT_SOUND_SWAT_PED_SHOUT = 101,
- SCRIPT_SOUND_PRETEND_FIRE_LOOP = 102,
- SCRIPT_SOUND_AMMUNATION_CHAT_1 = 103,
- SCRIPT_SOUND_AMMUNATION_CHAT_2 = 104,
- SCRIPT_SOUND_AMMUNATION_CHAT_3 = 105,
- SCRIPT_SOUND_BULLET_HIT_GROUND_1 = 106,
- SCRIPT_SOUND_BULLET_HIT_GROUND_2 = 107,
- SCRIPT_SOUND_BULLET_HIT_GROUND_3 = 108,
- SCRIPT_SOUND_BULLET_HIT_WATER = 109, //no sound
- SCRIPT_SOUND_110 = 110,
- SCRIPT_SOUND_111 = 111,
- SCRIPT_SOUND_PAYPHONE_RINGING = 112,
- SCRIPT_SOUND_113 = 113,
- SCRIPT_SOUND_GLASS_BREAK_L = 114,
- SCRIPT_SOUND_GLASS_BREAK_S = 115,
- SCRIPT_SOUND_GLASS_CRACK = 116,
- SCRIPT_SOUND_GLASS_LIGHT_BREAK = 117,
- SCRIPT_SOUND_BOX_DESTROYED_1 = 118,
- SCRIPT_SOUND_BOX_DESTROYED_2 = 119,
- SCRIPT_SOUND_METAL_COLLISION = 120,
- SCRIPT_SOUND_TIRE_COLLISION = 121,
- SCRIPT_SOUND_GUNSHELL_DROP = 122,
- SCRIPT_SOUND_GUNSHELL_DROP_SOFT = 123,
-};
-
class tSound
{
public:
int32 m_nEntityIndex;
int32 m_nCounter;
int32 m_nSampleIndex;
- uint8 m_bBankIndex;
+ uint8 m_nBankIndex;
bool m_bIs2D;
int32 m_nReleasingVolumeModificator;
- int32 m_nFrequency;
- uint8 m_bVolume;
+ uint32 m_nFrequency;
+ uint8 m_nVolume;
float m_fDistance;
int32 m_nLoopCount;
int32 m_nLoopStart;
int32 m_nLoopEnd;
- uint8 m_bEmittingVolume;
+ uint8 m_nEmittingVolume;
float m_fSpeedMultiplier;
float m_fSoundIntensity;
bool m_bReleasingSoundFlag;
CVector m_vecPos;
bool m_bReverbFlag;
- uint8 m_bLoopsRemaining;
+ uint8 m_nLoopsRemaining;
bool m_bRequireReflection; // Used for oneshots
- uint8 m_bOffset;
+ uint8 m_nOffset;
int32 m_nReleasingVolumeDivider;
bool m_bIsProcessed;
bool m_bLoopEnded;
@@ -166,7 +35,7 @@ public:
int8 m_nVolumeChange;
};
-static_assert(sizeof(tSound) == 92, "tSound: error");
+VALIDATE_SIZE(tSound, 92);
class CPhysical;
class CAutomobile;
@@ -177,13 +46,13 @@ public:
eAudioType m_nType;
void *m_pEntity;
bool m_bIsUsed;
- uint8 m_bStatus;
+ uint8 m_nStatus;
int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS];
float m_afVolume[NUM_AUDIOENTITY_EVENTS];
uint8 m_AudioEvents;
};
-static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error");
+VALIDATE_SIZE(tAudioEntity, 40);
class tPedComment
{
@@ -196,7 +65,7 @@ public:
int8 m_nProcess;
};
-static_assert(sizeof(tPedComment) == 28, "tPedComment: error");
+VALIDATE_SIZE(tPedComment, 28);
class cPedComments
{
@@ -211,7 +80,7 @@ public:
void Process();
};
-static_assert(sizeof(cPedComments) == 1164, "cPedComments: error");
+VALIDATE_SIZE(cPedComments, 1164);
class CEntity;
@@ -220,15 +89,14 @@ class cMissionAudio
public:
CVector m_vecPos;
bool m_bPredefinedProperties;
- int m_nSampleIndex;
- uint8 m_bLoadingStatus;
- uint8 m_bPlayStatus;
+ int32 m_nSampleIndex;
+ uint8 m_nLoadingStatus;
+ uint8 m_nPlayStatus;
uint8 field_22; // todo find a name
int32 m_nMissionAudioCounter;
bool m_bIsPlayed;
};
-
-static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error");
+VALIDATE_SIZE(cMissionAudio, 32);
// name made up
class cAudioScriptObjectManager
@@ -262,11 +130,11 @@ public:
float m_fDistance;
CVehicle *m_pVehicle;
cTransmission *m_pTransmission;
- int m_nIndex;
+ int32 m_nIndex;
float m_fVelocityChange;
};
-static_assert(sizeof(cVehicleParams) == 0x18, "cVehicleParams: error");
+VALIDATE_SIZE(cVehicleParams, 0x18);
enum {
/*
@@ -291,17 +159,17 @@ public:
bool m_bIsInitialised;
uint8 field_1; // unused
bool m_bFifthFrameFlag;
- uint8 m_bActiveSamples;
+ uint8 m_nActiveSamples;
uint8 field_4; // unused
bool m_bDynamicAcousticModelingStatus;
float m_fSpeedOfSound;
bool m_bTimerJustReset;
int32 m_nTimer;
tSound m_sQueueSample;
- bool m_bActiveSampleQueue;
+ uint8 m_nActiveSampleQueue;
tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_SOUNDS_SAMPLES_SLOTS];
uint8 m_abSampleQueueIndexTable[NUM_SOUNDS_SAMPLES_BANKS][NUM_SOUNDS_SAMPLES_SLOTS];
- uint8 m_bSampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS];
+ uint8 m_SampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS];
tSound m_asActiveSamples[NUM_SOUNDS_SAMPLES_SLOTS];
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
@@ -321,9 +189,9 @@ public:
int32 m_nBridgeEntity;
cMissionAudio m_sMissionAudio;
int32 m_anRandomTable[5];
- uint8 m_bTimeSpent;
- uint8 m_bUserPause;
- uint8 m_bPreviousUserPause;
+ uint8 m_nTimeSpent;
+ uint8 m_nUserPause;
+ uint8 m_nPreviousUserPause;
uint32 m_FrameCounter;
cAudioManager();
@@ -333,7 +201,8 @@ public:
uint32 GetFrameCounter() const { return m_FrameCounter; }
float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; }
int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; }
- bool IsMissionAudioPlaying() const { return m_sMissionAudio.m_bPlayStatus == 1; }
+ int32 GetRandomNumberInRange(int32 idx, int32 low, int32 high) const { return (m_anRandomTable[idx] % (high - low + 1)) + low; }
+ bool IsMissionAudioPlaying() const { return m_sMissionAudio.m_nPlayStatus == 1; }
// "Should" be in alphabetic order, except "getXTalkSfx"
void AddDetailsToRequestedOrderList(uint8 sample);
@@ -447,7 +316,7 @@ public:
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used
float GetCollisionOneShotRatio(int32 a, float b) const;
float GetCollisionRatio(float a, float b, float c, float d) const;
- float GetDistanceSquared(CVector *v) const;
+ float GetDistanceSquared(const CVector &v) const;
int32 GetJumboTaxiFreq() const;
bool GetMissionAudioLoadingStatus() const;
int8 GetMissionScriptPoliceAudioPlayingStatus() const;
@@ -568,15 +437,15 @@ public:
void SetEffectsFadeVolume(uint8 volume) const;
void SetEffectsMasterVolume(uint8 volume) const;
void SetEntityStatus(int32 id, uint8 status);
- uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision);
+ uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision);
void SetMissionAudioLocation(float x, float y, float z);
void SetMissionScriptPoliceAudio(int32 sfx) const;
void SetMonoMode(uint8); // todo (mobile)
void SetMusicFadeVolume(uint8 volume) const;
void SetMusicMasterVolume(uint8 volume) const;
void SetSpeakerConfig(int32 conf) const;
- void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter);
- void SetUpOneShotCollisionSound(cAudioCollision *col);
+ void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter);
+ void SetUpOneShotCollisionSound(const cAudioCollision &col);
bool SetupCrimeReport();
bool SetupJumboEngineSound(uint8 vol, int32 freq);
bool SetupJumboFlySound(uint8 emittingVol);
@@ -587,7 +456,7 @@ public:
void SetupSuspectLastSeenReport();
void Terminate();
- void TranslateEntity(CVector *v1, CVector *v2) const;
+ void TranslateEntity(Const CVector *v1, CVector *v2) const;
void UpdateGasPedalAudio(CAutomobile *automobile);
void UpdateReflections();
@@ -598,6 +467,8 @@ public:
// only used in pc
void AdjustSamplesVolume();
uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist);
+
+ void DebugShit();
};
#ifdef AUDIO_MSS
diff --git a/src/audio/AudioScriptObject.h b/src/audio/AudioScriptObject.h
index 4308faee..ecc07fdf 100644
--- a/src/audio/AudioScriptObject.h
+++ b/src/audio/AudioScriptObject.h
@@ -148,6 +148,6 @@ public:
static void SaveAllAudioScriptObjects(uint8 *buf, uint32 *size);
};
-static_assert(sizeof(cAudioScriptObject) == 20, "cAudioScriptObject: error");
+VALIDATE_SIZE(cAudioScriptObject, 20);
extern void PlayOneShotScriptObject(uint8 id, CVector const &pos); \ No newline at end of file
diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h
index 6a94d57f..052fdb81 100644
--- a/src/audio/DMAudio.h
+++ b/src/audio/DMAudio.h
@@ -1,180 +1,9 @@
#pragma once
#include "audio_enums.h"
+#include "soundlist.h"
#include "Crime.h"
-enum eSound : int16
-{
- SOUND_CAR_DOOR_CLOSE_BONNET = 0,
- SOUND_CAR_DOOR_CLOSE_BUMPER = 1,
- SOUND_CAR_DOOR_CLOSE_FRONT_LEFT = 2,
- SOUND_CAR_DOOR_CLOSE_FRONT_RIGHT = 3,
- SOUND_CAR_DOOR_CLOSE_BACK_LEFT = 4,
- SOUND_CAR_DOOR_CLOSE_BACK_RIGHT = 5,
- SOUND_CAR_DOOR_OPEN_BONNET = 6,
- SOUND_CAR_DOOR_OPEN_BUMPER = 7,
- SOUND_CAR_DOOR_OPEN_FRONT_LEFT = 8,
- SOUND_CAR_DOOR_OPEN_FRONT_RIGHT = 9,
- SOUND_CAR_DOOR_OPEN_BACK_LEFT = 10,
- SOUND_CAR_DOOR_OPEN_BACK_RIGHT = 11,
- SOUND_CAR_WINDSHIELD_CRACK = 12,
- SOUND_CAR_JUMP = 13,
- SOUND_E = 14,
- SOUND_F = 15,
- SOUND_CAR_ENGINE_START = 16,
- SOUND_CAR_LIGHT_BREAK = 17,
- SOUND_CAR_HYDRAULIC_1 = 18,
- SOUND_CAR_HYDRAULIC_2 = 19,
- SOUND_CAR_HYDRAULIC_3 = 20,
- SOUND_CAR_JERK = 21,
- SOUND_CAR_SPLASH = 22,
- SOUND_17 = 23,
- SOUND_18 = 24,
- SOUND_19 = 25,
- SOUND_CAR_TANK_TURRET_ROTATE = 26,
- SOUND_CAR_BOMB_TICK = 27,
- SOUND_PLANE_ON_GROUND = 28,
- SOUND_STEP_START = 29,
- SOUND_STEP_END = 30,
- SOUND_FALL_LAND = 31,
- SOUND_FALL_COLLAPSE = 32,
- SOUND_FIGHT_PUNCH_33 = 33,
- SOUND_FIGHT_KICK_34 = 34,
- SOUND_FIGHT_HEADBUTT_35 = 35,
- SOUND_FIGHT_PUNCH_36 = 36,
- SOUND_FIGHT_PUNCH_37 = 37,
- SOUND_FIGHT_CLOSE_PUNCH_38 = 38,
- SOUND_FIGHT_PUNCH_39 = 39,
- SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40 = 40,
- SOUND_FIGHT_PUNCH_41 = 41,
- SOUND_FIGHT_PUNCH_FROM_BEHIND_42 = 42,
- SOUND_FIGHT_KNEE_OR_KICK_43 = 43,
- SOUND_FIGHT_KICK_44 = 44,
- SOUND_2D = 45,
- SOUND_WEAPON_BAT_ATTACK = 46,
- SOUND_WEAPON_SHOT_FIRED = 47,
- SOUND_WEAPON_RELOAD = 48,
- SOUND_WEAPON_AK47_BULLET_ECHO = 49,
- SOUND_WEAPON_UZI_BULLET_ECHO = 50,
- SOUND_WEAPON_M16_BULLET_ECHO = 51,
- SOUND_WEAPON_FLAMETHROWER_FIRE = 52,
- SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM = 53,
- SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM = 54,
- SOUND_WEAPON_HIT_PED = 55,
- SOUND_WEAPON_HIT_VEHICLE = 56,
- SOUND_GARAGE_NO_MONEY = 57,
- SOUND_GARAGE_BAD_VEHICLE = 58,
- SOUND_GARAGE_OPENING = 59,
- SOUND_GARAGE_BOMB_ALREADY_SET = 60,
- SOUND_GARAGE_BOMB1_SET = 61,
- SOUND_GARAGE_BOMB2_SET = 62,
- SOUND_GARAGE_BOMB3_SET = 63,
- SOUND_40 = 64,
- SOUND_41 = 65,
- SOUND_GARAGE_VEHICLE_DECLINED = 66,
- SOUND_GARAGE_VEHICLE_ACCEPTED = 67,
- SOUND_GARAGE_DOOR_CLOSED = 68,
- SOUND_GARAGE_DOOR_OPENED = 69,
- SOUND_CRANE_PICKUP = 70,
- SOUND_PICKUP_WEAPON_BOUGHT = 71,
- SOUND_PICKUP_WEAPON = 72,
- SOUND_PICKUP_HEALTH = 73,
- SOUND_4A = 74,
- SOUND_4B = 75,
- SOUND_PICKUP_ADRENALINE = 76,
- SOUND_PICKUP_ARMOUR = 77,
- SOUND_PICKUP_BONUS = 78,
- SOUND_PICKUP_MONEY = 79,
- SOUND_PICKUP_HIDDEN_PACKAGE = 80,
- SOUND_PICKUP_PACMAN_PILL = 81,
- SOUND_PICKUP_PACMAN_PACKAGE = 82,
- SOUND_PICKUP_FLOAT_PACKAGE = 83,
- SOUND_BOMB_TIMED_ACTIVATED = 84,
- SOUND_55 = 85,
- SOUND_BOMB_ONIGNITION_ACTIVATED = 86,
- SOUND_BOMB_TICK = 87,
- SOUND_RAMPAGE_START = 88,
- SOUND_RAMPAGE_ONGOING = 89,
- SOUND_RAMPAGE_PASSED = 90,
- SOUND_RAMPAGE_FAILED = 91,
- SOUND_RAMPAGE_KILL = 92,
- SOUND_RAMPAGE_CAR_BLOWN = 93,
- SOUND_EVIDENCE_PICKUP = 94,
- SOUND_UNLOAD_GOLD = 95,
- SOUND_PAGER = 96,
- SOUND_PED_DEATH = 97, // 103 in VC
- SOUND_PED_DAMAGE = 98, // 104 in VC
- SOUND_PED_HIT = 99, // 105 in VC
- SOUND_PED_LAND = 100, // hopefully 106 in VC
- SOUND_PED_BULLET_HIT = 101,
- SOUND_PED_BOMBER = 102,
- SOUND_PED_BURNING = 103, // 108 in VC
- SOUND_PED_ARREST_FBI = 104,
- SOUND_PED_ARREST_SWAT = 105,
- SOUND_PED_ARREST_COP = 106,
- SOUND_PED_HELI_PLAYER_FOUND = 107,
- SOUND_PED_HANDS_UP = 108,
- SOUND_PED_HANDS_COWER = 109,
- SOUND_PED_FLEE_SPRINT = 110, // 120 in VC
- SOUND_PED_CAR_JACKING = 111,
- SOUND_PED_MUGGING = 112,
- SOUND_PED_CAR_JACKED = 113,
- SOUND_PED_ROBBED = 114,
- SOUND_PED_TAXI_WAIT = 115, // 137 in VC
- SOUND_PED_ATTACK = 116,
- SOUND_PED_DEFEND = 117,
- SOUND_PED_PURSUIT_ARMY = 118,
- SOUND_PED_PURSUIT_FBI = 119,
- SOUND_PED_PURSUIT_SWAT = 120,
- SOUND_PED_PURSUIT_COP = 121,
- SOUND_PED_HEALING = 122,
- SOUND_PED_7B = 123,
- SOUND_PED_LEAVE_VEHICLE = 124,
- SOUND_PED_EVADE = 125, // 142 in VC
- SOUND_PED_FLEE_RUN = 126,
- SOUND_PED_CAR_COLLISION = 127, // 144-145-146 in VC
- SOUND_PED_SOLICIT = 128,
- SOUND_PED_EXTINGUISHING_FIRE = 129,
- SOUND_PED_WAIT_DOUBLEBACK = 130,
- SOUND_PED_CHAT_SEXY = 131,
- SOUND_PED_CHAT_EVENT = 132,
- SOUND_PED_CHAT = 133,
- SOUND_PED_BODYCAST_HIT = 134,
- SOUND_PED_TAXI_CALL = 135,
- SOUND_INJURED_PED_MALE_OUCH = 136,
- SOUND_INJURED_PED_FEMALE = 137,
- SOUND_8A = 138,
- SOUND_RACE_START_3 = 139,
- SOUND_RACE_START_2 = 140,
- SOUND_RACE_START_1 = 141,
- SOUND_RACE_START_GO = 142,
- SOUND_SPLASH = 143,
- SOUND_WATER_FALL = 144,
- SOUND_SPLATTER = 145,
- SOUND_CAR_PED_COLLISION = 146,
- SOUND_CLOCK_TICK = 147,
- SOUND_PART_MISSION_COMPLETE = 148,
- SOUND_FRONTEND_MENU_STARTING = 149,
- SOUND_FRONTEND_MENU_COMPLETED = 150,
- SOUND_FRONTEND_MENU_DENIED = 151,
- SOUND_FRONTEND_MENU_SUCCESS = 152,
- SOUND_FRONTEND_EXIT = 153,
- SOUND_9A = 154,
- SOUND_9B = 155,
- SOUND_FRONTEND_AUDIO_TEST = 156,
- SOUND_FRONTEND_FAIL = 157,
- SOUND_FRONTEND_NO_RADIO = 158,
- SOUND_FRONTEND_RADIO_CHANGE = 159,
- SOUND_A0 = 160,
- SOUND_AMMUNATION_WELCOME_1 = 161,
- SOUND_AMMUNATION_WELCOME_2 = 162,
- SOUND_AMMUNATION_WELCOME_3 = 163,
- SOUND_LIGHTNING = 164,
- SOUND_A5 = 165,
- SOUND_TOTAL_SOUNDS = 166,
- SOUND_TOTAL_PED_SOUNDS = 167,
-};
-
#define AEHANDLE_IS_FAILED(h) ((h)<0)
#define AEHANDLE_IS_OK(h) ((h)>=0)
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index efea6e45..fd02691e 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -1,5 +1,6 @@
#include "common.h"
#include <time.h>
+#include "soundlist.h"
#include "MusicManager.h"
#include "AudioManager.h"
#include "ControllerConfig.h"
@@ -54,10 +55,10 @@ cMusicManager::PlayerInCar()
if (!FindPlayerVehicle())
return true;
- if (FindPlayerVehicle()->m_status == STATUS_WRECKED)
+ if (FindPlayerVehicle()->GetStatus() == STATUS_WRECKED)
return false;
- switch(FindPlayerVehicle()->m_modelIndex) {
+ switch (FindPlayerVehicle()->GetModelIndex()) {
case MI_FIRETRUCK:
case MI_AMBULAN:
case MI_MRWHOOP:
@@ -302,14 +303,14 @@ cMusicManager::GetRadioInCar(void)
CVehicle *veh = FindPlayerVehicle();
if (veh != nil){
if (UsesPoliceRadio(veh)) {
- if (m_nRadioInCar == NO_STREAMED_SOUND || CReplay::IsPlayingBack() && AudioManager.m_bUserPause)
+ if (m_nRadioInCar == NO_STREAMED_SOUND || CReplay::IsPlayingBack() && AudioManager.m_nUserPause)
return POLICE_RADIO;
return m_nRadioInCar;
} else return veh->m_nRadioStation;
}
}
- if (m_nRadioInCar == NO_STREAMED_SOUND || CReplay::IsPlayingBack() && AudioManager.m_bUserPause)
+ if (m_nRadioInCar == NO_STREAMED_SOUND || CReplay::IsPlayingBack() && AudioManager.m_nUserPause)
return RADIO_OFF;
return m_nRadioInCar;
}
@@ -402,7 +403,7 @@ cMusicManager::ServiceFrontEndMode()
switch (m_nCurrentStreamedSound)
{
case STREAMED_SOUND_MISSION_COMPLETED:
- if (!AudioManager.m_bUserPause)
+ if (!AudioManager.m_nUserPause)
ChangeMusicMode(MUSICMODE_GAME);
break;
case STREAMED_SOUND_GAME_COMPLETED:
@@ -458,7 +459,7 @@ cMusicManager::ServiceGameMode()
nFramesSinceCutsceneEnded = -1;
}
- if (AudioManager.m_bPreviousUserPause)
+ if (AudioManager.m_nPreviousUserPause)
m_bPreviousPlayerInCar = false;
if (!m_bPlayerInCar) {
if (m_bPreviousPlayerInCar) {
diff --git a/src/audio/MusicManager.h b/src/audio/MusicManager.h
index 5d6f41cf..e8b94da6 100644
--- a/src/audio/MusicManager.h
+++ b/src/audio/MusicManager.h
@@ -84,6 +84,6 @@ public:
bool ChangeRadioChannel();
};
-static_assert(sizeof(cMusicManager) == 0x95C, "cMusicManager: error");
+VALIDATE_SIZE(cMusicManager, 0x95C);
extern cMusicManager MusicManager;
diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp
index c4946da6..ec02368e 100644
--- a/src/audio/PoliceRadio.cpp
+++ b/src/audio/PoliceRadio.cpp
@@ -130,18 +130,18 @@ cAudioManager::DoPoliceRadioCrackle()
m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity;
m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE;
- m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
+ m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = true;
m_sQueueSample.m_nReleasingVolumeModificator = 10;
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_RADIO_CRACKLE);
- m_sQueueSample.m_bVolume = m_anRandomTable[2] % 20 + 15;
+ m_sQueueSample.m_nVolume = m_anRandomTable[2] % 20 + 15;
m_sQueueSample.m_nLoopCount = 0;
- m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume;
+ m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE);
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_bReverbFlag = false;
- m_sQueueSample.m_bOffset = 63;
+ m_sQueueSample.m_nOffset = 63;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
@@ -155,7 +155,7 @@ cAudioManager::ServicePoliceRadio()
if(!m_bIsInitialised) return;
- if(!m_bUserPause) {
+ if(!m_nUserPause) {
bool crimeReport = SetupCrimeReport();
#ifdef FIX_BUGS // Crash at 0x5fe6ef
if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted)
@@ -190,14 +190,14 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
if (!m_bIsInitialised) return;
- if (m_bUserPause) {
+ if (m_nUserPause) {
if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel);
if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1 &&
SampleManager.IsStreamPlaying(1)) {
SampleManager.PauseStream(1, 1);
}
} else {
- if (m_bPreviousUserPause && g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES &&
+ if (m_nPreviousUserPause && g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES &&
bMissionAudioPhysicalPlayingStatus == 1) {
SampleManager.PauseStream(0, 1);
}
@@ -306,7 +306,7 @@ cAudioManager::SetupCrimeReport()
if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return false;
audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position);
if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) {
- zone = &CTheZones::ZoneArray[CTheZones::AudioZoneArray[audioZoneId]];
+ zone = CTheZones::GetAudioZone(audioZoneId);
for (int j = 0; j < NUMAUDIOZONES; j++) {
if (strcmp(zone->name, ZoneSfx[j].m_aName) == 0) {
sampleIndex = ZoneSfx[j].m_nSampleIndex;
@@ -538,7 +538,7 @@ cAudioManager::SetupSuspectLastSeenReport()
main_color = gCarColourTable[color1][1];
color_pre_modifier = gCarColourTable[color1][0];
color_post_modifier = gCarColourTable[color1][2];
- switch (veh->m_modelIndex) {
+ switch (veh->GetModelIndex()) {
#ifdef FIX_BUGS
case MI_COLUMB:
main_color = SFX_POLICE_RADIO_BLUE;
@@ -637,7 +637,7 @@ cAudioManager::SetupSuspectLastSeenReport()
break;
default:
- debug("\n *** UNKNOWN CAR MODEL INDEX %d *** ", veh->m_modelIndex);
+ debug("\n *** UNKNOWN CAR MODEL INDEX %d *** ", veh->GetModelIndex());
return;
}
m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1);
@@ -722,7 +722,7 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z)
if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && 60 - m_sPoliceRadioQueue.policeChannelTimer > 9) {
audioZone = CTheZones::FindAudioZone(&vec);
if (audioZone >= 0 && audioZone < NUMAUDIOZONES) {
- zone = &CTheZones::ZoneArray[CTheZones::AudioZoneArray[audioZone]];
+ zone = CTheZones::GetAudioZone(audioZone);
for (int i = 0; i < NUMAUDIOZONES; i++) {
if (strcmp(zone->name, ZoneSfx[i].m_aName) == 0) {
sample = ZoneSfx[i].m_nSampleIndex;
diff --git a/src/audio/PoliceRadio.h b/src/audio/PoliceRadio.h
index 0f351f52..c01f21ce 100644
--- a/src/audio/PoliceRadio.h
+++ b/src/audio/PoliceRadio.h
@@ -15,7 +15,7 @@ struct cAMCrime {
}
};
-static_assert(sizeof(cAMCrime) == 20, "cAMCrime: error ");
+VALIDATE_SIZE(cAMCrime, 20);
class cPoliceRadioQueue
{
@@ -43,4 +43,4 @@ public:
}
};
-static_assert(sizeof(cPoliceRadioQueue) == 444, "cPoliceRadioQueue: error "); \ No newline at end of file
+VALIDATE_SIZE(cPoliceRadioQueue, 444);
diff --git a/src/audio/soundlist.h b/src/audio/soundlist.h
new file mode 100644
index 00000000..64d7dbcb
--- /dev/null
+++ b/src/audio/soundlist.h
@@ -0,0 +1,301 @@
+#pragma once
+
+enum eSound : int16
+{
+ SOUND_CAR_DOOR_CLOSE_BONNET = 0,
+ SOUND_CAR_DOOR_CLOSE_BUMPER = 1,
+ SOUND_CAR_DOOR_CLOSE_FRONT_LEFT = 2,
+ SOUND_CAR_DOOR_CLOSE_FRONT_RIGHT = 3,
+ SOUND_CAR_DOOR_CLOSE_BACK_LEFT = 4,
+ SOUND_CAR_DOOR_CLOSE_BACK_RIGHT = 5,
+ SOUND_CAR_DOOR_OPEN_BONNET = 6,
+ SOUND_CAR_DOOR_OPEN_BUMPER = 7,
+ SOUND_CAR_DOOR_OPEN_FRONT_LEFT = 8,
+ SOUND_CAR_DOOR_OPEN_FRONT_RIGHT = 9,
+ SOUND_CAR_DOOR_OPEN_BACK_LEFT = 10,
+ SOUND_CAR_DOOR_OPEN_BACK_RIGHT = 11,
+ SOUND_CAR_WINDSHIELD_CRACK = 12,
+ SOUND_CAR_JUMP = 13,
+ SOUND_E = 14,
+ SOUND_F = 15,
+ SOUND_CAR_ENGINE_START = 16,
+ SOUND_CAR_LIGHT_BREAK = 17,
+ SOUND_CAR_HYDRAULIC_1 = 18,
+ SOUND_CAR_HYDRAULIC_2 = 19,
+ SOUND_CAR_HYDRAULIC_3 = 20,
+ SOUND_CAR_JERK = 21,
+ SOUND_CAR_SPLASH = 22,
+ SOUND_17 = 23,
+ SOUND_18 = 24,
+ SOUND_19 = 25,
+ SOUND_CAR_TANK_TURRET_ROTATE = 26,
+ SOUND_CAR_BOMB_TICK = 27,
+ SOUND_PLANE_ON_GROUND = 28,
+ SOUND_STEP_START = 29,
+ SOUND_STEP_END = 30,
+ SOUND_FALL_LAND = 31,
+ SOUND_FALL_COLLAPSE = 32,
+ SOUND_FIGHT_PUNCH_33 = 33,
+ SOUND_FIGHT_KICK_34 = 34,
+ SOUND_FIGHT_HEADBUTT_35 = 35,
+ SOUND_FIGHT_PUNCH_36 = 36,
+ SOUND_FIGHT_PUNCH_37 = 37,
+ SOUND_FIGHT_CLOSE_PUNCH_38 = 38,
+ SOUND_FIGHT_PUNCH_39 = 39,
+ SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40 = 40,
+ SOUND_FIGHT_PUNCH_41 = 41,
+ SOUND_FIGHT_PUNCH_FROM_BEHIND_42 = 42,
+ SOUND_FIGHT_KNEE_OR_KICK_43 = 43,
+ SOUND_FIGHT_KICK_44 = 44,
+ SOUND_2D = 45,
+ SOUND_WEAPON_BAT_ATTACK = 46,
+ SOUND_WEAPON_SHOT_FIRED = 47,
+ SOUND_WEAPON_RELOAD = 48,
+ SOUND_WEAPON_AK47_BULLET_ECHO = 49,
+ SOUND_WEAPON_UZI_BULLET_ECHO = 50,
+ SOUND_WEAPON_M16_BULLET_ECHO = 51,
+ SOUND_WEAPON_FLAMETHROWER_FIRE = 52,
+ SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM = 53,
+ SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM = 54,
+ SOUND_WEAPON_HIT_PED = 55,
+ SOUND_WEAPON_HIT_VEHICLE = 56,
+ SOUND_GARAGE_NO_MONEY = 57,
+ SOUND_GARAGE_BAD_VEHICLE = 58,
+ SOUND_GARAGE_OPENING = 59,
+ SOUND_GARAGE_BOMB_ALREADY_SET = 60,
+ SOUND_GARAGE_BOMB1_SET = 61,
+ SOUND_GARAGE_BOMB2_SET = 62,
+ SOUND_GARAGE_BOMB3_SET = 63,
+ SOUND_40 = 64,
+ SOUND_41 = 65,
+ SOUND_GARAGE_VEHICLE_DECLINED = 66,
+ SOUND_GARAGE_VEHICLE_ACCEPTED = 67,
+ SOUND_GARAGE_DOOR_CLOSED = 68,
+ SOUND_GARAGE_DOOR_OPENED = 69,
+ SOUND_CRANE_PICKUP = 70,
+ SOUND_PICKUP_WEAPON_BOUGHT = 71,
+ SOUND_PICKUP_WEAPON = 72,
+ SOUND_PICKUP_HEALTH = 73,
+ SOUND_4A = 74,
+ SOUND_4B = 75,
+ SOUND_PICKUP_ADRENALINE = 76,
+ SOUND_PICKUP_ARMOUR = 77,
+ SOUND_PICKUP_BONUS = 78,
+ SOUND_PICKUP_MONEY = 79,
+ SOUND_PICKUP_HIDDEN_PACKAGE = 80,
+ SOUND_PICKUP_PACMAN_PILL = 81,
+ SOUND_PICKUP_PACMAN_PACKAGE = 82,
+ SOUND_PICKUP_FLOAT_PACKAGE = 83,
+ SOUND_BOMB_TIMED_ACTIVATED = 84,
+ SOUND_55 = 85,
+ SOUND_BOMB_ONIGNITION_ACTIVATED = 86,
+ SOUND_BOMB_TICK = 87,
+ SOUND_RAMPAGE_START = 88,
+ SOUND_RAMPAGE_ONGOING = 89,
+ SOUND_RAMPAGE_PASSED = 90,
+ SOUND_RAMPAGE_FAILED = 91,
+ SOUND_RAMPAGE_KILL = 92,
+ SOUND_RAMPAGE_CAR_BLOWN = 93,
+ SOUND_EVIDENCE_PICKUP = 94,
+ SOUND_UNLOAD_GOLD = 95,
+ SOUND_PAGER = 96,
+ SOUND_PED_DEATH = 97, // 103 in VC
+ SOUND_PED_DAMAGE = 98, // 104 in VC
+ SOUND_PED_HIT = 99, // 105 in VC
+ SOUND_PED_LAND = 100, // hopefully 106 in VC
+ SOUND_PED_BULLET_HIT = 101,
+ SOUND_PED_BOMBER = 102,
+ SOUND_PED_BURNING = 103, // 108 in VC
+ SOUND_PED_ARREST_FBI = 104,
+ SOUND_PED_ARREST_SWAT = 105,
+ SOUND_PED_ARREST_COP = 106,
+ SOUND_PED_HELI_PLAYER_FOUND = 107,
+ SOUND_PED_HANDS_UP = 108,
+ SOUND_PED_HANDS_COWER = 109,
+ SOUND_PED_FLEE_SPRINT = 110, // 120 in VC
+ SOUND_PED_CAR_JACKING = 111,
+ SOUND_PED_MUGGING = 112,
+ SOUND_PED_CAR_JACKED = 113,
+ SOUND_PED_ROBBED = 114,
+ SOUND_PED_TAXI_WAIT = 115, // 137 in VC
+ SOUND_PED_ATTACK = 116,
+ SOUND_PED_DEFEND = 117,
+ SOUND_PED_PURSUIT_ARMY = 118,
+ SOUND_PED_PURSUIT_FBI = 119,
+ SOUND_PED_PURSUIT_SWAT = 120,
+ SOUND_PED_PURSUIT_COP = 121,
+ SOUND_PED_HEALING = 122,
+ SOUND_PED_7B = 123,
+ SOUND_PED_LEAVE_VEHICLE = 124,
+ SOUND_PED_EVADE = 125, // 142 in VC
+ SOUND_PED_FLEE_RUN = 126,
+ SOUND_PED_CAR_COLLISION = 127, // 144-145-146 in VC
+ SOUND_PED_SOLICIT = 128,
+ SOUND_PED_EXTINGUISHING_FIRE = 129,
+ SOUND_PED_WAIT_DOUBLEBACK = 130,
+ SOUND_PED_CHAT_SEXY = 131,
+ SOUND_PED_CHAT_EVENT = 132,
+ SOUND_PED_CHAT = 133,
+ SOUND_PED_BODYCAST_HIT = 134,
+ SOUND_PED_TAXI_CALL = 135,
+ SOUND_INJURED_PED_MALE_OUCH = 136,
+ SOUND_INJURED_PED_FEMALE = 137,
+ SOUND_INJURED_PED_MALE_PRISON = 138,
+ SOUND_RACE_START_3 = 139,
+ SOUND_RACE_START_2 = 140,
+ SOUND_RACE_START_1 = 141,
+ SOUND_RACE_START_GO = 142,
+ SOUND_SPLASH = 143,
+ SOUND_WATER_FALL = 144,
+ SOUND_SPLATTER = 145,
+ SOUND_CAR_PED_COLLISION = 146,
+ SOUND_CLOCK_TICK = 147,
+ SOUND_PART_MISSION_COMPLETE = 148,
+ SOUND_FRONTEND_MENU_STARTING = 149,
+ SOUND_FRONTEND_MENU_COMPLETED = 150,
+ SOUND_FRONTEND_MENU_DENIED = 151,
+ SOUND_FRONTEND_MENU_SUCCESS = 152,
+ SOUND_FRONTEND_EXIT = 153,
+ SOUND_9A = 154,
+ SOUND_9B = 155,
+ SOUND_FRONTEND_AUDIO_TEST = 156,
+ SOUND_FRONTEND_FAIL = 157,
+ SOUND_FRONTEND_NO_RADIO = 158,
+ SOUND_FRONTEND_RADIO_CHANGE = 159,
+ SOUND_A0 = 160,
+ SOUND_AMMUNATION_WELCOME_1 = 161,
+ SOUND_AMMUNATION_WELCOME_2 = 162,
+ SOUND_AMMUNATION_WELCOME_3 = 163,
+ SOUND_LIGHTNING = 164,
+ SOUND_A5 = 165,
+ SOUND_TOTAL_SOUNDS = 166,
+ SOUND_TOTAL_PED_SOUNDS = 167,
+};
+
+
+enum eScriptSounds : int16 {
+ SCRIPT_SOUND_0 = 0,
+ SCRIPT_SOUND_1 = 1,
+ SCRIPT_SOUND_2 = 2,
+ SCRIPT_SOUND_3 = 3,
+ SCRIPT_SOUND_PARTY_1_LOOP_S = 4,
+ SCRIPT_SOUND_PARTY_1_LOOP_L = 5,
+ SCRIPT_SOUND_PARTY_2_LOOP_S = 6,
+ SCRIPT_SOUND_PARTY_2_LOOP_L = 7,
+ SCRIPT_SOUND_PARTY_3_LOOP_S = 8,
+ SCRIPT_SOUND_PARTY_3_LOOP_L = 9,
+ SCRIPT_SOUND_PARTY_4_LOOP_S = 10,
+ SCRIPT_SOUND_PARTY_4_LOOP_L = 11,
+ SCRIPT_SOUND_PARTY_5_LOOP_S = 12,
+ SCRIPT_SOUND_PARTY_5_LOOP_L = 13,
+ SCRIPT_SOUND_PARTY_6_LOOP_S = 14,
+ SCRIPT_SOUND_PARTY_6_LOOP_L = 15,
+ SCRIPT_SOUND_PARTY_7_LOOP_S = 16,
+ SCRIPT_SOUND_PARTY_7_LOOP_L = 17,
+ SCRIPT_SOUND_PARTY_8_LOOP_S = 18,
+ SCRIPT_SOUND_PARTY_8_LOOP_L = 19,
+ SCRIPT_SOUND_PARTY_9_LOOP_S = 20,
+ SCRIPT_SOUND_PARTY_9_LOOP_L = 21,
+ SCRIPT_SOUND_PARTY_10_LOOP_S = 22,
+ SCRIPT_SOUND_PARTY_10_LOOP_L = 23,
+ SCRIPT_SOUND_PARTY_11_LOOP_S = 24,
+ SCRIPT_SOUND_PARTY_11_LOOP_L = 25,
+ SCRIPT_SOUND_PARTY_12_LOOP_S = 26,
+ SCRIPT_SOUND_PARTY_12_LOOP_L = 27,
+ SCRIPT_SOUND_PARTY_13_LOOP_S = 28,
+ SCRIPT_SOUND_PARTY_13_LOOP_L = 29,
+ SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S = 30,
+ SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L = 31,
+ SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S = 32,
+ SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L = 33,
+ SCRIPT_SOUND_WORK_SHOP_LOOP_S = 34,
+ SCRIPT_SOUND_WORK_SHOP_LOOP_L = 35,
+ SCRIPT_SOUND_SAWMILL_LOOP_S = 36,
+ SCRIPT_SOUND_SAWMILL_LOOP_L = 37,
+ SCRIPT_SOUND_38 = 38,
+ SCRIPT_SOUND_39 = 39,
+ SCRIPT_SOUND_LAUNDERETTE_LOOP_S = 40,
+ SCRIPT_SOUND_LAUNDERETTE_LOOP_L = 41,
+ SCRIPT_SOUND_CHINATOWN_RESTAURANT_S = 42,
+ SCRIPT_SOUND_CHINATOWN_RESTAURANT_L = 43,
+ SCRIPT_SOUND_CIPRIANI_RESAURANT_S = 44,
+ SCRIPT_SOUND_CIPRIANI_RESAURANT_L = 45,
+ SCRIPT_SOUND_46_S = 46,
+ SCRIPT_SOUND_47_L = 47,
+ SCRIPT_SOUND_MARCO_BISTRO_S = 48,
+ SCRIPT_SOUND_MARCO_BISTRO_L = 49,
+ SCRIPT_SOUND_AIRPORT_LOOP_S = 50,
+ SCRIPT_SOUND_AIRPORT_LOOP_L = 51,
+ SCRIPT_SOUND_SHOP_LOOP_S = 52,
+ SCRIPT_SOUND_SHOP_LOOP_L = 53,
+ SCRIPT_SOUND_CINEMA_LOOP_S = 54,
+ SCRIPT_SOUND_CINEMA_LOOP_L = 55,
+ SCRIPT_SOUND_DOCKS_LOOP_S = 56,
+ SCRIPT_SOUND_DOCKS_LOOP_L = 57,
+ SCRIPT_SOUND_HOME_LOOP_S = 58,
+ SCRIPT_SOUND_HOME_LOOP_L = 59,
+ SCRIPT_SOUND_FRANKIE_PIANO = 60,
+ SCRIPT_SOUND_PARTY_1_LOOP = 61,
+ SCRIPT_SOUND_PORN_CINEMA_1_S = 62,
+ SCRIPT_SOUND_PORN_CINEMA_1_L = 63,
+ SCRIPT_SOUND_PORN_CINEMA_2_S = 64,
+ SCRIPT_SOUND_PORN_CINEMA_2_L = 65,
+ SCRIPT_SOUND_PORN_CINEMA_3_S = 66,
+ SCRIPT_SOUND_PORN_CINEMA_3_L = 67,
+ SCRIPT_SOUND_BANK_ALARM_LOOP_S = 68,
+ SCRIPT_SOUND_BANK_ALARM_LOOP_L = 69,
+ SCRIPT_SOUND_POLICE_BALL_LOOP_S = 70,
+ SCRIPT_SOUND_POLICE_BALL_LOOP_L = 71,
+ SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S = 72,
+ SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L = 73,
+ SCRIPT_SOUND_74 = 74,
+ SCRIPT_SOUND_75 = 75,
+ SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S = 76,
+ SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L = 77,
+ SCRIPT_SOUND_INJURED_PED_MALE_OUCH_S = 78,
+ SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L = 79,
+ SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S = 80,
+ SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L = 81,
+ SCRIPT_SOUND_EVIDENCE_PICKUP = 82,
+ SCRIPT_SOUND_UNLOAD_GOLD = 83,
+ SCRIPT_SOUND_RAVE_1_LOOP_S = 84,
+ SCRIPT_SOUND_RAVE_1_LOOP_L = 85,
+ SCRIPT_SOUND_RAVE_2_LOOP_S = 86,
+ SCRIPT_SOUND_RAVE_2_LOOP_L = 87,
+ SCRIPT_SOUND_RAVE_3_LOOP_S = 88,
+ SCRIPT_SOUND_RAVE_3_LOOP_L = 89,
+ SCRIPT_SOUND_MISTY_SEX_S = 90,
+ SCRIPT_SOUND_MISTY_SEX_L = 91,
+ SCRIPT_SOUND_GATE_START_CLUNK = 92,
+ SCRIPT_SOUND_GATE_STOP_CLUNK = 93,
+ SCRIPT_SOUND_PART_MISSION_COMPLETE = 94,
+ SCRIPT_SOUND_CHUNKY_RUN_SHOUT = 95,
+ SCRIPT_SOUND_SECURITY_GUARD_AWAY_SHOUT = 96,
+ SCRIPT_SOUND_RACE_START_3 = 97,
+ SCRIPT_SOUND_RACE_START_2 = 98,
+ SCRIPT_SOUND_RACE_START_1 = 99,
+ SCRIPT_SOUND_RACE_START_GO = 100,
+ SCRIPT_SOUND_SWAT_PED_SHOUT = 101,
+ SCRIPT_SOUND_PRETEND_FIRE_LOOP = 102,
+ SCRIPT_SOUND_AMMUNATION_CHAT_1 = 103,
+ SCRIPT_SOUND_AMMUNATION_CHAT_2 = 104,
+ SCRIPT_SOUND_AMMUNATION_CHAT_3 = 105,
+ SCRIPT_SOUND_BULLET_HIT_GROUND_1 = 106,
+ SCRIPT_SOUND_BULLET_HIT_GROUND_2 = 107,
+ SCRIPT_SOUND_BULLET_HIT_GROUND_3 = 108,
+ SCRIPT_SOUND_BULLET_HIT_WATER = 109, //no sound
+ SCRIPT_SOUND_110 = 110,
+ SCRIPT_SOUND_111 = 111,
+ SCRIPT_SOUND_PAYPHONE_RINGING = 112,
+ SCRIPT_SOUND_113 = 113,
+ SCRIPT_SOUND_GLASS_BREAK_L = 114,
+ SCRIPT_SOUND_GLASS_BREAK_S = 115,
+ SCRIPT_SOUND_GLASS_CRACK = 116,
+ SCRIPT_SOUND_GLASS_LIGHT_BREAK = 117,
+ SCRIPT_SOUND_BOX_DESTROYED_1 = 118,
+ SCRIPT_SOUND_BOX_DESTROYED_2 = 119,
+ SCRIPT_SOUND_METAL_COLLISION = 120,
+ SCRIPT_SOUND_TIRE_COLLISION = 121,
+ SCRIPT_SOUND_GUNSHELL_DROP = 122,
+ SCRIPT_SOUND_GUNSHELL_DROP_SOFT = 123,
+};
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp
index 69511bc8..b1fce95f 100644
--- a/src/control/AutoPilot.cpp
+++ b/src/control/AutoPilot.cpp
@@ -12,17 +12,17 @@ void CAutoPilot::ModifySpeed(float speed)
float positionBetweenNodes = (float)(CTimer::GetTimeInMilliseconds() - m_nTimeEnteredCurve) / m_nTimeToSpendOnCurrentCurve;
CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[m_nCurrentPathNodeInfo];
CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[m_nNextPathNodeInfo];
- float currentPathLinkForwardX = m_nCurrentDirection * ThePaths.m_carPathLinks[m_nCurrentPathNodeInfo].dir.x;
- float currentPathLinkForwardY = m_nCurrentDirection * ThePaths.m_carPathLinks[m_nCurrentPathNodeInfo].dir.y;
- float nextPathLinkForwardX = m_nNextDirection * ThePaths.m_carPathLinks[m_nNextPathNodeInfo].dir.x;
- float nextPathLinkForwardY = m_nNextDirection * ThePaths.m_carPathLinks[m_nNextPathNodeInfo].dir.y;
+ float currentPathLinkForwardX = m_nCurrentDirection * ThePaths.m_carPathLinks[m_nCurrentPathNodeInfo].GetDirX();
+ float currentPathLinkForwardY = m_nCurrentDirection * ThePaths.m_carPathLinks[m_nCurrentPathNodeInfo].GetDirY();
+ float nextPathLinkForwardX = m_nNextDirection * ThePaths.m_carPathLinks[m_nNextPathNodeInfo].GetDirX();
+ float nextPathLinkForwardY = m_nNextDirection * ThePaths.m_carPathLinks[m_nNextPathNodeInfo].GetDirY();
CVector positionOnCurrentLinkIncludingLane(
- pCurrentLink->pos.x + ((m_nCurrentLane + 0.5f) * LANE_WIDTH) * currentPathLinkForwardY,
- pCurrentLink->pos.y - ((m_nCurrentLane + 0.5f) * LANE_WIDTH) * currentPathLinkForwardX,
+ pCurrentLink->GetX() + ((m_nCurrentLane + 0.5f) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurrentLink->GetY() - ((m_nCurrentLane + 0.5f) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f);
CVector positionOnNextLinkIncludingLane(
- pNextLink->pos.x + ((m_nNextLane + 0.5f) * LANE_WIDTH) * nextPathLinkForwardY,
- pNextLink->pos.y - ((m_nNextLane + 0.5f) * LANE_WIDTH) * nextPathLinkForwardX,
+ pNextLink->GetX() + ((m_nNextLane + 0.5f) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((m_nNextLane + 0.5f) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor(
&positionOnCurrentLinkIncludingLane,
@@ -44,4 +44,83 @@ void CAutoPilot::RemoveOnePathNode()
--m_nPathFindNodesCount;
for (int i = 0; i < m_nPathFindNodesCount; i++)
m_aPathFindNodesInfo[i] = m_aPathFindNodesInfo[i + 1];
-} \ No newline at end of file
+}
+
+#ifdef COMPATIBLE_SAVES
+void CAutoPilot::Save(uint8*& buf)
+{
+ WriteSaveBuf<int32>(buf, m_nCurrentRouteNode);
+ WriteSaveBuf<int32>(buf, m_nNextRouteNode);
+ WriteSaveBuf<int32>(buf, m_nPrevRouteNode);
+ WriteSaveBuf<uint32>(buf, m_nTimeEnteredCurve);
+ WriteSaveBuf<uint32>(buf, m_nTimeToSpendOnCurrentCurve);
+ WriteSaveBuf<uint32>(buf, m_nCurrentPathNodeInfo);
+ WriteSaveBuf<uint32>(buf, m_nNextPathNodeInfo);
+ WriteSaveBuf<uint32>(buf, m_nPreviousPathNodeInfo);
+ WriteSaveBuf<uint32>(buf, m_nAntiReverseTimer);
+ WriteSaveBuf<uint32>(buf, m_nTimeToStartMission);
+ WriteSaveBuf<int8>(buf, m_nPreviousDirection);
+ WriteSaveBuf<int8>(buf, m_nCurrentDirection);
+ WriteSaveBuf<int8>(buf, m_nNextDirection);
+ WriteSaveBuf<int8>(buf, m_nCurrentLane);
+ WriteSaveBuf<int8>(buf, m_nNextLane);
+ WriteSaveBuf<uint8>(buf, m_nDrivingStyle);
+ WriteSaveBuf<uint8>(buf, m_nCarMission);
+ WriteSaveBuf<uint8>(buf, m_nTempAction);
+ WriteSaveBuf<uint32>(buf, m_nTimeTempAction);
+ WriteSaveBuf<float>(buf, m_fMaxTrafficSpeed);
+ WriteSaveBuf<uint8>(buf, m_nCruiseSpeed);
+ uint8 flags = 0;
+ if (m_bSlowedDownBecauseOfCars) flags |= BIT(0);
+ if (m_bSlowedDownBecauseOfPeds) flags |= BIT(1);
+ if (m_bStayInCurrentLevel) flags |= BIT(2);
+ if (m_bStayInFastLane) flags |= BIT(3);
+ if (m_bIgnorePathfinding) flags |= BIT(4);
+ WriteSaveBuf<uint8>(buf, flags);
+ SkipSaveBuf(buf, 2);
+ WriteSaveBuf<float>(buf, m_vecDestinationCoors.x);
+ WriteSaveBuf<float>(buf, m_vecDestinationCoors.y);
+ WriteSaveBuf<float>(buf, m_vecDestinationCoors.z);
+ SkipSaveBuf(buf, 32);
+ WriteSaveBuf<int16>(buf, m_nPathFindNodesCount);
+ SkipSaveBuf(buf, 6);
+}
+
+void CAutoPilot::Load(uint8*& buf)
+{
+ m_nCurrentRouteNode = ReadSaveBuf<int32>(buf);
+ m_nNextRouteNode = ReadSaveBuf<int32>(buf);
+ m_nPrevRouteNode = ReadSaveBuf<int32>(buf);
+ m_nTimeEnteredCurve = ReadSaveBuf<uint32>(buf);
+ m_nTimeToSpendOnCurrentCurve = ReadSaveBuf<uint32>(buf);
+ m_nCurrentPathNodeInfo = ReadSaveBuf<uint32>(buf);
+ m_nNextPathNodeInfo = ReadSaveBuf<uint32>(buf);
+ m_nPreviousPathNodeInfo = ReadSaveBuf<uint32>(buf);
+ m_nAntiReverseTimer = ReadSaveBuf<uint32>(buf);
+ m_nTimeToStartMission = ReadSaveBuf<uint32>(buf);
+ m_nPreviousDirection = ReadSaveBuf<int8>(buf);
+ m_nCurrentDirection = ReadSaveBuf<int8>(buf);
+ m_nNextDirection = ReadSaveBuf<int8>(buf);
+ m_nCurrentLane = ReadSaveBuf<int8>(buf);
+ m_nNextLane = ReadSaveBuf<int8>(buf);
+ m_nDrivingStyle = (eCarDrivingStyle)ReadSaveBuf<uint8>(buf);
+ m_nCarMission = (eCarMission)ReadSaveBuf<uint8>(buf);
+ m_nTempAction = (eCarTempAction)ReadSaveBuf<uint8>(buf);
+ m_nTimeTempAction = ReadSaveBuf<uint32>(buf);
+ m_fMaxTrafficSpeed = ReadSaveBuf<float>(buf);
+ m_nCruiseSpeed = ReadSaveBuf<uint8>(buf);
+ uint8 flags = ReadSaveBuf<uint8>(buf);
+ m_bSlowedDownBecauseOfCars = !!(flags & BIT(0));
+ m_bSlowedDownBecauseOfPeds = !!(flags & BIT(1));
+ m_bStayInCurrentLevel = !!(flags & BIT(2));
+ m_bStayInFastLane = !!(flags & BIT(3));
+ m_bIgnorePathfinding = !!(flags & BIT(4));
+ SkipSaveBuf(buf, 2);
+ m_vecDestinationCoors.x = ReadSaveBuf<float>(buf);
+ m_vecDestinationCoors.y = ReadSaveBuf<float>(buf);
+ m_vecDestinationCoors.z = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 32);
+ m_nPathFindNodesCount = ReadSaveBuf<int16>(buf);
+ SkipSaveBuf(buf, 6);
+}
+#endif \ No newline at end of file
diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h
index e1066071..337a93c1 100644
--- a/src/control/AutoPilot.h
+++ b/src/control/AutoPilot.h
@@ -26,13 +26,6 @@ enum eCarMission : uint8
MISSION_BLOCKCAR_FARAWAY,
MISSION_BLOCKCAR_CLOSE,
MISSION_BLOCKCAR_HANDBRAKESTOP,
- MISSION_HELI_FLYTOCOORS,
- MISSION_ATTACKPLAYER,
- MISSION_PLANE_FLYTOCOORS,
- MISSION_HELI_LAND,
- MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1,
- MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_2,
- MISSION_BLOCKPLAYER_FORWARDANDBACK
};
enum eCarTempAction : uint8
@@ -120,5 +113,11 @@ public:
void ModifySpeed(float);
void RemoveOnePathNode();
+#ifdef COMPATIBLE_SAVES
+ void Save(uint8*& buf);
+ void Load(uint8*& buf);
+#endif
+
};
-static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error");
+
+VALIDATE_SIZE(CAutoPilot, 0x70);
diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp
index 8514ef9e..e873062b 100644
--- a/src/control/Bridge.cpp
+++ b/src/control/Bridge.cpp
@@ -93,16 +93,16 @@ void CBridge::Update()
// Move bridge part
if (liftHeight != OldLift)
{
- pLiftPart->GetPosition().z = DefaultZLiftPart + liftHeight;
+ pLiftPart->GetMatrix().GetPosition().z = DefaultZLiftPart + liftHeight;
pLiftPart->GetMatrix().UpdateRW();
pLiftPart->UpdateRwFrame();
if (pLiftRoad)
{
- pLiftRoad->GetPosition().z = DefaultZLiftRoad + liftHeight;
+ pLiftRoad->GetMatrix().GetPosition().z = DefaultZLiftRoad + liftHeight;
pLiftRoad->GetMatrix().UpdateRW();
pLiftRoad->UpdateRwFrame();
}
- pWeight->GetPosition().z = DefaultZLiftWeight - liftHeight;
+ pWeight->GetMatrix().GetPosition().z = DefaultZLiftWeight - liftHeight;
pWeight->GetMatrix().UpdateRW();
pWeight->UpdateRwFrame();
@@ -115,7 +115,10 @@ void CBridge::Update()
ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, false);
}
-bool CBridge::ShouldLightsBeFlashing() { return State != STATE_LIFT_PART_IS_DOWN; }
+bool CBridge::ShouldLightsBeFlashing()
+{
+ return State != STATE_LIFT_PART_IS_DOWN;
+}
void CBridge::FindBridgeEntities()
{
diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp
index a8e77fc2..3e22ee77 100644
--- a/src/control/CarAI.cpp
+++ b/src/control/CarAI.cpp
@@ -21,19 +21,25 @@
#define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f
-float CCarAI::FindSwitchDistanceClose(CVehicle*)
+float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle)
{
return 30.0f;
}
+float CCarAI::FindSwitchDistanceFarNormalVehicle(CVehicle* pVehicle)
+{
+ return FindSwitchDistanceClose(pVehicle) + 5.0f;
+}
+
float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle)
{
- return pVehicle->bIsLawEnforcer ? 50.0f : 35.0f;
+ if (pVehicle->bIsLawEnforcer)
+ return 50.0f;
+ return FindSwitchDistanceFarNormalVehicle(pVehicle);
}
void CCarAI::UpdateCarAI(CVehicle* pVehicle)
{
- //return;
if (pVehicle->bIsLawEnforcer){
if (pVehicle->AutoPilot.m_nCarMission == MISSION_BLOCKCAR_FARAWAY ||
pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY ||
@@ -41,7 +47,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE)
pVehicle->AutoPilot.m_nCruiseSpeed = FindPoliceCarSpeedForWantedLevel(pVehicle);
}
- switch (pVehicle->m_status){
+ switch (pVehicle->GetStatus()){
case STATUS_PLAYER:
case STATUS_PLAYER_PLAYBACKFROMBUFFER:
case STATUS_TRAIN_MOVING:
@@ -65,6 +71,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
pVehicle->m_bSirenOrAlarm = false;
if (CCullZones::NoPolice())
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
@@ -117,10 +124,12 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())){
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
pVehicle->m_bSirenOrAlarm = false;
if (CCullZones::NoPolice())
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
}
+
else if (pVehicle->bIsLawEnforcer)
MellowOutChaseSpeed(pVehicle);
break;
@@ -135,6 +144,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
pVehicle->m_bSirenOrAlarm = false;
if (CCullZones::NoPolice())
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
@@ -172,11 +182,12 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
(FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
pVehicle->m_bSirenOrAlarm = false;
if (CCullZones::NoPolice())
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
}
- else if (pVehicle->bIsLawEnforcer)
+ if (pVehicle->bIsLawEnforcer)
MellowOutChaseSpeed(pVehicle);
break;
case MISSION_GOTOCOORDS:
@@ -193,7 +204,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
}
- else if (distance > 35.0f && !pVehicle->AutoPilot.m_bIgnorePathfinding && (CTimer::GetFrameCounter() & 7) == 0){
+ else if (distance > FindSwitchDistanceFarNormalVehicle(pVehicle) && !pVehicle->AutoPilot.m_bIgnorePathfinding && (CTimer::GetFrameCounter() & 7) == 0){
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
pVehicle->AutoPilot.m_nCarMission = (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, pVehicle->AutoPilot.m_vecDestinationCoors, true)) ?
MISSION_GOTOCOORDS_STRAIGHT : MISSION_GOTOCOORDS;
@@ -249,7 +260,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
}
- else if (distance > 35.0f && !pVehicle->AutoPilot.m_bIgnorePathfinding && (CTimer::GetFrameCounter() & 7) == 0) {
+ else if (distance > FindSwitchDistanceFarNormalVehicle(pVehicle) && !pVehicle->AutoPilot.m_bIgnorePathfinding && (CTimer::GetFrameCounter() & 7) == 0) {
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
pVehicle->AutoPilot.m_nCarMission = (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, pVehicle->AutoPilot.m_vecDestinationCoors, true)) ?
MISSION_GOTO_COORDS_STRAIGHT_ACCURATE : MISSION_GOTOCOORDS_ACCURATE;
@@ -330,12 +341,13 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
if (ABS(FindPlayerCoors().x - pVehicle->GetPosition().x) > 10.0f ||
ABS(FindPlayerCoors().y - pVehicle->GetPosition().y) > 10.0f){
pVehicle->AutoPilot.m_nCruiseSpeed = FindPoliceCarSpeedForWantedLevel(pVehicle);
- pVehicle->m_status = STATUS_PHYSICS;
- pVehicle->AutoPilot.m_nCarMission = FindPoliceCarMissionForWantedLevel();
+ pVehicle->SetStatus(STATUS_PHYSICS);
+ pVehicle->AutoPilot.m_nCarMission =
+ FindPoliceCarMissionForWantedLevel();
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
}else if (pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE){
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
TellOccupantsToLeaveCar(pVehicle);
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
@@ -357,12 +369,13 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds();
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
}
- if (pVehicle->m_status == STATUS_PHYSICS && pVehicle->AutoPilot.m_nTempAction == TEMPACT_NONE){
+ if (pVehicle->GetStatus() == STATUS_PHYSICS && pVehicle->AutoPilot.m_nTempAction == TEMPACT_NONE){
if (pVehicle->AutoPilot.m_nCarMission != MISSION_NONE){
if (pVehicle->AutoPilot.m_nCarMission != MISSION_STOP_FOREVER &&
pVehicle->AutoPilot.m_nCruiseSpeed != 0 &&
(pVehicle->VehicleCreatedBy != RANDOM_VEHICLE || pVehicle->AutoPilot.m_nCarMission != MISSION_CRUISE)){
- if (pVehicle->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_STOP_FOR_CARS){
+ if (pVehicle->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_STOP_FOR_CARS
+ ) {
if (CTimer::GetTimeInMilliseconds() - pVehicle->m_nLastTimeCollided > 500)
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
if (flatSpeed < SQR(0.018f) && CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nAntiReverseTimer > 2000){
@@ -386,7 +399,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
CTimer::GetPreviousTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeToStartMission <= 30000 &&
pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE &&
!CTrafficLights::ShouldCarStopForBridge(pVehicle)){
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
CCarCtrl::SwitchVehicleToRealPhysics(pVehicle);
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
pVehicle->AutoPilot.m_nTempAction = TEMPACT_REVERSE;
@@ -446,7 +459,7 @@ float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget)
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
pVehicle->AutoPilot.m_nCruiseSpeed = 20;
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
pVehicle->AutoPilot.m_nCarMission = (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, *pTarget, false)) ?
MISSION_GOTOCOORDS_STRAIGHT : MISSION_GOTOCOORDS;
}else if (Abs(pTarget->x - pVehicle->AutoPilot.m_vecDestinationCoors.x) > 2.0f ||
@@ -456,10 +469,11 @@ float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget)
return (pVehicle->GetPosition() - *pTarget).Magnitude2D();
}
-void CCarAI::AddPoliceOccupants(CVehicle* pVehicle)
+void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle)
{
if (pVehicle->bOccupantsHaveBeenGenerated)
return;
+ pVehicle->bOccupantsHaveBeenGenerated = true;
switch (pVehicle->GetModelIndex()){
case MI_FBICAR:
case MI_ENFORCER:
@@ -495,12 +509,14 @@ void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle)
{
if (pVehicle->pDriver){
pVehicle->pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle);
- if (pVehicle->GetModelIndex())
+ if (pVehicle->GetModelIndex() == MI_AMBULAN)
pVehicle->pDriver->Say(SOUND_PED_LEAVE_VEHICLE);
}
+ int timer = 100;
for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++){
- if (pVehicle->pPassengers[i])
+ if (pVehicle->pPassengers[i]) {
pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle);
+ }
}
}
@@ -521,6 +537,7 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
pVehicle->bEngineOn = true;
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
}
+
eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
{
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){
@@ -601,9 +618,9 @@ void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle)
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!vehicle)
continue;
- if (vehicle->m_vehType != VEHICLE_TYPE_CAR && vehicle->m_vehType != VEHICLE_TYPE_BIKE)
+ if (!vehicle->IsCar() && !vehicle->IsBike())
continue;
- if (vehicle->m_status != STATUS_SIMPLE && vehicle->m_status != STATUS_PHYSICS)
+ if (vehicle->GetStatus() != STATUS_SIMPLE && vehicle->GetStatus() != STATUS_PHYSICS)
continue;
if (vehicle->VehicleCreatedBy != RANDOM_VEHICLE)
continue;
@@ -627,7 +644,7 @@ void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle)
TEMPACT_SWERVELEFT : TEMPACT_SWERVERIGHT;
vehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2000;
}
- vehicle->m_status = STATUS_PHYSICS;
+ vehicle->SetStatus(STATUS_PHYSICS);
}else{
if (DotProduct2D(vehicle->GetMoveSpeed(), distance) < 0.0f && vehicle->AutoPilot.m_nTempAction != TEMPACT_WAIT){
vehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
diff --git a/src/control/CarAI.h b/src/control/CarAI.h
index fbd46e95..e88807c8 100644
--- a/src/control/CarAI.h
+++ b/src/control/CarAI.h
@@ -8,11 +8,12 @@ class CCarAI
{
public:
static float FindSwitchDistanceClose(CVehicle*);
+ static float FindSwitchDistanceFarNormalVehicle(CVehicle*);
static float FindSwitchDistanceFar(CVehicle*);
static void UpdateCarAI(CVehicle*);
static void CarHasReasonToStop(CVehicle*);
static float GetCarToGoToCoors(CVehicle*, CVector*);
- static void AddPoliceOccupants(CVehicle*);
+ static void AddPoliceCarOccupants(CVehicle*);
static void AddAmbulanceOccupants(CVehicle*);
static void AddFiretruckOccupants(CVehicle*);
static void TellOccupantsToLeaveCar(CVehicle*);
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index f347b2c9..71236580 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -281,7 +281,7 @@ CCarCtrl::GenerateOneRandomCar()
CPathNode* pCurNode = &ThePaths.m_pathNodes[curNodeId];
CPathNode* pNextNode = &ThePaths.m_pathNodes[nextNodeId];
while (idInNode < pCurNode->numLinks &&
- ThePaths.m_connections[idInNode + pCurNode->firstLink] != nextNodeId)
+ ThePaths.ConnectedNode(idInNode + pCurNode->firstLink) != nextNodeId)
idInNode++;
int16 connectionId = ThePaths.m_carPathConnections[idInNode + pCurNode->firstLink];
CCarPathLink* pPathLink = &ThePaths.m_carPathLinks[connectionId];
@@ -291,10 +291,10 @@ CCarCtrl::GenerateOneRandomCar()
/* Not spawning vehicle if road is one way and intended direction is opposide to that way. */
/* Also not spawning bikes but they don't exist in final game. */
return;
- CAutomobile* pCar = new CAutomobile(carModel, RANDOM_VEHICLE);
- pCar->AutoPilot.m_nPrevRouteNode = 0;
- pCar->AutoPilot.m_nCurrentRouteNode = curNodeId;
- pCar->AutoPilot.m_nNextRouteNode = nextNodeId;
+ CAutomobile* pVehicle = new CAutomobile(carModel, RANDOM_VEHICLE);
+ pVehicle->AutoPilot.m_nPrevRouteNode = 0;
+ pVehicle->AutoPilot.m_nCurrentRouteNode = curNodeId;
+ pVehicle->AutoPilot.m_nNextRouteNode = nextNodeId;
switch (carClass) {
case POOR:
case RICH:
@@ -313,71 +313,71 @@ CCarCtrl::GenerateOneRandomCar()
case GANG8:
case GANG9:
{
- pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(9, 14);
+ pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(9, 14);
if (carClass == EXEC)
- pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 18);
+ pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 18);
else if (carClass == POOR || carClass == SPECIAL)
- pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(7, 10);
- CVehicleModelInfo* pVehicleInfo = pCar->GetModelInfo();
- if (pVehicleInfo->GetColModel()->boundingBox.max.y - pCar->GetModelInfo()->GetColModel()->boundingBox.min.y > 10.0f || carClass == BIG) {
- pCar->AutoPilot.m_nCruiseSpeed *= 3;
- pCar->AutoPilot.m_nCruiseSpeed /= 4;
+ pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(7, 10);
+ CVehicleModelInfo* pVehicleInfo = pVehicle->GetModelInfo();
+ if (pVehicleInfo->GetColModel()->boundingBox.max.y - pVehicle->GetModelInfo()->GetColModel()->boundingBox.min.y > 10.0f || carClass == BIG) {
+ pVehicle->AutoPilot.m_nCruiseSpeed *= 3;
+ pVehicle->AutoPilot.m_nCruiseSpeed /= 4;
}
- pCar->AutoPilot.m_fMaxTrafficSpeed = pCar->AutoPilot.m_nCruiseSpeed;
- pCar->AutoPilot.m_nCarMission = MISSION_CRUISE;
- pCar->AutoPilot.m_nTempAction = TEMPACT_NONE;
- pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
+ pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed;
+ pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
break;
}
case COPS:
- pCar->AutoPilot.m_nTempAction = TEMPACT_NONE;
+ pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel != 0){
- pCar->AutoPilot.m_nCruiseSpeed = CCarAI::FindPoliceCarSpeedForWantedLevel(pCar);
- pCar->AutoPilot.m_fMaxTrafficSpeed = pCar->AutoPilot.m_nCruiseSpeed / 2;
- pCar->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel();
- pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
+ pVehicle->AutoPilot.m_nCruiseSpeed = CCarAI::FindPoliceCarSpeedForWantedLevel(pVehicle);
+ pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed / 2;
+ pVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel();
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
}else{
- pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 16);
- pCar->AutoPilot.m_fMaxTrafficSpeed = pCar->AutoPilot.m_nCruiseSpeed;
- pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
- pCar->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 16);
+ pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed;
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
+ pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
}
if (carModel == MI_FBICAR){
- pCar->m_currentColour1 = 0;
- pCar->m_currentColour2 = 0;
+ pVehicle->m_currentColour1 = 0;
+ pVehicle->m_currentColour2 = 0;
/* FBI cars are gray in carcols, but we want them black if they going after player. */
}
default:
break;
}
- if (pCar && pCar->GetModelIndex() == MI_MRWHOOP)
- pCar->m_bSirenOrAlarm = true;
- pCar->AutoPilot.m_nNextPathNodeInfo = connectionId;
- pCar->AutoPilot.m_nNextLane = pCar->AutoPilot.m_nCurrentLane = CGeneral::GetRandomNumber() % lanesOnCurrentRoad;
- CColBox* boundingBox = &CModelInfo::GetModelInfo(pCar->GetModelIndex())->GetColModel()->boundingBox;
+ if (pVehicle && pVehicle->GetModelIndex() == MI_MRWHOOP)
+ pVehicle->m_bSirenOrAlarm = true;
+ pVehicle->AutoPilot.m_nNextPathNodeInfo = connectionId;
+ pVehicle->AutoPilot.m_nNextLane = pVehicle->AutoPilot.m_nCurrentLane = CGeneral::GetRandomNumber() % lanesOnCurrentRoad;
+ CColBox* boundingBox = &CModelInfo::GetModelInfo(pVehicle->GetModelIndex())->GetColModel()->boundingBox;
float carLength = 1.0f + (boundingBox->max.y - boundingBox->min.y) / 2;
- float distanceBetweenNodes = (pCurNode->pos - pNextNode->pos).Magnitude2D();
+ float distanceBetweenNodes = (pCurNode->GetPosition() - pNextNode->GetPosition()).Magnitude2D();
/* If car is so long that it doesn't fit between two car nodes, place it directly in the middle. */
/* Otherwise put it at least in a way that full vehicle length fits between two nodes. */
if (distanceBetweenNodes / 2 < carLength)
positionBetweenNodes = 0.5f;
else
positionBetweenNodes = Min(1.0f - carLength / distanceBetweenNodes, Max(carLength / distanceBetweenNodes, positionBetweenNodes));
- pCar->AutoPilot.m_nNextDirection = (curNodeId >= nextNodeId) ? 1 : -1;
+ pVehicle->AutoPilot.m_nNextDirection = (curNodeId >= nextNodeId) ? 1 : -1;
if (pCurNode->numLinks == 1){
/* Do not create vehicle if there is nowhere to go. */
- delete pCar;
+ delete pVehicle;
return;
}
- int16 nextConnection = pCar->AutoPilot.m_nNextPathNodeInfo;
+ int16 nextConnection = pVehicle->AutoPilot.m_nNextPathNodeInfo;
int16 newLink;
- while (nextConnection == pCar->AutoPilot.m_nNextPathNodeInfo){
+ while (nextConnection == pVehicle->AutoPilot.m_nNextPathNodeInfo){
newLink = CGeneral::GetRandomNumber() % pCurNode->numLinks;
nextConnection = ThePaths.m_carPathConnections[newLink + pCurNode->firstLink];
}
- pCar->AutoPilot.m_nCurrentPathNodeInfo = nextConnection;
- pCar->AutoPilot.m_nCurrentDirection = (ThePaths.m_connections[newLink + pCurNode->firstLink] >= curNodeId) ? 1 : -1;
- CVector2D vecBetweenNodes = pNextNode->pos - pCurNode->pos;
+ pVehicle->AutoPilot.m_nCurrentPathNodeInfo = nextConnection;
+ pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(newLink + pCurNode->firstLink) >= curNodeId) ? 1 : -1;
+ CVector2D vecBetweenNodes = pNextNode->GetPosition() - pCurNode->GetPosition();
float forwardX, forwardY;
float distBetweenNodes = vecBetweenNodes.Magnitude();
if (distanceBetweenNodes == 0.0f){
@@ -389,44 +389,110 @@ CCarCtrl::GenerateOneRandomCar()
}
/* I think the following might be some form of SetRotateZOnly. */
/* Setting up direction between two car nodes. */
- pCar->GetForward() = CVector(forwardX, forwardY, 0.0f);
- pCar->GetRight() = CVector(forwardY, -forwardX, 0.0f);
- pCar->GetUp() = CVector(0.0f, 0.0f, 1.0f);
+ pVehicle->GetForward() = CVector(forwardX, forwardY, 0.0f);
+ pVehicle->GetRight() = CVector(forwardY, -forwardX, 0.0f);
+ pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f);
- float currentPathLinkForwardX = pCar->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nCurrentPathNodeInfo].dir.x;
- float currentPathLinkForwardY = pCar->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nCurrentPathNodeInfo].dir.y;
- float nextPathLinkForwardX = pCar->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nNextPathNodeInfo].dir.x;
- float nextPathLinkForwardY = pCar->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nNextPathNodeInfo].dir.y;
+ float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
+ float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
+ float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
+ float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
+
+#ifdef FIX_BUGS
+ CCarPathLink* pCurrentLink;
+ CCarPathLink* pNextLink;
+ CVector positionOnCurrentLinkIncludingLane;
+ CVector positionOnNextLinkIncludingLane;
+ float directionCurrentLinkX;
+ float directionCurrentLinkY;
+ float directionNextLinkX;
+ float directionNextLinkY;
+ if (positionBetweenNodes < 0.5f) {
+ float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
+ float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
+ float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
+ float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
+
+ pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
+ pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
+ positionOnCurrentLinkIncludingLane = CVector(
+ pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
+ 0.0f);
+ positionOnNextLinkIncludingLane = CVector(
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
+ 0.0f);
+ directionCurrentLinkX = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ directionCurrentLinkY = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
+ /* We want to make a path between two links that may not have the same forward directions a curve. */
+ pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor(
+ &positionOnCurrentLinkIncludingLane,
+ &positionOnNextLinkIncludingLane,
+ directionCurrentLinkX, directionCurrentLinkY,
+ directionNextLinkX, directionNextLinkY
+ ) * (1000.0f / pVehicle->AutoPilot.m_fMaxTrafficSpeed);
+ pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
+ (uint32)((0.5f + positionBetweenNodes) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
+ }
+ else {
+ PickNextNodeRandomly(pVehicle);
+ pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
+ (uint32)((positionBetweenNodes - 0.5f) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
- CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pCar->AutoPilot.m_nCurrentPathNodeInfo];
- CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pCar->AutoPilot.m_nNextPathNodeInfo];
+ float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
+ float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
+ float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
+ float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
+
+ pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
+ pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
+ positionOnCurrentLinkIncludingLane = CVector(
+ pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
+ 0.0f);
+ positionOnNextLinkIncludingLane = CVector(
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
+ 0.0f);
+ directionCurrentLinkX = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ directionCurrentLinkY = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
+ pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode];
+ pNextNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode];
+ }
+#else
+ float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
+ float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
+ float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
+ float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
+
+ CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
+ CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
CVector positionOnCurrentLinkIncludingLane(
- pCurrentLink->pos.x + ((pCar->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
- pCurrentLink->pos.y - ((pCar->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
+ pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f);
CVector positionOnNextLinkIncludingLane(
- pNextLink->pos.x + ((pCar->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
- pNextLink->pos.y - ((pCar->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
- float directionCurrentLinkX = pCurrentLink->dir.x * pCar->AutoPilot.m_nCurrentDirection;
- float directionCurrentLinkY = pCurrentLink->dir.y * pCar->AutoPilot.m_nCurrentDirection;
- float directionNextLinkX = pNextLink->dir.x * pCar->AutoPilot.m_nNextDirection;
- float directionNextLinkY = pNextLink->dir.y * pCar->AutoPilot.m_nNextDirection;
+ float directionCurrentLinkX = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionCurrentLinkY = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ float directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
/* We want to make a path between two links that may not have the same forward directions a curve. */
- pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor(
+ pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor(
&positionOnCurrentLinkIncludingLane,
&positionOnNextLinkIncludingLane,
directionCurrentLinkX, directionCurrentLinkY,
directionNextLinkX, directionNextLinkY
- ) * (1000.0f / pCar->AutoPilot.m_fMaxTrafficSpeed);
-#ifdef FIX_BUGS
- /* Casting timer to float is very unwanted. In this case it's not awful */
- /* but in CAutoPilot::ModifySpeed it can even cause crashes (see SilentPatch). */
- pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
- (uint32)((0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve);
-#else
- pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
- (0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve;
+ ) * (1000.0f / pVehicle->AutoPilot.m_fMaxTrafficSpeed);
+ pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
+ (0.5f + positionBetweenNodes) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve;
#endif
CVector directionCurrentLink(directionCurrentLinkX, directionCurrentLinkY, 0.0f);
CVector directionNextLink(directionNextLinkX, directionNextLinkY, 0.0f);
@@ -437,15 +503,15 @@ CCarCtrl::GenerateOneRandomCar()
&positionOnNextLinkIncludingLane,
&directionCurrentLink,
&directionNextLink,
- GetPositionAlongCurrentCurve(pCar),
- pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve,
+ GetPositionAlongCurrentCurve(pVehicle),
+ pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve,
&positionIncludingCurve,
&directionIncludingCurve
);
- CVector vectorBetweenNodes = pCurNode->pos - pNextNode->pos;
+ CVector vectorBetweenNodes = pCurNode->GetPosition() - pNextNode->GetPosition();
CVector finalPosition = positionIncludingCurve + vectorBetweenNodes * 2.0f / vectorBetweenNodes.Magnitude();
- finalPosition.z = positionBetweenNodes * pNextNode->pos.z +
- (1.0f - positionBetweenNodes) * pCurNode->pos.z;
+ finalPosition.z = positionBetweenNodes * pNextNode->GetZ() +
+ (1.0f - positionBetweenNodes) * pCurNode->GetZ();
float groundZ = INFINITE_Z;
CColPoint colPoint;
CEntity* pEntity;
@@ -457,13 +523,13 @@ CCarCtrl::GenerateOneRandomCar()
}
if (groundZ == INFINITE_Z || ABS(groundZ - finalPosition.z) > 7.0f) {
/* Failed to find ground or too far from expected position. */
- delete pCar;
+ delete pVehicle;
return;
}
- finalPosition.z = groundZ + pCar->GetHeightAboveRoad();
- pCar->GetPosition() = finalPosition;
- pCar->SetMoveSpeed(directionIncludingCurve / GAME_SPEED_TO_CARAI_SPEED);
- CVector2D speedDifferenceWithTarget = (CVector2D)pCar->GetMoveSpeed() - vecPlayerSpeed;
+ finalPosition.z = groundZ + pVehicle->GetHeightAboveRoad();
+ pVehicle->SetPosition(finalPosition);
+ pVehicle->SetMoveSpeed(directionIncludingCurve / GAME_SPEED_TO_CARAI_SPEED);
+ CVector2D speedDifferenceWithTarget = (CVector2D)pVehicle->GetMoveSpeed() - vecPlayerSpeed;
CVector2D distanceToTarget = positionIncludingCurve - vecTargetPos;
switch (carClass) {
case POOR:
@@ -482,59 +548,59 @@ CCarCtrl::GenerateOneRandomCar()
case NINES:
case GANG8:
case GANG9:
- pCar->m_status = STATUS_SIMPLE;
+ pVehicle->SetStatus(STATUS_SIMPLE);
break;
case COPS:
- pCar->m_status = (pCar->AutoPilot.m_nCarMission == MISSION_CRUISE) ? STATUS_SIMPLE : STATUS_PHYSICS;
- pCar->ChangeLawEnforcerState(1);
+ pVehicle->SetStatus((pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE) ? STATUS_SIMPLE : STATUS_PHYSICS);
+ pVehicle->ChangeLawEnforcerState(1);
break;
default:
break;
}
- CVisibilityPlugins::SetClumpAlpha(pCar->GetClump(), 0);
- if (!pCar->GetIsOnScreen()){
- if ((vecTargetPos - pCar->GetPosition()).Magnitude2D() > 50.0f) {
+ CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
+ if (!pVehicle->GetIsOnScreen()){
+ if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > 50.0f) {
/* Too far away cars that are not visible aren't needed. */
- delete pCar;
+ delete pVehicle;
return;
}
- }else if((vecTargetPos - pCar->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * 130.0f ||
- (vecTargetPos - pCar->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * 110.0f){
- delete pCar;
+ }else if((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * 130.0f ||
+ (vecTargetPos - pVehicle->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * 110.0f){
+ delete pVehicle;
return;
- }else if((TheCamera.GetPosition() - pCar->GetPosition()).Magnitude2D() < 90.0f * TheCamera.GenerationDistMultiplier){
- delete pCar;
+ }else if((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < 90.0f * TheCamera.GenerationDistMultiplier){
+ delete pVehicle;
return;
}
- CVehicleModelInfo* pVehicleModel = pCar->GetModelInfo();
+ CVehicleModelInfo* pVehicleModel = pVehicle->GetModelInfo();
float radiusToTest = pVehicleModel->GetColModel()->boundingSphere.radius;
if (testForCollision){
- CWorld::FindObjectsKindaColliding(pCar->GetPosition(), radiusToTest + 20.0f, true, &colliding, 2, nil, false, true, false, false, false);
+ CWorld::FindObjectsKindaColliding(pVehicle->GetPosition(), radiusToTest + 20.0f, true, &colliding, 2, nil, false, true, false, false, false);
if (colliding){
- delete pCar;
+ delete pVehicle;
return;
}
}
- CWorld::FindObjectsKindaColliding(pCar->GetPosition(), radiusToTest, true, &colliding, 2, nil, false, true, false, false, false);
+ CWorld::FindObjectsKindaColliding(pVehicle->GetPosition(), radiusToTest, true, &colliding, 2, nil, false, true, false, false, false);
if (colliding){
- delete pCar;
+ delete pVehicle;
return;
}
if (speedDifferenceWithTarget.x * distanceToTarget.x +
speedDifferenceWithTarget.y * distanceToTarget.y >= 0.0f){
- delete pCar;
+ delete pVehicle;
return;
}
- pVehicleModel->AvoidSameVehicleColour(&pCar->m_currentColour1, &pCar->m_currentColour2);
- CWorld::Add(pCar);
+ pVehicleModel->AvoidSameVehicleColour(&pVehicle->m_currentColour1, &pVehicle->m_currentColour2);
+ CWorld::Add(pVehicle);
if (carClass == COPS)
- CCarAI::AddPoliceOccupants(pCar);
+ CCarAI::AddPoliceCarOccupants(pVehicle);
else
- pCar->SetUpDriver();
+ pVehicle->SetUpDriver();
if ((CGeneral::GetRandomNumber() & 0x3F) == 0){ /* 1/64 probability */
- pCar->m_status = STATUS_PHYSICS;
- pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
- pCar->AutoPilot.m_nCruiseSpeed += 10;
+ pVehicle->SetStatus(STATUS_PHYSICS);
+ pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
+ pVehicle->AutoPilot.m_nCruiseSpeed += 10;
}
if (carClass == COPS)
LastTimeLawEnforcerCreated = CTimer::GetTimeInMilliseconds();
@@ -693,7 +759,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
if (pVehicle->bExtendedRange)
threshold *= 1.5f;
if (distanceToPlayer > threshold && !CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){
- if (pVehicle->GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(pVehicle)){
+ if (pVehicle->GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(pVehicle)) {
pVehicle->bFadeOut = true;
}else{
CWorld::Remove(pVehicle);
@@ -702,7 +768,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
return;
}
}
- if ((pVehicle->m_status == STATUS_SIMPLE || pVehicle->m_status == STATUS_PHYSICS && pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_STOP_FOR_CARS) &&
+ if ((pVehicle->GetStatus() == STATUS_SIMPLE || pVehicle->GetStatus() == STATUS_PHYSICS && pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_STOP_FOR_CARS) &&
CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeToStartMission > 5000 &&
!pVehicle->GetIsOnScreen() &&
(pVehicle->GetPosition() - vecPlayerPos).Magnitude2D() > 25.0f &&
@@ -716,10 +782,10 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
delete pVehicle;
return;
}
- if (pVehicle->m_status != STATUS_WRECKED || pVehicle->m_nTimeOfDeath == 0)
+ if (pVehicle->GetStatus() != STATUS_WRECKED || pVehicle->m_nTimeOfDeath == 0)
return;
if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 &&
- (!pVehicle->GetIsOnScreen() || !CRenderer::IsEntityCullZoneVisible(pVehicle))){
+ !(pVehicle->GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(pVehicle)) ){
if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(7.5f)){
if (!CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){
CWorld::Remove(pVehicle);
@@ -759,21 +825,21 @@ CCarCtrl::UpdateCarOnRails(CVehicle* pVehicle)
SlowCarOnRailsDownForTrafficAndLights(pVehicle);
if (pVehicle->AutoPilot.m_nTimeEnteredCurve + pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve <= CTimer::GetTimeInMilliseconds())
PickNextNodeAccordingStrategy(pVehicle);
- if (pVehicle->m_status == STATUS_PHYSICS)
+ if (pVehicle->GetStatus() == STATUS_PHYSICS)
return;
CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
- float currentPathLinkForwardX = pCurrentLink->dir.x * pVehicle->AutoPilot.m_nCurrentDirection;
- float currentPathLinkForwardY = pCurrentLink->dir.y * pVehicle->AutoPilot.m_nCurrentDirection;
- float nextPathLinkForwardX = pNextLink->dir.x * pVehicle->AutoPilot.m_nNextDirection;
- float nextPathLinkForwardY = pNextLink->dir.y * pVehicle->AutoPilot.m_nNextDirection;
+ float currentPathLinkForwardX = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float currentPathLinkForwardY = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float nextPathLinkForwardX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ float nextPathLinkForwardY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
CVector positionOnCurrentLinkIncludingLane(
- pCurrentLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
- pCurrentLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
+ pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f);
CVector positionOnNextLinkIncludingLane(
- pNextLink->pos.x + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
- pNextLink->pos.y - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
CVector directionCurrentLink(currentPathLinkForwardX, currentPathLinkForwardY, 0.0f);
CVector directionNextLink(nextPathLinkForwardX, nextPathLinkForwardY, 0.0f);
@@ -917,7 +983,7 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f
if (sideLength + 0.5f < sidewaysDistance)
/* If car is far enough taking side into account, don't care */
continue;
- if (pPed->m_type == ENTITY_TYPE_PED){ /* ...how can it not be? */
+ if (pPed->IsPed()){ /* ...how can it not be? */
if (pPed->GetPedState() != PED_STEP_AWAY && pPed->GetPedState() != PED_DIVE_AWAY){
if (distanceUntilHit < movementTowardsPedPerSecond){
/* Very close. Time to evade. */
@@ -937,7 +1003,7 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f
}
}else{
/* Relatively safe but annoying. */
- if (pVehicle->m_status == STATUS_PLAYER &&
+ if (pVehicle->GetStatus() == STATUS_PLAYER &&
pPed->GetPedState() != PED_FLEE_ENTITY &&
pPed->CharCreatedBy == RANDOM_CHAR){
float angleCarToPed = CGeneral::GetRadianAngleBetweenPoints(
@@ -1039,11 +1105,11 @@ void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle,
CTimer::GetTimeInMilliseconds() - pOtherVehicle->AutoPilot.m_nTimeToStartMission > 15000){
/* If cars are standing for 15 seconds, annoy one of them and make avoid cars. */
if (pOtherEntity != FindPlayerVehicle() &&
- DotProduct2D(pVehicle->GetForward(), pOtherVehicle->GetForward()) < 0.5f &&
+ DotProduct2D(pVehicle->GetForward(), pOtherVehicle->GetForward()) < -0.5f &&
pVehicle < pOtherVehicle){ /* that comparasion though... */
*pSpeed = Max(curSpeed / 5, *pSpeed);
- if (pVehicle->m_status == STATUS_SIMPLE){
- pVehicle->m_status = STATUS_PHYSICS;
+ if (pVehicle->GetStatus() == STATUS_SIMPLE){
+ pVehicle->SetStatus(STATUS_PHYSICS);
SwitchVehicleToRealPhysics(pVehicle);
}
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
@@ -1452,8 +1518,13 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
int32 curNode = pVehicle->AutoPilot.m_nNextRouteNode;
uint8 totalLinks = ThePaths.m_pathNodes[curNode].numLinks;
CCarPathLink* pCurLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
+#ifdef FIX_BUGS
+ uint8 lanesOnCurrentPath = pCurLink->pathNodeIndex == curNode ?
+ pCurLink->numLeftLanes : pCurLink->numRightLanes;
+#else
uint8 lanesOnCurrentPath = pCurLink->pathNodeIndex == curNode ?
pCurLink->numRightLanes : pCurLink->numLeftLanes;
+#endif
uint8 allowedDirections = PATH_DIRECTION_NONE;
uint8 nextLane = pVehicle->AutoPilot.m_nNextLane;
if (nextLane == 0)
@@ -1490,7 +1561,7 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
}
}
nextLink = CGeneral::GetRandomNumber() % totalLinks;
- pVehicle->AutoPilot.m_nNextRouteNode = ThePaths.m_connections[nextLink + pCurPathNode->firstLink];
+ pVehicle->AutoPilot.m_nNextRouteNode = ThePaths.ConnectedNode(nextLink + pCurPathNode->firstLink);
direction = FindPathDirection(prevNode, curNode, pVehicle->AutoPilot.m_nNextRouteNode);
pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurPathNode->firstLink]];
goingAgainstOneWayRoad = pNextLink->pathNodeIndex == curNode ? pNextLink->numRightLanes == 0 : pNextLink->numLeftLanes == 0;
@@ -1508,7 +1579,7 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
}
}
nextLink = CGeneral::GetRandomNumber() % totalLinks;
- pVehicle->AutoPilot.m_nNextRouteNode = ThePaths.m_connections[nextLink + pCurPathNode->firstLink];
+ pVehicle->AutoPilot.m_nNextRouteNode = ThePaths.ConnectedNode(nextLink + pCurPathNode->firstLink);
pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurPathNode->firstLink]];
goingAgainstOneWayRoad = pNextLink->pathNodeIndex == curNode ? pNextLink->numRightLanes == 0 : pNextLink->numLeftLanes == 0;
}
@@ -1516,7 +1587,7 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
if (attempt >= ATTEMPTS_TO_FIND_NEXT_NODE) {
/* If we failed again, remove no U-turn limitation and remove randomness */
for (nextLink = 0; nextLink < totalLinks; nextLink++) {
- pVehicle->AutoPilot.m_nNextRouteNode = ThePaths.m_connections[nextLink + pCurPathNode->firstLink];
+ pVehicle->AutoPilot.m_nNextRouteNode = ThePaths.ConnectedNode(nextLink + pCurPathNode->firstLink);
pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurPathNode->firstLink]];
goingAgainstOneWayRoad = pNextLink->pathNodeIndex == curNode ? pNextLink->numRightLanes == 0 : pNextLink->numLeftLanes == 0;
if (!goingAgainstOneWayRoad) {
@@ -1535,7 +1606,7 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurPathNode->firstLink]];
if (prevNode == pVehicle->AutoPilot.m_nNextRouteNode){
/* We can no longer shift vehicle without physics if we have to turn it around. */
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
SwitchVehicleToRealPhysics(pVehicle);
}
pVehicle->AutoPilot.m_nTimeEnteredCurve += pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve;
@@ -1553,12 +1624,16 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nNextDirection = -1;
lanesOnNextNode = pNextLink->numRightLanes;
}
- float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->dir.x;
- float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * pNextLink->dir.x;
+ float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirX();
+ float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirX();
+#ifdef FIX_BUGS
+ float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirY();
+ float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirY();
+#endif
if (lanesOnNextNode >= 0){
if ((CGeneral::GetRandomNumber() & 0x600) == 0){
/* 25% chance vehicle will try to switch lane */
- CVector2D dist = pNextPathNode->pos - pCurPathNode->pos;
+ CVector2D dist = pNextPathNode->GetPosition() - pCurPathNode->GetPosition();
if (dist.MagnitudeSqr() >= SQR(14.0f)){
if (CGeneral::GetRandomTrueFalse())
pVehicle->AutoPilot.m_nNextLane += 1;
@@ -1574,17 +1649,17 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
if (pVehicle->AutoPilot.m_bStayInFastLane)
pVehicle->AutoPilot.m_nNextLane = 0;
CVector positionOnCurrentLinkIncludingLane(
- pCurLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH), /* ...what about Y? */
- pCurLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
+ pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f);
CVector positionOnNextLinkIncludingLane(
- pNextLink->pos.x + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH),
- pNextLink->pos.y - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
- float directionCurrentLinkX = pCurLink->dir.x * pVehicle->AutoPilot.m_nCurrentDirection;
- float directionCurrentLinkY = pCurLink->dir.y * pVehicle->AutoPilot.m_nCurrentDirection;
- float directionNextLinkX = pNextLink->dir.x * pVehicle->AutoPilot.m_nNextDirection;
- float directionNextLinkY = pNextLink->dir.y * pVehicle->AutoPilot.m_nNextDirection;
+ float directionCurrentLinkX = pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionCurrentLinkY = pCurLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ float directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
/* We want to make a path between two links that may not have the same forward directions a curve. */
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor(
&positionOnCurrentLinkIncludingLane,
@@ -1600,8 +1675,8 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
uint8 CCarCtrl::FindPathDirection(int32 prevNode, int32 curNode, int32 nextNode)
{
- CVector2D prevToCur = ThePaths.m_pathNodes[curNode].pos - ThePaths.m_pathNodes[prevNode].pos;
- CVector2D curToNext = ThePaths.m_pathNodes[nextNode].pos - ThePaths.m_pathNodes[curNode].pos;
+ CVector2D prevToCur = ThePaths.m_pathNodes[curNode].GetPosition() - ThePaths.m_pathNodes[prevNode].GetPosition();
+ CVector2D curToNext = ThePaths.m_pathNodes[nextNode].GetPosition() - ThePaths.m_pathNodes[curNode].GetPosition();
float distPrevToCur = prevToCur.Magnitude();
if (distPrevToCur == 0.0f)
return PATH_DIRECTION_NONE;
@@ -1638,9 +1713,8 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
CPathNode* pTargetNode;
int16 numNodes;
float distanceToTargetNode;
-#ifndef REMOVE_TREADABLE_PATHFIND
if (pTarget && pTarget->m_pCurGroundEntity &&
- pTarget->m_pCurGroundEntity->m_type == ENTITY_TYPE_BUILDING &&
+ pTarget->m_pCurGroundEntity->IsBuilding() &&
((CBuilding*)pTarget->m_pCurGroundEntity)->GetIsATreadable() &&
((CTreadable*)pTarget->m_pCurGroundEntity)->m_nodeIndices[0][0] >= 0){
CTreadable* pCurrentMapObject = (CTreadable*)pTarget->m_pCurGroundEntity;
@@ -1650,31 +1724,31 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
int node = pCurrentMapObject->m_nodeIndices[0][i];
if (node < 0)
break;
- float dist = (ThePaths.m_pathNodes[node].pos - pTarget->GetPosition()).Magnitude();
+ float dist = (ThePaths.m_pathNodes[node].GetPosition() - pTarget->GetPosition()).Magnitude();
if (dist < minDist){
minDist = dist;
closestNode = node;
}
}
- ThePaths.DoPathSearch(0, pCurNode->pos, curNode,
+ ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode,
#ifdef FIX_PATHFIND_BUG
CVector(targetX, targetY, targetZ),
#else
CVector(targetX, targetY, 0.0f),
#endif
&pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, closestNode);
- }else{
-#endif
- ThePaths.DoPathSearch(0, pCurNode->pos, curNode,
+ }else
+ {
+
+ ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode,
#ifdef FIX_PATHFIND_BUG
CVector(targetX, targetY, targetZ),
#else
CVector(targetX, targetY, 0.0f),
#endif
&pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, -1);
-#ifndef REMOVE_TREADABLE_PATHFIND
}
-#endif
+
int newNextNode;
int nextLink;
if (numNodes != 1 || pTargetNode == pCurNode){
@@ -1684,11 +1758,11 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
int numLinks = pCurNode->numLinks;
newNextNode = 0;
for (int i = 0; i < numLinks; i++){
- int conNode = ThePaths.m_connections[i + pCurNode->firstLink];
+ int conNode = ThePaths.ConnectedNode(i + pCurNode->firstLink);
if (conNode == prevNode && i > 1)
continue;
CPathNode* pTestNode = &ThePaths.m_pathNodes[conNode];
- float angle = CGeneral::GetATanOfXY(pTestNode->pos.x - pCurNode->pos.x, pTestNode->pos.y - pCurNode->pos.y);
+ float angle = CGeneral::GetATanOfXY(pTestNode->GetX() - pCurNode->GetX(), pTestNode->GetY() - pCurNode->GetY());
angle = LimitRadianAngle(angle - currentAngle);
angle = ABS(angle);
if (angle < lowestAngleChange){
@@ -1700,7 +1774,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
}else{
nextLink = 0;
newNextNode = pTargetNode - ThePaths.m_pathNodes;
- for (int i = pCurNode->firstLink; ThePaths.m_connections[i] != newNextNode; i++, nextLink++)
+ for (int i = pCurNode->firstLink; ThePaths.ConnectedNode(i) != newNextNode; i++, nextLink++)
;
}
CPathNode* pNextPathNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode];
@@ -1725,12 +1799,12 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
pVehicle->AutoPilot.m_nNextDirection = -1;
lanesOnNextNode = pNextLink->numRightLanes;
}
- float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->dir.x;
- float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->dir.y;
- float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * pNextLink->dir.x;
- float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * pNextLink->dir.y;
+ float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirX();
+ float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirY();
+ float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirX();
+ float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirY();
if (lanesOnNextNode >= 0) {
- CVector2D dist = pNextPathNode->pos - pCurNode->pos;
+ CVector2D dist = pNextPathNode->GetPosition() - pCurNode->GetPosition();
if (dist.MagnitudeSqr() >= SQR(7.0f)){
/* 25% chance vehicle will try to switch lane */
/* No lane switching if following car from far away */
@@ -1755,17 +1829,17 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
if (pVehicle->AutoPilot.m_bStayInFastLane)
pVehicle->AutoPilot.m_nNextLane = 0;
CVector positionOnCurrentLinkIncludingLane(
- pCurLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
- pCurLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
+ pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f);
CVector positionOnNextLinkIncludingLane(
- pNextLink->pos.x + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
- pNextLink->pos.y - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
- float directionCurrentLinkX = pCurLink->dir.x * pVehicle->AutoPilot.m_nCurrentDirection;
- float directionCurrentLinkY = pCurLink->dir.y * pVehicle->AutoPilot.m_nCurrentDirection;
- float directionNextLinkX = pNextLink->dir.x * pVehicle->AutoPilot.m_nNextDirection;
- float directionNextLinkY = pNextLink->dir.y * pVehicle->AutoPilot.m_nNextDirection;
+ float directionCurrentLinkX = pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionCurrentLinkY = pCurLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ float directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
/* We want to make a path between two links that may not have the same forward directions a curve. */
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor(
&positionOnCurrentLinkIncludingLane,
@@ -1801,7 +1875,7 @@ bool CCarCtrl::PickNextNodeToFollowPath(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nCurrentDirection = pVehicle->AutoPilot.m_nNextDirection;
pVehicle->AutoPilot.m_nCurrentLane = pVehicle->AutoPilot.m_nNextLane;
int nextLink = 0;
- for (int i = pCurNode->firstLink; ThePaths.m_connections[i] != pVehicle->AutoPilot.m_nNextRouteNode; i++, nextLink++)
+ for (int i = pCurNode->firstLink; ThePaths.ConnectedNode(i) != pVehicle->AutoPilot.m_nNextRouteNode; i++, nextLink++)
;
CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurNode->firstLink]];
pVehicle->AutoPilot.m_nNextPathNodeInfo = ThePaths.m_carPathConnections[nextLink + pCurNode->firstLink];
@@ -1814,12 +1888,12 @@ bool CCarCtrl::PickNextNodeToFollowPath(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nNextDirection = -1;
lanesOnNextNode = pNextLink->numRightLanes;
}
- float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->dir.x;
- float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->dir.y;
- float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * pNextLink->dir.x;
- float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * pNextLink->dir.y;
+ float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirX();
+ float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirY();
+ float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirX();
+ float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirY();
if (lanesOnNextNode >= 0) {
- CVector2D dist = pNextPathNode->pos - pCurNode->pos;
+ CVector2D dist = pNextPathNode->GetPosition() - pCurNode->GetPosition();
if (dist.MagnitudeSqr() >= SQR(7.0f) && (CGeneral::GetRandomNumber() & 0x600) == 0) {
if (CGeneral::GetRandomTrueFalse())
pVehicle->AutoPilot.m_nNextLane += 1;
@@ -1835,17 +1909,17 @@ bool CCarCtrl::PickNextNodeToFollowPath(CVehicle* pVehicle)
if (pVehicle->AutoPilot.m_bStayInFastLane)
pVehicle->AutoPilot.m_nNextLane = 0;
CVector positionOnCurrentLinkIncludingLane(
- pCurLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
- pCurLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
+ pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY,
+ pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f);
CVector positionOnNextLinkIncludingLane(
- pNextLink->pos.x + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
- pNextLink->pos.y - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
- float directionCurrentLinkX = pCurLink->dir.x * pVehicle->AutoPilot.m_nCurrentDirection;
- float directionCurrentLinkY = pCurLink->dir.y * pVehicle->AutoPilot.m_nCurrentDirection;
- float directionNextLinkX = pNextLink->dir.x * pVehicle->AutoPilot.m_nNextDirection;
- float directionNextLinkY = pNextLink->dir.y * pVehicle->AutoPilot.m_nNextDirection;
+ float directionCurrentLinkX = pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionCurrentLinkY = pCurLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ float directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ float directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
/* We want to make a path between two links that may not have the same forward directions a curve. */
pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor(
&positionOnCurrentLinkIncludingLane,
@@ -1964,9 +2038,8 @@ void CCarCtrl::DragCarToPoint(CVehicle* pVehicle, CVector* pPoint)
pVehicle->GetRight() = CVector(posTarget.y - midPos.y, -(posTarget.x - midPos.x), 0.0f) / 3;
pVehicle->GetForward() = CVector(-cosZ * pVehicle->GetRight().y, cosZ * pVehicle->GetRight().x, sinZ);
pVehicle->GetUp() = CrossProduct(pVehicle->GetRight(), pVehicle->GetForward());
- pVehicle->GetPosition() = (CVector(midPos.x, midPos.y, actualBehindZ)
- + CVector(posTarget.x, posTarget.y, actualAheadZ)) / 2;
- pVehicle->GetPosition().z += pVehicle->GetHeightAboveRoad();
+ pVehicle->SetPosition((CVector(midPos.x, midPos.y, actualBehindZ) + CVector(posTarget.x, posTarget.y, actualAheadZ)) / 2);
+ pVehicle->GetMatrix().GetPosition().z += pVehicle->GetHeightAboveRoad();
}
float CCarCtrl::FindSpeedMultiplier(float angleChange, float minAngle, float maxAngle, float coef)
@@ -2200,16 +2273,16 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
forward.Normalise();
CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
- CVector2D currentPathLinkForward(pCurrentLink->dir.x * pVehicle->AutoPilot.m_nCurrentDirection,
- pCurrentLink->dir.y * pVehicle->AutoPilot.m_nCurrentDirection);
- float nextPathLinkForwardX = pNextLink->dir.x * pVehicle->AutoPilot.m_nNextDirection;
- float nextPathLinkForwardY = pNextLink->dir.y * pVehicle->AutoPilot.m_nNextDirection;
+ CVector2D currentPathLinkForward(pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection,
+ pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection);
+ float nextPathLinkForwardX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ float nextPathLinkForwardY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
CVector2D positionOnCurrentLinkIncludingLane(
- pCurrentLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y,
- pCurrentLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x);
+ pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y,
+ pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x);
CVector2D positionOnNextLinkIncludingLane(
- pNextLink->pos.x + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
- pNextLink->pos.y - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX);
+ pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
+ pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX);
CVector2D distanceToNextNode = (CVector2D)pVehicle->GetPosition() - positionOnCurrentLinkIncludingLane;
float scalarDistanceToNextNode = distanceToNextNode.Magnitude();
CVector2D distanceBetweenNodes = positionOnNextLinkIncludingLane - positionOnCurrentLinkIncludingLane;
@@ -2238,16 +2311,16 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
}
pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
scalarDistanceToNextNode = CVector2D(
- pCurrentLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y - pVehicle->GetPosition().x,
- pCurrentLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x - pVehicle->GetPosition().y).Magnitude();
+ pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y - pVehicle->GetPosition().x,
+ pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x - pVehicle->GetPosition().y).Magnitude();
pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
- currentPathLinkForward.x = pCurrentLink->dir.x * pVehicle->AutoPilot.m_nCurrentDirection;
- currentPathLinkForward.y = pCurrentLink->dir.y * pVehicle->AutoPilot.m_nCurrentDirection;
- nextPathLinkForwardX = pNextLink->dir.x * pVehicle->AutoPilot.m_nNextDirection;
- nextPathLinkForwardY = pNextLink->dir.y * pVehicle->AutoPilot.m_nNextDirection;
+ currentPathLinkForward.x = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
+ currentPathLinkForward.y = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
+ nextPathLinkForwardX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
+ nextPathLinkForwardY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
}
- positionOnCurrentLinkIncludingLane.x = pCurrentLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y;
- positionOnCurrentLinkIncludingLane.y = pCurrentLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x;
+ positionOnCurrentLinkIncludingLane.x = pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y;
+ positionOnCurrentLinkIncludingLane.y = pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x;
CVector2D projectedPosition = positionOnCurrentLinkIncludingLane - currentPathLinkForward * scalarDistanceToNextNode * 0.4f;
if (scalarDistanceToNextNode > DISTANCE_TO_NEXT_NODE_TO_CONSIDER_SLOWING_DOWN){
projectedPosition.x = positionOnCurrentLinkIncludingLane.x;
@@ -2289,8 +2362,8 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
CCarAI::CarHasReasonToStop(pVehicle);
speedStyleMultiplier = 0.0f;
}
- CVector2D trajectory(pCurrentLink->pos.x + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y,
- pCurrentLink->pos.y - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x);
+ CVector2D trajectory(pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.y,
+ pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x);
trajectory -= pVehicle->GetPosition();
float speedAngleMultiplier = FindSpeedMultiplier(
CGeneral::GetATanOfXY(trajectory.x, trajectory.y) - angleForward,
@@ -2504,9 +2577,9 @@ void CCarCtrl::JoinCarWithRoadSystem(CVehicle* pVehicle)
int prevNodeId = -1;
float minDistance = 999999.9f;
for (int i = 0; i < pNode->numLinks; i++){
- int candidateId = ThePaths.m_connections[i + pNode->firstLink];
+ int candidateId = ThePaths.ConnectedNode(i + pNode->firstLink);
CPathNode* pCandidateNode = &ThePaths.m_pathNodes[candidateId];
- float distance = (pCandidateNode->pos - pNode->pos).Magnitude2D();
+ float distance = (pCandidateNode->GetPosition() - pNode->GetPosition()).Magnitude2D();
if (distance < minDistance){
minDistance = distance;
prevNodeId = candidateId;
@@ -2518,7 +2591,7 @@ void CCarCtrl::JoinCarWithRoadSystem(CVehicle* pVehicle)
CPathNode* pPrevNode = &ThePaths.m_pathNodes[prevNodeId];
if (forward.x == 0.0f && forward.y == 0.0f)
forward.x = 1.0f;
- if (DotProduct2D(pNode->pos - pPrevNode->pos, forward) < 0.0f){
+ if (DotProduct2D(pNode->GetPosition() - pPrevNode->GetPosition(), forward) < 0.0f){
int tmp;
tmp = prevNodeId;
prevNodeId = nodeId;
@@ -2558,7 +2631,7 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
int nextLink;
CPathNode* pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode];
for (nextLink = 0; nextLink < 12; nextLink++)
- if (ThePaths.m_connections[nextLink + pCurNode->firstLink] == pVehicle->AutoPilot.m_nNextRouteNode)
+ if (ThePaths.ConnectedNode(nextLink + pCurNode->firstLink) == pVehicle->AutoPilot.m_nNextRouteNode)
break;
pVehicle->AutoPilot.m_nNextPathNodeInfo = ThePaths.m_carPathConnections[nextLink + pCurNode->firstLink];
pVehicle->AutoPilot.m_nNextDirection = (pVehicle->AutoPilot.m_nCurrentRouteNode >= pVehicle->AutoPilot.m_nNextRouteNode) ? 1 : -1;
@@ -2575,7 +2648,7 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
}
}
pVehicle->AutoPilot.m_nCurrentPathNodeInfo = curConnection;
- pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.m_connections[curLink + pCurNode->firstLink] >= pVehicle->AutoPilot.m_nCurrentRouteNode) ? 1 : -1;
+ pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(curLink + pCurNode->firstLink) >= pVehicle->AutoPilot.m_nCurrentRouteNode) ? 1 : -1;
}
void CCarCtrl::GenerateEmergencyServicesCar(void)
@@ -2647,7 +2720,7 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos)
return nil;
CAutomobile* pVehicle = new CAutomobile(mi, RANDOM_VEHICLE);
pVehicle->AutoPilot.m_vecDestinationCoors = vecPos;
- pVehicle->GetPosition() = spawnPos;
+ pVehicle->SetPosition(spawnPos);
pVehicle->AutoPilot.m_nCarMission = (JoinCarWithRoadSystemGotoCoors(pVehicle, vecPos, false)) ? MISSION_GOTOCOORDS_STRAIGHT : MISSION_GOTOCOORDS;
pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed = 25;
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
@@ -2657,7 +2730,7 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos)
pVehicle->GetForward() = CVector(direction.x, direction.y, 0.0f);
pVehicle->GetRight() = CVector(direction.y, -direction.x, 0.0f);
pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f);
- spawnPos.z = posBetweenNodes * ThePaths.m_pathNodes[curNode].pos.z + (1.0f - posBetweenNodes) * ThePaths.m_pathNodes[nextNode].pos.z;
+ spawnPos.z = posBetweenNodes * ThePaths.m_pathNodes[curNode].GetZ() + (1.0f - posBetweenNodes) * ThePaths.m_pathNodes[nextNode].GetZ();
float groundZ = INFINITE_Z;
CColPoint colPoint;
CEntity* pEntity;
@@ -2672,9 +2745,9 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos)
return false;
}
spawnPos.z = groundZ + pVehicle->GetDistanceFromCentreOfMassToBaseOfModel();
- pVehicle->GetPosition() = spawnPos;
+ pVehicle->SetPosition(spawnPos);
pVehicle->SetMoveSpeed(CVector(0.0f, 0.0f, 0.0f));
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
switch (mi){
case MI_FIRETRUCK:
pVehicle->bIsFireTruckOnDuty = true;
diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h
index 44ef9ab6..457224fb 100644
--- a/src/control/CarCtrl.h
+++ b/src/control/CarCtrl.h
@@ -23,6 +23,7 @@ enum{
class CCarCtrl
{
+public:
enum eCarClass {
POOR = 0,
RICH,
@@ -43,7 +44,7 @@ class CCarCtrl
GANG9,
COPS
};
-public:
+
static void SwitchVehicleToRealPhysics(CVehicle*);
static void AddToCarArray(int32 id, int32 vehclass);
static void UpdateCarCount(CVehicle*, bool);
diff --git a/src/control/Curves.cpp b/src/control/Curves.cpp
index 623ab040..0a01a7aa 100644
--- a/src/control/Curves.cpp
+++ b/src/control/Curves.cpp
@@ -19,7 +19,7 @@ void CCurves::CalcCurvePoint(CVector* pPos1, CVector* pPos2, CVector* pDir1, CVe
float actualFactor = CalcSpeedScaleFactor(pPos1, pPos2, pDir1->x, pDir1->y, pDir2->x, pDir2->y);
CVector2D dir1 = *pDir1 * actualFactor;
CVector2D dir2 = *pDir2 * actualFactor;
- float curveCoef = 0.5f - 0.5f * cos(3.1415f * between);
+ float curveCoef = 0.5f - 0.5f * Cos(3.1415f * between);
*pOutPos = CVector(
(pPos1->x + between * dir1.x) * (1.0f - curveCoef) + (pPos2->x - (1 - between) * dir2.x) * curveCoef,
(pPos1->y + between * dir1.y) * (1.0f - curveCoef) + (pPos2->y - (1 - between) * dir2.y) * curveCoef,
diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp
index f8c8fa69..abb5c5f3 100644
--- a/src/control/GameLogic.cpp
+++ b/src/control/GameLogic.cpp
@@ -102,8 +102,8 @@ CGameLogic::Update()
if (pVehicle != nil) {
if (pVehicle->pDriver == pPlayerInfo.m_pPed) {
pVehicle->pDriver = nil;
- if (pVehicle->m_status != STATUS_WRECKED)
- pVehicle->m_status = STATUS_ABANDONED;
+ if (pVehicle->GetStatus() != STATUS_WRECKED)
+ pVehicle->SetStatus(STATUS_ABANDONED);
} else
pVehicle->RemovePassenger(pPlayerInfo.m_pPed);
}
@@ -172,8 +172,8 @@ CGameLogic::Update()
if (pVehicle != nil) {
if (pVehicle->pDriver == pPlayerInfo.m_pPed) {
pVehicle->pDriver = nil;
- if (pVehicle->m_status != STATUS_WRECKED)
- pVehicle->m_status = STATUS_ABANDONED;
+ if (pVehicle->GetStatus() != STATUS_WRECKED)
+ pVehicle->SetStatus(STATUS_ABANDONED);
}
else
pVehicle->RemovePassenger(pPlayerInfo.m_pPed);
@@ -214,8 +214,8 @@ CGameLogic::Update()
if (pVehicle != nil) {
if (pVehicle->pDriver == pPlayerInfo.m_pPed) {
pVehicle->pDriver = nil;
- if (pVehicle->m_status != STATUS_WRECKED)
- pVehicle->m_status = STATUS_ABANDONED;
+ if (pVehicle->GetStatus() != STATUS_WRECKED)
+ pVehicle->SetStatus(STATUS_ABANDONED);
} else
pVehicle->RemovePassenger(pPlayerInfo.m_pPed);
}
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index a4aa3729..b6786598 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -528,9 +528,14 @@ void CGarage::Update()
CGarages::GivePlayerDetonator();
CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
}
+#ifdef DETECT_PAD_INPUT_SWITCH
+ int16 Mode = CPad::IsAffectedByController ? CPad::GetPad(0)->Mode : 0;
+#else
+ int16 Mode = CPad::GetPad(0)->Mode;
+#endif
switch (m_eGarageType) {
case GARAGE_BOMBSHOP1:
- switch (CPad::GetPad(0)->Mode) {
+ switch (Mode) {
case 0:
case 1:
case 2:
@@ -542,7 +547,7 @@ void CGarage::Update()
}
break;
case GARAGE_BOMBSHOP2:
- switch (CPad::GetPad(0)->Mode) {
+ switch (Mode) {
case 0:
case 1:
case 2:
@@ -749,7 +754,7 @@ void CGarage::Update()
if (((CAutomobile*)(m_pTarget))->Damage.GetEngineStatus() <= ENGINE_STATUS_ON_FIRE &&
((CAutomobile*)(m_pTarget))->m_fFireBlowUpTimer == 0.0f) {
#endif
- if (m_pTarget->m_status != STATUS_WRECKED) {
+ if (m_pTarget->GetStatus() != STATUS_WRECKED) {
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
m_eGarageState = GS_CLOSING;
@@ -1390,7 +1395,7 @@ void CGarages::PrintMessages()
CFont::SetBackgroundOff();
CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(50.0f));
CFont::SetCentreOn();
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, 255));
#if defined(PS2) || defined (FIX_BUGS)
@@ -1448,14 +1453,14 @@ void CGarage::UpdateDoorsHeight()
{
RefreshDoorPointers(false);
if (m_pDoor1) {
- m_pDoor1->GetPosition().z = m_fDoorPos + m_fDoor1Z;
+ m_pDoor1->GetMatrix().GetPosition().z = m_fDoorPos + m_fDoor1Z;
if (m_bRotatedDoor)
BuildRotatedDoorMatrix(m_pDoor1, m_fDoorPos / m_fDoorHeight);
m_pDoor1->GetMatrix().UpdateRW();
m_pDoor1->UpdateRwFrame();
}
if (m_pDoor2) {
- m_pDoor2->GetPosition().z = m_fDoorPos + m_fDoor2Z;
+ m_pDoor2->GetMatrix().GetPosition().z = m_fDoorPos + m_fDoor2Z;
if (m_bRotatedDoor)
BuildRotatedDoorMatrix(m_pDoor2, m_fDoorPos / m_fDoorHeight);
m_pDoor2->GetMatrix().UpdateRW();
@@ -1482,18 +1487,18 @@ void CGarage::UpdateCrusherAngle()
void CGarage::UpdateCrusherShake(float X, float Y)
{
RefreshDoorPointers(false);
- m_pDoor1->GetPosition().x += X;
- m_pDoor1->GetPosition().y += Y;
+ m_pDoor1->GetMatrix().GetPosition().x += X;
+ m_pDoor1->GetMatrix().GetPosition().y += Y;
m_pDoor1->GetMatrix().UpdateRW();
m_pDoor1->UpdateRwFrame();
- m_pDoor1->GetPosition().x -= X;
- m_pDoor1->GetPosition().y -= Y;
- m_pDoor2->GetPosition().x += X;
- m_pDoor2->GetPosition().y += Y;
+ m_pDoor1->GetMatrix().GetPosition().x -= X;
+ m_pDoor1->GetMatrix().GetPosition().y -= Y;
+ m_pDoor2->GetMatrix().GetPosition().x += X;
+ m_pDoor2->GetMatrix().GetPosition().y += Y;
m_pDoor2->GetMatrix().UpdateRW();
m_pDoor2->UpdateRwFrame();
- m_pDoor2->GetPosition().x -= X;
- m_pDoor2->GetPosition().y -= Y;
+ m_pDoor2->GetMatrix().GetPosition().x -= X;
+ m_pDoor2->GetMatrix().GetPosition().y -= Y;
}
// This is dumb but there is no way to avoid goto. What was there originally even?
@@ -1854,8 +1859,8 @@ CVehicle* CStoredCar::RestoreCar()
#else
CVehicle* pVehicle = new CAutomobile(m_nModelIndex, RANDOM_VEHICLE);
#endif
- pVehicle->GetPosition() = m_vecPos;
- pVehicle->m_status = STATUS_ABANDONED;
+ pVehicle->SetPosition(m_vecPos);
+ pVehicle->SetStatus(STATUS_ABANDONED);
pVehicle->GetForward() = m_vecAngle;
pVehicle->GetRight() = CVector(m_vecAngle.y, -m_vecAngle.x, 0.0f);
pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f);
@@ -1975,7 +1980,7 @@ void CGarage::TidyUpGarage()
if (pVehicle->GetPosition().x > m_fX1 && pVehicle->GetPosition().x < m_fX2 &&
pVehicle->GetPosition().y > m_fY1 && pVehicle->GetPosition().y < m_fY2 &&
pVehicle->GetPosition().z > m_fZ1 && pVehicle->GetPosition().z < m_fZ2) {
- if (pVehicle->m_status == STATUS_WRECKED || pVehicle->GetUp().z < 0.5f) {
+ if (pVehicle->GetStatus() == STATUS_WRECKED || pVehicle->GetUp().z < 0.5f) {
CWorld::Remove(pVehicle);
delete pVehicle;
}
@@ -1990,7 +1995,7 @@ void CGarage::TidyUpGarageClose()
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle || !pVehicle->IsCar())
continue;
- if (!pVehicle->IsCar() || pVehicle->m_status != STATUS_WRECKED || !IsEntityTouching3D(pVehicle))
+ if (!pVehicle->IsCar() || pVehicle->GetStatus() != STATUS_WRECKED || !IsEntityTouching3D(pVehicle))
continue;
bool bRemove = false;
if (m_eGarageState != GS_FULLYCLOSED) {
@@ -2089,15 +2094,15 @@ void CGarage::CenterCarInGarage(CVehicle* pVehicle)
float offsetZ = pos.z - pos.z;
float distance = CVector(offsetX, offsetY, offsetZ).Magnitude();
if (distance < RESPRAY_CENTERING_COEFFICIENT) {
- pVehicle->GetPosition().x = GetGarageCenterX();
- pVehicle->GetPosition().y = GetGarageCenterY();
+ pVehicle->GetMatrix().GetPosition().x = GetGarageCenterX();
+ pVehicle->GetMatrix().GetPosition().y = GetGarageCenterY();
}
else {
- pVehicle->GetPosition().x += offsetX * RESPRAY_CENTERING_COEFFICIENT / distance;
- pVehicle->GetPosition().y += offsetY * RESPRAY_CENTERING_COEFFICIENT / distance;
+ pVehicle->GetMatrix().GetPosition().x += offsetX * RESPRAY_CENTERING_COEFFICIENT / distance;
+ pVehicle->GetMatrix().GetPosition().y += offsetY * RESPRAY_CENTERING_COEFFICIENT / distance;
}
if (!IsEntityEntirelyInside3D(pVehicle, 0.1f))
- pVehicle->GetPosition() = pos;
+ pVehicle->SetPosition(pos);
}
void CGarages::CloseHideOutGaragesBeforeSave()
@@ -2164,7 +2169,7 @@ int32 CGarages::FindMaxNumStoredCarsForGarage(eGarageType type)
return 0;
}
-bool CGarages::IsPointWithinHideOutGarage(CVector& point)
+bool CGarages::IsPointWithinHideOutGarage(Const CVector& point)
{
for (int i = 0; i < NUM_GARAGES; i++) {
switch (aGarages[i].m_eGarageType) {
@@ -2180,7 +2185,7 @@ bool CGarages::IsPointWithinHideOutGarage(CVector& point)
return false;
}
-bool CGarages::IsPointWithinAnyGarage(CVector& point)
+bool CGarages::IsPointWithinAnyGarage(Const CVector& point)
{
for (int i = 0; i < NUM_GARAGES; i++) {
switch (aGarages[i].m_eGarageType) {
@@ -2205,7 +2210,7 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
default:
aGarages[i].RefreshDoorPointers(true);
if (aGarages[i].m_pDoor1) {
- aGarages[i].m_pDoor1->GetPosition().z = aGarages[i].m_fDoor1Z;
+ aGarages[i].m_pDoor1->GetMatrix().GetPosition().z = aGarages[i].m_fDoor1Z;
if (aGarages[i].m_pDoor1->IsObject())
((CObject*)aGarages[i].m_pDoor1)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor1Z;
if (aGarages[i].m_bRotatedDoor)
@@ -2214,7 +2219,7 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
aGarages[i].m_pDoor1->UpdateRwFrame();
}
if (aGarages[i].m_pDoor2) {
- aGarages[i].m_pDoor2->GetPosition().z = aGarages[i].m_fDoor2Z;
+ aGarages[i].m_pDoor2->GetMatrix().GetPosition().z = aGarages[i].m_fDoor2Z;
if (aGarages[i].m_pDoor2->IsObject())
((CObject*)aGarages[i].m_pDoor2)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor2Z;
if (aGarages[i].m_bRotatedDoor)
diff --git a/src/control/Garages.h b/src/control/Garages.h
index 65193b32..00020eb3 100644
--- a/src/control/Garages.h
+++ b/src/control/Garages.h
@@ -75,7 +75,7 @@ public:
CVehicle* RestoreCar();
};
-static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar");
+VALIDATE_SIZE(CStoredCar, 0x28);
#define SWITCH_GARAGE_DISTANCE_CLOSE 40.0f
@@ -172,7 +172,7 @@ class CGarage
friend class CCamera;
};
-static_assert(sizeof(CGarage) == 140, "CGarage");
+VALIDATE_SIZE(CGarage, 140);
class CGarages
{
@@ -232,8 +232,8 @@ public:
static bool CameraShouldBeOutside(void);
static void GivePlayerDetonator(void);
static void PlayerArrestedOrDied(void);
- static bool IsPointWithinHideOutGarage(CVector&);
- static bool IsPointWithinAnyGarage(CVector&);
+ static bool IsPointWithinHideOutGarage(Const CVector&);
+ static bool IsPointWithinAnyGarage(Const CVector&);
static void SetAllDoorsBackToOriginalHeight(void);
static void Save(uint8* buf, uint32* size);
static void Load(uint8* buf, uint32 size);
diff --git a/src/control/OnscreenTimer.h b/src/control/OnscreenTimer.h
index fb139266..3ef7764a 100644
--- a/src/control/OnscreenTimer.h
+++ b/src/control/OnscreenTimer.h
@@ -26,7 +26,7 @@ public:
void ProcessForDisplayCounter();
};
-static_assert(sizeof(COnscreenTimerEntry) == 0x74, "COnscreenTimerEntry: error");
+VALIDATE_SIZE(COnscreenTimerEntry, 0x74);
class COnscreenTimer
{
@@ -46,4 +46,4 @@ public:
void AddClock(uint32 offset, char* text);
};
-static_assert(sizeof(COnscreenTimer) == 0x78, "COnscreenTimer: error"); \ No newline at end of file
+VALIDATE_SIZE(COnscreenTimer, 0x78);
diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp
index 44062b38..ee15b82f 100644
--- a/src/control/PathFind.cpp
+++ b/src/control/PathFind.cpp
@@ -17,12 +17,19 @@ CPathFind ThePaths;
#define MAX_DIST INT16_MAX-1
#define MIN_PED_ROUTE_DISTANCE 23.8f
+
+#define NUMTEMPNODES 4000
+#define NUMDETACHED_CARS 100
+#define NUMDETACHED_PEDS 50
+
+
// object flags:
// 1 UseInRoadBlock
// 2 east/west road(?)
CPathInfoForObject *InfoForTileCars;
CPathInfoForObject *InfoForTilePeds;
+
// unused
CTempDetachedNode *DetachedNodesCars;
CTempDetachedNode *DetachedNodesPeds;
@@ -243,6 +250,7 @@ CPathFind::AllocatePathFindInfoMem(int16 numPathGroups)
delete[] InfoForTilePeds;
InfoForTilePeds = nil;
+ // NB: MIAMI doesn't use numPathGroups here but hardcodes 4500
InfoForTileCars = new CPathInfoForObject[12*numPathGroups];
memset(InfoForTileCars, 0, 12*numPathGroups*sizeof(CPathInfoForObject));
InfoForTilePeds = new CPathInfoForObject[12*numPathGroups];
@@ -253,10 +261,10 @@ CPathFind::AllocatePathFindInfoMem(int16 numPathGroups)
DetachedNodesCars = nil;
delete[] DetachedNodesPeds;
DetachedNodesPeds = nil;
- DetachedNodesCars = new CTempDetachedNode[100];
- memset(DetachedNodesCars, 0, 100*sizeof(CTempDetachedNode));
- DetachedNodesPeds = new CTempDetachedNode[50];
- memset(DetachedNodesPeds, 0, 50*sizeof(CTempDetachedNode));
+ DetachedNodesCars = new CTempDetachedNode[NUMDETACHED_CARS];
+ memset(DetachedNodesCars, 0, NUMDETACHED_CARS*sizeof(CTempDetachedNode));
+ DetachedNodesPeds = new CTempDetachedNode[NUMDETACHED_PEDS];
+ memset(DetachedNodesPeds, 0, NUMDETACHED_PEDS*sizeof(CTempDetachedNode));
}
void
@@ -306,6 +314,7 @@ CPathFind::StoreNodeInfoCar(int16 id, int16 node, int8 type, int8 next, int16 x,
InfoForTileCars[i].numLeftLanes = numLeft;
InfoForTileCars[i].numRightLanes = numRight;
+
if(type)
for(i = 0; i < node; i++){
j = id*12 + i;
@@ -346,10 +355,12 @@ CPathFind::PreparePathData(void)
printf("PreparePathData\n");
if(!CPathFind::LoadPathFindData() && // empty
InfoForTileCars && InfoForTilePeds &&
- DetachedNodesCars && DetachedNodesPeds){
- tempNodes = new CTempNode[4000];
+ DetachedNodesCars && DetachedNodesPeds
+ ){
+ tempNodes = new CTempNode[NUMTEMPNODES];
m_numConnections = 0;
+
for(i = 0; i < PATHNODESIZE; i++)
m_pathNodes[i].unkBits = 0;
@@ -369,6 +380,7 @@ CPathFind::PreparePathData(void)
for(i = 0; i < PATHNODESIZE; i++)
for(j = 0; j < 12; j++)
if(InfoForTileCars[i*12 + j].type == NodeTypeExtern){
+ // MIAMI has MI:%d here but no argument for it
if(InfoForTileCars[i*12 + j].numLeftLanes < 0)
printf("ILLEGAL BLOCK. NEGATIVE NUMBER OF LANES (Obj:%d)\n", i);
if(InfoForTileCars[i*12 + j].numRightLanes < 0)
@@ -378,9 +390,9 @@ CPathFind::PreparePathData(void)
}
m_numPathNodes = 0;
- PreparePathDataForType(PATH_CAR, tempNodes, InfoForTileCars, 1.0f, DetachedNodesCars, 100);
+ PreparePathDataForType(PATH_CAR, tempNodes, InfoForTileCars, 1.0f, DetachedNodesCars, NUMDETACHED_CARS);
m_numCarPathNodes = m_numPathNodes;
- PreparePathDataForType(PATH_PED, tempNodes, InfoForTilePeds, 1.0f, DetachedNodesPeds, 50);
+ PreparePathDataForType(PATH_PED, tempNodes, InfoForTilePeds, 1.0f, DetachedNodesPeds, NUMDETACHED_PEDS);
m_numPedPathNodes = m_numPathNodes - m_numCarPathNodes;
// TODO: figure out what exactly is going on here
@@ -431,6 +443,7 @@ CPathFind::PreparePathData(void)
InfoForTileCars = nil;
delete[] InfoForTilePeds;
InfoForTilePeds = nil;
+
delete[] DetachedNodesCars;
DetachedNodesCars = nil;
delete[] DetachedNodesPeds;
@@ -476,29 +489,28 @@ CPathFind::CountFloodFillGroups(uint8 type)
break;
node = &m_pathNodes[i];
- node->next = nil;
+ node->SetNext(nil);
node->group = n;
if(node->numLinks == 0){
if(type == PATH_CAR)
printf("Single car node: %f %f %f (%d)\n",
- node->pos.x, node->pos.y, node->pos.z,
- m_mapObjects[node->objectIndex]->m_modelIndex);
+ node->GetX(), node->GetY(), node->GetZ(), m_mapObjects[node->objectIndex]->GetModelIndex());
else
printf("Single ped node: %f %f %f\n",
- node->pos.x, node->pos.y, node->pos.z);
+ node->GetX(), node->GetY(), node->GetZ());
}
while(node){
prev = node;
- node = node->next;
+ node = node->GetNext();
for(i = 0; i < prev->numLinks; i++){
- l = m_connections[prev->firstLink + i];
+ l = ConnectedNode(prev->firstLink + i);
if(m_pathNodes[l].group == 0){
m_pathNodes[l].group = n;
if(m_pathNodes[l].group == 0)
m_pathNodes[l].group = INT8_MIN;
- m_pathNodes[l].next = node;
+ m_pathNodes[l].SetNext(node);
node = &m_pathNodes[l];
}
}
@@ -513,7 +525,7 @@ int32 TempListLength;
void
CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoForObject *objectpathinfo,
- float maxdist, CTempDetachedNode *detachednodes, int unused)
+ float maxdist, CTempDetachedNode *detachednodes, int numDetached)
{
static CVector CoorsXFormed;
int i, j, k, l;
@@ -525,14 +537,16 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
int nearestId;
int next;
int oldNumPathNodes, oldNumLinks;
- CVector dist;
+ float dist;
int iseg, jseg;
int istart, jstart;
int done, cont;
+ int tileStart;
oldNumPathNodes = m_numPathNodes;
oldNumLinks = m_numConnections;
+#define OBJECTINDEX(n) (m_pathNodes[(n)].objectIndex)
// Initialize map objects
for(i = 0; i < m_numMapObjects; i++)
for(j = 0; j < 12; j++)
@@ -540,28 +554,30 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
// Calculate internal nodes, store them and connect them to defining object
for(i = 0; i < m_numMapObjects; i++){
- start = 12*m_mapObjects[i]->m_modelIndex;
+ tileStart = m_numPathNodes;
+ start = 12 * m_mapObjects[i]->GetModelIndex();
for(j = 0; j < 12; j++){
- if(objectpathinfo[start + j].type != NodeTypeIntern)
- continue;
- CalcNodeCoors(
- objectpathinfo[start + j].x,
- objectpathinfo[start + j].y,
- objectpathinfo[start + j].z,
- i,
- &CoorsXFormed);
- m_pathNodes[m_numPathNodes].pos = CoorsXFormed;
- m_pathNodes[m_numPathNodes].objectIndex = i;
- m_pathNodes[m_numPathNodes].unkBits = 1;
- m_mapObjects[i]->m_nodeIndices[type][j] = m_numPathNodes++;
+ if(objectpathinfo[start + j].type == NodeTypeIntern){
+ CalcNodeCoors(
+ objectpathinfo[start + j].x,
+ objectpathinfo[start + j].y,
+ objectpathinfo[start + j].z,
+ i,
+ &CoorsXFormed);
+ m_pathNodes[m_numPathNodes].SetPosition(CoorsXFormed);
+ OBJECTINDEX(m_numPathNodes) = i;
+ m_pathNodes[m_numPathNodes].unkBits = 1;
+ m_mapObjects[i]->m_nodeIndices[type][j] = m_numPathNodes;
+ m_numPathNodes++;
+ }
}
}
+
// Insert external nodes into TempList
TempListLength = 0;
for(i = 0; i < m_numMapObjects; i++){
- start = 12*m_mapObjects[i]->m_modelIndex;
-
+ start = 12 * m_mapObjects[i]->GetModelIndex();
for(j = 0; j < 12; j++){
if(objectpathinfo[start + j].type != NodeTypeExtern)
continue;
@@ -618,8 +634,8 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
tempnodes[nearestId].linkState = 2;
// collapse this node with nearest we found
- dx = m_pathNodes[tempnodes[nearestId].link1].pos.x - m_pathNodes[tempnodes[nearestId].link2].pos.x;
- dy = m_pathNodes[tempnodes[nearestId].link1].pos.y - m_pathNodes[tempnodes[nearestId].link2].pos.y;
+ dx = m_pathNodes[tempnodes[nearestId].link1].GetX() - m_pathNodes[tempnodes[nearestId].link2].GetX();
+ dy = m_pathNodes[tempnodes[nearestId].link1].GetY() - m_pathNodes[tempnodes[nearestId].link2].GetY();
tempnodes[nearestId].pos = (tempnodes[nearestId].pos + CoorsXFormed)*0.5f;
mag = Sqrt(dx*dx + dy*dy);
tempnodes[nearestId].dirX = dx/mag;
@@ -648,6 +664,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
continue;
// Add link to other side of the external
+ // NB this clears the flags in MIAMI
if(tempnodes[j].link1 == i)
m_connections[m_numConnections] = tempnodes[j].link2;
else if(tempnodes[j].link2 == i)
@@ -655,8 +672,8 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
else
continue;
- dist = m_pathNodes[i].pos - m_pathNodes[m_connections[m_numConnections]].pos;
- m_distances[m_numConnections] = dist.Magnitude();
+ dist = (m_pathNodes[i].GetPosition() - m_pathNodes[ConnectedNode(m_numConnections)].GetPosition()).Magnitude();
+ m_distances[m_numConnections] = dist;
m_connectionFlags[m_numConnections].flags = 0;
if(type == PATH_CAR){
@@ -681,6 +698,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
m_carPathLinks[m_numCarPathLinks].numLeftLanes = tempnodes[j].numLeftLanes;
m_carPathLinks[m_numCarPathLinks].numRightLanes = tempnodes[j].numRightLanes;
m_carPathLinks[m_numCarPathLinks].trafficLightType = 0;
+ assert(m_numCarPathLinks <= NUM_CARPATHLINKS);
m_carPathConnections[m_numConnections] = m_numCarPathLinks++;
}
}
@@ -689,33 +707,35 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
m_numConnections++;
}
+
// Find i inside path segment
iseg = 0;
for(j = Max(oldNumPathNodes, i-12); j < i; j++)
- if(m_pathNodes[j].objectIndex == m_pathNodes[i].objectIndex)
+ if(OBJECTINDEX(j) == OBJECTINDEX(i))
iseg++;
- istart = 12*m_mapObjects[m_pathNodes[i].objectIndex]->m_modelIndex;
+ istart = 12 * m_mapObjects[m_pathNodes[i].objectIndex]->GetModelIndex();
// Add links to other internal nodes
for(j = Max(oldNumPathNodes, i-12); j < Min(m_numPathNodes, i+12); j++){
- if(m_pathNodes[i].objectIndex != m_pathNodes[j].objectIndex || i == j)
+ if(OBJECTINDEX(i) != OBJECTINDEX(j) || i == j)
continue;
// N.B.: in every path segment, the externals have to be at the end
jseg = j-i + iseg;
- jstart = 12*m_mapObjects[m_pathNodes[j].objectIndex]->m_modelIndex;
+ jstart = 12 * m_mapObjects[m_pathNodes[j].objectIndex]->GetModelIndex();
if(objectpathinfo[istart + iseg].next == jseg ||
objectpathinfo[jstart + jseg].next == iseg){
- // Found a link between i and j
+ // Found a link between i and jConnectionSetCrossesRoad
+ // NB this clears the flags in MIAMI
m_connections[m_numConnections] = j;
- dist = m_pathNodes[i].pos - m_pathNodes[j].pos;
- m_distances[m_numConnections] = dist.Magnitude();
+ dist = (m_pathNodes[i].GetPosition() - m_pathNodes[j].GetPosition()).Magnitude();
+ m_distances[m_numConnections] = dist;
if(type == PATH_CAR){
- posx = (m_pathNodes[i].pos.x + m_pathNodes[j].pos.x)*0.5f;
- posy = (m_pathNodes[i].pos.y + m_pathNodes[j].pos.y)*0.5f;
- dx = m_pathNodes[j].pos.x - m_pathNodes[i].pos.x;
- dy = m_pathNodes[j].pos.y - m_pathNodes[i].pos.y;
+ posx = (m_pathNodes[i].GetX() + m_pathNodes[j].GetX())*0.5f;
+ posy = (m_pathNodes[i].GetY() + m_pathNodes[j].GetY())*0.5f;
+ dx = m_pathNodes[j].GetX() - m_pathNodes[i].GetX();
+ dy = m_pathNodes[j].GetY() - m_pathNodes[i].GetY();
mag = Sqrt(dx*dx + dy*dy);
dx /= mag;
dy /= mag;
@@ -744,6 +764,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
m_carPathLinks[m_numCarPathLinks].numLeftLanes = -1;
m_carPathLinks[m_numCarPathLinks].numRightLanes = -1;
m_carPathLinks[m_numCarPathLinks].trafficLightType = 0;
+ assert(m_numCarPathLinks <= NUM_CARPATHLINKS);
m_carPathConnections[m_numConnections] = m_numCarPathLinks++;
}
}else{
@@ -825,7 +846,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
if(!m_pathNodes[i].bDeadEnd){
k = 0;
for(j = 0; j < m_pathNodes[i].numLinks; j++)
- if(!m_pathNodes[m_connections[m_pathNodes[i].firstLink + j]].bDeadEnd)
+ if(!m_pathNodes[ConnectedNode(m_pathNodes[i].firstLink + j)].bDeadEnd)
k++;
if(k < 2){
m_pathNodes[i].bDeadEnd = true;
@@ -847,9 +868,11 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
m_pathNodes[j] = m_pathNodes[j+1];
// Fix links
- for(j = oldNumLinks; j < m_numConnections; j++)
- if(m_connections[j] >= i)
- m_connections[j]--;
+ for(j = oldNumLinks; j < m_numConnections; j++){
+ int node = ConnectedNode(j);
+ if(node >= i)
+ m_connections[j] = node-1;
+ }
// Also in treadables
for(j = 0; j < m_numMapObjects; j++)
@@ -875,12 +898,12 @@ CPathFind::CalcRoadDensity(float x, float y)
float density = 0.0f;
for(i = 0; i < m_numCarPathNodes; i++){
- if(Abs(m_pathNodes[i].pos.x - x) < 80.0f &&
- Abs(m_pathNodes[i].pos.y - y) < 80.0f &&
+ if(Abs(m_pathNodes[i].GetX() - x) < 80.0f &&
+ Abs(m_pathNodes[i].GetY() - y) < 80.0f &&
m_pathNodes[i].numLinks > 0){
for(j = 0; j < m_pathNodes[i].numLinks; j++){
- int next = m_connections[m_pathNodes[i].firstLink + j];
- float dist = (m_pathNodes[i].pos - m_pathNodes[next].pos).Magnitude2D();
+ int next = ConnectedNode(m_pathNodes[i].firstLink + j);
+ float dist = (m_pathNodes[i].GetPosition() - m_pathNodes[next].GetPosition()).Magnitude2D();
next = m_carPathConnections[m_pathNodes[i].firstLink + j];
density += m_carPathLinks[next].numLeftLanes * dist;
density += m_carPathLinks[next].numRightLanes * dist;
@@ -888,11 +911,11 @@ CPathFind::CalcRoadDensity(float x, float y)
if(m_carPathLinks[next].numLeftLanes < 0)
printf("Link from object %d to %d (MIs)\n",
m_mapObjects[m_pathNodes[i].objectIndex]->GetModelIndex(),
- m_mapObjects[m_pathNodes[m_connections[m_pathNodes[i].firstLink + j]].objectIndex]->GetModelIndex());
+ m_mapObjects[m_pathNodes[ConnectedNode(m_pathNodes[i].firstLink + j)].objectIndex]->GetModelIndex());
if(m_carPathLinks[next].numRightLanes < 0)
printf("Link from object %d to %d (MIs)\n",
m_mapObjects[m_pathNodes[i].objectIndex]->GetModelIndex(),
- m_mapObjects[m_pathNodes[m_connections[m_pathNodes[i].firstLink + j]].objectIndex]->GetModelIndex());
+ m_mapObjects[m_pathNodes[ConnectedNode(m_pathNodes[i].firstLink + j)].objectIndex]->GetModelIndex());
}
}
}
@@ -904,8 +927,8 @@ CPathFind::TestForPedTrafficLight(CPathNode *n1, CPathNode *n2)
{
int i;
for(i = 0; i < n1->numLinks; i++)
- if(&m_pathNodes[m_connections[n1->firstLink + i]] == n2)
- return m_connectionFlags[n1->firstLink + i].bTrafficLight;
+ if(&m_pathNodes[ConnectedNode(n1->firstLink + i)] == n2)
+ return ConnectionHasTrafficLight(n1->firstLink + i);
return false;
}
@@ -914,8 +937,8 @@ CPathFind::TestCrossesRoad(CPathNode *n1, CPathNode *n2)
{
int i;
for(i = 0; i < n1->numLinks; i++)
- if(&m_pathNodes[m_connections[n1->firstLink + i]] == n2)
- return m_connectionFlags[n1->firstLink + i].bCrossesRoad;
+ if(&m_pathNodes[ConnectedNode(n1->firstLink + i)] == n2)
+ return ConnectionCrossesRoad(n1->firstLink + i);
return false;
}
@@ -923,20 +946,20 @@ void
CPathFind::AddNodeToList(CPathNode *node, int32 listId)
{
int i = listId & 0x1FF;
- node->next = m_searchNodes[i].next;
- node->prev = &m_searchNodes[i];
- if(m_searchNodes[i].next)
- m_searchNodes[i].next->prev = node;
- m_searchNodes[i].next = node;
+ node->SetNext(m_searchNodes[i].GetNext());
+ node->SetPrev(&m_searchNodes[i]);
+ if(m_searchNodes[i].GetNext())
+ m_searchNodes[i].GetNext()->SetPrev(node);
+ m_searchNodes[i].SetNext(node);
node->distance = listId;
}
void
CPathFind::RemoveNodeFromList(CPathNode *node)
{
- node->prev->next = node->next;
- if(node->next)
- node->next->prev = node->prev;
+ node->GetPrev()->SetNext(node->GetNext());
+ if(node->GetNext())
+ node->GetNext()->SetPrev(node->GetPrev());
}
void
@@ -945,7 +968,7 @@ CPathFind::RemoveBadStartNode(CVector pos, CPathNode **nodes, int16 *n)
int i;
if(*n < 2)
return;
- if(DotProduct2D(nodes[1]->pos - pos, nodes[0]->pos - pos) < 0.0f){
+ if(DotProduct2D(nodes[1]->GetPosition() - pos, nodes[0]->GetPosition() - pos) < 0.0f){
(*n)--;
for(i = 0; i < *n; i++)
nodes[i] = nodes[i+1];
@@ -956,10 +979,12 @@ void
CPathFind::SetLinksBridgeLights(float x1, float x2, float y1, float y2, bool enable)
{
int i;
- for(i = 0; i < m_numCarPathLinks; i++)
- if(x1 < m_carPathLinks[i].pos.x && m_carPathLinks[i].pos.x < x2 &&
- y1 < m_carPathLinks[i].pos.y && m_carPathLinks[i].pos.y < y2)
+ for(i = 0; i < m_numCarPathLinks; i++){
+ CVector2D pos = m_carPathLinks[i].GetPosition();
+ if(x1 < pos.x && pos.x < x2 &&
+ y1 < pos.y && pos.y < y2)
m_carPathLinks[i].bBridgeLights = enable;
+ }
}
void
@@ -970,7 +995,7 @@ CPathFind::SwitchOffNodeAndNeighbours(int32 nodeId, bool disable)
m_pathNodes[nodeId].bDisabled = disable;
if(m_pathNodes[nodeId].numLinks < 3)
for(i = 0; i < m_pathNodes[nodeId].numLinks; i++){
- next = m_connections[m_pathNodes[nodeId].firstLink + i];
+ next = ConnectedNode(m_pathNodes[nodeId].firstLink + i);
if(m_pathNodes[next].bDisabled != disable &&
m_pathNodes[next].numLinks < 3)
SwitchOffNodeAndNeighbours(next, disable);
@@ -982,12 +1007,14 @@ CPathFind::SwitchRoadsOffInArea(float x1, float x2, float y1, float y2, float z1
{
int i;
- for(i = 0; i < m_numCarPathNodes; i++)
- if (x1 <= m_pathNodes[i].pos.x && m_pathNodes[i].pos.x <= x2 &&
- y1 <= m_pathNodes[i].pos.y && m_pathNodes[i].pos.y <= y2 &&
- z1 <= m_pathNodes[i].pos.z && m_pathNodes[i].pos.z <= z2 &&
+ for(i = 0; i < m_numCarPathNodes; i++){
+ CVector pos = m_pathNodes[i].GetPosition();
+ if(x1 <= pos.x && pos.x <= x2 &&
+ y1 <= pos.y && pos.y <= y2 &&
+ z1 <= pos.z && pos.z <= z2 &&
disable != m_pathNodes[i].bDisabled)
SwitchOffNodeAndNeighbours(i, disable);
+ }
}
void
@@ -995,12 +1022,14 @@ CPathFind::SwitchPedRoadsOffInArea(float x1, float x2, float y1, float y2, float
{
int i;
- for(i = m_numCarPathNodes; i < m_numPathNodes; i++)
- if(x1 <= m_pathNodes[i].pos.x && m_pathNodes[i].pos.x <= x2 &&
- y1 <= m_pathNodes[i].pos.y && m_pathNodes[i].pos.y <= y2 &&
- z1 <= m_pathNodes[i].pos.z && m_pathNodes[i].pos.z <= z2 &&
+ for(i = m_numCarPathNodes; i < m_numPathNodes; i++){
+ CVector pos = m_pathNodes[i].GetPosition();
+ if(x1 <= pos.x && pos.x <= x2 &&
+ y1 <= pos.y && pos.y <= y2 &&
+ z1 <= pos.z && pos.z <= z2 &&
disable != m_pathNodes[i].bDisabled)
SwitchOffNodeAndNeighbours(i, disable);
+ }
}
void
@@ -1039,9 +1068,10 @@ CPathFind::SwitchRoadsInAngledArea(float x1, float y1, float z1, float x2, float
bool disable = mode == SWITCH_OFF;
for(i = firstNode; i < lastNode; i++){
- if(m_pathNodes[i].pos.z < z1 || m_pathNodes[i].pos.z > z2)
+ CVector pos = m_pathNodes[i].GetPosition();
+ if(pos.z < z1 || pos.z > z2)
continue;
- CVector2D d(m_pathNodes[i].pos.x - x1, m_pathNodes[i].pos.y - y1);
+ CVector2D d(pos.x - x1, pos.y - y1);
float dot = DotProduct2D(d, v12);
if(dot < 0.0f || dot > len12)
continue;
@@ -1061,7 +1091,7 @@ CPathFind::MarkRoadsBetweenLevelsNodeAndNeighbours(int32 nodeId)
m_pathNodes[nodeId].bBetweenLevels = true;
if(m_pathNodes[nodeId].numLinks < 3)
for(i = 0; i < m_pathNodes[nodeId].numLinks; i++){
- next = m_connections[m_pathNodes[nodeId].firstLink + i];
+ next = ConnectedNode(m_pathNodes[nodeId].firstLink + i);
if(!m_pathNodes[next].bBetweenLevels &&
m_pathNodes[next].numLinks < 3)
MarkRoadsBetweenLevelsNodeAndNeighbours(next);
@@ -1073,11 +1103,13 @@ CPathFind::MarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y2,
{
int i;
- for(i = 0; i < m_numPathNodes; i++)
- if(x1 < m_pathNodes[i].pos.x && m_pathNodes[i].pos.x < x2 &&
- y1 < m_pathNodes[i].pos.y && m_pathNodes[i].pos.y < y2 &&
- z1 < m_pathNodes[i].pos.z && m_pathNodes[i].pos.z < z2)
+ for(i = 0; i < m_numPathNodes; i++){
+ CVector pos = m_pathNodes[i].GetPosition();
+ if(x1 < pos.x && pos.x < x2 &&
+ y1 < pos.y && pos.y < y2 &&
+ z1 < pos.z && pos.z < z2)
MarkRoadsBetweenLevelsNodeAndNeighbours(i);
+ }
}
void
@@ -1085,11 +1117,13 @@ CPathFind::PedMarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y
{
int i;
- for(i = m_numCarPathNodes; i < m_numPathNodes; i++)
- if(x1 < m_pathNodes[i].pos.x && m_pathNodes[i].pos.x < x2 &&
- y1 < m_pathNodes[i].pos.y && m_pathNodes[i].pos.y < y2 &&
- z1 < m_pathNodes[i].pos.z && m_pathNodes[i].pos.z < z2)
+ for(i = m_numCarPathNodes; i < m_numPathNodes; i++){
+ CVector pos = m_pathNodes[i].GetPosition();
+ if(x1 < pos.x && pos.x < x2 &&
+ y1 < pos.y && pos.y < y2 &&
+ z1 < pos.z && pos.z < z2)
MarkRoadsBetweenLevelsNodeAndNeighbours(i);
+ }
}
int32
@@ -1118,9 +1152,9 @@ CPathFind::FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bo
switch(m_pathNodes[i].unkBits){
case 1:
case 2:
- dist = Abs(m_pathNodes[i].pos.x - coors.x) +
- Abs(m_pathNodes[i].pos.y - coors.y) +
- 3.0f*Abs(m_pathNodes[i].pos.z - coors.z);
+ dist = Abs(m_pathNodes[i].GetX() - coors.x) +
+ Abs(m_pathNodes[i].GetY() - coors.y) +
+ 3.0f*Abs(m_pathNodes[i].GetZ() - coors.z);
if(dist < closestDist){
closestDist = dist;
closestNode = i;
@@ -1156,10 +1190,10 @@ CPathFind::FindNodeClosestToCoorsFavourDirection(CVector coors, uint8 type, floa
switch(m_pathNodes[i].unkBits){
case 1:
case 2:
- dX = m_pathNodes[i].pos.x - coors.x;
- dY = m_pathNodes[i].pos.y - coors.y;
+ dX = m_pathNodes[i].GetX() - coors.x;
+ dY = m_pathNodes[i].GetY() - coors.y;
dist = Abs(dX) + Abs(dY) +
- 3.0f*Abs(m_pathNodes[i].pos.z - coors.z);
+ 3.0f*Abs(m_pathNodes[i].GetZ() - coors.z);
if(dist < closestDist){
NormalizeXY(dX, dY);
dist -= (dX*dirX + dY*dirY - 1.0f)*20.0f;
@@ -1174,13 +1208,12 @@ CPathFind::FindNodeClosestToCoorsFavourDirection(CVector coors, uint8 type, floa
return closestNode;
}
-
float
CPathFind::FindNodeOrientationForCarPlacement(int32 nodeId)
{
if(m_pathNodes[nodeId].numLinks == 0)
return 0.0f;
- CVector dir = m_pathNodes[m_connections[m_pathNodes[nodeId].firstLink]].pos - m_pathNodes[nodeId].pos;
+ CVector dir = m_pathNodes[ConnectedNode(m_pathNodes[nodeId].firstLink)].GetPosition() - m_pathNodes[nodeId].GetPosition();
dir.z = 0.0f;
dir.Normalise();
return RADTODEG(dir.Heading());
@@ -1191,14 +1224,14 @@ CPathFind::FindNodeOrientationForCarPlacementFacingDestination(int32 nodeId, flo
{
int i;
- CVector targetDir(x - m_pathNodes[nodeId].pos.x, y - m_pathNodes[nodeId].pos.y, 0.0f);
+ CVector targetDir(x - m_pathNodes[nodeId].GetX(), y - m_pathNodes[nodeId].GetY(), 0.0f);
targetDir.Normalise();
CVector dir;
if(m_pathNodes[nodeId].numLinks == 0)
return 0.0f;
- int bestNode = m_connections[m_pathNodes[nodeId].firstLink];
+ int bestNode = ConnectedNode(m_pathNodes[nodeId].firstLink);
#ifdef FIX_BUGS
float bestDot = towards ? -2.0f : 2.0f;
#else
@@ -1206,24 +1239,24 @@ CPathFind::FindNodeOrientationForCarPlacementFacingDestination(int32 nodeId, flo
#endif
for(i = 0; i < m_pathNodes[nodeId].numLinks; i++){
- dir = m_pathNodes[m_connections[m_pathNodes[nodeId].firstLink + i]].pos - m_pathNodes[nodeId].pos;
+ dir = m_pathNodes[ConnectedNode(m_pathNodes[nodeId].firstLink + i)].GetPosition() - m_pathNodes[nodeId].GetPosition();
dir.z = 0.0f;
dir.Normalise();
float angle = DotProduct2D(dir, targetDir);
if(towards){
if(angle > bestDot){
bestDot = angle;
- bestNode = m_connections[m_pathNodes[nodeId].firstLink + i];
+ bestNode = ConnectedNode(m_pathNodes[nodeId].firstLink + i);
}
}else{
if(angle < bestDot){
bestDot = angle;
- bestNode = m_connections[m_pathNodes[nodeId].firstLink + i];
+ bestNode = ConnectedNode(m_pathNodes[nodeId].firstLink + i);
}
}
}
- dir = m_pathNodes[bestNode].pos - m_pathNodes[nodeId].pos;
+ dir = m_pathNodes[bestNode].GetPosition() - m_pathNodes[nodeId].GetPosition();
dir.z = 0.0f;
dir.Normalise();
return RADTODEG(dir.Heading());
@@ -1243,21 +1276,21 @@ CPathFind::NewGenerateCarCreationCoors(float x, float y, float dirX, float dirY,
node1 = (CGeneral::GetRandomNumber()>>3) % m_numCarPathNodes;
if(m_pathNodes[node1].bDisabled && !ignoreDisabled)
continue;
- dist1 = Distance2D(m_pathNodes[node1].pos, x, y);
+ dist1 = Distance2D(m_pathNodes[node1].GetPosition(), x, y);
if(dist1 < spawnDist + 60.0f){
d1 = dist1 - spawnDist;
for(j = 0; j < m_pathNodes[node1].numLinks; j++){
- node2 = m_connections[m_pathNodes[node1].firstLink + j];
+ node2 = ConnectedNode(m_pathNodes[node1].firstLink + j);
if(m_pathNodes[node2].bDisabled && !ignoreDisabled)
continue;
- dist2 = Distance2D(m_pathNodes[node2].pos, x, y);
+ dist2 = Distance2D(m_pathNodes[node2].GetPosition(), x, y);
d2 = dist2 - spawnDist;
if(d1*d2 < 0.0f){
// nodes are on different sides of spawn distance
float f2 = Abs(d1)/(Abs(d1) + Abs(d2));
float f1 = 1.0f - f2;
*pPositionBetweenNodes = f2;
- CVector pos = m_pathNodes[node1].pos*f1 + m_pathNodes[node2].pos*f2;
+ CVector pos = m_pathNodes[node1].GetPosition()*f1 + m_pathNodes[node2].GetPosition()*f2;
CVector2D dist2d(pos.x - x, pos.y - y);
dist2d.Normalise(); // done manually in the game
float dot = DotProduct2D(dist2d, CVector2D(dirX, dirY));
@@ -1294,20 +1327,20 @@ CPathFind::GeneratePedCreationCoors(float x, float y, float minDist, float maxDi
for(i = 0; i < 400; i++){
node1 = m_numCarPathNodes + CGeneral::GetRandomNumber() % m_numPedPathNodes;
- if(DistanceSqr2D(m_pathNodes[node1].pos, x, y) < sq(maxDist+30.0f)){
+ if(DistanceSqr2D(m_pathNodes[node1].GetPosition(), x, y) < sq(maxDist+30.0f)){
if(m_pathNodes[node1].numLinks == 0)
continue;
int link = m_pathNodes[node1].firstLink + CGeneral::GetRandomNumber() % m_pathNodes[node1].numLinks;
- if(m_connectionFlags[link].bCrossesRoad)
+ if(ConnectionCrossesRoad(link))
continue;
- node2 = m_connections[link];
+ node2 = ConnectedNode(link);
if(m_pathNodes[node1].bDisabled || m_pathNodes[node2].bDisabled)
continue;
float f2 = (CGeneral::GetRandomNumber()&0xFF)/256.0f;
float f1 = 1.0f - f2;
*pPositionBetweenNodes = f2;
- CVector pos = m_pathNodes[node1].pos*f1 + m_pathNodes[node2].pos*f2;
+ CVector pos = m_pathNodes[node1].GetPosition()*f1 + m_pathNodes[node2].GetPosition()*f2;
if(Distance2D(pos, x, y) < maxDist+20.0f){
pos.x += ((CGeneral::GetRandomNumber()&0xFF)-128)*0.01f;
pos.y += ((CGeneral::GetRandomNumber()&0xFF)-128)*0.01f;
@@ -1363,11 +1396,11 @@ CPathFind::FindRoadObjectClosestToCoors(CVector coors, uint8 type)
break;
// FIX: game uses ThePaths here explicitly
for(k = 0; k < m_pathNodes[node1].numLinks; k++){
- node2 = m_connections[m_pathNodes[node1].firstLink + k];
- float lineDist = CCollision::DistToLine(&m_pathNodes[node1].pos, &m_pathNodes[node2].pos, &coors);
+ node2 = ConnectedNode(m_pathNodes[node1].firstLink + k);
+ float lineDist = CCollision::DistToLine(&m_pathNodes[node1].GetPosition(), &m_pathNodes[node2].GetPosition(), &coors);
if(lineDist < closestDist){
closestDist = lineDist;
- if((coors - m_pathNodes[node1].pos).MagnitudeSqr() < (coors - m_pathNodes[node2].pos).MagnitudeSqr())
+ if((coors - m_pathNodes[node1].GetPosition()).MagnitudeSqr() < (coors - m_pathNodes[node2].GetPosition()).MagnitudeSqr())
closestMapObj = m_mapObjects[m_pathNodes[node1].objectIndex];
else
closestMapObj = m_mapObjects[m_pathNodes[node2].objectIndex];
@@ -1384,7 +1417,7 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode
int i;
CPathNode *node;
- if(lastNode == nil || (node = *lastNode) == nil || (coors - (*lastNode)->pos).MagnitudeSqr() > 7.0f){
+ if(lastNode == nil || (node = *lastNode) == nil || (coors - (*lastNode)->GetPosition()).MagnitudeSqr() > 7.0f){
// need to find the node we're coming from
node = nil;
CTreadable *obj = FindRoadObjectClosestToCoors(coors, type);
@@ -1392,7 +1425,7 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode
for(i = 0; i < 12; i++){
if(obj->m_nodeIndices[type][i] < 0)
break;
- float dist = (coors - m_pathNodes[obj->m_nodeIndices[type][i]].pos).MagnitudeSqr();
+ float dist = (coors - m_pathNodes[obj->m_nodeIndices[type][i]].GetPosition()).MagnitudeSqr();
if(dist < nodeDist){
nodeDist = dist;
node = &m_pathNodes[obj->m_nodeIndices[type][i]];
@@ -1404,16 +1437,16 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode
*nextNode = 0;
float bestDot = -999999.0f;
for(i = 0; i < node->numLinks; i++){
- int next = m_connections[node->firstLink+i];
+ int next = ConnectedNode(node->firstLink+i);
if(!node->bDisabled && m_pathNodes[next].bDisabled)
continue;
CVector pedCoors = coors;
pedCoors.z += 1.0f;
- CVector nodeCoors = m_pathNodes[next].pos;
+ CVector nodeCoors = m_pathNodes[next].GetPosition();
nodeCoors.z += 1.0f;
if(!CWorld::GetIsLineOfSightClear(pedCoors, nodeCoors, true, false, false, false, false, false))
continue;
- CVector2D nodeDir = m_pathNodes[next].pos - node->pos;
+ CVector2D nodeDir = m_pathNodes[next].GetPosition() - node->GetPosition();
nodeDir.Normalise();
float dot = DotProduct2D(nodeDir, vCurDir);
if(dot >= bestDot){
@@ -1421,7 +1454,7 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode
bestDot = dot;
// direction is 0, 2, 4, 6 for north, east, south, west
- // this could be sone simpler...
+ // this could be done simpler...
if(nodeDir.x < 0.0f){
if(2.0f*Abs(nodeDir.y) < -nodeDir.x)
*nextDir = 6; // west
@@ -1456,17 +1489,14 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode
static CPathNode *apNodesToBeCleared[4995];
void
-CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, CPathNode **nodes, int16 *pNumNodes, int16 maxNumNodes, CVehicle *vehicle, float *pDist, float distLimit, int32 forcedTargetNode)
+CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, CPathNode **nodes, int16 *pNumNodes, int16 maxNumNodes, CVehicle *vehicle, float *pDist, float distLimit, int32 targetNodeId)
{
int i, j;
// Find target
- int targetNode;
- if(forcedTargetNode < 0)
- targetNode = FindNodeClosestToCoors(target, type, distLimit);
- else
- targetNode = forcedTargetNode;
- if(targetNode < 0) {
+ if(targetNodeId < 0)
+ targetNodeId = FindNodeClosestToCoors(target, type, distLimit);
+ if(targetNodeId < 0) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
@@ -1482,7 +1512,7 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
for(i = 0; i < 12; i++){
if(startObj->m_nodeIndices[type][i] < 0)
break;
- if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNode].group)
+ if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNodeId].group)
numPathsToTry++;
}
}else{
@@ -1498,39 +1528,39 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
if(startNodeId < 0){
// why only check node 0?
if(m_pathNodes[startObj->m_nodeIndices[type][0]].group !=
- m_pathNodes[targetNode].group) {
+ m_pathNodes[targetNodeId].group) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
}else{
- if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) {
+ if(m_pathNodes[startNodeId].group != m_pathNodes[targetNodeId].group) {
*pNumNodes = 0;
if(pDist) *pDist = 100000.0f;
return;
}
}
- for(i = 0; i < 512; i++)
- m_searchNodes[i].next = nil;
- AddNodeToList(&m_pathNodes[targetNode], 0);
+ for(i = 0; i < ARRAY_SIZE(m_searchNodes); i++)
+ m_searchNodes[i].SetNext(nil);
+ AddNodeToList(&m_pathNodes[targetNodeId], 0);
int numNodesToBeCleared = 0;
- apNodesToBeCleared[numNodesToBeCleared++] = &m_pathNodes[targetNode];
+ apNodesToBeCleared[numNodesToBeCleared++] = &m_pathNodes[targetNodeId];
// Dijkstra's algorithm
// Find distances
int numPathsFound = 0;
- if(startNodeId < 0 && m_mapObjects[m_pathNodes[targetNode].objectIndex] == startObj)
+ if(startNodeId < 0 && m_mapObjects[m_pathNodes[targetNodeId].objectIndex] == startObj)
numPathsFound++;
for(i = 0; numPathsFound < numPathsToTry; i = (i+1) & 0x1FF){
CPathNode *node;
- for(node = m_searchNodes[i].next; node; node = node->next){
+ for(node = m_searchNodes[i].GetNext(); node; node = node->GetNext()){
if(m_mapObjects[node->objectIndex] == startObj &&
(startNodeId < 0 || node == &m_pathNodes[startNodeId]))
numPathsFound++;
for(j = 0; j < node->numLinks; j++){
- int next = m_connections[node->firstLink + j];
+ int next = ConnectedNode(node->firstLink + j);
int dist = node->distance + m_distances[node->firstLink + j];
if(dist < m_pathNodes[next].distance){
if(m_pathNodes[next].distance != MAX_DIST)
@@ -1553,7 +1583,7 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
for(i = 0; i < 12; i++){
if(startObj->m_nodeIndices[type][i] < 0)
break;
- int dist = (m_pathNodes[startObj->m_nodeIndices[type][i]].pos - start).Magnitude();
+ int dist = (m_pathNodes[startObj->m_nodeIndices[type][i]].GetPosition() - start).Magnitude();
if(m_pathNodes[startObj->m_nodeIndices[type][i]].distance + dist < minDist){
minDist = m_pathNodes[startObj->m_nodeIndices[type][i]].distance + dist;
curNode = &m_pathNodes[startObj->m_nodeIndices[type][i]];
@@ -1567,7 +1597,8 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
}
if(pDist)
*pDist = minDist;
- }else{
+ }else
+ {
curNode = &m_pathNodes[startNodeId];
*pNumNodes = 0;
if(pDist)
@@ -1575,9 +1606,9 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
}
// Trace back to target and update list of nodes
- while(*pNumNodes < maxNumNodes && curNode != &m_pathNodes[targetNode])
+ while(*pNumNodes < maxNumNodes && curNode != &m_pathNodes[targetNodeId])
for(i = 0; i < curNode->numLinks; i++){
- int next = m_connections[curNode->firstLink + i];
+ int next = ConnectedNode(curNode->firstLink + i);
if(curNode->distance - m_distances[curNode->firstLink + i] == m_pathNodes[next].distance){
curNode = &m_pathNodes[next];
nodes[(*pNumNodes)++] = curNode;
@@ -1598,6 +1629,7 @@ bool
CPathFind::TestCoorsCloseness(CVector target, uint8 type, CVector start)
{
float dist;
+
if(type == PATH_CAR)
DoPathSearch(type, start, -1, target, pNodeList, &DummyResult, 32, nil, &dist, 999999.88f, -1);
else
@@ -1661,10 +1693,10 @@ CPathFind::DisplayPathData(void)
// Render car path nodes
if(gbShowCarPaths)
for(i = 0; i < m_numCarPathNodes; i++){
- if((m_pathNodes[i].pos - pos).MagnitudeSqr() > SQR(maxDist))
+ if((m_pathNodes[i].GetPosition() - pos).MagnitudeSqr() > SQR(maxDist))
continue;
- CVector n1 = m_pathNodes[i].pos;
+ CVector n1 = m_pathNodes[i].GetPosition();
n1.z += 0.3f;
// Draw node itself
@@ -1673,8 +1705,8 @@ CPathFind::DisplayPathData(void)
0xFFFFFFFF, 0xFFFFFFFF);
for(j = 0; j < m_pathNodes[i].numLinks; j++){
- k = m_connections[m_pathNodes[i].firstLink + j];
- CVector n2 = m_pathNodes[k].pos;
+ k = ConnectedNode(m_pathNodes[i].firstLink + j);
+ CVector n2 = m_pathNodes[k].GetPosition();
n2.z += 0.3f;
// Draw links to neighbours
CLines::RenderLineWithClipping(n1.x, n1.y, n1.z,
@@ -1686,12 +1718,12 @@ CPathFind::DisplayPathData(void)
// Render car path nodes
if(gbShowCarPathsLinks)
for(i = 0; i < m_numCarPathLinks; i++){
- CVector2D n1_2d = m_carPathLinks[i].pos;
+ CVector2D n1_2d = m_carPathLinks[i].GetPosition();
if((n1_2d - pos).MagnitudeSqr() > SQR(maxDist))
continue;
int ni = m_carPathLinks[i].pathNodeIndex;
- CVector pn1 = m_pathNodes[ni].pos;
+ CVector pn1 = m_pathNodes[ni].GetPosition();
pn1.z += 0.3f;
CVector n1(n1_2d.x, n1_2d.y, pn1.z);
n1.z += 0.3f;
@@ -1701,7 +1733,7 @@ CPathFind::DisplayPathData(void)
n1.x, n1.y, n1.z + 1.0f,
0xFFFFFFFF, 0xFFFFFFFF);
CLines::RenderLineWithClipping(n1.x, n1.y, n1.z + 0.5f,
- n1.x+m_carPathLinks[i].dir.x, n1.y+m_carPathLinks[i].dir.y, n1.z + 0.5f,
+ n1.x+m_carPathLinks[i].GetDirX(), n1.y+m_carPathLinks[i].GetDirY(), n1.z + 0.5f,
0xFFFFFFFF, 0xFFFFFFFF);
// Draw connection to car path node
@@ -1723,9 +1755,9 @@ CPathFind::DisplayPathData(void)
for(j = 0; j < m_pathNodes[ni].numLinks; j++){
k = m_carPathConnections[m_pathNodes[ni].firstLink + j];
- CVector2D n2_2d = m_carPathLinks[k].pos;
+ CVector2D n2_2d = m_carPathLinks[k].GetPosition();
int nk = m_carPathLinks[k].pathNodeIndex;
- CVector pn2 = m_pathNodes[nk].pos;
+ CVector pn2 = m_pathNodes[nk].GetPosition();
pn2.z += 0.3f;
CVector n2(n2_2d.x, n2_2d.y, pn2.z);
n2.z += 0.3f;
@@ -1740,10 +1772,10 @@ CPathFind::DisplayPathData(void)
// Render ped path nodes
if(gbShowPedPaths)
for(i = m_numCarPathNodes; i < m_numPathNodes; i++){
- if((m_pathNodes[i].pos - pos).MagnitudeSqr() > SQR(maxDist))
+ if((m_pathNodes[i].GetPosition() - pos).MagnitudeSqr() > SQR(maxDist))
continue;
- CVector n1 = m_pathNodes[i].pos;
+ CVector n1 = m_pathNodes[i].GetPosition();
n1.z += 0.3f;
// Draw node itself
@@ -1752,8 +1784,8 @@ CPathFind::DisplayPathData(void)
0xFFFFFFFF, 0xFFFFFFFF);
for(j = 0; j < m_pathNodes[i].numLinks; j++){
- k = m_connections[m_pathNodes[i].firstLink + j];
- CVector n2 = m_pathNodes[k].pos;
+ k = ConnectedNode(m_pathNodes[i].firstLink + j);
+ CVector n2 = m_pathNodes[k].GetPosition();
n2.z += 0.3f;
// Draw links to neighbours
CLines::RenderLineWithClipping(n1.x, n1.y, n1.z,
@@ -1763,9 +1795,9 @@ CPathFind::DisplayPathData(void)
// Draw connection flags
CVector mid = (n1+n2)/2.0f;
uint32 col = 0xFF;
- if(m_connectionFlags[m_pathNodes[i].firstLink + j].bCrossesRoad)
+ if(ConnectionCrossesRoad(m_pathNodes[i].firstLink + j))
col += 0x00FF0000;
- if(m_connectionFlags[m_pathNodes[i].firstLink + j].bTrafficLight)
+ if(ConnectionHasTrafficLight(m_pathNodes[i].firstLink + j))
col += 0xFF000000;
CLines::RenderLineWithClipping(mid.x, mid.y, mid.z,
mid.x, mid.y, mid.z + 1.0f,
diff --git a/src/control/PathFind.h b/src/control/PathFind.h
index 64c12d5b..bbfdf7b7 100644
--- a/src/control/PathFind.h
+++ b/src/control/PathFind.h
@@ -41,7 +41,8 @@ struct CPedPathNode
CPedPathNode* prev;
CPedPathNode* next;
};
-static_assert(sizeof(CPedPathNode) == 0x10, "CPedPathNode: error");
+
+VALIDATE_SIZE(CPedPathNode, 0x10);
class CPedPath {
public:
@@ -69,31 +70,17 @@ struct CPathNode
uint8 bBetweenLevels : 1;
int8 group;
-/* For reference VC:
- int16 prevIndex;
- int16 nextIndex;
- int16 x;
- int16 y;
- int16 z;
- int16 distance;
- int16 firstLink;
- int8 width;
- int8 group;
- int8 numLinks : 4;
- int8 bDeadEnd : 1;
- int8 bTurnedOff : 1; // flag 8 in node info
- int8 flagA40 : 1; // flag 20 in node info
- int8 flagA80 : 1; // flag 4 in node info
- int8 flagB1 : 1; // flag 10 in node info
- int8 flagB2 : 1; // flag 2 in node info
- int8 flagB4 : 1;
- int8 speedLimit : 2; // speed limit
- int8 flagB20 : 1;
- int8 flagB40 : 1;
- int8 flagB80 : 1;
- int8 spawnRate : 4;
- int8 flagsC : 4;
-*/
+
+ CVector &GetPosition(void) { return pos; }
+ void SetPosition(const CVector &p) { pos = p; }
+ float GetX(void) { return pos.x; }
+ float GetY(void) { return pos.y; }
+ float GetZ(void) { return pos.z; }
+
+ CPathNode *GetPrev(void) { return prev; }
+ CPathNode *GetNext(void) { return next; }
+ void SetPrev(CPathNode *node) { prev = node; }
+ void SetNext(CPathNode *node) { next = node; }
};
union CConnectionFlags
@@ -112,11 +99,18 @@ struct CCarPathLink
int16 pathNodeIndex;
int8 numLeftLanes;
int8 numRightLanes;
- int8 trafficLightType;
+ uint8 trafficLightType;
uint8 bBridgeLights : 1;
// more?
+ CVector2D &GetPosition(void) { return pos; }
+ CVector2D &GetDirection(void) { return dir; }
+ float GetX(void) { return pos.x; }
+ float GetY(void) { return pos.y; }
+ float GetDirX(void) { return dir.x; }
+ float GetDirY(void) { return dir.y; }
+
float OneWayLaneOffset()
{
if (numLeftLanes == 0)
@@ -127,6 +121,7 @@ struct CCarPathLink
}
};
+// This is what we're reading from the files, only temporary
struct CPathInfoForObject
{
int16 x;
@@ -161,16 +156,6 @@ struct CTempDetachedNode // unused
class CPathFind
{
public:
-/* For reference VC:
- CPathNode pathNodes[9650];
- CCarPathLink m_carPathLinks[3500];
- CBuilding *m_mapObjects[1250];
- // 0x8000 is cross road flag
- // 0x4000 is traffic light flag
- uint16 m_connections[20400];
- uint8 m_distances[20400];
- int16 m_carPathConnections[20400];
-*/
CPathNode m_pathNodes[NUM_PATHNODES];
CCarPathLink m_carPathLinks[NUM_CARPATHLINKS];
CTreadable *m_mapObjects[NUM_MAPOBJECTS];
@@ -179,6 +164,7 @@ public:
int16 m_distances[NUM_PATHCONNECTIONS];
CConnectionFlags m_connectionFlags[NUM_PATHCONNECTIONS];
int16 m_carPathConnections[NUM_PATHCONNECTIONS];
+
int32 m_numPathNodes;
int32 m_numCarPathNodes;
int32 m_numPedPathNodes;
@@ -199,7 +185,7 @@ public:
void PreparePathData(void);
void CountFloodFillGroups(uint8 type);
void PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoForObject *objectpathinfo,
- float unk, CTempDetachedNode *detachednodes, int unused);
+ float maxdist, CTempDetachedNode *detachednodes, int32 numDetached);
bool IsPathObject(int id) { return id < PATHNODESIZE && (InfoForTileCars[id*12].type != 0 || InfoForTilePeds[id*12].type != 0); }
@@ -229,10 +215,15 @@ public:
bool TestCoorsCloseness(CVector target, uint8 type, CVector start);
void Save(uint8 *buf, uint32 *size);
void Load(uint8 *buf, uint32 size);
+ uint16 ConnectedNode(int id) { return m_connections[id]; }
+ bool ConnectionCrossesRoad(int id) { return m_connectionFlags[id].bCrossesRoad; }
+ bool ConnectionHasTrafficLight(int id) { return m_connectionFlags[id].bTrafficLight; }
+ void ConnectionSetTrafficLight(int id) { m_connectionFlags[id].bTrafficLight = true; }
void DisplayPathData(void);
};
-static_assert(sizeof(CPathFind) == 0x49bf4, "CPathFind: error");
+
+VALIDATE_SIZE(CPathFind, 0x49bf4);
extern CPathFind ThePaths;
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp
index 15e9f9f1..136ef7db 100644
--- a/src/control/Phones.cpp
+++ b/src/control/Phones.cpp
@@ -298,10 +298,10 @@ CPhoneInfo::Initialise(void)
for (int i = pool->GetSize() - 1; i >= 0; i--) {
CBuilding *building = pool->GetSlot(i);
if (building) {
- if (building->m_modelIndex == MI_PHONEBOOTH1) {
+ if (building->GetModelIndex() == MI_PHONEBOOTH1) {
CPhone *maxPhone = &m_aPhones[m_nMax];
maxPhone->m_nState = PHONE_STATE_FREE;
- maxPhone->m_vecPos = *(building->GetPosition());
+ maxPhone->m_vecPos = building->GetPosition();
maxPhone->m_pEntity = building;
m_nMax++;
}
diff --git a/src/control/Phones.h b/src/control/Phones.h
index 7fbf403f..14d47ed1 100644
--- a/src/control/Phones.h
+++ b/src/control/Phones.h
@@ -32,7 +32,7 @@ public:
~CPhone() { }
};
-static_assert(sizeof(CPhone) == 0x34, "CPhone: error");
+VALIDATE_SIZE(CPhone, 0x34);
class CPhoneInfo {
public:
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index d5db4ad8..6b56cd8f 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -84,7 +84,7 @@ CPickup::GiveUsAPickUpObject(int32 handle)
if (object == nil) return nil;
object->ObjectCreatedBy = MISSION_OBJECT;
- object->GetPosition() = m_vecPos;
+ object->SetPosition(m_vecPos);
object->SetOrientation(0.0f, 0.0f, -HALFPI);
object->GetMatrix().UpdateRW();
object->UpdateRwFrame();
@@ -229,7 +229,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
if (m_eType == PICKUP_ON_STREET) {
m_nTimer = CTimer::GetTimeInMilliseconds() + 30000;
} else if (m_eType == PICKUP_ON_STREET_SLOW) {
- if (MI_PICKUP_BRIBE == m_pObject->m_modelIndex)
+ if (MI_PICKUP_BRIBE == m_pObject->GetModelIndex())
m_nTimer = CTimer::GetTimeInMilliseconds() + 300000;
else
m_nTimer = CTimer::GetTimeInMilliseconds() + 720000;
@@ -288,7 +288,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
case PICKUP_NAUTICAL_MINE_INACTIVE:
{
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
- m_pObject->GetPosition().z = waterLevel + 0.6f;
+ m_pObject->GetMatrix().GetPosition().z = waterLevel + 0.6f;
m_pObject->GetMatrix().UpdateRW();
m_pObject->UpdateRwFrame();
@@ -310,7 +310,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
case PICKUP_NAUTICAL_MINE_ARMED:
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
- m_pObject->GetPosition().z = waterLevel + 0.6f;
+ m_pObject->GetMatrix().GetPosition().z = waterLevel + 0.6f;
m_pObject->GetMatrix().UpdateRW();
m_pObject->UpdateRwFrame();
@@ -337,7 +337,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
case PICKUP_FLOATINGPACKAGE:
m_pObject->m_vecMoveSpeed.z -= 0.01f * CTimer::GetTimeStep();
- m_pObject->GetPosition() += m_pObject->GetMoveSpeed() * CTimer::GetTimeStep();
+ m_pObject->GetMatrix().GetPosition() += m_pObject->GetMoveSpeed() * CTimer::GetTimeStep();
m_pObject->GetMatrix().UpdateRW();
m_pObject->UpdateRwFrame();
@@ -346,7 +346,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
break;
case PICKUP_FLOATINGPACKAGE_FLOATING:
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, 0))
- m_pObject->GetPosition().z = waterLevel;
+ m_pObject->GetMatrix().GetPosition().z = waterLevel;
m_pObject->GetMatrix().UpdateRW();
m_pObject->UpdateRwFrame();
@@ -695,7 +695,7 @@ CPickups::DoPickUpEffects(CEntity *entity)
assert(colorId >= 0);
- CVector &pos = entity->GetPosition();
+ const CVector &pos = entity->GetPosition();
float colorModifier = ((CGeneral::GetRandomNumber() & 0x1F) * 0.015f + 1.0f) * modifiedSin * 0.15f;
CShadows::StoreStaticShadow(
@@ -749,7 +749,7 @@ CPickups::DoPickUpEffects(CEntity *entity)
void
CPickups::DoMineEffects(CEntity *entity)
{
- CVector &pos = entity->GetPosition();
+ const CVector &pos = entity->GetPosition();
float dist = (TheCamera.GetPosition() - pos).Magnitude();
const float MAXDIST = 20.0f;
@@ -771,7 +771,7 @@ CPickups::DoMineEffects(CEntity *entity)
void
CPickups::DoMoneyEffects(CEntity *entity)
{
- CVector &pos = entity->GetPosition();
+ const CVector &pos = entity->GetPosition();
float dist = (TheCamera.GetPosition() - pos).Magnitude();
const float MAXDIST = 20.0f;
@@ -793,7 +793,7 @@ CPickups::DoMoneyEffects(CEntity *entity)
void
CPickups::DoCollectableEffects(CEntity *entity)
{
- CVector &pos = entity->GetPosition();
+ const CVector &pos = entity->GetPosition();
float dist = (TheCamera.GetPosition() - pos).Magnitude();
const float MAXDIST = 14.0f;
@@ -1145,7 +1145,7 @@ CPacManPickups::GeneratePMPickUps(CVector pos, float scrambleMult, int16 count,
CObject *obj = new CObject(MI_BULLION, true);
if (obj != nil) {
obj->ObjectCreatedBy = MISSION_OBJECT;
- obj->GetPosition() = aPMPickUps[i].m_vecPosn;
+ obj->SetPosition(aPMPickUps[i].m_vecPosn);
obj->SetOrientation(0.0f, 0.0f, -HALFPI);
obj->GetMatrix().UpdateRW();
obj->UpdateRwFrame();
@@ -1296,7 +1296,7 @@ CPacManPickups::GeneratePMPickUpsForRace(int32 race)
if (obj != nil) {
obj->ObjectCreatedBy = MISSION_OBJECT;
- obj->GetPosition() = aPMPickUps[i].m_vecPosn;
+ obj->SetPosition(aPMPickUps[i].m_vecPosn);
obj->SetOrientation(0.0f, 0.0f, -HALFPI);
obj->GetMatrix().UpdateRW();
obj->UpdateRwFrame();
diff --git a/src/control/Pickups.h b/src/control/Pickups.h
index 11da5f54..b05f5db7 100644
--- a/src/control/Pickups.h
+++ b/src/control/Pickups.h
@@ -47,7 +47,7 @@ private:
void Remove();
};
-static_assert(sizeof(CPickup) == 0x1C, "CPickup: error");
+VALIDATE_SIZE(CPickup, 0x1C);
struct tPickupMessage
{
diff --git a/src/control/Record.cpp b/src/control/Record.cpp
index b9e8f8da..d086543f 100644
--- a/src/control/Record.cpp
+++ b/src/control/Record.cpp
@@ -279,14 +279,14 @@ void CRecordDataForChase::SaveOrRetrieveCarPositions(void)
}
if (CPad::GetPad(0)->GetLeftShockJustDown() && CPad::GetPad(0)->GetRightShockJustDown()) {
if (!CPad::GetPad(0)->GetRightShockJustDown()) {
- pChaseCars[CurrentCar]->GetPosition() = NewCoorsForRecordedCars[PositionChanges].pos;
+ pChaseCars[CurrentCar]->SetPosition(NewCoorsForRecordedCars[PositionChanges].pos);
pChaseCars[CurrentCar]->SetMoveSpeed(0.0f, 0.0f, 0.0f);
pChaseCars[CurrentCar]->GetMatrix().SetRotateZOnly(DEGTORAD(NewCoorsForRecordedCars[PositionChanges].angle));
++PositionChanges;
}
if (Status == STATE_PLAYBACK_BEFORE_RECORDING) {
Status = STATE_RECORD;
- pChaseCars[CurrentCar]->m_status = STATUS_PLAYER;
+ pChaseCars[CurrentCar]->SetStatus(STATUS_PLAYER);
}
}
break;
@@ -311,12 +311,12 @@ void CRecordDataForChase::SaveOrRetrieveCarPositions(void)
pChaseCars[i]->GetRight() += (tmp.GetRight() - pChaseCars[i]->GetRight()) * dp;
pChaseCars[i]->GetForward() += (tmp.GetForward() - pChaseCars[i]->GetForward()) * dp;
pChaseCars[i]->GetUp() += (tmp.GetUp() - pChaseCars[i]->GetUp()) * dp;
- pChaseCars[i]->GetPosition() += (tmp.GetPosition() - pChaseCars[i]->GetPosition()) * dp;
+ pChaseCars[i]->GetMatrix().GetPosition() += (tmp.GetPosition() - pChaseCars[i]->GetPosition()) * dp;
}
else{
RestoreInfoForCar(pChaseCars[i], &pBaseMemForCar[i][CHASE_SCENE_FRAMES_IN_RECORDING - 1], true);
if (i == 0)
- pChaseCars[i]->GetPosition().z += 0.2f;
+ pChaseCars[i]->GetMatrix().GetPosition().z += 0.2f;
}
pChaseCars[i]->GetMatrix().UpdateRW();
pChaseCars[i]->UpdateRwFrame();
@@ -407,8 +407,8 @@ void CRecordDataForChase::GiveUsACar(int32 mi, CVector pos, float angle, CAutomo
if (!CStreaming::HasModelLoaded(mi))
return;
CAutomobile* pCar = new CAutomobile(mi, MISSION_VEHICLE);
- pCar->GetPosition() = pos;
- pCar->m_status = STATUS_PLAYER_PLAYBACKFROMBUFFER;
+ pCar->SetPosition(pos);
+ pCar->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
pCar->GetMatrix().SetRotateZOnly(DEGTORAD(angle));
pCar->pDriver = nil;
pCar->m_currentColour1 = colour1;
@@ -517,7 +517,7 @@ CVehicle* CRecordDataForChase::TurnChaseCarIntoScriptCar(int32 i)
{
CVehicle* pVehicle = pChaseCars[i];
pChaseCars[i] = nil;
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
return pVehicle;
}
diff --git a/src/control/Remote.cpp b/src/control/Remote.cpp
index 9c749bd9..904e9023 100644
--- a/src/control/Remote.cpp
+++ b/src/control/Remote.cpp
@@ -18,8 +18,8 @@ CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uin
z = car->GetDistanceFromCentreOfMassToBaseOfModel() + CWorld::FindGroundZFor3DCoord(x, y, z + 2.0f, &found);
car->GetMatrix().SetRotateZOnly(rot);
- car->GetPosition() = CVector(x, y, z);
- car->m_status = STATUS_PLAYER_REMOTE;
+ car->SetPosition(x, y, z);
+ car->SetStatus(STATUS_PLAYER_REMOTE);
car->bIsLocked = true;
CCarCtrl::JoinCarWithRoadSystem(car);
@@ -31,7 +31,7 @@ CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uin
car->bEngineOn = true;
CWorld::Add(car);
if (FindPlayerVehicle() != nil)
- FindPlayerVehicle()->m_status = STATUS_PLAYER_DISABLED;
+ FindPlayerVehicle()->SetStatus(STATUS_PLAYER_DISABLED);
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = car;
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle);
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index da350660..707f1d87 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -850,7 +850,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
else{
new_v = new(vp->index << 8) CAutomobile(mi, 2);
}
- new_v->m_status = STATUS_PLAYER_PLAYBACKFROMBUFFER;
+ new_v->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
vp->matrix.DecompressIntoFullMatrix(new_v->GetMatrix());
new_v->m_currentColour1 = vp->primary_color;
new_v->m_currentColour2 = vp->secondary_color;
@@ -870,7 +870,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
}
else {
CPed* new_p = new(ph->index << 8) CCivilianPed((ePedType)ph->pedtype, ph->mi);
- new_p->m_status = STATUS_PLAYER_PLAYBACKFROMBUFFER;
+ new_p->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
new_p->GetMatrix().SetUnity();
CWorld::Add(new_p);
}
@@ -900,10 +900,10 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
TheCamera.GetMatrix().GetPosition() *= split;
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)TheCamera.GetPosition();
- pm->at = *(RwV3d*)TheCamera.GetForward();
- pm->up = *(RwV3d*)TheCamera.GetUp();
- pm->right = *(RwV3d*)TheCamera.GetRight();
+ pm->pos = TheCamera.GetPosition();
+ pm->at = TheCamera.GetForward();
+ pm->up = TheCamera.GetUp();
+ pm->right = TheCamera.GetRight();
CameraFocusX = split * CameraFocusX + interpolation * pg->player_pos.x;
CameraFocusY = split * CameraFocusY + interpolation * pg->player_pos.y;
CameraFocusZ = split * CameraFocusZ + interpolation * pg->player_pos.z;
@@ -987,7 +987,7 @@ void CReplay::FinishPlayback(void)
Mode = MODE_RECORD;
if (bDoLoadSceneWhenDone){
CVector v_ls(LoadSceneX, LoadSceneY, LoadSceneZ);
- CGame::currLevel = CTheZones::GetLevelFromPosition(v_ls);
+ CGame::currLevel = CTheZones::GetLevelFromPosition(&v_ls);
CCollision::SortOutCollisionAfterLoad();
CStreaming::LoadScene(v_ls);
}
@@ -1020,7 +1020,7 @@ void CReplay::ProcessReplayCamera(void)
switch (CameraMode) {
case REPLAYCAMMODE_TOPDOWN:
{
- TheCamera.GetPosition() = CVector(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f);
+ TheCamera.SetPosition(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f);
TheCamera.GetForward() = CVector(0.0f, 0.0f, -1.0f);
TheCamera.GetUp() = CVector(0.0f, 1.0f, 0.0f);
TheCamera.GetRight() = CVector(1.0f, 0.0f, 0.0f);
@@ -1101,7 +1101,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
LoadSceneZ = TheCamera.GetPosition().z;
CVector ff_coord;
FindFirstFocusCoordinate(&ff_coord);
- CGame::currLevel = CTheZones::GetLevelFromPosition(ff_coord);
+ CGame::currLevel = CTheZones::GetLevelFromPosition(&ff_coord);
CCollision::SortOutCollisionAfterLoad();
CStreaming::LoadScene(ff_coord);
}
@@ -1539,7 +1539,7 @@ void CReplay::ProcessLookAroundCam(void)
TheCamera.GetForward() = forward;
TheCamera.GetUp() = up;
TheCamera.GetRight() = right;
- TheCamera.GetPosition() = camera_pt;
+ TheCamera.SetPosition(camera_pt);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)&TheCamera.GetPosition();
pm->at = *(RwV3d*)&TheCamera.GetForward();
diff --git a/src/control/Replay.h b/src/control/Replay.h
index bf70a28a..66bee3bf 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -108,7 +108,8 @@ class CReplay
CMatrix camera_pos;
CVector player_pos;
};
- static_assert(sizeof(tGeneralPacket) == 88, "tGeneralPacket: error");
+
+ VALIDATE_SIZE(tGeneralPacket, 88);
struct tClockPacket
{
@@ -118,7 +119,7 @@ class CReplay
private:
uint8 __align;
};
- static_assert(sizeof(tClockPacket) == 4, "tClockPacket: error");
+ VALIDATE_SIZE(tClockPacket, 4);
struct tWeatherPacket
{
@@ -127,14 +128,14 @@ class CReplay
uint8 new_weather;
float interpolation;
};
- static_assert(sizeof(tWeatherPacket) == 8, "tWeatherPacket: error");
+ VALIDATE_SIZE(tWeatherPacket, 8);
struct tTimerPacket
{
uint8 type;
uint32 timer;
};
- static_assert(sizeof(tTimerPacket) == 8, "tTimerPacket: error");
+ VALIDATE_SIZE(tTimerPacket, 8);
struct tPedHeaderPacket
{
@@ -145,7 +146,7 @@ class CReplay
private:
uint8 __align[3];
};
- static_assert(sizeof(tPedHeaderPacket) == 8, "tPedHeaderPacket: error");
+ VALIDATE_SIZE(tPedHeaderPacket, 8);
struct tBulletTracePacket
{
@@ -156,7 +157,7 @@ class CReplay
CVector inf;
CVector sup;
};
- static_assert(sizeof(tBulletTracePacket) == 28, "tBulletTracePacket: error");
+ VALIDATE_SIZE(tBulletTracePacket, 28);
struct tEndOfFramePacket
{
@@ -164,7 +165,7 @@ class CReplay
private:
uint8 __align[3];
};
- static_assert(sizeof(tEndOfFramePacket) == 4, "tEndOfFramePacket: error");
+ VALIDATE_SIZE(tEndOfFramePacket, 4);
struct tPedUpdatePacket
{
@@ -177,7 +178,7 @@ class CReplay
int8 assoc_group_id;
uint8 weapon_model;
};
- static_assert(sizeof(tPedUpdatePacket) == 40, "tPedUpdatePacket: error");
+ VALIDATE_SIZE(tPedUpdatePacket, 40);
struct tVehicleUpdatePacket
{
@@ -202,7 +203,7 @@ class CReplay
uint8 primary_color;
uint8 secondary_color;
};
- static_assert(sizeof(tVehicleUpdatePacket) == 48, "tVehicleUpdatePacket: error");
+ VALIDATE_SIZE(tVehicleUpdatePacket, 48);
private:
static uint8 Mode;
diff --git a/src/control/Restart.cpp b/src/control/Restart.cpp
index 2a31f8f1..5a322cdb 100644
--- a/src/control/Restart.cpp
+++ b/src/control/Restart.cpp
@@ -108,7 +108,7 @@ CRestart::FindClosestHospitalRestartPoint(const CVector &pos, CVector *outPos, f
// if we still didn't find anything, find closest path node
if (closestPoint == NUM_RESTART_POINTS) {
- *outPos = ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, PATH_PED, 999999.9f)].pos;
+ *outPos = ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, PATH_PED, 999999.9f)].GetPosition();
*outHeading = 0.0f;
printf("Couldn't find a hospital restart zone near the player %f %f %f->%f %f %f\n", pos.x, pos.y, pos.z, outPos->x, outPos->y, outPos->z);
} else {
@@ -156,7 +156,7 @@ CRestart::FindClosestPoliceRestartPoint(const CVector &pos, CVector *outPos, flo
// if we still didn't find anything, find closest path node
if (closestPoint == NUM_RESTART_POINTS) {
printf("Couldn't find a police restart zone near the player\n");
- *outPos = ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, PATH_PED, 999999.9f)].pos;
+ *outPos = ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, PATH_PED, 999999.9f)].GetPosition();
*outHeading = 0.0f;
} else {
*outPos = PoliceRestartPoints[closestPoint];
diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp
index 7fb0c211..572f8134 100644
--- a/src/control/RoadBlocks.cpp
+++ b/src/control/RoadBlocks.cpp
@@ -15,6 +15,8 @@
#include "CarCtrl.h"
#include "General.h"
+#define ROADBLOCKDIST (80.0f)
+
int16 CRoadBlocks::NumRoadBlocks;
int16 CRoadBlocks::RoadBlockObjects[NUMROADBLOCKS];
bool CRoadBlocks::InOrOut[NUMROADBLOCKS];
@@ -22,12 +24,13 @@ bool CRoadBlocks::InOrOut[NUMROADBLOCKS];
void
CRoadBlocks::Init(void)
{
+ int i;
NumRoadBlocks = 0;
- for (int objId = 0; objId < ThePaths.m_numMapObjects; objId++) {
- if (ThePaths.m_objectFlags[objId] & UseInRoadBlock) {
+ for (i = 0; i < ThePaths.m_numMapObjects; i++) {
+ if (ThePaths.m_objectFlags[i] & UseInRoadBlock) {
if (NumRoadBlocks < NUMROADBLOCKS) {
InOrOut[NumRoadBlocks] = true;
- RoadBlockObjects[NumRoadBlocks] = objId;
+ RoadBlockObjects[NumRoadBlocks] = i;
NumRoadBlocks++;
} else {
#ifndef MASTER
@@ -38,7 +41,6 @@ CRoadBlocks::Init(void)
}
}
}
-
}
void
@@ -77,15 +79,15 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
if (copType == COP_STREET)
pCopPed->SetCurrentWeapon(WEAPONTYPE_COLT45);
CPedPlacement::FindZCoorForPed(&posForZ);
- pCopPed->m_matrix.GetPosition() = posForZ;
- CVector vecSavedPos = pCopPed->m_matrix.GetPosition();
+ pCopPed->SetPosition(posForZ);
+ CVector vecSavedPos = pCopPed->GetPosition();
pCopPed->m_matrix.SetRotate(0.0f, 0.0f, -HALFPI);
pCopPed->m_matrix.GetPosition() += vecSavedPos;
pCopPed->m_bIsDisabledCop = true;
pCopPed->SetIdle();
pCopPed->bKindaStayInSamePlace = true;
pCopPed->bNotAllowedToDuck = false;
- pCopPed->m_wRoadblockNode = roadBlockNode;
+ pCopPed->m_nRoadblockNode = roadBlockNode;
pCopPed->bCrouchWhenShooting = roadBlockType != 2;
if (pEntityToAttack) {
pCopPed->m_pPointGunAt = pEntityToAttack;
@@ -107,17 +109,14 @@ CRoadBlocks::GenerateRoadBlocks(void)
uint32 frame = CTimer::GetFrameCounter() & 0xF;
int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16;
const int16 maxRoadBlocks = (int16)(NUMROADBLOCKS * (frame + 1)) / 16;
- int16 numRoadBlocks = CRoadBlocks::NumRoadBlocks;
- if (CRoadBlocks::NumRoadBlocks >= maxRoadBlocks)
- numRoadBlocks = maxRoadBlocks;
- for (; nRoadblockNode < numRoadBlocks; nRoadblockNode++) {
- CTreadable *mapObject = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[nRoadblockNode]];
+ for (; nRoadblockNode < Min(NumRoadBlocks, maxRoadBlocks); nRoadblockNode++) {
+ CTreadable *mapObject = ThePaths.m_mapObjects[RoadBlockObjects[nRoadblockNode]];
CVector2D vecDistance = FindPlayerCoors() - mapObject->GetPosition();
- if (vecDistance.x > -80.0f && vecDistance.x < 80.0f &&
- vecDistance.y > -80.0f && vecDistance.y < 80.0f &&
- vecDistance.Magnitude() < 80.0f) {
- if (!CRoadBlocks::InOrOut[nRoadblockNode]) {
- CRoadBlocks::InOrOut[nRoadblockNode] = true;
+ if (vecDistance.x > -ROADBLOCKDIST && vecDistance.x < ROADBLOCKDIST &&
+ vecDistance.y > -ROADBLOCKDIST && vecDistance.y < ROADBLOCKDIST &&
+ vecDistance.Magnitude() < ROADBLOCKDIST) {
+ if (!InOrOut[nRoadblockNode]) {
+ InOrOut[nRoadblockNode] = true;
if (FindPlayerVehicle() && (CGeneral::GetRandomNumber() & 0x7F) < FindPlayerPed()->m_pWanted->m_RoadblockDensity) {
CWanted *pPlayerWanted = FindPlayerPed()->m_pWanted;
float fMapObjectRadius = 2.0f * mapObject->GetColModel()->boundingBox.max.x;
@@ -134,8 +133,8 @@ CRoadBlocks::GenerateRoadBlocks(void)
float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f;
int16 radius = (int16)(fMapObjectRadius / fModelRadius);
if (radius > 0 && radius < 6) {
- CVector2D vecDistanceToCamera = TheCamera.GetPosition() - mapObject->m_matrix.GetPosition();
- float fDotProduct = DotProduct2D(vecDistanceToCamera, mapObject->m_matrix.GetUp());
+ CVector2D vecDistanceToCamera = TheCamera.GetPosition() - mapObject->GetPosition();
+ float fDotProduct = DotProduct2D(vecDistanceToCamera, mapObject->GetForward());
float fOffset = 0.5f * fModelRadius * (float)(radius - 1);
for (int16 i = 0; i < radius; i++) {
uint8 nRoadblockType = fDotProduct < 0.0f;
@@ -146,7 +145,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
nRoadblockType = !nRoadblockType;
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI);
}
- if (ThePaths.m_objectFlags[CRoadBlocks::RoadBlockObjects[nRoadblockNode]] & ObjectEastWest)
+ if (ThePaths.m_objectFlags[RoadBlockObjects[nRoadblockNode]] & ObjectEastWest)
offsetMatrix.GetPosition() = CVector(0.0f, -fOffset, 0.6f);
else
offsetMatrix.GetPosition() = CVector(-fOffset, 0.0f, 0.6f);
@@ -156,7 +155,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false);
if (!colliding) {
CAutomobile *pVehicle = new CAutomobile(vehicleId, RANDOM_VEHICLE);
- pVehicle->m_status = STATUS_ABANDONED;
+ pVehicle->SetStatus(STATUS_ABANDONED);
// pVehicle->GetHeightAboveRoad(); // called but return value is ignored?
vehicleMatrix.GetPosition().z += fModelRadius - 0.6f;
pVehicle->m_matrix = vehicleMatrix;
@@ -175,7 +174,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
pVehicle->bExtendedRange = true;
if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1)
pVehicle->m_bSirenOrAlarm = true;
- if (pVehicle->m_matrix.GetForward().z > 0.94f) {
+ if (pVehicle->GetForward().z > 0.94f) {
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
CWorld::Add(pVehicle);
pVehicle->bCreateRoadBlockPeds = true;
@@ -191,7 +190,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
}
}
} else {
- CRoadBlocks::InOrOut[nRoadblockNode] = false;
+ InOrOut[nRoadblockNode] = false;
}
}
}
diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp
index 7f914a76..6aa64a3c 100644
--- a/src/control/SceneEdit.cpp
+++ b/src/control/SceneEdit.cpp
@@ -68,7 +68,9 @@ static const char* pCommandStrings[] = {
"Save Movie", "Load Movie", "Play Movie", "END"
};
+#ifdef CHECK_STRUCT_SIZES
static_assert(ARRAY_SIZE(pCommandStrings) == CSceneEdit::MOVIE_TOTAL_COMMANDS, "Scene edit: not all commands have names");
+#endif
static int32 NextValidModelId(int32 mi, int32 step)
{
@@ -76,7 +78,7 @@ static int32 NextValidModelId(int32 mi, int32 step)
int32 i = mi;
while (result == -1) {
i += step;
- if (i < 0 || i > 5500) {
+ if (i < 0 || i > MODELINFOSIZE) {
step = -step;
continue;
}
@@ -84,12 +86,11 @@ static int32 NextValidModelId(int32 mi, int32 step)
CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo;
if (!pInfo)
continue;
- if (pInfo->m_type == MITYPE_PED
+ if (pInfo->GetModelType() == MITYPE_PED
#ifdef FIX_BUGS
&& !(i >= MI_SPECIAL01 && i <= MI_SPECIAL04)
#endif
- ||
- pInfo->m_type == MITYPE_VEHICLE &&
+ || pInfo->GetModelType() == MITYPE_VEHICLE &&
#ifdef FIX_BUGS
(pVehicleInfo->m_vehicleType == VEHICLE_TYPE_CAR || pVehicleInfo->m_vehicleType == VEHICLE_TYPE_BOAT))
#else // && and || priority failure it seems, also crashes on special models
@@ -349,7 +350,7 @@ void CSceneEdit::ProcessCommand(void)
}
CPed* pPed = new CCivilianPed(PEDTYPE_SPECIAL, m_nPedmodelId);
pPed->CharCreatedBy = MISSION_CHAR;
- pPed->GetPosition() = m_vecCurrentPosition;
+ pPed->SetPosition(m_vecCurrentPosition);
pPed->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(pPed);
pPed->bUsesCollision = false;
@@ -363,7 +364,7 @@ void CSceneEdit::ProcessCommand(void)
}
}
else {
- pActors[m_nActor]->GetPosition() = m_vecCurrentPosition;
+ pActors[m_nActor]->SetPosition(m_vecCurrentPosition);
pActors[m_nActor]->SetOrientation(0.0f, 0.0f, 0.0f);
int32 mi = m_nPedmodelId;
if (CPad::GetPad(1)->GetLeftShoulder1JustDown())
@@ -405,7 +406,7 @@ void CSceneEdit::ProcessCommand(void)
SelectActor();
if (m_bCommandActive)
break;
- pActors[m_nActor]->GetPosition() = m_vecCurrentPosition;
+ pActors[m_nActor]->SetPosition(m_vecCurrentPosition);
if (CPad::GetPad(1)->GetTriangleJustDown()) {
m_bCommandActive = false;
#ifndef FIX_BUGS // why? it crashes, also makes no sense
@@ -450,8 +451,8 @@ void CSceneEdit::ProcessCommand(void)
break;
}
CVehicle* pVehicle = new CAutomobile(m_nVehiclemodelId, MISSION_VEHICLE);
- pVehicle->m_status = STATUS_PHYSICS;
- pVehicle->GetPosition() = m_vecCurrentPosition;
+ pVehicle->SetStatus(STATUS_PHYSICS);
+ pVehicle->SetPosition(m_vecCurrentPosition);
pVehicle->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(pVehicle);
pVehicle->bUsesCollision = false;
@@ -465,7 +466,7 @@ void CSceneEdit::ProcessCommand(void)
}
}
else {
- pVehicles[m_nVehicle]->GetPosition() = m_vecCurrentPosition;
+ pVehicles[m_nVehicle]->SetPosition(m_vecCurrentPosition);
pVehicles[m_nVehicle]->SetOrientation(0.0f, 0.0f, 0.0f);
int32 mi = m_nVehiclemodelId;
if (CPad::GetPad(1)->GetLeftShoulder1JustDown())
@@ -507,7 +508,7 @@ void CSceneEdit::ProcessCommand(void)
SelectVehicle();
if (m_bCommandActive)
break;
- pVehicles[m_nVehicle]->GetPosition() = m_vecCurrentPosition;
+ pVehicles[m_nVehicle]->SetPosition(m_vecCurrentPosition);
if (CPad::GetPad(1)->GetTriangleJustDown()) {
m_bCommandActive = false;
#ifndef FIX_BUGS // again, why? works wrong
@@ -567,7 +568,7 @@ void CSceneEdit::ProcessCommand(void)
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
else
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
- pActors[m_nActor]->m_pMyVehicle->m_status = STATUS_PHYSICS;
+ pActors[m_nActor]->m_pMyVehicle->SetStatus(STATUS_PHYSICS);
pActors[m_nActor]->m_pMyVehicle->bEngineOn = true;
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = Max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
@@ -785,7 +786,7 @@ void CSceneEdit::PlayBack(void)
CPed* pPed = new CCivilianPed(PEDTYPE_SPECIAL, m_nPedmodelId);
pPed->CharCreatedBy = MISSION_CHAR;
CWorld::Add(pPed);
- pPed->GetPosition() = m_vecCurrentPosition;
+ pPed->SetPosition(m_vecCurrentPosition);
pPed->SetOrientation(0.0f, 0.0f, 0.0f);
for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
if (pActors[i] == nil) {
@@ -810,8 +811,8 @@ void CSceneEdit::PlayBack(void)
break;
}
CVehicle* pVehicle = new CAutomobile(m_nVehiclemodelId, MISSION_VEHICLE);
- pVehicle->m_status = STATUS_PHYSICS;
- pVehicle->GetPosition() = m_vecCurrentPosition;
+ pVehicle->SetStatus(STATUS_PHYSICS);
+ pVehicle->SetPosition(m_vecCurrentPosition);
pVehicle->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(pVehicle);
for (int i = 0; i < NUM_VEHICLES_IN_MOVIE; i++) {
@@ -845,7 +846,7 @@ void CSceneEdit::PlayBack(void)
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
else
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
- pActors[m_nActor]->m_pMyVehicle->m_status = STATUS_PHYSICS;
+ pActors[m_nActor]->m_pMyVehicle->SetStatus(STATUS_PHYSICS);
pActors[m_nActor]->m_pMyVehicle->bEngineOn = true;
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = Max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 1f65ce6e..df3a489a 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -128,6 +128,14 @@ uint16 CTheScripts::CommandsExecuted;
uint16 CTheScripts::ScriptsUpdated;
int32 ScriptParams[32];
+
+const uint32 CRunningScript::nSaveStructSize =
+#ifdef COMPATIBLE_SAVES
+ 136;
+#else
+ sizeof(CRunningScript);
+#endif
+
CMissionCleanup::CMissionCleanup()
{
Init();
@@ -1293,7 +1301,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += CWorld::Players[index].m_pPed->GetDistanceFromCentreOfMassToBaseOfModel();
- CWorld::Players[index].m_pPed->GetPosition() = pos;
+ CWorld::Players[index].m_pPed->SetPosition(pos);
CTheScripts::ClearSpaceForMissionEntity(pos, CWorld::Players[index].m_pPed);
CPlayerPed::ReactivatePlayerPed(index);
ScriptParams[0] = index;
@@ -1717,11 +1725,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += 1.0f;
- ped->GetPosition() = pos;
+ ped->SetPosition(pos);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
CWorld::Add(ped);
- ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
+ ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
CPopulation::ms_nTotalMissionPeds++;
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
StoreParameters(&m_nIp, 1);
@@ -1737,7 +1745,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
if (ped->InVehicle()) {
if (ped->m_pMyVehicle->pDriver == ped) {
ped->m_pMyVehicle->RemoveDriver();
- ped->m_pMyVehicle->m_status = STATUS_ABANDONED;
+ ped->m_pMyVehicle->SetStatus(STATUS_ABANDONED);
if (ped->m_pMyVehicle->m_nDoorLock == CARLOCK_LOCKED_INITIALLY)
ped->m_pMyVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
if (ped->m_nPedType == PEDTYPE_COP && ped->m_pMyVehicle->IsLawEnforcementVehicle())
@@ -1931,9 +1939,9 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += boat->GetDistanceFromCentreOfMassToBaseOfModel();
- boat->GetPosition() = pos;
+ boat->SetPosition(pos);
CTheScripts::ClearSpaceForMissionEntity(pos, boat);
- boat->m_status = STATUS_ABANDONED;
+ boat->SetStatus(STATUS_ABANDONED);
boat->bIsLocked = true;
boat->AutoPilot.m_nCarMission = MISSION_NONE;
boat->AutoPilot.m_nTempAction = TEMPACT_NONE; /* Animation ID? */
@@ -1949,9 +1957,9 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
- car->GetPosition() = pos;
+ car->SetPosition(pos);
CTheScripts::ClearSpaceForMissionEntity(pos, car);
- car->m_status = STATUS_ABANDONED;
+ car->SetStatus(STATUS_ABANDONED);
car->bIsLocked = true;
CCarCtrl::JoinCarWithRoadSystem(car);
car->AutoPilot.m_nCarMission = MISSION_NONE;
@@ -1960,7 +1968,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0;
car->bEngineOn = false;
- car->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
+ car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
car->bHasBeenOwnedByPlayer = true;
CWorld::Add(car);
handle = CPools::GetVehiclePool()->GetIndex(car);
@@ -1997,7 +2005,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
else
car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
- car->m_status = STATUS_PHYSICS;
+ car->SetStatus(STATUS_PHYSICS);
car->bEngineOn = true;
car->AutoPilot.m_nCruiseSpeed = Max(car->AutoPilot.m_nCruiseSpeed, 6);
car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
@@ -2087,7 +2095,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
{
CollectParameters(&m_nIp, 1);
CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
- UpdateCompareFlag(car && car->m_status != STATUS_WRECKED && (car->IsBoat() || !car->bIsInWater));
+ UpdateCompareFlag(car && car->GetStatus() != STATUS_WRECKED && (car->IsBoat() || !car->bIsInWater));
return 0;
}
case COMMAND_SET_CAR_CRUISE_SPEED:
@@ -2523,7 +2531,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += pObj->GetDistanceFromCentreOfMassToBaseOfModel();
- pObj->GetPosition() = pos;
+ pObj->SetPosition(pos);
pObj->SetOrientation(0.0f, 0.0f, 0.0f);
pObj->GetMatrix().UpdateRW();
pObj->UpdateRwFrame();
@@ -2626,7 +2634,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
{
CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
- UpdateCompareFlag(!pVehicle || pVehicle->m_status == STATUS_WRECKED || !pVehicle->IsBoat() && pVehicle->bIsInWater);
+ UpdateCompareFlag(!pVehicle || pVehicle->GetStatus() == STATUS_WRECKED || !pVehicle->IsBoat() && pVehicle->bIsInWater);
return 0;
}
case COMMAND_SET_CHAR_THREAT_SEARCH:
@@ -2666,7 +2674,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
m_nIp += KEY_LENGTH_IN_SCRIPT; /* why only if zone != 1? */
CVector pos = pPlayer->GetPos();
CZone* pZone = CTheZones::GetZone(zoneToCheck);
- UpdateCompareFlag(CTheZones::PointLiesWithinZone(pos, pZone));
+ UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, pZone));
return 0;
}
case COMMAND_IS_PLAYER_PRESSING_HORN:
@@ -2743,7 +2751,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pPed->CharCreatedBy = MISSION_CHAR;
pPed->bRespondsToThreats = false;
pPed->bAllowMedicsToReviveMe = false;
- pPed->GetPosition() = pVehicle->GetPosition();
+ pPed->SetPosition(pVehicle->GetPosition());
pPed->SetOrientation(0.0f, 0.0f, 0.0f);
pPed->SetPedState(PED_DRIVING);
CPopulation::ms_nTotalMissionPeds++;
@@ -2753,7 +2761,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pPed->m_pMyVehicle = pVehicle;
pPed->m_pMyVehicle->RegisterReference((CEntity**)&pPed->m_pMyVehicle);
pPed->bInVehicle = true;
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
if (!pVehicle->IsBoat())
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
pVehicle->bEngineOn = true;
@@ -2765,7 +2773,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
#endif
pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f);
pPed->StopNonPartialAnims();
- pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
+ pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
CWorld::Add(pPed);
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
StoreParameters(&m_nIp, 1);
@@ -2786,7 +2794,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pPlayer->m_pPed->bRenderPedInCar = true;
if (pPlayer->m_pPed->m_pMyVehicle->pDriver == pPlayer->m_pPed){
pPlayer->m_pPed->m_pMyVehicle->RemoveDriver();
- pPlayer->m_pPed->m_pMyVehicle->m_status = STATUS_ABANDONED;
+ pPlayer->m_pPed->m_pMyVehicle->SetStatus(STATUS_ABANDONED);
pPlayer->m_pPed->m_pMyVehicle->bEngineOn = false;
pPlayer->m_pPed->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 0;
}else{
@@ -2878,7 +2886,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
float y1 = *(float*)&ScriptParams[2];
float x2 = *(float*)&ScriptParams[3];
float y2 = *(float*)&ScriptParams[4];
- UpdateCompareFlag(pVehicle->m_status == STATUS_WRECKED &&
+ UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED &&
pVehicle->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5])
return 0;
@@ -2898,7 +2906,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
float x2 = *(float*)&ScriptParams[4];
float y2 = *(float*)&ScriptParams[5];
float z2 = *(float*)&ScriptParams[6];
- UpdateCompareFlag(pVehicle->m_status == STATUS_WRECKED &&
+ UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED &&
pVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
if (!ScriptParams[7])
return 0;
@@ -3018,7 +3026,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
if (zone != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT;
CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
- UpdateCompareFlag(CTheZones::PointLiesWithinZone(pos, CTheZones::GetZone(zone)));
+ UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, CTheZones::GetZone(zone)));
return 0;
}
case COMMAND_SET_CAR_DENSITY:
@@ -3935,7 +3943,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
pPed->CharCreatedBy = MISSION_CHAR;
pPed->bRespondsToThreats = false;
pPed->bAllowMedicsToReviveMe = false;
- pPed->GetPosition() = pVehicle->GetPosition();
+ pPed->SetPosition(pVehicle->GetPosition());
pPed->SetOrientation(0.0f, 0.0f, 0.0f);
pPed->SetPedState(PED_DRIVING);
CPopulation::ms_nTotalMissionPeds++;
@@ -3947,7 +3955,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
pPed->m_pMyVehicle->RegisterReference((CEntity**)&pPed->m_pMyVehicle);
pPed->bInVehicle = true;
pPed->SetPedState(PED_DRIVING);
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
pPed->bUsesCollision = false;
#ifdef FIX_BUGS
AnimationId anim = pVehicle->GetDriverAnim();
@@ -3956,7 +3964,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
#endif
pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f);
pPed->StopNonPartialAnims();
- pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
+ pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
CWorld::Add(pPed);
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
StoreParameters(&m_nIp, 1);
@@ -5153,7 +5161,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CRestart::OverrideNextRestart(pos, *(float*)&ScriptParams[3]);
- if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING) //TODO: enum
+ if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING)
printf("RESTART_CRITICAL_MISSION - Player state is not PLAYING\n");
CWorld::Players[CWorld::PlayerInFocus].PlayerFailedCriticalMission();
return 0;
@@ -5250,7 +5258,11 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
return 0;
}
case COMMAND_GET_CONTROLLER_MODE:
+#if defined(GTA_PC) && !defined(DETECT_PAD_INPUT_SWITCH)
ScriptParams[0] = 0;
+#else
+ ScriptParams[0] = CPad::IsAffectedByController ? CPad::GetPad(0)->Mode : 0;
+#endif
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_SET_CAN_RESPRAY_CAR:
@@ -5307,7 +5319,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
CVector pos = *(CVector*)&ScriptParams[1];
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
- pObj->GetPosition() = pos;
+ pObj->SetPosition(pos);
pObj->SetOrientation(0.0f, 0.0f, 0.0f);
pObj->GetMatrix().UpdateRW();
pObj->UpdateRwFrame();
@@ -5555,7 +5567,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CPathNode* pNode = &ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, 1, 999999.9f)];
- *(CVector*)&ScriptParams[0] = pNode->pos;
+ *(CVector*)&ScriptParams[0] = pNode->GetPosition();
StoreParameters(&m_nIp, 3);
return 0;
}
@@ -5566,7 +5578,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CPathNode* pNode = &ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f)];
- *(CVector*)&ScriptParams[0] = pNode->pos;
+ *(CVector*)&ScriptParams[0] = pNode->GetPosition();
StoreParameters(&m_nIp, 3);
return 0;
}
@@ -5583,7 +5595,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTO_COORDS_STRAIGHT_ACCURATE;
else
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_ACCURATE;
- pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->SetStatus(STATUS_PHYSICS);
pVehicle->bEngineOn = true;
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
@@ -5699,7 +5711,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &pos.z, false);
pBoat->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_ASTHECROWSWIMS;
pBoat->AutoPilot.m_vecDestinationCoors = pos;
- pBoat->m_status = STATUS_PHYSICS;
+ pBoat->SetStatus(STATUS_PHYSICS);
pBoat->AutoPilot.m_nCruiseSpeed = Max(6, pBoat->AutoPilot.m_nCruiseSpeed);
pBoat->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
return 0;
@@ -5712,7 +5724,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT);
CBoat* pBoat = (CBoat*)pVehicle;
pBoat->AutoPilot.m_nCarMission = MISSION_NONE;
- pBoat->m_status = STATUS_PHYSICS;
+ pBoat->SetStatus(STATUS_PHYSICS);
pBoat->bEngineOn = false;
pBoat->AutoPilot.m_nCruiseSpeed = 0;
return 0;
@@ -5868,7 +5880,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
continue;
if (pPed->bIsLeader || pPed->m_leader)
continue;
- if (!CTheZones::PointLiesWithinZone(pPed->GetPosition(), pZone))
+ if (!CTheZones::PointLiesWithinZone(&pPed->GetPosition(), pZone))
continue;
if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
continue;
@@ -6524,7 +6536,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
continue;
if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE)
continue;
- if (!CTheZones::PointLiesWithinZone(pVehicle->GetPosition(), pZone))
+ if (!CTheZones::PointLiesWithinZone(&pVehicle->GetPosition(), pZone))
continue;
handle = CPools::GetVehiclePool()->GetIndex(pVehicle);
pVehicle->VehicleCreatedBy = MISSION_VEHICLE;
@@ -6911,7 +6923,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
if (pPed->m_pMyVehicle){
if (pPed == pPed->m_pMyVehicle->pDriver){
pPed->m_pMyVehicle->RemoveDriver();
- pPed->m_pMyVehicle->m_status = STATUS_ABANDONED;
+ pPed->m_pMyVehicle->SetStatus(STATUS_ABANDONED);
if (pPed->m_pMyVehicle->m_nDoorLock == CARLOCK_LOCKED_INITIALLY)
pPed->m_pMyVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
if (pPed->m_nPedType == PEDTYPE_COP && pPed->m_pMyVehicle->IsLawEnforcementVehicle())
@@ -7108,7 +7120,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
pPed->bRenderPedInCar = true;
if (pPed->m_pMyVehicle->pDriver == pPed){
pPed->m_pMyVehicle->RemoveDriver();
- pPed->m_pMyVehicle->m_status = STATUS_ABANDONED;
+ pPed->m_pMyVehicle->SetStatus(STATUS_ABANDONED);
pPed->m_pMyVehicle->bEngineOn = false;
pPed->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 0;
}else{
@@ -7331,11 +7343,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += 1.0f;
- ped->GetPosition() = pos;
+ ped->SetPosition(pos);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
CWorld::Add(ped);
- ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
+ ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
CPopulation::ms_nTotalMissionPeds++;
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
StoreParameters(&m_nIp, 1);
@@ -7779,7 +7791,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
- pVehicle->m_status = ScriptParams[1];
+ pVehicle->SetStatus((eEntityStatus)ScriptParams[1]);
return 0;
}
case COMMAND_IS_CHAR_MALE:
@@ -8062,7 +8074,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
continue;
// desperatly want to believe this was inlined :|
CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model);
- assert(pInfo->m_type == MITYPE_VEHICLE);
+ assert(pInfo->GetModelType() == MITYPE_VEHICLE);
CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo;
if (pVehicleInfo->m_vehicleType != VEHICLE_TYPE_CAR) {
switch (model) {
@@ -8153,10 +8165,10 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
car = new CAutomobile(model, MISSION_VEHICLE);
CVector pos = *(CVector*)&ScriptParams[0];
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
- car->GetPosition() = pos;
+ car->SetPosition(pos);
car->SetHeading(DEGTORAD(*(float*)&ScriptParams[3]));
CTheScripts::ClearSpaceForMissionEntity(pos, car);
- car->m_status = STATUS_ABANDONED;
+ car->SetStatus(STATUS_ABANDONED);
car->bIsLocked = true;
car->bIsCarParkVehicle = true;
CCarCtrl::JoinCarWithRoadSystem(car);
@@ -8166,7 +8178,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0;
car->bEngineOn = false;
- car->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
+ car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
CWorld::Add(car);
return 0;
}
@@ -8243,7 +8255,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
int node = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true);
- *(CVector*)&ScriptParams[0] = ThePaths.m_pathNodes[node].pos;
+ *(CVector*)&ScriptParams[0] = ThePaths.m_pathNodes[node].GetPosition();
*(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacement(node);
StoreParameters(&m_nIp, 4);
return 0;
@@ -8492,7 +8504,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
if (ScriptParams[1])
- pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(pVehicle->GetPosition());
+ pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition());
else
pVehicle->m_nZoneLevel = LEVEL_NONE;
return 0;
@@ -8503,7 +8515,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
if (ScriptParams[1])
- pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
+ pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
else
pPed->m_nZoneLevel = LEVEL_NONE;
return 0;
@@ -8908,7 +8920,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
if (ScriptParams[1])
pPed->m_nZoneLevel = LEVEL_IGNORE;
else
- pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
+ pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
return 0;
}
case COMMAND_GET_CHASE_CAR:
@@ -9107,7 +9119,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
if (ScriptParams[1])
pVehicle->m_nZoneLevel = LEVEL_IGNORE;
else
- pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(pVehicle->GetPosition());
+ pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition());
return 0;
}
case COMMAND_MAKE_CRAIGS_CAR_A_BIT_STRONGER:
@@ -9325,7 +9337,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
float destY = *(float*)&ScriptParams[4];
int32 nid = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true);
CPathNode* pNode = &ThePaths.m_pathNodes[nid];
- *(CVector*)&ScriptParams[0] = pNode->pos;
+ *(CVector*)&ScriptParams[0] = pNode->GetPosition();
*(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, true);
StoreParameters(&m_nIp, 4);
return 0;
@@ -9340,7 +9352,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
float destY = *(float*)&ScriptParams[4];
int32 nid = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true);
CPathNode* pNode = &ThePaths.m_pathNodes[nid];
- *(CVector*)&ScriptParams[0] = pNode->pos;
+ *(CVector*)&ScriptParams[0] = pNode->GetPosition();
*(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, false);
StoreParameters(&m_nIp, 4);
return 0;
@@ -9453,7 +9465,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
continue;
if (pPed->bIsLeader || pPed->m_leader)
continue;
- if (!CTheZones::PointLiesWithinZone(pPed->GetPosition(), pZone))
+ if (!CTheZones::PointLiesWithinZone(&pPed->GetPosition(), pZone))
continue;
if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
continue;
@@ -11188,12 +11200,14 @@ INITSAVEBUF
uint32 runningScripts = 0;
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
runningScripts++;
- *size = sizeof(CRunningScript) * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 3 * sizeof(uint32);
+ *size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 3 * sizeof(uint32);
WriteSaveHeader(buf, 'S', 'C', 'R', '\0', *size - SAVE_HEADER_SIZE);
WriteSaveBuf(buf, varSpace);
for (uint32 i = 0; i < varSpace; i++)
WriteSaveBuf(buf, ScriptSpace[i]);
+#ifdef CHECK_STRUCT_SIZES
static_assert(SCRIPT_DATA_SIZE == 968, "CTheScripts::SaveAllScripts");
+#endif
uint32 script_data_size = SCRIPT_DATA_SIZE;
WriteSaveBuf(buf, script_data_size);
WriteSaveBuf(buf, OnAMissionFlag);
@@ -11229,7 +11243,7 @@ INITSAVEBUF
type = 0;
handle = 0;
} else {
- switch (pEntity->m_type) {
+ switch (pEntity->GetType()) {
case ENTITY_TYPE_BUILDING:
if (((CBuilding*)pEntity)->GetIsATreadable()) {
type = 1;
@@ -11260,7 +11274,7 @@ INITSAVEBUF
WriteSaveBuf(buf, (uint16)0);
WriteSaveBuf(buf, runningScripts);
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
- WriteSaveBuf(buf, *pScript);
+ pScript->Save(buf);
VALIDATESAVEBUF(*size)
}
@@ -11336,7 +11350,7 @@ INITSAVEBUF
ReadSaveBuf<uint16>(buf);
uint32 runningScripts = ReadSaveBuf<uint32>(buf);
for (uint32 i = 0; i < runningScripts; i++)
- StartNewScript(0)->BuildFromSaved(ReadSaveBuf<CRunningScript>(buf));
+ StartNewScript(0)->Load(buf);
VALIDATESAVEBUF(size)
}
@@ -11371,7 +11385,7 @@ void CTheScripts::ClearSpaceForMissionEntity(const CVector& pos, CEntity* pEntit
}
if (cols <= 0)
continue;
- switch (pFound->m_type) {
+ switch (pFound->GetType()) {
case ENTITY_TYPE_VEHICLE:
{
printf("Will try to delete a vehicle where a mission entity should be\n");
@@ -11611,3 +11625,77 @@ void CTheScripts::ReadMultiScriptFileOffsetsFromScript()
MultiScriptArray[i] = Read4BytesFromScript(&ip);
}
}
+
+void CRunningScript::Save(uint8*& buf)
+{
+#ifdef COMPATIBLE_SAVES
+ SkipSaveBuf(buf, 8);
+ for (int i = 0; i < 8; i++)
+ WriteSaveBuf<char>(buf, m_abScriptName[i]);
+ WriteSaveBuf<uint32>(buf, m_nIp);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
+#endif
+ for (int i = 0; i < MAX_STACK_DEPTH; i++)
+ WriteSaveBuf<uint32>(buf, m_anStack[i]);
+ WriteSaveBuf<uint16>(buf, m_nStackPointer);
+ SkipSaveBuf(buf, 2);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
+#endif
+ for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
+ WriteSaveBuf<int32>(buf, m_anLocalVariables[i]);
+ WriteSaveBuf<bool>(buf, m_bCondResult);
+ WriteSaveBuf<bool>(buf, m_bIsMissionScript);
+ WriteSaveBuf<bool>(buf, m_bSkipWakeTime);
+ SkipSaveBuf(buf, 1);
+ WriteSaveBuf<uint32>(buf, m_nWakeTime);
+ WriteSaveBuf<uint16>(buf, m_nAndOrState);
+ WriteSaveBuf<bool>(buf, m_bNotFlag);
+ WriteSaveBuf<bool>(buf, m_bDeatharrestEnabled);
+ WriteSaveBuf<bool>(buf, m_bDeatharrestExecuted);
+ WriteSaveBuf<bool>(buf, m_bMissionFlag);
+ SkipSaveBuf(buf, 2);
+#else
+ WriteSaveBuf(buf, *this);
+#endif
+}
+
+void CRunningScript::Load(uint8*& buf)
+{
+#ifdef COMPATIBLE_SAVES
+ SkipSaveBuf(buf, 8);
+ for (int i = 0; i < 8; i++)
+ m_abScriptName[i] = ReadSaveBuf<char>(buf);
+ m_nIp = ReadSaveBuf<uint32>(buf);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
+#endif
+ for (int i = 0; i < MAX_STACK_DEPTH; i++)
+ m_anStack[i] = ReadSaveBuf<uint32>(buf);
+ m_nStackPointer = ReadSaveBuf<uint16>(buf);
+ SkipSaveBuf(buf, 2);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
+#endif
+ for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
+ m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
+ m_bCondResult = ReadSaveBuf<bool>(buf);
+ m_bIsMissionScript = ReadSaveBuf<bool>(buf);
+ m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
+ SkipSaveBuf(buf, 1);
+ m_nWakeTime = ReadSaveBuf<uint32>(buf);
+ m_nAndOrState = ReadSaveBuf<uint16>(buf);
+ m_bNotFlag = ReadSaveBuf<bool>(buf);
+ m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
+ m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
+ m_bMissionFlag = ReadSaveBuf<bool>(buf);
+ SkipSaveBuf(buf, 2);
+#else
+ CRunningScript* n = next;
+ CRunningScript* p = prev;
+ *this = ReadSaveBuf<CRunningScript>(buf);
+ next = n;
+ prev = p;
+#endif
+}
diff --git a/src/control/Script.h b/src/control/Script.h
index 2eed29fe..acab66cc 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -27,7 +27,7 @@ struct intro_script_rectangle
~intro_script_rectangle() { }
};
-static_assert(sizeof(intro_script_rectangle) == 0x18, "Script.h: error");
+VALIDATE_SIZE(intro_script_rectangle, 0x18);
enum {
SCRIPT_TEXT_MAX_LENGTH = 500
@@ -78,7 +78,7 @@ struct intro_text_line
}
};
-static_assert(sizeof(intro_text_line) == 0x414, "Script.h: error");
+VALIDATE_SIZE(intro_text_line, 0x414);
struct script_sphere_struct
{
@@ -423,14 +423,10 @@ class CRunningScript
public:
void SetIP(uint32 ip) { m_nIp = ip; }
CRunningScript* GetNext() const { return next; }
- void BuildFromSaved(const CRunningScript& pSaved)
- {
- CRunningScript* n = next;
- CRunningScript* p = prev;
- *this = pSaved;
- next = n;
- prev = p;
- }
+
+ void Save(uint8*& buf);
+ void Load(uint8*& buf);
+
void UpdateTimers(float timeStep) {
m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
@@ -442,6 +438,8 @@ public:
void RemoveScriptFromList(CRunningScript**);
void AddScriptToList(CRunningScript**);
+ static const uint32 nSaveStructSize;
+
private:
void CollectParameters(uint32*, int16);
int32 CollectNextParameterWithoutIncreasingPC(uint32);
diff --git a/src/control/TrafficLights.cpp b/src/control/TrafficLights.cpp
index c8d3f79f..b2f0900e 100644
--- a/src/control/TrafficLights.cpp
+++ b/src/control/TrafficLights.cpp
@@ -150,12 +150,12 @@ CTrafficLights::ScanForLightsOnMap(void)
// Check cars
for(i = 0; i < ThePaths.m_numCarPathLinks; i++){
- CVector2D dist = ThePaths.m_carPathLinks[i].pos - light->GetPosition();
+ CVector2D dist = ThePaths.m_carPathLinks[i].GetPosition() - light->GetPosition();
float dotY = Abs(DotProduct2D(dist, light->GetForward())); // forward is direction of car light
float dotX = DotProduct2D(dist, light->GetRight()); // towards base of light
// it has to be on the correct side of the node and also not very far away
if(dotX < 0.0f && dotX > -15.0f && dotY < 3.0f){
- float dz = ThePaths.m_pathNodes[ThePaths.m_carPathLinks[i].pathNodeIndex].pos.z -
+ float dz = ThePaths.m_pathNodes[ThePaths.m_carPathLinks[i].pathNodeIndex].GetZ() -
light->GetPosition().z;
if(dz < 15.0f){
ThePaths.m_carPathLinks[i].trafficLightType = FindTrafficLightType(light);
@@ -182,16 +182,16 @@ CTrafficLights::ScanForLightsOnMap(void)
// Check peds
for(i = ThePaths.m_numCarPathNodes; i < ThePaths.m_numPathNodes; i++){
float dist1, dist2;
- dist1 = Abs(ThePaths.m_pathNodes[i].pos.x - light->GetPosition().x) +
- Abs(ThePaths.m_pathNodes[i].pos.y - light->GetPosition().y);
+ dist1 = Abs(ThePaths.m_pathNodes[i].GetX() - light->GetPosition().x) +
+ Abs(ThePaths.m_pathNodes[i].GetY() - light->GetPosition().y);
if(dist1 < 50.0f){
for(l = 0; l < ThePaths.m_pathNodes[i].numLinks; l++){
j = ThePaths.m_pathNodes[i].firstLink + l;
- if(ThePaths.m_connectionFlags[j].bCrossesRoad){
- dist2 = Abs(ThePaths.m_pathNodes[j].pos.x - light->GetPosition().x) +
- Abs(ThePaths.m_pathNodes[j].pos.y - light->GetPosition().y);
+ if(ThePaths.ConnectionCrossesRoad(j)){
+ dist2 = Abs(ThePaths.m_pathNodes[j].GetX() - light->GetPosition().x) +
+ Abs(ThePaths.m_pathNodes[j].GetY() - light->GetPosition().y);
if(dist1 < 15.0f || dist2 < 15.0f)
- ThePaths.m_connectionFlags[j].bTrafficLight = true;
+ ThePaths.ConnectionSetTrafficLight(j);
}
}
}
@@ -213,8 +213,8 @@ CTrafficLights::ShouldCarStopForLight(CVehicle *vehicle, bool alwaysStop)
if(alwaysStop ||
(type&~SOME_FLAG) == 1 && LightForCars1() != CAR_LIGHTS_GREEN ||
(type&~SOME_FLAG) == 2 && LightForCars2() != CAR_LIGHTS_GREEN){
- float dist = DotProduct2D(CVector2D(vehicle->GetPosition()) - ThePaths.m_carPathLinks[node].pos,
- ThePaths.m_carPathLinks[node].dir);
+ float dist = DotProduct2D(CVector2D(vehicle->GetPosition()) - ThePaths.m_carPathLinks[node].GetPosition(),
+ ThePaths.m_carPathLinks[node].GetDirection());
if(vehicle->AutoPilot.m_nNextDirection == -1){
if(dist > 0.0f && dist < 8.0f)
return true;
@@ -233,8 +233,8 @@ CTrafficLights::ShouldCarStopForLight(CVehicle *vehicle, bool alwaysStop)
if(alwaysStop ||
(type&~SOME_FLAG) == 1 && LightForCars1() != CAR_LIGHTS_GREEN ||
(type&~SOME_FLAG) == 2 && LightForCars2() != CAR_LIGHTS_GREEN){
- float dist = DotProduct2D(CVector2D(vehicle->GetPosition()) - ThePaths.m_carPathLinks[node].pos,
- ThePaths.m_carPathLinks[node].dir);
+ float dist = DotProduct2D(CVector2D(vehicle->GetPosition()) - ThePaths.m_carPathLinks[node].GetPosition(),
+ ThePaths.m_carPathLinks[node].GetDirection());
if(vehicle->AutoPilot.m_nCurrentDirection == -1){
if(dist > 0.0f && dist < 8.0f)
return true;
@@ -245,7 +245,7 @@ CTrafficLights::ShouldCarStopForLight(CVehicle *vehicle, bool alwaysStop)
}
}
- if(vehicle->m_status == STATUS_PHYSICS){
+ if(vehicle->GetStatus() == STATUS_PHYSICS){
node = vehicle->AutoPilot.m_nPreviousPathNodeInfo;
type = ThePaths.m_carPathLinks[node].trafficLightType;
if(type){
@@ -254,8 +254,8 @@ CTrafficLights::ShouldCarStopForLight(CVehicle *vehicle, bool alwaysStop)
if(alwaysStop ||
(type&~SOME_FLAG) == 1 && LightForCars1() != CAR_LIGHTS_GREEN ||
(type&~SOME_FLAG) == 2 && LightForCars2() != CAR_LIGHTS_GREEN){
- float dist = DotProduct2D(CVector2D(vehicle->GetPosition()) - ThePaths.m_carPathLinks[node].pos,
- ThePaths.m_carPathLinks[node].dir);
+ float dist = DotProduct2D(CVector2D(vehicle->GetPosition()) - ThePaths.m_carPathLinks[node].GetPosition(),
+ ThePaths.m_carPathLinks[node].GetDirection());
if(vehicle->AutoPilot.m_nPreviousDirection == -1){
if(dist > 0.0f && dist < 6.0f)
return true;
diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp
index 36ea20b7..40a8b09e 100644
--- a/src/core/AnimViewer.cpp
+++ b/src/core/AnimViewer.cpp
@@ -108,7 +108,7 @@ CAnimViewer::Initialise(void) {
CTimeCycle::Initialise();
CCarCtrl::Init();
CPlayerPed *player = new CPlayerPed();
- player->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
+ player->SetPosition(0.0f, 0.0f, 0.0f);
CWorld::Players[0].m_pPed = player;
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
@@ -148,7 +148,7 @@ LastPedModelId(int modelId)
CBaseModelInfo *model;
for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i);
- if (model->m_type == MITYPE_PED)
+ if (model->GetModelType() == MITYPE_PED)
return i;
}
return modelId;
@@ -160,7 +160,7 @@ LastVehicleModelId(int modelId)
CBaseModelInfo* model;
for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i);
- if (model->m_type == MITYPE_VEHICLE)
+ if (model->GetModelType() == MITYPE_VEHICLE)
return i;
}
return modelId;
@@ -222,7 +222,7 @@ CAnimViewer::Update(void)
CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId);
CEntity *newEntity = nil;
- if (modelInfo->m_type == MITYPE_PED) {
+ if (modelInfo->GetModelType() == MITYPE_PED) {
int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup;
if (animId > ANIM_IDLE_STANCE)
@@ -248,8 +248,9 @@ CAnimViewer::Update(void)
}
CPad::UpdatePads();
CPad* pad = CPad::GetPad(0);
-
+#ifdef DEBUGMENU
DebugMenuProcess();
+#endif
CStreaming::UpdateForAnimViewer();
CStreaming::RequestModel(modelId, 0);
@@ -257,7 +258,7 @@ CAnimViewer::Update(void)
if (!pTarget) {
- if (modelInfo->m_type == MITYPE_VEHICLE) {
+ if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo;
if (veh->m_vehicleType != VEHICLE_TYPE_CAR) {
@@ -278,10 +279,10 @@ CAnimViewer::Update(void)
// }
} else {
newEntity = pTarget = new CAutomobile(modelId, RANDOM_VEHICLE);
- newEntity->m_status = STATUS_ABANDONED;
+ newEntity->SetStatus(STATUS_ABANDONED);
}
newEntity->bIsStuck = true;
- } else if (modelInfo->m_type == MITYPE_PED) {
+ } else if (modelInfo->GetModelType() == MITYPE_PED) {
pTarget = newEntity = new CPed(PEDTYPE_CIVMALE);
newEntity->SetModelIndex(modelId);
} else {
@@ -292,18 +293,18 @@ CAnimViewer::Update(void)
}
newEntity->bIsStuck = true;
}
- newEntity->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
+ newEntity->SetPosition(0.0f, 0.0f, 0.0f);
CWorld::Add(newEntity);
TheCamera.TakeControl(pTarget, CCam::MODE_MODELVIEW, JUMP_CUT, CAMCONTROL_SCRIPT);
}
- if (pTarget->m_type == ENTITY_TYPE_VEHICLE || pTarget->m_type == ENTITY_TYPE_PED || pTarget->m_type == ENTITY_TYPE_OBJECT) {
+ if (pTarget->IsVehicle() || pTarget->IsPed() || pTarget->IsObject()) {
((CPhysical*)pTarget)->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
}
- pTarget->GetPosition().z = 0.0f;
+ pTarget->GetMatrix().GetPosition().z = 0.0f;
- if (modelInfo->m_type != MITYPE_PED) {
+ if (modelInfo->GetModelType() != MITYPE_PED) {
- if (modelInfo->m_type == MITYPE_VEHICLE) {
+ if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) {
nextModelId = LastPedModelId(modelId);
@@ -369,10 +370,11 @@ CAnimViewer::Update(void)
if (pad->NewState.Triangle) {
#ifdef PED_SKIN
if(IsClumpSkinned(pTarget->GetClump()))
- ((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->AnimatePedColModelSkinned(pTarget->GetClump());
+ ((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->AnimatePedColModelSkinned(pTarget->GetClump());
else
#endif
- CPedModelInfo::AnimatePedColModel(((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->GetHitColModel(), RpClumpGetFrame(pTarget->GetClump()));
+ CPedModelInfo::AnimatePedColModel(((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->GetHitColModel(),
+ RpClumpGetFrame(pTarget->GetClump()));
AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString);
CMessages::AddMessage(gUString, 100, 0);
}
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 801652cb..20b262c8 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -25,13 +25,11 @@
#include "Camera.h"
#include "DMAudio.h"
-const float DefaultFOV = 70.0f; // beta: 80.0f
-
bool PrintDebugCode = false;
int16 DebugCamMode;
#ifdef FREE_CAM
-bool CCamera::bFreeCam = false;
+bool CCamera::bFreeCam = true;
int nPreviousMode = -1;
#endif
@@ -3794,7 +3792,7 @@ CCam::Process_Debug(const CVector&, float, float, float)
if(FindPlayerVehicle())
FindPlayerVehicle()->Teleport(Source);
else
- CWorld::Players[CWorld::PlayerInFocus].m_pPed->GetPosition() = Source;
+ CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetPosition(Source);
}
// stay inside sectors
@@ -3941,7 +3939,7 @@ CCam::Process_Editor(const CVector&, float, float, float)
if(FindPlayerVehicle())
FindPlayerVehicle()->Teleport(Source);
else
- CWorld::Players[CWorld::PlayerInFocus].m_pPed->GetPosition() = Source;
+ CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetPosition(Source);
}
@@ -4489,7 +4487,7 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient
*/
{
LookLeftRight = -CPad::GetPad(0)->LookAroundLeftRight();
- LookUpDown = CPad::GetPad(0)->LookAroundUpDown();
+ LookUpDown = -CPad::GetPad(0)->LookAroundUpDown();
}
float AlphaOffset, BetaOffset;
if(UseMouse){
@@ -4639,7 +4637,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
uint8 camSetArrPos = 0;
// We may need those later
- bool isPlane = car->m_modelIndex == MI_DODO;
+ bool isPlane = car->GetModelIndex() == MI_DODO;
bool isHeli = false;
bool isBike = false;
bool isCar = car->IsCar() && !isPlane && !isHeli && !isBike;
@@ -4650,9 +4648,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
uint8 nextDirectionIsForward = !(pad->GetLookBehindForCar() || pad->GetLookBehindForPed() || pad->GetLookLeft() || pad->GetLookRight()) &&
DirectionWasLooking == LOOKING_FORWARD;
- if (car->m_modelIndex == MI_FIRETRUCK) {
+ if (car->GetModelIndex() == MI_FIRETRUCK) {
camSetArrPos = 7;
- } else if (car->m_modelIndex == MI_RCBANDIT) {
+ } else if (car->GetModelIndex() == MI_RCBANDIT) {
camSetArrPos = 5;
} else if (car->IsBoat()) {
camSetArrPos = 4;
@@ -4683,7 +4681,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
static float ZmTwoAlphaOffsetLCS[] = { 0.1f, 0.08f, 0.3f, 0.08f, 0.08f };
static float ZmThreeAlphaOffsetLCS[] = { 0.065f, 0.05f, 0.15f, 0.06f, 0.08f };
- if (isHeli && car->m_status == STATUS_PLAYER_REMOTE)
+ if (isHeli && car->GetStatus() == STATUS_PLAYER_REMOTE)
zoomModeAlphaOffset = ZmTwoAlphaOffsetLCS[alphaArrPos];
else {
switch ((int)TheCamera.CarZoomIndicator) {
@@ -4712,7 +4710,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float minDistForThisCar = approxCarLength * CARCAM_SET[camSetArrPos][3];
- if (!isHeli || car->m_status == STATUS_PLAYER_REMOTE) {
+ if (!isHeli || car->GetStatus() == STATUS_PLAYER_REMOTE) {
float radiusToStayOutside = colMaxZ * CARCAM_SET[camSetArrPos][0] - CARCAM_SET[camSetArrPos][2];
if (radiusToStayOutside > 0.0f) {
TargetCoors.z += radiusToStayOutside;
@@ -4851,7 +4849,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// This is also original LCS and SA bug, or some attempt to fix lag. We'll never know
// if (car->m_vecMoveSpeed.MagnitudeSqr() < sq(0.2f))
- if (car->m_modelIndex != MI_FIRETRUCK) {
+ if (car->GetModelIndex() != MI_FIRETRUCK) {
// if (!isBike || GetMysteriousWheelRelatedThingBike(car) > 3)
// if (!isHeli && (!isPlane || car->GetWheelsOnGround())) {
@@ -4907,7 +4905,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
bool correctAlpha = true;
// if (SA checks if we aren't in work car, why?) {
- if (!isCar || car->m_modelIndex != MI_YARDIE) {
+ if (!isCar || car->GetModelIndex() != MI_YARDIE) {
correctAlpha = false;
}
else {
@@ -5186,13 +5184,13 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// gTargetCoordsForLookingBehind = TargetCoors;
// SA code from CAutomobile::TankControl/FireTruckControl.
- if (car->m_modelIndex == MI_RHINO || car->m_modelIndex == MI_FIRETRUCK) {
+ if (car->GetModelIndex() == MI_RHINO || car->GetModelIndex() == MI_FIRETRUCK) {
float &carGunLR = ((CAutomobile*)car)->m_fCarGunLR;
CVector hi = Multiply3x3(Front, car->GetMatrix());
// III/VC's firetruck turret angle is reversed
- float angleToFace = (car->m_modelIndex == MI_FIRETRUCK ? -hi.Heading() : hi.Heading());
+ float angleToFace = (car->GetModelIndex() == MI_FIRETRUCK ? -hi.Heading() : hi.Heading());
if (angleToFace <= carGunLR + PI) {
if (angleToFace < carGunLR - PI)
@@ -5202,7 +5200,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
float neededTurn = angleToFace - carGunLR;
- float turnPerFrame = CTimer::GetTimeStep() * (car->m_modelIndex == MI_FIRETRUCK ? 0.05f : 0.015f);
+ float turnPerFrame = CTimer::GetTimeStep() * (car->GetModelIndex() == MI_FIRETRUCK ? 0.05f : 0.015f);
if (neededTurn <= turnPerFrame) {
if (neededTurn < -turnPerFrame)
angleToFace = carGunLR - turnPerFrame;
@@ -5210,7 +5208,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
angleToFace = turnPerFrame + carGunLR;
}
- if (car->m_modelIndex == MI_RHINO && carGunLR != angleToFace) {
+ if (car->GetModelIndex() == MI_RHINO && carGunLR != angleToFace) {
DMAudio.PlayOneShot(car->m_audioEntityId, SOUND_CAR_TANK_TURRET_ROTATE, Abs(angleToFace - carGunLR));
}
carGunLR = angleToFace;
@@ -5222,7 +5220,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
// Because firetruk turret also has Y movement
- if (car->m_modelIndex == MI_FIRETRUCK) {
+ if (car->GetModelIndex() == MI_FIRETRUCK) {
float &carGunUD = ((CAutomobile*)car)->m_fCarGunUD;
float alphaToFace = Atan2(hi.z, hi.Magnitude2D()) + DEGTORAD(15.0f);
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 9a053056..9b178f35 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -470,19 +470,19 @@ CCamera::Process(void)
}
}
- GetRight() = CrossProduct(CamUp, CamFront); // actually Left
- GetForward() = CamFront;
- GetUp() = CamUp;
- GetPosition() = CamSource;
+ GetMatrix().GetRight() = CrossProduct(CamUp, CamFront); // actually Left
+ GetMatrix().GetForward() = CamFront;
+ GetMatrix().GetUp() = CamUp;
+ GetMatrix().GetPosition() = CamSource;
// Process Shake
float shakeStrength = m_fCamShakeForce - 0.28f*(CTimer::GetTimeInMilliseconds()-m_uiCamShakeStart)/1000.0f;
shakeStrength = clamp(shakeStrength, 0.0f, 2.0f);
int shakeRand = CGeneral::GetRandomNumber();
float shakeOffset = shakeStrength*0.1f;
- GetPosition().x += shakeOffset*((shakeRand&0xF)-7);
- GetPosition().y += shakeOffset*(((shakeRand&0xF0)>>4)-7);
- GetPosition().z += shakeOffset*(((shakeRand&0xF00)>>8)-7);
+ GetMatrix().GetPosition().x += shakeOffset * ((shakeRand & 0xF) - 7);
+ GetMatrix().GetPosition().y += shakeOffset * (((shakeRand & 0xF0) >> 4) - 7);
+ GetMatrix().GetPosition().z += shakeOffset * (((shakeRand & 0xF00) >> 8) - 7);
if(shakeOffset > 0.0f && m_BlurType != MBLUR_SNIPER)
SetMotionBlurAlpha(Min((int)(shakeStrength*255.0f) + 25, 150));
@@ -499,27 +499,27 @@ CCamera::Process(void)
CVector Front = Cams[2].Front;
CVector Up = Cams[2].Up;
- GetRight() = CrossProduct(Up, Front);
- GetForward() = Front;
- GetUp() = Up;
- GetPosition() = Source;
+ GetMatrix().GetRight() = CrossProduct(Up, Front);
+ GetMatrix().GetForward() = Front;
+ GetMatrix().GetUp() = Up;
+ GetMatrix().GetPosition() = Source;
CDraw::SetFOV(Cams[2].FOV);
m_vecGameCamPos = Cams[ActiveCam].Source;
- *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d();
- *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d();
- *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d();
- *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d();
+ *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition();
+ *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward();
+ *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp();
+ *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight();
RwMatrixUpdate(RwFrameGetMatrix(frame));
RwFrameUpdateObjects(frame);
}else{
RwFrame *frame = RwCameraGetFrame(m_pRwCamera);
m_vecGameCamPos = GetPosition();
- *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d();
- *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d();
- *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d();
- *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d();
+ *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition();
+ *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward();
+ *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp();
+ *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight();
RwMatrixUpdate(RwFrameGetMatrix(frame));
RwFrameUpdateObjects(frame);
}
@@ -2707,7 +2707,6 @@ CCamera::DontProcessObbeCinemaCamera(void)
bDidWeProcessAnyCinemaCam = false;
}
-
void
CCamera::LoadTrainCamNodes(char const *name)
{
@@ -2887,7 +2886,6 @@ CCamera::Process_Train_Camera_Control(void)
}
-
void
CCamera::LoadPathSplines(int file)
{
diff --git a/src/core/Camera.h b/src/core/Camera.h
index 6d53f417..94bcbd23 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -40,6 +40,8 @@ enum
#define DEFAULT_CAR_ZOOM_VALUE_2 (1.9f)
#define DEFAULT_CAR_ZOOM_VALUE_3 (3.9f)
+const float DefaultFOV = 70.0f; // beta: 80.0f
+
class CCam
{
public:
@@ -258,9 +260,8 @@ public:
void Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrientation, float, float);
void Process_FollowCar_SA(const CVector &CameraTarget, float TargetOrientation, float, float);
};
-static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size");
-static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error");
-static_assert(offsetof(CCam, Front) == 0x140, "CCam: error");
+
+VALIDATE_SIZE(CCam, 0x1A4);
class CCamPathSplines
{
@@ -298,11 +299,12 @@ enum
enum
{
- // TODO: figure out
- FADE_0,
+ // TODO: find better names
+ FADE_0, // faded in
FADE_1, // mid fade
- FADE_2,
+ FADE_2, // faded out
+ // Direction
FADE_OUT = 0,
FADE_IN,
FADE_NONE
@@ -634,19 +636,8 @@ uint32 unknown; // some counter having to do with music
bool IsSphereVisible(const CVector &center, float radius);
bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
};
-static_assert(offsetof(CCamera, DistanceToWater) == 0xe4, "CCamera: error");
-static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error");
-static_assert(offsetof(CCamera, WorldViewerBeingUsed) == 0x75, "CCamera: error");
-static_assert(offsetof(CCamera, m_uiNumberOfTrainCamNodes) == 0x84, "CCamera: error");
-static_assert(offsetof(CCamera, m_uiTransitionState) == 0x89, "CCamera: error");
-static_assert(offsetof(CCamera, m_uiTimeTransitionStart) == 0x94, "CCamera: error");
-static_assert(offsetof(CCamera, m_BlurBlue) == 0x9C, "CCamera: error");
-static_assert(offsetof(CCamera, Cams) == 0x1A4, "CCamera: error");
-static_assert(offsetof(CCamera, pToGarageWeAreIn) == 0x690, "CCamera: error");
-static_assert(offsetof(CCamera, m_PreviousCameraPosition) == 0x6B0, "CCamera: error");
-static_assert(offsetof(CCamera, m_vecCutSceneOffset) == 0x6F8, "CCamera: error");
-static_assert(offsetof(CCamera, m_arrPathArray) == 0x7a8, "CCamera: error");
-static_assert(sizeof(CCamera) == 0xE9D8, "CCamera: wrong size");
+
+VALIDATE_SIZE(CCamera, 0xE9D8);
extern CCamera TheCamera;
diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp
index ea79fb9a..666041e1 100644
--- a/src/core/CdStream.cpp
+++ b/src/core/CdStream.cpp
@@ -22,6 +22,7 @@ struct CdReadInfo
HANDLE hFile;
OVERLAPPED Overlapped;
};
+
VALIDATE_SIZE(CdReadInfo, 0x30);
char gCdImageNames[MAX_CDIMAGES+1][64];
diff --git a/src/core/CdStream.h b/src/core/CdStream.h
index 9ef71b65..ba6c63a3 100644
--- a/src/core/CdStream.h
+++ b/src/core/CdStream.h
@@ -27,7 +27,6 @@ struct Queue
VALIDATE_SIZE(Queue, 0x10);
-
void CdStreamInitThread(void);
void CdStreamInit(int32 numChannels);
uint32 GetGTA3ImgSize(void);
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp
index 7dfe3651..0cdacfdb 100644
--- a/src/core/Collision.cpp
+++ b/src/core/Collision.cpp
@@ -184,6 +184,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
CPad::StopPadsShaking();
LoadCollisionScreen(CGame::currLevel);
DMAudio.Service();
+
CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false);
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
@@ -204,6 +205,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(true);
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
+
CGame::TidyUpMemory(true, true);
CTimer::Update();
DMAudio.SetEffectsFadeVol(127);
diff --git a/src/core/Collision.h b/src/core/Collision.h
index bdf51eb8..895f012a 100644
--- a/src/core/Collision.h
+++ b/src/core/Collision.h
@@ -89,11 +89,11 @@ struct CColModel
{
CColSphere boundingSphere;
CColBox boundingBox;
- short numSpheres;
- short numLines;
- short numBoxes;
- short numTriangles;
- int level;
+ int16 numSpheres;
+ int16 numLines;
+ int16 numBoxes;
+ int16 numTriangles;
+ int32 level;
bool ownsCollisionVolumes;
CColSphere *spheres;
CColLine *lines;
diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp
index f55568be..cba8186f 100644
--- a/src/core/ControllerConfig.cpp
+++ b/src/core/ControllerConfig.cpp
@@ -685,7 +685,15 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_Driving(int32
}
bool isDodo = false;
- if (FindPlayerVehicle() && (FindPlayerVehicle()->IsVehicle() && FindPlayerVehicle()->GetModelIndex() == MI_DODO))
+ if (FindPlayerVehicle() && (FindPlayerVehicle()->IsVehicle() && (
+ FindPlayerVehicle()->GetModelIndex() == MI_DODO
+#ifdef FIX_BUGS
+ || CVehicle::bAllDodosCheat
+#ifdef ALLCARSHELI_CHEAT
+ || bAllCarCheat
+#endif
+#endif
+ )))
{
isDodo = true;
}
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index b7d82089..88afb40c 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -172,16 +172,19 @@ CFileLoader::LoadTexDictionary(const char *filename)
return txd;
}
+struct ColHeader
+{
+ char ident[4];
+ uint32 size;
+};
+
void
CFileLoader::LoadCollisionFile(const char *filename)
{
int fd;
char modelname[24];
CBaseModelInfo *mi;
- struct {
- char ident[4];
- uint32 size;
- } header;
+ ColHeader header;
debug("Loading collision file %s\n", filename);
fd = CFileMgr::OpenFile(filename, "rb");
@@ -384,7 +387,7 @@ CFileLoader::LoadClumpFile(RwStream *stream, uint32 id)
return false;
mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id);
mi->SetClump(clump);
- if(mi->m_type == MITYPE_PED && id != 0 && RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)){
+ if (mi->GetModelType() == MITYPE_PED && id != 0 && RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)) {
// Read LOD ped
clump = RpClumpStreamRead(stream);
if(clump){
@@ -780,7 +783,7 @@ CFileLoader::LoadVehicleObject(const char *line)
mi->SetTexDictionary(txd);
for(p = gamename; *p; p++)
if(*p == '_') *p = ' ';
- strncpy(mi->m_gameName, gamename, 32);
+ strcpy(mi->m_gameName, gamename);
mi->m_level = level;
mi->m_compRules = comprules;
@@ -809,33 +812,33 @@ CFileLoader::LoadVehicleObject(const char *line)
// Well this is kinda dumb....
if(strncmp(vehclass, "poorfamily", 11) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_POOR;
+ mi->m_vehicleClass = CCarCtrl::POOR;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_POOR);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::POOR);
}else if(strncmp(vehclass, "richfamily", 11) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_RICH;
+ mi->m_vehicleClass = CCarCtrl::RICH;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_RICH);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::RICH);
}else if(strncmp(vehclass, "executive", 10) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_EXECUTIVE;
+ mi->m_vehicleClass = CCarCtrl::EXEC;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_EXECUTIVE);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::EXEC);
}else if(strncmp(vehclass, "worker", 7) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_WORKER;
+ mi->m_vehicleClass = CCarCtrl::WORKER;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_WORKER);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::WORKER);
}else if(strncmp(vehclass, "special", 8) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_SPECIAL;
+ mi->m_vehicleClass = CCarCtrl::SPECIAL;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_SPECIAL);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::SPECIAL);
}else if(strncmp(vehclass, "big", 4) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_BIG;
+ mi->m_vehicleClass = CCarCtrl::BIG;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_BIG);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::BIG);
}else if(strncmp(vehclass, "taxi", 5) == 0){
- mi->m_vehicleClass = VEHICLE_CLASS_TAXI;
+ mi->m_vehicleClass = CCarCtrl::TAXI;
while(frequency-- > 0)
- CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_TAXI);
+ CCarCtrl::AddToCarArray(id, CCarCtrl::TAXI);
}
}
@@ -1060,7 +1063,6 @@ CFileLoader::LoadObjectInstance(const char *line)
CSimpleModelInfo *mi;
RwMatrix *xform;
CEntity *entity;
-
if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f",
&id, name,
&trans.x, &trans.y, &trans.z,
@@ -1086,7 +1088,7 @@ CFileLoader::LoadObjectInstance(const char *line)
entity = new CBuilding;
entity->SetModelIndexNoCreate(id);
entity->GetMatrix() = CMatrix(xform);
- entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
+ entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
if(mi->IsSimple()){
if(mi->m_isBigBuilding)
entity->SetupBigBuilding();
@@ -1103,7 +1105,7 @@ CFileLoader::LoadObjectInstance(const char *line)
CWorld::Add(entity);
if(IsGlass(entity->GetModelIndex()))
entity->bIsVisible = false;
- entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
+ entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
}
RwMatrixDestroy(xform);
@@ -1325,7 +1327,7 @@ CFileLoader::ReloadObject(const char *line)
#ifdef FIX_BUGS
mi &&
#endif
- mi->m_type == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
+ mi->GetModelType() == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
} else {
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index b0766cff..827e2ca7 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -110,7 +110,7 @@ int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt;
int32 CMenuManager::m_PrefsMusicVolume = 102;
int32 CMenuManager::m_PrefsSfxVolume = 102;
-char CMenuManager::m_PrefsSkinFile[256] = "$$\"\"";
+char CMenuManager::m_PrefsSkinFile[256] = DEFAULT_SKIN_NAME;
int32 CMenuManager::m_KeyPressedCode = -1;
@@ -286,7 +286,7 @@ ScaleAndCenterX(float x)
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); \
CFont::SetRightJustifyOn(); \
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); \
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
#define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \
do { \
@@ -394,6 +394,9 @@ CMenuManager::ThingsToDoBeforeLeavingPage()
#endif
} else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) {
m_nDisplayVideoMode = m_nPrefsVideoMode;
+#ifdef IMPROVED_VIDEOMODE
+ m_nSelectedScreenMode = m_nPrefsWindowed;
+#endif
}
if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) {
@@ -413,6 +416,14 @@ CMenuManager::BuildStatLine(char *text, void *stat, bool itsFloat, void *stat2)
if (!text)
return;
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese() && stat2)
+ if (itsFloat)
+ sprintf(gString2, " %.2f/%.2f", *(float*)stat, *(float*)stat2);
+ else
+ sprintf(gString2, " %d/%d", *(int*)stat, *(int*)stat2);
+ else
+#endif
if (stat2) {
if (itsFloat)
sprintf(gString2, " %.2f %s %.2f", *(float*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(float*)stat2);
@@ -596,7 +607,7 @@ CMenuManager::DisplayHelperText()
CFont::SetCentreOn();
CFont::SetScale(SCREEN_SCALE_X(SMALLESTTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
// TODO: name this cases?
switch (m_nHelperTextMsgId) {
@@ -732,7 +743,7 @@ CMenuManager::Draw()
nextYToUse += 24.0f + 10.0f;
}
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_X), MENU_Y(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_Y));
CFont::SetRightJustifyOff();
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
@@ -788,7 +799,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 240;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -805,7 +816,7 @@ CMenuManager::Draw()
columnWidth = 50;
headerHeight = 0;
lineHeight = 20;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = MEDIUMTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = MEDIUMTEXT_Y_SCALE));
CFont::SetRightJustifyOff();
break;
@@ -815,7 +826,7 @@ CMenuManager::Draw()
columnWidth = 120;
headerHeight = 38;
lineHeight = 20;
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE));
CFont::SetRightJustifyOff();
break;
@@ -827,7 +838,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 60;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -835,7 +846,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 140;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -843,7 +854,7 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 117;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
@@ -852,7 +863,7 @@ CMenuManager::Draw()
columnWidth = 180;
headerHeight = 60;
lineHeight = 24;
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
break;
#endif
@@ -860,14 +871,14 @@ CMenuManager::Draw()
columnWidth = 320;
headerHeight = 40;
lineHeight = 24;
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE));
CFont::SetCentreOn();
break;
}
#ifdef PS2_LIKE_MENU
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
#endif
switch (m_nCurrScreen) {
@@ -890,6 +901,25 @@ CMenuManager::Draw()
bool foundTheHoveringItem = false;
wchar unicodeTemp[64];
+#ifdef MENU_MAP
+ if (m_nCurrScreen == MENUPAGE_MAP) {
+ // Back button
+ wchar *backTx = TheText.Get("FEDS_TB");
+ CFont::SetDropShadowPosition(1);
+ CFont::SetDropColor(CRGBA(0, 0, 0, 255));
+ CFont::PrintString(MENU_X(60.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), backTx);
+ CFont::SetDropShadowPosition(0);
+ if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) {
+ m_nHoverOption = HOVEROPTION_NOT_HOVERING;
+ m_nCurrOption = m_nPrevOption = 0;
+ } else {
+ m_nHoverOption = HOVEROPTION_RANDOM_ITEM;
+ m_nCurrOption = m_nPrevOption = 1;
+ }
+ return;
+ }
+#endif
+
for (int i = 0; i < NUM_MENUROWS; ++i) {
if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') {
wchar *rightText = nil;
@@ -1070,6 +1100,18 @@ CMenuManager::Draw()
AsciiToUnicode(_psGetVideoModeList()[m_nDisplayVideoMode], unicodeTemp);
rightText = unicodeTemp;
break;
+#ifdef IMPROVED_VIDEOMODE
+ case MENUACTION_SCREENMODE:
+ char mode[32];
+ if (m_nSelectedScreenMode == 0)
+ sprintf(mode, "FULLSCREEN");
+ else
+ sprintf(mode, "WINDOWED");
+
+ AsciiToUnicode(mode, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+#endif
case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex == -1)
rightText = TheText.Get("FEA_NAH");
@@ -1241,6 +1283,14 @@ CMenuManager::Draw()
SetHelperText(3);
}
}
+#ifdef IMPROVED_VIDEOMODE
+ if (m_nSelectedScreenMode != m_nPrefsWindowed) {
+ if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "SCRFOR") != 0
+ && m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) {
+ m_nSelectedScreenMode = m_nPrefsWindowed;
+ }
+ }
+#endif
// Sliders
int lastActiveBarX;
@@ -1580,7 +1630,12 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
nextX += CFont::GetStringWidth(seperator, true) + bindingMargin;
}
CFont::PrintString(nextX, nextY, settingText);
- nextX += CFont::GetStringWidth(settingText, true) + bindingMargin;
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ nextX += CFont::GetStringWidth_Jap(settingText) + bindingMargin;
+ else
+#endif
+ nextX += CFont::GetStringWidth(settingText, true) + bindingMargin;
}
}
if (controllerAction == -1) {
@@ -1629,7 +1684,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
}
CFont::SetCentreOn();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(255, 255, 255, FadeIn(255)));
if (m_bKeyChangeNotProcessed) {
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_CIG")); // BACKSPACE TO CLEAR - LMB,RETURN TO CHANGE
@@ -1639,7 +1694,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(0);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
if (!m_bKeyIsOK)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0);
@@ -1647,24 +1702,24 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
} else {
CFont::SetCentreOn();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(255, 255, 255, FadeIn(255)));
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_CIG")); // BACKSPACE TO CLEAR - LMB,RETURN TO CHANGE
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
m_bKeyIsOK = false;
m_bKeyChangeNotProcessed = false;
}
} else if (optionIdx == m_nSelectedListRow) {
CFont::SetCentreOn();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(55, 55, 55, FadeIn(255)));
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_EIG")); // CANNOT SET A CONTROL FOR THIS ACTION
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
}
}
}
@@ -1819,7 +1874,7 @@ CMenuManager::DrawControllerSetupScreen()
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
// List header
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
CFont::SetRightJustifyOff();
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_1_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CAC"));
@@ -1827,7 +1882,7 @@ CMenuManager::DrawControllerSetupScreen()
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CCR"));
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X_LEFT_ALIGNED(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
int yStart;
if (m_ControlMethod == CONTROL_CLASSIC)
yStart = CONTSETUP_LIST_HEADER_HEIGHT + 29;
@@ -1916,7 +1971,7 @@ CMenuManager::DrawControllerSetupScreen()
}
// Back button and it's shadow
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y));
CFont::SetRightJustifyOn();
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90)));
@@ -2174,7 +2229,7 @@ CMenuManager::DrawFrontEndNormal()
if (CheckHover(xStart, xStart + optionWidth, optionTop, optionBottom))
hoveredBottomBarOption = i;
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetScale(MENU_X(0.35f), MENU_Y(0.7f));
CFont::SetRightJustifyOff();
if (hoveredBottomBarOption == i && hoveredBottomBarOption != curBottomBarOption)
@@ -2442,7 +2497,7 @@ CMenuManager::DrawPlayerSetupScreen()
m_pSelectedSkin->nextSkin = new tSkinInfo;
m_pSelectedSkin = m_pSelectedSkin->nextSkin;
m_pSelectedSkin->skinId = 0;
- strcpy(m_pSelectedSkin->skinNameOriginal, "$$\"\"");
+ strcpy(m_pSelectedSkin->skinNameOriginal, DEFAULT_SKIN_NAME);
strcpy(m_pSelectedSkin->skinNameDisplayed, UnicodeToAscii(TheText.Get("FET_DSN")));
int nextSkinId = 1;
m_pSelectedSkin->nextSkin = nil;
@@ -2451,7 +2506,7 @@ CMenuManager::DrawPlayerSetupScreen()
SYSTEMTIME SystemTime;
HANDLE handle = FindFirstFile("skins\\*.bmp", &FindFileData);
for (int i = 1; handle != INVALID_HANDLE_VALUE && i; i = FindNextFile(handle, &FindFileData)) {
- if (strncmp(FindFileData.cFileName, "$$\"\"", 5) != 0) {
+ if (strncmp(FindFileData.cFileName, DEFAULT_SKIN_NAME, 5) != 0) {
m_pSelectedSkin->nextSkin = new tSkinInfo;
m_pSelectedSkin = m_pSelectedSkin->nextSkin;
m_pSelectedSkin->skinId = nextSkinId;
@@ -2525,7 +2580,7 @@ CMenuManager::DrawPlayerSetupScreen()
} else {
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
}
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
CFont::SetRightJustifyOn();
CFont::PrintString(MENU_X_RIGHT_ALIGNED(PLAYERSETUP_DATE_COLUMN_RIGHT), MENU_Y(PLAYERSETUP_LIST_TOP), TheText.Get("FES_DAT"));
@@ -2544,7 +2599,7 @@ CMenuManager::DrawPlayerSetupScreen()
// Skin list
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(PLAYERSETUP_ROW_TEXT_X_SCALE), MENU_Y(PLAYERSETUP_ROW_TEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
if (m_nSkinsTotal > 0) {
for (m_pSelectedSkin = m_pSkinListHead.nextSkin; m_pSelectedSkin->skinId != m_nFirstVisibleRowOnList;
m_pSelectedSkin = m_pSelectedSkin->nextSkin);
@@ -2698,7 +2753,7 @@ CMenuManager::DrawPlayerSetupScreen()
// Big apply button
if (strcmp(m_aSkinName, m_PrefsSkinFile) != 0) {
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
switch (m_PrefsLanguage) {
case LANGUAGE_FRENCH:
CFont::SetScale(MENU_X(1.1f), MENU_Y(1.9f));
@@ -2718,7 +2773,7 @@ CMenuManager::DrawPlayerSetupScreen()
CFont::SetRightJustifyOff();
CFont::PrintString(MENU_X_LEFT_ALIGNED(20.0f), MENU_Y(220.0f), TheText.Get("FET_APL"));
}
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(SMALLTEXT_X_SCALE), MENU_Y(SMALLTEXT_Y_SCALE));
@@ -2796,7 +2851,7 @@ CMenuManager::DrawPlayerSetupScreen()
m_nHoverOption = HOVEROPTION_NOT_HOVERING;
}
}
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(MENU_X(SMALLTEXT_X_SCALE), MENU_Y(SMALLTEXT_Y_SCALE));
CFont::SetRightJustifyOn();
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90)));
@@ -2898,6 +2953,8 @@ CMenuManager::InitialiseChangedLanguageSettings()
CGame::frenchGame = false;
CGame::germanGame = false;
#ifdef MORE_LANGUAGES
+ CGame::russianGame = false;
+ CGame::japaneseGame = false;
switch (m_PrefsLanguage) {
case LANGUAGE_POLISH:
CFont::ReloadFonts(FONT_LANGSET_POLISH);
@@ -2905,6 +2962,9 @@ CMenuManager::InitialiseChangedLanguageSettings()
case LANGUAGE_RUSSIAN:
CFont::ReloadFonts(FONT_LANGSET_RUSSIAN);
break;
+ case LANGUAGE_JAPANESE:
+ CFont::ReloadFonts(FONT_LANGSET_JAPANESE);
+ break;
default:
CFont::ReloadFonts(FONT_LANGSET_EFIGS);
break;
@@ -2919,12 +2979,12 @@ CMenuManager::InitialiseChangedLanguageSettings()
CGame::germanGame = true;
break;
#ifdef MORE_LANGUAGES
- case LANGUAGE_POLISH:
- CGame::polishGame = true;
- break;
case LANGUAGE_RUSSIAN:
CGame::russianGame = true;
break;
+ case LANGUAGE_JAPANESE:
+ CGame::japaneseGame = true;
+ break;
#endif
default:
break;
@@ -3027,7 +3087,25 @@ CMenuManager::LoadSettings()
if (strncmp(Ver, TopLineEmptyFile, sizeof(TopLineEmptyFile) - 1)) {
CFileMgr::Seek(fileHandle, 0, 0);
ControlsManager.LoadSettings(fileHandle);
+#ifdef IMPROVED_VIDEOMODE
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsWidth, sizeof(m_nPrefsWidth));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsHeight, sizeof(m_nPrefsHeight));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsDepth, sizeof(m_nPrefsDepth));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsWindowed, sizeof(m_nPrefsWindowed));
+ CFileMgr::Read(fileHandle, (char*)&m_nPrefsSubsystem, sizeof(m_nPrefsSubsystem));
+ if(m_nPrefsWindowed != 0 && m_nPrefsWindowed != 1){
+ // garbage data from vanilla settings file
+ // let skeleton find something
+ m_nPrefsWidth = 0;
+ m_nPrefsHeight = 0;
+ m_nPrefsDepth = 0;
+ m_nPrefsWindowed = 0;
+ m_nPrefsSubsystem = 0;
+ }
+ m_nSelectedScreenMode = m_nPrefsWindowed;
+#else
CFileMgr::Read(fileHandle, gString, 20);
+#endif
CFileMgr::Read(fileHandle, gString, 20);
CFileMgr::Read(fileHandle, gString, 4);
CFileMgr::Read(fileHandle, gString, 4);
@@ -3094,8 +3172,8 @@ CMenuManager::LoadSettings()
if (!SkinFound) {
OutputDebugString("Default skin set as no other skins are available OR saved skin not found!");
- strcpy(m_PrefsSkinFile, "$$\"\"");
- strcpy(m_aSkinName, "$$\"\"");
+ strcpy(m_PrefsSkinFile, DEFAULT_SKIN_NAME);
+ strcpy(m_aSkinName, DEFAULT_SKIN_NAME);
}
}
@@ -3109,7 +3187,15 @@ CMenuManager::SaveSettings()
int fileHandle = CFileMgr::OpenFile("gta3.set", "w+");
if (fileHandle) {
ControlsManager.SaveSettings(fileHandle);
+#ifdef IMPROVED_VIDEOMODE
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsWidth, sizeof(m_nPrefsWidth));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsHeight, sizeof(m_nPrefsHeight));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsDepth, sizeof(m_nPrefsDepth));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsWindowed, sizeof(m_nPrefsWindowed));
+ CFileMgr::Write(fileHandle, (char*)&m_nPrefsSubsystem, sizeof(m_nPrefsSubsystem));
+#else
CFileMgr::Write(fileHandle, RubbishString, 20);
+#endif
CFileMgr::Write(fileHandle, RubbishString, 20);
CFileMgr::Write(fileHandle, RubbishString, 4);
CFileMgr::Write(fileHandle, RubbishString, 4);
@@ -3169,7 +3255,7 @@ CMenuManager::MessageScreen(const char *text)
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f));
CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(170.0f));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_SCALE_FROM_BOTTOM(220.0f)), CRGBA(50, 50, 50, 210));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetCentreSize(SCREEN_SCALE_X(380.0f));
CFont::SetCentreOn();
CFont::SetColor(CRGBA(255, 217, 106, 255));
@@ -3199,7 +3285,7 @@ void
CMenuManager::PrintBriefs()
{
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetRightJustifyOff();
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why
@@ -3254,7 +3340,7 @@ CMenuManager::PrintErrorMessage()
return;
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(140.0f), SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f)), CRGBA(64, 16, 16, 224));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetBackgroundOff();
CFont::SetPropOn();
CFont::SetCentreOff();
@@ -3275,7 +3361,7 @@ CMenuManager::PrintStats()
{
int rowNum = ConstructStatLine(99999);
#ifdef GTA3_1_1_PATCH
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
#endif
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why
float nextYChange, y, alphaMult;
@@ -3334,9 +3420,21 @@ CMenuManager::PrintStats()
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
CFont::SetRightJustifyOff();
- CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), TheText.Get("CRIMRA")); nextX += MENU_X(10.0f) + CFont::GetStringWidth(TheText.Get("CRIMRA"), true);
+ CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), TheText.Get("CRIMRA"));
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ nextX += MENU_X(10.0f) + CFont::GetStringWidth_Jap(TheText.Get("CRIMRA"));
+ else
+#endif
+ nextX += MENU_X(10.0f) + CFont::GetStringWidth(TheText.Get("CRIMRA"), true);
UnicodeStrcpy(gUString, CStats::FindCriminalRatingString());
- CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString); nextX += MENU_X(6.0f) + CFont::GetStringWidth(gUString, true);
+ CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString);
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ nextX += MENU_X(6.0f) + CFont::GetStringWidth_Jap(gUString);
+ else
+#endif
+ nextX += MENU_X(6.0f) + CFont::GetStringWidth(gUString, true);
sprintf(gString, "%d", CStats::FindCriminalRatingNumber());
AsciiToUnicode(gString, gUString);
CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString);
@@ -4285,6 +4383,12 @@ CMenuManager::ProcessButtonPresses(void)
case MENUACTION_LANG_RUS:
m_PrefsLanguage = LANGUAGE_RUSSIAN;
m_bFrontEnd_ReloadObrTxtGxt = true;
+ CMenuManager::InitialiseChangedLanguageSettings();
+ SaveSettings();
+ break;
+ case MENUACTION_LANG_JAP:
+ m_PrefsLanguage = LANGUAGE_JAPANESE;
+ m_bFrontEnd_ReloadObrTxtGxt = true;
InitialiseChangedLanguageSettings();
SaveSettings();
break;
@@ -4428,6 +4532,16 @@ CMenuManager::ProcessButtonPresses(void)
SaveSettings();
}
break;
+#ifdef IMPROVED_VIDEOMODE
+ case MENUACTION_SCREENMODE:
+ if (m_nSelectedScreenMode != m_nPrefsWindowed) {
+ m_nPrefsWindowed = m_nSelectedScreenMode;
+ _psSelectScreenVM(m_nPrefsVideoMode); // apply same resolution
+ SetHelperText(0);
+ SaveSettings();
+ }
+ break;
+#endif
case MENUACTION_AUDIOHW:
{
int selectedProvider = m_nPrefsAudio3DProviderIndex;
@@ -4701,6 +4815,12 @@ CMenuManager::ProcessButtonPresses(void)
}
}
break;
+#ifdef IMPROVED_VIDEOMODE
+ case MENUACTION_SCREENMODE:
+ DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0);
+ m_nSelectedScreenMode = !m_nSelectedScreenMode;
+ break;
+#endif
case MENUACTION_AUDIOHW:
if (m_nPrefsAudio3DProviderIndex != -1) {
m_nPrefsAudio3DProviderIndex += changeValueBy;
@@ -5075,7 +5195,7 @@ CMenuManager::PrintController(void)
m_aFrontEndSprites[FE_ARROWS4].Draw(MENU_X_LEFT_ALIGNED(160.0f), MENU_Y(160.0f), MENU_X(235.2f), MENU_Y(175.2f), CRGBA(255, 255, 255, 255));
}
- CFont::SetFontStyle(FONT_BANK); // X
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); // X
// CFont::SetScale(0.4f, 0.4f);
CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); // X
@@ -5280,13 +5400,13 @@ CMenuManager::PrintController(void)
#define ZOOM(x, y, in) \
do { \
- if(fMapSize > SCREEN_WIDTH * 2 && in) \
+ if(fMapSize > SCREEN_HEIGHT * 3.0f && in) \
break; \
float z2 = in? 1.1f : 1.f/1.1f; \
fMapCenterX += (x - fMapCenterX) * (1.0f - z2); \
fMapCenterY += (y - fMapCenterY) * (1.0f - z2); \
\
- if (fMapSize < SCREEN_WIDTH / 3 && !in) \
+ if (fMapSize < SCREEN_HEIGHT / 2 && !in) \
break; \
\
fMapSize *= z2; \
@@ -5299,10 +5419,18 @@ CMenuManager::PrintMap(void)
bMenuMapActive = true;
CRadar::InitFrontEndMap();
+ // Just entered to map
if (!bMapLoaded) {
- fMapCenterX = SCREEN_WIDTH / 2;
- fMapCenterY = SCREEN_HEIGHT / 3;
- fMapSize = SCREEN_HEIGHT / CDraw::GetAspectRatio();
+ fMapSize = SCREEN_HEIGHT * 2.0f;
+ fMapCenterX = 0.0f;
+ fMapCenterY = 0.0f;
+ CVector2D radarSpacePlayer;
+ CVector2D screenSpacePlayer;
+ CRadar::TransformRealWorldPointToRadarSpace(radarSpacePlayer, CVector2D(FindPlayerCoors()));
+ CRadar::TransformRadarPointToScreenSpace(screenSpacePlayer, radarSpacePlayer);
+
+ fMapCenterX = (-screenSpacePlayer.x) + SCREEN_WIDTH / 2;
+ fMapCenterY = (-screenSpacePlayer.y) + SCREEN_HEIGHT / 2;
bMapMouseShownOnce = false;
bMapLoaded = true;
@@ -5452,13 +5580,23 @@ CMenuManager::PrintMap(void)
CRGBA(235, 170, 50, 255));
CFont::SetScale(MENU_X(0.4f), MENU_Y(0.7f));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
float nextX = MENU_X(30.0f), nextY = 95.0f;
wchar *text;
+#ifdef MORE_LANGUAGES
+#define TEXT_PIECE(key,extraSpace) \
+ text = TheText.Get(key);\
+ CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), text);\
+ if (CFont::IsJapanese())\
+ nextX += CFont::GetStringWidth_Jap(text) + MENU_X(extraSpace);\
+ else\
+ nextX += CFont::GetStringWidth(text, true) + MENU_X(extraSpace);
+#else
#define TEXT_PIECE(key,extraSpace) \
text = TheText.Get(key); CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), text); nextX += CFont::GetStringWidth(text, true) + MENU_X(extraSpace);
+#endif
TEXT_PIECE("FEC_MWF", 3.0f);
TEXT_PIECE("FEC_PGU", 1.0f);
@@ -5506,9 +5644,9 @@ CMenuManager::ConstructStatLine(int rowIdx)
STAT_LINE("PER_COM", &percentCompleted, false, nil);
STAT_LINE("NMISON", &CStats::MissionsGiven, false, nil);
- STAT_LINE("FEST_MP", &CStats::MissionsPassed, 0, &CStats::TotalNumberMissions);
+ STAT_LINE("FEST_MP", &CStats::MissionsPassed, false, &CStats::TotalNumberMissions);
if (CGame::nastyGame) {
- STAT_LINE("FEST_RP", &CStats::NumberKillFrenziesPassed, 0, &CStats::TotalNumberKillFrenzies);
+ STAT_LINE("FEST_RP", &CStats::NumberKillFrenziesPassed, false, &CStats::TotalNumberKillFrenzies);
}
CPlayerInfo &player = CWorld::Players[CWorld::PlayerInFocus];
@@ -5517,8 +5655,8 @@ CMenuManager::ConstructStatLine(int rowIdx)
packagesPercent = player.m_nCollectedPackages * 100.0f / player.m_nTotalPackages;
int nPackagesPercent = packagesPercent;
- STAT_LINE("PERPIC", &nPackagesPercent, 0, &(nTemp = 100));
- STAT_LINE("NOUNIF", &CStats::TotalNumberOfUniqueJumps, 0, &CStats::NumberOfUniqueJumpsFound);
+ STAT_LINE("PERPIC", &nPackagesPercent, false, &(nTemp = 100));
+ STAT_LINE("NOUNIF", &CStats::NumberOfUniqueJumpsFound, false, &CStats::TotalNumberOfUniqueJumps);
STAT_LINE("DAYSPS", &CStats::DaysPassed, false, nil);
if (CGame::nastyGame) {
STAT_LINE("PE_WAST", &CStats::PeopleKilledByPlayer, false, nil);
@@ -5599,6 +5737,7 @@ CMenuManager::ConstructStatLine(int rowIdx)
#ifdef MORE_LANGUAGES
case LANGUAGE_POLISH:
case LANGUAGE_RUSSIAN:
+ case LANGUAGE_JAPANESE:
#endif
STAT_LINE("FESTDFM", &CStats::DistanceTravelledOnFoot, true, nil);
STAT_LINE("FESTDCM", &CStats::DistanceTravelledInVehicle, true, nil);
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index ef5279aa..e496f9c0 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -91,6 +91,7 @@ enum eLanguages
#ifdef MORE_LANGUAGES
LANGUAGE_POLISH,
LANGUAGE_RUSSIAN,
+ LANGUAGE_JAPANESE,
#endif
};
@@ -368,6 +369,10 @@ enum eMenuAction
#ifdef MORE_LANGUAGES
MENUACTION_LANG_PL,
MENUACTION_LANG_RUS,
+ MENUACTION_LANG_JAP,
+#endif
+#ifdef IMPROVED_VIDEOMODE
+ MENUACTION_SCREENMODE
#endif
};
@@ -531,6 +536,15 @@ public:
int32 m_nCurrSaveSlot;
int32 m_nScreenChangeDelayTimer;
+#ifdef IMPROVED_VIDEOMODE
+ int32 m_nPrefsWidth;
+ int32 m_nPrefsHeight;
+ int32 m_nPrefsDepth;
+ int32 m_nPrefsWindowed;
+ int32 m_nPrefsSubsystem;
+ int32 m_nSelectedScreenMode;
+#endif
+
public:
bool GetIsMenuActive() {return !!m_bMenuActive;}
@@ -643,7 +657,9 @@ public:
// uint8 GetNumberOfMenuOptions();
};
-static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error");
+#ifndef IMPROVED_VIDEOMODE
+VALIDATE_SIZE(CMenuManager, 0x564);
+#endif
extern CMenuManager FrontEndMenuManager;
extern unsigned long _dwOperatingSystemVersion; \ No newline at end of file
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 8ab12e3f..c50471f1 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -97,8 +97,8 @@ bool CGame::noProstitutes;
bool CGame::playingIntro;
char CGame::aDatFile[32];
#ifdef MORE_LANGUAGES
-bool CGame::polishGame = false;
bool CGame::russianGame = false;
+bool CGame::japaneseGame = false;
#endif
int gameTxdSlot;
@@ -306,24 +306,7 @@ bool CGame::Initialise(const char* datFile)
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
LoadingScreen("Loading the Game", "Setup streaming", nil);
-#ifdef USE_TXD_CDIMAGE
- int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
- if (txdHandle)
- CFileMgr::CloseFile(txdHandle);
- if (!CheckVideoCardCaps() && txdHandle) {
- CdStreamAddImage("MODELS\\TXD.IMG");
- CStreaming::Init();
- } else {
- CStreaming::Init();
- if (CreateTxdImageForVideoCard()) {
- CStreaming::Shutdown();
- CdStreamAddImage("MODELS\\TXD.IMG");
- CStreaming::Init();
- }
- }
-#else
CStreaming::Init();
-#endif
CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds();
CStreaming::RequestBigBuildings(LEVEL_NONE);
@@ -615,8 +598,9 @@ void CGame::Process(void)
TheCamera.SetMotionBlurAlpha(0);
if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL)
TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE);
-
+#ifdef DEBUGMENU
DebugMenuProcess();
+#endif
CCutsceneMgr::Update();
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
FrontEndMenuManager.Process();
diff --git a/src/core/Game.h b/src/core/Game.h
index 01f5f0e9..48f31abc 100644
--- a/src/core/Game.h
+++ b/src/core/Game.h
@@ -17,8 +17,8 @@ public:
static bool frenchGame;
static bool germanGame;
#ifdef MORE_LANGUAGES
- static bool polishGame;
static bool russianGame;
+ static bool japaneseGame;
#endif
static bool noProstitutes;
static bool playingIntro;
diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h
index e55ec49f..6c2ebdb8 100644
--- a/src/core/MenuScreens.h
+++ b/src/core/MenuScreens.h
@@ -62,6 +62,9 @@ const CMenuScreen aScreens[] = {
MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_WIDESCREEN, "FED_WIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_SCREENRES, "FED_RES", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
+#ifdef IMPROVED_VIDEOMODE
+ MENUACTION_SCREENMODE, "SCRFOR", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
+#endif
MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS,
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
@@ -76,6 +79,7 @@ const CMenuScreen aScreens[] = {
#ifdef MORE_LANGUAGES
MENUACTION_LANG_PL, "FEL_POL", SAVESLOT_NONE, MENUPAGE_NONE,
MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE,
+ MENUACTION_LANG_JAP, "FEL_JAP", SAVESLOT_NONE, MENUPAGE_NONE,
#endif
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
@@ -455,6 +459,8 @@ const CMenuScreen aScreens[] = {
#ifdef MENU_MAP
// MENUPAGE_MAP = 59
{ "FEG_MAP", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2,
+ MENUACTION_UNK110, "", SAVESLOT_NONE, MENUPAGE_NONE, // to prevent cross/enter to go back
+ MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
#endif
};
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 0a626570..da86d15e 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -55,6 +55,10 @@ CMouseControllerState CPad::OldMouseControllerState;
CMouseControllerState CPad::NewMouseControllerState;
CMouseControllerState CPad::PCTempMouseControllerState;
+#ifdef DETECT_PAD_INPUT_SWITCH
+bool CPad::IsAffectedByController = false;
+#endif
+
_TODO("gbFastTime");
extern bool gbFastTime;
@@ -102,12 +106,12 @@ void TankCheat()
CAutomobile *tank = new CAutomobile(MI_RHINO, MISSION_VEHICLE);
#endif
if (tank != nil) {
- CVector pos = ThePaths.m_pathNodes[node].pos;
+ CVector pos = ThePaths.m_pathNodes[node].GetPosition();
pos.z += 4.0f;
- tank->GetPosition() = pos;
+ tank->SetPosition(pos);
tank->SetOrientation(0.0f, 0.0f, DEGTORAD(200.0f));
- tank->m_status = STATUS_ABANDONED;
+ tank->SetStatus(STATUS_ABANDONED);
tank->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(tank);
}
@@ -325,6 +329,16 @@ void AltDodoCheat(void)
}
#endif
+#ifdef DETECT_PAD_INPUT_SWITCH
+bool
+CControllerState::IsAnyButtonPressed(void)
+{
+ return !!LeftStickX || !!LeftStickY || !!RightStickX || !!RightStickY || !!LeftShoulder1 || !!LeftShoulder2 || !!RightShoulder1 || !!RightShoulder2 ||
+ !!DPadUp || !!DPadDown || !!DPadLeft || !!DPadRight || !!Start || !!Select || !!Square || !!Triangle || !!Cross || !!Circle || !!LeftShock ||
+ !!RightShock || !!NetworkTalk;
+}
+#endif
+
void
CControllerState::Clear(void)
{
@@ -575,14 +589,15 @@ void CPad::UpdateMouse()
PCTempMouseControllerState.MXB1 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_4);
PCTempMouseControllerState.MXB2 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_5);
- PSGLOBAL(lastMousePos.x) = xpos;
- PSGLOBAL(lastMousePos.y) = ypos;
-
if (PSGLOBAL(mouseWheel) > 0)
PCTempMouseControllerState.WHEELUP = 1;
else if (PSGLOBAL(mouseWheel) < 0)
PCTempMouseControllerState.WHEELDN = 1;
+ PSGLOBAL(lastMousePos.x) = xpos;
+ PSGLOBAL(lastMousePos.y) = ypos;
+ PSGLOBAL(mouseWheel) = 0.0f;
+
OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState;
#endif
@@ -1001,7 +1016,7 @@ void CPad::AffectFromXinput(uint32 pad)
if (Abs(rx) > 0.3f || Abs(ry) > 0.3f) {
PCTempJoyState.RightStickX = (int32)(rx * 128.0f);
- PCTempJoyState.RightStickY = (int32)(ry * 128.0f);
+ PCTempJoyState.RightStickY = (int32)(-ry * 128.0f);
}
XINPUT_VIBRATION VibrationState;
@@ -1036,11 +1051,20 @@ void CPad::UpdatePads(void)
#else
CapturePad(0);
#endif
-
+#ifdef DETECT_PAD_INPUT_SWITCH
+ if (GetPad(0)->PCTempJoyState.IsAnyButtonPressed())
+ IsAffectedByController = true;
+ else {
+#endif
+ ControlsManager.ClearSimButtonPressCheckers();
+ ControlsManager.AffectPadFromKeyBoard();
+ ControlsManager.AffectPadFromMouse();
- ControlsManager.ClearSimButtonPressCheckers();
- ControlsManager.AffectPadFromKeyBoard();
- ControlsManager.AffectPadFromMouse();
+#ifdef DETECT_PAD_INPUT_SWITCH
+ }
+ if (IsAffectedByController && (GetPad(0)->PCTempKeyState.IsAnyButtonPressed() || GetPad(0)->PCTempMouseState.IsAnyButtonPressed()))
+ IsAffectedByController = false;
+#endif
if ( CReplay::IsPlayingBackFromFile() )
bUpdate = false;
@@ -1095,7 +1119,10 @@ void CPad::Update(int16 unk)
void CPad::DoCheats(void)
{
- GetPad(0)->DoCheats(0);
+#ifdef DETECT_PAD_INPUT_SWITCH
+ if (IsAffectedByController)
+#endif
+ GetPad(0)->DoCheats(0);
}
void CPad::DoCheats(int16 unk)
@@ -1153,13 +1180,19 @@ CPad *CPad::GetPad(int32 pad)
{
return &Pads[pad];
}
+#ifdef DETECT_PAD_INPUT_SWITCH
+#define CURMODE (IsAffectedByController ? Mode : 0)
+#else
+#define CURMODE (Mode)
+#endif
+
int16 CPad::GetSteeringLeftRight(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1191,8 +1224,8 @@ int16 CPad::GetSteeringUpDown(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1224,8 +1257,8 @@ int16 CPad::GetCarGunUpDown(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1251,8 +1284,8 @@ int16 CPad::GetCarGunLeftRight(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1278,8 +1311,8 @@ int16 CPad::GetPedWalkLeftRight(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1312,8 +1345,8 @@ int16 CPad::GetPedWalkUpDown(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1343,7 +1376,7 @@ int16 CPad::GetPedWalkUpDown(void)
int16 CPad::GetAnalogueUpDown(void)
{
- switch ( Mode )
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1408,8 +1441,8 @@ bool CPad::GetHorn(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
{
@@ -1447,8 +1480,8 @@ bool CPad::HornJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
{
@@ -1487,8 +1520,8 @@ bool CPad::GetCarGunFired(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1514,8 +1547,8 @@ bool CPad::CarGunJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1541,8 +1574,8 @@ int16 CPad::GetHandBrake(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1574,8 +1607,8 @@ int16 CPad::GetBrake(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1612,8 +1645,8 @@ bool CPad::GetExitVehicle(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1639,8 +1672,8 @@ bool CPad::ExitVehicleJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1666,8 +1699,8 @@ int32 CPad::GetWeapon(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1699,8 +1732,8 @@ bool CPad::WeaponJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1732,8 +1765,8 @@ int16 CPad::GetAccelerate(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1768,7 +1801,7 @@ int16 CPad::GetAccelerate(void)
bool CPad::CycleCameraModeUpJustDown(void)
{
- switch ( Mode )
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1792,7 +1825,7 @@ bool CPad::CycleCameraModeUpJustDown(void)
bool CPad::CycleCameraModeDownJustDown(void)
{
- switch ( Mode )
+ switch (CURMODE)
{
case 0:
case 2:
@@ -1818,8 +1851,8 @@ bool CPad::ChangeStationJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
{
@@ -1874,8 +1907,8 @@ bool CPad::GetTarget(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1901,8 +1934,8 @@ bool CPad::TargetJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -1936,8 +1969,8 @@ bool CPad::GetSprint(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2091,8 +2124,8 @@ bool CPad::ForceCameraBehindPlayer(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2124,8 +2157,8 @@ bool CPad::SniperZoomIn(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2151,8 +2184,8 @@ bool CPad::SniperZoomOut(void)
{
if ( ArePlayerControlsDisabled() )
return false;
-
- switch ( Mode )
+
+ switch (CURMODE)
{
case 0:
case 1:
@@ -2174,6 +2207,7 @@ bool CPad::SniperZoomOut(void)
return false;
}
+#undef CURMODE
int16 CPad::SniperModeLookLeftRight(void)
{
@@ -2189,6 +2223,9 @@ int16 CPad::SniperModeLookLeftRight(void)
int16 CPad::SniperModeLookUpDown(void)
{
int16 axis = NewState.LeftStickY;
+#ifdef FIX_BUGS
+ axis = -axis;
+#endif
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
if ( Abs(axis) > Abs(dpad) )
@@ -2215,7 +2252,11 @@ int16 CPad::LookAroundLeftRight(void)
int16 CPad::LookAroundUpDown(void)
{
int16 axis = GetPad(0)->NewState.RightStickY;
-
+
+#ifdef FIX_BUGS
+ axis = -axis;
+#endif
+
if ( Abs(axis) > 85 && !GetLookBehindForPed() )
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
* (127.0f / 32.0f) ); // 3.96875f
diff --git a/src/core/Pad.h b/src/core/Pad.h
index b8228444..ea771f81 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -29,6 +29,9 @@ public:
float GetRightStickX(void) { return RightStickX/32767.0f; };
float GetRightStickY(void) { return RightStickY/32767.0f; };
+#ifdef DETECT_PAD_INPUT_SWITCH
+ bool IsAnyButtonPressed();
+#endif
void Clear(void);
};
VALIDATE_SIZE(CControllerState, 0x2A);
@@ -158,7 +161,10 @@ public:
int32 LastTimeTouched;
int32 AverageWeapon;
int32 AverageEntries;
-
+
+#ifdef DETECT_PAD_INPUT_SWITCH
+ static bool IsAffectedByController;
+#endif
CPad() { }
~CPad() { }
@@ -418,6 +424,7 @@ public:
bool GetLeftStickYJustDown() { return !!(NewState.LeftStickY && !OldState.LeftStickY); }
bool GetTriangleJustUp() { return !!(!NewState.Triangle && OldState.Triangle); }
+ bool GetCircleJustUp() { return !!(!NewState.Circle && OldState.Circle); }
bool GetCrossJustUp() { return !!(!NewState.Cross && OldState.Cross); }
bool GetSquareJustUp() { return !!(!NewState.Square && OldState.Square); }
bool GetDPadUpJustUp() { return !!(!NewState.DPadUp && OldState.DPadUp); }
diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp
index 99ca5659..69b3d3ea 100644
--- a/src/core/Placeable.cpp
+++ b/src/core/Placeable.cpp
@@ -12,9 +12,9 @@ CPlaceable::~CPlaceable(void) = default;
void
CPlaceable::SetHeading(float angle)
{
- CVector pos = GetPosition();
+ CVector pos = GetMatrix().GetPosition();
m_matrix.SetRotateZ(angle);
- GetPosition() += pos;
+ GetMatrix().Translate(pos);
}
bool
diff --git a/src/core/Placeable.h b/src/core/Placeable.h
index 2df26a7c..970c0d48 100644
--- a/src/core/Placeable.h
+++ b/src/core/Placeable.h
@@ -10,7 +10,13 @@ public:
CPlaceable(void);
virtual ~CPlaceable(void);
- CVector &GetPosition(void) { return m_matrix.GetPosition(); }
+ const CVector &GetPosition(void) { return m_matrix.GetPosition(); }
+ void SetPosition(float x, float y, float z) {
+ m_matrix.GetPosition().x = x;
+ m_matrix.GetPosition().y = y;
+ m_matrix.GetPosition().z = z;
+ }
+ void SetPosition(const CVector &pos) { m_matrix.GetPosition() = pos; }
CVector &GetRight(void) { return m_matrix.GetRight(); }
CVector &GetForward(void) { return m_matrix.GetForward(); }
CVector &GetUp(void) { return m_matrix.GetUp(); }
@@ -25,4 +31,5 @@ public:
bool IsWithinArea(float x1, float y1, float x2, float y2);
bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2);
};
-static_assert(sizeof(CPlaceable) == 0x4C, "CPlaceable: error"); \ No newline at end of file
+
+VALIDATE_SIZE(CPlaceable, 0x4C);
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index e92f7568..ec6d3023 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -38,7 +38,7 @@ CPlayerInfo::SetPlayerSkin(char *skin)
LoadPlayerSkin();
}
-CVector&
+const CVector &
CPlayerInfo::GetPos()
{
#ifdef FIX_BUGS
@@ -328,7 +328,7 @@ CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1,
continue;
car->m_scanCode = CWorld::GetCurrentScanCode();
- if (car->m_status != STATUS_WRECKED && car->m_status != STATUS_TRAIN_MOVING
+ if (car->GetStatus() != STATUS_WRECKED && car->GetStatus() != STATUS_TRAIN_MOVING
&& (car->GetUp().z > 0.3f || (car->IsVehicle() && ((CVehicle*)car)->m_vehType == VEHICLE_TYPE_BIKE))) {
CVector carCentre = car->GetBoundCentre();
@@ -354,7 +354,7 @@ CPlayerInfo::Process(void)
bool startTaxiTimer = true;
if (m_bUnusedTaxiThing && m_pPed->bInVehicle) {
CVehicle *veh = m_pPed->m_pMyVehicle;
- if ((veh->m_modelIndex == MI_TAXI || veh->m_modelIndex == MI_CABBIE || veh->m_modelIndex == MI_BORGNINE)
+ if ((veh->GetModelIndex() == MI_TAXI || veh->GetModelIndex() == MI_CABBIE || veh->GetModelIndex() == MI_BORGNINE)
&& veh->pDriver == m_pPed && veh->m_nNumPassengers != 0) {
for (uint32 timePassed = CTimer::GetTimeInMilliseconds() - m_nUnusedTaxiTimer; timePassed >= 1000; m_nUnusedTaxiTimer += 1000) {
timePassed -= 1000;
@@ -407,13 +407,13 @@ CPlayerInfo::Process(void)
if (m_pPed->bInVehicle) {
if (!m_pRemoteVehicle) {
CEntity *surfaceBelowVeh = m_pPed->m_pMyVehicle->m_pCurGroundEntity;
- if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->m_modelIndex)) {
+ if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->GetModelIndex())) {
CVehicle *veh = m_pPed->m_pMyVehicle;
if (!veh->IsBoat() || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
// This condition will always return true, else block was probably WIP Miami code.
if (veh->m_vehType != VEHICLE_TYPE_BIKE || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {
- if (veh->m_status != STATUS_WRECKED && veh->m_status != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) {
+ if (veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) {
if (veh->m_vecMoveSpeed.Magnitude() < 0.17f && CTimer::GetTimeScale() >= 0.5f && !veh->bIsInWater) {
m_pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh);
}
@@ -430,7 +430,7 @@ CPlayerInfo::Process(void)
CPed::PedSetOutCarCB(0, m_pPed);
CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
CAnimManager::BlendAnimation(m_pPed->GetClump(), ASSOCGRP_STD, ANIM_FALL_LAND, 100.0f);
- m_pPed->GetPosition() = sth;
+ m_pPed->SetPosition(sth);
m_pPed->SetMoveState(PEDMOVE_STILL);
m_pPed->m_vecMoveSpeed = veh->m_vecMoveSpeed;
}
@@ -454,9 +454,9 @@ CPlayerInfo::Process(void)
weAreOnBoat = true;
m_pPed->bOnBoat = true;
#ifdef VC_PED_PORTS
- if (carBelow->m_status != STATUS_WRECKED && carBelow->GetUp().z > 0.3f)
+ if (carBelow->GetStatus() != STATUS_WRECKED && carBelow->GetUp().z > 0.3f)
#else
- if (carBelow->m_status != STATUS_WRECKED)
+ if (carBelow->GetStatus() != STATUS_WRECKED)
#endif
m_pPed->SetSeekBoatPosition(carBelow);
}
@@ -491,7 +491,7 @@ CPlayerInfo::Process(void)
}
// carBelow is now closest vehicle
if (carBelow && !weAreOnBoat) {
- if (carBelow->m_status == STATUS_TRAIN_NOT_MOVING) {
+ if (carBelow->GetStatus() == STATUS_TRAIN_NOT_MOVING) {
m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, carBelow);
} else if (carBelow->IsBoat()) {
if (!carBelow->pDriver) {
@@ -526,7 +526,7 @@ CPlayerInfo::Process(void)
m_bInRemoteMode = false;
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = nil;
if (FindPlayerVehicle()) {
- FindPlayerVehicle()->m_status = STATUS_PLAYER;
+ FindPlayerVehicle()->SetStatus(STATUS_PLAYER);
}
}
}
diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h
index ff31418c..94410753 100644
--- a/src/core/PlayerInfo.h
+++ b/src/core/PlayerInfo.h
@@ -62,7 +62,7 @@ public:
void DeletePlayerSkin();
void AwardMoneyForExplosion(CVehicle *vehicle);
void SetPlayerSkin(char* skin);
- CVector& GetPos();
+ const CVector &GetPos();
void Process(void);
void KillPlayer(void);
void ArrestPlayer(void);
@@ -81,4 +81,4 @@ public:
~CPlayerInfo() { };
};
-static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error");
+VALIDATE_SIZE(CPlayerInfo, 0x13C);
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index 4f4588da..bc65f6b6 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -88,7 +88,7 @@ CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
delete object;
} else if (!CProjectileInfo::RemoveIfThisIsAProjectile(object)) {
// relocate to another slot??
- CObject *newObject = new CObject();
+ CObject *newObject = new CObject(object->GetModelIndex(), false);
CWorld::Remove(object);
memcpy(newObject, object, ms_pObjectPool->GetMaxEntrySize());
CWorld::Add(newObject);
@@ -110,13 +110,24 @@ INITSAVEBUF
CStreaming::LoadAllRequestedModels(false);
int32 slot = ReadSaveBuf<int32>(buf);
CVehicle* pVehicle;
- char* vbuf = new char[Max(sizeof(CAutomobile), sizeof(CBoat))];
+#ifdef COMPATIBLE_SAVES
+ if (type == VEHICLE_TYPE_BOAT)
+ pVehicle = new(slot) CBoat(model, RANDOM_VEHICLE);
+ else if (type == VEHICLE_TYPE_CAR)
+ pVehicle = new(slot) CAutomobile(model, RANDOM_VEHICLE);
+ else
+ assert(0);
+ --CCarCtrl::NumRandomCars;
+ pVehicle->Load(buf);
+ CWorld::Add(pVehicle);
+#else
+ char* vbuf = new char[Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize)];
if (type == VEHICLE_TYPE_BOAT) {
memcpy(vbuf, buf, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));
CBoat* pBoat = new(slot) CBoat(model, RANDOM_VEHICLE);
pVehicle = pBoat;
- --CCarCtrl::NumRandomCars; // why?
+ --CCarCtrl::NumRandomCars;
}
else if (type == VEHICLE_TYPE_CAR) {
memcpy(vbuf, buf, sizeof(CAutomobile));
@@ -161,13 +172,14 @@ INITSAVEBUF
pVehicle->m_nTimeOfDeath = pBufferVehicle->m_nTimeOfDeath;
#endif
pVehicle->m_nDoorLock = pBufferVehicle->m_nDoorLock;
- pVehicle->m_status = pBufferVehicle->m_status;
- pVehicle->m_type = pBufferVehicle->m_type;
+ pVehicle->SetStatus(pBufferVehicle->GetStatus());
+ pVehicle->SetType(pBufferVehicle->GetType());
(pVehicle->GetAddressOfEntityProperties())[0] = (pBufferVehicle->GetAddressOfEntityProperties())[0];
(pVehicle->GetAddressOfEntityProperties())[1] = (pBufferVehicle->GetAddressOfEntityProperties())[1];
pVehicle->AutoPilot = pBufferVehicle->AutoPilot;
CWorld::Add(pVehicle);
delete[] vbuf;
+#endif
}
VALIDATESAVEBUF(size)
}
@@ -184,7 +196,7 @@ INITSAVEBUF
continue;
bool bHasPassenger = false;
for (int j = 0; j < ARRAY_SIZE(pVehicle->pPassengers); j++) {
- if (pVehicle->pPassengers[i])
+ if (pVehicle->pPassengers[j])
bHasPassenger = true;
}
if (!pVehicle->pDriver && !bHasPassenger) {
@@ -194,8 +206,8 @@ INITSAVEBUF
++nNumBoats;
}
}
- *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + sizeof(CAutomobile)) + sizeof(int) +
- nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + sizeof(CBoat)) + sizeof(int);
+ *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CAutomobile::nSaveStructSize) + sizeof(int) +
+ nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int);
WriteSaveBuf(buf, nNumCars);
WriteSaveBuf(buf, nNumBoats);
for (int i = 0; i < nPoolSize; i++) {
@@ -208,20 +220,29 @@ INITSAVEBUF
bHasPassenger = true;
}
if (!pVehicle->pDriver && !bHasPassenger) {
+#ifdef COMPATIBLE_SAVES
+ if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
+ WriteSaveBuf<uint32>(buf, pVehicle->m_vehType);
+ WriteSaveBuf<int16>(buf, pVehicle->GetModelIndex());
+ WriteSaveBuf<int32>(buf, GetVehicleRef(pVehicle));
+ pVehicle->Save(buf);
+ }
+#else
if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
- WriteSaveBuf(buf, pVehicle->m_modelIndex);
+ WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CAutomobile));
SkipSaveBuf(buf, sizeof(CAutomobile));
}
if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
- WriteSaveBuf(buf, pVehicle->m_modelIndex);
+ WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));
}
+#endif
}
}
VALIDATESAVEBUF(*size)
@@ -258,7 +279,7 @@ INITSAVEBUF
bool bHasBeenDamaged = pObject->bHasBeenDamaged;
bool bUseVehicleColours = pObject->bUseVehicleColours;
CCompressedMatrixNotAligned tmp;
- WriteSaveBuf(buf, pObject->m_modelIndex);
+ WriteSaveBuf(buf, pObject->GetModelIndex());
WriteSaveBuf(buf, GetObjectRef(pObject));
tmp.CompressFromFullMatrix(pObject->GetMatrix());
WriteSaveBuf(buf, tmp);
@@ -279,8 +300,12 @@ INITSAVEBUF
WriteSaveBuf(buf, pObject->m_nCollisionDamageEffect);
WriteSaveBuf(buf, pObject->m_nSpecialCollisionResponseCases);
WriteSaveBuf(buf, pObject->m_nEndOfLifeTime);
+#ifdef COMPATIBLE_SAVES
+ pObject->SaveEntityFlags(buf);
+#else
WriteSaveBuf(buf, (pObject->GetAddressOfEntityProperties())[0]);
WriteSaveBuf(buf, (pObject->GetAddressOfEntityProperties())[1]);
+#endif
}
}
VALIDATESAVEBUF(*size)
@@ -315,12 +340,17 @@ INITSAVEBUF
pBufferObject->m_nCollisionDamageEffect = ReadSaveBuf<uint8>(buf);
pBufferObject->m_nSpecialCollisionResponseCases = ReadSaveBuf<uint8>(buf);
pBufferObject->m_nEndOfLifeTime = ReadSaveBuf<uint32>(buf);
+#ifndef COMPATIBLE_SAVES
(pBufferObject->GetAddressOfEntityProperties())[0] = ReadSaveBuf<uint32>(buf);
(pBufferObject->GetAddressOfEntityProperties())[1] = ReadSaveBuf<uint32>(buf);
+#endif
if (GetObjectPool()->GetSlot(ref >> 8))
CPopulation::ConvertToDummyObject(GetObjectPool()->GetSlot(ref >> 8));
CObject* pObject = new(ref) CObject(mi, false);
pObject->GetMatrix() = pBufferObject->GetMatrix();
+#ifdef COMPATIBLE_SAVES
+ pObject->LoadEntityFlags(buf);
+#endif
pObject->m_fUprootLimit = pBufferObject->m_fUprootLimit;
pObject->m_objectMatrix = pBufferObject->m_objectMatrix;
pObject->ObjectCreatedBy = pBufferObject->ObjectCreatedBy;
@@ -335,8 +365,10 @@ INITSAVEBUF
pObject->m_nCollisionDamageEffect = pBufferObject->m_nCollisionDamageEffect;
pObject->m_nSpecialCollisionResponseCases = pBufferObject->m_nSpecialCollisionResponseCases;
pObject->m_nEndOfLifeTime = pBufferObject->m_nEndOfLifeTime;
+#ifndef COMPATIBLE_SAVES
(pObject->GetAddressOfEntityProperties())[0] = (pBufferObject->GetAddressOfEntityProperties())[0];
(pObject->GetAddressOfEntityProperties())[1] = (pBufferObject->GetAddressOfEntityProperties())[1];
+#endif
pObject->bHasCollided = false;
CWorld::Add(pObject);
delete[] obuf;
@@ -356,7 +388,7 @@ INITSAVEBUF
if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1)
nNumPeds++;
}
- *size = sizeof(int) + nNumPeds * (sizeof(uint32) + sizeof(int16) + sizeof(int) + sizeof(CPlayerPed) +
+ *size = sizeof(int) + nNumPeds * (sizeof(uint32) + sizeof(int16) + sizeof(int) + CPlayerPed::nSaveStructSize +
sizeof(CWanted::MaximumWantedLevel) + sizeof(CWanted::nMaximumWantedLevel) + MAX_MODEL_NAME);
WriteSaveBuf(buf, nNumPeds);
for (int i = 0; i < nPoolSize; i++) {
@@ -365,10 +397,14 @@ INITSAVEBUF
continue;
if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1) {
WriteSaveBuf(buf, pPed->m_nPedType);
- WriteSaveBuf(buf, pPed->m_modelIndex);
+ WriteSaveBuf(buf, pPed->GetModelIndex());
WriteSaveBuf(buf, GetPedRef(pPed));
+#ifdef COMPATIBLE_SAVES
+ pPed->Save(buf);
+#else
memcpy(buf, pPed, sizeof(CPlayerPed));
SkipSaveBuf(buf, sizeof(CPlayerPed));
+#endif
WriteSaveBuf(buf, CWanted::MaximumWantedLevel);
WriteSaveBuf(buf, CWanted::nMaximumWantedLevel);
memcpy(buf, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetName(), MAX_MODEL_NAME);
@@ -386,6 +422,34 @@ INITSAVEBUF
uint32 pedtype = ReadSaveBuf<uint32>(buf);
int16 model = ReadSaveBuf<int16>(buf);
int ref = ReadSaveBuf<int>(buf);
+#ifdef COMPATIBLE_SAVES
+ CPed* pPed;
+
+ char name[MAX_MODEL_NAME];
+ // Unfortunate hack: player model is stored after ped structure.
+ // It could be avoided by just using "player" because in practice it is always true.
+ memcpy(name, buf + CPlayerPed::nSaveStructSize + 2 * sizeof(int32), MAX_MODEL_NAME);
+ CStreaming::RequestSpecialModel(model, name, STREAMFLAGS_DONT_REMOVE);
+ CStreaming::LoadAllRequestedModels(false);
+
+ if (pedtype == PEDTYPE_PLAYER1)
+ pPed = new(ref) CPlayerPed();
+ else
+ assert(0);
+
+ pPed->Load(buf);
+ if (pedtype == PEDTYPE_PLAYER1) {
+ CWanted::MaximumWantedLevel = ReadSaveBuf<int32>(buf);
+ CWanted::nMaximumWantedLevel = ReadSaveBuf<int32>(buf);
+ SkipSaveBuf(buf, MAX_MODEL_NAME);
+ }
+
+ if (pedtype == PEDTYPE_PLAYER1) {
+ pPed->m_wepAccuracy = 100;
+ CWorld::Players[0].m_pPed = (CPlayerPed*)pPed;
+ }
+ CWorld::Add(pPed);
+#else
char* pbuf = new char[sizeof(CPlayerPed)];
CPlayerPed* pBufferPlayer = (CPlayerPed*)pbuf;
CPed* pPed;
@@ -416,12 +480,14 @@ INITSAVEBUF
pPed->m_maxWeaponTypeAllowed = pBufferPlayer->m_maxWeaponTypeAllowed;
for (int i = 0; i < WEAPONTYPE_TOTAL_INVENTORY_WEAPONS; i++)
pPed->m_weapons[i] = pBufferPlayer->m_weapons[i];
+
if (pedtype == PEDTYPE_PLAYER1) {
pPed->m_wepAccuracy = 100;
CWorld::Players[0].m_pPed = (CPlayerPed*)pPed;
}
CWorld::Add(pPed);
delete[] pbuf;
+#endif
}
VALIDATESAVEBUF(size)
}
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 2b3e6f1e..9406f1bd 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -66,9 +66,17 @@ CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
&WeaponSprite
};
+// Why this doesn't coincide with world coordinates i don't know
+#define RADAR_MIN_X (-2000.0f)
+#define RADAR_MIN_Y (-2000.0f)
+#define RADAR_MAX_X (2000.0f)
+#define RADAR_MAX_Y (2000.0f)
+#define RADAR_SIZE_X (RADAR_MAX_X - RADAR_MIN_X)
+#define RADAR_SIZE_Y (RADAR_MAX_Y - RADAR_MIN_Y)
+
#define RADAR_NUM_TILES (8)
-#define RADAR_TILE_SIZE (WORLD_SIZE_X / RADAR_NUM_TILES)
-static_assert(RADAR_TILE_SIZE == (WORLD_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square");
+#define RADAR_TILE_SIZE (RADAR_SIZE_X / RADAR_NUM_TILES)
+static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square");
#define RADAR_MIN_RANGE (120.0f)
#define RADAR_MAX_RANGE (350.0f)
@@ -523,8 +531,8 @@ void CRadar::DrawBlips()
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else {
#ifdef TRIANGULAR_BLIPS
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = blipEntity->GetPosition();
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = blipEntity->GetPosition();
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -562,8 +570,8 @@ void CRadar::DrawBlips()
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} else {
#ifdef TRIANGULAR_BLIPS
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -629,8 +637,8 @@ void CRadar::DrawBlips()
else
#ifdef TRIANGULAR_BLIPS
{
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = blipEntity->GetPosition();
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = blipEntity->GetPosition();
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -678,8 +686,8 @@ void CRadar::DrawBlips()
else
#ifdef TRIANGULAR_BLIPS
{
- CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
- CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
+ const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift();
+ const CVector &blipPos = ms_RadarTrace[blipId].m_vecPos;
uint8 mode = BLIP_MODE_TRIANGULAR_UP;
if (blipPos.z - pos.z <= 2.0f) {
if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN;
@@ -738,8 +746,8 @@ void CRadar::DrawRadarMap()
DrawRadarMask();
// top left ist (0, 0)
- int x = floorf((vec2DRadarOrigin.x - WORLD_MIN_X) / RADAR_TILE_SIZE);
- int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - WORLD_MIN_Y) / RADAR_TILE_SIZE);
+ int x = floorf((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE);
+ int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE);
StreamRadarSections(x, y);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
@@ -1064,6 +1072,13 @@ void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size)
INITSAVEBUF
WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE);
+#ifdef MENU_MAP
+ if (TargetMarkerId != -1) {
+ ClearBlip(TargetMarkerId);
+ TargetMarkerId = -1;
+ }
+#endif
+
for (int i = 0; i < NUMRADARBLIPS; i++)
WriteSaveBuf(buf, ms_RadarTrace[i]);
@@ -1253,8 +1268,8 @@ void CRadar::StreamRadarSections(int32 x, int32 y)
void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int32 x, int32 y)
{
- out.x = in.x - (x * RADAR_TILE_SIZE + WORLD_MIN_X);
- out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + WORLD_MIN_Y));
+ out.x = in.x - (x * RADAR_TILE_SIZE + RADAR_MIN_X);
+ out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + RADAR_MIN_Y));
out.x /= RADAR_TILE_SIZE;
out.y /= RADAR_TILE_SIZE;
}
@@ -1420,9 +1435,9 @@ CRadar::DrawYouAreHereSprite(float x, float y)
if (show) {
float left = x - SCREEN_SCALE_X(12.0f);
- float top = y - SCREEN_SCALE_Y(2.0f);
+ float top = y;
float right = SCREEN_SCALE_X(12.0) + x;
- float bottom = y - SCREEN_SCALE_Y(26.0f);
+ float bottom = y - SCREEN_SCALE_Y(24.0f);
CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255));
}
MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE;
diff --git a/src/core/Radar.h b/src/core/Radar.h
index e39a17f0..7d07671d 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -71,7 +71,7 @@ struct sRadarTrace
uint16 m_eBlipDisplay; // eBlipDisplay
uint16 m_eRadarSprite; // eRadarSprite
};
-static_assert(sizeof(sRadarTrace) == 0x30, "sRadarTrace: error");
+VALIDATE_SIZE(sRadarTrace, 0x30);
// Values for screen space
#define RADAR_LEFT (40.0f)
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index a76e9038..f24192ef 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -114,7 +114,7 @@ CStreamingInfo::RemoveFromList(void)
}
void
-CStreaming::Init(void)
+CStreaming::Init2(void)
{
int i;
@@ -244,6 +244,29 @@ CStreaming::Init(void)
}
void
+CStreaming::Init(void)
+{
+#ifdef USE_TXD_CDIMAGE
+ int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
+ if (txdHandle)
+ CFileMgr::CloseFile(txdHandle);
+ if (!CheckVideoCardCaps() && txdHandle) {
+ CdStreamAddImage("MODELS\\TXD.IMG");
+ CStreaming::Init2();
+ } else {
+ CStreaming::Init2();
+ if (CreateTxdImageForVideoCard()) {
+ CStreaming::Shutdown();
+ CdStreamAddImage("MODELS\\TXD.IMG");
+ CStreaming::Init2();
+ }
+ }
+#else
+ CStreaming::Init();
+#endif
+}
+
+void
CStreaming::Shutdown(void)
{
RwFreeAlign(ms_pStreamingBuffer[0]);
@@ -294,6 +317,7 @@ CStreaming::Update(void)
LoadRequestedModels();
+
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
prev = si->m_prev;
if((si->m_flags & (STREAMFLAGS_KEEP_IN_MEMORY|STREAMFLAGS_PRIORITY)) == 0)
@@ -435,7 +459,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(mi->IsSimple()){
success = CFileLoader::LoadAtomicFile(stream, streamId);
- }else if(mi->m_type == MITYPE_VEHICLE){
+ } else if (mi->GetModelType() == MITYPE_VEHICLE) {
// load vehicles in two parts
CModelInfo::GetModelInfo(streamId)->AddRef();
success = CFileLoader::StartLoadClumpFile(stream, streamId);
@@ -499,7 +523,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(streamId < STREAM_OFFSET_TXD){
// Model
// Vehicles and Peds not in loaded list
- if(mi->m_type != MITYPE_VEHICLE && mi->m_type != MITYPE_PED){
+ if (mi->GetModelType() != MITYPE_VEHICLE && mi->GetModelType() != MITYPE_PED) {
CSimpleModelInfo *smi = (CSimpleModelInfo*)mi;
// Set fading for some objects
@@ -510,12 +534,12 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
smi->m_alpha = 0;
}
- if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0)
+ if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList);
}
}else{
// Txd
- if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0)
+ if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList);
}
@@ -628,7 +652,7 @@ CStreaming::RequestModel(int32 id, int32 flags)
// reinsert into list
if(ms_aInfoForModel[id].m_next){
ms_aInfoForModel[id].RemoveFromList();
- if((ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0)
+ if((ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0)
ms_aInfoForModel[id].AddToList(&ms_startLoadedList);
}
}else if(ms_aInfoForModel[id].m_loadState == STREAMSTATE_NOTLOADED ||
@@ -689,6 +713,8 @@ CStreaming::RequestSubway(void)
}
}
+#define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY
+
void
CStreaming::RequestBigBuildings(eLevelName level)
{
@@ -699,7 +725,7 @@ CStreaming::RequestBigBuildings(eLevelName level)
for(i = n; i >= 0; i--){
b = CPools::GetBuildingPool()->GetSlot(i);
if(b && b->bIsBIGBuilding && b->m_level == level)
- RequestModel(b->GetModelIndex(), STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS);
}
RequestIslands(level);
ms_hasLoadedLODs = false;
@@ -710,16 +736,16 @@ CStreaming::RequestIslands(eLevelName level)
{
switch(level){
case LEVEL_INDUSTRIAL:
- RequestModel(islandLODcomInd, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
- RequestModel(islandLODsubInd, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(islandLODcomInd, BIGBUILDINGFLAGS);
+ RequestModel(islandLODsubInd, BIGBUILDINGFLAGS);
break;
case LEVEL_COMMERCIAL:
- RequestModel(islandLODindust, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
- RequestModel(islandLODsubCom, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(islandLODindust, BIGBUILDINGFLAGS);
+ RequestModel(islandLODsubCom, BIGBUILDINGFLAGS);
break;
case LEVEL_SUBURBAN:
- RequestModel(islandLODindust, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
- RequestModel(islandLODcomSub, STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
+ RequestModel(islandLODindust, BIGBUILDINGFLAGS);
+ RequestModel(islandLODcomSub, BIGBUILDINGFLAGS);
break;
}
}
@@ -858,7 +884,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -871,7 +897,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -884,7 +910,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered && ((CObject*)e)->ObjectCreatedBy == GAME_OBJECT){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -897,7 +923,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -972,7 +998,7 @@ CStreaming::RemoveBigBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){
e->DeleteRwObject();
- if(mi->m_refCount == 0)
+ if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex());
}
}
@@ -990,8 +1016,7 @@ CStreaming::RemoveLoadedVehicle(void)
ms_lastVehicleDeleted = 0;
id = ms_vehiclesLoaded[ms_lastVehicleDeleted];
if(id != -1 &&
- (ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 &&
- CModelInfo::GetModelInfo(id)->m_refCount == 0 &&
+ (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0 && CModelInfo::GetModelInfo(id)->GetNumRefs() == 0 &&
ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED)
goto found;
}
@@ -1012,7 +1037,7 @@ CStreaming::RemoveLeastUsedModel(void)
for(si = ms_endLoadedList.m_prev; si != &ms_startLoadedList; si = si->m_prev){
streamId = si - ms_aInfoForModel;
if(streamId < STREAM_OFFSET_TXD){
- if(CModelInfo::GetModelInfo(streamId)->m_refCount == 0){
+ if (CModelInfo::GetModelInfo(streamId)->GetNumRefs() == 0) {
RemoveModel(streamId);
return true;
}
@@ -1038,7 +1063,7 @@ CStreaming::RemoveAllUnusedModels(void)
for(i = NUM_DEFAULT_MODELS; i < MODELINFOSIZE; i++){
if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED &&
ms_aInfoForModel[i].m_flags & STREAMFLAGS_DONT_REMOVE &&
- CModelInfo::GetModelInfo(i)->m_refCount == 0){
+ CModelInfo::GetModelInfo(i)->GetNumRefs() == 0) {
RemoveModel(i);
ms_aInfoForModel[i].m_loadState = STREAMSTATE_NOTLOADED;
}
@@ -1129,8 +1154,7 @@ CStreaming::AddToLoadedVehiclesList(int32 modelId)
for(i = 0; i < MAXVEHICLESLOADED; i++){
id = ms_vehiclesLoaded[ms_lastVehicleDeleted];
if(id != -1 &&
- (ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 &&
- CModelInfo::GetModelInfo(id)->m_refCount == 0)
+ (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0 && CModelInfo::GetModelInfo(id)->GetNumRefs() == 0)
goto found;
ms_lastVehicleDeleted++;
if(ms_lastVehicleDeleted == MAXVEHICLESLOADED)
@@ -1202,7 +1226,7 @@ void
CStreaming::SetModelIsDeletable(int32 id)
{
ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_DONT_REMOVE;
- if((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->m_type != MITYPE_VEHICLE) &&
+ if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_SCRIPTOWNED) == 0){
if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED)
RemoveModel(id);
@@ -1221,7 +1245,7 @@ void
CStreaming::SetMissionDoesntRequireModel(int32 id)
{
ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_SCRIPTOWNED;
- if((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->m_type != MITYPE_VEHICLE) &&
+ if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_DONT_REMOVE) == 0){
if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED)
RemoveModel(id);
@@ -1307,7 +1331,7 @@ CStreaming::StreamVehiclesAndPeds(void)
for(i = 1; i <= 10; i++){
model = CCarCtrl::ChooseCarModel(modelQualityClass);
modelQualityClass++;
- if(modelQualityClass >= NUM_VEHICLE_CLASSES)
+ if(modelQualityClass >= CCarCtrl::TOTAL_CUSTOM_CLASSES)
modelQualityClass = 0;
// check if we want to load this model
@@ -1336,7 +1360,7 @@ CStreaming::StreamZoneModels(const CVector &pos)
// unload pevious group
if(ms_currentPedGrp != -1)
- for(i = 0; i < 8; i++){
+ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1)
break;
SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
@@ -1345,7 +1369,7 @@ CStreaming::StreamZoneModels(const CVector &pos)
ms_currentPedGrp = info.pedGroup;
- for(i = 0; i < 8; i++){
+ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1)
break;
RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE);
@@ -1431,7 +1455,6 @@ CStreaming::RemoveCurrentZonesModels(void)
}
-
// Find starting offset of the cdimage we next want to read
// Not useful at all on PC...
int32
@@ -1470,12 +1493,14 @@ CStreaming::GetCdImageOffset(int32 lastPosn)
}
inline bool
-TxdAvailable(int32 txdId)
+ModelNotLoaded(int32 modelId)
{
- CStreamingInfo *si = &CStreaming::ms_aInfoForModel[txdId + STREAM_OFFSET_TXD];
- return si->m_loadState == STREAMSTATE_LOADED || si->m_loadState == STREAMSTATE_READING;
+ CStreamingInfo *si = &CStreaming::ms_aInfoForModel[modelId];
+ return si->m_loadState != STREAMSTATE_LOADED && si->m_loadState != STREAMSTATE_READING;
}
+inline bool TxdNotLoaded(int32 txdId) { return ModelNotLoaded(txdId + STREAM_OFFSET_TXD); }
+
// Find stream id of next requested file in cdimage
int32
CStreaming::GetNextFileOnCd(int32 lastPosn, bool priority)
@@ -1500,10 +1525,15 @@ CStreaming::GetNextFileOnCd(int32 lastPosn, bool priority)
continue;
// request Txd if necessary
- if(streamId < STREAM_OFFSET_TXD &&
- !TxdAvailable(CModelInfo::GetModelInfo(streamId)->GetTxdSlot())){
- ReRequestTxd(CModelInfo::GetModelInfo(streamId)->GetTxdSlot());
- }else if(ms_aInfoForModel[streamId].GetCdPosnAndSize(posn, size)){
+ if(streamId < STREAM_OFFSET_TXD){
+ int txdId = CModelInfo::GetModelInfo(streamId)->GetTxdSlot();
+ if(TxdNotLoaded(txdId)){
+ ReRequestTxd(txdId);
+ continue;
+ }
+ }
+
+ if(ms_aInfoForModel[streamId].GetCdPosnAndSize(posn, size)){
if(posn < posnFirst){
// find first requested file in image
streamIdFirst = streamId;
@@ -1599,9 +1629,9 @@ CStreaming::RequestModelStream(int32 ch)
// Can't load certain combinations of files together
if(streamId < STREAM_OFFSET_TXD){
- if(havePed && CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_PED ||
- haveBigFile && CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_VEHICLE ||
- !TxdAvailable(CModelInfo::GetModelInfo(streamId)->GetTxdSlot()))
+ if (havePed && CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_PED ||
+ haveBigFile && CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_VEHICLE ||
+ TxdNotLoaded(CModelInfo::GetModelInfo(streamId)->GetTxdSlot()))
break;
}else{
if(haveBigFile && size > 200)
@@ -1619,9 +1649,9 @@ CStreaming::RequestModelStream(int32 ch)
break;
}
if(streamId < STREAM_OFFSET_TXD){
- if(CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_PED)
+ if (CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_PED)
havePed = 1;
- if(CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_VEHICLE)
+ if (CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_VEHICLE)
haveBigFile = 1;
}else{
if(size > 200)
@@ -1679,14 +1709,13 @@ CStreaming::ProcessLoadingChannel(int32 ch)
continue;
cdsize = ms_aInfoForModel[id].GetCdSize();
- if(id < STREAM_OFFSET_TXD &&
- CModelInfo::GetModelInfo(id)->m_type == MITYPE_VEHICLE &&
+ if(id < STREAM_OFFSET_TXD && CModelInfo::GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
ms_numVehiclesLoaded >= desiredNumVehiclesLoaded &&
!RemoveLoadedVehicle() &&
- ((ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 || GetAvailableVehicleSlot() == -1)){
+ ((ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0 || GetAvailableVehicleSlot() == -1)){
// can't load vehicle
RemoveModel(id);
- if(ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST)
+ if(ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE)
ReRequestModel(id);
else if(CTxdStore::GetNumRefs(CModelInfo::GetModelInfo(id)->GetTxdSlot()) == 0)
RemoveTxd(CModelInfo::GetModelInfo(id)->GetTxdSlot());
@@ -1953,7 +1982,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float
if(!e->bStreamingDontDelete && !e->bIsSubway &&
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
- if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())){
+ if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) {
lodDistSq = sq(mi->GetLargestLodDistance());
lodDistSq = Min(lodDistSq, sq(STREAM_DIST));
pos = CVector2D(e->GetPosition());
@@ -1983,7 +2012,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list)
if(!e->bStreamingDontDelete && !e->bIsSubway &&
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
- if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff()))
+ if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff()))
if(CRenderer::IsEntityCullZoneVisible(e))
RequestModel(e->GetModelIndex(), 0);
}
@@ -2349,7 +2378,7 @@ CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem)
if(!e->bStreamingDontDelete && !e->bImBeingRendered &&
e->m_rwObject && ms_aInfoForModel[e->GetModelIndex()].m_next){
e->DeleteRwObject();
- if(CModelInfo::GetModelInfo(e->GetModelIndex())->m_refCount == 0){
+ if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex());
if(ms_memoryUsed < mem)
return true;
@@ -2370,7 +2399,7 @@ CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem)
if(!e->bStreamingDontDelete && !e->bImBeingRendered &&
e->m_rwObject && !e->IsVisible() && ms_aInfoForModel[e->GetModelIndex()].m_next){
e->DeleteRwObject();
- if(CModelInfo::GetModelInfo(e->GetModelIndex())->m_refCount == 0){
+ if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex());
if(ms_memoryUsed < mem)
return true;
@@ -2400,7 +2429,7 @@ CStreaming::LoadScene(const CVector &pos)
CStreamingInfo *si, *prev;
eLevelName level;
- level = CTheZones::GetLevelFromPosition(pos);
+ level = CTheZones::GetLevelFromPosition(&pos);
debug("Start load scene\n");
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
prev = si->m_prev;
diff --git a/src/core/Streaming.h b/src/core/Streaming.h
index cf8790e9..84434769 100644
--- a/src/core/Streaming.h
+++ b/src/core/Streaming.h
@@ -3,8 +3,7 @@
#include "Game.h"
enum {
- STREAM_OFFSET_MODEL = 0,
- STREAM_OFFSET_TXD = STREAM_OFFSET_MODEL+MODELINFOSIZE,
+ STREAM_OFFSET_TXD = MODELINFOSIZE,
NUMSTREAMINFO = STREAM_OFFSET_TXD+TXDSTORESIZE
};
@@ -16,8 +15,7 @@ enum StreamFlags
STREAMFLAGS_PRIORITY = 0x08,
STREAMFLAGS_NOFADE = 0x10,
- // TODO: this isn't named well, maybe CANT_REMOVE?
- STREAMFLAGS_NOT_IN_LIST = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED,
+ STREAMFLAGS_CANT_REMOVE = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED,
STREAMFLAGS_KEEP_IN_MEMORY = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED|STREAMFLAGS_DEPENDENCY,
};
@@ -108,6 +106,7 @@ public:
static uint32 ms_memoryAvailable;
static void Init(void);
+ static void Init2(void);
static void Shutdown(void);
static void Update(void);
static void LoadCdDirectory(void);
@@ -115,6 +114,9 @@ public:
static bool ConvertBufferToObject(int8 *buf, int32 streamId);
static bool FinishLoadingLargeFile(int8 *buf, int32 streamId);
static bool HasModelLoaded(int32 id) { return ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED; }
+ static bool HasTxdLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_TXD); }
+ static bool CanRemoveModel(int32 id) { return (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0; }
+ static bool CanRemoveTxd(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_TXD); }
static void RequestModel(int32 model, int32 flags);
static void ReRequestModel(int32 model) { RequestModel(model, ms_aInfoForModel[model].m_flags); }
static void RequestTxd(int32 txd, int32 flags) { RequestModel(txd + STREAM_OFFSET_TXD, flags); }
diff --git a/src/core/Timer.h b/src/core/Timer.h
index 00a11409..004cda4d 100644
--- a/src/core/Timer.h
+++ b/src/core/Timer.h
@@ -56,6 +56,11 @@ public:
friend bool GenericLoad(void);
friend bool GenericSave(int file);
+
+#ifdef FIX_BUGS
+ static float GetDefaultTimeStep(void) { return 5.0f / 3.0f; }
+ static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); }
+#endif
};
#ifdef FIX_BUGS
diff --git a/src/core/User.cpp b/src/core/User.cpp
index 50eb7d9d..f906ae44 100644
--- a/src/core/User.cpp
+++ b/src/core/User.cpp
@@ -32,15 +32,15 @@ void
CPlaceName::Process()
{
CVector pos = CWorld::Players[CWorld::PlayerInFocus].GetPos();
- CZone *navigZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_TYPE1);
- CZone *audioZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_AUDIO);
+ CZone *navigZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_NAVIG);
+ CZone *defaultZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_DEFAULT);
if (navigZone == nil) m_pZone = nil;
- if (audioZone == nil) m_pZone2 = nil;
+ if (defaultZone == nil) m_pZone2 = nil;
if (navigZone == m_pZone) {
- if (audioZone == m_pZone2 || m_pZone != nil) {
- if (navigZone != nil || audioZone != nil) {
+ if (defaultZone == m_pZone2 || m_pZone != nil) {
+ if (navigZone != nil || defaultZone != nil) {
if (m_nAdditionalTimer != 0)
m_nAdditionalTimer--;
} else {
@@ -49,7 +49,7 @@ CPlaceName::Process()
m_pZone2 = nil;
}
} else {
- m_pZone2 = audioZone;
+ m_pZone2 = defaultZone;
m_nAdditionalTimer = 250;
}
} else {
diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp
index 6f5fdf06..7508c9f4 100644
--- a/src/core/Wanted.cpp
+++ b/src/core/Wanted.cpp
@@ -352,7 +352,7 @@ CWanted::WorkOutPolicePresence(CVector posn, float radius)
vehicle->bIsLawEnforcer &&
IsPoliceVehicleModel(vehicle->GetModelIndex()) &&
vehicle != FindPlayerVehicle() &&
- vehicle->m_status != STATUS_ABANDONED && vehicle->m_status != STATUS_WRECKED &&
+ vehicle->GetStatus() != STATUS_ABANDONED && vehicle->GetStatus() != STATUS_WRECKED &&
(posn - vehicle->GetPosition()).Magnitude() < radius)
numPolice++;
}
diff --git a/src/core/Wanted.h b/src/core/Wanted.h
index e3e407b0..de36c442 100644
--- a/src/core/Wanted.h
+++ b/src/core/Wanted.h
@@ -54,4 +54,4 @@ public:
static void SetMaximumWantedLevel(int32 level);
};
-static_assert(sizeof(CWanted) == 0x204, "CWanted: error");
+VALIDATE_SIZE(CWanted, 0x204);
diff --git a/src/core/World.cpp b/src/core/World.cpp
index b2a01b80..c884f1ed 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -1,4 +1,4 @@
-#include "World.h"
+#include "common.h"
#include "Camera.h"
#include "CarCtrl.h"
#include "CopPed.h"
@@ -26,7 +26,7 @@
#include "TempColModels.h"
#include "Vehicle.h"
#include "WaterLevel.h"
-#include "common.h"
+#include "World.h"
#define OBJECT_REPOSITION_OFFSET_Z 2.0f
@@ -75,7 +75,7 @@ CWorld::Add(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return;
- if(!ent->bIsStatic) ((CPhysical *)ent)->AddToMovingList();
+ if(!ent->IsStatic()) ((CPhysical *)ent)->AddToMovingList();
}
void
@@ -90,7 +90,7 @@ CWorld::Remove(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return;
- if(!ent->bIsStatic) ((CPhysical *)ent)->RemoveFromMovingList();
+ if(!ent->IsStatic()) ((CPhysical *)ent)->RemoveFromMovingList();
}
void
@@ -382,7 +382,7 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C
{
AdvanceCurrentScanCode();
CVector point2(point1.x, point1.y, z2);
- return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexX(point1.y)),
+ return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexY(point1.y)),
CColLine(point1, point2), point, entity, checkBuildings, checkVehicles,
checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly);
}
@@ -659,7 +659,7 @@ CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bo
}
void
-CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector &centre, float radius, bool ignoreZ, short *nextObject,
+CWorld::FindObjectsInRangeSectorList(CPtrList &list, Const CVector &centre, float radius, bool ignoreZ, short *nextObject,
short lastObject, CEntity **objects)
{
float radiusSqr = radius * radius;
@@ -685,7 +685,7 @@ CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector &centre, float radi
}
void
-CWorld::FindObjectsInRange(CVector &centre, float radius, bool ignoreZ, short *nextObject, short lastObject,
+CWorld::FindObjectsInRange(Const CVector &centre, float radius, bool ignoreZ, short *nextObject, short lastObject,
CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds,
bool checkObjects, bool checkDummies)
{
@@ -758,7 +758,7 @@ CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList &list, const
CEntity *pEntity = (CEntity *)pNode->item;
if(pEntity->m_scanCode != GetCurrentScanCode()) {
pEntity->m_scanCode = GetCurrentScanCode();
- if(modelId == pEntity->m_modelIndex) {
+ if (modelId == pEntity->GetModelIndex()) {
float fMagnitude = 0.0f;
if(bCheck2DOnly)
fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D();
@@ -953,14 +953,13 @@ CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float rad
float distance = diff.Magnitude();
if(e->GetBoundRadius() + radius > distance) {
- CColModel *eCol = CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel();
+ CColModel *eCol = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
int collidedSpheres =
CCollision::ProcessColModels(sphereMat, sphereCol, e->GetMatrix(), *eCol,
gaTempSphereColPoints, nil, nil);
if(collidedSpheres != 0 ||
- (e->IsVehicle() && ((CVehicle *)e)->m_vehType == VEHICLE_TYPE_CAR &&
- e->m_modelIndex != MI_DODO &&
+ (e->IsVehicle() && ((CVehicle *)e)->m_vehType == VEHICLE_TYPE_CAR && e->GetModelIndex() != MI_DODO &&
radius + eCol->boundingBox.max.x > distance)) {
return e;
}
@@ -1417,7 +1416,7 @@ FindPlayerSpeed(void)
return ped->m_vecMoveSpeed;
}
-CVector &
+const CVector &
FindPlayerCentreOfWorld(int32 player)
{
#ifdef FIX_BUGS
@@ -1429,7 +1428,7 @@ FindPlayerCentreOfWorld(int32 player)
return CWorld::Players[player].m_pPed->GetPosition();
}
-CVector &
+const CVector &
FindPlayerCentreOfWorld_NoSniperShift(void)
{
#ifdef FIX_BUGS
@@ -1618,7 +1617,7 @@ CWorld::RemoveFallenPeds(void)
if(ped->CharCreatedBy != RANDOM_CHAR || ped->IsPlayer()) {
int closestNode = ThePaths.FindNodeClosestToCoors(ped->GetPosition(), PATH_PED,
999999.9f, false, false);
- CVector newPos = ThePaths.m_pathNodes[closestNode].pos;
+ CVector newPos = ThePaths.m_pathNodes[closestNode].GetPosition();
newPos.z += 2.0f;
ped->Teleport(newPos);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
@@ -1642,7 +1641,7 @@ CWorld::RemoveFallenCars(void)
(veh->pDriver && veh->pDriver->IsPlayer())) {
int closestNode = ThePaths.FindNodeClosestToCoors(veh->GetPosition(), PATH_CAR,
999999.9f, false, false);
- CVector newPos = ThePaths.m_pathNodes[closestNode].pos;
+ CVector newPos = ThePaths.m_pathNodes[closestNode].GetPosition();
newPos.z += 3.0f;
veh->Teleport(newPos);
veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
@@ -1823,13 +1822,8 @@ CWorld::RepositionCertainDynamicObjects()
void
CWorld::RepositionOneObject(CEntity *pEntity)
{
- int16 modelId = pEntity->m_modelIndex;
- if(modelId == MI_SINGLESTREETLIGHTS1 || modelId == MI_SINGLESTREETLIGHTS2 ||
- modelId == MI_SINGLESTREETLIGHTS3 || modelId == MI_DOUBLESTREETLIGHTS || modelId == MI_TREE1 ||
- modelId == MI_TREE2 || modelId == MI_TREE3 || modelId == MI_TREE4 || modelId == MI_TREE5 ||
- modelId == MI_TREE6 || modelId == MI_TREE7 || modelId == MI_TREE8 || modelId == MI_TREE9 ||
- modelId == MI_TREE10 || modelId == MI_TREE11 || modelId == MI_TREE12 || modelId == MI_TREE13 ||
- modelId == MI_TREE14 || modelId == MI_TRAFFICLIGHTS || modelId == MI_PARKINGMETER ||
+ int16 modelId = pEntity->GetModelIndex();
+ if (IsTrafficLight(modelId) || IsTreeModel(modelId) || modelId == MI_PARKINGMETER ||
modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || modelId == MI_BIN || modelId == MI_POSTBOX1 ||
modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || modelId == MI_DUMP1 ||
modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 ||
@@ -1837,7 +1831,7 @@ CWorld::RepositionOneObject(CEntity *pEntity)
modelId == MI_FISHSTALL02 || modelId == MI_FISHSTALL03 || modelId == MI_FISHSTALL04 ||
modelId == MI_BAGELSTAND2 || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT ||
modelId == MI_PARKTABLE) {
- CVector &position = pEntity->GetPosition();
+ CVector &position = pEntity->GetMatrix().GetPosition();
float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z;
position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y,
position.z + OBJECT_REPOSITION_OFFSET_Z, nil) -
@@ -1855,7 +1849,7 @@ CWorld::RepositionOneObject(CEntity *pEntity)
if(!bFound || fWaterLevel > fGroundZ) {
CColModel *pColModel = pEntity->GetColModel();
float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z;
- pEntity->GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
+ pEntity->GetMatrix().GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
}
}
}
@@ -1867,7 +1861,7 @@ CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason)
int poolSize = CPools::GetVehiclePool()->GetSize();
for(int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
- if(veh && veh->m_status != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) {
+ if(veh && veh->GetStatus() != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) {
if(Abs(veh->GetPosition().z - z) < 5.0f && Abs(veh->GetPosition().x - x) < radius &&
Abs(veh->GetPosition().y - y) < radius)
gFireManager.StartFire(veh, reason, 0.8f, true);
@@ -1928,7 +1922,7 @@ CWorld::Process(void)
if(csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) {
RpAnimBlendClumpUpdateAnimations(csObj->GetClump(),
- 0.02f * (csObj->m_type == ENTITY_TYPE_OBJECT
+ 0.02f * (csObj->IsObject()
? CTimer::GetTimeStepNonClipped()
: CTimer::GetTimeStep()));
}
@@ -1946,7 +1940,7 @@ CWorld::Process(void)
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(),
- 0.02f * (movingEnt->m_type == ENTITY_TYPE_OBJECT
+ 0.02f * (movingEnt->IsObject()
? CTimer::GetTimeStepNonClipped()
: CTimer::GetTimeStep()));
}
@@ -1957,7 +1951,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else {
movingEnt->ProcessControl();
- if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); }
+ if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); }
}
}
bForceProcessControl = true;
@@ -1968,7 +1962,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else {
movingEnt->ProcessControl();
- if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); }
+ if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); }
}
}
}
@@ -2030,9 +2024,8 @@ CWorld::Process(void)
movingEnt->UpdateRwFrame();
if(!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
- if(movingEnt->m_status == STATUS_PLAYER) {
- printf("STUCK: Final Step: Player Entity %d Is Stuck\n",
- movingEnt->m_modelIndex);
+ if(movingEnt->GetStatus() == STATUS_PLAYER) {
+ printf("STUCK: Final Step: Player Entity %d Is Stuck\n", movingEnt->GetModelIndex());
movingEnt->m_vecMoveSpeed *= 0.3f;
movingEnt->ApplyMoveSpeed();
movingEnt->ApplyTurnSpeed();
@@ -2122,15 +2115,15 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
CObject *pObject = (CObject *)pEntity;
CVehicle *pVehicle = (CVehicle *)pEntity;
if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) {
- if(pEntity->bIsStatic) {
+ if(pEntity->IsStatic()) {
if(pEntity->IsObject()) {
- if(fPower > pObject->m_fUprootLimit || IsFence(pObject->m_modelIndex)) {
- if(IsGlass(pObject->m_modelIndex)) {
+ if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) {
+ if (IsGlass(pObject->GetModelIndex())) {
CGlass::WindowRespondsToExplosion(pObject, position);
} else {
pObject->bIsStatic = false;
pObject->AddToMovingList();
- int16 modelId = pEntity->m_modelIndex;
+ int16 modelId = pEntity->GetModelIndex();
if(modelId != MI_FIRE_HYDRANT ||
pObject->bHasBeenDamaged) {
if(pEntity->IsObject() &&
@@ -2146,7 +2139,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
}
}
}
- if(pEntity->bIsStatic) {
+ if(pEntity->IsStatic()) {
float fDamageMultiplier =
(fRadius - fMagnitude) * 2.0f / fRadius;
float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f);
@@ -2157,7 +2150,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
pEntity->AddToMovingList();
}
}
- if(!pEntity->bIsStatic) {
+ if(!pEntity->IsStatic()) {
float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f);
CVector vecForceDir =
vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier /
@@ -2178,10 +2171,10 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
pEntity->ApplyTurnForce(vecForceDir.x, vecForceDir.y, vecForceDir.z,
0.0f, 0.0f, fPointZ);
}
- switch(pEntity->m_type) {
+ switch(pEntity->GetType()) {
case ENTITY_TYPE_VEHICLE:
- if(pEntity->m_status == STATUS_SIMPLE) {
- pEntity->m_status = STATUS_PHYSICS;
+ if(pEntity->GetStatus() == STATUS_SIMPLE) {
+ pEntity->SetStatus(STATUS_PHYSICS);
CCarCtrl::SwitchVehicleToRealPhysics(pVehicle);
}
pVehicle->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION,
diff --git a/src/core/World.h b/src/core/World.h
index 25c76531..2bcc4e43 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -45,7 +45,8 @@ class CSector
public:
CPtrList m_lists[NUMSECTORENTITYLISTS];
};
-static_assert(sizeof(CSector) == 0x28, "CSector: error");
+
+VALIDATE_SIZE(CSector, 0x28);
class CEntity;
struct CColPoint;
@@ -101,8 +102,8 @@ public:
static CEntity *TestSphereAgainstWorld(CVector centre, float radius, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects);
static CEntity *TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool);
- static void FindObjectsInRangeSectorList(CPtrList&, CVector&, float, bool, short*, short, CEntity**);
- static void FindObjectsInRange(CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool);
+ static void FindObjectsInRangeSectorList(CPtrList&, Const CVector&, float, bool, short*, short, CEntity**);
+ static void FindObjectsInRange(Const CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool);
static void FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities);
static void FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies);
static float FindGroundZForCoord(float x, float y);
@@ -164,6 +165,6 @@ CVehicle *FindPlayerTrain(void);
CEntity *FindPlayerEntity(void);
CVector FindPlayerCoors(void);
CVector &FindPlayerSpeed(void);
-CVector &FindPlayerCentreOfWorld(int32 player);
-CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
+const CVector &FindPlayerCentreOfWorld(int32 player);
+const CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
float FindPlayerHeading(void);
diff --git a/src/core/ZoneCull.cpp b/src/core/ZoneCull.cpp
index 7a221f39..6dcd0f18 100644
--- a/src/core/ZoneCull.cpp
+++ b/src/core/ZoneCull.cpp
@@ -34,13 +34,13 @@ CCullZones::Init(void)
int i;
NumAttributeZones = 0;
- NumCullZones = 0;
CurrentWantedLevelDrop_Player = 0;
CurrentFlags_Camera = 0;
CurrentFlags_Player = 0;
+ bCurrentSubwayIsInvisible = false;
+ NumCullZones = 0;
OldCullZone = -1;
EntityIndicesUsed = 0;
- bCurrentSubwayIsInvisible = false;
for(i = 0; i < NUMBUILDINGS; i++)
aPointersToBigBuildingsForBuildings[i] = -1;
@@ -386,7 +386,6 @@ CCullZones::AddCullZone(CVector const &position,
}
-
void
CCullZone::DoStuffLeavingZone(void)
{
@@ -522,7 +521,7 @@ CCullZone::CalcDistToCullZoneSquared(float x, float y)
bool
CCullZone::IsEntityCloseEnoughToZone(CEntity *entity, bool checkLevel)
{
- CVector &pos = entity->GetPosition();
+ const CVector &pos = entity->GetPosition();
CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(entity->GetModelIndex());
float distToZone = CalcDistToCullZone(pos.x, pos.y);
@@ -534,7 +533,7 @@ CCullZone::IsEntityCloseEnoughToZone(CEntity *entity, bool checkLevel)
if (lodDist > distToZone) return true;
if (!checkLevel) return false;
- return CTheZones::GetLevelFromPosition(pos) == CTheZones::GetLevelFromPosition(CVector(minx, miny, minz));
+ return CTheZones::GetLevelFromPosition(&pos) == CTheZones::GetLevelFromPosition(&CVector(minx, miny, minz));
}
bool
@@ -561,4 +560,4 @@ CCullZones::DoWeHaveMoreThanXOccurencesOfSet(int32 count, uint16 *set)
}
}
return false;
-}
+} \ No newline at end of file
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 804708b4..22c0735a 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -23,6 +23,8 @@ CZoneInfo CTheZones::ZoneInfoArray[2*NUMZONES];
#define SWAPF(a, b) { float t; t = a; a = b; b = t; }
+inline bool IsNormalZone(int type) { return type == ZONE_DEFAULT || type == ZONE_NAVIG || type == ZONE_INFO; }
+
static void
CheckZoneInfo(CZoneInfo *info)
{
@@ -58,6 +60,9 @@ CTheZones::Init(void)
AudioZoneArray[i] = -1;
NumberOfAudioZones = 0;
+ for(i = 0; i < NUMZONES; i++)
+ memset(&ZoneArray[i], 0, sizeof(CZone));
+
CZoneInfo *zonei;
int x = 1000/6;
for(i = 0; i < 2*NUMZONES; i++){
@@ -81,10 +86,13 @@ CTheZones::Init(void)
zonei->gangThreshold[8] = zonei->gangThreshold[7];
CheckZoneInfo(zonei);
}
+
TotalNumberOfZoneInfos = 1; // why 1?
+ TotalNumberOfZones = 1;
+
+ m_CurrLevel = LEVEL_NONE;
+ m_pPlayersZone = &ZoneArray[0];
- for(i = 0; i < NUMZONES; i++)
- memset(&ZoneArray[i], 0, sizeof(CZone));
strcpy(ZoneArray[0].name, "CITYZON");
ZoneArray[0].minx = -4000.0f;
ZoneArray[0].miny = -4000.0f;
@@ -93,15 +101,14 @@ CTheZones::Init(void)
ZoneArray[0].maxy = 4000.0f;
ZoneArray[0].maxz = 500.0f;
ZoneArray[0].level = LEVEL_NONE;
- TotalNumberOfZones = 1;
-
- m_CurrLevel = LEVEL_NONE;
- m_pPlayersZone = &ZoneArray[0];
for(i = 0; i < NUMMAPZONES; i++){
memset(&MapZoneArray[i], 0, sizeof(CZone));
MapZoneArray[i].type = ZONE_MAPZONE;
}
+
+ TotalNumberOfMapZones = 1;
+
strcpy(MapZoneArray[0].name, "THEMAP");
MapZoneArray[0].minx = -4000.0f;
MapZoneArray[0].miny = -4000.0f;
@@ -110,7 +117,6 @@ CTheZones::Init(void)
MapZoneArray[0].maxy = 4000.0f;
MapZoneArray[0].maxz = 500.0f;
MapZoneArray[0].level = LEVEL_NONE;
- TotalNumberOfMapZones = 1;
}
void
@@ -119,7 +125,7 @@ CTheZones::Update(void)
CVector pos;
pos = FindPlayerCoors();
m_pPlayersZone = FindSmallestZonePosition(&pos);
- m_CurrLevel = GetLevelFromPosition(pos);
+ m_CurrLevel = GetLevelFromPosition(&pos);
}
void
@@ -128,8 +134,8 @@ CTheZones::CreateZone(char *name, eZoneType type,
float maxx, float maxy, float maxz,
eLevelName level)
{
- CZone *zone;
char *p;
+ char tmpname[8];
if(minx > maxx) SWAPF(minx, maxx);
if(miny > maxy) SWAPF(miny, maxy);
@@ -139,21 +145,22 @@ CTheZones::CreateZone(char *name, eZoneType type,
for(p = name; *p; p++) if(islower(*p)) *p = toupper(*p);
// add zone
- zone = &ZoneArray[TotalNumberOfZones++];
- strncpy(zone->name, name, 7);
- zone->name[7] = '\0';
- zone->type = type;
- zone->minx = minx;
- zone->miny = miny;
- zone->minz = minz;
- zone->maxx = maxx;
- zone->maxy = maxy;
- zone->maxz = maxz;
- zone->level = level;
- if(type == ZONE_AUDIO || type == ZONE_TYPE1 || type == ZONE_TYPE2){
- zone->zoneinfoDay = TotalNumberOfZoneInfos++;
- zone->zoneinfoNight = TotalNumberOfZoneInfos++;
+ strncpy(tmpname, name, 7);
+ tmpname[7] = '\0';
+ strcpy(ZoneArray[TotalNumberOfZones].name, tmpname);
+ ZoneArray[TotalNumberOfZones].type = type;
+ ZoneArray[TotalNumberOfZones].minx = minx;
+ ZoneArray[TotalNumberOfZones].miny = miny;
+ ZoneArray[TotalNumberOfZones].minz = minz;
+ ZoneArray[TotalNumberOfZones].maxx = maxx;
+ ZoneArray[TotalNumberOfZones].maxy = maxy;
+ ZoneArray[TotalNumberOfZones].maxz = maxz;
+ ZoneArray[TotalNumberOfZones].level = level;
+ if(IsNormalZone(type)){
+ ZoneArray[TotalNumberOfZones].zoneinfoDay = TotalNumberOfZoneInfos++;
+ ZoneArray[TotalNumberOfZones].zoneinfoNight = TotalNumberOfZoneInfos++;
}
+ TotalNumberOfZones++;
}
void
@@ -259,11 +266,11 @@ CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
inner->minz < outer->minz ||
inner->maxz > outer->maxz){
CVector vmin(inner->minx, inner->miny, inner->minz);
- if(PointLiesWithinZone(vmin, outer))
+ if(PointLiesWithinZone(&vmin, outer))
sprintf(tmp, "Overlapping zones %s and %s\n",
inner->name, outer->name);
CVector vmax(inner->maxx, inner->maxy, inner->maxz);
- if(PointLiesWithinZone(vmax, outer))
+ if(PointLiesWithinZone(&vmax, outer))
sprintf(tmp, "Overlapping zones %s and %s\n",
inner->name, outer->name);
return false;
@@ -272,15 +279,15 @@ CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
}
bool
-CTheZones::PointLiesWithinZone(const CVector &v, CZone *zone)
+CTheZones::PointLiesWithinZone(const CVector *v, CZone *zone)
{
- return zone->minx <= v.x && v.x <= zone->maxx &&
- zone->miny <= v.y && v.y <= zone->maxy &&
- zone->minz <= v.z && v.z <= zone->maxz;
+ return zone->minx <= v->x && v->x <= zone->maxx &&
+ zone->miny <= v->y && v->y <= zone->maxy &&
+ zone->minz <= v->z && v->z <= zone->maxz;
}
eLevelName
-CTheZones::GetLevelFromPosition(CVector const &v)
+CTheZones::GetLevelFromPosition(CVector const *v)
{
int i;
// char tmp[116];
@@ -300,7 +307,7 @@ CTheZones::FindSmallestZonePosition(const CVector *v)
CZone *zone = ZoneArray[0].child;
while(zone)
// if in zone, descent into children
- if(PointLiesWithinZone(*v, zone)){
+ if(PointLiesWithinZone(v, zone)){
best = zone;
zone = zone->child;
// otherwise try next zone
@@ -319,7 +326,7 @@ CTheZones::FindSmallestZonePositionType(const CVector *v, eZoneType type)
CZone *zone = ZoneArray[0].child;
while(zone)
// if in zone, descent into children
- if(PointLiesWithinZone(*v, zone)){
+ if(PointLiesWithinZone(v, zone)){
if(zone->type == type)
best = zone;
zone = zone->child;
@@ -333,18 +340,14 @@ CZone*
CTheZones::FindSmallestZonePositionILN(const CVector *v)
{
CZone *best = nil;
- if(ZoneArray[0].type == ZONE_AUDIO ||
- ZoneArray[0].type == ZONE_TYPE1 ||
- ZoneArray[0].type == ZONE_TYPE2)
+ if(IsNormalZone(ZoneArray[0].type))
best = &ZoneArray[0];
// zone to test next
CZone *zone = ZoneArray[0].child;
while(zone)
// if in zone, descent into children
- if(PointLiesWithinZone(*v, zone)){
- if(zone->type == ZONE_AUDIO ||
- zone->type == ZONE_TYPE1 ||
- zone->type == ZONE_TYPE2)
+ if(PointLiesWithinZone(v, zone)){
+ if(IsNormalZone(zone->type))
best = zone;
zone = zone->child;
// otherwise try next zone
@@ -532,7 +535,7 @@ CTheZones::SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity)
{
CZone *zone;
zone = GetZone(zoneid);
- if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
+ if(IsNormalZone(zone->type))
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].carDensity = cardensity;
}
@@ -541,7 +544,7 @@ CTheZones::SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity)
{
CZone *zone;
zone = GetZone(zoneid);
- if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
+ if(IsNormalZone(zone->type))
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedDensity = peddensity;
}
@@ -550,7 +553,7 @@ CTheZones::SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup)
{
CZone *zone;
zone = GetZone(zoneid);
- if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
+ if(IsNormalZone(zone->type))
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedGroup = pedgroup;
}
@@ -560,7 +563,7 @@ CTheZones::FindAudioZone(CVector *pos)
int i;
for(i = 0; i < NumberOfAudioZones; i++)
- if(PointLiesWithinZone(*pos, GetZone(AudioZoneArray[i])))
+ if(PointLiesWithinZone(pos, GetAudioZone(i)))
return i;
return -1;
}
@@ -568,11 +571,11 @@ CTheZones::FindAudioZone(CVector *pos)
eLevelName
CTheZones::FindZoneForPoint(const CVector &pos)
{
- if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("IND_ZON"))))
+ if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("IND_ZON"))))
return LEVEL_INDUSTRIAL;
- if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("COM_ZON"))))
+ if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("COM_ZON"))))
return LEVEL_COMMERCIAL;
- if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON"))))
+ if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON"))))
return LEVEL_SUBURBAN;
return LEVEL_NONE;
}
@@ -582,7 +585,7 @@ CTheZones::AddZoneToAudioZoneArray(CZone *zone)
{
int i, z;
- if(zone->type != ZONE_AUDIO)
+ if(zone->type != ZONE_DEFAULT)
return;
/* This is a bit stupid */
diff --git a/src/core/Zones.h b/src/core/Zones.h
index bb1585dc..67800569 100644
--- a/src/core/Zones.h
+++ b/src/core/Zones.h
@@ -5,9 +5,9 @@
enum eZoneType
{
- ZONE_AUDIO,
- ZONE_TYPE1, // this should be NAVIG
- ZONE_TYPE2, // this should be INFO...but all except MAPINFO get zoneinfo??
+ ZONE_DEFAULT,
+ ZONE_NAVIG,
+ ZONE_INFO,
ZONE_MAPZONE,
};
@@ -51,8 +51,6 @@ public:
class CTheZones
{
-public:
- static eLevelName m_CurrLevel;
static CZone *m_pPlayersZone;
static int16 FindIndex;
@@ -64,6 +62,8 @@ public:
static CZone MapZoneArray[NUMMAPZONES];
static uint16 TotalNumberOfZoneInfos;
static CZoneInfo ZoneInfoArray[2*NUMZONES];
+public:
+ static eLevelName m_CurrLevel;
static void Init(void);
static void Update(void);
@@ -76,12 +76,13 @@ public:
float maxx, float maxy, float maxz,
eLevelName level);
static CZone *GetZone(uint16 i) { return &ZoneArray[i]; }
+ static CZone *GetAudioZone(uint16 i) { return &ZoneArray[AudioZoneArray[i]]; }
static void PostZoneCreation(void);
static void InsertZoneIntoZoneHierarchy(CZone *zone);
static bool InsertZoneIntoZoneHierRecursive(CZone *z1, CZone *z2);
static bool ZoneIsEntirelyContainedWithinOtherZone(CZone *z1, CZone *z2);
- static bool PointLiesWithinZone(const CVector &v, CZone *zone);
- static eLevelName GetLevelFromPosition(CVector const &v);
+ static bool PointLiesWithinZone(const CVector *v, CZone *zone);
+ static eLevelName GetLevelFromPosition(const CVector *v);
static CZone *FindSmallestZonePosition(const CVector *v);
static CZone *FindSmallestZonePositionType(const CVector *v, eZoneType type);
static CZone *FindSmallestZonePositionILN(const CVector *v);
diff --git a/src/core/common.h b/src/core/common.h
index 66a3ad81..f79b199b 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -58,6 +58,9 @@
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define Min(a,b) ((a) < (b) ? (a) : (b))
+// Use this to add const that wasn't there in the original code
+#define Const const
+
typedef uint8_t uint8;
typedef int8_t int8;
typedef uint16_t uint16;
@@ -225,7 +228,11 @@ void re3_usererror(const char *format, ...);
#define _TODO(x)
#define _TODOCONST(x) (x)
+#ifdef CHECK_STRUCT_SIZES
#define VALIDATE_SIZE(struc, size) static_assert(sizeof(struc) == size, "Invalid structure size of " #struc)
+#else
+#define VALIDATE_SIZE(struc, size)
+#endif
#define VALIDATE_OFFSET(struc, member, offset) static_assert(offsetof(struc, member) == offset, "The offset of " #member " in " #struc " is not " #offset "...")
#define PERCENT(x, p) ((float(x) * (float(p) / 100.0f)))
diff --git a/src/core/config.h b/src/core/config.h
index 6896a7ba..ae30b539 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -38,6 +38,9 @@ enum Config {
NUMAUDIOSCRIPTOBJECTS = 256,
NUMCUTSCENEOBJECTS = 50,
+ NUMANIMBLOCKS = 2,
+ NUMANIMATIONS = 250,
+
NUMTEMPOBJECTS = 30,
// Path data
@@ -184,6 +187,7 @@ enum Config {
# define NO_MOVIES // disable intro videos
# define NO_CDCHECK
# define CHATTYSPLASH // print what the game is loading
+# define DEBUGMENU
//# define TIMEBARS // print debug timers
#endif
@@ -192,6 +196,7 @@ enum Config {
#define MORE_LANGUAGES // Add more translations to the game
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
#define USE_TXD_CDIMAGE // generate and load textures from txd.img
+#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
//#define USE_TEXTURE_POOL
//#define AUDIO_OAL
#define AUDIO_MSS
@@ -204,6 +209,7 @@ enum Config {
#ifndef RW_GL3
#define XINPUT
#endif
+#define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m
#define KANGAROO_CHEAT
#define ALLCARSHELI_CHEAT
#define ALT_DODO_CHEAT
@@ -226,6 +232,8 @@ enum Config {
#define USE_MEASUREMENTS_IN_METERS // makes game use meters instead of feet in script
#define USE_PRECISE_MEASUREMENT_CONVERTION // makes game convert feet to meeters more precisely
+#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
+
// Replay
//#define DONT_FIX_REPLAY_BUGS // keeps various bugs in CReplay, some of which are fairly cool!
//#define USE_BETA_REPLAY_MODE // adds another replay mode, a few seconds slomo (caution: buggy!)
diff --git a/src/core/main.cpp b/src/core/main.cpp
index ec37fa28..37a5673f 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -91,7 +91,9 @@ void GameInit(void);
void SystemInit(void);
void TheGame(void);
+#ifdef DEBUGMENU
void DebugMenuPopulate(void);
+#endif
void
@@ -328,11 +330,10 @@ Initialise3D(void *param)
{
if (RsRwInitialise(param))
{
- //
+#ifdef DEBUGMENU
DebugMenuInit();
DebugMenuPopulate();
- //
-
+#endif // !DEBUGMENU
return CGame::InitialiseRenderWare();
}
@@ -343,8 +344,9 @@ static void
Terminate3D(void)
{
CGame::ShutdownRenderWare();
-
+#ifdef DEBUGMENU
DebugMenuShutdown();
+#endif // !DEBUGMENU
RsRwTerminate();
@@ -878,7 +880,9 @@ Render2dStuff(void)
CPad::PrintErrorMessage();
CFont::DrawFonts();
+#ifdef DEBUGMENU
DebugMenuRender();
+#endif
}
void
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index b7eb6480..0ab32999 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -26,6 +26,7 @@
#include "PlayerPed.h"
#include "Radar.h"
#include "debugmenu.h"
+#include "Frontend.h"
#include <list>
@@ -60,6 +61,7 @@ mysrand(unsigned int seed)
myrand_seed = seed;
}
+#ifdef DEBUGMENU
void WeaponCheat();
void HealthCheat();
void TankCheat();
@@ -115,13 +117,13 @@ SpawnCar(int id)
DebugMenuEntrySetAddress(carCol2, &v->m_currentColour2);
if(CModelInfo::IsBoatModel(id))
- v->GetPosition() = TheCamera.GetPosition() + TheCamera.GetForward()*15.0f;
+ v->SetPosition(TheCamera.GetPosition() + TheCamera.GetForward()*15.0f);
else
- v->GetPosition() = ThePaths.m_pathNodes[node].pos;
+ v->SetPosition(ThePaths.m_pathNodes[node].GetPosition());
- v->GetPosition().z += 4.0f;
+ v->GetMatrix().GetPosition().z += 4.0f;
v->SetOrientation(0.0f, 0.0f, 3.49f);
- v->m_status = STATUS_ABANDONED;
+ v->SetStatus(STATUS_ABANDONED);
v->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(v);
}
@@ -322,11 +324,26 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); });
DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); });
+ DebugMenuAddVarBool8("Render", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil);
#ifdef LIBRW
DebugMenuAddVarBool8("Render", "PS2 Alpha test Emu", &gPS2alphaTest, nil);
#endif
+ DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil);
+ DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil);
+ DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil);
+ DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil);
+ DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil);
+ DebugMenuAddVarBool8("Render", "Show Car Path Links", &gbShowCarPathsLinks, nil);
+ DebugMenuAddVarBool8("Render", "Show Ped Road Groups", &gbShowPedRoadGroups, nil);
+ DebugMenuAddVarBool8("Render", "Show Car Road Groups", &gbShowCarRoadGroups, nil);
+ DebugMenuAddVarBool8("Render", "Show Collision Lines", &gbShowCollisionLines, nil);
+ DebugMenuAddVarBool8("Render", "Show Collision Polys", &gbShowCollisionPolys, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Buildings", &gbDontRenderBuildings, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Peds", &gbDontRenderPeds, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Vehicles", &gbDontRenderVehicles, nil);
+ DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil);
- DebugMenuAddVarBool8("Debug", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil);
DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil);
#ifdef MENU_MAP
DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint);
@@ -343,18 +360,6 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway);
DebugMenuAddVarBool8("Debug", "Script Heli On", &CHeli::ScriptHeliOn, nil);
- DebugMenuAddVarBool8("Debug", "Show Ped Paths", &gbShowPedPaths, nil);
- DebugMenuAddVarBool8("Debug", "Show Car Paths", &gbShowCarPaths, nil);
- DebugMenuAddVarBool8("Debug", "Show Car Path Links", &gbShowCarPathsLinks, nil);
- DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", &gbShowPedRoadGroups, nil);
- DebugMenuAddVarBool8("Debug", "Show Car Road Groups", &gbShowCarRoadGroups, nil);
- DebugMenuAddVarBool8("Debug", "Show Collision Lines", &gbShowCollisionLines, nil);
- DebugMenuAddVarBool8("Debug", "Show Collision Polys", &gbShowCollisionPolys, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Buildings", &gbDontRenderBuildings, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Peds", &gbDontRenderPeds, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Vehicles", &gbDontRenderVehicles, nil);
- DebugMenuAddVarBool8("Debug", "Don't render Objects", &gbDontRenderObjects, nil);
#ifdef TOGGLEABLE_BETA_FEATURES
DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil);
DebugMenuAddVarBool8("Debug", "Toggle peds running to phones to report crimes", &CPed::bMakePedsRunToPhonesToReportCrimes, nil);
@@ -380,6 +385,7 @@ DebugMenuPopulate(void)
CTweakVars::AddDBG("Debug");
}
}
+#endif
const int re3_buffsize = 1024;
static char re3_buff[re3_buffsize];
diff --git a/src/core/templates.h b/src/core/templates.h
index 51a24e4c..4f7b8490 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -17,6 +17,16 @@ public:
void clear(void){
this->allocPtr = 0;
}
+ int getIndex(T *item){
+ assert(item >= &this->store[0]);
+ assert(item < &this->store[n]);
+ return item - this->store;
+ }
+ T *getItem(int index){
+ assert(index >= 0);
+ assert(index < n);
+ return &this->store[index];
+ }
};
template<typename T, typename U = T>
@@ -35,6 +45,7 @@ class CPool
public:
CPool(int size){
+ // TODO: use new here
m_entries = (U*)malloc(sizeof(U)*size);
m_flags = (Flags*)malloc(sizeof(Flags)*size);
m_size = size;
@@ -44,6 +55,7 @@ public:
m_flags[i].free = 1;
}
}
+
~CPool() {
Flush();
}
@@ -119,7 +131,7 @@ public:
// TODO: the cast is unsafe
return (int)((U*)entry - m_entries);
}
- int GetNoOfUsedSpaces(void){
+ int GetNoOfUsedSpaces(void) const{
int i;
int n = 0;
for(i = 0; i < m_size; i++)
diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp
index aad2d402..3c096636 100644
--- a/src/entities/Building.cpp
+++ b/src/entities/Building.cpp
@@ -12,7 +12,7 @@ CBuilding::ReplaceWithNewModel(int32 id)
{
DeleteRwObject();
- if(CModelInfo::GetModelInfo(m_modelIndex)->m_refCount == 0)
+ if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0)
CStreaming::RemoveModel(m_modelIndex);
m_modelIndex = id;
diff --git a/src/entities/Building.h b/src/entities/Building.h
index 7b837f46..3586a8dc 100644
--- a/src/entities/Building.h
+++ b/src/entities/Building.h
@@ -16,4 +16,6 @@ public:
virtual bool GetIsATreadable(void) { return false; }
};
-static_assert(sizeof(CBuilding) == 0x64, "CBuilding: error");
+
+VALIDATE_SIZE(CBuilding, 0x64);
+
diff --git a/src/entities/Dummy.h b/src/entities/Dummy.h
index fcfd23fb..3717a01c 100644
--- a/src/entities/Dummy.h
+++ b/src/entities/Dummy.h
@@ -15,4 +15,6 @@ public:
static void *operator new(size_t);
static void operator delete(void*, size_t);
};
-static_assert(sizeof(CDummy) == 0x68, "CDummy: error");
+
+VALIDATE_SIZE(CDummy, 0x68);
+
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index ee4faa82..ec50dd30 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -27,6 +27,7 @@
#include "Zones.h"
#include "Bones.h"
#include "Debug.h"
+#include "Renderer.h"
int gBuildings;
@@ -330,7 +331,7 @@ CEntity::SetupBigBuilding(void)
bIsBIGBuilding = true;
bStreamingDontDelete = true;
bUsesCollision = false;
- m_level = CTheZones::GetLevelFromPosition(GetPosition());
+ m_level = CTheZones::GetLevelFromPosition(&GetPosition());
if(m_level == LEVEL_NONE){
if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){
mi->SetTexDictionary("generic");
@@ -452,7 +453,7 @@ CEntity::PreRender(void)
break;
}
- if(CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects != 0)
+ if (CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects() != 0)
ProcessLightsForEntity();
}
@@ -611,7 +612,7 @@ CEntity::AddSteamsFromGround(CVector *unused)
C2dEffect *effect;
CVector pos;
- n = CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects;
+ n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects();
for(i = 0; i < n; i++){
effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i);
if(effect->type != EFFECT_PARTICLE)
@@ -654,7 +655,7 @@ CEntity::ProcessLightsForEntity(void)
flashTimer2 = 0;
flashTimer3 = 0;
- n = CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects;
+ n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects();
for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){
effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i);
@@ -920,3 +921,108 @@ CEntity::AddSteamsFromGround(CPtrList& list)
pNode = pNode->next;
}
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CEntity::SaveEntityFlags(uint8*& buf)
+{
+ uint32 tmp = 0;
+ tmp |= (m_type & (BIT(3) - 1));
+ tmp |= (m_status & (BIT(5) - 1)) << 3;
+
+ if (bUsesCollision) tmp |= BIT(8);
+ if (bCollisionProcessed) tmp |= BIT(9);
+ if (bIsStatic) tmp |= BIT(10);
+ if (bHasContacted) tmp |= BIT(11);
+ if (bPedPhysics) tmp |= BIT(12);
+ if (bIsStuck) tmp |= BIT(13);
+ if (bIsInSafePosition) tmp |= BIT(14);
+ if (bUseCollisionRecords) tmp |= BIT(15);
+
+ if (bWasPostponed) tmp |= BIT(16);
+ if (bExplosionProof) tmp |= BIT(17);
+ if (bIsVisible) tmp |= BIT(18);
+ if (bHasCollided) tmp |= BIT(19);
+ if (bRenderScorched) tmp |= BIT(20);
+ if (bHasBlip) tmp |= BIT(21);
+ if (bIsBIGBuilding) tmp |= BIT(22);
+ if (bRenderDamaged) tmp |= BIT(23);
+
+ if (bBulletProof) tmp |= BIT(24);
+ if (bFireProof) tmp |= BIT(25);
+ if (bCollisionProof) tmp |= BIT(26);
+ if (bMeleeProof) tmp |= BIT(27);
+ if (bOnlyDamagedByPlayer) tmp |= BIT(28);
+ if (bStreamingDontDelete) tmp |= BIT(29);
+ if (bZoneCulled) tmp |= BIT(30);
+ if (bZoneCulled2) tmp |= BIT(31);
+
+ WriteSaveBuf<uint32>(buf, tmp);
+
+ tmp = 0;
+
+ if (bRemoveFromWorld) tmp |= BIT(0);
+ if (bHasHitWall) tmp |= BIT(1);
+ if (bImBeingRendered) tmp |= BIT(2);
+ if (bTouchingWater) tmp |= BIT(3);
+ if (bIsSubway) tmp |= BIT(4);
+ if (bDrawLast) tmp |= BIT(5);
+ if (bNoBrightHeadLights) tmp |= BIT(6);
+ if (bDoNotRender) tmp |= BIT(7);
+
+ if (bDistanceFade) tmp |= BIT(8);
+ if (m_flagE2) tmp |= BIT(9);
+
+ WriteSaveBuf<uint32>(buf, tmp);
+}
+
+void
+CEntity::LoadEntityFlags(uint8*& buf)
+{
+ uint32 tmp = ReadSaveBuf<uint32>(buf);
+ m_type = (tmp & ((BIT(3) - 1)));
+ m_status = ((tmp >> 3) & (BIT(5) - 1));
+
+ bUsesCollision = !!(tmp & BIT(8));
+ bCollisionProcessed = !!(tmp & BIT(9));
+ bIsStatic = !!(tmp & BIT(10));
+ bHasContacted = !!(tmp & BIT(11));
+ bPedPhysics = !!(tmp & BIT(12));
+ bIsStuck = !!(tmp & BIT(13));
+ bIsInSafePosition = !!(tmp & BIT(14));
+ bUseCollisionRecords = !!(tmp & BIT(15));
+
+ bWasPostponed = !!(tmp & BIT(16));
+ bExplosionProof = !!(tmp & BIT(17));
+ bIsVisible = !!(tmp & BIT(18));
+ bHasCollided = !!(tmp & BIT(19));
+ bRenderScorched = !!(tmp & BIT(20));
+ bHasBlip = !!(tmp & BIT(21));
+ bIsBIGBuilding = !!(tmp & BIT(22));
+ bRenderDamaged = !!(tmp & BIT(23));
+
+ bBulletProof = !!(tmp & BIT(24));
+ bFireProof = !!(tmp & BIT(25));
+ bCollisionProof = !!(tmp & BIT(26));
+ bMeleeProof = !!(tmp & BIT(27));
+ bOnlyDamagedByPlayer = !!(tmp & BIT(28));
+ bStreamingDontDelete = !!(tmp & BIT(29));
+ bZoneCulled = !!(tmp & BIT(30));
+ bZoneCulled2 = !!(tmp & BIT(31));
+
+ tmp = ReadSaveBuf<uint32>(buf);
+
+ bRemoveFromWorld = !!(tmp & BIT(0));
+ bHasHitWall = !!(tmp & BIT(1));
+ bImBeingRendered = !!(tmp & BIT(2));
+ bTouchingWater = !!(tmp & BIT(3));
+ bIsSubway = !!(tmp & BIT(4));
+ bDrawLast = !!(tmp & BIT(5));
+ bNoBrightHeadLights = !!(tmp & BIT(6));
+ bDoNotRender = !!(tmp & BIT(7));
+
+ bDistanceFade = !!(tmp & BIT(8));
+ m_flagE2 = !!(tmp & BIT(9));
+}
+
+#endif
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index ee9e6490..eca462cd 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -6,7 +6,7 @@
struct CReference;
class CPtrList;
-enum eEntityType
+enum eEntityType : uint8
{
ENTITY_TYPE_NOTHING = 0,
ENTITY_TYPE_BUILDING,
@@ -16,7 +16,7 @@ enum eEntityType
ENTITY_TYPE_DUMMY,
};
-enum eEntityStatus
+enum eEntityStatus : uint8
{
STATUS_PLAYER,
STATUS_PLAYER_PLAYBACKFROMBUFFER,
@@ -36,9 +36,11 @@ class CEntity : public CPlaceable
{
public:
RwObject *m_rwObject;
+protected:
uint32 m_type : 3;
+private:
uint32 m_status : 5;
-
+public:
// flagsA
uint32 bUsesCollision : 1; // does entity use collision
uint32 bCollisionProcessed : 1; // has object been processed by a ProcessEntityCollision function
@@ -57,7 +59,6 @@ public:
uint32 bRenderScorched : 1;
uint32 bHasBlip : 1;
uint32 bIsBIGBuilding : 1; // Set if this entity is a big building
- // VC inserts one more flag here: if drawdist <= 2000
uint32 bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage
// flagsC
@@ -90,8 +91,19 @@ public:
uint16 m_level; // int16
CReference *m_pFirstReference;
+public:
+ eEntityType GetType() const { return (eEntityType)m_type; }
+ void SetType(eEntityType type) { m_type = type; }
+ eEntityStatus GetStatus() const { return (eEntityStatus)m_status; }
+ void SetStatus(eEntityStatus status) { m_status = status; }
CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
+ bool IsStatic(void) { return bIsStatic; }
+#ifdef COMPATIBLE_SAVES
+ void SaveEntityFlags(uint8*& buf);
+ void LoadEntityFlags(uint8*& buf);
+#else
uint32* GetAddressOfEntityProperties() { /* AWFUL */ return (uint32*)((char*)&m_rwObject + sizeof(m_rwObject)); }
+#endif
CEntity(void);
~CEntity(void);
@@ -137,7 +149,7 @@ public:
bool GetIsOnScreenComplex(void);
bool IsVisible(void) { return m_rwObject && bIsVisible && GetIsOnScreen(); }
bool IsVisibleComplex(void) { return m_rwObject && bIsVisible && GetIsOnScreenComplex(); }
- int GetModelIndex(void) { return m_modelIndex; }
+ int16 GetModelIndex(void) const { return m_modelIndex; }
void UpdateRwFrame(void);
void SetupBigBuilding(void);
@@ -160,4 +172,5 @@ public:
static void AddSteamsFromGround(CPtrList& list);
};
-static_assert(sizeof(CEntity) == 0x64, "CEntity: error");
+
+VALIDATE_SIZE(CEntity, 0x64);
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index d37405ec..64358cbf 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -54,7 +54,7 @@ CPhysical::CPhysical(void)
bInfiniteMass = false;
bIsInWater = false;
bHitByTrain = false;
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
m_fDistanceTravelled = 0.0f;
m_treadable[PATH_CAR] = nil;
@@ -315,7 +315,7 @@ CPhysical::PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phy
CWorld::Remove(phys);
phys->GetMatrix() = other->GetMatrix();
- phys->GetPosition() = pos;
+ phys->SetPosition(pos);
phys->m_vecMoveSpeed = other->m_vecMoveSpeed;
phys->GetMatrix().UpdateRW();
phys->UpdateRwFrame();
@@ -326,15 +326,15 @@ int32
CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
{
int32 numSpheres = CCollision::ProcessColModels(
- GetMatrix(), *CModelInfo::GetModelInfo(GetModelIndex())->GetColModel(),
- ent->GetMatrix(), *CModelInfo::GetModelInfo(ent->GetModelIndex())->GetColModel(),
+ GetMatrix(), *GetColModel(),
+ ent->GetMatrix(), *ent->GetColModel(),
colpoints,
nil, nil); // No Lines allowed!
if(numSpheres > 0){
AddCollisionRecord(ent);
if(!ent->IsBuilding()) // Can't this catch dummies too?
((CPhysical*)ent)->AddCollisionRecord(this);
- if(ent->IsBuilding() || ent->bIsStatic)
+ if(ent->IsBuilding() || ent->IsStatic())
this->bHasHitWall = true;
}
return numSpheres;
@@ -350,7 +350,7 @@ CPhysical::ProcessControl(void)
bWasPostponed = false;
bHasHitWall = false;
- if(m_status == STATUS_SIMPLE)
+ if(GetStatus() == STATUS_SIMPLE)
return;
m_nCollisionRecords = 0;
@@ -410,7 +410,7 @@ CPhysical::GetSpeed(const CVector &r)
void
CPhysical::ApplyMoveSpeed(void)
{
- GetPosition() += m_vecMoveSpeed * CTimer::GetTimeStep();
+ GetMatrix().Translate(m_vecMoveSpeed * CTimer::GetTimeStep());
}
void
@@ -538,7 +538,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
float timestepB;
if(A->bPedPhysics){
if(A->IsPed() && ((CPed*)A)->IsPlayer() && B->IsVehicle() &&
- (B->m_status == STATUS_ABANDONED || B->m_status == STATUS_WRECKED || A->bHasHitWall))
+ (B->GetStatus() == STATUS_ABANDONED || B->GetStatus() == STATUS_WRECKED || A->bHasHitWall))
timestepB = 2200.0f / B->m_fMass;
else
timestepB = 10.0f;
@@ -549,7 +549,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
timestepB = B->bIsHeavy ? 2.0f : 1.0f;
float speedA, speedB;
- if(B->bIsStatic){
+ if(B->IsStatic()){
if(A->bPedPhysics){
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
if(speedA < 0.0f){
@@ -632,7 +632,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
}
}
- if(B->bIsStatic)
+ if(B->IsStatic())
return false;
if(!B->bInfiniteMass)
B->AddToMovingList();
@@ -757,7 +757,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
fA.y *= 1.4f;
if(colpoint.normal.z < 0.7f)
fA.z *= 0.3f;
- if(A->m_status == STATUS_PLAYER)
+ if(A->GetStatus() == STATUS_PLAYER)
pointposA *= 0.8f;
if(CWorld::bNoMoreCollisionTorque){
A->ApplyFrictionMoveForce(fA*-0.3f);
@@ -769,7 +769,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
fB.y *= 1.4f;
if(colpoint.normal.z < 0.7f)
fB.z *= 0.3f;
- if(B->m_status == STATUS_PLAYER)
+ if(B->GetStatus() == STATUS_PLAYER)
pointposB *= 0.8f;
if(CWorld::bNoMoreCollisionTorque){
// BUG: the game actually uses A here, but this can't be right
@@ -815,7 +815,7 @@ CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CV
if(normalSpeed < 0.0f){
float minspeed = 0.0104f * CTimer::GetTimeStep();
#ifdef GTA3_1_1_PATCH
- if ((IsObject() || IsVehicle() && (GetUp().z < -0.3f || ((CVehicle*)this)->IsBike() && (m_status == STATUS_ABANDONED || m_status == STATUS_WRECKED))) &&
+ if ((IsObject() || IsVehicle() && (GetUp().z < -0.3f || ((CVehicle*)this)->IsBike() && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED))) &&
#else
if((IsObject() || IsVehicle() && GetUp().z < -0.3f) &&
#endif
@@ -1089,7 +1089,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Aobj = (CObject*)A;
if(Aobj->ObjectCreatedBy != TEMP_OBJECT &&
!Aobj->bHasBeenDamaged &&
- Aobj->bIsStatic){
+ Aobj->IsStatic()){
if(Aobj->m_pCollidingEntity == B)
Aobj->m_pCollidingEntity = nil;
}else if(Aobj->m_pCollidingEntity != B){
@@ -1106,7 +1106,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Bobj = (CObject*)B;
if(Bobj->ObjectCreatedBy != TEMP_OBJECT &&
!Bobj->bHasBeenDamaged &&
- Bobj->bIsStatic){
+ Bobj->IsStatic()){
if(Bobj->m_pCollidingEntity == A)
Bobj->m_pCollidingEntity = nil;
}else if(Bobj->m_pCollidingEntity != A){
@@ -1165,7 +1165,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
float f = Min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
- B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f);
+ B->GetMatrix().Translate(dir * colpoints[mostColliding].depth / (1.0f - f));
// BUG? how can that ever happen? A is a Ped
if(B->IsVehicle())
B->ProcessEntityCollision(A, colpoints);
@@ -1182,7 +1182,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
if(!doShift)
return false;
- GetPosition() += shift;
+ GetMatrix().Translate(shift);
if(boat)
ProcessEntityCollision(boat, colpoints);
return true;
@@ -1341,8 +1341,8 @@ collision:
}
}
- if(B->m_status == STATUS_SIMPLE){
- B->m_status = STATUS_PHYSICS;
+ if(B->GetStatus() == STATUS_SIMPLE){
+ B->SetStatus(STATUS_PHYSICS);
if(B->IsVehicle())
CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)B);
}
@@ -1401,7 +1401,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
continue;
}
- A->m_phy_flagA80 = false;
+ A->bSkipLineCol = false;
skipCollision = false;
altcollision = false;
@@ -1411,20 +1411,20 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
(B->IsVehicle() || B->IsPed()) &&
A->GetUp().z < 0.66f){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
Aobj->m_pCollidingEntity = B;
}else if((A->IsVehicle() || A->IsPed()) &&
B->GetUp().z < 0.66f &&
IsTrafficLight(B->GetModelIndex())){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
Bobj->m_pCollidingEntity = A;
}else if(A->IsObject() && B->IsVehicle()){
if(A->GetModelIndex() == MI_CAR_BUMPER || A->GetModelIndex() == MI_FILES)
skipCollision = true;
else if(Aobj->ObjectCreatedBy == TEMP_OBJECT ||
Aobj->bHasBeenDamaged ||
- !Aobj->bIsStatic){
+ !Aobj->IsStatic()){
if(Aobj->m_pCollidingEntity == B)
skipCollision = true;
else{
@@ -1443,7 +1443,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true;
else if(Bobj->ObjectCreatedBy == TEMP_OBJECT ||
Bobj->bHasBeenDamaged ||
- !Bobj->bIsStatic){
+ !Bobj->IsStatic()){
if(Bobj->m_pCollidingEntity == A)
skipCollision = true;
else{
@@ -1460,18 +1460,18 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true;
}else if(A->IsPed() && IsBodyPart(B->GetModelIndex())){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(A->IsPed() && Aped->m_pCollidingEntity == B){
skipCollision = true;
if(!Aped->bKnockedUpIntoAir)
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(B->IsPed() && Bped->m_pCollidingEntity == A){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(A->GetModelIndex() == MI_RCBANDIT && (B->IsPed() || B->IsVehicle()) ||
B->GetModelIndex() == MI_RCBANDIT && (A->IsPed() || A->IsVehicle())){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(A->IsPed() && B->IsObject() && Bobj->m_fUprootLimit > 0.0f)
altcollision = true;
@@ -1544,7 +1544,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
}else
adhesion = 0.0f;
}else if(A->IsVehicle()){
- if(A->m_status == STATUS_WRECKED)
+ if(A->GetStatus() == STATUS_WRECKED)
adhesion *= 3.0f;
else if(A->GetUp().z > 0.3f)
adhesion = 0.0f;
@@ -1561,7 +1561,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
m_vecMoveSpeed += moveSpeed / numResponses;
m_vecTurnSpeed += turnSpeed / numResponses;
if(!CWorld::bNoMoreCollisionTorque &&
- A->m_status == STATUS_PLAYER && A->IsVehicle() &&
+ A->GetStatus() == STATUS_PLAYER && A->IsVehicle() &&
Abs(A->m_vecMoveSpeed.x) > 0.2f &&
Abs(A->m_vecMoveSpeed.y) > 0.2f){
A->m_vecMoveFriction.x += moveSpeed.x * -0.3f / numCollisions;
@@ -1713,8 +1713,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
Aobj->ObjectDamage(maxImpulseB);
}
- if(B->m_status == STATUS_SIMPLE){
- B->m_status = STATUS_PHYSICS;
+ if(B->GetStatus() == STATUS_SIMPLE){
+ B->SetStatus(STATUS_PHYSICS);
if(B->IsVehicle())
CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)B);
}
@@ -1758,7 +1758,7 @@ void
CPhysical::ProcessShift(void)
{
m_fDistanceTravelled = 0.0f;
- if(m_status == STATUS_SIMPLE){
+ if(GetStatus() == STATUS_SIMPLE){
bIsStuck = false;
bIsInSafePosition = true;
RemoveAndAdd();
@@ -1804,7 +1804,7 @@ CPhysical::ProcessCollision(void)
m_fDistanceTravelled = 0.0f;
m_bIsVehicleBeingShifted = false;
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
if(!bUsesCollision){
bIsStuck = false;
@@ -1813,9 +1813,9 @@ CPhysical::ProcessCollision(void)
return;
}
- if(m_status == STATUS_SIMPLE){
- if(CheckCollision_SimpleCar() && m_status == STATUS_SIMPLE){
- m_status = STATUS_PHYSICS;
+ if(GetStatus() == STATUS_SIMPLE){
+ if(CheckCollision_SimpleCar() && GetStatus() == STATUS_SIMPLE){
+ SetStatus(STATUS_PHYSICS);
if(IsVehicle())
CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)this);
}
@@ -1840,14 +1840,14 @@ CPhysical::ProcessCollision(void)
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;
}else if(IsVehicle() && distSq >= sq(0.4f)){
- if(m_status == STATUS_PLAYER)
+ if(GetStatus() == STATUS_PLAYER)
n = NUMSTEPS(0.2f);
else
n = distSq > 0.32f ? NUMSTEPS(0.3f) : NUMSTEPS(0.4f);
step = savedTimeStep / n;
}else if(IsObject()){
int responsecase = ((CObject*)this)->m_nSpecialCollisionResponseCases;
- if(responsecase == COLLRESPONSE_CHANGE_MODEL){
+ if(responsecase == COLLRESPONSE_LAMPOST){
CVector speedUp = { 0.0f, 0.0f, 0.0f };
CVector speedDown = { 0.0f, 0.0f, 0.0f };
speedUp.z = GetBoundRadius();
@@ -1866,7 +1866,7 @@ CPhysical::ProcessCollision(void)
n = NUMSTEPS(0.09f);
step = savedTimeStep / n;
}
- }else if(responsecase == COLLRESPONSE_SPLIT_MODEL || responsecase == COLLRESPONSE_CHANGE_THEN_SMASH){
+ }else if(responsecase == COLLRESPONSE_SMALLBOX || responsecase == COLLRESPONSE_FENCEPART){
if(distSq >= sq(0.15f)){
n = NUMSTEPS(0.15f);
step = savedTimeStep / n;
@@ -1886,7 +1886,7 @@ CPhysical::ProcessCollision(void)
// TODO: get rid of copy paste?
if(CheckCollision()){
if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
- !ped->m_ped_flagA2 &&
+ !ped->bWasStanding &&
ped->bIsStanding)
savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
@@ -1894,7 +1894,7 @@ CPhysical::ProcessCollision(void)
return;
}
if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
- !ped->m_ped_flagA2 &&
+ !ped->bWasStanding &&
ped->bIsStanding)
savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
@@ -1917,11 +1917,11 @@ CPhysical::ProcessCollision(void)
ApplyTurnSpeed();
GetMatrix().Reorthogonalise();
m_bIsVehicleBeingShifted = false;
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
if(!m_vecMoveSpeed.IsZero() ||
!m_vecTurnSpeed.IsZero() ||
bHitByTrain ||
- m_status == STATUS_PLAYER || IsPed() && ped->IsPlayer()){
+ GetStatus() == STATUS_PLAYER || IsPed() && ped->IsPlayer()){
if(IsVehicle())
((CVehicle*)this)->bVehicleColProcessed = true;
if(CheckCollision()){
@@ -1931,7 +1931,7 @@ CPhysical::ProcessCollision(void)
}
bHitByTrain = false;
m_fDistanceTravelled = (GetPosition() - savedMatrix.GetPosition()).Magnitude();
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
bIsStuck = false;
bIsInSafePosition = true;
diff --git a/src/entities/Physical.h b/src/entities/Physical.h
index fa5ada05..c84686ed 100644
--- a/src/entities/Physical.h
+++ b/src/entities/Physical.h
@@ -58,7 +58,7 @@ public:
uint8 m_phy_flagA10 : 1; // unused
uint8 m_phy_flagA20 : 1; // unused
uint8 bHitByTrain : 1;
- uint8 m_phy_flagA80 : 1;
+ uint8 bSkipLineCol : 1;
uint8 m_nSurfaceTouched;
int8 m_nZoneLevel;
@@ -160,4 +160,5 @@ public:
bool CheckCollision(void);
bool CheckCollision_SimpleCar(void);
};
-static_assert(sizeof(CPhysical) == 0x128, "CPhysical: error");
+
+VALIDATE_SIZE(CPhysical, 0x128);
diff --git a/src/entities/Treadable.h b/src/entities/Treadable.h
index 9e4de59a..c3160f47 100644
--- a/src/entities/Treadable.h
+++ b/src/entities/Treadable.h
@@ -12,4 +12,6 @@ public:
bool GetIsATreadable(void) { return true; }
};
-static_assert(sizeof(CTreadable) == 0x94, "CTreadable: error");
+
+VALIDATE_SIZE(CTreadable, 0x94);
+
diff --git a/src/extras/debugmenu.cpp b/src/extras/debugmenu.cpp
index 1c5e26ee..a31426bb 100644
--- a/src/extras/debugmenu.cpp
+++ b/src/extras/debugmenu.cpp
@@ -1,4 +1,5 @@
#include "common.h"
+#ifdef DEBUGMENU
#include "RwHelper.h"
#include "Pad.h"
#include "ControllerConfig.h"
@@ -6,6 +7,7 @@
#include "rtcharse.h"
#include "inttypes.h"
#include "debugmenu.h"
+#include <new>
#define snprintf _snprintf
@@ -152,6 +154,7 @@ struct Menu
void update(void);
void draw(void);
Menu(void){ memset(this, 0, sizeof(Menu)); }
+ ~Menu(void);
};
extern Menu toplevel;
@@ -160,6 +163,7 @@ struct MenuEntry_Sub : MenuEntry
Menu *submenu;
MenuEntry_Sub(const char *name, Menu *menu);
+ ~MenuEntry_Sub(void) { delete submenu; }
};
struct MenuEntry_Var : MenuEntry
@@ -705,6 +709,16 @@ Menu::draw(void)
((MenuEntry_Sub*)this->selectedEntry)->submenu->draw();
}
+Menu::~Menu(void)
+{
+ MenuEntry *e, *next;
+ for(e = entries; e; e = next){
+ next = e->next;
+ delete e;
+ }
+ memset(this, 0, sizeof(Menu));
+}
+
Menu*
findMenu(const char *name)
{
@@ -792,6 +806,7 @@ DebugMenuInit(void)
assert(arrow);
RwImageDestroy(img);
+
menuInitialized = true;
}
@@ -804,7 +819,14 @@ DebugMenuShutdown(void)
cursor = nil;
RwRasterDestroy(arrow);
arrow = nil;
- // TODO: the menus ...
+
+ toplevel.~Menu();
+ new (&toplevel) Menu();
+
+ activeMenu = &toplevel;
+ deepestMenu = &toplevel;
+ mouseOverMenu = nil;
+ mouseOverEntry = nil;
}
menuInitialized = false;
}
@@ -1292,3 +1314,4 @@ DebugMenuEntrySetAddress(MenuEntry *e, void *addr)
((MenuEntry_Float32*)e)->variable = (float*)addr;
}
}
+#endif \ No newline at end of file
diff --git a/src/extras/debugmenu.h b/src/extras/debugmenu.h
index 462b59c4..eb56c8f9 100644
--- a/src/extras/debugmenu.h
+++ b/src/extras/debugmenu.h
@@ -1,5 +1,7 @@
#pragma once
+#ifdef DEBUGMENU
+
typedef void (*TriggerFunc)(void);
struct Menu;
@@ -13,6 +15,7 @@ struct MenuEntry
Menu *menu;
MenuEntry(const char *name);
+ virtual ~MenuEntry(void) {}
};
typedef MenuEntry DebugMenuEntry;
@@ -84,3 +87,4 @@ inline DebugMenuEntry *DebugMenuAddVarBool8(const char *path, const char *name,
{
return DebugMenuAddVarBool8(path, name, (int8_t*)ptr, triggerFunc);
}
+#endif \ No newline at end of file
diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp
index ccc7635f..f1531490 100644
--- a/src/fakerw/fake.cpp
+++ b/src/fakerw/fake.cpp
@@ -126,8 +126,8 @@ rwFrameList *rwFrameListStreamRead(RwStream *stream, rwFrameList *fl) { return f
RwCamera *RwCameraBeginUpdate(RwCamera * camera) { camera->beginUpdate(); return camera; }
RwCamera *RwCameraEndUpdate(RwCamera * camera) { camera->endUpdate(); return camera; }
RwCamera *RwCameraClear(RwCamera * camera, RwRGBA * colour, RwInt32 clearMode) { camera->clear(colour, clearMode); return camera; }
-// WARNING: ignored arguments
-RwCamera *RwCameraShowRaster(RwCamera * camera, void *pDev, RwUInt32 flags) { camera->showRaster(); return camera; }
+// WARNING: ignored argument
+RwCamera *RwCameraShowRaster(RwCamera * camera, void *pDev, RwUInt32 flags) { camera->showRaster(flags); return camera; }
RwBool RwCameraDestroy(RwCamera * camera) { camera->destroy(); return true; }
RwCamera *RwCameraCreate(void) { return rw::Camera::create(); }
RwCamera *RwCameraClone(RwCamera * camera) { return camera->clone(); }
@@ -392,8 +392,8 @@ RwStream *RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, const v
}
}
RwBool RwStreamClose(RwStream * stream, void *pData) { stream->close(); rwFree(stream); return true; }
-RwUInt32 RwStreamRead(RwStream * stream, void *buffer, RwUInt32 length) { return stream->read(buffer, length); }
-RwStream *RwStreamWrite(RwStream * stream, const void *buffer, RwUInt32 length) { stream->write(buffer, length); return stream; }
+RwUInt32 RwStreamRead(RwStream * stream, void *buffer, RwUInt32 length) { return stream->read8(buffer, length); }
+RwStream *RwStreamWrite(RwStream * stream, const void *buffer, RwUInt32 length) { stream->write8(buffer, length); return stream; }
RwStream *RwStreamSkip(RwStream * stream, RwUInt32 offset) { stream->seek(offset); return stream; }
RwBool RwStreamFindChunk(RwStream *stream, RwUInt32 type, RwUInt32 *lengthOut, RwUInt32 *versionOut)
@@ -429,8 +429,7 @@ void RwIm3DVertexSetU(RwIm3DVertex *vert, RwReal u) { vert->setU(u); }
void RwIm3DVertexSetV(RwIm3DVertex *vert, RwReal v) { vert->setV(v); }
void RwIm3DVertexSetRGBA(RwIm3DVertex *vert, RwUInt8 r, RwUInt8 g, RwUInt8 b, RwUInt8 a) { vert->setColor(r, g, b, a); }
-// WARNING: ignoring flags
-void *RwIm3DTransform(RwIm3DVertex *pVerts, RwUInt32 numVerts, RwMatrix *ltm, RwUInt32 flags) { im3d::Transform(pVerts, numVerts, ltm); return pVerts; }
+void *RwIm3DTransform(RwIm3DVertex *pVerts, RwUInt32 numVerts, RwMatrix *ltm, RwUInt32 flags) { im3d::Transform(pVerts, numVerts, ltm, flags); return pVerts; }
RwBool RwIm3DEnd(void) { im3d::End(); return true; }
RwBool RwIm3DRenderLine(RwInt32 vert1, RwInt32 vert2) {
RwImVertexIndex indices[2];
@@ -450,6 +449,7 @@ RwBool RwIm3DRenderPrimitive(RwPrimitiveType primType);
RwBool RwRenderStateSet(RwRenderState state, void *value)
{
uint32 uival = (uintptr)value;
+ uint32 fog;
switch(state){
case rwRENDERSTATETEXTURERASTER: SetRenderState(TEXTURERASTER, uival); return true;
case rwRENDERSTATETEXTUREADDRESS: SetRenderState(TEXTUREADDRESS, uival); return true;
@@ -465,7 +465,14 @@ RwBool RwRenderStateSet(RwRenderState state, void *value)
case rwRENDERSTATEVERTEXALPHAENABLE: SetRenderState(VERTEXALPHA, uival); return true;
case rwRENDERSTATEBORDERCOLOR: return true;
case rwRENDERSTATEFOGENABLE: SetRenderState(FOGENABLE, uival); return true;
- case rwRENDERSTATEFOGCOLOR: SetRenderState(FOGCOLOR, uival); return true;
+ case rwRENDERSTATEFOGCOLOR:
+ // have to swap R and B here
+ fog = (uival>>16)&0xFF;
+ fog |= (uival&0xFF)<<16;
+ fog |= uival&0xFF00;
+ fog |= uival&0xFF000000;
+ SetRenderState(FOGCOLOR, fog);
+ return true;
case rwRENDERSTATEFOGTYPE: return true;
case rwRENDERSTATEFOGDENSITY: return true;
case rwRENDERSTATEFOGTABLE: return true;
@@ -490,12 +497,11 @@ RwBool RwRenderStateSet(RwRenderState state, void *value)
RwBool RwEngineInit(RwMemoryFunctions *memFuncs, RwUInt32 initFlags, RwUInt32 resArenaSize) { Engine::init(); return true; }
// TODO: this is platform dependent
RwBool RwEngineOpen(RwEngineOpenParams *initParams) {
-#if defined RW_D3D9 || defined RWLIBS
static EngineOpenParams openParams;
+#ifdef RW_D3D9
openParams.window = (HWND)initParams->displayID;
#else
- extern EngineOpenParams openParams;
- openParams.window = (GLFWwindow**)initParams->displayID;
+ openParams = *(EngineOpenParams*)initParams->displayID;
#endif
return Engine::open(&openParams);
}
@@ -750,6 +756,7 @@ RwCamera *RwCameraForAllClumpsNotInFrustum(RwCamera *camera, RwInt32 numClumps,
RwBool RpMatFXPluginAttach( void ) { registerMatFXPlugin(); return true; }
RpAtomic *RpMatFXAtomicEnableEffects( RpAtomic *atomic ) { MatFX::enableEffects(atomic); return atomic; }
+RpMatFXMaterialFlags RpMatFXMaterialGetEffects( const RpMaterial *material ){ return (RpMatFXMaterialFlags)MatFX::getEffects(material); }
RpMaterial *RpMatFXMaterialSetEffects( RpMaterial *material, RpMatFXMaterialFlags flags ) { MatFX::setEffects(material, (uint32)flags); return material; }
RpMaterial *RpMatFXMaterialSetupEnvMap( RpMaterial *material, RwTexture *texture, RwFrame *frame, RwBool useFrameBufferAlpha, RwReal coef ) {
MatFX *mfx = MatFX::get(material);
@@ -758,8 +765,23 @@ RpMaterial *RpMatFXMaterialSetupEnvMap( RpMaterial *material, RwTexture *texture
mfx->setEnvCoefficient(coef);
return material;
}
-
-
+RpMaterial *RpMatFXMaterialSetEnvMapFrame( RpMaterial *material, RwFrame *frame )
+{
+ MatFX *mfx = MatFX::get(material);
+ mfx->setEnvFrame(frame);
+ return material;
+}
+RpMaterial *RpMatFXMaterialSetEnvMapCoefficient( RpMaterial *material, RwReal coef )
+{
+ MatFX *mfx = MatFX::get(material);
+ mfx->setEnvCoefficient(coef);
+ return material;
+}
+RwReal RpMatFXMaterialGetEnvMapCoefficient( const RpMaterial *material )
+{
+ MatFX *mfx = MatFX::get(material);
+ return mfx->getEnvCoefficient();
+}
diff --git a/src/fakerw/rwcore.h b/src/fakerw/rwcore.h
index 22e29737..31bc5541 100644
--- a/src/fakerw/rwcore.h
+++ b/src/fakerw/rwcore.h
@@ -20,11 +20,11 @@ typedef RwUInt16 RwImVertexIndex;
enum RwIm3DTransformFlags
{
- rwIM3D_VERTEXUV = 1,
- rwIM3D_ALLOPAQUE = 2,
- rwIM3D_NOCLIP = 4,
- rwIM3D_VERTEXXYZ = 8,
- rwIM3D_VERTEXRGBA = 16,
+ rwIM3D_VERTEXUV = rw::im3d::VERTEXUV,
+ rwIM3D_ALLOPAQUE = rw::im3d::ALLOPAQUE,
+ rwIM3D_NOCLIP = rw::im3d::NOCLIP,
+ rwIM3D_VERTEXXYZ = rw::im3d::VERTEXXYZ,
+ rwIM3D_VERTEXRGBA = rw::im3d::VERTEXRGBA,
};
void RwIm2DVertexSetCameraX(RwIm2DVertex *vert, RwReal camx);
diff --git a/src/math/Rect.h b/src/math/Rect.h
index fd1bd05e..326bb479 100644
--- a/src/math/Rect.h
+++ b/src/math/Rect.h
@@ -26,6 +26,25 @@ public:
if(v.y < top) top = v.y;
if(v.y > bottom) bottom = v.y;
}
+ void ContainRect(const CRect &r){
+ if(r.left < left) left = r.left;
+ if(r.right > right) right = r.right;
+ if(r.top < top) top = r.top;
+ if(r.bottom > bottom) bottom = r.bottom;
+ }
+
+ bool IsPointInside(const CVector2D &p){
+ return p.x >= left &&
+ p.x <= right &&
+ p.y >= top &&
+ p.y <= bottom;
+ }
+ bool IsPointInside(const CVector2D &p, float extraRadius){
+ return p.x >= left-extraRadius &&
+ p.x <= right+extraRadius &&
+ p.y >= top-extraRadius &&
+ p.y <= bottom+extraRadius;
+ }
void Translate(float x, float y){
left += x;
diff --git a/src/math/Vector.h b/src/math/Vector.h
index 44e646e9..5918a5d1 100644
--- a/src/math/Vector.h
+++ b/src/math/Vector.h
@@ -9,11 +9,6 @@ public:
#ifdef RWCORE_H
CVector(const RwV3d &v) : x(v.x), y(v.y), z(v.z) {}
- RwV3d toRwV3d(void) const {
- RwV3d vecRw = { this->x, this->y, this->z };
- return vecRw;
- }
-
operator RwV3d (void) const {
RwV3d vecRw = { this->x, this->y, this->z };
return vecRw;
@@ -22,10 +17,6 @@ public:
operator RwV3d *(void) {
return (RwV3d*)this;
}
-
- operator RwV3d &(void) {
- return *((RwV3d*)this);
- }
#endif
// (0,1,0) means no rotation. So get right vector and its atan
float Heading(void) const { return Atan2(-x, y); }
@@ -95,6 +86,10 @@ public:
return x == right.x && y == right.y && z == right.z;
}
+ const bool operator!=(CVector const &right) {
+ return x != right.x || y != right.y || z != right.z;
+ }
+
bool IsZero(void) const { return x == 0.0f && y == 0.0f && z == 0.0f; }
};
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp
index e8d2601f..a2779107 100644
--- a/src/modelinfo/BaseModelInfo.cpp
+++ b/src/modelinfo/BaseModelInfo.cpp
@@ -6,7 +6,7 @@
#include "BaseModelInfo.h"
-CBaseModelInfo::CBaseModelInfo(ModeInfoType type)
+CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
{
m_colModel = nil;
m_twodEffects = nil;
@@ -15,7 +15,7 @@ CBaseModelInfo::CBaseModelInfo(ModeInfoType type)
m_txdSlot = -1;
m_type = type;
m_num2dEffects = 0;
- m_freeCol = false;
+ m_bOwnsColModel = false;
}
void
@@ -31,7 +31,7 @@ CBaseModelInfo::Shutdown(void)
void
CBaseModelInfo::DeleteCollisionModel(void)
{
- if(m_colModel && m_freeCol){
+ if(m_colModel && m_bOwnsColModel){
if(m_colModel)
delete m_colModel;
m_colModel = nil;
diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h
index 0c4bf934..783f871f 100644
--- a/src/modelinfo/BaseModelInfo.h
+++ b/src/modelinfo/BaseModelInfo.h
@@ -4,7 +4,7 @@
#define MAX_MODEL_NAME (24)
-enum ModeInfoType : uint8
+enum ModelInfoType : uint8
{
MITYPE_NA = 0,
MITYPE_SIMPLE = 1,
@@ -15,26 +15,25 @@ enum ModeInfoType : uint8
MITYPE_PED = 6,
MITYPE_XTRACOMPS = 7,
};
-static_assert(sizeof(ModeInfoType) == 1, "ModeInfoType: error");
+VALIDATE_SIZE(ModelInfoType, 1);
class C2dEffect;
class CBaseModelInfo
{
protected:
- // TODO?: make more things protected
char m_name[MAX_MODEL_NAME];
CColModel *m_colModel;
C2dEffect *m_twodEffects;
int16 m_objectId;
-public:
uint16 m_refCount;
int16 m_txdSlot;
- ModeInfoType m_type;
+ ModelInfoType m_type;
uint8 m_num2dEffects;
- bool m_freeCol;
+ bool m_bOwnsColModel;
- CBaseModelInfo(ModeInfoType type);
+public:
+ CBaseModelInfo(ModelInfoType type);
virtual ~CBaseModelInfo() {}
virtual void Shutdown(void);
virtual void DeleteRwObject(void) = 0;
@@ -42,15 +41,18 @@ public:
virtual RwObject *CreateInstance(void) = 0;
virtual RwObject *GetRwObject(void) = 0;
+ // one day it becomes virtual
+ ModelInfoType GetModelType() const { return m_type; }
bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; }
bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE ||
m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck
}
char *GetName(void) { return m_name; }
- void SetName(const char *name) { strncpy(m_name, name, 24); }
- void SetColModel(CColModel *col, bool free = false){
- m_colModel = col; m_freeCol = free; }
+ void SetName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); }
+ void SetColModel(CColModel *col, bool owns = false){
+ m_colModel = col; m_bOwnsColModel = owns; }
CColModel *GetColModel(void) { return m_colModel; }
+ bool DoesOwnColModel(void) { return m_bOwnsColModel; }
void DeleteCollisionModel(void);
void ClearTexDictionary(void) { m_txdSlot = -1; }
short GetObjectID(void) { return m_objectId; }
@@ -64,6 +66,8 @@ public:
void Init2dEffects(void);
void Add2dEffect(C2dEffect *fx);
C2dEffect *Get2dEffect(int n);
+ uint8 GetNum2dEffects() const { return m_num2dEffects; }
+ uint16 GetNumRefs() const { return m_refCount; }
};
-static_assert(sizeof(CBaseModelInfo) == 0x30, "CBaseModelInfo: error");
+VALIDATE_SIZE(CBaseModelInfo, 0x30);
diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp
index 44faf3c5..ccfcd304 100644
--- a/src/modelinfo/ClumpModelInfo.cpp
+++ b/src/modelinfo/ClumpModelInfo.cpp
@@ -43,7 +43,7 @@ CClumpModelInfo::CreateInstance(void)
RpClumpForAllAtomics(clone, SetHierarchyForSkinAtomic, hier);
anim = HAnimAnimationCreateForHierarchy(hier);
RpHAnimHierarchySetCurrentAnim(hier, anim);
-// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
+ RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
// the rest is xbox only:
// RpSkinGetNumBones(RpSkinGeometryGetSkin(RpAtomicGetGeometry(IsClumpSkinned(clone))));
RpHAnimHierarchyUpdateMatrices(hier);
@@ -113,7 +113,7 @@ CClumpModelInfo::SetClump(RpClump *clump)
weights->w2 /= sum;
weights->w3 /= sum;
}
-// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
+ RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
}
#endif
}
@@ -139,13 +139,12 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data)
{
RwObjectIdAssociation *assoc = (RwObjectIdAssociation*)data;
- if(CVisibilityPlugins::GetFrameHierarchyId(frame) != assoc->id){
- RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc);
- return assoc->frame ? nil : frame;
- }else{
+ if(CVisibilityPlugins::GetFrameHierarchyId(frame) == assoc->id){
assoc->frame = frame;
return nil;
}
+ RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc);
+ return assoc->frame ? nil : frame;
}
RwFrame*
@@ -153,13 +152,12 @@ CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data)
{
RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data;
- if(CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
- RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc);
- return assoc->frame ? nil : frame;
- }else{
+ if(!CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
assoc->frame = frame;
return nil;
}
+ RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc);
+ return assoc->frame ? nil : frame;
}
RwFrame*
@@ -167,14 +165,13 @@ CClumpModelInfo::FindFrameFromNameWithoutIdCB(RwFrame *frame, void *data)
{
RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data;
- if(CVisibilityPlugins::GetFrameHierarchyId(frame) ||
- CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
- RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc);
- return assoc->frame ? nil : frame;
- }else{
+ if(CVisibilityPlugins::GetFrameHierarchyId(frame) == 0 &&
+ !CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
assoc->frame = frame;
return nil;
}
+ RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc);
+ return assoc->frame ? nil : frame;
}
RwFrame*
diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h
index 100aa30b..58b6de11 100644
--- a/src/modelinfo/ClumpModelInfo.h
+++ b/src/modelinfo/ClumpModelInfo.h
@@ -32,7 +32,7 @@ public:
RpClump *m_clump;
CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {}
- CClumpModelInfo(ModeInfoType id) : CBaseModelInfo(id) {}
+ CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {}
~CClumpModelInfo() {}
void DeleteRwObject(void);
RwObject *CreateInstance(void);
@@ -50,4 +50,5 @@ public:
static RwFrame *FillFrameArrayCB(RwFrame *frame, void *data);
static RwFrame *GetFrameFromId(RpClump *clump, int32 id);
};
-static_assert(sizeof(CClumpModelInfo) == 0x34, "CClumpModelInfo: error");
+
+VALIDATE_SIZE(CClumpModelInfo, 0x34);
diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h
index 8e117882..cc6ed25c 100644
--- a/src/modelinfo/ModelIndices.h
+++ b/src/modelinfo/ModelIndices.h
@@ -255,7 +255,8 @@ enum
MI_BUSKER4,
// three more peds possible
- MI_LANDSTAL = 90,
+ MI_FIRST_VEHICLE = 90,
+ MI_LANDSTAL = MI_FIRST_VEHICLE,
MI_IDAHO,
MI_STINGER,
MI_LINERUN,
diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp
index c1ae692f..da09bdfa 100644
--- a/src/modelinfo/ModelInfo.cpp
+++ b/src/modelinfo/ModelInfo.cpp
@@ -203,14 +203,14 @@ CModelInfo::GetModelInfo(const char *name, int *id)
bool
CModelInfo::IsBoatModel(int32 id)
{
- return GetModelInfo(id)->m_type == MITYPE_VEHICLE &&
+ return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT;
}
bool
CModelInfo::IsBikeModel(int32 id)
{
- return GetModelInfo(id)->m_type == MITYPE_VEHICLE &&
+ return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE;
}
diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h
index a2bfd122..52f75894 100644
--- a/src/modelinfo/PedModelInfo.h
+++ b/src/modelinfo/PedModelInfo.h
@@ -36,7 +36,8 @@ public:
static RwObjectNameIdAssocation m_pPedIds[PED_NODE_MAX];
- CPedModelInfo(void) : CClumpModelInfo(MITYPE_PED) { }
+ CPedModelInfo(void) : CClumpModelInfo(MITYPE_PED) { m_hitColModel = nil; }
+ ~CPedModelInfo(void) { delete m_hitColModel; }
void DeleteRwObject(void);
void SetClump(RpClump *);
@@ -55,5 +56,5 @@ public:
#endif
};
#ifndef PED_SKIN
-static_assert(sizeof(CPedModelInfo) == 0x48, "CPedModelInfo: error");
+VALIDATE_SIZE(CPedModelInfo, 0x48);
#endif \ No newline at end of file
diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp
index 2fb2adeb..a781cf58 100644
--- a/src/modelinfo/SimpleModelInfo.cpp
+++ b/src/modelinfo/SimpleModelInfo.cpp
@@ -95,6 +95,12 @@ CSimpleModelInfo::IncreaseAlpha(void)
}
float
+CSimpleModelInfo::GetLodDistance(int i)
+{
+ return m_lodDistances[i] * TheCamera.LODDistMultiplier;
+}
+
+float
CSimpleModelInfo::GetNearDistance(void)
{
return m_lodDistances[2] * TheCamera.LODDistMultiplier;
@@ -119,7 +125,7 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist)
if(m_isDamaged)
i = m_firstDamaged;
for(; i < m_numAtomics; i++)
- if(dist < m_lodDistances[i] *TheCamera.LODDistMultiplier)
+ if(dist < m_lodDistances[i] * TheCamera.LODDistMultiplier)
return m_atomics[i];
return nil;
}
@@ -144,7 +150,7 @@ void
CSimpleModelInfo::SetupBigBuilding(void)
{
CSimpleModelInfo *related;
- if(m_lodDistances[0] > LOD_DISTANCE && m_atomics[2] == nil){
+ if(m_lodDistances[0] > LOD_DISTANCE && GetRelatedModel() == nil){
m_isBigBuilding = 1;
FindRelatedModel();
related = GetRelatedModel();
diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h
index 35d48669..ee63f24b 100644
--- a/src/modelinfo/SimpleModelInfo.h
+++ b/src/modelinfo/SimpleModelInfo.h
@@ -25,7 +25,7 @@ public:
uint16 m_noZwrite : 1;
CSimpleModelInfo(void) : CBaseModelInfo(MITYPE_SIMPLE) {}
- CSimpleModelInfo(ModeInfoType id) : CBaseModelInfo(id) {}
+ CSimpleModelInfo(ModelInfoType id) : CBaseModelInfo(id) {}
~CSimpleModelInfo() {}
void DeleteRwObject(void);
RwObject *CreateInstance(void);
@@ -36,7 +36,7 @@ public:
void IncreaseAlpha(void);
void SetAtomic(int n, RpAtomic *atomic);
void SetLodDistances(float *dist);
- float GetLodDistance(int i) { return m_lodDistances[i]; }
+ float GetLodDistance(int i);
float GetNearDistance(void);
float GetLargestLodDistance(void);
RpAtomic *GetAtomicFromDistance(float dist);
@@ -49,4 +49,5 @@ public:
void SetRelatedModel(CSimpleModelInfo *m){
m_atomics[2] = (RpAtomic*)m; }
};
-static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: error");
+
+VALIDATE_SIZE(CSimpleModelInfo, 0x4C);
diff --git a/src/modelinfo/TimeModelInfo.cpp b/src/modelinfo/TimeModelInfo.cpp
index fec3f6e5..d4f92293 100644
--- a/src/modelinfo/TimeModelInfo.cpp
+++ b/src/modelinfo/TimeModelInfo.cpp
@@ -22,7 +22,7 @@ CTimeModelInfo::FindOtherTimeModel(void)
for(i = 0; i < MODELINFOSIZE; i++){
CBaseModelInfo *mi = CModelInfo::GetModelInfo(i);
- if(mi && mi->m_type == MITYPE_TIME &&
+ if (mi && mi->GetModelType() == MITYPE_TIME &&
strncmp(name, mi->GetName(), 24) == 0){
m_otherTimeModelID = i;
return (CTimeModelInfo*)mi;
diff --git a/src/modelinfo/TimeModelInfo.h b/src/modelinfo/TimeModelInfo.h
index f8b7c8ff..73b6ab26 100644
--- a/src/modelinfo/TimeModelInfo.h
+++ b/src/modelinfo/TimeModelInfo.h
@@ -17,4 +17,5 @@ public:
void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; }
CTimeModelInfo *FindOtherTimeModel(void);
};
-static_assert(sizeof(CTimeModelInfo) == 0x58, "CTimeModelInfo: error");
+
+VALIDATE_SIZE(CTimeModelInfo, 0x58);
diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h
index 9992ab98..ba25d3cd 100644
--- a/src/modelinfo/VehicleModelInfo.h
+++ b/src/modelinfo/VehicleModelInfo.h
@@ -36,17 +36,6 @@ enum eVehicleType {
};
enum {
- VEHICLE_CLASS_POOR,
- VEHICLE_CLASS_RICH,
- VEHICLE_CLASS_EXECUTIVE,
- VEHICLE_CLASS_WORKER,
- VEHICLE_CLASS_SPECIAL,
- VEHICLE_CLASS_BIG,
- VEHICLE_CLASS_TAXI,
- NUM_VEHICLE_CLASSES
-};
-
-enum {
NUM_VEHICLE_POSITIONS = 10
};
@@ -134,4 +123,5 @@ public:
static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id);
static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; }
};
-static_assert(sizeof(CVehicleModelInfo) == 0x1F8, "CVehicleModelInfo: error");
+
+VALIDATE_SIZE(CVehicleModelInfo, 0x1F8);
diff --git a/src/objects/CutsceneHead.cpp b/src/objects/CutsceneHead.cpp
index 3ef257d2..0938960e 100644
--- a/src/objects/CutsceneHead.cpp
+++ b/src/objects/CutsceneHead.cpp
@@ -131,7 +131,7 @@ CCutsceneHead::RenderLimb(int32 bone)
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(m_parentObject->GetClump());
int idx = RpHAnimIDGetIndex(hier, bone);
RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
- CPedModelInfo *mi = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
+ CPedModelInfo *mi = (CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex());
switch(bone){
case BONE_Lhand:
atomic = mi->getLeftHand();
diff --git a/src/objects/CutsceneHead.h b/src/objects/CutsceneHead.h
index 0a70353d..c931eb01 100644
--- a/src/objects/CutsceneHead.h
+++ b/src/objects/CutsceneHead.h
@@ -24,5 +24,5 @@ public:
void PlayAnimation(const char *animName);
};
#ifndef PED_SKIN
-static_assert(sizeof(CCutsceneHead) == 0x19C, "CCutsceneHead: error");
+VALIDATE_SIZE(CCutsceneHead, 0x19C);
#endif
diff --git a/src/objects/CutsceneObject.cpp b/src/objects/CutsceneObject.cpp
index 7b4ae02b..5c10d37d 100644
--- a/src/objects/CutsceneObject.cpp
+++ b/src/objects/CutsceneObject.cpp
@@ -15,7 +15,7 @@
CCutsceneObject::CCutsceneObject(void)
{
- m_status = STATUS_SIMPLE;
+ SetStatus(STATUS_SIMPLE);
bUsesCollision = false;
bStreamingDontDelete = true;
ObjectCreatedBy = CUTSCENE_OBJECT;
@@ -100,7 +100,7 @@ void
CCutsceneObject::RenderLimb(int32 bone)
{
RpAtomic *atomic;
- CPedModelInfo *mi = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
+ CPedModelInfo *mi = (CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex());
switch(bone){
case BONE_head:
atomic = mi->getHead();
diff --git a/src/objects/CutsceneObject.h b/src/objects/CutsceneObject.h
index 9c4036bf..407adcc7 100644
--- a/src/objects/CutsceneObject.h
+++ b/src/objects/CutsceneObject.h
@@ -29,5 +29,5 @@ public:
void RemoveLighting(bool reset);
};
#ifndef PED_SKIN
-static_assert(sizeof(CCutsceneObject) == 0x198, "CCutsceneObject: error");
+VALIDATE_SIZE(CCutsceneObject, 0x198);
#endif
diff --git a/src/objects/DummyObject.h b/src/objects/DummyObject.h
index d4dce609..d6f88335 100644
--- a/src/objects/DummyObject.h
+++ b/src/objects/DummyObject.h
@@ -10,4 +10,5 @@ public:
CDummyObject(void) {}
CDummyObject(CObject *obj);
};
-static_assert(sizeof(CDummyObject) == 0x68, "CDummyObject: error");
+
+VALIDATE_SIZE(CDummyObject, 0x68);
diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp
index c0ce38f8..cd2cd688 100644
--- a/src/objects/Object.cpp
+++ b/src/objects/Object.cpp
@@ -57,7 +57,7 @@ CObject::CObject(int32 mi, bool createRW)
CObject::CObject(CDummyObject *dummy)
{
- SetModelIndexNoCreate(dummy->m_modelIndex);
+ SetModelIndexNoCreate(dummy->GetModelIndex());
if (dummy->m_rwObject)
AttachToRwObject(dummy->m_rwObject);
@@ -97,7 +97,7 @@ CObject::ProcessControl(void)
m_vecMoveSpeed *= fTimeStep;
m_vecTurnSpeed *= fTimeStep;
}
- if ((m_modelIndex == MI_EXPLODINGBARREL || m_modelIndex == MI_PETROLPUMP) && bHasBeenDamaged && bIsVisible
+ if ((GetModelIndex() == MI_EXPLODINGBARREL || GetModelIndex() == MI_PETROLPUMP) && bHasBeenDamaged && bIsVisible
&& (CGeneral::GetRandomNumber() & 0x1F) == 10) {
bExplosionProof = true;
bIsVisible = false;
@@ -125,7 +125,7 @@ CObject::Render(void)
if(m_nRefModelIndex != -1 && ObjectCreatedBy == TEMP_OBJECT && bUseVehicleColours){
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_nRefModelIndex);
- assert(mi->m_type == MITYPE_VEHICLE);
+ assert(mi->GetModelType() == MITYPE_VEHICLE);
mi->SetVehicleColour(m_colour1, m_colour2);
}
@@ -159,7 +159,7 @@ CObject::ObjectDamage(float amount)
return;
static int8 nFrameGen = 0;
bool bBodyCastDamageEffect = false;
- if (m_modelIndex == MI_BODYCAST){
+ if (GetModelIndex() == MI_BODYCAST) {
if (amount > 50.0f)
nBodyCastHealth = (int16)(nBodyCastHealth - 0.5f * amount);
if (nBodyCastHealth < 0)
@@ -173,12 +173,12 @@ CObject::ObjectDamage(float amount)
const float fDirectionZ = 0.0002f * amount;
switch (m_nCollisionDamageEffect)
{
- case COLDAMAGE_EFFECT_CHANGE_MODEL:
+ case DAMAGE_EFFECT_CHANGE_MODEL:
bRenderDamaged = true;
break;
- case COLDAMAGE_EFFECT_SPLIT_MODEL:
+ case DAMAGE_EFFECT_SPLIT_MODEL:
break;
- case COLDAMAGE_EFFECT_SMASH_COMPLETELY:
+ case DAMAGE_EFFECT_SMASH_COMPLETELY:
bIsVisible = false;
bUsesCollision = false;
bIsStatic = true;
@@ -186,7 +186,7 @@ CObject::ObjectDamage(float amount)
SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f);
break;
- case COLDAMAGE_EFFECT_CHANGE_THEN_SMASH:
+ case DAMAGE_EFFECT_CHANGE_THEN_SMASH:
if (!bRenderDamaged) {
bRenderDamaged = true;
}
@@ -199,7 +199,7 @@ CObject::ObjectDamage(float amount)
SetTurnSpeed(0.0f, 0.0f, 0.0f);
}
break;
- case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: {
+ case DAMAGE_EFFECT_SMASH_CARDBOARD_COMPLETELY: {
bIsVisible = false;
bUsesCollision = false;
bIsStatic = true;
@@ -222,7 +222,7 @@ CObject::ObjectDamage(float amount)
PlayOneShotScriptObject(_SCRSOUND_CARDBOARD_BOX_SMASH, vecPos);
break;
}
- case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: {
+ case DAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: {
bIsVisible = false;
bUsesCollision = false;
bIsStatic = true;
@@ -245,7 +245,7 @@ CObject::ObjectDamage(float amount)
PlayOneShotScriptObject(_SCRSOUND_WOODEN_BOX_SMASH, vecPos);
break;
}
- case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: {
+ case DAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: {
bIsVisible = false;
bUsesCollision = false;
bIsStatic = true;
@@ -270,7 +270,7 @@ CObject::ObjectDamage(float amount)
PlayOneShotScriptObject(_SCRSOUND_TYRE_BUMP, vecPos);
break;
}
- case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: {
+ case DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: {
bIsVisible = false;
bUsesCollision = false;
bIsStatic = true;
@@ -309,8 +309,8 @@ CObject::RefModelInfo(int32 modelId)
void
CObject::Init(void)
{
- m_type = ENTITY_TYPE_OBJECT;;
- CObjectData::SetObjectData(m_modelIndex, *this);
+ m_type = ENTITY_TYPE_OBJECT;
+ CObjectData::SetObjectData(GetModelIndex(), *this);
m_nEndOfLifeTime = 0;
ObjectCreatedBy = GAME_OBJECT;
bIsStatic = true;
@@ -333,9 +333,9 @@ CObject::Init(void)
m_pCurSurface = outEntity;
else
m_pCurSurface = nil;
- if (m_modelIndex == MI_BODYCAST)
+ if (GetModelIndex() == MI_BODYCAST)
nBodyCastHealth = 1000;
- else if (m_modelIndex == MI_BUOY)
+ else if (GetModelIndex() == MI_BUOY)
bTouchingWater = true;
}
diff --git a/src/objects/Object.h b/src/objects/Object.h
index 319ec4bc..79589dc9 100644
--- a/src/objects/Object.h
+++ b/src/objects/Object.h
@@ -10,31 +10,28 @@ enum {
CUTSCENE_OBJECT = 4,
};
-enum {
- COLDAMAGE_EFFECT_NONE = 0,
- COLDAMAGE_EFFECT_CHANGE_MODEL = 1,
- COLDAMAGE_EFFECT_SPLIT_MODEL = 2,
- COLDAMAGE_EFFECT_SMASH_COMPLETELY = 3,
- COLDAMAGE_EFFECT_CHANGE_THEN_SMASH = 4,
- COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY = 50,
- COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY = 60,
- COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY = 70,
- COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY = 80,
-};
-
-enum {
+enum CollisionSpecialResponseCase
+{
COLLRESPONSE_NONE,
- COLLRESPONSE_CHANGE_MODEL,
- COLLRESPONSE_SPLIT_MODEL,
- COLLRESPONSE_SMASH_COMPLETELY,
- COLLRESPONSE_CHANGE_THEN_SMASH,
- COLLRESPONSE_UNKNOWN5,
-
- COLLRESPONSE_SMASH_CARDBOARD_COMPLETELY = 50,
- COLLRESPONSE_SMASH_WOODENBOX_COMPLETELY = 60,
- COLLRESPONSE_SMASH_TRAFFICCONE_COMPLETELY = 70,
- COLLRESPONSE_SMASH_BARPOST_COMPLETELY = 80,
+ COLLRESPONSE_LAMPOST,
+ COLLRESPONSE_SMALLBOX,
+ COLLRESPONSE_BIGBOX,
+ COLLRESPONSE_FENCEPART,
+ COLLRESPONSE_UNKNOWN5
+};
+enum CollisionDamageEffect
+{
+ DAMAGE_EFFECT_NONE,
+ DAMAGE_EFFECT_CHANGE_MODEL,
+ DAMAGE_EFFECT_SPLIT_MODEL,
+ DAMAGE_EFFECT_SMASH_COMPLETELY,
+ DAMAGE_EFFECT_CHANGE_THEN_SMASH,
+
+ DAMAGE_EFFECT_SMASH_CARDBOARD_COMPLETELY = 50,
+ DAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY = 60,
+ DAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY = 70,
+ DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY = 80
};
class CVehicle;
@@ -100,4 +97,5 @@ public:
static void DeleteAllTempObjects();
static void DeleteAllTempObjectsInArea(CVector point, float fRadius);
};
-static_assert(sizeof(CObject) == 0x198, "CObject: error");
+
+VALIDATE_SIZE(CObject, 0x198);
diff --git a/src/objects/ObjectData.h b/src/objects/ObjectData.h
index e3a5c1bd..e25c1aeb 100644
--- a/src/objects/ObjectData.h
+++ b/src/objects/ObjectData.h
@@ -16,7 +16,7 @@ public:
uint8 m_nSpecialCollisionResponseCases;
bool m_bCameraToAvoidThisObject;
};
-static_assert(sizeof(CObjectInfo) == 0x20, "CObjectInfo: error");
+VALIDATE_SIZE(CObjectInfo, 0x20);
class CObjectData
{
diff --git a/src/objects/ParticleObject.cpp b/src/objects/ParticleObject.cpp
index 932a0b8a..3dd80546 100644
--- a/src/objects/ParticleObject.cpp
+++ b/src/objects/ParticleObject.cpp
@@ -7,6 +7,7 @@
#include "Particle.h"
#include "Camera.h"
#include "Game.h"
+#include "DMAudio.h"
CParticleObject gPObjectArray[MAX_PARTICLEOBJECTS];
@@ -136,7 +137,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
pobj->m_nState = POBJECTSTATE_UPDATE_CLOSE;
pobj->m_Type = (eParticleObjectType)type;
- pobj->GetPosition() = pos;
+ pobj->SetPosition(pos);
pobj->m_vecTarget = target;
pobj->m_nNumEffectCycles = 1;
@@ -1173,7 +1174,7 @@ CParticleObject::LoadParticle(uint8 *buffer, uint32 length)
dst->m_nState = POBJECTSTATE_UPDATE_CLOSE;
dst->m_Type = src->m_Type;
dst->m_ParticleType = src->m_ParticleType;
- dst->GetPosition() = src->GetPosition();
+ dst->SetPosition(src->GetPosition());
dst->m_vecTarget = src->m_vecTarget;
dst->m_nFrameCounter = src->m_nFrameCounter;
dst->m_bRemove = src->m_bRemove;
diff --git a/src/peds/CivilianPed.h b/src/peds/CivilianPed.h
index 88d034c8..8418a99f 100644
--- a/src/peds/CivilianPed.h
+++ b/src/peds/CivilianPed.h
@@ -12,5 +12,5 @@ public:
void ProcessControl(void);
};
#ifndef PED_SKIN
-static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error");
+VALIDATE_SIZE(CCivilianPed, 0x53C);
#endif
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index 3fc8b8ca..99e8c1ae 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -73,7 +73,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
// VC also initializes in here, but as nil
#ifdef FIX_BUGS
- m_wRoadblockNode = -1;
+ m_nRoadblockNode = -1;
#endif
}
@@ -132,7 +132,7 @@ CCopPed::SetArrestPlayer(CPed *player)
player->m_pMyVehicle->m_nNumGettingIn = 0;
player->m_pMyVehicle->m_nGettingInFlags = 0;
player->m_pMyVehicle->bIsHandbrakeOn = true;
- player->m_pMyVehicle->m_status = STATUS_PLAYER_DISABLED;
+ player->m_pMyVehicle->SetStatus(STATUS_PLAYER_DISABLED);
}
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED)
SetCurrentWeapon(WEAPONTYPE_COLT45);
@@ -305,9 +305,9 @@ CCopPed::CopAI(void)
m_bZoneDisabled = true;
m_bIsDisabledCop = true;
#ifdef FIX_BUGS
- m_wRoadblockNode = -1;
+ m_nRoadblockNode = -1;
#else
- m_wRoadblockNode = 0;
+ m_nRoadblockNode = 0;
#endif
bKindaStayInSamePlace = true;
bIsRunning = false;
@@ -424,8 +424,8 @@ CCopPed::CopAI(void)
// VC checks for != nil compared to buggy behaviour of III. I check for != -1 here.
#ifdef VC_PED_PORTS
float dotProd;
- if (m_wRoadblockNode != -1) {
- CTreadable *roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_wRoadblockNode]];
+ if (m_nRoadblockNode != -1) {
+ CTreadable *roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_nRoadblockNode]];
dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), GetPosition() - roadBlockRoad->GetPosition());
} else
dotProd = -1.0f;
@@ -437,10 +437,10 @@ CCopPed::CopAI(void)
float copRoadDotProd, targetRoadDotProd;
#else
float copRoadDotProd = 1.0f, targetRoadDotProd = 1.0f;
- if (m_wRoadblockNode != -1)
+ if (m_nRoadblockNode != -1)
#endif
{
- CTreadable* roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_wRoadblockNode]];
+ CTreadable* roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_nRoadblockNode]];
CVector2D roadFwd = roadBlockRoad->GetForward();
copRoadDotProd = DotProduct2D(GetPosition() - roadBlockRoad->GetPosition(), roadFwd);
targetRoadDotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), roadFwd);
diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h
index e9780035..5346d9a1 100644
--- a/src/peds/CopPed.h
+++ b/src/peds/CopPed.h
@@ -12,7 +12,7 @@ enum eCopType
class CCopPed : public CPed
{
public:
- int16 m_wRoadblockNode;
+ int16 m_nRoadblockNode;
float m_fDistanceToTarget;
bool m_bIsInPursuit;
bool m_bIsDisabledCop;
@@ -37,5 +37,5 @@ public:
};
#ifndef PED_SKIN
-static_assert(sizeof(CCopPed) == 0x558, "CCopPed: error");
+VALIDATE_SIZE(CCopPed, 0x558);
#endif
diff --git a/src/peds/DummyPed.h b/src/peds/DummyPed.h
index af633dc4..ea617c76 100644
--- a/src/peds/DummyPed.h
+++ b/src/peds/DummyPed.h
@@ -8,4 +8,5 @@ class CDummyPed : CDummy
int32 pedType;
int32 unknown;
};
-static_assert(sizeof(CDummyPed) == 0x70, "CDummyPed: error");
+
+VALIDATE_SIZE(CDummyPed, 0x70);
diff --git a/src/peds/EmergencyPed.h b/src/peds/EmergencyPed.h
index 6d3dac79..390ba0bd 100644
--- a/src/peds/EmergencyPed.h
+++ b/src/peds/EmergencyPed.h
@@ -37,5 +37,5 @@ public:
void MedicAI(void);
};
#ifndef PED_SKIN
-static_assert(sizeof(CEmergencyPed) == 0x554, "CEmergencyPed: error");
+VALIDATE_SIZE(CEmergencyPed, 0x554);
#endif
diff --git a/src/peds/Gangs.h b/src/peds/Gangs.h
index dd7a7f93..c8ea2916 100644
--- a/src/peds/Gangs.h
+++ b/src/peds/Gangs.h
@@ -10,7 +10,7 @@ struct CGangInfo
CGangInfo();
};
-static_assert(sizeof(CGangInfo) == 0x10, "CGangInfo: error");
+VALIDATE_SIZE(CGangInfo, 0x10);
enum {
GANG_MAFIA = 0,
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index dcb167f0..78f4b586 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -414,8 +414,8 @@ CPed::FlagToDestroyWhenNextProcessed(void)
return;
if (m_pMyVehicle->pDriver == this){
m_pMyVehicle->pDriver = nil;
- if (IsPlayer() && m_pMyVehicle->m_status != STATUS_WRECKED)
- m_pMyVehicle->m_status = STATUS_ABANDONED;
+ if (IsPlayer() && m_pMyVehicle->GetStatus() != STATUS_WRECKED)
+ m_pMyVehicle->SetStatus(STATUS_ABANDONED);
}else{
m_pMyVehicle->RemovePassenger(this);
}
@@ -522,7 +522,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_fElasticity = 0.05f;
bIsStanding = false;
- m_ped_flagA2 = false;
+ bWasStanding = false;
bIsAttacking = false;
bIsPointingGunAt = false;
bIsLooking = false;
@@ -1667,7 +1667,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP
CVector vehDoorOffset;
float seatOffset;
- vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(veh->m_modelIndex);
+ vehModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(veh->GetModelIndex());
if (veh->bIsVan && (component == CAR_DOOR_LR || component == CAR_DOOR_RR)) {
seatOffset = 0.0f;
vehDoorOffset = vecPedVanRearDoorAnimOffset;
@@ -2019,7 +2019,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
}
if (seatPosMult > 0.2f || vehIsUpsideDown) {
- GetPosition() = neededPos;
+ SetPosition(neededPos);
SetHeading(m_fRotationCur);
} else {
@@ -2096,10 +2096,10 @@ CPed::PlayFootSteps(void)
float walkRunAssocBlend = 0.0f, idleAssocBlend = 0.0f;
for (; assoc; assoc = RpAnimBlendGetNextAssociation(assoc)) {
- if (assoc->flags & ASSOC_FLAG80) {
+ if (assoc->flags & ASSOC_WALK) {
walkRunAssoc = assoc;
walkRunAssocBlend += assoc->blendAmount;
- } else if ((assoc->flags & ASSOC_FLAG200) == 0) {
+ } else if ((assoc->flags & ASSOC_NOWALK) == 0) {
idleAssocBlend += assoc->blendAmount;
}
}
@@ -2351,7 +2351,7 @@ CPed::SetModelIndex(uint32 mi)
CEntity::SetModelIndex(mi);
RpAnimBlendClumpInit(GetClump());
RpAnimBlendClumpFillFrameArray(GetClump(), m_pFrames);
- CPedModelInfo *modelInfo = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
+ CPedModelInfo *modelInfo = (CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex());
SetPedStats(modelInfo->m_pedStatType);
m_headingRate = m_pedStats->m_headingChangeRate;
m_animGroup = (AssocGroupId) modelInfo->m_animGroup;
@@ -2401,7 +2401,7 @@ void
CPed::Teleport(CVector pos)
{
CWorld::Remove(this);
- GetPosition() = pos;
+ SetPosition(pos);
bIsStanding = false;
m_nPedStateTimer = 0;
m_actionX = 0.0f;
@@ -2919,7 +2919,7 @@ CPed::SetObjective(eObjective newObj, void *entity)
if (newObj == OBJECTIVE_SOLICIT) {
m_objectiveTimer = CTimer::GetTimeInMilliseconds() + 10000;
} else if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && CharCreatedBy == MISSION_CHAR &&
- (m_carInObjective->m_status == STATUS_PLAYER_DISABLED || CPad::GetPad(CWorld::PlayerInFocus)->ArePlayerControlsDisabled())) {
+ (m_carInObjective->GetStatus() == STATUS_PLAYER_DISABLED || CPad::GetPad(CWorld::PlayerInFocus)->ArePlayerControlsDisabled())) {
SetObjectiveTimer(14000);
} else {
m_objectiveTimer = 0;
@@ -3166,13 +3166,13 @@ CPed::ReactToAttack(CEntity *attacker)
&& (m_pMyVehicle->pDriver == this || m_pMyVehicle->pDriver && m_pMyVehicle->pDriver->m_nPedState == PED_DRIVING)) {
if (m_pMyVehicle->VehicleCreatedBy == RANDOM_VEHICLE
- && (m_pMyVehicle->m_status == STATUS_SIMPLE || m_pMyVehicle->m_status == STATUS_PHYSICS)
+ && (m_pMyVehicle->GetStatus() == STATUS_SIMPLE || m_pMyVehicle->GetStatus() == STATUS_PHYSICS)
&& m_pMyVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE) {
CCarCtrl::SwitchVehicleToRealPhysics(m_pMyVehicle);
m_pMyVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fUnkMaxVelocity;
- m_pMyVehicle->m_status = STATUS_PHYSICS;
+ m_pMyVehicle->SetStatus(STATUS_PHYSICS);
}
} else
#endif
@@ -3222,7 +3222,7 @@ CPed::TurnBody(void)
bool turnDone = true;
if (m_pLookTarget) {
- CVector &lookPos = m_pLookTarget->GetPosition();
+ const CVector &lookPos = m_pLookTarget->GetPosition();
lookDir = CGeneral::GetRadianAngleBetweenPoints(
lookPos.x,
@@ -3287,7 +3287,7 @@ CPed::Chat(void)
} else
Say(SOUND_PED_CHAT);
- } else if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG100)) {
+ } else if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG_XPRESS)) {
if (CGeneral::GetRandomNumber() < 20) {
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_XPRESS_SCRATCH, 4.0f);
@@ -3743,7 +3743,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
bool detectDieAnim = true;
if (m_nPedState == PED_FALL || m_nPedState == PED_GETUP) {
if (!IsPedHeadAbovePos(-0.3f)) {
- if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800))
+ if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL))
dieAnim = ANIM_FLOOR_HIT_F;
else
dieAnim = ANIM_FLOOR_HIT;
@@ -3765,7 +3765,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
if (IsPedHeadAbovePos(-0.3f)) {
dieAnim = NUM_ANIMS;
} else {
- if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800))
+ if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL))
dieAnim = ANIM_FLOOR_HIT_F;
else
dieAnim = ANIM_FLOOR_HIT;
@@ -3805,7 +3805,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
if (IsPedHeadAbovePos(-0.3f)) {
dieAnim = NUM_ANIMS;
} else {
- if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800))
+ if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL))
dieAnim = ANIM_FLOOR_HIT_F;
else
dieAnim = ANIM_FLOOR_HIT;
@@ -3848,7 +3848,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
if (IsPedHeadAbovePos(-0.3f)) {
dieAnim = NUM_ANIMS;
} else {
- if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800))
+ if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL))
dieAnim = ANIM_FLOOR_HIT_F;
else
dieAnim = ANIM_FLOOR_HIT;
@@ -4136,8 +4136,8 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
#ifdef VC_PED_PORTS
if (m_pMyVehicle) {
if (m_pMyVehicle->IsCar() && m_pMyVehicle->pDriver == this) {
- if (m_pMyVehicle->m_status == STATUS_SIMPLE) {
- m_pMyVehicle->m_status = STATUS_PHYSICS;
+ if (m_pMyVehicle->GetStatus() == STATUS_SIMPLE) {
+ m_pMyVehicle->SetStatus(STATUS_PHYSICS);
CCarCtrl::SwitchVehicleToRealPhysics(m_pMyVehicle);
}
m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
@@ -4151,7 +4151,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
m_fHealth = 0.0f;
if (m_pMyVehicle && m_pMyVehicle->pDriver == this) {
SetRadioStation();
- m_pMyVehicle->m_status = STATUS_ABANDONED;
+ m_pMyVehicle->SetStatus(STATUS_ABANDONED);
}
SetDie(dieAnim, dieDelta, dieSpeed);
/*
@@ -4183,7 +4183,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
}
m_fHealth = 0.0f;
if (player == this)
- m_pMyVehicle->m_status = STATUS_PLAYER_DISABLED;
+ m_pMyVehicle->SetStatus(STATUS_PLAYER_DISABLED);
SetDie(NUM_ANIMS, 4.0f, 0.0f);
return true;
@@ -4245,9 +4245,8 @@ CPed::SetGetUp(void)
CVehicle *veh = (CVehicle*)CPedPlacement::IsPositionClearOfCars(&GetPosition());
if (veh && veh->m_vehType != VEHICLE_TYPE_BIKE ||
collidingVeh && collidingVeh->IsVehicle() && collidingVeh->m_vehType != VEHICLE_TYPE_BIKE
- && ((uint8)(CTimer::GetFrameCounter() + m_randomSeed + 5) % 8
- || CCollision::ProcessColModels(GetMatrix(), *CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(),
- collidingVeh->GetMatrix(), *CModelInfo::GetModelInfo(collidingVeh->m_modelIndex)->GetColModel(),
+ && ((uint8)(CTimer::GetFrameCounter() + m_randomSeed + 5) % 8 ||
+ CCollision::ProcessColModels(GetMatrix(), *GetColModel(), collidingVeh->GetMatrix(), *collidingVeh->GetColModel(),
aTempPedColPts, nil, nil) > 0)) {
bGetUpAnimStarted = false;
@@ -4274,7 +4273,7 @@ CPed::SetGetUp(void)
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
}
- if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800))
+ if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL))
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_GETUP_FRONT, 1000.0f);
else
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_GETUP1, 1000.0f);
@@ -4504,7 +4503,7 @@ CPed::RestorePreviousState(void)
bIsRunning = false;
if (!bFindNewNodeAfterStateRestore) {
if (m_pNextPathNode) {
- CVector diff = m_pNextPathNode->pos - GetPosition();
+ CVector diff = m_pNextPathNode->GetPosition() - GetPosition();
if (diff.MagnitudeSqr() < sq(7.0f)) {
SetMoveState(PEDMOVE_WALK);
break;
@@ -4640,9 +4639,9 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
animType = 1;
}
}
- if (neededTurn <= DEGTORAD(90.0f) || veh->m_modelIndex == MI_RCBANDIT || vehPressedHorn || animType != 0) {
+ if (neededTurn <= DEGTORAD(90.0f) || veh->GetModelIndex() == MI_RCBANDIT || vehPressedHorn || animType != 0) {
SetLookFlag(veh, true);
- if ((CGeneral::GetRandomNumber() & 1) && veh->m_modelIndex != MI_RCBANDIT && animType == 0) {
+ if ((CGeneral::GetRandomNumber() & 1) && veh->GetModelIndex() != MI_RCBANDIT && animType == 0) {
stepAnim = ANIM_IDLE_TAXI;
} else {
@@ -5149,7 +5148,7 @@ CPed::FightStrike(CVector &touchedNodePos)
#ifdef PED_SKIN
// Have to animate a skinned clump because the initial col model is useless
if(IsClumpSkinned(GetClump()))
- ourCol = ((CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex))->AnimatePedColModelSkinned(GetClump());
+ ourCol = ((CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex()))->AnimatePedColModelSkinned(GetClump());
else
#endif
if (nearPed->m_nPedState == PED_FALL
@@ -5158,7 +5157,8 @@ CPed::FightStrike(CVector &touchedNodePos)
ourCol = &CTempColModels::ms_colModelPedGroundHit;
} else {
#ifdef ANIMATE_PED_COL_MODEL
- ourCol = CPedModelInfo::AnimatePedColModel(((CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex))->GetHitColModel(), RpClumpGetFrame(GetClump()));
+ ourCol = CPedModelInfo::AnimatePedColModel(((CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex()))->GetHitColModel(),
+ RpClumpGetFrame(GetClump()));
#else
ourCol = ((CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex))->GetHitColModel();
#endif
@@ -5916,7 +5916,7 @@ CPed::CreateDeadPedMoney(void)
if (!CGame::nastyGame)
return;
- int skin = m_modelIndex;
+ int skin = GetModelIndex();
if ((skin >= MI_COP && skin <= MI_FIREMAN) || CharCreatedBy == MISSION_CHAR || bInVehicle)
return;
@@ -6013,9 +6013,9 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack)
m_vehEnterType = vehEnterType;
if (m_vehEnterType == CAR_DOOR_LF) {
if (veh->pDriver && veh->pDriver->IsPlayer())
- veh->m_status = STATUS_PLAYER_DISABLED;
+ veh->SetStatus(STATUS_PLAYER_DISABLED);
else
- veh->m_status = STATUS_ABANDONED;
+ veh->SetStatus(STATUS_ABANDONED);
}
RemoveInCarAnims();
SetMoveState(PEDMOVE_NONE);
@@ -6397,7 +6397,7 @@ uint8
CPed::GetNearestTrainPedPosition(CVehicle *train, CVector &enterPos)
{
CVector enterStepOffset;
- CVehicleModelInfo *trainModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(train->m_modelIndex);
+ CVehicleModelInfo *trainModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(train->GetModelIndex());
CMatrix trainMat = CMatrix(train->GetMatrix());
CVector leftEntryPos, rightEntryPos, midEntryPos;
float distLeftEntry, distRightEntry, distMidEntry;
@@ -6472,7 +6472,7 @@ void
CPed::LineUpPedWithTrain(void)
{
CVector lineUpPos;
- CVehicleModelInfo *trainModel = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_pMyVehicle->m_modelIndex);
+ CVehicleModelInfo *trainModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(m_pMyVehicle->GetModelIndex());
CVector enterOffset(1.5f, 0.0f, -0.2f);
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
@@ -6504,7 +6504,7 @@ CPed::LineUpPedWithTrain(void)
lineUpPos += (GetPosition() - lineUpPos) * percentageLeft;
}
- GetPosition() = lineUpPos;
+ SetPosition(lineUpPos);
SetHeading(m_fRotationCur);
}
@@ -6535,7 +6535,7 @@ CPed::ExitCar(void)
// Car is upside down
if (m_pMyVehicle->GetUp().z > -0.8f) {
if (exitAnim != ANIM_CAR_CLOSE_RHS && exitAnim != ANIM_CAR_CLOSE_LHS && animTime <= 0.3f)
- LineUpPedWithCar((m_pMyVehicle->m_modelIndex == MI_DODO ? LINE_UP_TO_CAR_END : LINE_UP_TO_CAR_START));
+ LineUpPedWithCar((m_pMyVehicle->GetModelIndex() == MI_DODO ? LINE_UP_TO_CAR_END : LINE_UP_TO_CAR_START));
else
LineUpPedWithCar(LINE_UP_TO_CAR_END);
} else {
@@ -6925,10 +6925,10 @@ SelectClosestNodeForSeek(CPed *ped, CPathNode *node, CVector2D closeDist, CVecto
{
for (int i = 0; i < node->numLinks; i++) {
- CPathNode *testNode = &ThePaths.m_pathNodes[ThePaths.m_connections[i + node->firstLink]];
+ CPathNode *testNode = &ThePaths.m_pathNodes[ThePaths.ConnectedNode(i + node->firstLink)];
if (testNode && testNode != closeNode && testNode != closeNode2) {
- CVector2D posDiff(ped->m_vecSeekPos - testNode->pos);
+ CVector2D posDiff(ped->m_vecSeekPos - testNode->GetPosition());
float dist = posDiff.MagnitudeSqr();
if (farDist.MagnitudeSqr() > dist) {
@@ -6969,16 +6969,16 @@ CPed::FindBestCoordsFromNodes(CVector unused, CVector *bestCoords)
CVector2D seekPosDist (m_vecSeekPos - ourPos);
CPathNode *closestNode = &ThePaths.m_pathNodes[closestNodeId];
- CVector2D closeDist(m_vecSeekPos - closestNode->pos);
+ CVector2D closeDist(m_vecSeekPos - closestNode->GetPosition());
SelectClosestNodeForSeek(this, closestNode, closeDist, seekPosDist, closestNode, nil);
// Above function decided that going to the next node is more logical than seeking the object.
if (m_pNextPathNode) {
- CVector pathToNextNode = m_pNextPathNode->pos - ourPos;
+ CVector pathToNextNode = m_pNextPathNode->GetPosition() - ourPos;
if (pathToNextNode.MagnitudeSqr2D() < seekPosDist.MagnitudeSqr()) {
- *bestCoords = m_pNextPathNode->pos;
+ *bestCoords = m_pNextPathNode->GetPosition();
return true;
}
m_pNextPathNode = nil;
@@ -7043,7 +7043,7 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg)
return;
CVector forward(0.15f * ped->GetForward() + ped->GetPosition());
- forward.z += CModelInfo::GetModelInfo(ped->m_modelIndex)->GetColModel()->spheres->center.z + 0.25f;
+ forward.z += CModelInfo::GetModelInfo(ped->GetModelIndex())->GetColModel()->spheres->center.z + 0.25f;
CEntity *obstacle = CWorld::TestSphereAgainstWorld(forward, 0.25f, nil, true, true, false, true, false, false);
if (!obstacle) {
@@ -7483,7 +7483,7 @@ CPed::Seek(void)
if (!obstacle->IsVehicle() || ((CVehicle*)obstacle)->m_vehType == VEHICLE_TYPE_CAR) {
distanceToCountItDone = 2.5f;
} else {
- CVehicleModelInfo *vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(obstacle->m_modelIndex);
+ CVehicleModelInfo *vehModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(obstacle->GetModelIndex());
float yLength = vehModel->GetColModel()->boundingBox.max.y
- vehModel->GetColModel()->boundingBox.min.y;
distanceToCountItDone = yLength * 0.55f;
@@ -7671,7 +7671,7 @@ CPed::Flee(void)
}
if (m_pNextPathNode) {
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
if (m_nMoveState == PEDMOVE_RUN)
bIsRunning = true;
@@ -7940,9 +7940,9 @@ CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen)
CVector rfPos, lrPos, rrPos;
bool canEnter = false;
- CVehicleModelInfo *vehModel = (CVehicleModelInfo*)CModelInfo::GetModelInfo(veh->m_modelIndex);
+ CVehicleModelInfo *vehModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(veh->GetModelIndex());
- switch (veh->m_modelIndex) {
+ switch (veh->GetModelIndex()) {
case MI_BUS:
m_vehEnterType = CAR_DOOR_RF;
posToOpen = GetPositionToOpenCarDoor(veh, CAR_DOOR_RF);
@@ -8584,7 +8584,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
eWeaponType killMethod;
if (m_nPedState == PED_FALL || m_nPedState == PED_DIE) {
- if (!this->m_pCollidingEntity || car->m_status == STATUS_PLAYER)
+ if (!this->m_pCollidingEntity || car->GetStatus() == STATUS_PLAYER)
this->m_pCollidingEntity = car;
return;
}
@@ -8599,7 +8599,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
CVector distVec = GetPosition() - car->GetPosition();
- if ((impulse > 12.0f || car->m_modelIndex == MI_TRAIN) && !IsPlayer()) {
+ if ((impulse > 12.0f || car->GetModelIndex() == MI_TRAIN) && !IsPlayer()) {
nodeToDamage = PED_TORSO;
killMethod = WEAPONTYPE_RAMMEDBYCAR;
uint8 randVal = CGeneral::GetRandomNumber() & 3;
@@ -8616,11 +8616,11 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
}
bIsStanding = false;
damageDir = CPed::GetLocalDirection(-m_vecMoveSpeed);
- vehModel = (CVehicleModelInfo*)CModelInfo::GetModelInfo(car->m_modelIndex);
+ vehModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(car->GetModelIndex());
vehColModel = vehModel->GetColModel();
float carRightAndDistDotProd = DotProduct(distVec, car->GetRight());
- if (car->m_modelIndex == MI_TRAIN) {
+ if (car->GetModelIndex() == MI_TRAIN) {
killMethod = WEAPONTYPE_RUNOVERBYCAR;
nodeToDamage = PED_HEAD;
m_vecMoveSpeed = 0.9f * car->m_vecMoveSpeed;
@@ -8684,7 +8684,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
carHighestZ = (car->GetMatrix() * CVector(0.0f, vehColMaxY, vehColMaxZ)).z;
float highestZDist = carHighestZ - GetPosition().z;
if (highestZDist > 0.0f) {
- GetPosition().z += 0.5f * highestZDist;
+ GetMatrix().GetPosition().z += 0.5f * highestZDist;
carHighestZ += highestZDist * 0.25f;
}
carLength = vehColMaxY;
@@ -8780,7 +8780,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
bIsStanding = false;
uint8 fallDirection = GetLocalDirection(-car->m_vecMoveSpeed);
float damage;
- if (IsPlayer() && car->m_modelIndex == MI_TRAIN)
+ if (IsPlayer() && car->GetModelIndex() == MI_TRAIN)
damage = 150.0f;
else
damage = 30.0f;
@@ -8789,14 +8789,14 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
CPed::SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true);
if ((m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD)
- && !m_pCollidingEntity
- && (!IsPlayer() || bHasHitWall || car->m_modelIndex == MI_TRAIN || m_vecDamageNormal.z < -0.8f)) {
+ && !m_pCollidingEntity &&
+ (!IsPlayer() || bHasHitWall || car->GetModelIndex() == MI_TRAIN || m_vecDamageNormal.z < -0.8f)) {
m_pCollidingEntity = car;
}
bKnockedUpIntoAir = false;
- if (car->m_modelIndex != MI_TRAIN && !bHasHitWall) {
+ if (car->GetModelIndex() != MI_TRAIN && !bHasHitWall) {
m_vecMoveSpeed = car->m_vecMoveSpeed * 0.75f;
}
m_vecMoveSpeed.z = 0.0f;
@@ -8870,8 +8870,8 @@ CPed::LookForInterestingNodes(void)
for (ptrNode = sector->m_lists[ENTITYLIST_VEHICLES].first; ptrNode && !found; ptrNode = ptrNode->next) {
CVehicle *veh = (CVehicle*)ptrNode->item;
model = veh->GetModelInfo();
- if (model->m_num2dEffects != 0) {
- for (int e = 0; e < model->m_num2dEffects; e++) {
+ if (model->GetNum2dEffects() != 0) {
+ for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &veh->GetMatrix();
@@ -8887,9 +8887,9 @@ CPed::LookForInterestingNodes(void)
}
for (ptrNode = sector->m_lists[ENTITYLIST_OBJECTS].first; ptrNode && !found; ptrNode = ptrNode->next) {
CObject *obj = (CObject*)ptrNode->item;
- model = CModelInfo::GetModelInfo(obj->m_modelIndex);
- if (model->m_num2dEffects != 0) {
- for (int e = 0; e < model->m_num2dEffects; e++) {
+ model = CModelInfo::GetModelInfo(obj->GetModelIndex());
+ if (model->GetNum2dEffects() != 0) {
+ for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &obj->GetMatrix();
@@ -8905,9 +8905,9 @@ CPed::LookForInterestingNodes(void)
}
for (ptrNode = sector->m_lists[ENTITYLIST_BUILDINGS].first; ptrNode && !found; ptrNode = ptrNode->next) {
CBuilding *building = (CBuilding*)ptrNode->item;
- model = CModelInfo::GetModelInfo(building->m_modelIndex);
- if (model->m_num2dEffects != 0) {
- for (int e = 0; e < model->m_num2dEffects; e++) {
+ model = CModelInfo::GetModelInfo(building->GetModelIndex());
+ if (model->GetNum2dEffects() != 0) {
+ for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &building->GetMatrix();
@@ -8923,9 +8923,9 @@ CPed::LookForInterestingNodes(void)
}
for (ptrNode = sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first; ptrNode && !found; ptrNode = ptrNode->next) {
CBuilding *building = (CBuilding*)ptrNode->item;
- model = CModelInfo::GetModelInfo(building->m_modelIndex);
- if (model->m_num2dEffects != 0) {
- for (int e = 0; e < model->m_num2dEffects; e++) {
+ model = CModelInfo::GetModelInfo(building->GetModelIndex());
+ if (model->GetNum2dEffects() != 0) {
+ for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &building->GetMatrix();
@@ -9153,7 +9153,7 @@ CPed::MoveHeadToLook(void)
if (animTime > 4.0f / 30.0f && animTime - fuckUAssoc->timeStep > 4.0f / 30.0f) {
bool lookingToCop = false;
- if (m_pLookTarget->m_modelIndex == MI_POLICE
+ if (m_pLookTarget->GetModelIndex() == MI_POLICE
|| m_pLookTarget->IsPed() && ((CPed*)m_pLookTarget)->m_nPedType == PEDTYPE_COP) {
lookingToCop = true;
@@ -9213,7 +9213,7 @@ CPed::MoveHeadToLook(void)
} else {
animToPlay = ANIM_FUCKU;
}
- } else if (m_pedStats->m_temper > 49 || m_pLookTarget->m_modelIndex == MI_POLICE) {
+ } else if (m_pedStats->m_temper > 49 || m_pLookTarget->GetModelIndex() == MI_POLICE) {
animToPlay = ANIM_FUCKU;
}
} else if (notRocketLauncher && (CGeneral::GetRandomNumber() & 1)) {
@@ -9487,14 +9487,14 @@ CPed::ProcessControl(void)
#ifdef VC_PED_PORTS
if (bIsInWater) {
bIsStanding = false;
- m_ped_flagA2 = false;
+ bWasStanding = false;
CPhysical::ProcessControl();
}
#endif
return;
}
- m_ped_flagA2 = false;
+ bWasStanding = false;
if (bIsStanding) {
if (!CWorld::bForceProcessControl) {
if (m_pCurrentPhysSurface && m_pCurrentPhysSurface->bIsInSafePosition) {
@@ -9544,14 +9544,14 @@ CPed::ProcessControl(void)
#else
} else if (collidingEnt) {
#endif
- switch (collidingEnt->m_type)
+ switch (collidingEnt->GetType())
{
case ENTITY_TYPE_BUILDING:
case ENTITY_TYPE_OBJECT:
{
- CBaseModelInfo *collidingModel = CModelInfo::GetModelInfo(collidingEnt->m_modelIndex);
+ CBaseModelInfo *collidingModel = CModelInfo::GetModelInfo(collidingEnt->GetModelIndex());
CColModel *collidingCol = collidingModel->GetColModel();
- if (collidingEnt->IsObject() && ((CObject*)collidingEnt)->m_nSpecialCollisionResponseCases != COLLRESPONSE_CHANGE_THEN_SMASH
+ if (collidingEnt->IsObject() && ((CObject*)collidingEnt)->m_nSpecialCollisionResponseCases != COLLRESPONSE_FENCEPART
|| collidingCol->boundingBox.max.x < 3.0f
&& collidingCol->boundingBox.max.y < 3.0f) {
@@ -9653,17 +9653,17 @@ CPed::ProcessControl(void)
if (m_nPedState == PED_WANDER_PATH) {
m_pNextPathNode = &ThePaths.m_pathNodes[closestNodeId];
angleToFace = CGeneral::GetRadianAngleBetweenPoints(
- m_pNextPathNode->pos.x, m_pNextPathNode->pos.y,
+ m_pNextPathNode->GetX(), m_pNextPathNode->GetY(),
GetPosition().x, GetPosition().y);
} else {
- if (ThePaths.m_pathNodes[closestNodeId].pos.x == 0.0f
- || ThePaths.m_pathNodes[closestNodeId].pos.y == 0.0f) {
+ if (ThePaths.m_pathNodes[closestNodeId].GetX() == 0.0f
+ || ThePaths.m_pathNodes[closestNodeId].GetY() == 0.0f) {
posToHead = (3.0f * m_vecDamageNormal) + GetPosition();
posToHead.x += (CGeneral::GetRandomNumber() % 512) / 250.0f - 1.0f;
posToHead.y += (CGeneral::GetRandomNumber() % 512) / 250.0f - 1.0f;
} else {
- posToHead.x = ThePaths.m_pathNodes[closestNodeId].pos.x;
- posToHead.y = ThePaths.m_pathNodes[closestNodeId].pos.y;
+ posToHead.x = ThePaths.m_pathNodes[closestNodeId].GetX();
+ posToHead.y = ThePaths.m_pathNodes[closestNodeId].GetY();
}
angleToFace = CGeneral::GetRadianAngleBetweenPoints(
posToHead.x, posToHead.y,
@@ -9674,12 +9674,12 @@ CPed::ProcessControl(void)
}
} else {
angleToFace = CGeneral::GetRadianAngleBetweenPoints(
- ThePaths.m_pathNodes[closestNodeId].pos.x,
- ThePaths.m_pathNodes[closestNodeId].pos.y,
+ ThePaths.m_pathNodes[closestNodeId].GetX(),
+ ThePaths.m_pathNodes[closestNodeId].GetY(),
GetPosition().x,
GetPosition().y);
- CVector2D distToNode = ThePaths.m_pathNodes[closestNodeId].pos - GetPosition();
+ CVector2D distToNode = ThePaths.m_pathNodes[closestNodeId].GetPosition() - GetPosition();
CVector2D distToSeekPos = m_vecSeekPos - GetPosition();
if (DotProduct2D(distToNode, distToSeekPos) < 0.0f) {
@@ -9773,7 +9773,7 @@ CPed::ProcessControl(void)
if (collidingVeh != m_pCurrentPhysSurface || IsPlayer()) {
if (!bVehEnterDoorIsBlocked) {
- if (collidingVeh->m_status != STATUS_PLAYER || CharCreatedBy == MISSION_CHAR) {
+ if (collidingVeh->GetStatus() != STATUS_PLAYER || CharCreatedBy == MISSION_CHAR) {
// VC calls SetDirectionToWalkAroundVehicle instead if ped is in PED_SEEK_CAR.
SetDirectionToWalkAroundObject(collidingVeh);
@@ -9959,7 +9959,7 @@ CPed::ProcessControl(void)
}
} else if (!bVehEnterDoorIsBlocked) {
- if (collidingVeh->m_status != STATUS_PLAYER || CharCreatedBy == MISSION_CHAR) {
+ if (collidingVeh->GetStatus() != STATUS_PLAYER || CharCreatedBy == MISSION_CHAR) {
SetDirectionToWalkAroundObject(collidingVeh);
@@ -9978,7 +9978,7 @@ CPed::ProcessControl(void)
} else {
DMAudio.PlayOneShot(collidingVeh->m_audioEntityId, SOUND_CAR_PED_COLLISION, m_fDamageImpulse);
if (IsPlayer()) {
- CColModel *collidingCol = CModelInfo::GetModelInfo(collidingVeh->m_modelIndex)->GetColModel();
+ CColModel *collidingCol = CModelInfo::GetModelInfo(collidingVeh->GetModelIndex())->GetColModel();
CVector colMinVec = collidingCol->boundingBox.min;
CVector colMaxVec = collidingCol->boundingBox.max;
@@ -10040,7 +10040,7 @@ CPed::ProcessControl(void)
float damage;
if (driver && driver->IsPlayer()) {
damage = vehRightVecAndSpeedDotProd * 1000.0f;
- } else if (collidingVeh->m_modelIndex == MI_TRAIN) {
+ } else if (collidingVeh->GetModelIndex() == MI_TRAIN) {
damage = 50.0f;
} else {
damage = 20.0f;
@@ -10106,7 +10106,7 @@ CPed::ProcessControl(void)
}
if ((bIsInTheAir && !DyingOrDead())
#ifdef VC_PED_PORTS
- || (!bIsStanding && !m_ped_flagA2 && m_nPedState == PED_FALL)
+ || (!bIsStanding && !bWasStanding && m_nPedState == PED_FALL)
#endif
) {
if (m_nPedStateTimer <= 1000 && m_nPedStateTimer) {
@@ -10126,7 +10126,7 @@ CPed::ProcessControl(void)
if ((m_nPedStateTimer <= 50.0f / (4.0f * adjustedTs) || m_nPedStateTimer * 0.01f <= forceDir.MagnitudeSqr())
&& (m_nCollisionRecords <= 1 || m_nPedStateTimer <= 50.0f / (2.0f * adjustedTs) || m_nPedStateTimer * 1.0f / 250.0f <= Abs(forceDir.z))) {
- if (m_nCollisionRecords == 1 && m_aCollisionRecords[0] != nil && m_aCollisionRecords[0]->m_type == ENTITY_TYPE_BUILDING
+ if (m_nCollisionRecords == 1 && m_aCollisionRecords[0] != nil && m_aCollisionRecords[0]->IsBuilding()
&& m_nPedStateTimer > 50.0f / (2.0f * adjustedTs) && m_nPedStateTimer * 1.0f / 250.0f > Abs(forceDir.z)) {
offsetToCheck.x = -forceDir.y;
#ifdef VC_PED_PORTS
@@ -10169,8 +10169,8 @@ CPed::ProcessControl(void)
}
if (flyDir != 0 && !bSomeVCflag1) {
- GetPosition() = (flyDir == 2 ? obstacleForFlyingOtherDir.point : obstacleForFlying.point);
- GetPosition().z += FEET_OFFSET;
+ SetPosition((flyDir == 2 ? obstacleForFlyingOtherDir.point : obstacleForFlying.point));
+ GetMatrix().GetPosition().z += FEET_OFFSET;
GetMatrix().UpdateRW();
SetLanding();
bIsStanding = true;
@@ -10184,7 +10184,7 @@ CPed::ProcessControl(void)
forceDir.z = 4.0f;
ApplyMoveForce(forceDir);
- GetPosition() += 0.25f * offsetToCheck;
+ GetMatrix().GetPosition() += 0.25f * offsetToCheck;
m_fRotationCur = CGeneral::GetRadianAngleBetweenPoints(offsetToCheck.x, offsetToCheck.y, 0.0f, 0.0f);
m_fRotationCur = CGeneral::LimitRadianAngle(m_fRotationCur);
@@ -10276,13 +10276,13 @@ CPed::ProcessControl(void)
if (CWorld::ProcessVerticalLine(offsetToCheck, GetPosition().z - FEET_OFFSET, foundCol, foundEnt, true, true, false, true, false, false, nil)) {
#ifdef VC_PED_PORTS
if (!bSomeVCflag1 || FEET_OFFSET + foundCol.point.z < GetPosition().z) {
- GetPosition().z = FEET_OFFSET + foundCol.point.z;
+ GetMatrix().GetPosition().z = FEET_OFFSET + foundCol.point.z;
GetMatrix().UpdateRW();
if (bSomeVCflag1)
bSomeVCflag1 = false;
}
#else
- GetPosition().z = FEET_OFFSET + foundCol.point.z;
+ GetMatrix().GetPosition().z = FEET_OFFSET + foundCol.point.z;
GetMatrix().UpdateRW();
#endif
SetLanding();
@@ -10994,7 +10994,7 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
} else if (ped->m_nPedType == PEDTYPE_COP) {
ped->QuitEnteringCar();
if (ped->m_pedInObjective && ped->m_pedInObjective->m_nPedState == PED_DRIVING) {
- veh->m_status = STATUS_PLAYER_DISABLED;
+ veh->SetStatus(STATUS_PLAYER_DISABLED);
((CCopPed*)ped)->SetArrestPlayer(ped->m_pedInObjective);
} else if (!veh->IsDoorMissing(DOOR_FRONT_RIGHT)) {
((CAutomobile*)veh)->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_SWINGING);
@@ -11145,7 +11145,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
veh->m_nNumGettingIn = 0;
veh->m_nGettingInFlags = 0;
veh->bIsHandbrakeOn = true;
- veh->m_status = STATUS_PLAYER_DISABLED;
+ veh->SetStatus(STATUS_PLAYER_DISABLED);
}
return;
}
@@ -11190,7 +11190,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
driver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh);
if (driver->IsPlayer()) {
veh->bIsHandbrakeOn = true;
- veh->m_status = STATUS_PLAYER_DISABLED;
+ veh->SetStatus(STATUS_PLAYER_DISABLED);
}
driver->bBusJacked = true;
veh->bIsBeingCarJacked = false;
@@ -11562,7 +11562,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
#endif
CPedPlacement::FindZCoorForPed(&posAfterBeingDragged);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- ped->GetPosition() = posAfterBeingDragged;
+ ped->SetPosition(posAfterBeingDragged);
if (ped->m_pMyVehicle && !ped->m_pMyVehicle->IsRoomForPedToLeaveCar(ped->m_vehEnterType, &vecPedDraggedOutCarAnimOffset)) {
ped->PositionPedOutOfCollision();
@@ -11704,11 +11704,11 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
#if defined(FIX_BUGS) || defined(VC_PED_PORTS)
CCarCtrl::RegisterVehicleOfInterest(veh);
#endif
- if (veh->m_status == STATUS_SIMPLE) {
+ if (veh->GetStatus() == STATUS_SIMPLE) {
veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.00001f);
veh->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
}
- veh->m_status = STATUS_PLAYER;
+ veh->SetStatus(STATUS_PLAYER);
AudioManager.PlayerJustGotInCar();
}
veh->SetDriver(ped);
@@ -11729,19 +11729,19 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (ped->IsPlayer()) {
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
- if (veh->m_status == STATUS_SIMPLE) {
+ if (veh->GetStatus() == STATUS_SIMPLE) {
veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
veh->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
}
- veh->m_status = STATUS_PLAYER;
+ veh->SetStatus(STATUS_PLAYER);
}
AudioManager.PlayerJustGotInCar();
} else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
- if (veh->m_status == STATUS_SIMPLE) {
+ if (veh->GetStatus() == STATUS_SIMPLE) {
veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
veh->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
}
- veh->m_status = STATUS_PHYSICS;
+ veh->SetStatus(STATUS_PHYSICS);
}
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
@@ -11979,7 +11979,7 @@ CPed::RegisterThreatWithGangPeds(CEntity *attacker)
}
if (attackerPed && attackerPed->IsPlayer() && (attackerPed->m_nPedState == PED_CARJACK || attackerPed->bInVehicle)) {
- if (!attackerPed->m_pMyVehicle || attackerPed->m_pMyVehicle->m_modelIndex != MI_TOYZ) {
+ if (!attackerPed->m_pMyVehicle || attackerPed->m_pMyVehicle->GetModelIndex() != MI_TOYZ) {
int16 lastVehicle;
CEntity *vehicles[8];
CWorld::FindObjectsInRange(GetPosition(), 30.0f, true, &lastVehicle, 6, vehicles, false, true, false, false, false);
@@ -11998,7 +11998,7 @@ CPed::RegisterThreatWithGangPeds(CEntity *attacker)
if (nearVeh->IsVehicleNormal() && nearVeh->IsCar()) {
nearVeh->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * nearVeh->pHandling->Transmission.fUnkMaxVelocity * 0.8f;
nearVeh->AutoPilot.m_nCarMission = MISSION_RAMPLAYER_FARAWAY;
- nearVeh->m_status = STATUS_PHYSICS;
+ nearVeh->SetStatus(STATUS_PHYSICS);
nearVeh->AutoPilot.m_nTempAction = TEMPACT_NONE;
nearVeh->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
}
@@ -12187,7 +12187,7 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg)
CVector posFromZ = ped->GetPosition();
CPedPlacement::FindZCoorForPed(&posFromZ);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- ped->GetPosition() = posFromZ;
+ ped->SetPosition(posFromZ);
veh = ped->m_pMyVehicle;
if (veh) {
if (ped->m_nPedType == PEDTYPE_PROSTITUTE) {
@@ -12205,7 +12205,7 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg)
veh->m_nGettingOutFlags &= ~GetCarDoorFlag(ped->m_vehEnterType);
if (veh->pDriver == ped) {
veh->RemoveDriver();
- veh->m_status = STATUS_ABANDONED;
+ veh->SetStatus(STATUS_ABANDONED);
if (veh->m_nDoorLock == CARLOCK_LOCKED_INITIALLY)
veh->m_nDoorLock = CARLOCK_UNLOCKED;
if (ped->m_nPedType == PEDTYPE_COP && veh->IsLawEnforcementVehicle())
@@ -12310,7 +12310,7 @@ CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg)
posAfterExit += ped->GetPosition();
CPedPlacement::FindZCoorForPed(&posAfterExit);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- ped->GetPosition() = posAfterExit;
+ ped->SetPosition(posAfterExit);
ped->SetHeading(ped->m_fRotationCur);
veh->RemovePassenger(ped);
}
@@ -12342,9 +12342,9 @@ CPed::PlacePedOnDryLand(void)
foundColZ = foundCol.point.z;
if (foundColZ >= waterLevel) {
posToCheck.z = 0.8f + foundColZ;
- GetPosition() = posToCheck;
+ SetPosition(posToCheck);
bIsStanding = true;
- m_ped_flagA2 = true;
+ bWasStanding = true;
return true;
}
}
@@ -12360,9 +12360,9 @@ CPed::PlacePedOnDryLand(void)
return false;
posToCheck.z = 0.8f + foundColZ;
- GetPosition() = posToCheck;
+ SetPosition(posToCheck);
bIsStanding = true;
- m_ped_flagA2 = true;
+ bWasStanding = true;
return true;
}
@@ -12388,7 +12388,7 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void
finalPos = finalLocalPos + ped->GetPosition();
CPedPlacement::FindZCoorForPed(&finalPos);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- ped->GetPosition() = finalPos;
+ ped->SetPosition(finalPos);
if (veh) {
ped->m_fRotationDest = veh->GetForward().Heading() - HALFPI;
@@ -12524,11 +12524,11 @@ CPed::PositionPedOutOfCollision(void)
// We refrain from using posNearVeh, probably because of it may be top of the vehicle.
if (putSomewhereClose) {
- GetPosition() = posSomewhereClose;
+ SetPosition(posSomewhereClose);
} else {
CVector vehSize = veh->GetModelInfo()->GetColModel()->boundingBox.max;
- GetPosition() = posNearVeh;
- GetPosition().z += vehSize.z;
+ posNearVeh.z += vehSize.z;
+ SetPosition(posNearVeh);
}
return true;
}
@@ -12706,7 +12706,7 @@ CPed::renderLimb(int node)
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
int idx = RpHAnimIDGetIndex(hier, m_pFrames[node]->nodeID);
RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
- CPedModelInfo *mi = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
+ CPedModelInfo *mi = (CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex());
RpAtomic *atomic;
switch(node){
case PED_HEAD:
@@ -12846,7 +12846,7 @@ CPed::ProcessObjective(void)
|| m_pMyVehicle->m_vecMoveSpeed.MagnitudeSqr() >= sq(0.02f)) {
if (m_pMyVehicle->pDriver == this
&& !m_pMyVehicle->m_nGettingInFlags) {
- m_pMyVehicle->m_status = STATUS_PHYSICS;
+ m_pMyVehicle->SetStatus(STATUS_PHYSICS);
m_pMyVehicle->AutoPilot.m_nPrevRouteNode = 0;
if (m_nPedType == PEDTYPE_COP) {
m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->m_nWantedLevel * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fUnkMaxVelocity);
@@ -12904,7 +12904,7 @@ CPed::ProcessObjective(void)
if (closestNode >= 0) {
int16 colliding;
CWorld::FindObjectsKindaColliding(
- ThePaths.m_pathNodes[closestNode].pos, 10.0f, true, &colliding, 2, nil, false, true, true, false, false);
+ ThePaths.m_pathNodes[closestNode].GetPosition(), 10.0f, true, &colliding, 2, nil, false, true, true, false, false);
if (!colliding) {
CZoneInfo zoneInfo;
int chosenCarClass;
@@ -12912,10 +12912,10 @@ CPed::ProcessObjective(void)
int chosenModel = CCarCtrl::ChooseModel(&zoneInfo, &ourPos, &chosenCarClass);
CAutomobile *newVeh = new CAutomobile(chosenModel, RANDOM_VEHICLE);
if (newVeh) {
- newVeh->GetPosition() = ThePaths.m_pathNodes[closestNode].pos;
- newVeh->GetPosition().z += 4.0f;
+ newVeh->GetMatrix().GetPosition() = ThePaths.m_pathNodes[closestNode].GetPosition();
+ newVeh->GetMatrix().GetPosition().z += 4.0f;
newVeh->SetHeading(DEGTORAD(200.0f));
- newVeh->m_status = STATUS_ABANDONED;
+ newVeh->SetStatus(STATUS_ABANDONED);
newVeh->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(newVeh);
m_pMyVehicle = newVeh;
@@ -13017,7 +13017,7 @@ CPed::ProcessObjective(void)
float distWithTargetSc = distWithTarget.Magnitude();
if (m_pedInObjective->bInVehicle && m_pedInObjective->m_nPedState != PED_DRAG_FROM_CAR) {
CVehicle *vehOfTarget = m_pedInObjective->m_pMyVehicle;
- if (vehOfTarget->bIsInWater || vehOfTarget->m_status == STATUS_PLAYER_DISABLED
+ if (vehOfTarget->bIsInWater || vehOfTarget->GetStatus() == STATUS_PLAYER_DISABLED
|| m_pedInObjective->IsPlayer() && CPad::GetPad(0)->ArePlayerControlsDisabled()) {
SetIdle();
return;
@@ -13112,7 +13112,7 @@ CPed::ProcessObjective(void)
FindBestCoordsFromNodes(m_vecSeekPos, &bestCoords);
if (m_pNextPathNode)
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
} else {
@@ -13424,7 +13424,7 @@ CPed::ProcessObjective(void)
}
}
if (foundSeat) {
- GetPosition() = GetPositionToOpenCarDoor(m_carInObjective, m_vehEnterType);
+ SetPosition(GetPositionToOpenCarDoor(m_carInObjective, m_vehEnterType));
SetEnterCar(m_carInObjective, m_vehEnterType);
}
}
@@ -13666,7 +13666,7 @@ CPed::ProcessObjective(void)
FindBestCoordsFromNodes(m_vecSeekPos, &bestCoords);
if (m_pNextPathNode)
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
}
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
}
@@ -14033,7 +14033,7 @@ CPed::SetSeekBoatPosition(CVehicle *boat)
void
CPed::SetExitTrain(CVehicle* train)
{
- if (m_nPedState == PED_EXIT_TRAIN || train->m_status != STATUS_TRAIN_NOT_MOVING || !((CTrain*)train)->Doors[0].IsFullyOpen())
+ if (m_nPedState == PED_EXIT_TRAIN || train->GetStatus() != STATUS_TRAIN_NOT_MOVING || !((CTrain*)train)->Doors[0].IsFullyOpen())
return;
/*
@@ -14098,7 +14098,7 @@ void
CPed::SetDirectionToWalkAroundObject(CEntity *obj)
{
float distLimitForTimer = 8.0f;
- CColModel *objCol = CModelInfo::GetModelInfo(obj->m_modelIndex)->GetColModel();
+ CColModel *objCol = CModelInfo::GetModelInfo(obj->GetModelIndex())->GetColModel();
CVector objColMin = objCol->boundingBox.min;
CVector objColMax = objCol->boundingBox.max;
CVector objColCenter = (objColMin + objColMax) / 2.0f;
@@ -14117,7 +14117,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
#ifdef TOGGLEABLE_BETA_FEATURES
if (!bMakePedsRunToPhonesToReportCrimes)
#endif
- if (CharCreatedBy != MISSION_CHAR && obj->m_modelIndex == MI_PHONEBOOTH1) {
+ if (CharCreatedBy != MISSION_CHAR && obj->GetModelIndex() == MI_PHONEBOOTH1) {
bool isRunning = m_nMoveState == PEDMOVE_RUN || m_nMoveState == PEDMOVE_SPRINT;
SetFindPathAndFlee(obj, 5000, !isRunning);
return;
@@ -14133,7 +14133,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
if (objMat.GetUp().z < 0.0f)
objUpsideDown = true;
- if (obj->m_modelIndex != MI_TRAFFICLIGHTS && obj->m_modelIndex != MI_SINGLESTREETLIGHTS1 && obj->m_modelIndex != MI_SINGLESTREETLIGHTS2) {
+ if (obj->GetModelIndex() != MI_TRAFFICLIGHTS && obj->GetModelIndex() != MI_SINGLESTREETLIGHTS1 && obj->GetModelIndex() != MI_SINGLESTREETLIGHTS2) {
objColCenter = obj->GetMatrix() * objColCenter;
} else {
checkIntervalInDist = 0.4f;
@@ -14650,8 +14650,8 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
CColPoint intersectionPoint;
CColLine ourLine;
- CColModel *ourCol = CModelInfo::GetModelInfo(m_modelIndex)->GetColModel();
- CColModel *hisCol = CModelInfo::GetModelInfo(collidingEnt->m_modelIndex)->GetColModel();
+ CColModel *ourCol = CModelInfo::GetModelInfo(GetModelIndex())->GetColModel();
+ CColModel *hisCol = CModelInfo::GetModelInfo(collidingEnt->GetModelIndex())->GetColModel();
if (!bUsesCollision)
return false;
@@ -14660,7 +14660,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
collidedWithBoat = true;
// ofc we're not vehicle
- if (!m_bIsVehicleBeingShifted && !m_phy_flagA80
+ if (!m_bIsVehicleBeingShifted && !bSkipLineCol
#ifdef VC_PED_PORTS
&& !collidingEnt->IsPed()
#endif
@@ -14671,7 +14671,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
#endif
if (bIsStanding) {
bIsStanding = false;
- m_ped_flagA2 = true;
+ bWasStanding = true;
}
bCollisionProcessed = true;
m_fCollisionSpeed += m_vecMoveSpeed.Magnitude2D() * CTimer::GetTimeStep();
@@ -14684,7 +14684,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
} else {
CVector pos = GetPosition();
float potentialGroundZ = GetPosition().z - FEET_OFFSET;
- if (m_ped_flagA2) {
+ if (bWasStanding) {
pos.z += -0.25f;
potentialGroundZ += gravityEffect;
}
@@ -14692,12 +14692,12 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
bStillOnValidPoly = true;
#ifdef VC_PED_PORTS
if(!bSomeVCflag1 || FEET_OFFSET + intersectionPoint.point.z < GetPosition().z) {
- GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
+ GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
if (bSomeVCflag1)
bSomeVCflag1 = false;
}
#else
- GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
+ GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
#endif
m_vecMoveSpeed.z = 0.0f;
@@ -14716,7 +14716,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
// 0.52f should be a ped's approx. radius
float totalRadiusWhenCollided = collidingEnt->GetBoundRadius() + 0.52f - gravityEffect;
- if (m_ped_flagA2) {
+ if (bWasStanding) {
if (collidedWithBoat) {
potentialCenter.z += 2.0f * gravityEffect;
totalRadiusWhenCollided += Abs(gravityEffect);
@@ -14728,7 +14728,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
ourLine.p0 = GetPosition();
ourLine.p1 = GetPosition();
ourLine.p1.z = GetPosition().z - FEET_OFFSET;
- if (m_ped_flagA2) {
+ if (bWasStanding) {
ourLine.p1.z = ourLine.p1.z + gravityEffect;
ourLine.p0.z = ourLine.p0.z + -0.25f;
}
@@ -14736,7 +14736,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
belowTorsoCollided = CCollision::ProcessVerticalLine(ourLine, collidingEnt->GetMatrix(), *hisCol,
intersectionPoint, minDist, false, &m_collPoly);
- if (collidedWithBoat && m_ped_flagA2 && !belowTorsoCollided) {
+ if (collidedWithBoat && bWasStanding && !belowTorsoCollided) {
ourLine.p0.z = ourLine.p1.z;
ourLine.p1.z = ourLine.p1.z + gravityEffect;
belowTorsoCollided = CCollision::ProcessVerticalLine(ourLine, collidingEnt->GetMatrix(), *hisCol,
@@ -14770,12 +14770,12 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
}
#ifdef VC_PED_PORTS
if (!bSomeVCflag1 || FEET_OFFSET + intersectionPoint.point.z < GetPosition().z) {
- GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
+ GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
if (bSomeVCflag1)
bSomeVCflag1 = false;
}
#else
- GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
+ GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
#endif
m_nSurfaceTouched = intersectionPoint.surfaceB;
if (m_nSurfaceTouched == SURFACE_STONE) {
@@ -14817,7 +14817,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
}
#else
float speedSqr = 0.0f;
- if (!m_ped_flagA2) {
+ if (!bWasStanding) {
if (m_vecMoveSpeed.z >= -0.25f && (speedSqr = m_vecMoveSpeed.MagnitudeSqr()) <= sq(0.5f)) {
if (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL) && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) {
@@ -14856,13 +14856,13 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
if (!collidingEnt->IsBuilding())
((CPhysical*)collidingEnt)->AddCollisionRecord(this);
- if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->bIsStatic)) {
+ if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->IsStatic())) {
bHasHitWall = true;
}
}
- if (collidingEnt->IsBuilding() || collidingEnt->bIsStatic) {
+ if (collidingEnt->IsBuilding() || collidingEnt->IsStatic()) {
- if (m_ped_flagA2) {
+ if (bWasStanding) {
CVector sphereNormal;
float normalLength;
for(int sphere = 0; sphere < ourCollidedSpheres; sphere++) {
@@ -14880,7 +14880,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
float speed = m_vecMoveSpeed.Magnitude2D();
sphereNormal.x = -m_vecMoveSpeed.x / Max(0.001f, speed);
sphereNormal.y = -m_vecMoveSpeed.y / Max(0.001f, speed);
- GetPosition().z -= 0.05f;
+ GetMatrix().GetPosition().z -= 0.05f;
bSomeVCflag1 = true;
}
#endif
@@ -15106,7 +15106,7 @@ CPed::SetRadioStation(void)
if (IsPlayer() || !m_pMyVehicle || m_pMyVehicle->pDriver != this)
return;
- uint8 category = GetPedRadioCategory(m_modelIndex);
+ uint8 category = GetPedRadioCategory(GetModelIndex());
if (DMAudio.IsMP3RadioChannelAvailable()) {
if (CGeneral::GetRandomNumber() & 15) {
for (orderInCat = 0; orderInCat < 4; orderInCat++) {
@@ -15137,7 +15137,7 @@ CPed::SetRadioStation(void)
inline bool
CPed::IsNotInWreckedVehicle()
{
- return m_pMyVehicle != nil && m_pMyVehicle->m_status != STATUS_WRECKED;
+ return m_pMyVehicle != nil && m_pMyVehicle->GetStatus() != STATUS_WRECKED;
}
void
@@ -15196,7 +15196,7 @@ CPed::PreRender(void)
if (CWeather::Rain > 0.3f && TheCamera.SoundDistUp > 15.0f) {
if ((TheCamera.GetPosition() - GetPosition()).Magnitude() < 25.0f) {
bool doSplashUp = true;
- CColModel *ourCol = CModelInfo::GetModelInfo(m_modelIndex)->GetColModel();
+ CColModel *ourCol = CModelInfo::GetModelInfo(GetModelIndex())->GetColModel();
CVector speed = FindPlayerSpeed();
if (Abs(speed.x) <= 0.05f && Abs(speed.y) <= 0.05f) {
@@ -15669,11 +15669,11 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
zForPed = Max(foundColZ, foundColZ2);
if (zForPed > -99.0f)
- GetPosition().z = FEET_OFFSET + zForPed;
+ GetMatrix().GetPosition().z = FEET_OFFSET + zForPed;
} else {
if (veh->GetUp().z > -0.8f) {
bool addDoorSmoke = false;
- if (veh->m_modelIndex == MI_YARDIE)
+ if (veh->GetModelIndex() == MI_YARDIE)
addDoorSmoke = true;
switch (m_vehEnterType) {
@@ -15759,9 +15759,9 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
SetRadioStation();
if (veh->pDriver == this) {
if (IsPlayer())
- veh->m_status = STATUS_PLAYER_DISABLED;
+ veh->SetStatus(STATUS_PLAYER_DISABLED);
else
- veh->m_status = STATUS_ABANDONED;
+ veh->SetStatus(STATUS_ABANDONED);
}
}
}
@@ -15915,8 +15915,8 @@ CPed::ScanForInterestingStuff(void)
for (int i = 0; i < lastVehicle; i++) {
CVehicle* veh = (CVehicle*)vehicles[i];
- if (veh->m_modelIndex == MI_MRWHOOP) {
- if (veh->m_status != STATUS_ABANDONED && veh->m_status != STATUS_WRECKED) {
+ if (veh->GetModelIndex() == MI_MRWHOOP) {
+ if (veh->GetStatus() != STATUS_ABANDONED && veh->GetStatus() != STATUS_WRECKED) {
if ((GetPosition() - veh->GetPosition()).Magnitude() < 5.0f) {
SetObjective(OBJECTIVE_BUY_ICE_CREAM, veh);
return;
@@ -16132,11 +16132,11 @@ CPed::SeekCar(void)
SetMoveState(PEDMOVE_STILL);
return;
}
- if (vehToSeek->m_modelIndex == MI_COACH) {
+ if (vehToSeek->GetModelIndex() == MI_COACH) {
GetNearestDoor(vehToSeek, dest);
} else {
if (vehToSeek->IsTrain()) {
- if (vehToSeek->m_status != STATUS_TRAIN_NOT_MOVING) {
+ if (vehToSeek->GetStatus() != STATUS_TRAIN_NOT_MOVING) {
RestorePreviousObjective();
RestorePreviousState();
return;
@@ -16222,7 +16222,7 @@ CPed::SeekCar(void)
} else if (vehToSeek->m_nNumGettingIn < vehToSeek->m_nNumMaxPassengers + 1
&& vehToSeek->CanPedEnterCar()) {
- switch (vehToSeek->m_status) {
+ switch (vehToSeek->GetStatus()) {
case STATUS_PLAYER:
case STATUS_SIMPLE:
case STATUS_PHYSICS:
@@ -16270,7 +16270,7 @@ void
CPed::ServiceTalking(void)
{
if (!bBodyPartJustCameOff || m_bodyPartBleeding != PED_HEAD) {
- if (CGeneral::faststricmp(CModelInfo::GetModelInfo(m_modelIndex)->GetName(), "bomber")) {
+ if (CGeneral::faststricmp(CModelInfo::GetModelInfo(GetModelIndex())->GetName(), "bomber")) {
if (m_nPedState == PED_ON_FIRE)
m_queuedSound = SOUND_PED_BURNING;
} else {
@@ -16301,7 +16301,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
if (CGame::nastyGame) {
if (hitLevel == HITLEVEL_GROUND) {
CAnimBlendAssociation *floorHitAssoc;
- if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) {
+ if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) {
floorHitAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f);
} else {
floorHitAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[FIGHTMOVE_HITONFLOOR].animId, 8.0f);
@@ -16323,7 +16323,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
}
} else if (m_nPedState == PED_FALL) {
if (hitLevel == HITLEVEL_GROUND && !IsPedHeadAbovePos(-0.3f)) {
- CAnimBlendAssociation *floorHitAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800) ?
+ CAnimBlendAssociation *floorHitAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL) ?
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f) :
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f);
if (floorHitAssoc) {
@@ -16806,7 +16806,7 @@ CPed::SetPedPositionInCar(void)
return;
}
}
- CVehicleModelInfo *vehModel = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_pMyVehicle->m_modelIndex);
+ CVehicleModelInfo *vehModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(m_pMyVehicle->GetModelIndex());
CMatrix newMat(m_pMyVehicle->GetMatrix());
CVector seatPos;
if (m_pMyVehicle->pDriver == this) {
@@ -16924,7 +16924,7 @@ CPed::SpawnFlyingComponent(int pedNode, int8 direction)
default:
break;
}
- obj->RefModelInfo(m_modelIndex);
+ obj->RefModelInfo(GetModelIndex());
obj->AttachToRwObject((RwObject*)clump);
obj->m_fMass = 15.0f;
obj->m_fTurnMass = 5.0f;
@@ -16934,7 +16934,7 @@ CPed::SpawnFlyingComponent(int pedNode, int8 direction)
obj->ObjectCreatedBy = TEMP_OBJECT;
obj->bIsStatic = false;
obj->bIsPickup = false;
- obj->m_nSpecialCollisionResponseCases = COLLRESPONSE_SPLIT_MODEL;
+ obj->m_nSpecialCollisionResponseCases = COLLRESPONSE_SMALLBOX;
// life time - the more objects the are, the shorter this one will live
CObject::nNoTempObjects++;
@@ -16994,15 +16994,15 @@ CPed::WarpPedIntoCar(CVehicle *car)
return;
if (IsPlayer()) {
- car->m_status = STATUS_PLAYER;
+ car->SetStatus(STATUS_PLAYER);
AudioManager.PlayerJustGotInCar();
CCarCtrl::RegisterVehicleOfInterest(car);
} else {
- car->m_status = STATUS_PHYSICS;
+ car->SetStatus(STATUS_PHYSICS);
}
CWorld::Remove(this);
- GetPosition() = car->GetPosition();
+ SetPosition(car->GetPosition());
CWorld::Add(this);
if (car->bIsAmbulanceOnDuty) {
@@ -17148,7 +17148,7 @@ CPed::SetMoveAnim(void)
else
animGroupToUse = m_animGroup;
- CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG400);
+ CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK);
if (!animAssoc) {
CAnimBlendAssociation *fightIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
animAssoc = fightIdleAssoc;
@@ -17324,7 +17324,7 @@ CPed::WanderPath(void)
if (m_nMoveState == PEDMOVE_STILL || m_nMoveState == PEDMOVE_NONE)
SetMoveState(PEDMOVE_WALK);
}
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
m_vecSeekPos.z += 1.0f;
// Only returns true when ped is stuck(not stopped) I think, then we should assign new direction or wait state to him.
@@ -17602,7 +17602,7 @@ CPed::SetCarJack(CVehicle* car)
pedInSeat = car->pDriver;
if (m_fHealth > 0.0f && (IsPlayer() || m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS ||
- (car->VehicleCreatedBy != MISSION_VEHICLE && car->m_modelIndex != MI_DODO)))
+ (car->VehicleCreatedBy != MISSION_VEHICLE && car->GetModelIndex() != MI_DODO)))
if (pedInSeat && !pedInSeat->IsPedDoingDriveByShooting() && pedInSeat->m_nPedState == PED_DRIVING)
if (m_nPedState != PED_CARJACK && !m_pVehicleAnim)
if ((car->IsDoorReady(door) || car->IsDoorFullyOpen(door)))
@@ -17658,7 +17658,7 @@ CPed::SetExitBoat(CVehicle *boat)
m_nPedState = PED_IDLE;
CVector firstPos = GetPosition();
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 100.0f);
- if (boat->m_modelIndex == MI_SPEEDER && boat->IsUpsideDown()) {
+ if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f);
m_pVehicleAnim->SetFinishCallback(CPed::PedSetOutCarCB, this);
m_vehEnterType = CAR_DOOR_RF;
@@ -17670,7 +17670,7 @@ CPed::SetExitBoat(CVehicle *boat)
m_pCurSurface = boat;
m_pCurSurface->RegisterReference((CEntity**)&m_pCurSurface);
}
- GetPosition() = firstPos;
+ SetPosition(firstPos);
SetMoveState(PEDMOVE_STILL);
m_vecMoveSpeed = boat->m_vecMoveSpeed;
bTryingToReachDryLand = true;
@@ -17725,10 +17725,52 @@ CPed::SetExitBoat(CVehicle *boat)
return;
}
*/ }
- GetPosition() = newPos;
+ SetPosition(newPos);
SetMoveState(PEDMOVE_STILL);
m_vecMoveSpeed = boat->m_vecMoveSpeed;
#endif
// Not there in VC.
CWaterLevel::FreeBoatWakeArray();
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CPed::Save(uint8*& buf)
+{
+ SkipSaveBuf(buf, 52);
+ WriteSaveBuf<float>(buf, GetPosition().x);
+ WriteSaveBuf<float>(buf, GetPosition().y);
+ WriteSaveBuf<float>(buf, GetPosition().z);
+ SkipSaveBuf(buf, 288);
+ WriteSaveBuf<uint8>(buf, CharCreatedBy);
+ SkipSaveBuf(buf, 351);
+ WriteSaveBuf<float>(buf, m_fHealth);
+ WriteSaveBuf<float>(buf, m_fArmour);
+ SkipSaveBuf(buf, 148);
+ for (int i = 0; i < 13; i++) // has to be hardcoded
+ m_weapons[i].Save(buf);
+ SkipSaveBuf(buf, 5);
+ WriteSaveBuf<uint8>(buf, m_maxWeaponTypeAllowed);
+ SkipSaveBuf(buf, 162);
+}
+
+void
+CPed::Load(uint8*& buf)
+{
+ SkipSaveBuf(buf, 52);
+ GetMatrix().GetPosition().x = ReadSaveBuf<float>(buf);
+ GetMatrix().GetPosition().y = ReadSaveBuf<float>(buf);
+ GetMatrix().GetPosition().z = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 288);
+ CharCreatedBy = ReadSaveBuf<uint8>(buf);
+ SkipSaveBuf(buf, 351);
+ m_fHealth = ReadSaveBuf<float>(buf);
+ m_fArmour = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 148);
+ for (int i = 0; i < 13; i++) // has to be hardcoded
+ m_weapons[i].Load(buf);
+ SkipSaveBuf(buf, 5);
+ m_maxWeaponTypeAllowed = ReadSaveBuf<uint8>(buf);
+ SkipSaveBuf(buf, 162);
+}
+#endif
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 46c6c82d..56e527c5 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -82,7 +82,7 @@ struct FightMove
uint8 damage;
uint8 flags;
};
-static_assert(sizeof(FightMove) == 0x18, "FightMove: error");
+VALIDATE_SIZE(FightMove, 0x18);
// TODO: This is eFightState on mobile.
enum PedFightMoves
@@ -303,7 +303,7 @@ public:
// cf. https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CPed.h from R*
uint32 bIsStanding : 1;
- uint32 m_ped_flagA2 : 1; // bWasStanding?
+ uint32 bWasStanding : 1;
uint32 bIsAttacking : 1; // doesn't reset after fist fight
uint32 bIsPointingGunAt : 1;
uint32 bIsLooking : 1;
@@ -886,21 +886,15 @@ public:
#ifdef PED_SKIN
void renderLimb(int node);
#endif
+
+#ifdef COMPATIBLE_SAVES
+ virtual void Save(uint8*& buf);
+ virtual void Load(uint8*& buf);
+#endif
};
void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg);
#ifndef PED_SKIN
-static_assert(offsetof(CPed, m_nPedState) == 0x224, "CPed: error");
-static_assert(offsetof(CPed, m_pCurSurface) == 0x2FC, "CPed: error");
-static_assert(offsetof(CPed, m_pMyVehicle) == 0x310, "CPed: error");
-static_assert(offsetof(CPed, m_nPedType) == 0x32C, "CPed: error");
-static_assert(offsetof(CPed, m_pCollidingEntity) == 0x34C, "CPed: error");
-static_assert(offsetof(CPed, m_weapons) == 0x35C, "CPed: error");
-static_assert(offsetof(CPed, m_currentWeapon) == 0x498, "CPed: error");
-static_assert(offsetof(CPed, m_lookTimer) == 0x4CC, "CPed: error");
-static_assert(offsetof(CPed, m_bodyPartBleeding) == 0x4F2, "CPed: error");
-static_assert(offsetof(CPed, m_pedInObjective) == 0x16C, "CPed: error");
-static_assert(offsetof(CPed, m_pEventEntity) == 0x19C, "CPed: error");
-static_assert(sizeof(CPed) == 0x53C, "CPed: error");
+VALIDATE_SIZE(CPed, 0x53C);
#endif
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index 3db3dc0f..c9428cb3 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -33,13 +33,18 @@ CPedIK::CPedIK(CPed *ped)
#ifdef PED_SKIN
inline RwMatrix*
-GetComponentMatrix(CPed *ped, int32 node)
+GetBoneMatrix(CPed *ped, int32 bone)
{
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(ped->GetClump());
- int idx = RpHAnimIDGetIndex(hier, ped->m_pFrames[node]->nodeID);
+ int idx = RpHAnimIDGetIndex(hier, bone);
RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
return &mats[idx];
}
+inline RwMatrix*
+GetComponentMatrix(CPed *ped, int32 node)
+{
+ return GetBoneMatrix(ped, ped->m_pFrames[node]->nodeID);
+}
#endif
void
@@ -245,7 +250,7 @@ CPedIK::LookInDirection(float phi, float theta)
}
// parent of head is torso
- RwMatrix worldMat = *GetComponentMatrix(m_ped, BONE_torso);
+ RwMatrix worldMat = *GetBoneMatrix(m_ped, BONE_torso);
ExtractYawAndPitchWorld(&worldMat, &yaw, &pitch);
LimbMoveStatus headStatus = MoveLimb(m_headOrient, CGeneral::LimitRadianAngle(phi - yaw),
diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h
index fd9e4702..a1cb5d13 100644
--- a/src/peds/PedIK.h
+++ b/src/peds/PedIK.h
@@ -64,4 +64,5 @@ public:
bool LookAtPosition(CVector const& pos);
bool RestoreLookAt(void);
};
-static_assert(sizeof(CPedIK) == 0x28, "CPedIK: error");
+
+VALIDATE_SIZE(CPedIK, 0x28);
diff --git a/src/peds/PedPlacement.cpp b/src/peds/PedPlacement.cpp
index 8b8b3dfa..2d4a92fa 100644
--- a/src/peds/PedPlacement.cpp
+++ b/src/peds/PedPlacement.cpp
@@ -37,7 +37,7 @@ CPedPlacement::FindZCoorForPed(CVector* pos)
}
CEntity*
-CPedPlacement::IsPositionClearOfCars(CVector* pos)
+CPedPlacement::IsPositionClearOfCars(Const CVector *pos)
{
return CWorld::TestSphereAgainstWorld(*pos, 0.25f, nil, true, true, false, false, false, false);
}
diff --git a/src/peds/PedPlacement.h b/src/peds/PedPlacement.h
index 6ba4ae71..b51e2aad 100644
--- a/src/peds/PedPlacement.h
+++ b/src/peds/PedPlacement.h
@@ -3,6 +3,6 @@
class CPedPlacement {
public:
static void FindZCoorForPed(CVector* pos);
- static CEntity* IsPositionClearOfCars(CVector*);
+ static CEntity* IsPositionClearOfCars(Const CVector*);
static bool IsPositionClearForPed(CVector*);
}; \ No newline at end of file
diff --git a/src/peds/PedStats.h b/src/peds/PedStats.h
index 4c35e8ee..df97bdb8 100644
--- a/src/peds/PedStats.h
+++ b/src/peds/PedStats.h
@@ -76,4 +76,5 @@ public:
static void LoadPedStats(void);
static ePedStats GetPedStatType(char *name);
};
-static_assert(sizeof(CPedStats) == 0x34, "CPedStats: error");
+
+VALIDATE_SIZE(CPedStats, 0x34);
diff --git a/src/peds/PedType.h b/src/peds/PedType.h
index c0c72550..3a765da1 100644
--- a/src/peds/PedType.h
+++ b/src/peds/PedType.h
@@ -91,4 +91,4 @@ public:
static bool IsThreat(int type, int threat) { return ms_apPedType[type]->m_threats & threat; }
};
-static_assert(sizeof(CPedType) == 0x20, "CPedType: error");
+VALIDATE_SIZE(CPedType, 0x20);
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 664fff18..c6c4824b 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -19,6 +19,13 @@
#define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f
+const uint32 CPlayerPed::nSaveStructSize =
+#ifdef COMPATIBLE_SAVES
+ 1520;
+#else
+ sizeof(CPlayerPed);
+#endif
+
CPlayerPed::~CPlayerPed()
{
delete m_pWanted;
@@ -771,7 +778,7 @@ CPlayerPed::KeepAreaAroundPlayerClear(void)
for (int i = 0; i < lastVehicle; i++) {
CVehicle *veh = (CVehicle*)vehicles[i];
if (veh->VehicleCreatedBy != MISSION_VEHICLE) {
- if (veh->m_status != STATUS_PLAYER && veh->m_status != STATUS_PLAYER_DISABLED) {
+ if (veh->GetStatus() != STATUS_PLAYER && veh->GetStatus() != STATUS_PLAYER_DISABLED) {
if ((veh->GetPosition() - playerPos).MagnitudeSqr() > 25.0f) {
veh->AutoPilot.m_nTempAction = TEMPACT_WAIT;
veh->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 5000;
@@ -1320,7 +1327,7 @@ CPlayerPed::ProcessControl(void)
case PED_ATTACK:
case PED_FIGHT:
case PED_AIM_GUN:
- if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG400)) {
+ if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK)) {
if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
if (padUsed)
PlayerControl1stPersonRunAround(padUsed);
@@ -1504,3 +1511,33 @@ CPlayerPed::ProcessControl(void)
UpdateRpHAnim();
#endif
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CPlayerPed::Save(uint8*& buf)
+{
+ CPed::Save(buf);
+ SkipSaveBuf(buf, 16);
+ WriteSaveBuf<float>(buf, m_fMaxStamina);
+ SkipSaveBuf(buf, 28);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[0]);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[1]);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[2]);
+ WriteSaveBuf<int32>(buf, m_nTargettableObjects[3]);
+ SkipSaveBuf(buf, 116);
+}
+
+void
+CPlayerPed::Load(uint8*& buf)
+{
+ CPed::Load(buf);
+ SkipSaveBuf(buf, 16);
+ m_fMaxStamina = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 28);
+ m_nTargettableObjects[0] = ReadSaveBuf<int32>(buf);
+ m_nTargettableObjects[1] = ReadSaveBuf<int32>(buf);
+ m_nTargettableObjects[2] = ReadSaveBuf<int32>(buf);
+ m_nTargettableObjects[3] = ReadSaveBuf<int32>(buf);
+ SkipSaveBuf(buf, 116);
+}
+#endif
diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h
index b8bd57e4..e8173c8c 100644
--- a/src/peds/PlayerPed.h
+++ b/src/peds/PlayerPed.h
@@ -75,8 +75,15 @@ public:
static void SetupPlayerPed(int32);
static void DeactivatePlayerPed(int32);
static void ReactivatePlayerPed(int32);
+
+#ifdef COMPATIBLE_SAVES
+ virtual void Save(uint8*& buf);
+ virtual void Load(uint8*& buf);
+#endif
+
+ static const uint32 nSaveStructSize;
};
#ifndef PED_SKIN
-static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error");
+VALIDATE_SIZE(CPlayerPed, 0x5F0);
#endif
diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp
index cd89a05d..1566ba3d 100644
--- a/src/peds/Population.cpp
+++ b/src/peds/Population.cpp
@@ -396,7 +396,7 @@ CPopulation::FindCollisionZoneForCoors(CVector *coors, int *safeZoneOut, eLevelN
if (*safeZoneOut >= 0)
*levelOut = LEVEL_NONE;
else
- *levelOut = CTheZones::GetLevelFromPosition(*coors);
+ *levelOut = CTheZones::GetLevelFromPosition(coors);
}
void
@@ -495,7 +495,7 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
case PEDTYPE_CIVFEMALE:
{
CCivilianPed *ped = new CCivilianPed(pedType, miOrCopType);
- ped->GetPosition() = coors;
+ ped->SetPosition(coors);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped);
if (ms_bGivePedsWeapons) {
@@ -509,7 +509,7 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
case PEDTYPE_COP:
{
CCopPed *ped = new CCopPed((eCopType)miOrCopType);
- ped->GetPosition() = coors;
+ ped->SetPosition(coors);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped);
return ped;
@@ -525,7 +525,7 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
case PEDTYPE_GANG9:
{
CCivilianPed *ped = new CCivilianPed(pedType, miOrCopType);
- ped->GetPosition() = coors;
+ ped->SetPosition(coors);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped);
@@ -540,7 +540,7 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
case PEDTYPE_EMERGENCY:
{
CEmergencyPed *ped = new CEmergencyPed(PEDTYPE_EMERGENCY);
- ped->GetPosition() = coors;
+ ped->SetPosition(coors);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped);
return ped;
@@ -548,7 +548,7 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
case PEDTYPE_FIREMAN:
{
CEmergencyPed *ped = new CEmergencyPed(PEDTYPE_FIREMAN);
- ped->GetPosition() = coors;
+ ped->SetPosition(coors);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped);
return ped;
@@ -557,7 +557,7 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
case PEDTYPE_PROSTITUTE:
{
CCivilianPed *ped = new CCivilianPed(pedType, miOrCopType);
- ped->GetPosition() = coors;
+ ped->SetPosition(coors);
ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped);
return ped;
@@ -755,7 +755,7 @@ CPopulation::AddPedInCar(CVehicle* car)
int preferredModel;
CTheZones::GetZoneInfoForTimeOfDay(&coors, &zoneInfo);
- switch (car->m_modelIndex) {
+ switch (car->GetModelIndex()) {
case MI_FIRETRUCK:
preferredModel = 0;
pedType = PEDTYPE_FIREMAN;
@@ -796,14 +796,14 @@ CPopulation::AddPedInCar(CVehicle* car)
int gangOfPed = 0;
imSureThatModelIsLoaded = false;
- while (gangOfPed < NUM_GANGS && CGangs::GetGangInfo(gangOfPed)->m_nVehicleMI != car->m_modelIndex)
+ while (gangOfPed < NUM_GANGS && CGangs::GetGangInfo(gangOfPed)->m_nVehicleMI != car->GetModelIndex())
gangOfPed++;
if (gangOfPed < NUM_GANGS) {
pedType = gangOfPed + PEDTYPE_GANG1;
preferredModel = ChooseGangOccupation(gangOfPed);
} else if (gangOfPed == NUM_GANGS) {
- CVehicleModelInfo *carModelInfo = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(car->m_modelIndex));
+ CVehicleModelInfo *carModelInfo = ((CVehicleModelInfo *)CModelInfo::GetModelInfo(car->GetModelIndex()));
int i = 15;
for(; i >= 0; i--) {
// Should return random model each time
@@ -869,8 +869,8 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
if (veh && veh->m_nZoneLevel == LEVEL_NONE && veh->IsCar()) {
- if(veh->m_status != STATUS_ABANDONED && veh->m_status != STATUS_WRECKED && veh->m_status != STATUS_PLAYER &&
- veh->m_status != STATUS_PLAYER_REMOTE) {
+ if(veh->GetStatus() != STATUS_ABANDONED && veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_PLAYER &&
+ veh->GetStatus() != STATUS_PLAYER_REMOTE) {
CVector vehPos(veh->GetPosition());
CPopulation::FindCollisionZoneForCoors(&vehPos, &zone, &level);
@@ -880,22 +880,22 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
if (veh->bIsLocked || !veh->CanBeDeleted()) {
switch (movedVehicleCount & 3) {
case 0:
- veh->GetPosition() = RegenerationPoint_a;
+ veh->SetPosition(RegenerationPoint_a);
break;
case 1:
- veh->GetPosition() = RegenerationPoint_b;
+ veh->SetPosition(RegenerationPoint_b);
break;
case 2:
- veh->GetPosition() = CVector(RegenerationPoint_a.x, RegenerationPoint_b.y, RegenerationPoint_a.z);
+ veh->SetPosition(RegenerationPoint_a.x, RegenerationPoint_b.y, RegenerationPoint_a.z);
break;
case 3:
- veh->GetPosition() = CVector(RegenerationPoint_b.x, RegenerationPoint_a.y, RegenerationPoint_a.z);
+ veh->SetPosition(RegenerationPoint_b.x, RegenerationPoint_a.y, RegenerationPoint_a.z);
break;
default:
break;
}
- veh->GetPosition().z += (movedVehicleCount / 4) * 7.0f;
- veh->GetForward() = RegenerationForward;
+ veh->GetMatrix().GetPosition().z += (movedVehicleCount / 4) * 7.0f;
+ veh->GetMatrix().GetForward() = RegenerationForward;
((CAutomobile*)veh)->PlaceOnRoadProperly();
CCarCtrl::JoinCarWithRoadSystem(veh);
CTheScripts::ClearSpaceForMissionEntity(veh->GetPosition(), veh);
@@ -924,14 +924,14 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
CWorld::Remove(ped);
delete ped;
} else if (ped->m_nPedType != PEDTYPE_PLAYER1 && ped->m_nPedType != PEDTYPE_PLAYER2) {
- ped->GetPosition() = RegenerationPoint_a;
+ ped->SetPosition(RegenerationPoint_a);
bool foundGround;
float groundZ = CWorld::FindGroundZFor3DCoord(ped->GetPosition().x, ped->GetPosition().y,
ped->GetPosition().z + 2.0f, &foundGround);
if (foundGround) {
- ped->GetPosition().z = 1.0f + groundZ;
+ ped->GetMatrix().GetPosition().z = 1.0f + groundZ;
//ped->GetPosition().z += 0.0f;
CTheScripts::ClearSpaceForMissionEntity(ped->GetPosition(), ped);
}
@@ -970,7 +970,7 @@ CPopulation::ConvertToRealObject(CDummyObject *dummy)
CWorld::Remove(dummy);
delete dummy;
CWorld::Add(obj);
- int16 mi = obj->m_modelIndex;
+ int16 mi = obj->GetModelIndex();
if (mi == MI_GLASS1 || mi == MI_GLASS2 || mi == MI_GLASS3 || mi == MI_GLASS4 ||
mi == MI_GLASS5 || mi == MI_GLASS6 || mi == MI_GLASS7 || mi == MI_GLASS8)
makeInvisible = true;
@@ -979,7 +979,7 @@ CPopulation::ConvertToRealObject(CDummyObject *dummy)
if (makeInvisible) {
obj->bIsVisible = false;
- } else if (obj->m_modelIndex == MI_BUOY) {
+ } else if (obj->GetModelIndex() == MI_BUOY) {
obj->bIsStatic = false;
obj->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.001f);
obj->bTouchingWater = true;
@@ -997,7 +997,7 @@ CPopulation::ConvertToDummyObject(CObject *obj)
dummy->UpdateRwFrame();
bool makeInvisible;
- int16 mi = obj->m_modelIndex;
+ int16 mi = obj->GetModelIndex();
if (mi == MI_GLASS1 || mi == MI_GLASS2 || mi == MI_GLASS3 || mi == MI_GLASS4 ||
mi == MI_GLASS5 || mi == MI_GLASS6 || mi == MI_GLASS7 || mi == MI_GLASS8)
makeInvisible = true;
@@ -1017,8 +1017,7 @@ bool
CPopulation::TestRoomForDummyObject(CObject *obj)
{
int16 collidingObjs;
- CWorld::FindObjectsKindaColliding(obj->m_objectMatrix.GetPosition(),
- CModelInfo::GetModelInfo(obj->m_modelIndex)->GetColModel()->boundingSphere.radius,
+ CWorld::FindObjectsKindaColliding(obj->m_objectMatrix.GetPosition(), CModelInfo::GetModelInfo(obj->GetModelIndex())->GetColModel()->boundingSphere.radius,
false, &collidingObjs, 2, nil, false, true, true, false, false);
return collidingObjs == 0;
diff --git a/src/render/2dEffect.h b/src/render/2dEffect.h
index b0615e4d..2a71a8d5 100644
--- a/src/render/2dEffect.h
+++ b/src/render/2dEffect.h
@@ -1,3 +1,5 @@
+#pragma once
+
enum {
EFFECT_LIGHT,
EFFECT_PARTICLE,
@@ -87,4 +89,5 @@ public:
}
}
};
-static_assert(sizeof(C2dEffect) == 0x34, "C2dEffect: error");
+
+VALIDATE_SIZE(C2dEffect, 0x34);
diff --git a/src/render/Coronas.h b/src/render/Coronas.h
index 4b49e40e..46eb4315 100644
--- a/src/render/Coronas.h
+++ b/src/render/Coronas.h
@@ -38,7 +38,8 @@ struct CRegisteredCorona
void Update(void);
};
-static_assert(sizeof(CRegisteredCorona) == 0x80, "CRegisteredCorona: error");
+
+VALIDATE_SIZE(CRegisteredCorona, 0x80);
class CCoronas
{
diff --git a/src/render/Font.cpp b/src/render/Font.cpp
index e4bd2a11..ef665fae 100644
--- a/src/render/Font.cpp
+++ b/src/render/Font.cpp
@@ -11,6 +11,7 @@ CSprite2d CFont::Sprite[MAX_FONTS];
#ifdef MORE_LANGUAGES
uint8 CFont::LanguageSet = FONT_LANGSET_EFIGS;
int32 CFont::Slot = -1;
+#define JAP_TERMINATION (0x8000 | '~')
int16 CFont::Size[LANGSET_MAX][MAX_FONTS][193] = {
{
@@ -166,6 +167,26 @@ int16 CFont::Size[MAX_FONTS][193] = {
#endif
};
+#ifdef MORE_LANGUAGES
+int16 Size_jp[] = {
+ 15, 14, 16, 20, 19, 26, 22, 11, 18, 18, 27, 26, 13, //; 0
+ 19, 20, 27, 19, 15, 19, 19, 21, 19, 20, 18, 19, 15, //; 13
+ 13, 28, 15, 32, 15, 35, 15, 19, 19, 19, 19, 17, 16, //; 26
+ 19, 20, 15, 19, 20, 14, 17, 19, 19, 19, 19, 19, 19, //; 39
+ 19, 19, 20, 25, 20, 19, 19, 33, 31, 39, 37, 39, 37, //; 52
+ 21, 21, 21, 19, 17, 15, 23, 21, 15, 19, 20, 16, 19, //; 65
+ 19, 19, 20, 20, 17, 22, 19, 22, 22, 19, 22, 22, 23, //; 78
+ 35, 35, 35, 35, 37, 19, 19, 19, 19, 29, 19, 19, 19, //; 91
+ 19, 19, 9, 9, 9, 9, 19, 19, 19, 19, 19, 19, 19, 19, //; 104
+ 19, 19, 19, 19, 19, 30, 19, 19, 19, 19, 19, 10, 10, //; 118
+ 10, 10, 19, 19, 19, 19, 19, 19, 19, 19, 19, 23, 35, //; 131
+ 12, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 144
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 157
+ 19, 19, 19, 11, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 170
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 21
+};
+#endif
+
wchar foreign_table[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -197,6 +218,9 @@ CFont::Initialise(void)
case FONT_LANGSET_RUSSIAN:
CTxdStore::LoadTxd(slot, "MODELS/FONTS_R.TXD");
break;
+ case FONT_LANGSET_JAPANESE:
+ CTxdStore::LoadTxd(slot, "MODELS/FONTS_J.TXD");
+ break;
}
#else
CTxdStore::LoadTxd(slot, "MODELS/FONTS.TXD");
@@ -205,7 +229,14 @@ CFont::Initialise(void)
CTxdStore::PushCurrentTxd();
CTxdStore::SetCurrentTxd(slot);
Sprite[0].SetTexture("font2", "font2_mask");
- Sprite[1].SetTexture("pager", "pager_mask");
+#ifdef MORE_LANGUAGES
+ if (IsJapanese()) {
+ Sprite[1].SetTexture("FONTJAP", "FONTJAP_mask");
+ Sprite[3].SetTexture("FONTJAP", "FONTJAP_mask");
+ }
+ else
+#endif // MORE_LANGUAGES
+ Sprite[1].SetTexture("pager", "pager_mask");
Sprite[2].SetTexture("font1", "font1_mask");
SetScale(1.0f, 1.0f);
SetSlantRefPoint(SCREEN_WIDTH, 0.0f);
@@ -213,8 +244,8 @@ CFont::Initialise(void)
SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0));
SetJustifyOff();
SetCentreOff();
- SetWrapx(640.0f);
- SetCentreSize(640.0f);
+ SetWrapx(DEFAULT_SCREEN_WIDTH);
+ SetCentreSize(DEFAULT_SCREEN_WIDTH);
SetBackgroundOff();
SetBackgroundColor(CRGBA(0x80, 0x80, 0x80, 0x80));
SetBackGroundOnlyTextOff();
@@ -234,6 +265,8 @@ CFont::ReloadFonts(uint8 set)
Sprite[0].Delete();
Sprite[1].Delete();
Sprite[2].Delete();
+ if (IsJapanese())
+ Sprite[3].Delete();
CTxdStore::PushCurrentTxd();
CTxdStore::RemoveTxd(Slot);
switch (set)
@@ -248,10 +281,18 @@ CFont::ReloadFonts(uint8 set)
case FONT_LANGSET_RUSSIAN:
CTxdStore::LoadTxd(Slot, "MODELS/FONTS_R.TXD");
break;
+ case FONT_LANGSET_JAPANESE:
+ CTxdStore::LoadTxd(Slot, "MODELS/FONTS_J.TXD");
+ break;
}
CTxdStore::SetCurrentTxd(Slot);
Sprite[0].SetTexture("font2", "font2_mask");
- Sprite[1].SetTexture("pager", "pager_mask");
+ if (set == FONT_LANGSET_JAPANESE) {
+ Sprite[1].SetTexture("FONTJAP", "FONTJAP_mask");
+ Sprite[3].SetTexture("FONTJAP", "FONTJAP_mask");
+ }
+ else
+ Sprite[1].SetTexture("pager", "pager_mask");
Sprite[2].SetTexture("font1", "font1_mask");
CTxdStore::PopCurrentTxd();
}
@@ -266,6 +307,8 @@ CFont::Shutdown(void)
Sprite[1].Delete();
Sprite[2].Delete();
#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ Sprite[3].Delete();
CTxdStore::RemoveTxdSlot(Slot);
Slot = -1;
#else
@@ -279,6 +322,10 @@ CFont::InitPerFrame(void)
Details.bank = CSprite2d::GetBank(30, Sprite[0].m_pTexture);
CSprite2d::GetBank(15, Sprite[1].m_pTexture);
CSprite2d::GetBank(15, Sprite[2].m_pTexture);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ CSprite2d::GetBank(15, Sprite[3].m_pTexture);
+#endif
SetDropShadowPosition(0);
NewLine = 0;
}
@@ -291,8 +338,15 @@ CFont::PrintChar(float x, float y, wchar c)
return;
float w = GetCharacterWidth(c) / 32.0f;
- float xoff = c & 0xF;
- float yoff = c >> 4;
+ float xoff = c % 16;
+ float yoff = c / 16;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont()) {
+ w = 21.0f;
+ xoff = (float)(c % 48);
+ yoff = c / 48;
+ }
+#endif
if(Details.style == FONT_BANK || Details.style == FONT_HEADING){
if(Details.dropShadowPosition != 0){
@@ -316,19 +370,64 @@ CFont::PrintChar(float x, float y, wchar c)
(xoff+1.0f)/16.0f - 0.001f, yoff/12.8f,
xoff/16.0f, (yoff+1.0f)/12.8f - 0.002f,
(xoff+1.0f)/16.0f - 0.001f, (yoff+1.0f)/12.8f - 0.002f);
- }else{
+#ifdef MORE_LANGUAGES
+ }else if (IsJapaneseFont()) {
+ if (Details.dropShadowPosition != 0) {
+ CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
+ CRect(x + SCREEN_SCALE_X(Details.dropShadowPosition),
+ y + SCREEN_SCALE_Y(Details.dropShadowPosition),
+ x + SCREEN_SCALE_X(Details.dropShadowPosition) + 32.0f * Details.scaleX * 1.0f,
+ y + SCREEN_SCALE_Y(Details.dropShadowPosition) + 40.0f * Details.scaleY / 2.75f),
+ Details.dropColor,
+ xoff * w / 1024.0f, yoff / 25.6f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, yoff / 25.6f,
+ xoff * w / 1024.0f, (yoff + 1.0f) / 25.6f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, (yoff + 1.0f) / 25.6f - 0.0001f);
+ }
CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
CRect(x, y,
- x + 32.0f * Details.scaleX * w,
- y + 32.0f * Details.scaleY * 0.5f),
+ x + 32.0f * Details.scaleX * 1.0f,
+ y + 40.0f * Details.scaleY / 2.75f),
+ Details.color,
+ xoff * w / 1024.0f, yoff / 25.6f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, yoff / 25.6f,
+ xoff * w / 1024.0f, (yoff + 1.0f) / 25.6f - 0.002f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, (yoff + 1.0f) / 25.6f - 0.0001f);
+#endif
+ }else
+ CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
+ CRect(x, y,
+ x + 32.0f * Details.scaleX * w,
+ y + 32.0f * Details.scaleY * 0.5f),
Details.color,
xoff/16.0f, yoff/16.0f,
(xoff+w)/16.0f, yoff/16.0f,
xoff/16.0f, (yoff+1.0f)/16.0f,
(xoff+w)/16.0f - 0.0001f, (yoff+1.0f)/16.0f - 0.0001f);
- }
}
+#ifdef MORE_LANGUAGES
+bool CFont::IsJapanesePunctuation(wchar *str)
+{
+ return (*str == 0xE7 || *str == 0x124 || *str == 0x126 || *str == 0x128 || *str == 0x104 || *str == ',' || *str == '>' || *str == '!' || *str == 0x99 || *str == '?' || *str == ':');
+}
+
+bool CFont::IsAnsiCharacter(wchar *s)
+{
+ if (*s >= 'A' && *s <= 'Z')
+ return true;
+ if (*s >= 'a' && *s <= 'z')
+ return true;
+ if (*s >= '0' && *s <= ':')
+ return true;
+ if (*s == '(' || *s == ')')
+ return true;
+ if (*s == 'D' || *s == '$')
+ return true;
+ return false;
+}
+#endif
+
void
CFont::PrintString(float xstart, float ystart, wchar *s)
{
@@ -364,17 +463,27 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
for(;;){
if(*s == '\0')
return;
- int xend = Details.centre ? Details.centreSize :
+ float xend = Details.centre ? Details.centreSize :
Details.rightJustify ? xstart - Details.rightJustifyWrap :
Details.wrapX;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ xend -= SCREEN_SCALE_X(21.0f * 2.0f);
+#endif
if(x + GetStringWidth(s) > xend && !first){
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && IsJapanesePunctuation(s))
+ s--;
+#endif
// flush line
float spaceWidth = !Details.justify || Details.centre ? 0.0f :
(Details.wrapX - lineLength) / numSpaces;
float xleft = Details.centre ? xstart - x/2 :
Details.rightJustify ? xstart - x :
xstart;
- PrintString(xleft, y, start, s, spaceWidth);
+#ifdef MORE_LANGUAGES
+ PrintString(xleft, y, start, s, spaceWidth, xstart);
+#endif
// reset things
lineLength = 0.0f;
numSpaces = 0;
@@ -383,7 +492,12 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
x = 0.0f;
else
x = xstart;
- y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ else
+#endif
+ y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
start = s;
}else
break;
@@ -397,8 +511,35 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
numSpaces++;
first = false;
x += GetStringWidth(s) + GetCharacterSize(*t - ' ');
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont() && IsAnsiCharacter(s))
+ x += 21.0f;
+#endif
lineLength = x;
s = t+1;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont() && !*s) {
+ x += GetStringWidth(s);
+ if (IsAnsiCharacter(s))
+ x += 21.0f;
+ float xleft = Details.centre ? xstart - x / 2 :
+ Details.rightJustify ? xstart - x :
+ xstart;
+ if (PrintString(xleft, y, start, s, 0.0f, xstart))
+ {
+ start = s;
+ if (!Details.centre && !Details.rightJustify)
+ x = xstart;
+ else
+ x = 0.0f;
+
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ numSpaces = 0;
+ first = true;
+ lineLength = 0.0f;
+ }
+ }
+#endif
}
// print rest
if(t[0] == ' ' && t[1] == '\0')
@@ -408,7 +549,21 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
float xleft = Details.centre ? xstart - x/2 :
Details.rightJustify ? xstart - x :
xstart;
+#ifdef MORE_LANGUAGES
+ if (PrintString(xleft, y, start, s, 0.0f, xstart) && IsJapaneseFont()) {
+ start = s;
+ if (!Details.centre && !Details.rightJustify)
+ x = xstart;
+ else
+ x = 0.0f;
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ numSpaces = 0;
+ first = true;
+ lineLength = 0.0f;
+ }
+#else
PrintString(xleft, y, start, s, 0.0f);
+#endif
}
}
@@ -418,8 +573,29 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
int n;
float x, y;
wchar *t;
-
n = 0;
+
+#ifdef MORE_LANGUAGES
+ bool bSomeJapBool = false;
+
+ if (IsJapanese()) {
+ t = s;
+ wchar unused;
+ while (*t) {
+ if (*t == JAP_TERMINATION || *t == '~')
+ t = ParseToken(t, &unused, true);
+ if (NewLine) {
+ n++;
+ NewLine = false;
+ bSomeJapBool = true;
+ }
+ t++;
+ }
+ }
+
+ if (bSomeJapBool) n--;
+#endif
+
if(Details.centre || Details.rightJustify)
x = 0.0f;
else
@@ -427,7 +603,20 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
y = ystart;
while(*s){
- if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
+ float f = (Details.centre ? Details.centreSize : Details.wrapX);
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ f -= SCREEN_SCALE_X(21.0f * 2.0f);
+#endif
+
+ if(x + GetStringWidth(s) > f){
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ {
+ if (IsJapanesePunctuation(s))
+ s--;
+ }
+#endif
// reached end of line
if(Details.centre || Details.rightJustify)
x = 0.0f;
@@ -435,19 +624,36 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
x = xstart;
n++;
// Why even?
- y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ else
+#endif
+ y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
}else{
// still space in current line
t = GetNextSpace(s);
if(*t == '\0'){
// end of string
x += GetStringWidth(s);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && IsAnsiCharacter(s))
+ x += 21.0f;
+#endif
n++;
s = t;
}else{
x += GetStringWidth(s);
- x += GetCharacterSize(*t - ' ');
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && IsAnsiCharacter(s))
+ x += 21.0f;
+#endif
s = t+1;
+ x += GetCharacterSize(*t - ' ');
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && !*s)
+ n++;
+#endif
}
}
}
@@ -465,65 +671,137 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s)
maxlength = 0;
numLines = 0;
- if(Details.centre || Details.rightJustify)
- x = 0.0f;
- else
- x = xstart;
- y = ystart;
- while(*s){
- if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
- // reached end of line
- if(x > maxlength)
- maxlength = x;
- if(Details.centre || Details.rightJustify)
- x = 0.0f;
- else
- x = xstart;
- numLines++;
- y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
- }else{
- // still space in current line
- t = GetNextSpace(s);
- if(*t == '\0'){
- // end of string
- x += GetStringWidth(s);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese()) {
+ numLines = GetNumberLines(xstart, ystart, s);
+ }else{
+#endif
+ if(Details.centre || Details.rightJustify)
+ x = 0.0f;
+ else
+ x = xstart;
+ y = ystart;
+
+ while(*s){
+ if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
+ // reached end of line
if(x > maxlength)
maxlength = x;
+ if(Details.centre || Details.rightJustify)
+ x = 0.0f;
+ else
+ x = xstart;
numLines++;
- s = t;
+ y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
}else{
- x += GetStringWidth(s);
- x += GetCharacterSize(*t - ' ');
- s = t+1;
+ // still space in current line
+ t = GetNextSpace(s);
+ if(*t == '\0'){
+ // end of string
+ x += GetStringWidth(s);
+ if(x > maxlength)
+ maxlength = x;
+ numLines++;
+ s = t;
+ }else{
+ x += GetStringWidth(s);
+ x += GetCharacterSize(*t - ' ');
+ s = t+1;
+ }
}
}
+#ifdef MORE_LANGUAGES
}
+#endif
if(Details.centre){
if(Details.backgroundOnlyText){
rect->left = xstart - maxlength/2 - 4.0f;
rect->right = xstart + maxlength/2 + 4.0f;
- rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines +
- ystart + 2.0f;
- rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont()) {
+ rect->bottom = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + (4.0f / 2.75f);
+ rect->top = ystart - (4.0f / 2.75f);
+ } else {
+#endif
+ rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f;
+ rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ }
+#endif
}else{
rect->left = xstart - Details.centreSize*0.5f - 4.0f;
rect->right = xstart + Details.centreSize*0.5f + 4.0f;
- rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines +
- ystart + 2.0f;
- rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont()) {
+ rect->bottom = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + (4.0f / 2.75f);
+ rect->top = ystart - (4.0f / 2.75f);
+ } else {
+#endif
+ rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f;
+ rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ }
+#endif
}
}else{
rect->left = xstart - 4.0f;
rect->right = Details.wrapX;
// WTF?
rect->bottom = ystart - 4.0f + 4.0f;
- rect->top = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines +
- ystart + 2.0f + 2.0f;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ rect->top = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f + (4.0f / 2.75f);
+ else
+#endif
+ rect->top = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f + 2.0f;
}
}
+#ifdef MORE_LANGUAGES
+bool
+CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, float japX)
+{
+ wchar *s, c, unused;
+
+ if (IsJapanese()) {
+ float jx = 0.0f;
+ for (s = start; s < end; s++) {
+ if (*s == JAP_TERMINATION || *s == '~')
+ s = ParseToken(s, &unused, true);
+ if (NewLine) {
+ NewLine = false;
+ break;
+ }
+ jx += GetCharacterSize(*s - ' ');
+ }
+ s = start;
+ if (Details.centre)
+ x = japX - jx / 2.0f;
+ else if (Details.rightJustify)
+ x = japX - jx;
+ }
+
+ for (s = start; s < end; s++) {
+ if (*s == '~' || (IsJapanese() && *s == JAP_TERMINATION))
+ s = ParseToken(s, &unused);
+ if (NewLine && IsJapanese()) {
+ NewLine = false;
+ end = s;
+ return true;
+ }
+ c = *s - ' ';
+ if (Details.slant != 0.0f && !IsJapanese())
+ y = (Details.slantRefX - x) * Details.slant + Details.slantRefY;
+ PrintChar(x, y, c);
+ x += GetCharacterSize(c);
+ if (c == 0 && (!NewLine || !IsJapanese())) // space
+ x += spwidth;
+ }
+ return false;
+}
+#else
void
CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
{
@@ -541,12 +819,41 @@ CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
x += spwidth;
}
}
+#endif
float
CFont::GetCharacterWidth(wchar c)
{
#ifdef MORE_LANGUAGES
- if (Details.proportional)
+ if (IsJapanese()) {
+ if (!Details.proportional)
+ return Size[0][Details.style][192];
+ if (c <= 94 || Details.style == FONT_HEADING || Details.style == FONT_BANK) {
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return Size_jp[c];
+ default:
+ return Size[0][Details.style][c];
+ }
+ }
+ if (c < 254 && Details.style == FONT_PAGER)
+ return 29.4f;
+
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return 29.4f;
+ case FONT_BANK:
+ return 10.0f;
+ case FONT_PAGER:
+ return 31.5f;
+ default:
+ return Size[0][Details.style][c];
+ }
+ }
+
+ else if (Details.proportional)
return Size[LanguageSet][Details.style][c];
else
return Size[LanguageSet][Details.style][192];
@@ -562,7 +869,36 @@ float
CFont::GetCharacterSize(wchar c)
{
#ifdef MORE_LANGUAGES
- if(Details.proportional)
+
+ if (IsJapanese())
+ {
+ if (!Details.proportional)
+ return Size[0][Details.style][192] * Details.scaleX;
+ if (c <= 94 || Details.style == FONT_HEADING || Details.style == FONT_BANK) {
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return Size_jp[c] * Details.scaleX;
+ default:
+ return Size[0][Details.style][c] * Details.scaleX;
+ }
+ }
+ if (c < 254 && (Details.style == FONT_PAGER))
+ return 29.4f * Details.scaleX;
+
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return 29.4f * Details.scaleX;
+ case FONT_BANK:
+ return 10.0f * Details.scaleX;
+ case FONT_PAGER:
+ return 31.5f * Details.scaleX;
+ default:
+ return Size[0][Details.style][c] * Details.scaleX;
+ }
+ }
+ else if(Details.proportional)
return Size[LanguageSet][Details.style][c] * Details.scaleX;
else
return Size[LanguageSet][Details.style][192] * Details.scaleX;
@@ -580,33 +916,127 @@ CFont::GetStringWidth(wchar *s, bool spaces)
float w;
w = 0.0f;
- for(; (*s != ' ' || spaces) && *s != '\0'; s++){
- if(*s == '~'){
- s++;
- while(*s != '~') s++;
- s++;
- if(*s == ' ' && !spaces)
- break;
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ {
+ do
+ {
+ if ((*s != ' ' || spaces) && *s != '\0') {
+ do {
+ while (*s == '~' || *s == JAP_TERMINATION) {
+ s++;
+ while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
+ s++;
+ }
+ w += GetCharacterSize(*s - ' ');
+ ++s;
+ } while (*s == '~' || *s == JAP_TERMINATION);
+ }
+ } while (IsAnsiCharacter(s));
+ } else
+#endif
+ {
+ for (; (*s != ' ' || spaces) && *s != '\0'; s++) {
+ if (*s == '~') {
+ s++;
+ while (*s != '~') s++;
+ s++;
+ if (*s == ' ' && !spaces)
+ break;
+ }
+ w += GetCharacterSize(*s - ' ');
}
- w += GetCharacterSize(*s - ' ');
}
return w;
}
+
+#ifdef MORE_LANGUAGES
+float
+CFont::GetStringWidth_Jap(wchar* s)
+{
+ float w;
+
+ w = 0.0f;
+ for (; *s != '\0';) {
+ do {
+ while (*s == '~' || *s == JAP_TERMINATION) {
+ s++;
+ while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
+ s++;
+ }
+ w += GetCharacterSize(*s - ' ');
+ ++s;
+ } while (*s == '~' || *s == JAP_TERMINATION);
+ }
+ return w;
+}
+#endif
+
wchar*
CFont::GetNextSpace(wchar *s)
{
- for(; *s != ' ' && *s != '\0'; s++)
- if(*s == '~'){
- s++;
- while(*s != '~') s++;
- s++;
- if(*s == ' ')
- break;
- }
+#ifdef MORE_LANGUAGES
+ if (IsJapanese()) {
+ do
+ {
+ if (*s != ' ' && *s != '\0') {
+ do {
+ while (*s == '~' || *s == JAP_TERMINATION) {
+ s++;
+ while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
+ s++;
+ }
+ ++s;
+ } while (*s == '~' || *s == JAP_TERMINATION);
+ }
+ } while (IsAnsiCharacter(s));
+ } else
+#endif
+ {
+ for(; *s != ' ' && *s != '\0'; s++)
+ if(*s == '~'){
+ s++;
+ while(*s != '~') s++;
+ s++;
+ if(*s == ' ')
+ break;
+ }
+ }
return s;
}
+#ifdef MORE_LANGUAGES
+wchar*
+CFont::ParseToken(wchar *s, wchar*, bool japShit)
+{
+ s++;
+ if ((Details.color.r || Details.color.g || Details.color.b) && !japShit) {
+ wchar c = *s;
+ if (IsJapanese())
+ c &= 0x7FFF;
+ switch (c) {
+ case 'N':
+ case 'n':
+ NewLine = true;
+ break;
+ case 'b': SetColor(CRGBA(128, 167, 243, 255)); break;
+ case 'g': SetColor(CRGBA(95, 160, 106, 255)); break;
+ case 'h': SetColor(CRGBA(225, 225, 225, 255)); break;
+ case 'l': SetColor(CRGBA(0, 0, 0, 255)); break;
+ case 'p': SetColor(CRGBA(168, 110, 252, 255)); break;
+ case 'r': SetColor(CRGBA(113, 43, 73, 255)); break;
+ case 'w': SetColor(CRGBA(175, 175, 175, 255)); break;
+ case 'y': SetColor(CRGBA(210, 196, 106, 255)); break;
+ }
+ } else if (IsJapanese()) {
+ if ((*s & 0x7FFF) == 'N' || (*s & 0x7FFF) == 'n')
+ NewLine = true;
+ }
+ while ((!IsJapanese() || (*s != JAP_TERMINATION)) && *s != '~') s++;
+ return s + 1;
+}
+#else
wchar*
CFont::ParseToken(wchar *s, wchar*)
{
@@ -629,6 +1059,7 @@ CFont::ParseToken(wchar *s, wchar*)
while(*s != '~') s++;
return s+1;
}
+#endif
void
CFont::DrawFonts(void)
@@ -636,6 +1067,10 @@ CFont::DrawFonts(void)
CSprite2d::DrawBank(Details.bank);
CSprite2d::DrawBank(Details.bank+1);
CSprite2d::DrawBank(Details.bank+2);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ CSprite2d::DrawBank(Details.bank+3);
+#endif
}
wchar
@@ -645,3 +1080,39 @@ CFont::character_code(uint8 c)
return c;
return foreign_table[c-128];
}
+
+
+void
+CFont::SetScale(float x, float y)
+{
+#ifdef MORE_LANGUAGES
+ /*if (IsJapanese()) {
+ x *= 1.35f;
+ y *= 1.25f;
+ }*/
+#endif
+ Details.scaleX = x;
+ Details.scaleY = y;
+}
+
+void
+CFont::SetBackgroundColor(CRGBA col)
+{
+ Details.backgroundColor = col;
+}
+
+void
+CFont::SetColor(CRGBA col)
+{
+ Details.color = col;
+ if (Details.alphaFade < 255.0f)
+ Details.color.a *= Details.alphaFade / 255.0f;
+}
+
+void
+CFont::SetDropColor(CRGBA col)
+{
+ Details.dropColor = col;
+ if (Details.alphaFade < 255.0f)
+ Details.dropColor.a *= Details.alphaFade / 255.0f;
+}
diff --git a/src/render/Font.h b/src/render/Font.h
index 01d67700..9b4e7132 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -31,6 +31,9 @@ enum {
FONT_BANK,
FONT_PAGER,
FONT_HEADING,
+#ifdef MORE_LANGUAGES
+ FONT_JAPANESE,
+#endif
MAX_FONTS
};
@@ -46,8 +49,13 @@ enum
FONT_LANGSET_EFIGS,
FONT_LANGSET_RUSSIAN,
FONT_LANGSET_POLISH,
+ FONT_LANGSET_JAPANESE,
LANGSET_MAX
};
+
+#define FONT_LOCALE(style) (CFont::IsJapanese() ? FONT_JAPANESE : style)
+#else
+#define FONT_LOCALE(style) (style)
#endif
class CFont
@@ -71,17 +79,28 @@ public:
static void PrintString(float x, float y, wchar *s);
static int GetNumberLines(float xstart, float ystart, wchar *s);
static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s);
+#ifdef MORE_LANGUAGES
+ static bool PrintString(float x, float y, wchar *start, wchar* &end, float spwidth, float japX);
+#else
static void PrintString(float x, float y, wchar *start, wchar *end, float spwidth);
+#endif
static float GetCharacterWidth(wchar c);
static float GetCharacterSize(wchar c);
static float GetStringWidth(wchar *s, bool spaces = false);
- static wchar *GetNextSpace(wchar *s);
- static wchar *ParseToken(wchar *s, wchar*);
+#ifdef MORE_LANGUAGES
+ static float GetStringWidth_Jap(wchar* s);
+#endif
+ static uint16 *GetNextSpace(wchar *s);
+#ifdef MORE_LANGUAGES
+ static uint16 *ParseToken(wchar *s, wchar*, bool japShit = false);
+#else
+ static uint16 *ParseToken(wchar *s, wchar*);
+#endif
static void DrawFonts(void);
- static wchar character_code(uint8 c);
+ static uint16 character_code(uint8 c);
static CFontDetails GetDetails() { return Details; }
- static void SetScale(float x, float y) { Details.scaleX = x; Details.scaleY = y; }
+ static void SetScale(float x, float y);
static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; }
static void SetSlant(float s) { Details.slant = s; }
static void SetJustifyOn(void) {
@@ -140,19 +159,17 @@ public:
static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; }
static void SetAlphaFade(float fade) { Details.alphaFade = fade; }
static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; }
+ static void SetBackgroundColor(CRGBA col);
+ static void SetColor(CRGBA col);
+ static void SetDropColor(CRGBA col);
- // TODO: really just CRGBA but that isn't passed correctly
- static void SetBackgroundColor(const CRGBA &col) { Details.backgroundColor = col; }
- static void SetColor(const CRGBA &col) {
- Details.color = col;
- if(Details.alphaFade < 255.0f)
- Details.color.a *= Details.alphaFade/255.0f;
- }
- static void SetDropColor(const CRGBA &col) {
- Details.dropColor = col;
- if(Details.alphaFade < 255.0f)
- Details.dropColor.a *= Details.alphaFade/255.0f;
- }
-
+#ifdef MORE_LANGUAGES
static void ReloadFonts(uint8 set);
+
+ // japanese stuff
+ static bool IsAnsiCharacter(wchar* s);
+ static bool IsJapanesePunctuation(wchar* str);
+ static bool IsJapanese() { return LanguageSet == FONT_LANGSET_JAPANESE; }
+ static bool IsJapaneseFont() { return IsJapanese() && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER); }
+#endif
};
diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp
index 9a4dbcfe..6f17013c 100644
--- a/src/render/Glass.cpp
+++ b/src/render/Glass.cpp
@@ -647,7 +647,7 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
}
object->bGlassBroken = true;
- object->GetPosition().z = -100.0f;
+ object->GetMatrix().GetPosition().z = -100.0f;
}
void
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index f88d6b9c..c3fcb7bf 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -336,7 +336,11 @@ void CHud::Draw()
|| FindPlayerPed()->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) {
AsciiToUnicode("{", sPrintIcon);
+#ifdef FIX_BUGS
+ sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fHealth + 0.5f));
+#else
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fHealth);
+#endif
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
@@ -362,7 +366,11 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
if (FindPlayerPed()->m_fArmour > 1.0f) {
AsciiToUnicode("[", sPrintIcon);
+#ifdef FIX_BUGS
+ sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fArmour + 0.5f));
+#else
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fArmour);
+#endif
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
@@ -660,7 +668,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f);
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
@@ -701,7 +709,7 @@ void CHud::Draw()
CFont::SetCentreOff();
CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f);
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(244, 20, 20, 255));
CFont::SetWrapx(SCREEN_SCALE_X(640.0f));
CFont::SetPropOff();
@@ -852,7 +860,7 @@ void CHud::Draw()
else
CFont::SetPropOff();
- CFont::SetFontStyle(CTheScripts::IntroTextLines[i].m_nFont);
+ CFont::SetFontStyle(FONT_LOCALE(CTheScripts::IntroTextLines[i].m_nFont));
CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - CTheScripts::IntroTextLines[i].m_fAtY), CTheScripts::IntroTextLines[i].m_Text);
}
}
@@ -892,7 +900,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.48f), SCREEN_SCALE_Y(1.120f));
CFont::SetCentreOn();
CFont::SetPropOn();
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
float offsetX = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f);
float center = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - offsetX;
@@ -1080,13 +1088,22 @@ void CHud::DrawAfterFade()
if (CGame::germanGame)
CFont::SetScale(SCREEN_SCALE_X(0.52f * 0.85f), SCREEN_SCALE_Y(1.1f * 0.85f));
+#ifdef MORE_LANGUAGES
+ else if (CFont::IsJapanese())
+ CFont::SetScale(SCREEN_SCALE_X(0.52f) * 1.35f, SCREEN_SCALE_Y(1.1f) * 1.25f);
+#endif
else
CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f));
CFont::SetColor(CRGBA(175, 175, 175, 255));
CFont::SetJustifyOff();
- CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f));
- CFont::SetFontStyle(FONT_BANK);
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ CFont::SetWrapx(SCREEN_SCALE_X(229.0f + 26.0f - 4.0f));
+ else
+#endif
+ CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f));
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetBackgroundOn();
CFont::SetBackGroundOnlyTextOff();
CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.9f));
@@ -1164,7 +1181,7 @@ void CHud::DrawAfterFade()
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(600.0f));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]);
@@ -1181,7 +1198,7 @@ void CHud::DrawAfterFade()
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(620.0f));
CFont::SetColor(CRGBA(0, 0, 0, 255));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]);
@@ -1238,7 +1255,7 @@ void CHud::DrawAfterFade()
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f));
CFont::SetColor(CRGBA(0, 0, 0, 255));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
#ifdef BETA_SLIDING_TEXT
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]);
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index c855c860..5995432b 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -222,10 +222,12 @@ int32 Randomizer;
int32 nParticleCreationInterval = 1;
float fParticleScaleLimit = 0.5f;
+#ifdef DEBUGMENU
SETTWEAKPATH("Particle");
TWEAKINT32(nParticleCreationInterval, 0, 5, 1);
TWEAKFLOAT(fParticleScaleLimit, 0.0f, 1.0f, 0.1f);
TWEAKFUNC(CParticle::ReloadConfig);
+#endif
void CParticle::ReloadConfig()
{
diff --git a/src/render/Particle.h b/src/render/Particle.h
index b71dc717..7f02e318 100644
--- a/src/render/Particle.h
+++ b/src/render/Particle.h
@@ -91,4 +91,4 @@ public:
static void AddYardieDoorSmoke(CVector const &vecPos, CMatrix const &matMatrix);
};
-VALIDATE_SIZE(CParticle, 0x68); \ No newline at end of file
+VALIDATE_SIZE(CParticle, 0x68);
diff --git a/src/render/ParticleMgr.h b/src/render/ParticleMgr.h
index 70845a56..42e3f132 100644
--- a/src/render/ParticleMgr.h
+++ b/src/render/ParticleMgr.h
@@ -64,8 +64,10 @@ struct tParticleSystemData
RwRaster **m_ppRaster;
CParticle *m_pParticles;
};
-VALIDATE_SIZE(tParticleSystemData, 0x88);
+#ifdef CHECK_STRUCT_SIZES
+VALIDATE_SIZE(tParticleSystemData, 0x88);
+#endif
class cParticleSystemMgr
{
@@ -125,6 +127,8 @@ public:
void RangeCheck(tParticleSystemData *pData) { }
};
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(cParticleSystemMgr, 0x2420);
+#endif
extern cParticleSystemMgr mod_ParticleSystemManager; \ No newline at end of file
diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp
index b92e7e83..88b9aaea 100644
--- a/src/render/PointLights.cpp
+++ b/src/render/PointLights.cpp
@@ -58,7 +58,7 @@ CPointLights::AddLight(uint8 type, CVector coors, CVector dir, float radius, flo
}
float
-CPointLights::GenerateLightsAffectingObject(CVector *objCoors)
+CPointLights::GenerateLightsAffectingObject(Const CVector *objCoors)
{
int i;
float ret;
diff --git a/src/render/PointLights.h b/src/render/PointLights.h
index 215e1dc9..9e94328f 100644
--- a/src/render/PointLights.h
+++ b/src/render/PointLights.h
@@ -13,7 +13,7 @@ public:
int8 fogType;
bool castExtraShadows;
};
-static_assert(sizeof(CRegisteredPointLight) == 0x2C, "CRegisteredPointLight: error");
+VALIDATE_SIZE(CRegisteredPointLight, 0x2C);
class CPointLights
{
@@ -39,7 +39,7 @@ public:
static void InitPerFrame(void);
static void AddLight(uint8 type, CVector coors, CVector dir, float radius, float red, float green, float blue, uint8 fogType, bool castExtraShadows);
- static float GenerateLightsAffectingObject(CVector *objCoors);
+ static float GenerateLightsAffectingObject(Const CVector *objCoors);
static void RemoveLightsAffectingObject(void);
static void RenderFogEffect(void);
};
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 3d308c52..714ff6e6 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -91,9 +91,7 @@ CRenderer::RenderOneRoad(CEntity *e)
if(gbDontRenderBuildings)
return;
if(gbShowCollisionPolys)
- CCollision::DrawColModel_Coloured(e->GetMatrix(),
- *CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel(),
- e->m_modelIndex);
+ CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
else
e->Render();
}
@@ -109,9 +107,7 @@ CRenderer::RenderOneNonRoad(CEntity *e)
#ifndef MASTER
if(gbShowCollisionPolys){
if(!e->IsVehicle()){
- CCollision::DrawColModel_Coloured(e->GetMatrix(),
- *CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel(),
- e->m_modelIndex);
+ CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
return;
}
}else if(e->IsBuilding()){
@@ -336,7 +332,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
float dist;
bool request = true;
- if(mi->m_type == MITYPE_TIME){
+ if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel();
if(CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())){
@@ -352,7 +348,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
request = false;
}
}else{
- if(mi->m_type != MITYPE_SIMPLE){
+ if (mi->GetModelType() != MITYPE_SIMPLE) {
if(FindPlayerVehicle() == ent &&
TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){
// Player's vehicle in first person mode
@@ -382,7 +378,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
}
return VIS_INVISIBLE;
}
- if(ent->m_type == ENTITY_TYPE_OBJECT &&
+ if(ent->IsObject() &&
((CObject*)ent)->ObjectCreatedBy == TEMP_OBJECT){
if(ent->m_rwObject == nil || !ent->bIsVisible)
return VIS_INVISIBLE;
@@ -399,12 +395,12 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
if(LOD_DISTANCE + STREAM_DISTANCE < dist && dist < mi->GetLargestLodDistance())
dist = mi->GetLargestLodDistance();
- if(ent->m_type == ENTITY_TYPE_OBJECT && ent->bRenderDamaged)
+ if(ent->IsObject() && ent->bRenderDamaged)
mi->m_isDamaged = true;
RpAtomic *a = mi->GetAtomicFromDistance(dist);
if(a){
- mi->m_isDamaged = 0;
+ mi->m_isDamaged = false;
if(ent->m_rwObject == nil)
ent->CreateRwObject();
assert(ent->m_rwObject);
@@ -480,20 +476,20 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
int32
CRenderer::SetupBigBuildingVisibility(CEntity *ent)
{
- CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex);
+ CSimpleModelInfo *mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(ent->GetModelIndex());
CTimeModelInfo *ti;
int32 other;
- if(mi->m_type == MITYPE_TIME){
+ if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel();
// Hide objects not in time range if possible
if(CANTIMECULL)
if(!CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff()))
- return 0;
+ return VIS_INVISIBLE;
// Draw like normal
- }else if(mi->m_type == MITYPE_VEHICLE)
- return ent->IsVisible();
+ } else if (mi->GetModelType() == MITYPE_VEHICLE)
+ return ent->IsVisible() ? VIS_VISIBLE : VIS_INVISIBLE;
float dist = (ms_vecCameraPosition-ent->GetPosition()).Magnitude();
CSimpleModelInfo *nonLOD = mi->GetRelatedModel();
@@ -505,15 +501,15 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
// No non-LOD or non-LOD is completely visible.
if(nonLOD == nil ||
nonLOD->GetRwObject() && nonLOD->m_alpha == 255)
- return 0;
+ return VIS_INVISIBLE;
// But if it is a time object, we'd rather draw the wrong
// non-LOD than the right LOD.
- if(nonLOD->m_type == MITYPE_TIME){
+ if (nonLOD->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)nonLOD;
other = ti->GetOtherTimeModel();
if(other != -1 && CModelInfo::GetModelInfo(other)->GetRwObject())
- return 0;
+ return VIS_INVISIBLE;
}
}
@@ -529,18 +525,18 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(!ent->IsVisibleComplex())
- return 0;
+ return VIS_INVISIBLE;
if(mi->m_drawLast){
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
- ent->bDistanceFade = 0;
- return 0;
+ ent->bDistanceFade = false;
+ return VIS_INVISIBLE;
}
- return 1;
+ return VIS_VISIBLE;
}
if(mi->m_noFade){
ent->DeleteRwObject();
- return 0;
+ return VIS_INVISIBLE;
}
@@ -548,7 +544,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
a = mi->GetAtomicFromDistance(dist - FADE_DISTANCE);
if(a == nil){
ent->DeleteRwObject();
- return 0;
+ return VIS_INVISIBLE;
}
// Fade...
@@ -560,7 +556,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(ent->IsVisibleComplex())
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
- return 0;
+ return VIS_INVISIBLE;
}
void
@@ -954,7 +950,7 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
for(node = list.first; node; node = node->next){
ent = (CEntity*)node->item;
- if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == 1)
+ if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
}
}
@@ -1108,7 +1104,8 @@ CRenderer::ScanSectorList_RequestModels(CPtrList *lists)
if(ent->m_scanCode == CWorld::GetCurrentScanCode())
continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode();
- if(IsEntityCullZoneVisible(ent) && ShouldModelBeStreamed(ent))
+ if(IsEntityCullZoneVisible(ent))
+ if(ShouldModelBeStreamed(ent))
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}
}
@@ -1145,7 +1142,7 @@ CRenderer::SortBIGBuildingsForSectorList(CPtrList *list)
bool
CRenderer::ShouldModelBeStreamed(CEntity *ent)
{
- CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex);
+ CSimpleModelInfo *mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(ent->GetModelIndex());
float dist = (ent->GetPosition() - ms_vecCameraPosition).Magnitude();
if(mi->m_noFade)
return dist - STREAM_DISTANCE < mi->GetLargestLodDistance();
@@ -1162,7 +1159,7 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
if(ent->bZoneCulled)
return false;
- switch(ent->m_type){
+ switch(ent->GetType()){
case ENTITY_TYPE_VEHICLE:
return IsVehicleCullZoneVisible(ent);
case ENTITY_TYPE_PED:
@@ -1176,7 +1173,7 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
return !(ped->m_pCurSurface && ped->m_pCurSurface->bZoneCulled2);
case ENTITY_TYPE_OBJECT:
obj = (CObject*)ent;
- if(!obj->bIsStatic)
+ if(!obj->IsStatic())
return true;
return !(obj->m_pCurSurface && obj->m_pCurSurface->bZoneCulled2);
}
@@ -1187,7 +1184,7 @@ bool
CRenderer::IsVehicleCullZoneVisible(CEntity *ent)
{
CVehicle *v = (CVehicle*)ent;
- switch(v->m_status)
+ switch(v->GetStatus())
case STATUS_SIMPLE:
case STATUS_PHYSICS:
case STATUS_ABANDONED:
diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp
index d5970ebe..cefc1d9f 100644
--- a/src/render/Shadows.cpp
+++ b/src/render/Shadows.cpp
@@ -20,8 +20,10 @@
#include "SpecialFX.h"
#include "Shadows.h"
+#ifdef DEBUGMENU
SETTWEAKPATH("Shadows");
TWEAKBOOL(gbPrintShite);
+#endif
RwImVertexIndex ShadowIndexList[24];
@@ -214,7 +216,7 @@ CShadows::AddPermanentShadow(uint8 ShadowType, RwTexture *pTexture, CVector *pPo
}
void
-CShadows::StoreStaticShadow(uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn,
+CShadows::StoreStaticShadow(uint32 nID, uint8 ShadowType, RwTexture *pTexture, Const CVector *pPosn,
float fFrontX, float fFrontY, float fSideX, float fSideY,
int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue,
float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance)
diff --git a/src/render/Shadows.h b/src/render/Shadows.h
index 65274879..ef56d336 100644
--- a/src/render/Shadows.h
+++ b/src/render/Shadows.h
@@ -51,7 +51,10 @@ public:
CStoredShadow()
{ }
};
+
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(CStoredShadow, 0x30);
+#endif
class CPolyBunch
{
@@ -65,7 +68,10 @@ public:
CPolyBunch()
{ }
};
+
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(CPolyBunch, 0x6C);
+#endif
class CStaticShadow
{
@@ -93,7 +99,10 @@ public:
void Free();
};
+
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(CStaticShadow, 0x40);
+#endif
class CPermanentShadow
{
@@ -115,6 +124,7 @@ public:
CPermanentShadow()
{ }
};
+
VALIDATE_SIZE(CPermanentShadow, 0x38);
class CPtrList;
@@ -143,7 +153,7 @@ public:
static void Init (void);
static void Shutdown (void);
static void AddPermanentShadow ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale);
- static void StoreStaticShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance);
+ static void StoreStaticShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, Const CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance);
static void StoreShadowToBeRendered ( uint8 ShadowType, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue);
static void StoreShadowToBeRendered ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, bool bDrawOnWater, float fScale);
static void StoreShadowForCar (CAutomobile *pCar);
diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp
index 30eaf840..1dd1aaab 100644
--- a/src/render/Sprite.cpp
+++ b/src/render/Sprite.cpp
@@ -29,13 +29,17 @@ CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh,
float recip = 1.0f/out->z;
out->x *= SCREEN_WIDTH * recip;
out->y *= SCREEN_HEIGHT * recip;
- // What is this? size?
- *outw = 70.0f/CDraw::GetFOV() * SCREEN_WIDTH * recip;
#ifdef ASPECT_RATIO_SCALE
- *outh = 70.0f/CDraw::GetFOV() / (DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO) * SCREEN_HEIGHT * recip;
+ float fov = CDraw::ConvertFOV(DefaultFOV);
#else
- *outh = 70.0f/CDraw::GetFOV() * SCREEN_HEIGHT * recip;
+ const float fov = DefaultFOV;
#endif
+ // this is used to scale correctly if you zoom in with sniper rifle
+ float fovScale = fov / CDraw::GetFOV();
+
+ *outw = fovScale * SCREEN_SCALE_AR(recip) * SCREEN_WIDTH;
+ *outh = fovScale * recip * SCREEN_HEIGHT;
+
return true;
}
diff --git a/src/render/WaterCannon.h b/src/render/WaterCannon.h
index d2d20863..a37bdd12 100644
--- a/src/render/WaterCannon.h
+++ b/src/render/WaterCannon.h
@@ -25,7 +25,7 @@ public:
void PushPeds(void);
};
-static_assert(sizeof(CWaterCannon) == 412, "CWaterCannon: error");
+VALIDATE_SIZE(CWaterCannon, 412);
class CWaterCannons
{
diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp
index d7035ab1..e8e79f96 100644
--- a/src/render/WaterLevel.cpp
+++ b/src/render/WaterLevel.cpp
@@ -351,8 +351,13 @@ CWaterLevel::RenderWater()
if ( !CTimer::GetIsPaused() )
{
+#ifdef FIX_BUGS
+ TEXTURE_ADDU += (CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV) * CTimer::GetTimeStepFix();
+ TEXTURE_ADDV += (CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV) * CTimer::GetTimeStepFix();
+#else
TEXTURE_ADDU += CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV;
TEXTURE_ADDV += CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV;
+#endif
}
if ( TEXTURE_ADDU >= 1.0f )
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index ed618dd8..cb1d4ab5 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -13,6 +13,7 @@ RtCharset *debugCharset;
bool gPS2alphaTest = 1;
+#ifndef FINAL
static bool charsetOpen;
void OpenCharsetSafe()
{
@@ -20,6 +21,7 @@ void OpenCharsetSafe()
RtCharsetOpen();
charsetOpen = true;
}
+#endif
void CreateDebugFont()
{
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 7dc27f48..5184860b 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -146,8 +146,12 @@ CVisibilityPlugins::RenderFadingEntities(void)
CEntity *e = node->item.entity;
if(e->m_rwObject == nil)
continue;
- mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(e->m_modelIndex);
+ mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex());
+#ifdef FIX_BUGS
+ if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite)
+#else
if(mi->m_noZwrite)
+#endif
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
if(e->bDistanceFade){
@@ -159,7 +163,11 @@ CVisibilityPlugins::RenderFadingEntities(void)
}else
CRenderer::RenderOneNonRoad(e);
+#ifdef FIX_BUGS
+ if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite)
+#else
if(mi->m_noZwrite)
+#endif
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
}
}
@@ -718,7 +726,7 @@ CVisibilityPlugins::SetAtomicModelInfo(RpAtomic *atomic,
{
AtomicExt *ext = ATOMICEXT(atomic);
ext->modelInfo = modelInfo;
- switch(modelInfo->m_type)
+ switch (modelInfo->GetModelType())
case MITYPE_SIMPLE:
case MITYPE_TIME:
if(modelInfo->m_normalCull)
@@ -828,7 +836,7 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo
SetFrameHierarchyId(RpClumpGetFrame(clump), (int32)modelInfo);
// Unused
- switch(modelInfo->m_type){
+ switch (modelInfo->GetModelType()) {
// ignore MLO
case MITYPE_VEHICLE:
vmi = (CVehicleModelInfo*)modelInfo;
diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp
index 29f666df..bb074042 100644
--- a/src/save/GenericGameStorage.cpp
+++ b/src/save/GenericGameStorage.cpp
@@ -3,6 +3,7 @@
#include "crossplatform.h"
#include "main.h"
+#include "DMAudio.h"
#include "AudioScriptObject.h"
#include "Camera.h"
#include "CarGen.h"
@@ -163,7 +164,7 @@ GenericSave(int file)
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMonth);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nYear);
WriteDataToBufferPointer(buf, CWeather::WeatherTypeInList);
-#ifdef FIX_BUGS
+#ifdef COMPATIBLE_SAVES
// converted to float for compatibility with original format
// TODO: maybe remove this? not really gonna break anything vital
float f = TheCamera.CarZoomIndicator;
@@ -254,9 +255,9 @@ GenericLoad()
buf = (work_buff + 0x40);
ReadDataFromBufferPointer(buf, saveSize);
ReadDataFromBufferPointer(buf, CGame::currLevel);
- ReadDataFromBufferPointer(buf, TheCamera.GetPosition().x);
- ReadDataFromBufferPointer(buf, TheCamera.GetPosition().y);
- ReadDataFromBufferPointer(buf, TheCamera.GetPosition().z);
+ ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().x);
+ ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().y);
+ ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().z);
ReadDataFromBufferPointer(buf, CClock::ms_nMillisecondsPerGameMinute);
ReadDataFromBufferPointer(buf, CClock::ms_nLastClockTick);
ReadDataFromBufferPointer(buf, CClock::ms_nGameClockHours);
@@ -282,7 +283,7 @@ GenericLoad()
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nMonth);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nYear);
ReadDataFromBufferPointer(buf, CWeather::WeatherTypeInList);
-#ifdef FIX_BUGS
+#ifdef COMPATIBLE_SAVES
// converted to float for compatibility with original format
// TODO: maybe remove this? not really gonna break anything vital
float f;
@@ -537,9 +538,9 @@ RestoreForStartLoad()
} else {
uint8 *_buf = buf + sizeof(int32) + sizeof(wchar[24]) + sizeof(SYSTEMTIME) + sizeof(SIZE_OF_ONE_GAME_IN_BYTES);
ReadDataFromBufferPointer(_buf, CGame::currLevel);
- ReadDataFromBufferPointer(_buf, TheCamera.GetPosition().x);
- ReadDataFromBufferPointer(_buf, TheCamera.GetPosition().y);
- ReadDataFromBufferPointer(_buf, TheCamera.GetPosition().z);
+ ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().x);
+ ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().y);
+ ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z);
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
CCollision::SortOutCollisionAfterLoad();
diff --git a/src/save/PCSave.cpp b/src/save/PCSave.cpp
index 6f1b1b45..d3aeee26 100644
--- a/src/save/PCSave.cpp
+++ b/src/save/PCSave.cpp
@@ -3,6 +3,9 @@
#include "crossplatform.h"
#include "FileMgr.h"
+#ifdef MORE_LANGUAGES
+#include "Game.h"
+#endif
#include "GenericGameStorage.h"
#include "Messages.h"
#include "PCSave.h"
@@ -131,7 +134,12 @@ C_PcSave::PopulateSlotInfo()
default: assert(0);
}
char date[70];
- sprintf(date, "%02d %s %04d %02d:%02d:%02d", st.wDay, UnicodeToAsciiForSaveLoad(TheText.Get(month)), st.wYear, st.wHour, st.wMinute, st.wSecond);
+#ifdef MORE_LANGUAGES
+ if (CGame::japaneseGame)
+ sprintf(date, "%02d %02d %04d %02d:%02d:%02d", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond);
+ else
+#endif // MORE_LANGUAGES
+ sprintf(date, "%02d %s %04d %02d:%02d:%02d", st.wDay, UnicodeToAsciiForSaveLoad(TheText.Get(month)), st.wYear, st.wHour, st.wMinute, st.wSecond);
AsciiToUnicode(date, SlotSaveDate[i]);
} else {
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index db6be3a2..63ebccee 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -49,7 +49,13 @@ static RwInt32 GcurSel = 0, GcurSelVM = 0;
static RwBool useDefault;
+// What is that for anyway?
+#ifndef IMPROVED_VIDEOMODE
static RwBool defaultFullscreenRes = TRUE;
+#else
+static RwBool defaultFullscreenRes = FALSE;
+static RwInt32 bestWndMode = -1;
+#endif
static psGlobalType PsGlobal;
@@ -248,83 +254,6 @@ psNativeTextureSupport(void)
/*
*****************************************************************************
*/
-static char cpuvendor[16] = "UnknownVendr";
-__declspec(naked) const char * _psGetCpuVendr()
-{
- __asm
- {
- push ebx
- xor eax, eax
- cpuid
- mov dword ptr [cpuvendor+0], ebx
- mov dword ptr [cpuvendor+4], edx
- mov dword ptr [cpuvendor+8], ecx
- mov eax, offset cpuvendor
- pop ebx
- retn
- }
-}
-
-/*
- *****************************************************************************
- */
-__declspec(naked) RwUInt32 _psGetCpuFeatures()
-{
- __asm
- {
- mov eax, 1
- cpuid
- mov eax, edx
- retn
- }
-}
-
-/*
- *****************************************************************************
- */
-__declspec(naked) RwUInt32 _psGetCpuFeaturesEx()
-{
- __asm
- {
- mov eax, 80000000h
- cpuid
-
- cmp eax, 80000000h
- jbe short _NOEX
-
- mov eax, 80000001h
- cpuid
-
- mov eax, edx
- jmp short _RETEX
-
-_NOEX:
- xor eax, eax
- mov eax, eax
-
-_RETEX:
- retn
- }
-}
-
-void _psPrintCpuInfo()
-{
- RwUInt32 features = _psGetCpuFeatures();
- RwUInt32 FeaturesEx = _psGetCpuFeaturesEx();
-
- debug("Running on a %s", _psGetCpuVendr());
-
- if ( features & 0x800000 )
- debug("with MMX");
- if ( features & 0x2000000 )
- debug("with SSE");
- if ( FeaturesEx & 0x80000000 )
- debug("with 3DNow");
-}
-
-/*
- *****************************************************************************
- */
#ifdef UNDER_CE
#define CMDSTR LPWSTR
#else
@@ -357,8 +286,6 @@ psInitialise(void)
gGameState = GS_START_UP;
TRACE("gGameState = GS_START_UP");
- _psPrintCpuInfo();
-
OSVERSIONINFO verInfo;
verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
@@ -515,7 +442,7 @@ void _psSelectScreenVM(RwInt32 videoMode)
FrontEndMenuManager.UnloadTextures();
- if ( !_psSetVideoMode(RwEngineGetCurrentSubSystem(), videoMode) )
+ if (!_psSetVideoMode(RwEngineGetCurrentSubSystem(), videoMode))
{
RsGlobal.quit = TRUE;
}
@@ -608,6 +535,10 @@ psSelectDevice()
/* Get the default selection */
GcurSel = RwEngineGetCurrentSubSystem();
+#ifdef IMPROVED_VIDEOMODE
+ if(FrontEndMenuManager.m_nPrefsSubsystem < GnumSubSystems)
+ GcurSel = FrontEndMenuManager.m_nPrefsSubsystem;
+#endif
}
/* Set the driver to use the correct sub system */
@@ -615,8 +546,12 @@ psSelectDevice()
{
return FALSE;
}
-
-
+
+#ifdef IMPROVED_VIDEOMODE
+ FrontEndMenuManager.m_nPrefsSubsystem = GcurSel;
+#endif
+
+#ifndef IMPROVED_VIDEOMODE
if ( !useDefault )
{
if ( _psGetVideoModeList()[FrontEndMenuManager.m_nDisplayVideoMode] && FrontEndMenuManager.m_nDisplayVideoMode )
@@ -660,9 +595,67 @@ psSelectDevice()
}
}
}
-
+#else
+ if ( !useDefault )
+ {
+ if(FrontEndMenuManager.m_nPrefsWidth == 0 ||
+ FrontEndMenuManager.m_nPrefsHeight == 0 ||
+ FrontEndMenuManager.m_nPrefsDepth == 0){
+ // Defaults if nothing specified
+ FrontEndMenuManager.m_nPrefsWidth = GetSystemMetrics(SM_CXSCREEN);
+ FrontEndMenuManager.m_nPrefsHeight = GetSystemMetrics(SM_CYSCREEN);
+ FrontEndMenuManager.m_nPrefsDepth = 32;
+ FrontEndMenuManager.m_nPrefsWindowed = 0;
+ }
+
+ // Find the videomode that best fits what we got from the settings file
+ RwInt32 bestFsMode = -1;
+ RwInt32 bestWidth = -1;
+ RwInt32 bestHeight = -1;
+ RwInt32 bestDepth = -1;
+ for(GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++){
+ RwEngineGetVideoModeInfo(&vm, GcurSelVM);
+
+ if (!(vm.flags & rwVIDEOMODEEXCLUSIVE)){
+ bestWndMode = GcurSelVM;
+ } else {
+ // try the largest one that isn't larger than what we wanted
+ if(vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth &&
+ vm.height >= bestHeight && vm.height <= FrontEndMenuManager.m_nPrefsHeight &&
+ vm.depth >= bestDepth && vm.depth <= FrontEndMenuManager.m_nPrefsDepth){
+ bestWidth = vm.width;
+ bestHeight = vm.height;
+ bestDepth = vm.depth;
+ bestFsMode = GcurSelVM;
+ }
+ }
+ }
+
+ if(bestFsMode < 0){
+ MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK);
+ return FALSE;
+ }
+ GcurSelVM = bestFsMode;
+
+ FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
+ FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
+
+ FrontEndMenuManager.m_nSelectedScreenMode = FrontEndMenuManager.m_nPrefsWindowed;
+ }
+#endif
+
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
-
+
+#ifdef IMPROVED_VIDEOMODE
+ if (FrontEndMenuManager.m_nPrefsWindowed)
+ GcurSelVM = bestWndMode;
+
+ // Now GcurSelVM is 0 but vm has sizes(and fullscreen flag) of the video mode we want, that's why we changed the rwVIDEOMODEEXCLUSIVE conditions below
+ FrontEndMenuManager.m_nPrefsWidth = vm.width;
+ FrontEndMenuManager.m_nPrefsHeight = vm.height;
+ FrontEndMenuManager.m_nPrefsDepth = vm.depth;
+#endif
+
FrontEndMenuManager.m_nCurrOption = 0;
/* Set up the video mode and set the apps window
@@ -686,6 +679,7 @@ psSelectDevice()
}
}
*/
+#ifndef IMPROVED_VIDEOMODE
if (vm.flags & rwVIDEOMODEEXCLUSIVE)
{
RsGlobal.maximumWidth = vm.width;
@@ -695,10 +689,71 @@ psSelectDevice()
PSGLOBAL(fullScreen) = TRUE;
}
+#else
+ RsGlobal.maximumWidth = FrontEndMenuManager.m_nPrefsWidth;
+ RsGlobal.maximumHeight = FrontEndMenuManager.m_nPrefsHeight;
+ RsGlobal.width = FrontEndMenuManager.m_nPrefsWidth;
+ RsGlobal.height = FrontEndMenuManager.m_nPrefsHeight;
+
+ PSGLOBAL(fullScreen) = !FrontEndMenuManager.m_nPrefsWindowed;
+#endif
return TRUE;
}
+void keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods);
+void resizeCB(GLFWwindow* window, int width, int height);
+void scrollCB(GLFWwindow* window, double xoffset, double yoffset);
+void cursorCB(GLFWwindow* window, double xpos, double ypos);
+void joysChangeCB(int jid, int event);
+
+void _InputInitialiseJoys()
+{
+ for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
+ if (glfwJoystickPresent(i)) {
+ if (PSGLOBAL(joy1id) == -1)
+ PSGLOBAL(joy1id) = i;
+ else if (PSGLOBAL(joy2id) == -1)
+ PSGLOBAL(joy2id) = i;
+ else
+ break;
+ }
+ }
+
+ if (PSGLOBAL(joy1id) != -1) {
+ int count;
+ glfwGetJoystickButtons(PSGLOBAL(joy1id), &count);
+ ControlsManager.InitDefaultControlConfigJoyPad(count);
+ }
+}
+
+void _InputInitialiseMouse()
+{
+ glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
+}
+
+void psPostRWinit(void)
+{
+ RwVideoMode vm;
+ RwEngineGetVideoModeInfo(&vm, GcurSelVM);
+
+ glfwSetKeyCallback(PSGLOBAL(window), keypressCB);
+ glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB);
+ glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
+ glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
+ glfwSetJoystickCallback(joysChangeCB);
+
+ _InputInitialiseJoys();
+ _InputInitialiseMouse();
+
+ if(!(vm.flags & rwVIDEOMODEEXCLUSIVE))
+ glfwSetWindowSize(PSGLOBAL(window), RsGlobal.maximumWidth, RsGlobal.maximumHeight);
+
+ // Make sure all keys are released
+ CPad::GetPad(0)->Clear(true);
+ CPad::GetPad(1)->Clear(true);
+}
+
/*
*****************************************************************************
*/
@@ -713,9 +768,9 @@ RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode)
useDefault = TRUE;
- if ( RsEventHandler(rsRWINITIALISE, &PSGLOBAL(window)) == rsEVENTERROR )
+ if ( RsEventHandler(rsRWINITIALISE, &openParams) == rsEVENTERROR )
return FALSE;
-
+
RwInitialised = TRUE;
useDefault = FALSE;
@@ -728,6 +783,8 @@ RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode)
RsEventHandler(rsCAMERASIZE, &r);
+ psPostRWinit();
+
return TRUE;
}
@@ -967,14 +1024,18 @@ void resizeCB(GLFWwindow* window, int width, int height) {
if (RwInitialised && height > 0 && width > 0) {
RwRect r;
+ // TODO fix artifacts of resizing with mouse
+ RsGlobal.maximumHeight = height;
+ RsGlobal.maximumWidth = width;
+
r.x = 0;
r.y = 0;
- r.w = RsGlobal.maximumWidth;
- r.h = RsGlobal.maximumHeight;
+ r.w = width;
+ r.h = height;
RsEventHandler(rsCAMERASIZE, &r);
}
- glfwSetWindowPos(window, 0, 0);
+// glfwSetWindowPos(window, 0, 0);
}
void scrollCB(GLFWwindow* window, double xoffset, double yoffset) {
@@ -1146,31 +1207,6 @@ cursorCB(GLFWwindow* window, double xpos, double ypos) {
FrontEndMenuManager.m_nMouseTempPosY = ypos;
}
-void _InputInitialiseJoys()
-{
- for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
- if (glfwJoystickPresent(i)) {
- if (PSGLOBAL(joy1id) == -1)
- PSGLOBAL(joy1id) = i;
- else if (PSGLOBAL(joy2id) == -1)
- PSGLOBAL(joy2id) = i;
- else
- break;
- }
- }
-
- if (PSGLOBAL(joy1id) != -1) {
- int count;
- glfwGetJoystickButtons(PSGLOBAL(joy1id), &count);
- ControlsManager.InitDefaultControlConfigJoyPad(count);
- }
-}
-
-void _InputInitialiseMouse()
-{
- glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
-}
-
/*
*****************************************************************************
*/
@@ -1224,6 +1260,7 @@ WinMain(HINSTANCE instance,
openParams.width = RsGlobal.maximumWidth;
openParams.height = RsGlobal.maximumHeight;
openParams.windowtitle = RsGlobal.appName;
+ openParams.window = &PSGLOBAL(window);
ControlsManager.MakeControllerActionsBlank();
ControlsManager.InitDefaultControlConfiguration();
@@ -1231,18 +1268,18 @@ WinMain(HINSTANCE instance,
/*
* Initialize the 3D (RenderWare) components of the app...
*/
- if( rsEVENTERROR == RsEventHandler(rsRWINITIALISE, &PSGLOBAL(window)) )
+ if( rsEVENTERROR == RsEventHandler(rsRWINITIALISE, &openParams) )
{
RsEventHandler(rsTERMINATE, nil);
return 0;
}
- _InputInitialiseJoys();
- _InputInitialiseMouse();
+ psPostRWinit();
+
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
- glfwSetWindowPos(PSGLOBAL(window), 0, 0);
+// glfwSetWindowPos(PSGLOBAL(window), 0, 0);
/*
* Parse command line parameters (except program name) one at
@@ -1310,11 +1347,6 @@ WinMain(HINSTANCE instance,
#endif
initkeymap();
- glfwSetKeyCallback(PSGLOBAL(window), keypressCB);
- glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB);
- glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
- glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
- glfwSetJoystickCallback(joysChangeCB);
while ( TRUE )
{
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 288788c0..d20cc0bf 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -59,8 +59,6 @@ static RwBool startupDeactivate;
static RwBool useDefault;
-static RwBool defaultFullscreenRes = TRUE;
-
/* Class name for the MS Window's window class. */
static const RwChar *AppClassName = RWSTRING("Grand theft auto 3");
@@ -113,6 +111,14 @@ DWORD _dwOperatingSystemVersion;
RwUInt32 gGameState;
CJoySticks AllValidWinJoys;
+// What is that for anyway?
+#ifndef IMPROVED_VIDEOMODE
+static RwBool defaultFullscreenRes = TRUE;
+#else
+static RwBool defaultFullscreenRes = FALSE;
+static RwInt32 bestWndMode = -1;
+#endif
+
CJoySticks::CJoySticks()
{
for (int i = 0; i < MAX_JOYSTICKS; i++)
@@ -1310,6 +1316,10 @@ psSelectDevice()
/* Get the default selection */
GcurSel = RwEngineGetCurrentSubSystem();
+#ifdef IMPROVED_VIDEOMODE
+ if(FrontEndMenuManager.m_nPrefsSubsystem < GnumSubSystems)
+ GcurSel = FrontEndMenuManager.m_nPrefsSubsystem;
+#endif
}
/* Set the driver to use the correct sub system */
@@ -1317,8 +1327,12 @@ psSelectDevice()
{
return FALSE;
}
-
-
+
+#ifdef IMPROVED_VIDEOMODE
+ FrontEndMenuManager.m_nPrefsSubsystem = GcurSel;
+#endif
+
+#ifndef IMPROVED_VIDEOMODE
if ( !useDefault )
{
if ( _psGetVideoModeList()[FrontEndMenuManager.m_nDisplayVideoMode] && FrontEndMenuManager.m_nDisplayVideoMode )
@@ -1362,9 +1376,67 @@ psSelectDevice()
}
}
}
-
+#else
+ if ( !useDefault )
+ {
+ if(FrontEndMenuManager.m_nPrefsWidth == 0 ||
+ FrontEndMenuManager.m_nPrefsHeight == 0 ||
+ FrontEndMenuManager.m_nPrefsDepth == 0){
+ // Defaults if nothing specified
+ FrontEndMenuManager.m_nPrefsWidth = GetSystemMetrics(SM_CXSCREEN);
+ FrontEndMenuManager.m_nPrefsHeight = GetSystemMetrics(SM_CYSCREEN);
+ FrontEndMenuManager.m_nPrefsDepth = 32;
+ FrontEndMenuManager.m_nPrefsWindowed = 0;
+ }
+
+ // Find the videomode that best fits what we got from the settings file
+ RwInt32 bestFsMode = -1;
+ RwInt32 bestWidth = -1;
+ RwInt32 bestHeight = -1;
+ RwInt32 bestDepth = -1;
+ for (GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++) {
+ RwEngineGetVideoModeInfo(&vm, GcurSelVM);
+
+ if (!(vm.flags & rwVIDEOMODEEXCLUSIVE)) {
+ bestWndMode = GcurSelVM;
+ } else {
+ // try the largest one that isn't larger than what we wanted
+ if (vm.width >= bestWidth && vm.width <= FrontEndMenuManager.m_nPrefsWidth &&
+ vm.height >= bestHeight && vm.height <= FrontEndMenuManager.m_nPrefsHeight &&
+ vm.depth >= bestDepth && vm.depth <= FrontEndMenuManager.m_nPrefsDepth){
+ bestWidth = vm.width;
+ bestHeight = vm.height;
+ bestDepth = vm.depth;
+ bestFsMode = GcurSelVM;
+ }
+ }
+ }
+
+ if(bestFsMode < 0){
+ MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK);
+ return FALSE;
+ }
+ GcurSelVM = bestFsMode;
+
+ FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
+ FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
+
+ FrontEndMenuManager.m_nSelectedScreenMode = FrontEndMenuManager.m_nPrefsWindowed;
+ }
+#endif
+
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
-
+
+#ifdef IMPROVED_VIDEOMODE
+ if (FrontEndMenuManager.m_nPrefsWindowed)
+ GcurSelVM = bestWndMode;
+
+ // Now GcurSelVM is 0 but vm has sizes(and fullscreen flag) of the video mode we want, that's why we changed the rwVIDEOMODEEXCLUSIVE conditions below
+ FrontEndMenuManager.m_nPrefsWidth = vm.width;
+ FrontEndMenuManager.m_nPrefsHeight = vm.height;
+ FrontEndMenuManager.m_nPrefsDepth = vm.depth;
+#endif
+
FrontEndMenuManager.m_nCurrOption = 0;
/* Set up the video mode and set the apps window
@@ -1374,7 +1446,11 @@ psSelectDevice()
return FALSE;
}
+#ifdef IMPROVED_VIDEOMODE
+ if (!FrontEndMenuManager.m_nPrefsWindowed)
+#else
if (vm.flags & rwVIDEOMODEEXCLUSIVE)
+#endif
{
debug("%dx%dx%d", vm.width, vm.height, vm.depth);
@@ -1387,7 +1463,11 @@ psSelectDevice()
}
}
+#ifdef IMPROVED_VIDEOMODE
+ if (!FrontEndMenuManager.m_nPrefsWindowed)
+#else
if (vm.flags & rwVIDEOMODEEXCLUSIVE)
+#endif
{
RsGlobal.maximumWidth = vm.width;
RsGlobal.maximumHeight = vm.height;
@@ -1395,8 +1475,39 @@ psSelectDevice()
RsGlobal.height = vm.height;
PSGLOBAL(fullScreen) = TRUE;
+
+#ifdef IMPROVED_VIDEOMODE
+ SetWindowLong(PSGLOBAL(window), GWL_STYLE, WS_POPUP);
+ SetWindowPos(PSGLOBAL(window), nil, 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
+ SWP_FRAMECHANGED);
+ }else{
+ RECT rect;
+ rect.left = rect.top = 0;
+ rect.right = FrontEndMenuManager.m_nPrefsWidth;
+ rect.bottom = FrontEndMenuManager.m_nPrefsHeight;
+ AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
+
+ // center it
+ int spaceX = GetSystemMetrics(SM_CXSCREEN) - (rect.right-rect.left);
+ int spaceY = GetSystemMetrics(SM_CYSCREEN) - (rect.bottom-rect.top);
+
+ SetWindowLong(PSGLOBAL(window), GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW);
+ SetWindowPos(PSGLOBAL(window), HWND_NOTOPMOST, spaceX/2, spaceY/2,
+ (rect.right - rect.left),
+ (rect.bottom - rect.top), 0);
+
+ // Have to get actual size because the window perhaps didn't fit
+ GetClientRect(PSGLOBAL(window), &rect);
+ RsGlobal.maximumWidth = rect.right;
+ RsGlobal.maximumHeight = rect.bottom;
+ RsGlobal.width = rect.right;
+ RsGlobal.height = rect.bottom;
+
+ PSGLOBAL(fullScreen) = FALSE;
+#endif
}
-
+
return TRUE;
}
@@ -1840,11 +1951,13 @@ WinMain(HINSTANCE instance,
}
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
-
+
+#ifndef IMPROVED_VIDEOMODE
SetWindowLong(PSGLOBAL(window), GWL_STYLE, WS_POPUP);
SetWindowPos(PSGLOBAL(window), nil, 0, 0, 0, 0,
SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
SWP_FRAMECHANGED);
+#endif
/*
* Initialize the 3D (RenderWare) components of the app...
diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp
index 5abaa7ae..82ab294c 100644
--- a/src/text/Messages.cpp
+++ b/src/text/Messages.cpp
@@ -9,6 +9,8 @@
#include "ControllerConfig.h"
+#include "Font.h"
+
tMessage CMessages::BriefMessages[NUMBRIEFMESSAGES];
tPreviousBrief CMessages::PreviousBriefs[NUMPREVIOUSBRIEFS];
tBigMessage CMessages::BIGMessages[NUMBIGMESSAGES];
@@ -50,6 +52,15 @@ CMessages::WideStringCopy(wchar *dst, wchar *src, uint16 size)
dst[i] = '\0';
}
+wchar FixupChar(wchar c)
+{
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ return c & 0x7fff;
+#endif
+ return c;
+}
+
bool
CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size)
{
@@ -59,10 +70,10 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size)
return false;
for (int32 i = 0; i < size; i++) {
- if (!str1[i])
+ if (FixupChar(str1[i]) == '\0')
break;
- if (str1[i] != str2[i])
+ if (FixupChar(str1[i]) != FixupChar(str2[i]))
return false;
}
return true;
@@ -368,7 +379,12 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32
int32 i = 0;
for (int32 c = 0; c < size;) {
+#ifdef MORE_LANGUAGES
+ if ((CFont::IsJapanese() && str[c] == (0x8000 | '~') && str[c + 1] == (0x8000 | '1') && str[c + 2] == (0x8000 | '~')) ||
+ (!CFont::IsJapanese() && str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~')) {
+#else
if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') {
+#endif
switch (i) {
case 0: sprintf(numStr, "%d", n1); break;
case 1: sprintf(numStr, "%d", n2); break;
@@ -406,7 +422,13 @@ CMessages::InsertStringInString(wchar *str1, wchar *str2)
wchar *_str1 = str1;
uint16 i;
for (i = 0; i < total_size; ) {
- if (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~') {
+#ifdef MORE_LANGUAGES
+ if ((CFont::IsJapanese() && *_str1 == (0x8000 | '~') && *(_str1 + 1) == (0x8000 | 'a') && *(_str1 + 2) == (0x8000 | '~'))
+ || (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~'))
+ {
+#else
+ if (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~') {
+#endif
_str1 += 3;
for (int j = 0; j < str2_size; j++) {
tempstr[i++] = str2[j];
@@ -437,7 +459,12 @@ CMessages::InsertPlayerControlKeysInString(wchar *str)
wchar *_outstr = outstr;
for (i = 0; i < strSize;) {
+#ifdef MORE_LANGUAGES
+ if ((CFont::IsJapanese() && str[i] == (0x8000 | '~') && str[i + 1] == (0x8000 | 'k') && str[i + 2] == (0x8000 | '~')) ||
+ (!CFont::IsJapanese() && str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~')) {
+#else
if (str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~') {
+#endif
i += 4;
for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS; cont++) {
uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]);
diff --git a/src/text/Text.cpp b/src/text/Text.cpp
index f481403d..549f68d9 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -1,6 +1,9 @@
#include "common.h"
#include "FileMgr.h"
+#ifdef MORE_LANGUAGES
+#include "Game.h"
+#endif
#include "Frontend.h"
#include "Messages.h"
#include "Text.h"
@@ -50,6 +53,9 @@ CText::Load(void)
case LANGUAGE_RUSSIAN:
sprintf(filename, "RUSSIAN.GXT");
break;
+ case LANGUAGE_JAPANESE:
+ sprintf(filename, "JAPANESE.GXT");
+ break;
#endif
}
@@ -257,7 +263,7 @@ CData::Unload(void)
void
AsciiToUnicode(const char *src, wchar *dst)
{
- while((*dst++ = *src++) != '\0');
+ while((*dst++ = (unsigned char)*src++) != '\0');
}
char*
@@ -266,7 +272,11 @@ UnicodeToAscii(wchar *src)
static char aStr[256];
int len;
for(len = 0; *src != '\0' && len < 256-1; len++, src++)
+#ifdef MORE_LANGUAGES
+ if(*src < 128 || ((CGame::russianGame || CGame::japaneseGame) && *src < 256))
+#else
if(*src < 128)
+#endif
aStr[len] = *src;
else
aStr[len] = '#';
@@ -306,4 +316,4 @@ void
TextCopy(wchar *dst, const wchar *src)
{
while((*dst++ = *src++) != '\0');
-}
+} \ No newline at end of file
diff --git a/src/text/Text.h b/src/text/Text.h
index 00d1c5e6..4255e2a5 100644
--- a/src/text/Text.h
+++ b/src/text/Text.h
@@ -12,8 +12,9 @@ struct CKeyEntry
wchar *value;
char key[8];
};
+
// If this fails, CKeyArray::Load will have to be fixed
-static_assert(sizeof(CKeyEntry) == 12, "CKeyEntry: error");
+VALIDATE_SIZE(CKeyEntry, 12);
class CKeyArray
{
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index bfb215d2..60f17204 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -51,6 +51,13 @@ RwObject *GetCurrentAtomicObjectCB(RwObject *object, void *data);
bool CAutomobile::m_sAllTaxiLights;
+const uint32 CAutomobile::nSaveStructSize =
+#ifdef COMPATIBLE_SAVES
+ 1448;
+#else
+ sizeof(CAutomobile);
+#endif
+
CAutomobile::CAutomobile(int32 id, uint8 CreatedBy)
: CVehicle(CreatedBy)
{
@@ -162,7 +169,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy)
SetupSuspensionLines();
- m_status = STATUS_SIMPLE;
+ SetStatus(STATUS_SIMPLE);
bUseCollisionRecords = true;
m_nNumPassengers = 0;
@@ -254,8 +261,8 @@ CAutomobile::ProcessControl(void)
ProcessCarAlarm();
// Scan if this car sees the player committing any crimes
- if(m_status != STATUS_ABANDONED && m_status != STATUS_WRECKED &&
- m_status != STATUS_PLAYER && m_status != STATUS_PLAYER_REMOTE && m_status != STATUS_PLAYER_DISABLED){
+ if(GetStatus() != STATUS_ABANDONED && GetStatus() != STATUS_WRECKED &&
+ GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PLAYER_DISABLED){
switch(GetModelIndex())
case MI_FBICAR:
case MI_POLICE:
@@ -318,7 +325,7 @@ CAutomobile::ProcessControl(void)
// Set Center of Mass to make car more stable
if(strongGrip1 || bCheat3)
m_vecCentreOfMass.z = 0.3f*m_aSuspensionSpringLength[0] + -1.0f*m_fHeightAboveRoad;
- else if(pHandling->Flags & HANDLING_NONPLAYER_STABILISER && m_status == STATUS_PHYSICS)
+ else if(pHandling->Flags & HANDLING_NONPLAYER_STABILISER && GetStatus() == STATUS_PHYSICS)
m_vecCentreOfMass.z = pHandling->CentreOfMass.z - 0.2f*pHandling->Dimension.z;
else
m_vecCentreOfMass.z = pHandling->CentreOfMass.z;
@@ -326,7 +333,7 @@ CAutomobile::ProcessControl(void)
// Process depending on status
bool playerRemote = false;
- switch(m_status){
+ switch(GetStatus()){
case STATUS_PLAYER_REMOTE:
if(CPad::GetPad(0)->WeaponJustDown()){
BlowUpCar(FindPlayerPed());
@@ -356,7 +363,7 @@ CAutomobile::ProcessControl(void)
PruneReferences();
- if(m_status == STATUS_PLAYER && !CRecordDataForChase::IsRecording())
+ if(GetStatus() == STATUS_PLAYER && !CRecordDataForChase::IsRecording())
DoDriveByShootings();
}
break;
@@ -426,7 +433,7 @@ CAutomobile::ProcessControl(void)
// Skip physics if object is found to have been static recently
bool skipPhysics = false;
- if(!bIsStuck && (m_status == STATUS_ABANDONED || m_status == STATUS_WRECKED)){
+ if(!bIsStuck && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED)){
bool makeStatic = false;
float moveSpeedLimit, turnSpeedLimit, distanceLimit;
@@ -436,7 +443,7 @@ CAutomobile::ProcessControl(void)
m_aSuspensionSpringRatioPrev[3] != 1.0f)
makeStatic = true;
- if(m_status == STATUS_WRECKED){
+ if(GetStatus() == STATUS_WRECKED){
moveSpeedLimit = 0.006f;
turnSpeedLimit = 0.0015f;
distanceLimit = 0.015f;
@@ -494,7 +501,7 @@ CAutomobile::ProcessControl(void)
default:
if(CVehicle::bCheat3){
// Make vehicle jump when horn is sounded
- if(m_status == STATUS_PLAYER && m_vecMoveSpeed.MagnitudeSqr() > sq(0.2f) &&
+ if(GetStatus() == STATUS_PLAYER && m_vecMoveSpeed.MagnitudeSqr() > sq(0.2f) &&
// BUG: game checks [0] four times, instead of all wheels
m_aSuspensionSpringRatio[0] < 1.0f &&
CPad::GetPad(0)->HornJustDown()){
@@ -563,7 +570,7 @@ CAutomobile::ProcessControl(void)
bHasHitWall = false;
m_fDistanceTravelled = 0.0f;
m_bIsVehicleBeingShifted = false;
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
ApplyMoveSpeed();
ApplyTurnSpeed();
for(i = 0; CheckCollision() && i < 5; i++){
@@ -713,7 +720,7 @@ CAutomobile::ProcessControl(void)
}
float traction;
- if(m_status == STATUS_PHYSICS)
+ if(GetStatus() == STATUS_PHYSICS)
traction = 0.004f * m_fTraction;
else
traction = 0.004f;
@@ -764,7 +771,7 @@ CAutomobile::ProcessControl(void)
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceA = SURFACE_RUBBER29;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_LEFT])*traction;
- if(m_status == STATUS_PLAYER)
+ if(GetStatus() == STATUS_PLAYER)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB);
WheelState[CARWHEEL_FRONT_LEFT] = m_aWheelState[CARWHEEL_FRONT_LEFT];
@@ -798,7 +805,7 @@ CAutomobile::ProcessControl(void)
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceA = SURFACE_RUBBER29;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT])*traction;
- if(m_status == STATUS_PLAYER)
+ if(GetStatus() == STATUS_PLAYER)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB);
WheelState[CARWHEEL_FRONT_RIGHT] = m_aWheelState[CARWHEEL_FRONT_RIGHT];
@@ -873,7 +880,7 @@ CAutomobile::ProcessControl(void)
m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceA = SURFACE_RUBBER29;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_LEFT])*traction;
- if(m_status == STATUS_PLAYER)
+ if(GetStatus() == STATUS_PLAYER)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB);
WheelState[CARWHEEL_REAR_LEFT] = m_aWheelState[CARWHEEL_REAR_LEFT];
@@ -907,7 +914,7 @@ CAutomobile::ProcessControl(void)
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceA = SURFACE_RUBBER29;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_RIGHT])*traction;
- if(m_status == STATUS_PLAYER)
+ if(GetStatus() == STATUS_PLAYER)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB);
WheelState[CARWHEEL_REAR_RIGHT] = m_aWheelState[CARWHEEL_REAR_RIGHT];
@@ -976,7 +983,7 @@ CAutomobile::ProcessControl(void)
// Process horn
- if(m_status != STATUS_PLAYER){
+ if(GetStatus() != STATUS_PLAYER){
ReduceHornCounter();
}else{
if(GetModelIndex() == MI_MRWHOOP){
@@ -1008,7 +1015,7 @@ CAutomobile::ProcessControl(void)
// Flying
- if(m_status != STATUS_PLAYER && m_status != STATUS_PLAYER_REMOTE && m_status != STATUS_PHYSICS){
+ if(GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PHYSICS){
if(GetModelIndex() == MI_MIAMI_RCRAIDER || GetModelIndex() == MI_MIAMI_SPARROW)
m_aWheelSpeed[0] = Max(m_aWheelSpeed[0]-0.0005f, 0.0f);
}else if((GetModelIndex() == MI_DODO || CVehicle::bAllDodosCheat) &&
@@ -1061,7 +1068,7 @@ CAutomobile::ProcessControl(void)
// move fire forward if in first person
if(this == FindPlayerVehicle() && TheCamera.GetLookingForwardFirstPerson())
- if(m_fHealth < 250.0f && m_status != STATUS_WRECKED){
+ if(m_fHealth < 250.0f && GetStatus() != STATUS_WRECKED){
if(GetModelIndex() == MI_FIRETRUCK)
damagePos += CVector(0.0f, 3.0f, -0.2f);
else
@@ -1071,7 +1078,7 @@ CAutomobile::ProcessControl(void)
damagePos = GetMatrix()*damagePos;
damagePos.z += 0.15f;
- if(m_fHealth < 250.0f && m_status != STATUS_WRECKED){
+ if(m_fHealth < 250.0f && GetStatus() != STATUS_WRECKED){
// Car is on fire
CParticle::AddParticle(PARTICLE_CARFLAME, damagePos,
@@ -1137,7 +1144,7 @@ CAutomobile::ProcessControl(void)
// Shake pad
- if((suspShake > 0.0f || surfShake > 0.0f) && m_status == STATUS_PLAYER){
+ if((suspShake > 0.0f || surfShake > 0.0f) && GetStatus() == STATUS_PLAYER){
float speed = m_vecMoveSpeed.MagnitudeSqr();
if(speed > sq(0.1f)){
speed = Sqrt(speed);
@@ -1198,7 +1205,7 @@ CAutomobile::ProcessControl(void)
m_vecMoveFriction = CVector(0.0f, 0.0f, 0.0f);
m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f);
}else if(!skipPhysics &&
- (m_fGasPedal == 0.0f && brake == 0.0f || m_status == STATUS_WRECKED)){
+ (m_fGasPedal == 0.0f && brake == 0.0f || GetStatus() == STATUS_WRECKED)){
if(Abs(m_vecMoveSpeed.x) < 0.005f &&
Abs(m_vecMoveSpeed.y) < 0.005f &&
Abs(m_vecMoveSpeed.z) < 0.005f){
@@ -1213,7 +1220,7 @@ CAutomobile::Teleport(CVector pos)
{
CWorld::Remove(this);
- GetPosition() = pos;
+ SetPosition(pos);
SetOrientation(0.0f, 0.0f, 0.0f);
SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f);
@@ -1255,7 +1262,7 @@ CAutomobile::PreRender(void)
}
}
}else{
- if(m_status == STATUS_SIMPLE){
+ if(GetStatus() == STATUS_SIMPLE){
CMatrix mat;
CVector pos;
@@ -1285,8 +1292,8 @@ CAutomobile::PreRender(void)
}
int drawParticles = Abs(fwdSpeed) < 90.0f;
- if(m_status == STATUS_SIMPLE || m_status == STATUS_PHYSICS ||
- m_status == STATUS_PLAYER || m_status == STATUS_PLAYER_PLAYBACKFROMBUFFER){
+ if(GetStatus() == STATUS_SIMPLE || GetStatus() == STATUS_PHYSICS ||
+ GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PLAYER_PLAYBACKFROMBUFFER){
bool rearSkidding = false;
if(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SKIDDING ||
m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SKIDDING)
@@ -1618,8 +1625,8 @@ CAutomobile::PreRender(void)
CClock::GetHours() < 8 && CClock::GetMinutes() < (m_randomSeed & 0x3F) ||
m_randomSeed/50000.0f < CWeather::Foggyness ||
m_randomSeed/50000.0f < CWeather::WetRoads;
- if(shouldLightsBeOn != bLightsOn && m_status != STATUS_WRECKED){
- if(m_status == STATUS_ABANDONED){
+ if(shouldLightsBeOn != bLightsOn && GetStatus() != STATUS_WRECKED){
+ if(GetStatus() == STATUS_ABANDONED){
// Turn off lights on abandoned vehicles only when we they're far away
if(bLightsOn &&
Abs(TheCamera.GetPosition().x - GetPosition().x) + Abs(TheCamera.GetPosition().y - GetPosition().y) > 100.0f)
@@ -1857,7 +1864,7 @@ CAutomobile::PreRender(void)
}else{
// Lights off
- if(m_status == STATUS_ABANDONED || m_status == STATUS_WRECKED) {
+ if(GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED) {
CShadows::StoreShadowForCar(this);
return;
}
@@ -2139,7 +2146,7 @@ CAutomobile::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
int i;
CColModel *colModel;
- if(m_status != STATUS_SIMPLE)
+ if(GetStatus() != STATUS_SIMPLE)
bVehicleColProcessed = true;
if(bUsingSpecialColModel)
@@ -2160,7 +2167,7 @@ CAutomobile::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
// m_aSuspensionSpringRatio are now set to the point where the tyre touches ground.
// In ProcessControl these will be re-normalized to ignore the tyre radius.
- if(m_bIsVehicleBeingShifted || m_phy_flagA80 ||
+ if(m_bIsVehicleBeingShifted || bSkipLineCol ||
GetModelIndex() == MI_DODO && (ent->IsPed() || ent->IsVehicle())){
// don't do line collision
for(i = 0; i < 4; i++)
@@ -2178,7 +2185,7 @@ CAutomobile::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
phys->RegisterReference((CEntity**)&m_aGroundPhysical[i]);
m_aGroundOffset[i] = m_aWheelColPoints[i].point - phys->GetPosition();
- if(phys->GetModelIndex() == MI_BODYCAST && m_status == STATUS_PLAYER){
+ if(phys->GetModelIndex() == MI_BODYCAST && GetStatus() == STATUS_PLAYER){
// damage body cast
float speed = m_vecMoveSpeed.MagnitudeSqr();
if(speed > 0.1f){
@@ -2187,7 +2194,7 @@ CAutomobile::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
}
// move body cast
- if(phys->bIsStatic){
+ if(phys->IsStatic()){
phys->bIsStatic = false;
phys->m_nStaticFrames = 0;
phys->ApplyMoveForce(m_vecMoveSpeed / Sqrt(speed));
@@ -2370,7 +2377,7 @@ CAutomobile::FireTruckControl(void)
cannonDir = Multiply3x3(GetMatrix(), cannonDir);
cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f;
CWaterCannons::UpdateOne((uintptr)this, &cannonPos, &cannonDir);
- }else if(m_status == STATUS_PHYSICS){
+ }else if(GetStatus() == STATUS_PHYSICS){
CFire *fire = gFireManager.FindFurthestFire_NeverMindFireMen(GetPosition(), 10.0f, 35.0f);
if(fire == nil)
return;
@@ -2531,7 +2538,7 @@ CAutomobile::HydraulicControl(void)
CPlayerInfo *playerInfo = &CWorld::Players[CWorld::PlayerInFocus];
CColModel *specialColModel = &playerInfo->m_ColModel;
- if(m_status != STATUS_PLAYER){
+ if(GetStatus() != STATUS_PLAYER){
// reset hydraulics for non-player cars
if(!bUsingSpecialColModel)
@@ -3123,7 +3130,7 @@ CAutomobile::RcbanditCheck1CarWheels(CPtrList &list)
mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(car->GetModelIndex());
for(i = 0; i < 4; i++){
- if(car->m_aSuspensionSpringRatioPrev[i] < 1.0f || car->m_status == STATUS_SIMPLE){
+ if(car->m_aSuspensionSpringRatioPrev[i] < 1.0f || car->GetStatus() == STATUS_SIMPLE){
CVector wheelPos;
CColSphere sph;
mi->GetWheelPosn(i, wheelPos);
@@ -3179,10 +3186,10 @@ CAutomobile::PlaceOnRoadProperly(void)
float c = Cos(angle);
float s = Sin(angle);
- GetRight() = CVector((front.y - rear.y)/len, -(front.x - rear.x)/len, 0.0f);
- GetForward() = CVector(-c*GetRight().y, c*GetRight().x, s);
- GetUp() = CrossProduct(GetRight(), GetForward());
- GetPosition() = CVector((front.x + rear.x)/2.0f, (front.y + rear.y)/2.0f, (frontZ + rearZ)/2.0f + GetHeightAboveRoad());
+ GetMatrix().GetRight() = CVector((front.y - rear.y) / len, -(front.x - rear.x) / len, 0.0f);
+ GetMatrix().GetForward() = CVector(-c * GetRight().y, c * GetRight().x, s);
+ GetMatrix().GetUp() = CrossProduct(GetRight(), GetForward());
+ GetMatrix().GetPosition() = CVector((front.x + rear.x) / 2.0f, (front.y + rear.y) / 2.0f, (frontZ + rearZ) / 2.0f + GetHeightAboveRoad());
}
void
@@ -3205,20 +3212,20 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
// damage flipped over car
if(GetUp().z < 0.0f && this != FindPlayerVehicle()){
- if(bNotDamagedUpsideDown || m_status == STATUS_PLAYER_REMOTE || bIsInWater)
+ if(bNotDamagedUpsideDown || GetStatus() == STATUS_PLAYER_REMOTE || bIsInWater)
return;
m_fHealth -= 4.0f*CTimer::GetTimeStep();
}
- if(impulse > 25.0f && m_status != STATUS_WRECKED){
+ if(impulse > 25.0f && GetStatus() != STATUS_WRECKED){
if(bIsLawEnforcer &&
FindPlayerVehicle() && FindPlayerVehicle() == m_pDamageEntity &&
- m_status != STATUS_ABANDONED &&
+ GetStatus() != STATUS_ABANDONED &&
FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() >= m_vecMoveSpeed.Magnitude() &&
FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() > 0.1f)
FindPlayerPed()->SetWantedLevelNoDrop(1);
- if(m_status == STATUS_PLAYER && impulse > 50.0f){
+ if(GetStatus() == STATUS_PLAYER && impulse > 50.0f){
uint8 freq = Min(0.4f*impulse*2000.0f/m_fMass + 100.0f, 250.0f);
CPad::GetPad(0)->StartShake(40000/freq, freq);
}
@@ -3382,7 +3389,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
float damage = (impulse-25.0f)*pHandling->fCollisionDamageMultiplier*0.6f*damageMultiplier;
- if(GetModelIndex() == MI_SECURICA && m_pDamageEntity && m_pDamageEntity->m_status == STATUS_PLAYER)
+ if(GetModelIndex() == MI_SECURICA && m_pDamageEntity && m_pDamageEntity->GetStatus() == STATUS_PLAYER)
damage *= 7.0f;
if(damage > 0.0f){
@@ -3816,7 +3823,7 @@ CAutomobile::BlowUpCar(CEntity *culprit)
// explosion pushes vehicle up
m_vecMoveSpeed.z += 0.13f;
- m_status = STATUS_WRECKED;
+ SetStatus(STATUS_WRECKED);
bRenderScorched = true;
m_nTimeOfDeath = CTimer::GetTimeInMilliseconds();
Damage.FuckCarCompletely();
@@ -3933,8 +3940,8 @@ CAutomobile::BurstTyre(uint8 wheel)
if(status == WHEEL_STATUS_OK){
Damage.SetWheelStatus(wheel, WHEEL_STATUS_BURST);
- if(m_status == STATUS_SIMPLE){
- m_status = STATUS_PHYSICS;
+ if(GetStatus() == STATUS_SIMPLE){
+ SetStatus(STATUS_PHYSICS);
CCarCtrl::SwitchVehicleToRealPhysics(this);
}
@@ -4133,13 +4140,13 @@ CAutomobile::HasCarStoppedBecauseOfLight(void)
{
int i;
- if(m_status != STATUS_SIMPLE && m_status != STATUS_PHYSICS)
+ if(GetStatus() != STATUS_SIMPLE && GetStatus() != STATUS_PHYSICS)
return false;
if(AutoPilot.m_nCurrentRouteNode && AutoPilot.m_nNextRouteNode){
CPathNode *curnode = &ThePaths.m_pathNodes[AutoPilot.m_nCurrentRouteNode];
for(i = 0; i < curnode->numLinks; i++)
- if(ThePaths.m_connections[curnode->firstLink + i] == AutoPilot.m_nNextRouteNode)
+ if(ThePaths.ConnectedNode(curnode->firstLink + i) == AutoPilot.m_nNextRouteNode)
break;
if(i < curnode->numLinks &&
ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[curnode->firstLink + i]].trafficLightType & 3)
@@ -4149,7 +4156,7 @@ CAutomobile::HasCarStoppedBecauseOfLight(void)
if(AutoPilot.m_nCurrentRouteNode && AutoPilot.m_nPrevRouteNode){
CPathNode *curnode = &ThePaths.m_pathNodes[AutoPilot.m_nCurrentRouteNode];
for(i = 0; i < curnode->numLinks; i++)
- if(ThePaths.m_connections[curnode->firstLink + i] == AutoPilot.m_nPrevRouteNode)
+ if(ThePaths.ConnectedNode(curnode->firstLink + i) == AutoPilot.m_nPrevRouteNode)
break;
if(i < curnode->numLinks &&
ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[curnode->firstLink + i]].trafficLightType & 3)
@@ -4401,7 +4408,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
if(GetUp().z > 0.0f){
// simulate fast upward movement if going fast
float speed = CVector2D(m_vecMoveSpeed).MagnitudeSqr();
- obj->GetPosition() += GetUp()*speed;
+ obj->GetMatrix().Translate(GetUp()*speed);
}
}
obj->ApplyMoveForce(dist);
@@ -4580,3 +4587,22 @@ CAutomobile::SetAllTaxiLights(bool set)
{
m_sAllTaxiLights = set;
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CAutomobile::Save(uint8*& buf)
+{
+ CVehicle::Save(buf);
+ WriteSaveBuf<CDamageManager>(buf, Damage);
+ SkipSaveBuf(buf, 800 - sizeof(CDamageManager));
+}
+
+void
+CAutomobile::Load(uint8*& buf)
+{
+ CVehicle::Load(buf);
+ Damage = ReadSaveBuf<CDamageManager>(buf);
+ SkipSaveBuf(buf, 800 - sizeof(CDamageManager));
+ SetupDamageAfterLoad();
+}
+#endif
diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h
index 2de85a99..a3e8ac17 100644
--- a/src/vehicles/Automobile.h
+++ b/src/vehicles/Automobile.h
@@ -188,10 +188,16 @@ public:
void HideAllComps(void);
void ShowAllComps(void);
void ReduceHornCounter(void);
+#ifdef COMPATIBLE_SAVES
+ virtual void Save(uint8*& buf);
+ virtual void Load(uint8*& buf);
+#endif
+ static const uint32 nSaveStructSize;
static void SetAllTaxiLights(bool set);
};
-static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error");
+
+VALIDATE_SIZE(CAutomobile, 0x5A8);
inline uint8 GetCarDoorFlag(int32 carnode) {
switch (carnode) {
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index 14eb2f05..348f2732 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -32,6 +32,13 @@ float WAKE_LIFETIME = 400.0f;
CBoat *CBoat::apFrameWakeGeneratingBoats[4];
+const uint32 CBoat::nSaveStructSize =
+#ifdef COMPATIBLE_SAVES
+ 1156;
+#else
+ sizeof(CBoat);
+#endif
+
CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner)
{
CVehicleModelInfo *minfo = (CVehicleModelInfo*)CModelInfo::GetModelInfo(mi);
@@ -137,7 +144,7 @@ CBoat::ProcessControl(void)
ProcessCarAlarm();
- switch(m_status){
+ switch(GetStatus()){
case STATUS_PLAYER:
m_bIsAnchored = false;
m_fOrientation = INVALID_ORIENTATION;
@@ -176,7 +183,7 @@ CBoat::ProcessControl(void)
}
float collisionDamage = pHandling->fCollisionDamageMultiplier * m_fDamageImpulse;
- if(collisionDamage > 25.0f && m_status != STATUS_WRECKED && m_fHealth >= 150.0f){
+ if(collisionDamage > 25.0f && GetStatus() != STATUS_WRECKED && m_fHealth >= 150.0f){
float prevHealth = m_fHealth;
if(this == FindPlayerVehicle()){
if(bTakeLessDamage)
@@ -199,7 +206,7 @@ CBoat::ProcessControl(void)
}
// Damage particles
- if(m_fHealth <= 600.0f && m_status != STATUS_WRECKED &&
+ if(m_fHealth <= 600.0f && GetStatus() != STATUS_WRECKED &&
Abs(GetPosition().x - TheCamera.GetPosition().x) < 200.0f &&
Abs(GetPosition().y - TheCamera.GetPosition().y) < 200.0f){
float speedSq = m_vecMoveSpeed.MagnitudeSqr();
@@ -283,7 +290,7 @@ CBoat::ProcessControl(void)
AddWakePoint(GetPosition());
float steerFactor = 1.0f - DotProduct(m_vecMoveSpeed, GetForward());
- if(m_modelIndex == MI_GHOST)
+ if (GetModelIndex() == MI_GHOST)
steerFactor = 1.0f - DotProduct(m_vecMoveSpeed, GetForward())*0.3f;
if(steerFactor < 0.0f) steerFactor = 0.0f;
@@ -326,7 +333,7 @@ CBoat::ProcessControl(void)
// Spray some particles
CVector jetDir = -0.04f * force;
if(m_fGasPedal > 0.0f){
- if(m_status == STATUS_PLAYER){
+ if(GetStatus() == STATUS_PLAYER){
bool cameraHack = TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN ||
TheCamera.WhoIsInControlOfTheCamera == CAMCONTROL_OBBE;
CVector sternPos = GetColModel()->boundingBox.min;
@@ -513,7 +520,7 @@ CBoat::ProcessControl(void)
// is this some inlined CPlaceable method?
CVector pos = GetPosition();
GetMatrix().RotateZ(m_fOrientation - GetForward().Heading());
- GetPosition() = pos;
+ GetMatrix().GetPosition() = pos;
}
}
@@ -597,7 +604,7 @@ CBoat::BlowUpCar(CEntity *culprit)
// explosion pushes vehicle up
m_vecMoveSpeed.z += 0.13f;
- m_status = STATUS_WRECKED;
+ SetStatus(STATUS_WRECKED);
bRenderScorched = true;
m_fHealth = 0.0;
@@ -673,7 +680,7 @@ CBoat::BlowUpCar(CEntity *culprit)
dist.Normalise();
if(GetUp().z > 0.0f)
dist += GetUp();
- obj->GetPosition() += GetUp();
+ obj->GetMatrix().GetPosition() += GetUp();
CWorld::Add(obj);
@@ -764,7 +771,7 @@ void
CBoat::Teleport(CVector v)
{
CWorld::Remove(this);
- GetPosition() = v;
+ SetPosition(v);
SetOrientation(0.0f, 0.0f, 0.0f);
SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f);
@@ -899,3 +906,19 @@ CBoat::AddWakePoint(CVector point)
m_nNumWakePoints = 1;
}
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CBoat::Save(uint8*& buf)
+{
+ CVehicle::Save(buf);
+ SkipSaveBuf(buf, 1156 - 648);
+}
+
+void
+CBoat::Load(uint8*& buf)
+{
+ CVehicle::Load(buf);
+ SkipSaveBuf(buf, 1156 - 648);
+}
+#endif
diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h
index ba56e355..3cc3513d 100644
--- a/src/vehicles/Boat.h
+++ b/src/vehicles/Boat.h
@@ -64,8 +64,15 @@ public:
static float IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat);
static void FillBoatList(void);
+#ifdef COMPATIBLE_SAVES
+ virtual void Save(uint8*& buf);
+ virtual void Load(uint8*& buf);
+#endif
+ static const uint32 nSaveStructSize;
+
};
-static_assert(sizeof(CBoat) == 0x484, "CBoat: error");
+
+VALIDATE_SIZE(CBoat, 0x484);
extern float MAX_WAKE_LENGTH;
extern float MIN_WAKE_INTERVAL;
diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp
index 64743929..72b6c30c 100644
--- a/src/vehicles/CarGen.cpp
+++ b/src/vehicles/CarGen.cpp
@@ -59,9 +59,9 @@ void CCarGenerator::DoInternalProcessing()
if (pos.z <= -100.0f)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += pBoat->GetDistanceFromCentreOfMassToBaseOfModel();
- pBoat->GetPosition() = pos;
+ pBoat->SetPosition(pos);
pBoat->SetOrientation(0.0f, 0.0f, DEGTORAD(m_fAngle));
- pBoat->m_status = STATUS_ABANDONED;
+ pBoat->SetStatus(STATUS_ABANDONED);
pBoat->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(pBoat);
if (CGeneral::GetRandomNumberInRange(0, 100) < m_nAlarm)
@@ -93,9 +93,9 @@ void CCarGenerator::DoInternalProcessing()
pCar->bIsStatic = false;
pCar->bEngineOn = false;
pos.z += pCar->GetDistanceFromCentreOfMassToBaseOfModel();
- pCar->GetPosition() = pos;
+ pCar->SetPosition(pos);
pCar->SetOrientation(0.0f, 0.0f, DEGTORAD(m_fAngle));
- pCar->m_status = STATUS_ABANDONED;
+ pCar->SetStatus(STATUS_ABANDONED);
pCar->bLightsOn = false;
pCar->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(pCar);
@@ -130,7 +130,7 @@ void CCarGenerator::Process()
m_nVehicleHandle = -1;
return;
}
- if (pVehicle->m_status != STATUS_PLAYER)
+ if (pVehicle->GetStatus() != STATUS_PLAYER)
return;
m_nTimer += 60000;
m_nVehicleHandle = -1;
diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp
index 7d2160d9..3ef11302 100644
--- a/src/vehicles/Cranes.cpp
+++ b/src/vehicles/Cranes.cpp
@@ -340,7 +340,7 @@ void CCrane::Update(void)
case GOING_TOWARDS_TARGET_ONLY_HEIGHT:
case ROTATING_TARGET:
if (m_pVehiclePickedUp) {
- m_pVehiclePickedUp->GetPosition() = CVector(m_vecHookCurPos.x, m_vecHookCurPos.y, m_vecHookCurPos.z - m_pVehiclePickedUp->GetColModel()->boundingBox.max.z);
+ m_pVehiclePickedUp->SetPosition(m_vecHookCurPos.x, m_vecHookCurPos.y, m_vecHookCurPos.z - m_pVehiclePickedUp->GetColModel()->boundingBox.max.z);
m_pVehiclePickedUp->SetMoveSpeed(0.0f, 0.0f, 0.0f);
CVector up(vecHook.x - m_vecHookCurPos.x, vecHook.y - m_vecHookCurPos.y, 20.0f);
up.Normalise();
@@ -416,7 +416,7 @@ void CCrane::FindCarInSectorList(CPtrList* pList)
Abs(pVehicle->GetMoveSpeed().y) >= CAR_MOVING_SPEED_THRESHOLD ||
Abs(pVehicle->GetMoveSpeed().z) >= CAR_MOVING_SPEED_THRESHOLD)
continue;
- if (!pVehicle->IsCar() || pVehicle->m_status == STATUS_WRECKED || pVehicle->m_fHealth < 250.0f)
+ if (!pVehicle->IsCar() || pVehicle->GetStatus() == STATUS_WRECKED || pVehicle->m_fHealth < 250.0f)
continue;
if (!DoesCranePickUpThisCarType(pVehicle->GetModelIndex()) ||
m_bIsMilitaryCrane && CCranes::DoesMilitaryCraneHaveThisOneAlready(pVehicle->GetModelIndex())) {
@@ -443,7 +443,9 @@ bool CCrane::DoesCranePickUpThisCarType(uint32 mi)
if (m_bIsCrusher) {
return mi != MI_FIRETRUCK &&
mi != MI_TRASH &&
-#ifndef FIX_BUGS // why
+#ifdef FIX_BUGS
+ mi != MI_COACH &&
+#else
mi != MI_BLISTA &&
#endif
mi != MI_SECURICA &&
@@ -585,7 +587,7 @@ void CCrane::SetHookMatrix()
{
if (m_pHook == nil)
return;
- m_pHook->GetPosition() = m_vecHookCurPos;
+ m_pHook->SetPosition(m_vecHookCurPos);
CVector up(m_vecHookInitPos.x - m_vecHookCurPos.x, m_vecHookInitPos.y - m_vecHookCurPos.y, 20.0f);
up.Normalise();
m_pHook->GetRight() = CrossProduct(CVector(0.0f, 1.0f, 0.0f), up);
diff --git a/src/vehicles/Cranes.h b/src/vehicles/Cranes.h
index c0502638..6d877d82 100644
--- a/src/vehicles/Cranes.h
+++ b/src/vehicles/Cranes.h
@@ -72,7 +72,7 @@ public:
float GetHeightToDropoffHeight() { return m_fDropoffHeight + (m_bIsCrusher ? 7.0f : 2.0f); }
};
-static_assert(sizeof(CCrane) == 128, "CCrane: error");
+VALIDATE_SIZE(CCrane, 128);
class CCranes
{
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index 0073a5ad..e4cd5883 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -77,7 +77,7 @@ CHeli::CHeli(int32 id, uint8 CreatedBy)
m_fHeliDustZ[i] = -50.0f;
m_nPoliceShoutTimer = CTimer::GetTimeInMilliseconds();
- m_status = STATUS_HELI;
+ SetStatus(STATUS_HELI);
m_bTestRight = true;
m_fTargetOffset = 0.0f;
m_fSearchLightX = m_fSearchLightY = 0.0f;
@@ -144,11 +144,11 @@ CHeli::ProcessControl(void)
if(GetPosition().z > 31.55f)
break;
m_pathState = 7;
- GetPosition().z = 31.55f;
+ GetMatrix().GetPosition().z = 31.55f;
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
break;
case 7:
- GetPosition().z = 31.55f;
+ GetMatrix().GetPosition().z = 31.55f;
target = GetPosition();
break;
@@ -214,8 +214,8 @@ CHeli::ProcessControl(void)
vTargetDist = target - GetPosition();
m_fTargetZ = target.z;
if(m_pathState == 6){
- GetPosition().x = GetPosition().x*0.99f + target.x*0.01f;
- GetPosition().y = GetPosition().y*0.99f + target.y*0.01f;
+ GetMatrix().GetPosition().x = GetMatrix().GetPosition().x*0.99f + target.x*0.01f;
+ GetMatrix().GetPosition().y = GetMatrix().GetPosition().y*0.99f + target.y*0.01f;
}
}else{
vTargetDist = FindPlayerCoors() - GetPosition();
@@ -367,8 +367,8 @@ CHeli::ProcessControl(void)
m_vecMoveSpeed.x += speedDir.x*speedInc;
m_vecMoveSpeed.y += speedDir.y*speedInc;
}
- GetPosition().x += m_vecMoveSpeed.x*CTimer::GetTimeStep();
- GetPosition().y += m_vecMoveSpeed.y*CTimer::GetTimeStep();
+ GetMatrix().GetPosition().x += m_vecMoveSpeed.x*CTimer::GetTimeStep();
+ GetMatrix().GetPosition().y += m_vecMoveSpeed.y*CTimer::GetTimeStep();
// Find z target
if(m_heliStatus == HELI_STATUS_FLY_AWAY)
@@ -389,7 +389,7 @@ CHeli::ProcessControl(void)
m_vecMoveSpeed.z -= speedIncZ;
else
m_vecMoveSpeed.z += speedIncZ*1.5f;
- GetPosition().z += m_vecMoveSpeed.z*CTimer::GetTimeStep();
+ GetMatrix().GetPosition().z += m_vecMoveSpeed.z*CTimer::GetTimeStep();
// Find angular speed
float targetAngularSpeed;
@@ -810,7 +810,7 @@ GenerateHeli(bool catalina)
if(catalina)
heli->GetMatrix().SetRotateZOnly(DEGTORAD(270.0f)); // game actually uses 3.14 here
- heli->m_status = STATUS_ABANDONED;
+ heli->SetStatus(STATUS_ABANDONED);
int id = -1;
bool found = false;
diff --git a/src/vehicles/Heli.h b/src/vehicles/Heli.h
index 39e4cbcf..cf3f791f 100644
--- a/src/vehicles/Heli.h
+++ b/src/vehicles/Heli.h
@@ -95,4 +95,6 @@ public:
static void ActivateHeli(bool activate);
};
-static_assert(sizeof(CHeli) == 0x33C, "CHeli: error");
+
+VALIDATE_SIZE(CHeli, 0x33C);
+
diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp
index 273ac54a..71189d84 100644
--- a/src/vehicles/Plane.cpp
+++ b/src/vehicles/Plane.cpp
@@ -81,7 +81,7 @@ CPlane::CPlane(int32 id, uint8 CreatedBy)
m_bIsDrugRunCesna = false;
m_bIsDropOffCesna = false;
- m_status = STATUS_PLANE;
+ SetStatus(STATUS_PLANE);
bIsBIGBuilding = true;
m_level = LEVEL_NONE;
}
@@ -359,8 +359,8 @@ CPlane::ProcessControl(void)
CVector posFront2 = (1.0f - f)*pPathNodes[curPathNodeFront2].p + f*pPathNodes[nextPathNodeFront2].p;
// Now set matrix
- GetPosition() = (posRear + posFront)/2.0f;
- GetPosition().z += 4.3f;
+ GetMatrix().GetPosition() = (posRear + posFront) / 2.0f;
+ GetMatrix().GetPosition().z += 4.3f;
CVector fwd = posFront - posRear;
fwd.Normalise();
if(pitch != 0.0f){
@@ -375,9 +375,9 @@ CPlane::ProcessControl(void)
right.z += 3.0f*roll.z;
right.Normalise();
CVector up = CrossProduct(right, fwd);
- GetRight() = right;
- GetUp() = up;
- GetForward() = fwd;
+ GetMatrix().GetRight() = right;
+ GetMatrix().GetUp() = up;
+ GetMatrix().GetForward() = fwd;
// Set speed
m_vecMoveSpeed = fwd*PlanePathSpeed[m_nPlaneId]/60.0f;
@@ -511,8 +511,8 @@ CPlane::ProcessControl(void)
CVector posFront2 = (1.0f - f)*pathNodes[curPathNodeFront2].p + f*pathNodes[nextPathNodeFront2].p;
// Now set matrix
- GetPosition() = (posRear + posFront)/2.0f;
- GetPosition().z += 1.0f;
+ GetMatrix().GetPosition() = (posRear + posFront) / 2.0f;
+ GetMatrix().GetPosition().z += 1.0f;
CVector fwd = posFront - posRear;
fwd.Normalise();
CVector fwd2 = posFront2 - posRear;
@@ -522,9 +522,9 @@ CPlane::ProcessControl(void)
right.z += 3.0f*roll.z;
right.Normalise();
CVector up = CrossProduct(right, fwd);
- GetRight() = right;
- GetUp() = up;
- GetForward() = fwd;
+ GetMatrix().GetRight() = right;
+ GetMatrix().GetUp() = up;
+ GetMatrix().GetForward() = fwd;
// Set speed
m_vecMoveSpeed = fwd*planePathSpeed/60.0f;
@@ -754,7 +754,7 @@ CPlane::InitPlanes(void)
for(i = 0; i < 3; i++){
CPlane *plane = new CPlane(MI_AIRTRAIN, PERMANENT_VEHICLE);
plane->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
- plane->m_status = STATUS_ABANDONED;
+ plane->SetStatus(STATUS_ABANDONED);
plane->bIsLocked = true;
plane->m_nPlaneId = i;
plane->m_nCurPathNode = 0;
@@ -768,7 +768,7 @@ CPlane::InitPlanes(void)
for(i = 0; i < 3; i++){
CPlane *plane = new CPlane(MI_DEADDODO, PERMANENT_VEHICLE);
plane->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
- plane->m_status = STATUS_ABANDONED;
+ plane->SetStatus(STATUS_ABANDONED);
plane->bIsLocked = true;
plane->m_nPlaneId = i;
plane->m_nCurPathNode = 0;
@@ -926,7 +926,7 @@ CPlane::CreateIncomingCesna(void)
}
pDrugRunCesna = new CPlane(MI_DEADDODO, PERMANENT_VEHICLE);
pDrugRunCesna->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
- pDrugRunCesna->m_status = STATUS_ABANDONED;
+ pDrugRunCesna->SetStatus(STATUS_ABANDONED);
pDrugRunCesna->bIsLocked = true;
pDrugRunCesna->m_nPlaneId = 0;
pDrugRunCesna->m_nCurPathNode = 0;
@@ -948,7 +948,7 @@ CPlane::CreateDropOffCesna(void)
}
pDropOffCesna = new CPlane(MI_DEADDODO, PERMANENT_VEHICLE);
pDropOffCesna->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
- pDropOffCesna->m_status = STATUS_ABANDONED;
+ pDropOffCesna->SetStatus(STATUS_ABANDONED);
pDropOffCesna->bIsLocked = true;
pDropOffCesna->m_nPlaneId = 0;
pDropOffCesna->m_nCurPathNode = 0;
diff --git a/src/vehicles/Plane.h b/src/vehicles/Plane.h
index 79738858..7e822d64 100644
--- a/src/vehicles/Plane.h
+++ b/src/vehicles/Plane.h
@@ -63,7 +63,8 @@ public:
static bool HasCesnaBeenDestroyed(void);
static bool HasDropOffCesnaBeenShotDown(void);
};
-static_assert(sizeof(CPlane) == 0x29C, "CPlane: error");
+
+VALIDATE_SIZE(CPlane, 0x29C);
extern float LandingPoint;
extern float TakeOffPoint;
diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp
index 0d1ff9b0..7831a0c8 100644
--- a/src/vehicles/Train.cpp
+++ b/src/vehicles/Train.cpp
@@ -59,7 +59,7 @@ CTrain::CTrain(int32 id, uint8 CreatedBy)
m_nDoorState = TRAIN_DOOR_CLOSED;
bUsesCollision = true;
- m_status = STATUS_TRAIN_MOVING;
+ SetStatus(STATUS_TRAIN_MOVING);
}
void
@@ -161,7 +161,7 @@ CTrain::ProcessControl(void)
CVector posFront = (1.0f - f)*trackNodes[curTrackNodeFront].p + f*trackNodes[nextTrackNodeFront].p;
// Now set matrix
- GetPosition() = (posRear + posFront)/2.0f;
+ SetPosition((posRear + posFront)/2.0f);
CVector fwd = posFront - posRear;
fwd.Normalise();
CVector right = CrossProduct(fwd, CVector(0.0f, 0.0f, 1.0f));
@@ -177,11 +177,11 @@ CTrain::ProcessControl(void)
m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
if(engineTrackSpeed[m_nWagonGroup] > 0.001f){
- m_status = STATUS_TRAIN_MOVING;
+ SetStatus(STATUS_TRAIN_MOVING);
m_bTrainStopping = false;
m_bProcessDoor = true;
}else{
- m_status = STATUS_TRAIN_NOT_MOVING;
+ SetStatus(STATUS_TRAIN_NOT_MOVING);
m_bTrainStopping = true;
}
@@ -252,7 +252,7 @@ CTrain::ProcessControl(void)
}
// Hit stuff
- if(m_bIsFirstWagon && m_status == STATUS_TRAIN_MOVING){
+ if(m_bIsFirstWagon && GetStatus()== STATUS_TRAIN_MOVING){
CVector front = GetPosition() + GetForward()*GetColModel()->boundingBox.max.y + m_vecMoveSpeed*CTimer::GetTimeStep();
int x, xmin, xmax;
@@ -440,7 +440,7 @@ CTrain::InitTrains(void)
for(i = 0; i < 5; i++){
train = new CTrain(MI_TRAIN, PERMANENT_VEHICLE);
train->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
- train->m_status = STATUS_ABANDONED;
+ train->SetStatus(STATUS_ABANDONED);
train->bIsLocked = true;
train->m_fWagonPosition = wagonPositions[i];
train->m_bIsFirstWagon = firstWagon[i];
@@ -459,7 +459,7 @@ CTrain::InitTrains(void)
for(i = 0; i < 8; i++){
train = new CTrain(MI_TRAIN, PERMANENT_VEHICLE);
train->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
- train->m_status = STATUS_ABANDONED;
+ train->SetStatus(STATUS_ABANDONED);
train->bIsLocked = true;
train->m_fWagonPosition = wagonPositions_S[i];
train->m_bIsFirstWagon = firstWagon_S[i];
diff --git a/src/vehicles/Train.h b/src/vehicles/Train.h
index bf541250..6aa76fa8 100644
--- a/src/vehicles/Train.h
+++ b/src/vehicles/Train.h
@@ -91,4 +91,5 @@ public:
float *totalLength, float *totalDuration, CTrainInterpolationLine *interpLines, bool rightRail);
static void UpdateTrains(void);
};
-static_assert(sizeof(CTrain) == 0x2E4, "CTrain: error");
+
+VALIDATE_SIZE(CTrain, 0x2E4);
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index d0ccd31b..5dc7bc72 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -98,7 +98,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
bHasAlreadyBeenRecorded = false;
m_bSirenOrAlarm = 0;
m_nCarHornTimer = 0;
- field_22D = 0;
+ m_nCarHornPattern = 0;
m_nAlarmState = 0;
m_nDoorLock = CARLOCK_UNLOCKED;
m_nLastWeaponDamage = -1;
@@ -393,7 +393,7 @@ CVehicle::FlyingControl(eFlightModel flightModel)
m_vecMoveSpeed.x *= rmX;
m_vecMoveSpeed.y *= rmY;
m_vecMoveSpeed.z *= rmZ;
- if (m_status != STATUS_PLAYER && m_status != STATUS_PLAYER_REMOTE)
+ if (GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE)
return;
float fThrust;
if (bCheat5)
@@ -623,13 +623,13 @@ CVehicle::InflictDamage(CEntity* damagedBy, eWeaponType weaponType, float damage
}
if (m_fHealth > 0.0f) {
if (VehicleCreatedBy == RANDOM_VEHICLE && pDriver &&
- (m_status == STATUS_SIMPLE || m_status == STATUS_PHYSICS) &&
+ (GetStatus() == STATUS_SIMPLE || GetStatus() == STATUS_PHYSICS) &&
AutoPilot.m_nCarMission == MISSION_CRUISE) {
if (m_randomSeed < DAMAGE_FLEE_IN_CAR_PROBABILITY_VALUE) {
CCarCtrl::SwitchVehicleToRealPhysics(this);
AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * pHandling->Transmission.fUnkMaxVelocity;
- m_status = STATUS_PHYSICS;
+ SetStatus(STATUS_PHYSICS);
}
}
m_nLastWeaponDamage = weaponType;
@@ -639,11 +639,11 @@ CVehicle::InflictDamage(CEntity* damagedBy, eWeaponType weaponType, float damage
if (VehicleCreatedBy == RANDOM_VEHICLE &&
(m_fHealth < DAMAGE_HEALTH_TO_FLEE_ALWAYS ||
bFrightensDriver && m_randomSeed > DAMAGE_FLEE_ON_FOOT_PROBABILITY_VALUE)) {
- switch (m_status) {
+ switch (GetStatus()) {
case STATUS_SIMPLE:
case STATUS_PHYSICS:
if (pDriver) {
- m_status = STATUS_ABANDONED;
+ SetStatus(STATUS_ABANDONED);
pDriver->bFleeAfterExitingCar = true;
pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, this);
}
@@ -871,7 +871,7 @@ CVehicle::UsesSiren(uint32 id)
bool
CVehicle::IsVehicleNormal(void)
{
- if (!pDriver || m_nNumPassengers != 0 || m_status == STATUS_WRECKED)
+ if (!pDriver || m_nNumPassengers != 0 || GetStatus() == STATUS_WRECKED)
return false;
switch (GetModelIndex()){
case MI_FIRETRUCK:
@@ -1141,7 +1141,7 @@ CVehicle::AddPassenger(CPed *passenger, uint8 n)
void
CVehicle::RemoveDriver(void)
{
- m_status = STATUS_ABANDONED;
+ SetStatus(STATUS_ABANDONED);
pDriver = nil;
}
@@ -1222,3 +1222,128 @@ DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle)
CWorld::Remove(pVehicle);
delete pVehicle;
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CVehicle::Save(uint8*& buf)
+{
+ SkipSaveBuf(buf, 4);
+ WriteSaveBuf<float>(buf, GetRight().x);
+ WriteSaveBuf<float>(buf, GetRight().y);
+ WriteSaveBuf<float>(buf, GetRight().z);
+ SkipSaveBuf(buf, 4);
+ WriteSaveBuf<float>(buf, GetForward().x);
+ WriteSaveBuf<float>(buf, GetForward().y);
+ WriteSaveBuf<float>(buf, GetForward().z);
+ SkipSaveBuf(buf, 4);
+ WriteSaveBuf<float>(buf, GetUp().x);
+ WriteSaveBuf<float>(buf, GetUp().y);
+ WriteSaveBuf<float>(buf, GetUp().z);
+ SkipSaveBuf(buf, 4);
+ WriteSaveBuf<float>(buf, GetPosition().x);
+ WriteSaveBuf<float>(buf, GetPosition().y);
+ WriteSaveBuf<float>(buf, GetPosition().z);
+ SkipSaveBuf(buf, 16);
+ SaveEntityFlags(buf);
+ SkipSaveBuf(buf, 212);
+ AutoPilot.Save(buf);
+ WriteSaveBuf<int8>(buf, m_currentColour1);
+ WriteSaveBuf<int8>(buf, m_currentColour2);
+ SkipSaveBuf(buf, 2);
+ WriteSaveBuf<int16>(buf, m_nAlarmState);
+ SkipSaveBuf(buf, 43);
+ WriteSaveBuf<uint8>(buf, m_nNumMaxPassengers);
+ SkipSaveBuf(buf, 2);
+ WriteSaveBuf<float>(buf, field_1D0[0]);
+ WriteSaveBuf<float>(buf, field_1D0[1]);
+ WriteSaveBuf<float>(buf, field_1D0[2]);
+ WriteSaveBuf<float>(buf, field_1D0[3]);
+ SkipSaveBuf(buf, 8);
+ WriteSaveBuf<float>(buf, m_fSteerAngle);
+ WriteSaveBuf<float>(buf, m_fGasPedal);
+ WriteSaveBuf<float>(buf, m_fBrakePedal);
+ WriteSaveBuf<uint8>(buf, VehicleCreatedBy);
+ uint8 flags = 0;
+ if (bIsLawEnforcer) flags |= BIT(0);
+ if (bIsLocked) flags |= BIT(3);
+ if (bEngineOn) flags |= BIT(4);
+ if (bIsHandbrakeOn) flags |= BIT(5);
+ if (bLightsOn) flags |= BIT(6);
+ if (bFreebies) flags |= BIT(7);
+ WriteSaveBuf<uint8>(buf, flags);
+ SkipSaveBuf(buf, 10);
+ WriteSaveBuf<float>(buf, m_fHealth);
+ WriteSaveBuf<uint8>(buf, m_nCurrentGear);
+ SkipSaveBuf(buf, 3);
+ WriteSaveBuf<float>(buf, m_fChangeGearTime);
+ SkipSaveBuf(buf, 4);
+ WriteSaveBuf<uint32>(buf, m_nTimeOfDeath);
+ SkipSaveBuf(buf, 2);
+ WriteSaveBuf<int16>(buf, m_nBombTimer);
+ SkipSaveBuf(buf, 12);
+ WriteSaveBuf<int8>(buf, m_nDoorLock);
+ SkipSaveBuf(buf, 99);
+}
+
+void
+CVehicle::Load(uint8*& buf)
+{
+ CMatrix tmp;
+ SkipSaveBuf(buf, 4);
+ tmp.GetRight().x = ReadSaveBuf<float>(buf);
+ tmp.GetRight().y = ReadSaveBuf<float>(buf);
+ tmp.GetRight().z = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 4);
+ tmp.GetForward().x = ReadSaveBuf<float>(buf);
+ tmp.GetForward().y = ReadSaveBuf<float>(buf);
+ tmp.GetForward().z = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 4);
+ tmp.GetUp().x = ReadSaveBuf<float>(buf);
+ tmp.GetUp().y = ReadSaveBuf<float>(buf);
+ tmp.GetUp().z = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 4);
+ tmp.GetPosition().x = ReadSaveBuf<float>(buf);
+ tmp.GetPosition().y = ReadSaveBuf<float>(buf);
+ tmp.GetPosition().z = ReadSaveBuf<float>(buf);
+ m_matrix = tmp;
+ SkipSaveBuf(buf, 16);
+ LoadEntityFlags(buf);
+ SkipSaveBuf(buf, 212);
+ AutoPilot.Load(buf);
+ m_currentColour1 = ReadSaveBuf<int8>(buf);
+ m_currentColour2 = ReadSaveBuf<int8>(buf);
+ SkipSaveBuf(buf, 2);
+ m_nAlarmState = ReadSaveBuf<int16>(buf);
+ SkipSaveBuf(buf, 43);
+ m_nNumMaxPassengers = ReadSaveBuf<int8>(buf);
+ SkipSaveBuf(buf, 2);
+ field_1D0[0] = ReadSaveBuf<float>(buf);
+ field_1D0[1] = ReadSaveBuf<float>(buf);
+ field_1D0[2] = ReadSaveBuf<float>(buf);
+ field_1D0[3] = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 8);
+ m_fSteerAngle = ReadSaveBuf<float>(buf);
+ m_fGasPedal = ReadSaveBuf<float>(buf);
+ m_fBrakePedal = ReadSaveBuf<float>(buf);
+ VehicleCreatedBy = ReadSaveBuf<uint8>(buf);
+ uint8 flags = ReadSaveBuf<uint8>(buf);
+ bIsLawEnforcer = !!(flags & BIT(0));
+ bIsLocked = !!(flags & BIT(3));
+ bEngineOn = !!(flags & BIT(4));
+ bIsHandbrakeOn = !!(flags & BIT(5));
+ bLightsOn = !!(flags & BIT(6));
+ bFreebies = !!(flags & BIT(7));
+ SkipSaveBuf(buf, 10);
+ m_fHealth = ReadSaveBuf<float>(buf);
+ m_nCurrentGear = ReadSaveBuf<uint8>(buf);
+ SkipSaveBuf(buf, 3);
+ m_fChangeGearTime = ReadSaveBuf<float>(buf);
+ SkipSaveBuf(buf, 4);
+ m_nTimeOfDeath = ReadSaveBuf<uint32>(buf);
+ SkipSaveBuf(buf, 2);
+ m_nBombTimer = ReadSaveBuf<int16>(buf);
+ SkipSaveBuf(buf, 12);
+ m_nDoorLock = (eCarLock)ReadSaveBuf<int8>(buf);
+ SkipSaveBuf(buf, 99);
+}
+#endif
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index cb4ac2cf..f7205c7d 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -193,7 +193,7 @@ public:
uint8 m_bRainAudioCounter;
uint8 m_bRainSamplesCounter;
uint8 m_nCarHornTimer;
- int8 field_22D; // last horn?
+ uint8 m_nCarHornPattern; // last horn?
bool m_bSirenOrAlarm;
int8 m_comedyControlState;
CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car
@@ -231,6 +231,10 @@ public:
virtual bool IsRoomForPedToLeaveCar(uint32 component, CVector *forcedDoorPos) { return false;}
virtual float GetHeightAboveRoad(void);
virtual void PlayCarHorn(void) {}
+#ifdef COMPATIBLE_SAVES
+ virtual void Save(uint8*& buf);
+ virtual void Load(uint8*& buf);
+#endif
bool IsCar(void) { return m_vehType == VEHICLE_TYPE_CAR; }
bool IsBoat(void) { return m_vehType == VEHICLE_TYPE_BOAT; }
@@ -270,6 +274,7 @@ public:
void InflictDamage(CEntity *damagedBy, eWeaponType weaponType, float damage);
void DoFixedMachineGuns(void);
+
bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; }
CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); }
bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE; }
@@ -286,9 +291,6 @@ public:
static bool m_bDisableMouseSteering;
};
-static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error");
-static_assert(offsetof(CVehicle, m_pCurGroundEntity) == 0x1E0, "CVehicle: error");
-static_assert(offsetof(CVehicle, m_nAlarmState) == 0x1A0, "CVehicle: error");
-static_assert(offsetof(CVehicle, m_nLastWeaponDamage) == 0x228, "CVehicle: error");
+VALIDATE_SIZE(CVehicle, 0x288);
void DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle);
diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp
index 36c3cc78..92d98a50 100644
--- a/src/weapons/BulletInfo.cpp
+++ b/src/weapons/BulletInfo.cpp
@@ -3,7 +3,7 @@
#include "BulletInfo.h"
#include "AnimBlendAssociation.h"
-#include "AudioManager.h"
+#include "DMAudio.h"
#include "AudioScriptObject.h"
#ifdef FIX_BUGS
#include "Collision.h"
@@ -122,7 +122,7 @@ void CBulletInfo::Update(void)
}
if (pPed->GetPedState() == PED_DEAD) {
CAnimBlendAssociation* pAnim;
- if (RpAnimBlendClumpGetFirstAssociation(pPed->GetClump(), ASSOC_FLAG800))
+ if (RpAnimBlendClumpGetFirstAssociation(pPed->GetClump(), ASSOC_FRONTAL))
pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f);
else
pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f);
@@ -156,11 +156,11 @@ void CBulletInfo::Update(void)
if (pHitEntity->IsObject()) {
CObject* pObject = (CObject*)pHitEntity;
if (!pObject->bInfiniteMass) {
- if (pObject->bIsStatic && pObject->m_fUprootLimit <= 0.0f) {
+ if (pObject->IsStatic() && pObject->m_fUprootLimit <= 0.0f) {
pObject->bIsStatic = false;
pObject->AddToMovingList();
}
- if (!pObject->bIsStatic)
+ if (!pObject->IsStatic())
pObject->ApplyMoveForce(-BULLET_HIT_FORCE * point.normal);
}
}
@@ -171,7 +171,7 @@ void CBulletInfo::Update(void)
}
if (pBullet->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE && bAddSound) {
cAudioScriptObject* pAudio;
- switch (pHitEntity->m_type) {
+ switch (pHitEntity->GetType()) {
case ENTITY_TYPE_BUILDING:
pAudio = new cAudioScriptObject();
pAudio->Posn = pHitEntity->GetPosition();
diff --git a/src/weapons/ProjectileInfo.cpp b/src/weapons/ProjectileInfo.cpp
index c174305c..8297d953 100644
--- a/src/weapons/ProjectileInfo.cpp
+++ b/src/weapons/ProjectileInfo.cpp
@@ -193,7 +193,7 @@ CProjectileInfo::Update()
if (!gaProjectileInfo[i].m_bInUse) continue;
CPed *ped = (CPed*)gaProjectileInfo[i].m_pSource;
- if (ped != nil && ped->m_type == ENTITY_TYPE_PED && !ped->IsPointerValid())
+ if (ped != nil && ped->IsPed() && !ped->IsPointerValid())
gaProjectileInfo[i].m_pSource = nil;
if (ms_apProjectile[i] == nil) {
@@ -245,7 +245,7 @@ CProjectileInfo::IsProjectileInRange(float x1, float x2, float y1, float y2, flo
for (int i = 0; i < ARRAY_SIZE(ms_apProjectile); i++) {
if (gaProjectileInfo[i].m_bInUse) {
if (gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER || gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_MOLOTOV || gaProjectileInfo[i].m_eWeaponType == WEAPONTYPE_GRENADE) {
- CVector &pos = ms_apProjectile[i]->GetPosition();
+ const CVector &pos = ms_apProjectile[i]->GetPosition();
if (pos.x >= x1 && pos.x <= x2 && pos.y >= y1 && pos.y <= y2 && pos.z >= z1 && pos.z <= z2) {
result = true;
if (remove) {
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index a3d52f69..aef53094 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -973,7 +973,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
if ( victimPed->Dead() )
{
CAnimBlendAssociation *asoc;
- if ( RpAnimBlendClumpGetFirstAssociation(victimPed->GetClump(), ASSOC_FLAG800) )
+ if ( RpAnimBlendClumpGetFirstAssociation(victimPed->GetClump(), ASSOC_FRONTAL) )
asoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f);
else
asoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f);
@@ -990,7 +990,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
}
else
{
- switch ( victim->m_type )
+ switch ( victim->GetType() )
{
case ENTITY_TYPE_BUILDING:
{
@@ -1047,13 +1047,13 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
if ( !victimObject->bInfiniteMass )
{
- if ( victimObject->bIsStatic && victimObject->m_fUprootLimit <= 0.0f )
+ if ( victimObject->IsStatic() && victimObject->m_fUprootLimit <= 0.0f )
{
victimObject->bIsStatic = false;
victimObject->AddToMovingList();
}
- if ( !victimObject->bIsStatic )
+ if ( !victimObject->IsStatic())
{
CVector moveForce = point->normal*-4.0f;
victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);
@@ -1065,7 +1065,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
}
}
- switch ( victim->m_type )
+ switch ( victim->GetType() )
{
case ENTITY_TYPE_BUILDING:
{
@@ -1256,7 +1256,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
}
else
{
- switch ( victim->m_type )
+ switch ( victim->GetType() )
{
case ENTITY_TYPE_VEHICLE:
{
@@ -1296,13 +1296,13 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
if ( !victimObject->bInfiniteMass )
{
- if ( victimObject->bIsStatic && victimObject->m_fUprootLimit <= 0.0f )
+ if ( victimObject->IsStatic() && victimObject->m_fUprootLimit <= 0.0f )
{
victimObject->bIsStatic = false;
victimObject->AddToMovingList();
}
- if ( !victimObject->bIsStatic )
+ if ( !victimObject->IsStatic())
{
CVector moveForce = point.normal*-5.0f;
victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);
@@ -1315,7 +1315,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
}
}
- switch ( victim->m_type )
+ switch ( victim->GetType() )
{
case ENTITY_TYPE_BUILDING:
{
@@ -1724,7 +1724,7 @@ CWeapon::FireInstantHitFromCar(CAutomobile *shooter, bool left)
else
CGlass::WasGlassHitByBullet(victim, point.point);
- switch ( victim->m_type )
+ switch ( victim->GetType() )
{
case ENTITY_TYPE_BUILDING:
{
@@ -1796,10 +1796,10 @@ CWeapon::DoDoomAiming(CEntity *shooter, CVector *source, CVector *target)
if ( (CEntity*)shooterPed != victim && shooterPed->CanSeeEntity(victim, DEGTORAD(22.5f)) )
{
- if ( !(victim->m_status == STATUS_TRAIN_MOVING
- || victim->m_status == STATUS_TRAIN_NOT_MOVING
- || victim->m_status == STATUS_HELI
- || victim->m_status == STATUS_PLANE) )
+ if ( !(victim->GetStatus() == STATUS_TRAIN_MOVING
+ || victim->GetStatus() == STATUS_TRAIN_NOT_MOVING
+ || victim->GetStatus() == STATUS_HELI
+ || victim->GetStatus() == STATUS_PLANE) )
{
float distToVictim = (shooterPed->GetPosition()-victim->GetPosition()).Magnitude2D();
float distToVictimZ = Abs(shooterPed->GetPosition().z-victim->GetPosition().z);
@@ -1866,10 +1866,10 @@ CWeapon::DoTankDoomAiming(CEntity *shooter, CEntity *driver, CVector *source, CV
if ( shooter != victim && driver != victim )
{
- if ( !(victim->m_status == STATUS_TRAIN_MOVING
- || victim->m_status == STATUS_TRAIN_NOT_MOVING
- || victim->m_status == STATUS_HELI
- || victim->m_status == STATUS_PLANE) )
+ if ( !(victim->GetStatus() == STATUS_TRAIN_MOVING
+ || victim->GetStatus() == STATUS_TRAIN_NOT_MOVING
+ || victim->GetStatus() == STATUS_HELI
+ || victim->GetStatus() == STATUS_PLANE) )
{
if ( !(victim->IsVehicle() && victim->bRenderScorched) )
{
@@ -2086,7 +2086,7 @@ FireOneInstantHitRound(CVector *source, CVector *target, int32 damage)
((CVehicle *)victim)->InflictDamage(nil, WEAPONTYPE_UZI, damage);
//BUG ? no CGlass::WasGlassHitByBullet
- switch ( victim->m_type )
+ switch ( victim->GetType() )
{
case ENTITY_TYPE_BUILDING:
{
@@ -2232,7 +2232,7 @@ CWeapon::BlowUpExplosiveThings(CEntity *thing)
object->m_vecMoveSpeed.x += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
object->m_vecMoveSpeed.y += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
- if ( object->bIsStatic )
+ if ( object->IsStatic())
{
object->bIsStatic = false;
object->AddToMovingList();
@@ -2257,4 +2257,30 @@ bool
CWeapon::ProcessLineOfSight(CVector const &point1, CVector const &point2, CColPoint &point, CEntity *&entity, eWeaponType type, CEntity *shooter, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects)
{
return CWorld::ProcessLineOfSight(point1, point2, point, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, ignoreSomeObjects);
-} \ No newline at end of file
+}
+
+#ifdef COMPATIBLE_SAVES
+void
+CWeapon::Save(uint8*& buf)
+{
+ WriteSaveBuf<uint32>(buf, m_eWeaponType);
+ WriteSaveBuf<uint32>(buf, m_eWeaponState);
+ WriteSaveBuf<uint32>(buf, m_nAmmoInClip);
+ WriteSaveBuf<uint32>(buf, m_nAmmoTotal);
+ WriteSaveBuf<uint32>(buf, m_nTimer);
+ WriteSaveBuf<bool>(buf, m_bAddRotOffset);
+ SkipSaveBuf(buf, 3);
+}
+
+void
+CWeapon::Load(uint8*& buf)
+{
+ m_eWeaponType = (eWeaponType)ReadSaveBuf<uint32>(buf);
+ m_eWeaponState = (eWeaponState)ReadSaveBuf<uint32>(buf);
+ m_nAmmoInClip = ReadSaveBuf<uint32>(buf);
+ m_nAmmoTotal = ReadSaveBuf<uint32>(buf);
+ m_nTimer = ReadSaveBuf<uint32>(buf);
+ m_bAddRotOffset = ReadSaveBuf<bool>(buf);
+ SkipSaveBuf(buf, 3);
+}
+#endif
diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h
index 2c3a9657..1b2c0320 100644
--- a/src/weapons/Weapon.h
+++ b/src/weapons/Weapon.h
@@ -67,6 +67,11 @@ public:
bool HasWeaponAmmoToBeUsed(void);
static bool ProcessLineOfSight(CVector const &point1, CVector const &point2, CColPoint &point, CEntity *&entity, eWeaponType type, CEntity *shooter, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects);
+
+#ifdef COMPATIBLE_SAVES
+ void Save(uint8*& buf);
+ void Load(uint8*& buf);
+#endif
};
VALIDATE_SIZE(CWeapon, 0x18);
diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h
index 3bafd324..b5882082 100644
--- a/src/weapons/WeaponInfo.h
+++ b/src/weapons/WeaponInfo.h
@@ -46,4 +46,4 @@ public:
static void Shutdown(void);
};
-static_assert(sizeof(CWeaponInfo) == 0x54, "CWeaponInfo: error"); \ No newline at end of file
+VALIDATE_SIZE(CWeaponInfo, 0x54); \ No newline at end of file