summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio/AudioCollision.cpp19
-rw-r--r--src/audio/AudioManager.cpp18
-rw-r--r--src/audio/AudioManager.h14
-rw-r--r--src/audio/DMAudio.cpp12
-rw-r--r--src/audio/DMAudio.h4
-rw-r--r--src/audio/PolRadio.cpp4
-rw-r--r--src/core/FileLoader.cpp6
-rw-r--r--src/core/Radar.cpp18
-rw-r--r--src/core/config.h2
-rw-r--r--src/modelinfo/MloModelInfo.h2
-rw-r--r--src/modelinfo/XtraCompsModelInfo.h3
-rw-r--r--src/peds/Ped.cpp15
-rw-r--r--src/peds/PedIK.h2
-rw-r--r--src/peds/PlayerPed.cpp11
-rw-r--r--src/renderer/Renderer.cpp5
-rw-r--r--src/rw/VisibilityPlugins.cpp54
-rw-r--r--src/rw/VisibilityPlugins.h3
-rw-r--r--src/weapons/Weapon.cpp10
18 files changed, 155 insertions, 47 deletions
diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp
index cfd13fb6..bc470c49 100644
--- a/src/audio/AudioCollision.cpp
+++ b/src/audio/AudioCollision.cpp
@@ -353,33 +353,34 @@ cAudioManager::GetCollisionOneShotRatio(uint32 a, float b)
case SURFACE_STEEP_CLIFF:
case SURFACE_TRANSPARENT_STONE: return GetCollisionRatio(b, 10.f, 60.f, 50.f);
case SURFACE_GRASS:
- case SURFACE_CARDBOARDBOX: return GetCollisionRatio(b, 0.f, 2.f, 2.f);
- case SURFACE_GRAVEL: return GetCollisionRatio(b, 0.f, 2.f, 2.f);
+ case SURFACE_CARDBOARDBOX:
+ case SURFACE_GRAVEL:
case SURFACE_MUD_DRY: return GetCollisionRatio(b, 0.f, 2.f, 2.f);
case SURFACE_CAR: return GetCollisionRatio(b, 6.f, 50.f, 44.f);
- case SURFACE_GLASS: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f);
+ case SURFACE_GLASS:
+ case SURFACE_METAL_CHAIN_FENCE: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f);
case SURFACE_TRANSPARENT_CLOTH:
case SURFACE_THICK_METAL_PLATE: return GetCollisionRatio(b, 30.f, 130.f, 100.f);
case SURFACE_GARAGE_DOOR: return GetCollisionRatio(b, 20.f, 100.f, 80.f);
case SURFACE_CAR_PANEL: return GetCollisionRatio(b, 0.f, 4.f, 4.f);
case SURFACE_SCAFFOLD_POLE:
- case SURFACE_METAL_GATE: return GetCollisionRatio(b, 1.f, 10.f, 9.f);
+ case SURFACE_METAL_GATE:
case SURFACE_LAMP_POST: return GetCollisionRatio(b, 1.f, 10.f, 9.f);
case SURFACE_FIRE_HYDRANT: return GetCollisionRatio(b, 1.f, 15.f, 14.f);
case SURFACE_GIRDER: return GetCollisionRatio(b, 8.f, 50.f, 42.f);
- case SURFACE_METAL_CHAIN_FENCE: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f);
case SURFACE_PED: return GetCollisionRatio(b, 0.f, 20.f, 20.f);
- case SURFACE_SAND: return GetCollisionRatio(b, 0.f, 10.f, 10.f);
- case SURFACE_WATER: return GetCollisionRatio(b, 0.f, 10.f, 10.f);
+ case SURFACE_SAND:
+ case SURFACE_WATER:
+ case SURFACE_RUBBER:
+ case SURFACE_WHEELBASE: return GetCollisionRatio(b, 0.f, 10.f, 10.f);
case SURFACE_WOOD_CRATES: return GetCollisionRatio(b, 1.f, 4.f, 3.f);
case SURFACE_WOOD_BENCH: return GetCollisionRatio(b, 0.1f, 5.f, 4.9f);
case SURFACE_WOOD_SOLID: return GetCollisionRatio(b, 0.1f, 40.f, 39.9f);
- case SURFACE_RUBBER:
- case SURFACE_WHEELBASE: return GetCollisionRatio(b, 0.f, 10.f, 10.f);
case SURFACE_PLASTIC: return GetCollisionRatio(b, 0.1f, 4.f, 3.9f);
case SURFACE_HEDGE: return GetCollisionRatio(b, 0.f, 0.5f, 0.5f);
case SURFACE_CONTAINER: return GetCollisionRatio(b, 4.f, 40.f, 36.f);
case SURFACE_NEWS_VENDOR: return GetCollisionRatio(b, 0.f, 5.f, 5.f);
+ default: break;
}
return 0.f;
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index c3565828..22415e76 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -160,6 +160,14 @@ cAudioManager::DestroyEntity(int32 id)
}
}
+bool8
+cAudioManager::GetEntityStatus(int32 id)
+{
+ if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed)
+ return m_asAudioEntities[id].m_bStatus;
+ return FALSE;
+}
+
void
cAudioManager::SetEntityStatus(int32 id, bool8 status)
{
@@ -167,6 +175,14 @@ cAudioManager::SetEntityStatus(int32 id, bool8 status)
m_asAudioEntities[id].m_bStatus = status;
}
+void *
+cAudioManager::GetEntityPointer(int32 id)
+{
+ if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed)
+ return m_asAudioEntities[id].m_pEntity;
+ return NULL;
+}
+
void
cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
{
@@ -512,7 +528,7 @@ cAudioManager::ComputePan(float dist, CVector *vec)
return Min(107, PanTable[index] + 63);
}
-int32
+uint32
cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier)
{
uint32 newFreq = oldFreq;
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 7c591a1e..187a71a8 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -48,7 +48,7 @@ public:
eAudioType m_nType;
void *m_pEntity;
bool8 m_bIsUsed;
- uint8 m_bStatus;
+ bool8 m_bStatus;
int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS];
float m_afVolume[NUM_AUDIOENTITY_EVENTS];
uint8 m_AudioEvents;
@@ -237,7 +237,9 @@ public:
void Service();
int32 CreateEntity(eAudioType type, void *entity);
void DestroyEntity(int32 id);
+ bool8 GetEntityStatus(int32 id);
void SetEntityStatus(int32 id, bool8 status);
+ void *GetEntityPointer(int32 id);
void PlayOneShot(int32 index, uint16 sound, float vol);
void SetEffectsMasterVolume(uint8 volume);
void SetMusicMasterVolume(uint8 volume);
@@ -267,7 +269,7 @@ public:
uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance);
void TranslateEntity(Const CVector *v1, CVector *v2);
int32 ComputePan(float, CVector *);
- int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier); // inlined on PS2
+ uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier); // inlined on PS2
int32 RandomDisplacement(uint32 seed);
void InterrogateAudioEntities(); // inlined on PS2
void AddSampleToRequestedQueue();
@@ -300,14 +302,14 @@ public:
void ProcessSpecial();
void ProcessEntity(int32 sound);
void ProcessPhysical(int32 id);
+
+ // vehicles
void ProcessVehicle(CVehicle *vehicle);
void ProcessRainOnVehicle(cVehicleParams &params);
bool8 ProcessReverseGear(cVehicleParams &params);
void ProcessModelCarEngine(cVehicleParams &params);
bool8 ProcessVehicleRoadNoise(cVehicleParams &params);
bool8 ProcessWetRoadNoise(cVehicleParams &params);
-
- // vehicles
void ProcessVehicleEngine(cVehicleParams &params);
void UpdateGasPedalAudio(CAutomobile *automobile); // inlined on PS2
void PlayerJustGotInCar();
@@ -317,7 +319,7 @@ public:
void ProcessPlayersVehicleEngine(cVehicleParams &params, CAutomobile *automobile);
bool8 ProcessVehicleSkidding(cVehicleParams &params);
float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange);
- float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); // was in .h on PS2
+ float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); // inlined on PS2
void ProcessVehicleHorn(cVehicleParams &params);
bool8 UsesSiren(uint32 model); // inlined on PS2
bool8 UsesSirenSwitching(uint32 model); // inlined on PS2
@@ -485,7 +487,7 @@ public:
void InitialisePoliceRadioZones();
void InitialisePoliceRadio();
void ResetPoliceRadio();
- void SetMissionScriptPoliceAudio(int32 sfx);
+ void SetMissionScriptPoliceAudio(uint32 sfx);
int8 GetMissionScriptPoliceAudioPlayingStatus();
void DoPoliceRadioCrackle();
void ServicePoliceRadio();
diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp
index eea91bd1..688da201 100644
--- a/src/audio/DMAudio.cpp
+++ b/src/audio/DMAudio.cpp
@@ -38,6 +38,12 @@ cDMAudio::DestroyEntity(int32 audioEntity)
AudioManager.DestroyEntity(audioEntity);
}
+bool8
+cDMAudio::GetEntityStatus(int32 audioEntity)
+{
+ return AudioManager.GetEntityStatus(audioEntity);
+}
+
void
cDMAudio::SetEntityStatus(int32 audioEntity, bool8 status)
{
@@ -171,6 +177,12 @@ cDMAudio::IsAudioInitialised(void)
}
void
+cDMAudio::ResetPoliceRadio()
+{
+ AudioManager.ResetPoliceRadio();
+}
+
+void
cDMAudio::ReportCrime(eCrimeType crime, const CVector &pos)
{
AudioManager.ReportCrime(crime, pos);
diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h
index 19689fab..9f427272 100644
--- a/src/audio/DMAudio.h
+++ b/src/audio/DMAudio.h
@@ -22,6 +22,7 @@ public:
int32 CreateEntity(eAudioType type, void *UID);
void DestroyEntity(int32 audioEntity);
+ bool8 GetEntityStatus(int32 audioEntity);
void SetEntityStatus(int32 audioEntity, bool8 status);
void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume);
void DestroyAllGameCreatedEntities(void);
@@ -51,7 +52,8 @@ public:
char GetCDAudioDriveLetter(void);
bool8 IsAudioInitialised(void);
-
+
+ void ResetPoliceRadio();
void ReportCrime(eCrimeType crime, CVector const &pos);
int32 CreateLoopingScriptObject(cAudioScriptObject *scriptObject);
diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp
index 9a98de35..d6079191 100644
--- a/src/audio/PolRadio.cpp
+++ b/src/audio/PolRadio.cpp
@@ -25,7 +25,7 @@ tPoliceRadioZone ZoneSfx[NUMAUDIOZONES];
char SubZo2Label[8];
char SubZo3Label[8];
-int32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES;
+uint32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES;
int8 g_nMissionAudioPlayingStatus = 2;
uint8 gSpecialSuspectLastSeenReport;
uint32 gMinTimeToNextReport[NUM_CRIME_TYPES];
@@ -106,7 +106,7 @@ cAudioManager::ResetPoliceRadio()
}
void
-cAudioManager::SetMissionScriptPoliceAudio(int32 sfx)
+cAudioManager::SetMissionScriptPoliceAudio(uint32 sfx)
{
if (!m_bIsInitialised) return;
if (g_nMissionAudioPlayingStatus != 1) {
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index cc2b402b..afa2a66f 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -1135,12 +1135,12 @@ CFileLoader::LoadMLO(const char *line)
char smth[8];
char name[24];
int modelIndex;
- float someFloat;
+ float drawDist;
- sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &someFloat);
+ sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &drawDist);
CMloModelInfo *minfo = CModelInfo::AddMloModel(modelIndex);
minfo->SetModelName(name);
- minfo->field_34 = someFloat;
+ minfo->drawDist = drawDist;
int instId = CModelInfo::GetMloInstanceStore().allocPtr;
minfo->firstInstance = instId;
minfo->lastInstance = instId;
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 77d6cc7f..e0203355 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -485,7 +485,11 @@ void CRadar::Draw3dMarkers()
void CRadar::DrawBlips()
{
- if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
+ if ((!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud)
+#ifdef MENU_MAP
+ || CMenuManager::bMenuMapActive
+#endif
+ ) {
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
@@ -1216,7 +1220,11 @@ void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) {
void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha)
{
- if (!CHud::m_Wants_To_Draw_Hud || TheCamera.m_WideScreenOn)
+ if ((TheCamera.m_WideScreenOn || !CHud::m_Wants_To_Draw_Hud)
+#ifdef MENU_MAP
+ && !CMenuManager::bMenuMapActive
+#endif
+ )
return;
CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size + 1.0f), y - SCREEN_SCALE_Y(size + 1.0f), SCREEN_SCALE_X(size + 1.0f) + x, SCREEN_SCALE_Y(size + 1.0f) + y), CRGBA(0, 0, 0, alpha));
@@ -1225,7 +1233,11 @@ void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 gree
void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha, uint8 mode)
{
- if (!CHud::m_Wants_To_Draw_Hud || TheCamera.m_WideScreenOn)
+ if ((TheCamera.m_WideScreenOn || !CHud::m_Wants_To_Draw_Hud)
+#ifdef MENU_MAP
+ && !CMenuManager::bMenuMapActive
+#endif
+ )
return;
switch (mode)
diff --git a/src/core/config.h b/src/core/config.h
index 17f0e44c..21a8b738 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -412,7 +412,7 @@ enum Config {
// #define VC_PED_PORTS // various ports from VC's CPed, mostly subtle
// #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward
#define CANCELLABLE_CAR_ENTER
-//#define PEDS_REPORT_CRIMES_ON_PHONE, requires COMPATIBLE_SAVES
+//#define PEDS_REPORT_CRIMES_ON_PHONE // requires COMPATIBLE_SAVES
// Camera
//#define PS2_CAM_TRANSITION // old way of transitioning between cam modes
diff --git a/src/modelinfo/MloModelInfo.h b/src/modelinfo/MloModelInfo.h
index d4344706..b1ae3298 100644
--- a/src/modelinfo/MloModelInfo.h
+++ b/src/modelinfo/MloModelInfo.h
@@ -5,7 +5,7 @@
class CMloModelInfo : public CClumpModelInfo
{
public:
- float field_34; // draw distance?
+ float drawDist;
int firstInstance;
int lastInstance;
public:
diff --git a/src/modelinfo/XtraCompsModelInfo.h b/src/modelinfo/XtraCompsModelInfo.h
index 9832399c..ab308a8a 100644
--- a/src/modelinfo/XtraCompsModelInfo.h
+++ b/src/modelinfo/XtraCompsModelInfo.h
@@ -7,6 +7,7 @@ class CXtraCompsModelInfo : public CClumpModelInfo
int field_34;
public:
CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; }
- void SetClump(RpClump*) {};
void Shutdown(void) {};
+ RwObject *CreateInstance(void) { return nil; }
+ void SetClump(RpClump*) {};
}; \ No newline at end of file
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 8d0fbbe8..3ccae5d0 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -393,8 +393,20 @@ CPed::BuildPedLists(void)
if (ped != this && !ped->bInVehicle) {
float dist = (ped->GetPosition() - GetPosition()).Magnitude2D();
if (nThreatReactionRangeMultiplier * 30.0f > dist) {
+#ifdef FIX_BUGS
+ // If the gap ped list is full, sort it and truncate it
+ // before pushing more unsorted peds
+ if( gnNumTempPedList == ARRAY_SIZE(gapTempPedList) - 1 )
+ {
+ gapTempPedList[gnNumTempPedList] = nil;
+ SortPeds(gapTempPedList, 0, gnNumTempPedList - 1);
+ gnNumTempPedList = ARRAY_SIZE(m_nearPeds);
+ }
+#endif
+
gapTempPedList[gnNumTempPedList] = ped;
gnNumTempPedList++;
+ // NOTE: We cannot absolutely fill the gap list, as the list is null-terminated before being passed to SortPeds
assert(gnNumTempPedList < ARRAY_SIZE(gapTempPedList));
}
}
@@ -1348,6 +1360,9 @@ CPed::CalculateNewVelocity(void)
limitedRotDest -= 2 * PI;
}
+#ifdef FREE_CAM
+ if (!TheCamera.Cams[0].Using3rdPersonMouseCam())
+#endif
if (IsPlayer() && m_nPedState == PED_ATTACK)
headAmount /= 4.0f;
diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h
index 9077fbea..1543fa34 100644
--- a/src/peds/PedIK.h
+++ b/src/peds/PedIK.h
@@ -29,7 +29,7 @@ class CPedIK
{
public:
enum {
- GUN_POINTED_SUCCESSFULLY = 1, // set but unused
+ GUN_POINTED_SUCCESSFULLY = 1,
LOOKAROUND_HEAD_ONLY = 2,
AIMS_WITH_ARM = 4,
};
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 6d6fc714..416fb949 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -503,6 +503,10 @@ CPlayerPed::DoWeaponSmoothSpray(void)
{
if (m_nPedState == PED_ATTACK && !m_pPointGunAt) {
eWeaponType weapon = GetWeapon()->m_eWeaponType;
+#ifdef FREE_CAM
+ if(TheCamera.Cams[0].Using3rdPersonMouseCam() && (weapon == WEAPONTYPE_COLT45 || weapon == WEAPONTYPE_UZI))
+ return false;
+#endif
if (weapon == WEAPONTYPE_FLAMETHROWER || weapon == WEAPONTYPE_COLT45 || weapon == WEAPONTYPE_UZI || weapon == WEAPONTYPE_SHOTGUN ||
weapon == WEAPONTYPE_AK47 || weapon == WEAPONTYPE_M16 || weapon == WEAPONTYPE_HELICANNON)
return true;
@@ -1183,6 +1187,13 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
padMoveInGameUnit = CVector2D(leftRight, upDown).Magnitude() / PAD_MOVE_TO_GAME_WORLD_MOVE;
}
+#ifdef FREE_CAM
+ if(TheCamera.Cams[0].Using3rdPersonMouseCam() && doSmoothSpray) {
+ padMoveInGameUnit = 0.0f;
+ smoothSprayWithoutMove = false;
+ }
+#endif
+
if (padMoveInGameUnit > 0.0f || smoothSprayWithoutMove) {
float padHeading = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown);
float neededTurn = CGeneral::LimitRadianAngle(padHeading - camOrientation);
diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp
index 1c0bd445..25effc81 100644
--- a/src/renderer/Renderer.cpp
+++ b/src/renderer/Renderer.cpp
@@ -154,11 +154,14 @@ CRenderer::PreRender(void)
void
CRenderer::RenderOneRoad(CEntity *e)
{
+#ifndef MASTER
if(gbDontRenderBuildings)
return;
if(gbShowCollisionPolys)
CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
- else{
+ else
+#endif
+ {
#ifdef EXTENDED_PIPELINES
CustomPipes::AttachGlossPipe(e->GetAtomic());
#endif
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 7ff5c243..e6d4641d 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -155,7 +155,7 @@ CVisibilityPlugins::Initialise(void)
m_alphaList.head.item.sort = 0.0f;
m_alphaList.tail.item.sort = 100000000.0f;
#ifdef ASPECT_RATIO_SCALE
- // default 150 if not enough for bigger FOVs
+ // default 150 is not enough for bigger FOVs
m_alphaEntityList.Init(NUMALPHAENTITYLIST * 3);
#else
m_alphaEntityList.Init(NUMALPHAENTITYLIST);
@@ -658,8 +658,7 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic)
return atomic;
if(flags & ATOMIC_FLAG_DRAWLAST){
- // sort before clump
- if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f))
+ if(!InsertAtomicIntoSortedList(atomic, distsq))
RENDERCALLBACK(atomic);
}else{
if(!InsertAtomicIntoSortedList(atomic, distsq + dot))
@@ -792,16 +791,6 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump)
}
bool
-CVisibilityPlugins::MloVisibilityCB(RpClump *clump)
-{
- RwFrame *frame = RpClumpGetFrame(clump);
- CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame);
- if (sq(modelInfo->field_34) < GetDistanceSquaredFromCamera(frame))
- return false;
- return CVisibilityPlugins::FrustumSphereCB(clump);
-}
-
-bool
CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
{
RwSphere sphere;
@@ -817,11 +806,22 @@ CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
}
bool
+CVisibilityPlugins::MloVisibilityCB(RpClump *clump)
+{
+ RwFrame *frame = RpClumpGetFrame(clump);
+ CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame);
+ if (SQR(modelInfo->drawDist) < GetDistanceSquaredFromCamera(frame))
+ return false;
+ return CVisibilityPlugins::FrustumSphereCB(clump);
+}
+
+bool
CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump)
{
- if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist)
- return FrustumSphereCB(clump);
- return false;
+ RwFrame *frame = RpClumpGetFrame(clump);
+ if (ms_vehicleLod1Dist < GetDistanceSquaredFromCamera(frame))
+ return false;
+ return FrustumSphereCB(clump);
}
bool
@@ -927,6 +927,12 @@ CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f)
ATOMICEXT(atomic)->flags &= ~f;
}
+void
+CVisibilityPlugins::SetAtomicId(RpAtomic *atomic, int id)
+{
+ ATOMICEXT(atomic)->flags = id;
+}
+
int
CVisibilityPlugins::GetAtomicId(RpAtomic *atomic)
{
@@ -1012,7 +1018,9 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo
// Unused
switch (modelInfo->GetModelType()) {
- // ignore MLO
+ case MITYPE_MLO:
+ CLUMPEXT(clump)->visibilityCB = MloVisibilityCB;
+ break;
case MITYPE_VEHICLE:
vmi = (CVehicleModelInfo*)modelInfo;
if(vmi->m_vehicleType == VEHICLE_TYPE_TRAIN ||
@@ -1026,6 +1034,12 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo
}
}
+CClumpModelInfo*
+CVisibilityPlugins::GetClumpModelInfo(RpClump *clump)
+{
+ return (CClumpModelInfo*)GetFrameHierarchyId(RpClumpGetFrame(clump));
+}
+
void
CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha)
{
@@ -1037,3 +1051,9 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump)
{
return CLUMPEXT(clump)->alpha;
}
+
+bool
+CVisibilityPlugins::IsClumpVisible(RpClump *clump)
+{
+ return CLUMPEXT(clump)->visibilityCB(clump);
+}
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index 5fb87765..f97fd589 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -94,6 +94,7 @@ public:
static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic);
static void SetAtomicFlag(RpAtomic*, int);
static void ClearAtomicFlag(RpAtomic*, int);
+ static void SetAtomicId(RpAtomic *atomic, int);
static int GetAtomicId(RpAtomic *atomic);
static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender);
@@ -123,8 +124,10 @@ public:
int alpha;
};
static void SetClumpModelInfo(RpClump*, CClumpModelInfo*);
+ static CClumpModelInfo *GetClumpModelInfo(RpClump*);
static void SetClumpAlpha(RpClump*, int);
static int GetClumpAlpha(RpClump*);
+ static bool IsClumpVisible(RpClump*);
static void *ClumpConstructor(void *object, int32 offset, int32 len);
static void *ClumpDestructor(void *object, int32 offset, int32 len);
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index 6f0e9094..6eab1a65 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -592,6 +592,16 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource)
{
CVector src, trgt;
TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, src, trgt);
+#ifdef FREE_CAM
+ CPed *shooterPed = (CPed *)shooter;
+ if((shooterPed->m_pedIK.m_flags & CPedIK::GUN_POINTED_SUCCESSFULLY) == 0) {
+ trgt.x = info->m_fRange;
+ trgt.y = 0.0f;
+ trgt.z = 0.0f;
+
+ shooterPed->TransformToNode(trgt, PED_HANDR);
+ }
+#endif
#ifdef FIX_BUGS
// fix muzzleflash rotation