summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Cam.cpp18
-rw-r--r--src/core/Camera.cpp10
-rw-r--r--src/core/FileLoader.cpp2
-rw-r--r--src/core/Frontend.cpp28
-rw-r--r--src/core/Frontend_PS2.cpp4
-rw-r--r--src/core/General.h2
-rw-r--r--src/core/PlayerInfo.cpp2
-rw-r--r--src/core/Pools.cpp18
-rw-r--r--src/core/Radar.cpp31
-rw-r--r--src/core/Ropes.cpp2
-rw-r--r--src/core/World.cpp4
-rw-r--r--src/core/Zones.cpp75
-rw-r--r--src/core/Zones.h4
-rw-r--r--src/core/common.h213
-rw-r--r--src/core/config.h1
15 files changed, 112 insertions, 302 deletions
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 56409af4..3204613d 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -1187,7 +1187,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
float ReqSpeed = DeltaBeta * SpeedMultiplier;
// this is also added
- ReqSpeed = clamp(ReqSpeed, -SpeedLimit, SpeedLimit);
+ ReqSpeed = Clamp(ReqSpeed, -SpeedLimit, SpeedLimit);
// Add or subtract absolute depending on sign, genius!
if(ReqSpeed - BetaSpeed > 0.0f)
@@ -1682,7 +1682,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
Test.z = TargetCoors.z + 0.2f + Length*Sin(CarAlpha+AlphaOffset) + m_fCloseInCarHeightOffset;
if(CWorld::ProcessVerticalLine(Test, CamTargetEntity->GetPosition().z, point, entity, true, false, false, false, false, false, nil)){
float sin = (point.point.z - TargetCoors.z - 0.2f - m_fCloseInCarHeightOffset)/Length;
- CarAlpha = Asin(clamp(sin, -1.0f, 1.0f)) - AlphaOffset;
+ CarAlpha = Asin(Clamp(sin, -1.0f, 1.0f)) - AlphaOffset;
if(CarAlpha < 0.0f)
AlphaOffset += CarAlpha;
}
@@ -1832,7 +1832,7 @@ CCam::Process_Cam_On_A_String(const CVector &CameraTarget, float TargetOrientati
if(DeltaBeta > PI) DeltaBeta -= TWOPI;
else if(DeltaBeta < -PI) DeltaBeta += TWOPI;
float dist = (TargetCoors - Source).Magnitude();
- dist = FIRETRUCK_TRACKING_MULT*dist*clamp(DeltaBeta, -0.8f, 0.8f);
+ dist = FIRETRUCK_TRACKING_MULT*dist*Clamp(DeltaBeta, -0.8f, 0.8f);
Source += dist*CrossProduct(Front, CVector(0.0f, 0.0f, 1.0f));
}
@@ -2805,7 +2805,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float,
if(BetaOffset > PI) BetaOffset -= TWOPI;
else if(BetaOffset < PI) BetaOffset += TWOPI;
- BetaOffset = clamp(BetaOffset, -pedTarget->m_attachRotStep, pedTarget->m_attachRotStep);
+ BetaOffset = Clamp(BetaOffset, -pedTarget->m_attachRotStep, pedTarget->m_attachRotStep);
Beta = NewBeta + BetaOffset;
}
@@ -3275,7 +3275,7 @@ CCam::Process_BehindBoat(const CVector &CameraTarget, float TargetOrientation, f
// useless call
//CWaterLevel::GetWaterLevelNoWaves(TargetCoors.x, TargetCoors.y, TargetCoors.z, &Water);
Water = (WaterLevel + WATER_Z_ADDITION_MIN - WaterLevelBuffered - WATER_Z_ADDITION)/(BoatDimensions.z/2.0f + MaxHeightUp);
- TargetAlpha = Asin(clamp(Water, -1.0f, 1.0f));
+ TargetAlpha = Asin(Clamp(Water, -1.0f, 1.0f));
}
if(ResetStatics){
@@ -3461,7 +3461,7 @@ FindSplinePathPositionFloat(float *out, float *spline, uint32 time, uint32 &mark
}
}
float a = ((float)time - (float)MS(spline[marker-4])) / (float)MS(spline[marker] - spline[marker-4]);
- a = clamp(a, 0.0f, 1.0f);
+ a = Clamp(a, 0.0f, 1.0f);
float b = 1.0f - a;
*out = b*b*b * spline[marker-3] +
3.0f*a*b*b * spline[marker-1] +
@@ -3499,7 +3499,7 @@ FindSplinePathPositionVector(CVector *out, float *spline, uint32 time, uint32 &m
}
float a = ((float)time - (float)MS(spline[marker-10])) / (float)MS(spline[marker] - spline[marker-10]);
- a = clamp(a, 0.0f, 1.0f);
+ a = Clamp(a, 0.0f, 1.0f);
float b = 1.0f - a;
out->x =
b*b*b * spline[marker-9] +
@@ -4925,7 +4925,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// 0.98f: CAR_FOV_FADE_MULT
FOV = Pow(0.98f, CTimer::GetTimeStep()) * (FOV - DefaultFOV) + DefaultFOV;
- FOV = clamp(FOV, DefaultFOV, DefaultFOV + 30.0f);
+ FOV = Clamp(FOV, DefaultFOV, DefaultFOV + 30.0f);
}
// WORKAROUND: I still don't know how looking behind works (m_bCamDirectlyInFront is unused in III, they seem to use m_bUseTransitionBeta)
@@ -5044,7 +5044,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
}
- float targetAlpha = Asin(clamp(Front.z, -1.0f, 1.0f)) - zoomModeAlphaOffset;
+ float targetAlpha = Asin(Clamp(Front.z, -1.0f, 1.0f)) - zoomModeAlphaOffset;
if (targetAlpha <= maxAlphaAllowed) {
if (targetAlpha < -CARCAM_SET[camSetArrPos][14])
targetAlpha = -CARCAM_SET[camSetArrPos][14];
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 987efe04..6e632c7c 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -348,7 +348,7 @@ CCamera::Process(void)
currentTime = m_uiTransitionDuration;
float fractionInter = (float) currentTime / m_uiTransitionDuration;
float fractionInterTarget = (float) currentTime / m_uiTransitionDurationTargetCoors;
- fractionInterTarget = clamp(fractionInterTarget, 0.0f, 1.0f);
+ fractionInterTarget = Clamp(fractionInterTarget, 0.0f, 1.0f);
// Interpolate target separately
if(fractionInterTarget <= m_fFractionInterToStopMovingTarget){
@@ -552,7 +552,7 @@ CCamera::Process(void)
// Process Shake
float shakeStrength = m_fCamShakeForce - 0.28f*(CTimer::GetTimeInMilliseconds()-m_uiCamShakeStart)/1000.0f;
- shakeStrength = clamp(shakeStrength, 0.0f, 2.0f);
+ shakeStrength = Clamp(shakeStrength, 0.0f, 2.0f);
int shakeRand = CGeneral::GetRandomNumber();
float shakeOffset = shakeStrength*0.1f;
GetMatrix().GetPosition().x += shakeOffset * ((shakeRand & 0xF) - 7);
@@ -1914,7 +1914,7 @@ CCamera::CamShake(float strength, float x, float y, float z)
float curForce = mult*(m_fCamShakeForce - (CTimer::GetTimeInMilliseconds() - m_uiCamShakeStart)/1000.0f);
strength = mult*strength;
- if(clamp(curForce, 0.0f, 2.0f) < strength){
+ if(Clamp(curForce, 0.0f, 2.0f) < strength){
m_fCamShakeForce = strength;
m_uiCamShakeStart = CTimer::GetTimeInMilliseconds();
}
@@ -1925,7 +1925,7 @@ void
CamShakeNoPos(CCamera *cam, float strength)
{
float curForce = cam->m_fCamShakeForce - (CTimer::GetTimeInMilliseconds() - cam->m_uiCamShakeStart)/1000.0f;
- if(clamp(curForce, 0.0f, 2.0f) < strength){
+ if(Clamp(curForce, 0.0f, 2.0f) < strength){
cam->m_fCamShakeForce = strength;
cam->m_uiCamShakeStart = CTimer::GetTimeInMilliseconds();
}
@@ -3987,7 +3987,7 @@ CCamera::Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source,
float
CCamera::Find3rdPersonQuickAimPitch(void)
{
- float clampedFrontZ = clamp(Cams[ActiveCam].Front.z, -1.0f, 1.0f);
+ float clampedFrontZ = Clamp(Cams[ActiveCam].Front.z, -1.0f, 1.0f);
float rot = Asin(clampedFrontZ);
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index d57bdd92..e2b66286 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -1147,7 +1147,7 @@ CFileLoader::Load2dEffect(const char *line)
&probability);
effect->attractor.type = flags;
#ifdef FIX_BUGS
- effect->attractor.probability = clamp(probability, 0, 255);
+ effect->attractor.probability = Clamp(probability, 0, 255);
#else
effect->attractor.probability = probability;
#endif
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 3bf05836..bbc79d4e 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -711,27 +711,27 @@ CMenuManager::CheckSliderMovement(int value)
switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) {
case MENUACTION_BRIGHTNESS:
m_PrefsBrightness += value * 32.0f;
- m_PrefsBrightness = clamp(m_PrefsBrightness, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
+ m_PrefsBrightness = Clamp(m_PrefsBrightness, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
break;
case MENUACTION_DRAWDIST:
if(value > 0)
m_PrefsLOD += ((1.8f - 0.925f) / 16.0f);
else
m_PrefsLOD -= ((1.8f - 0.925f) / 16.0f);
- m_PrefsLOD = clamp(m_PrefsLOD, 0.925f, 1.8f);
+ m_PrefsLOD = Clamp(m_PrefsLOD, 0.925f, 1.8f);
CRenderer::ms_lodDistScale = m_PrefsLOD;
break;
case MENUACTION_MUSICVOLUME:
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
m_PrefsMusicVolume += value * (128 / 32);
- m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 65);
+ m_PrefsMusicVolume = Clamp(m_PrefsMusicVolume, 0, 65);
DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume);
}
break;
case MENUACTION_SFXVOLUME:
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
m_PrefsSfxVolume += value * (128 / 32);
- m_PrefsSfxVolume = clamp(m_PrefsSfxVolume, 0, 65);
+ m_PrefsSfxVolume = Clamp(m_PrefsSfxVolume, 0, 65);
DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume);
}
break;
@@ -739,14 +739,14 @@ CMenuManager::CheckSliderMovement(int value)
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
if (DMAudio.IsMP3RadioChannelAvailable()) {
m_PrefsMP3BoostVolume += value * (128 / 32);
- m_PrefsMP3BoostVolume = clamp(m_PrefsMP3BoostVolume, 0, 65);
+ m_PrefsMP3BoostVolume = Clamp(m_PrefsMP3BoostVolume, 0, 65);
DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume);
}
}
break;
case MENUACTION_MOUSESENS:
TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ???
- TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f);
+ TheCamera.m_fMouseAccelHorzntl = Clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f);
#ifdef FIX_BUGS
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
#endif
@@ -3490,8 +3490,8 @@ CMenuManager::Process(void)
break; \
\
m_fMapSize *= z2; \
- m_fMapCenterX = clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); \
- m_fMapCenterY = clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); \
+ m_fMapCenterX = Clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2); \
+ m_fMapCenterY = Clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2); \
} while(0)
#endif
@@ -3529,8 +3529,8 @@ CMenuManager::AdditionalOptionInput(bool &goBack)
m_fMapCenterX += (SCREEN_WIDTH/2 - m_fMapCenterX) / ((m_fMapSize - MENU_X(MAP_MIN_SIZE)) * 1/15.f);
m_fMapSize = Max(MENU_Y(MAP_MIN_SIZE), m_fMapSize - MENU_Y(15.f));
- m_fMapCenterX = clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2);
- m_fMapCenterY = clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2);
+ m_fMapCenterX = Clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2);
+ m_fMapCenterY = Clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2);
} else {
m_fMapSize = MENU_Y(MAP_MIN_SIZE);
}
@@ -3571,8 +3571,8 @@ CMenuManager::AdditionalOptionInput(bool &goBack)
if (!justResetPointer) {
m_fMapCenterX += m_nMousePosX - m_nMouseOldPosX;
m_fMapCenterY += m_nMousePosY - m_nMouseOldPosY;
- m_fMapCenterX = clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2);
- m_fMapCenterY = clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2);
+ m_fMapCenterX = Clamp(m_fMapCenterX, SCREEN_WIDTH/2 - (m_fMapSize - MENU_X(MAP_MIN_SIZE)), m_fMapSize - MENU_X(MAP_MIN_SIZE) + SCREEN_WIDTH/2);
+ m_fMapCenterY = Clamp(m_fMapCenterY, SCREEN_HEIGHT/2 - (m_fMapSize - MENU_Y(MAP_MIN_SIZE)), m_fMapSize - MENU_Y(MAP_MIN_SIZE) + SCREEN_HEIGHT/2);
}
justResetPointer = false;
@@ -5068,7 +5068,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u
case MENUACTION_SPEAKERCONF:
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
m_PrefsSpeakers -= changeAmount;
- m_PrefsSpeakers = clamp(m_PrefsSpeakers, 0, 2);
+ m_PrefsSpeakers = Clamp(m_PrefsSpeakers, 0, 2);
DMAudio.SetSpeakerConfig(m_PrefsSpeakers);
SaveSettings();
}
@@ -5679,7 +5679,7 @@ CMenuManager::DrawQuitGameScreen(void)
static int32 exitSignalTimer = 0;
#ifdef FIX_BUGS
- int alpha = clamp(m_nMenuFadeAlpha, 0, 255);
+ int alpha = Clamp(m_nMenuFadeAlpha, 0, 255);
#else
int alpha = m_nMenuFadeAlpha;
#endif
diff --git a/src/core/Frontend_PS2.cpp b/src/core/Frontend_PS2.cpp
index c635c21f..fa238031 100644
--- a/src/core/Frontend_PS2.cpp
+++ b/src/core/Frontend_PS2.cpp
@@ -1375,7 +1375,7 @@ CMenuManager::DrawFrontEndNormal(void)
if ((m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) <= 1600)
alpha = float(m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 400.0f;
- m_someAlpha = 255 - clamp(alpha, 0.0f, 1.0f) * 255.0f;
+ m_someAlpha = 255 - Clamp(alpha, 0.0f, 1.0f) * 255.0f;
switch ( m_nSlidingDir )
{
@@ -1392,7 +1392,7 @@ CMenuManager::DrawFrontEndNormal(void)
float slide = float(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 800.0f;
float alpha = float((int32)(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) + -266) / 533.0f;
- m_someAlpha = clamp(alpha, 0.0f, 1.0f) * 255.0f;
+ m_someAlpha = Clamp(alpha, 0.0f, 1.0f) * 255.0f;
switch ( m_nSlidingDir )
{
diff --git a/src/core/General.h b/src/core/General.h
index 2f205c39..c17d916d 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -56,7 +56,7 @@ public:
static float LimitRadianAngle(float angle)
{
- float result = clamp(angle, -25.0f, 25.0f);
+ float result = Clamp(angle, -25.0f, 25.0f);
while (result >= PI) {
result -= 2 * PI;
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 337d631c..2e3372f1 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -299,7 +299,7 @@ CPlayerInfo::Process(void)
m_fRoadDensity = ThePaths.CalcRoadDensity(playerPos.x, playerPos.y);
}
- m_fRoadDensity = clamp(m_fRoadDensity, 0.5f, 1.45f);
+ m_fRoadDensity = Clamp(m_fRoadDensity, 0.5f, 1.45f);
// Because vehicle enter/exit use same key binding.
bool enterOrExitVeh;
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index d824d498..d1947813 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -14,6 +14,7 @@
#include "Wanted.h"
#include "World.h"
#include "MemoryHeap.h"
+#include "SaveBuf.h"
CCPtrNodePool *CPools::ms_pPtrNodePool;
CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool;
@@ -137,15 +138,20 @@ CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
void CPools::LoadVehiclePool(uint8* buf, uint32 size)
{
INITSAVEBUF
- int nNumCars = ReadSaveBuf<int>(buf);
- int nNumBoats = ReadSaveBuf<int>(buf);
- int nNumBikes = ReadSaveBuf<int>(buf);
+ int nNumCars, nNumBoats, nNumBikes;
+ ReadSaveBuf(&nNumCars, buf);
+ ReadSaveBuf(&nNumBoats, buf);
+ ReadSaveBuf(&nNumBikes, buf);
for (int i = 0; i < nNumCars + nNumBoats + nNumBikes; i++) {
- uint32 type = ReadSaveBuf<uint32>(buf);
- int16 model = ReadSaveBuf<int16>(buf);
+ uint32 type;
+ int16 model;
+ int32 slot;
+
+ ReadSaveBuf(&type, buf);
+ ReadSaveBuf(&model, buf);
CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY);
CStreaming::LoadAllRequestedModels(false);
- int32 slot = ReadSaveBuf<int32>(buf);
+ ReadSaveBuf(&slot, buf);
CVehicle* pVehicle;
#ifdef COMPATIBLE_SAVES
if (type == VEHICLE_TYPE_BOAT)
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index b8c3d717..5c92206f 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -19,6 +19,7 @@
#include "Streaming.h"
#include "SpecialFX.h"
#include "Font.h"
+#include "SaveBuf.h"
float CRadar::m_radarRange;
sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS];
@@ -1028,21 +1029,21 @@ INITSAVEBUF
CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE);
for (int i = 0; i < NUMRADARBLIPS; i++) {
- ms_RadarTrace[i].m_nColor = ReadSaveBuf<uint32>(buf);
- ms_RadarTrace[i].m_Radius = ReadSaveBuf<float>(buf);
- ms_RadarTrace[i].m_eBlipType = ReadSaveBuf<uint32>(buf);
- ms_RadarTrace[i].m_nEntityHandle = ReadSaveBuf<int32>(buf);
- ms_RadarTrace[i].m_vec2DPos.x = ReadSaveBuf<float>(buf); // CVector2D
- ms_RadarTrace[i].m_vec2DPos.y = ReadSaveBuf<float>(buf);
- ms_RadarTrace[i].m_vecPos = ReadSaveBuf<CVector>(buf);
- ms_RadarTrace[i].m_BlipIndex = ReadSaveBuf<uint16>(buf);
- ms_RadarTrace[i].m_bDim = ReadSaveBuf<bool>(buf);
- ms_RadarTrace[i].m_bInUse = ReadSaveBuf<bool>(buf);
- ms_RadarTrace[i].m_bShortRange = ReadSaveBuf<bool>(buf);
- ms_RadarTrace[i].m_unused = ReadSaveBuf<bool>(buf);
- ms_RadarTrace[i].m_wScale = ReadSaveBuf<int16>(buf);
- ms_RadarTrace[i].m_eBlipDisplay = ReadSaveBuf<uint16>(buf);
- ms_RadarTrace[i].m_eRadarSprite = ReadSaveBuf<uint16>(buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_nColor, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_Radius, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_eBlipType, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_nEntityHandle, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_vec2DPos.x, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_vec2DPos.y, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_vecPos, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_BlipIndex, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_bDim, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_bInUse, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_bShortRange, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_unused, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_wScale, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_eBlipDisplay, buf);
+ ReadSaveBuf(&ms_RadarTrace[i].m_eRadarSprite, buf);
}
VALIDATESAVEBUF(size);
diff --git a/src/core/Ropes.cpp b/src/core/Ropes.cpp
index e390a917..71297eb1 100644
--- a/src/core/Ropes.cpp
+++ b/src/core/Ropes.cpp
@@ -150,7 +150,7 @@ CRopes::FindCoorsAlongRope(uintptr id, float t, CVector *coors)
float f;
for(i = 0; i < ARRAY_SIZE(aRopes); i++)
if(aRopes[i].m_bActive && aRopes[i].m_id == id){
- t = (ARRAY_SIZE(aRopes[0].m_pos)-1)*clamp(t, 0.0f, 0.999f);
+ t = (ARRAY_SIZE(aRopes[0].m_pos)-1)*Clamp(t, 0.0f, 0.999f);
j = t;
f = t - j;
*coors = (1.0f-f)*aRopes[i].m_pos[j] + f*aRopes[i].m_pos[j+1];
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 9e2c4345..8756049d 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -399,8 +399,8 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C
CVector point2(point1.x, point1.y, z2);
int secX = GetSectorIndexX(point1.x);
int secY = GetSectorIndexY(point1.y);
- secX = clamp(secX, 0, NUMSECTORS_X-1);
- secY = clamp(secY, 0, NUMSECTORS_Y-1);
+ secX = Clamp(secX, 0, NUMSECTORS_X-1);
+ secY = Clamp(secY, 0, NUMSECTORS_Y-1);
return ProcessVerticalLineSector(*GetSector(secX, secY),
CColLine(point1, point2), point, entity, checkBuildings, checkVehicles,
checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly);
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 30253809..5a53ee29 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -8,6 +8,7 @@
#include "Text.h"
#include "World.h"
#include "Timer.h"
+#include "SaveBuf.h"
eLevelName CTheZones::m_CurrLevel;
int16 CTheZones::FindIndex;
@@ -714,11 +715,11 @@ CTheZones::SaveOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zo
WriteSaveBuf(*buffer, *length, zone->zoneinfoNight);
int32 zoneId;
- zoneId = GetIndexForZonePointer(zone->child);
+ zoneId = GetIndexForNavigationZonePointer(zone->child);
WriteSaveBuf(*buffer, *length, zoneId);
- zoneId = GetIndexForZonePointer(zone->parent);
+ zoneId = GetIndexForNavigationZonePointer(zone->parent);
WriteSaveBuf(*buffer, *length, zoneId);
- zoneId = GetIndexForZonePointer(zone->next);
+ zoneId = GetIndexForNavigationZonePointer(zone->next);
WriteSaveBuf(*buffer, *length, zoneId);
}
@@ -731,9 +732,9 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
uint32 length = 0;
CheckSaveHeaderWithLength(buffer, length, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
- m_CurrLevel = ReadSaveBuf<eLevelName>(buffer, length);
- FindIndex = ReadSaveBuf<int16>(buffer, length);
- ReadSaveBuf<int16>(buffer, length);
+ ReadSaveBuf(&m_CurrLevel, buffer);
+ ReadSaveBuf(&FindIndex, buffer);
+ SkipSaveBuf(buffer, 2);
for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++)
LoadOneZone(&NavigationZoneArray[i], &buffer, &length, ZONE_NAVIG);
@@ -742,21 +743,21 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
LoadOneZone(&InfoZoneArray[i], &buffer, &length, ZONE_INFO);
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
- ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer, length);
+ ReadSaveBuf(&ZoneInfoArray[i], buffer);
- TotalNumberOfNavigationZones = ReadSaveBuf<int16>(buffer, length);
- TotalNumberOfInfoZones = ReadSaveBuf<int16>(buffer, length);
- TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer, length);
- ReadSaveBuf<int16>(buffer, length);
+ ReadSaveBuf(&TotalNumberOfNavigationZones, buffer);
+ ReadSaveBuf(&TotalNumberOfInfoZones, buffer);
+ ReadSaveBuf(&TotalNumberOfZoneInfos, buffer);
+ SkipSaveBuf(buffer, 2);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++)
LoadOneZone(&MapZoneArray[i], &buffer, &length, ZONE_MAPZONE);
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
- AudioZoneArray[i] = ReadSaveBuf<int16>(buffer, length);
+ ReadSaveBuf(&AudioZoneArray[i], buffer);
- TotalNumberOfMapZones = ReadSaveBuf<uint16>(buffer, length);
- NumberOfAudioZones = ReadSaveBuf<uint16>(buffer, length);
+ ReadSaveBuf(&TotalNumberOfMapZones, buffer);
+ ReadSaveBuf(&NumberOfAudioZones, buffer);
VALIDATESAVEBUF(size)
}
@@ -764,26 +765,36 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
void
CTheZones::LoadOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType)
{
- *(uint32*)&zone->name[0] = ReadSaveBuf<uint32>(*buffer, *length);
- *(uint32*)&zone->name[4] = ReadSaveBuf<uint32>(*buffer, *length);
+#ifdef THIS_IS_STUPID
+ uint32 part1, part2;
+ ReadSaveBuf(&part1, *buffer, *length);
+ ReadSaveBuf(&part2, *buffer, *length);
+
+ *(uint64 *)&zone->name[0] = (uint64)part2;
+ *(uint64 *)&zone->name[0] <<= 32;
+ *(uint64 *)&zone->name[0] |= (uint64)part1;
+#else
+ for(int i = 0; i < sizeof(zone->name); i++)
+ ReadSaveBuf(&zone->name[i], *buffer, *length);
+#endif
- zone->minx = ReadSaveBuf<float>(*buffer, *length);
- zone->miny = ReadSaveBuf<float>(*buffer, *length);
- zone->minz = ReadSaveBuf<float>(*buffer, *length);
- zone->maxx = ReadSaveBuf<float>(*buffer, *length);
- zone->maxy = ReadSaveBuf<float>(*buffer, *length);
- zone->maxz = ReadSaveBuf<float>(*buffer, *length);
+ ReadSaveBuf(&zone->minx, *buffer, *length);
+ ReadSaveBuf(&zone->miny, *buffer, *length);
+ ReadSaveBuf(&zone->minz, *buffer, *length);
+ ReadSaveBuf(&zone->maxx, *buffer, *length);
+ ReadSaveBuf(&zone->maxy, *buffer, *length);
+ ReadSaveBuf(&zone->maxz, *buffer, *length);
- zone->type = ReadSaveBuf<eZoneType>(*buffer, *length);
- zone->level = ReadSaveBuf<eLevelName>(*buffer, *length);
- zone->zoneinfoDay = ReadSaveBuf<int16>(*buffer, *length);
- zone->zoneinfoNight = ReadSaveBuf<int16>(*buffer, *length);
+ ReadSaveBuf(&zone->type, *buffer, *length);
+ ReadSaveBuf(&zone->level, *buffer, *length);
+ ReadSaveBuf(&zone->zoneinfoDay, *buffer, *length);
+ ReadSaveBuf(&zone->zoneinfoNight, *buffer, *length);
int32 zoneId;
- zoneId = ReadSaveBuf<int32>(*buffer, *length);
- zone->child = GetPointerForZoneIndex(zoneId);
- zoneId = ReadSaveBuf<int32>(*buffer, *length);
- zone->parent = GetPointerForZoneIndex(zoneId);
- zoneId = ReadSaveBuf<int32>(*buffer, *length);
- zone->next = GetPointerForZoneIndex(zoneId);
+ ReadSaveBuf(&zoneId, *buffer, *length);
+ zone->child = GetPointerForNavigationZoneIndex(zoneId);
+ ReadSaveBuf(&zoneId, *buffer, *length);
+ zone->parent = GetPointerForNavigationZoneIndex(zoneId);
+ ReadSaveBuf(&zoneId, *buffer, *length);
+ zone->next = GetPointerForNavigationZoneIndex(zoneId);
} \ No newline at end of file
diff --git a/src/core/Zones.h b/src/core/Zones.h
index b987f009..2316eeef 100644
--- a/src/core/Zones.h
+++ b/src/core/Zones.h
@@ -103,8 +103,8 @@ public:
static void SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity);
static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup);
static int16 FindAudioZone(CVector *pos);
- static CZone *GetPointerForZoneIndex(ssize_t i) { return i == -1 ? nil : &NavigationZoneArray[i]; }
- static ssize_t GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - NavigationZoneArray; }
+ static CZone *GetPointerForNavigationZoneIndex(ssize_t i) { return i == -1 ? nil : &NavigationZoneArray[i]; }
+ static ssize_t GetIndexForNavigationZonePointer(CZone *zone) { return zone == nil ? -1 : zone - NavigationZoneArray; }
static void AddZoneToAudioZoneArray(CZone *zone);
static void InitialiseAudioZoneArray(void);
static void SaveAllZones(uint8 *buffer, uint32 *length);
diff --git a/src/core/common.h b/src/core/common.h
index 51170986..bb6b93d3 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -303,9 +303,9 @@ extern int strncasecmp(const char *str1, const char *str2, size_t len);
extern wchar *AllocUnicode(const char*src);
-#define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v))
+#define Clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v))
-#define clamp2(v, center, radius) ((v) < (center) ? Max(v, center - radius) : Min(v, center + radius))
+#define Clamp2(v, center, radius) ((v) < (center) ? Max(v, center - radius) : Min(v, center + radius))
inline float sq(float x) { return x*x; }
#define SQR(x) ((x) * (x))
@@ -406,212 +406,3 @@ __inline__ void TRACE(char *f, ...) { } // this is re3 only, and so the function
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
-#ifdef DEBUGMENU
-// Tweaking stuff for debugmenu
-#define TWEAKPATH ___tw___TWEAKPATH
-#define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path;
-#define TWEAKFUNC(v) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
-#define TWEAKFUNCN(v, name) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
-#define TWEAKBOOL(v) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
-#define TWEAKBOOLN(v, name) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
-#define TWEAKINT32(v, lower, upper, step) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKINT32N(v, lower, upper, step, name) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKUINT32(v, lower, upper, step) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKUINT32N(v, lower, upper, step, name) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKINT16(v, lower, upper, step) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKINT16N(v, lower, upper, step, name) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKUINT16(v, lower, upper, step) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKUINT16N(v, lower, upper, step, name) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKINT8(v, lower, upper, step) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKINT8N(v, lower, upper, step, name) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKUINT8(v, lower, upper, step) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKUINT8N(v, lower, upper, step, name) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKFLOAT(v, lower, upper, step) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
-#define TWEAKFLOATN(v, lower, upper, step, name) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
-#define TWEAKSWITCH(v, lower, upper, str, f) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, str, f, TWEAKPATH);
-#define TWEAKSWITCHN(v, lower, upper, str, f, name) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, str, f, TWEAKPATH);
-
-// interface
-class CTweakVar
-{
-public:
- virtual void AddDBG(const char *path) = 0;
-};
-
-class CTweakVars
-{
-public:
- static void Add(CTweakVar *var);
- static void AddDBG(const char *path);
-};
-
-class CTweakFunc : public CTweakVar
-{
- const char *m_pPath, *m_pVarName;
- void (*m_pFunc)();
-public:
- CTweakFunc(void (*pFunc)(), const char *strName, const char *strPath) :
- m_pPath(strPath), m_pVarName(strName), m_pFunc(pFunc)
- {
- CTweakVars::Add(this);
- }
-
- void AddDBG(const char *path);
-};
-
-class CTweakBool : public CTweakVar
-{
- const char *m_pPath, *m_pVarName;
- bool *m_pBoolVar;
-public:
- CTweakBool(bool *pBool, const char *strName, const char *strPath) :
- m_pPath(strPath), m_pVarName(strName), m_pBoolVar(pBool)
- {
- CTweakVars::Add(this);
- }
-
- void AddDBG(const char *path);
-};
-
-class CTweakSwitch : public CTweakVar
-{
- const char *m_pPath, *m_pVarName;
- void *m_pIntVar;
- int32 m_nMin, m_nMax;
- const char **m_aStr;
- void (*m_pFunc)();
-public:
- CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr,
- void (*pFunc)(), const char *strPath)
- : m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax),
- m_aStr(aStr)
- {
- CTweakVars::Add(this);
- }
-
- void AddDBG(const char *path);
-};
-
-#define _TWEEKCLASS(name, type) \
- class name : public CTweakVar \
- { \
- public: \
- const char *m_pPath, *m_pVarName; \
- type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \
- \
- name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, \
- const char *strPath) \
- : m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), \
- m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep) \
- \
- { \
- CTweakVars::Add(this); \
- } \
- \
- void AddDBG(const char *path); \
- };
-
-_TWEEKCLASS(CTweakInt8, int8);
-_TWEEKCLASS(CTweakUInt8, uint8);
-_TWEEKCLASS(CTweakInt16, int16);
-_TWEEKCLASS(CTweakUInt16, uint16);
-_TWEEKCLASS(CTweakInt32, int32);
-_TWEEKCLASS(CTweakUInt32, uint32);
-_TWEEKCLASS(CTweakFloat, float);
-
-#undef _TWEEKCLASS
-#endif
-
-#ifdef VALIDATE_SAVE_SIZE
-extern int32 _saveBufCount;
-#define INITSAVEBUF _saveBufCount = 0;
-#define VALIDATESAVEBUF(b) assert(_saveBufCount == b);
-#else
-#define INITSAVEBUF
-#define VALIDATESAVEBUF(b)
-#endif
-
-inline void SkipSaveBuf(uint8 *&buf, int32 skip)
-{
- buf += skip;
-#ifdef VALIDATE_SAVE_SIZE
- _saveBufCount += skip;
-#endif
-}
-
-inline void SkipSaveBuf(uint8*& buf, uint32 &length, int32 skip)
-{
- buf += skip;
- length += skip;
-#ifdef VALIDATE_SAVE_SIZE
- _saveBufCount += skip;
-#endif
-}
-
-template<typename T>
-inline const T ReadSaveBuf(uint8 *&buf)
-{
- T &value = *(T*)buf;
- SkipSaveBuf(buf, sizeof(T));
- return value;
-}
-
-template<typename T>
-inline const T ReadSaveBuf(uint8 *&buf, uint32 &length)
-{
- T &value = *(T*)buf;
- SkipSaveBuf(buf, length, sizeof(T));
- return value;
-}
-
-template<typename T>
-inline T *WriteSaveBuf(uint8 *&buf, const T &value)
-{
- T *p = (T*)buf;
- *p = value;
- SkipSaveBuf(buf, sizeof(T));
- return p;
-}
-
-template<typename T>
-inline T *WriteSaveBuf(uint8 *&buf, uint32 &length, const T &value)
-{
- T *p = (T*)buf;
- *p = value;
- SkipSaveBuf(buf, length, sizeof(T));
- return p;
-}
-
-
-#define SAVE_HEADER_SIZE (4*sizeof(char)+sizeof(uint32))
-
-#define WriteSaveHeader(buf,a,b,c,d,size) \
- WriteSaveBuf(buf, a);\
- WriteSaveBuf(buf, b);\
- WriteSaveBuf(buf, c);\
- WriteSaveBuf(buf, d);\
- WriteSaveBuf<uint32>(buf, size);
-
-#define WriteSaveHeaderWithLength(buf,len,a,b,c,d,size) \
- WriteSaveBuf(buf, len, a);\
- WriteSaveBuf(buf, len, b);\
- WriteSaveBuf(buf, len, c);\
- WriteSaveBuf(buf, len, d);\
- WriteSaveBuf<uint32>(buf, len, size);
-
-#define CheckSaveHeader(buf,a,b,c,d,size)\
- assert(ReadSaveBuf<char>(buf) == a);\
- assert(ReadSaveBuf<char>(buf) == b);\
- assert(ReadSaveBuf<char>(buf) == c);\
- assert(ReadSaveBuf<char>(buf) == d);\
- assert(ReadSaveBuf<uint32>(buf) == size);
-
-#define CheckSaveHeaderWithLength(buf,len,a,b,c,d,size)\
- assert(ReadSaveBuf<char>(buf,len) == a);\
- assert(ReadSaveBuf<char>(buf,len) == b);\
- assert(ReadSaveBuf<char>(buf,len) == c);\
- assert(ReadSaveBuf<char>(buf,len) == d);\
- assert(ReadSaveBuf<uint32>(buf,len) == size);
-
-
-void cprintf(char*, ...);
diff --git a/src/core/config.h b/src/core/config.h
index 96069304..1f042e08 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -406,6 +406,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
#define MULTITHREADED_AUDIO // for streams. requires C++11 or later
+#define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused
#ifdef AUDIO_OPUS
#define AUDIO_OAL_USE_OPUS // enable support of opus files