mirror of
https://github.com/halpz/re3.git
synced 2025-01-09 20:35:27 +00:00
Merge remote-tracking branch 'upstream/lcs' into lcs
This commit is contained in:
commit
10cc444482
|
@ -998,8 +998,8 @@ cAudioManager::ProcessModelVehicle(cVehicleParams& params)
|
||||||
freq = 25000;
|
freq = 25000;
|
||||||
}
|
}
|
||||||
if (isPlayerVeh) {
|
if (isPlayerVeh) {
|
||||||
volume = clamp2(volume, prevVolume, 7);
|
volume = Clamp2(volume, prevVolume, 7);
|
||||||
freq = clamp2(freq, prevFreq, 800);
|
freq = Clamp2(freq, prevFreq, 800);
|
||||||
}
|
}
|
||||||
if (volume > 0) {
|
if (volume > 0) {
|
||||||
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
||||||
|
@ -1047,8 +1047,8 @@ cAudioManager::ProcessModelVehicle(cVehicleParams& params)
|
||||||
freq = Min(22000, (8000 * acceletateState / 255 + 14000) * 3.0f * Abs(params.m_fVelocityChange));
|
freq = Min(22000, (8000 * acceletateState / 255 + 14000) * 3.0f * Abs(params.m_fVelocityChange));
|
||||||
}
|
}
|
||||||
if (isPlayerVeh && !vehSlowdown) {
|
if (isPlayerVeh && !vehSlowdown) {
|
||||||
volume = clamp2(volume, prevVolume, 7);
|
volume = Clamp2(volume, prevVolume, 7);
|
||||||
freq = clamp2(freq, prevFreq, 800);
|
freq = Clamp2(freq, prevFreq, 800);
|
||||||
}
|
}
|
||||||
if (!vehSlowdown)
|
if (!vehSlowdown)
|
||||||
#ifdef THIS_IS_STUPID
|
#ifdef THIS_IS_STUPID
|
||||||
|
@ -1127,7 +1127,7 @@ cAudioManager::ProcessModelHeliVehicle(cVehicleParams& params)
|
||||||
}
|
}
|
||||||
if (acceletateState < brakeState)
|
if (acceletateState < brakeState)
|
||||||
acceletateState = brakeState;
|
acceletateState = brakeState;
|
||||||
freq = clamp2(5 * acceletateState + 22050, prevFreq, 30);
|
freq = Clamp2(5 * acceletateState + 22050, prevFreq, 30);
|
||||||
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
||||||
m_sQueueSample.m_nVolume = ComputeVolume(70, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
|
m_sQueueSample.m_nVolume = ComputeVolume(70, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
|
||||||
if (m_sQueueSample.m_nVolume != 0) {
|
if (m_sQueueSample.m_nVolume != 0) {
|
||||||
|
@ -1667,8 +1667,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
bHandbrakeOnLastFrame = FALSE;
|
bHandbrakeOnLastFrame = FALSE;
|
||||||
}
|
}
|
||||||
if (CReplay::IsPlayingBack()) {
|
if (CReplay::IsPlayingBack()) {
|
||||||
accelerateState = (255.0f * clamp(params.m_pVehicle->m_fGasPedal, 0.0f, 1.0f));
|
accelerateState = (255.0f * Clamp(params.m_pVehicle->m_fGasPedal, 0.0f, 1.0f));
|
||||||
brakeState = (255.0f * clamp(params.m_pVehicle->m_fBrakePedal, 0.0f, 1.0f));
|
brakeState = (255.0f * Clamp(params.m_pVehicle->m_fBrakePedal, 0.0f, 1.0f));
|
||||||
} else {
|
} else {
|
||||||
accelerateState = Pads[0].GetAccelerate();
|
accelerateState = Pads[0].GetAccelerate();
|
||||||
brakeState = Pads[0].GetBrake();
|
brakeState = Pads[0].GetBrake();
|
||||||
|
@ -1820,7 +1820,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
relativeVelocityChange = 2.0f * params.m_fVelocityChange / params.m_pTransmission->fMaxVelocity;
|
relativeVelocityChange = 2.0f * params.m_fVelocityChange / params.m_pTransmission->fMaxVelocity;
|
||||||
accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f);
|
accelerationMultipler = Clamp(relativeVelocityChange, 0.0f, 1.0f);
|
||||||
gasPedalAudio = accelerationMultipler;
|
gasPedalAudio = accelerationMultipler;
|
||||||
/*switch (engineSoundType) {
|
/*switch (engineSoundType) {
|
||||||
case SFX_BANK_MOPED:
|
case SFX_BANK_MOPED:
|
||||||
|
@ -3595,7 +3595,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params)
|
||||||
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713;
|
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713;
|
||||||
if (propellerSpeed < 1.0f)
|
if (propellerSpeed < 1.0f)
|
||||||
m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f);
|
m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f);
|
||||||
m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197);
|
m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197);
|
||||||
freqFrontPrev = m_sQueueSample.m_nFrequency;
|
freqFrontPrev = m_sQueueSample.m_nFrequency;
|
||||||
|
|
||||||
m_sQueueSample.m_bIs2D = FALSE;
|
m_sQueueSample.m_bIs2D = FALSE;
|
||||||
|
@ -3651,7 +3651,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params)
|
||||||
if (propellerSpeed < 1.0f)
|
if (propellerSpeed < 1.0f)
|
||||||
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2);
|
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2);
|
||||||
|
|
||||||
m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98);
|
m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98);
|
||||||
freqPropellerPrev = m_sQueueSample.m_nFrequency;
|
freqPropellerPrev = m_sQueueSample.m_nFrequency;
|
||||||
} else {
|
} else {
|
||||||
m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2;
|
m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2;
|
||||||
|
@ -3720,7 +3720,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params)
|
||||||
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713;
|
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713;
|
||||||
if (propellerSpeed < 1.0f)
|
if (propellerSpeed < 1.0f)
|
||||||
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f);
|
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f);
|
||||||
m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197);
|
m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197);
|
||||||
freqSkimmerPrev = m_sQueueSample.m_nFrequency;
|
freqSkimmerPrev = m_sQueueSample.m_nFrequency;
|
||||||
|
|
||||||
m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4;
|
m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4;
|
||||||
|
@ -11483,8 +11483,10 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
||||||
if (!m_nUserPause) {
|
if (!m_nUserPause) {
|
||||||
if (nCheckPlayingDelay[slot]) {
|
if (nCheckPlayingDelay[slot]) {
|
||||||
--nCheckPlayingDelay[slot];
|
--nCheckPlayingDelay[slot];
|
||||||
} else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_sMissionAudio.m_nMissionAudioCounter[slot]-- == 0) {
|
} else if ((g_bMissionAudioLoadFailed[slot] && m_sMissionAudio.m_nMissionAudioCounter[slot]-- == 0) || GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED) {
|
||||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED;
|
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED;
|
||||||
|
//if (m_sMissionAudio.m_nSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_sMissionAudio.m_nSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A)
|
||||||
|
// m_sMissionAudio.m_bIsMobile[slot] = FALSE;
|
||||||
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE;
|
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE;
|
||||||
//SampleManager.StopStreamedFile(slot + 1);
|
//SampleManager.StopStreamedFile(slot + 1);
|
||||||
SampleManager.StopChannel(slot + CHANNEL_MISSION_AUDIO_1);
|
SampleManager.StopChannel(slot + CHANNEL_MISSION_AUDIO_1);
|
||||||
|
|
|
@ -333,7 +333,7 @@ cAudioManager::Get3DProviderName(uint8 id) const
|
||||||
if (!m_bIsInitialised)
|
if (!m_bIsInitialised)
|
||||||
return nil;
|
return nil;
|
||||||
#ifdef AUDIO_OAL
|
#ifdef AUDIO_OAL
|
||||||
id = clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1);
|
id = Clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1);
|
||||||
#else
|
#else
|
||||||
// We don't want that either since it will crash the game, but skipping for now
|
// We don't want that either since it will crash the game, but skipping for now
|
||||||
if (id >= SampleManager.GetNum3DProvidersAvailable())
|
if (id >= SampleManager.GetNum3DProvidersAvailable())
|
||||||
|
@ -533,7 +533,7 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1,
|
||||||
if (dist != 0.0f) {
|
if (dist != 0.0f) {
|
||||||
float speedOfSource = (dist / m_nTimeSpent) * speedMultiplier;
|
float speedOfSource = (dist / m_nTimeSpent) * speedMultiplier;
|
||||||
if (m_fSpeedOfSound > Abs(speedOfSource)) {
|
if (m_fSpeedOfSound > Abs(speedOfSource)) {
|
||||||
speedOfSource = clamp2(speedOfSource, 0.0f, 1.5f);
|
speedOfSource = Clamp2(speedOfSource, 0.0f, 1.5f);
|
||||||
newFreq = (oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound);
|
newFreq = (oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,11 +897,11 @@ cAudioManager::ProcessActiveQueues()
|
||||||
sample.m_fSpeedMultiplier);
|
sample.m_fSpeedMultiplier);
|
||||||
|
|
||||||
if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) {
|
if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) {
|
||||||
m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000);
|
m_asActiveSamples[j].m_nFrequency = Clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000);
|
||||||
SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency);
|
SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency);
|
||||||
}
|
}
|
||||||
if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
|
if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
|
||||||
vol = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10);
|
vol = Clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10);
|
||||||
|
|
||||||
if (field_4) {
|
if (field_4) {
|
||||||
emittingVol = 2 * Min(63, vol);
|
emittingVol = 2 * Min(63, vol);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "AudioScriptObject.h"
|
#include "AudioScriptObject.h"
|
||||||
#include "Pools.h"
|
#include "Pools.h"
|
||||||
#include "DMAudio.h"
|
#include "DMAudio.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
cAudioScriptObject::cAudioScriptObject()
|
cAudioScriptObject::cAudioScriptObject()
|
||||||
{
|
{
|
||||||
|
@ -53,12 +54,14 @@ cAudioScriptObject::LoadAllAudioScriptObjects(uint8 *buf, uint32 size)
|
||||||
|
|
||||||
CheckSaveHeader(buf, 'A', 'U', 'D', '\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buf, 'A', 'U', 'D', '\0', size - SAVE_HEADER_SIZE);
|
||||||
|
|
||||||
int32 pool_size = ReadSaveBuf<int32>(buf);
|
int32 pool_size;
|
||||||
|
ReadSaveBuf(&pool_size, buf);
|
||||||
for (int32 i = 0; i < pool_size; i++) {
|
for (int32 i = 0; i < pool_size; i++) {
|
||||||
int handle = ReadSaveBuf<int32>(buf);
|
int32 handle;
|
||||||
|
ReadSaveBuf(&handle, buf);
|
||||||
cAudioScriptObject *p = new(handle) cAudioScriptObject;
|
cAudioScriptObject *p = new(handle) cAudioScriptObject;
|
||||||
assert(p != nil);
|
assert(p != nil);
|
||||||
*p = ReadSaveBuf<cAudioScriptObject>(buf);
|
ReadSaveBuf(p, buf);
|
||||||
p->AudioEntity = DMAudio.CreateLoopingScriptObject(p);
|
p->AudioEntity = DMAudio.CreateLoopingScriptObject(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,18 @@ cMusicManager::ChangeMusicMode(uint8 mode)
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case MUSICMODE_FRONTEND: m_nUpcomingMusicMode = MUSICMODE_FRONTEND; break;
|
case MUSICMODE_FRONTEND:
|
||||||
|
m_nUpcomingMusicMode = MUSICMODE_FRONTEND;
|
||||||
|
|
||||||
|
#ifdef PAUSE_RADIO_IN_FRONTEND
|
||||||
|
// rewind those streams we weren't listening right now
|
||||||
|
for( uint32 i = STREAMED_SOUND_RADIO_HEAD; i < STREAMED_SOUND_CUTSCENE_BIKER; i++ ) {
|
||||||
|
m_aTracks[i].m_nPosition = GetTrackStartPos(i);
|
||||||
|
m_aTracks[i].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
break;
|
||||||
case MUSICMODE_GAME: m_nUpcomingMusicMode = MUSICMODE_GAME; break;
|
case MUSICMODE_GAME: m_nUpcomingMusicMode = MUSICMODE_GAME; break;
|
||||||
case MUSICMODE_CUTSCENE:
|
case MUSICMODE_CUTSCENE:
|
||||||
m_nUpcomingMusicMode = MUSICMODE_CUTSCENE;
|
m_nUpcomingMusicMode = MUSICMODE_CUTSCENE;
|
||||||
|
@ -414,6 +425,12 @@ cMusicManager::ServiceFrontEndMode()
|
||||||
{
|
{
|
||||||
static bool8 bRadioStatsRecorded = FALSE;
|
static bool8 bRadioStatsRecorded = FALSE;
|
||||||
|
|
||||||
|
#ifdef PAUSE_RADIO_IN_FRONTEND
|
||||||
|
// pause radio
|
||||||
|
for( uint32 i = STREAMED_SOUND_RADIO_HEAD; i < STREAMED_SOUND_CUTSCENE_BIKER; i++ )
|
||||||
|
m_aTracks[i].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_bAnnouncementInProgress) {
|
if (m_bAnnouncementInProgress) {
|
||||||
SampleManager.StopStreamedFile();
|
SampleManager.StopStreamedFile();
|
||||||
if (SampleManager.IsStreamPlaying())
|
if (SampleManager.IsStreamPlaying())
|
||||||
|
|
|
@ -162,7 +162,7 @@ public:
|
||||||
else
|
else
|
||||||
StepIndex--;
|
StepIndex--;
|
||||||
|
|
||||||
StepIndex = clamp(StepIndex, 0, 88);
|
StepIndex = Clamp(StepIndex, 0, 88);
|
||||||
|
|
||||||
int delta = step >> 3;
|
int delta = step >> 3;
|
||||||
if (adpcm & 1) delta += step >> 2;
|
if (adpcm & 1) delta += step >> 2;
|
||||||
|
@ -171,7 +171,7 @@ public:
|
||||||
if (adpcm & 8) delta = -delta;
|
if (adpcm & 8) delta = -delta;
|
||||||
|
|
||||||
int newSample = Sample + delta;
|
int newSample = Sample + delta;
|
||||||
Sample = clamp(newSample, -32768, 32767);
|
Sample = Clamp(newSample, -32768, 32767);
|
||||||
return Sample;
|
return Sample;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -716,7 +716,7 @@ public:
|
||||||
static short quantize(double sample)
|
static short quantize(double sample)
|
||||||
{
|
{
|
||||||
int a = int(sample + 0.5);
|
int a = int(sample + 0.5);
|
||||||
return short(clamp(a, -32768, 32767));
|
return short(Clamp(a, -32768, 32767));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decode(void* _inbuf, int16* _outbuf, size_t size)
|
void Decode(void* _inbuf, int16* _outbuf, size_t size)
|
||||||
|
@ -1448,10 +1448,10 @@ void CStream::SetVolume(uint32 nVol)
|
||||||
|
|
||||||
void CStream::SetPan(uint8 nPan)
|
void CStream::SetPan(uint8 nPan)
|
||||||
{
|
{
|
||||||
m_nPan = clamp((int8)nPan - 63, 0, 63);
|
m_nPan = Clamp((int8)nPan - 63, 0, 63);
|
||||||
SetPosition(0, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
|
SetPosition(0, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
|
||||||
|
|
||||||
m_nPan = clamp((int8)nPan + 64, 64, 127);
|
m_nPan = Clamp((int8)nPan + 64, 64, 127);
|
||||||
SetPosition(1, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
|
SetPosition(1, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
|
||||||
|
|
||||||
m_nPan = nPan;
|
m_nPan = nPan;
|
||||||
|
|
|
@ -1750,7 +1750,7 @@ cSampleManager::UpdateReverb(void)
|
||||||
#undef CALCULATE_RATIO
|
#undef CALCULATE_RATIO
|
||||||
#undef MIN_DIST
|
#undef MIN_DIST
|
||||||
|
|
||||||
fRatio = clamp(fRatio, 0.0f, 0.6f);
|
fRatio = Clamp(fRatio, 0.0f, 0.6f);
|
||||||
|
|
||||||
if ( fRatio == _fPrevEaxRatioDestination )
|
if ( fRatio == _fPrevEaxRatioDestination )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -430,7 +430,7 @@ int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider)
|
||||||
{
|
{
|
||||||
int savedprovider = curprovider;
|
int savedprovider = curprovider;
|
||||||
|
|
||||||
nProvider = clamp(nProvider, 0, m_nNumberOfProviders - 1);
|
nProvider = Clamp(nProvider, 0, m_nNumberOfProviders - 1);
|
||||||
|
|
||||||
if ( set_new_provider(nProvider) )
|
if ( set_new_provider(nProvider) )
|
||||||
return curprovider;
|
return curprovider;
|
||||||
|
@ -553,18 +553,32 @@ _FindMP3s(void)
|
||||||
bool8 bInitFirstEntry;
|
bool8 bInitFirstEntry;
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
char filepath[MAX_PATH*2];
|
|
||||||
int total_ms;
|
int total_ms;
|
||||||
WIN32_FIND_DATA fd;
|
WIN32_FIND_DATA fd;
|
||||||
|
char filepath[MAX_PATH + sizeof(fd.cFileName)];
|
||||||
|
|
||||||
if (getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) {
|
if (getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) {
|
||||||
perror("getcwd: ");
|
perror("getcwd: ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen(_mp3DirectoryPath) + 1 > MAX_PATH - 10) {
|
||||||
|
// This is not gonna end well
|
||||||
|
printf("MP3 folder path is too long, no place left for file names. MP3 finding aborted.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OutputDebugString("Finding MP3s...");
|
OutputDebugString("Finding MP3s...");
|
||||||
strcpy(path, _mp3DirectoryPath);
|
strcpy(path, _mp3DirectoryPath);
|
||||||
strcat(path, "\\MP3\\");
|
strcat(path, "\\MP3\\");
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
char *actualPath = casepath(path);
|
||||||
|
if (actualPath) {
|
||||||
|
strcpy(path, actualPath);
|
||||||
|
free(actualPath);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
strcpy(_mp3DirectoryPath, path);
|
strcpy(_mp3DirectoryPath, path);
|
||||||
OutputDebugString(_mp3DirectoryPath);
|
OutputDebugString(_mp3DirectoryPath);
|
||||||
|
@ -577,92 +591,32 @@ _FindMP3s(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(filepath, _mp3DirectoryPath);
|
|
||||||
strcat(filepath, fd.cFileName);
|
|
||||||
|
|
||||||
size_t filepathlen = strlen(filepath);
|
|
||||||
|
|
||||||
if ( filepathlen <= 0)
|
|
||||||
{
|
|
||||||
FindClose(hFind);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( _ResolveLink(filepath, filepath) )
|
bShortcut = FALSE;
|
||||||
{
|
bInitFirstEntry = TRUE;
|
||||||
OutputDebugString("Resolving Link");
|
|
||||||
OutputDebugString(filepath);
|
|
||||||
bShortcut = TRUE;
|
|
||||||
} else
|
|
||||||
bShortcut = FALSE;
|
|
||||||
|
|
||||||
if (aStream[0] && aStream[0]->Open(filepath))
|
|
||||||
{
|
|
||||||
total_ms = aStream[0]->GetLengthMS();
|
|
||||||
aStream[0]->Close();
|
|
||||||
|
|
||||||
OutputDebugString(fd.cFileName);
|
do
|
||||||
|
{
|
||||||
_pMP3List = new tMP3Entry;
|
strcpy(filepath, _mp3DirectoryPath);
|
||||||
|
strcat(filepath, fd.cFileName);
|
||||||
if ( _pMP3List == NULL )
|
|
||||||
{
|
if (!strcmp(fd.cFileName, ".") || !strcmp(fd.cFileName, ".."))
|
||||||
FindClose(hFind);
|
continue;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nNumMP3s = 1;
|
|
||||||
|
|
||||||
strcpy(_pMP3List->aFilename, fd.cFileName);
|
|
||||||
|
|
||||||
_pMP3List->nTrackLength = total_ms;
|
|
||||||
|
|
||||||
_pMP3List->pNext = NULL;
|
|
||||||
|
|
||||||
pList = _pMP3List;
|
|
||||||
|
|
||||||
if ( bShortcut )
|
|
||||||
{
|
|
||||||
_pMP3List->pLinkPath = new char[MAX_PATH*2];
|
|
||||||
strcpy(_pMP3List->pLinkPath, filepath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_pMP3List->pLinkPath = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bInitFirstEntry = FALSE;
|
size_t filepathlen = strlen(filepath);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat(filepath, " - NOT A VALID MP3");
|
|
||||||
|
|
||||||
OutputDebugString(filepath);
|
|
||||||
|
|
||||||
bInitFirstEntry = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( TRUE )
|
|
||||||
{
|
|
||||||
if ( !FindNextFile(hFind, &fd) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
if ( bInitFirstEntry )
|
if ( bInitFirstEntry )
|
||||||
{
|
{
|
||||||
strcpy(filepath, _mp3DirectoryPath);
|
if (filepathlen > 0)
|
||||||
strcat(filepath, fd.cFileName);
|
|
||||||
|
|
||||||
size_t filepathlen = strlen(filepath);
|
|
||||||
|
|
||||||
if ( filepathlen > 0 )
|
|
||||||
{
|
{
|
||||||
if ( _ResolveLink(filepath, filepath) )
|
if (_ResolveLink(filepath, filepath))
|
||||||
{
|
{
|
||||||
OutputDebugString("Resolving Link");
|
OutputDebugString("Resolving Link");
|
||||||
OutputDebugString(filepath);
|
OutputDebugString(filepath);
|
||||||
bShortcut = TRUE;
|
bShortcut = TRUE;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
bShortcut = FALSE;
|
bShortcut = FALSE;
|
||||||
if (filepathlen > MAX_PATH) {
|
if (filepathlen > MAX_PATH) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -674,29 +628,29 @@ _FindMP3s(void)
|
||||||
aStream[0]->Close();
|
aStream[0]->Close();
|
||||||
|
|
||||||
OutputDebugString(fd.cFileName);
|
OutputDebugString(fd.cFileName);
|
||||||
|
|
||||||
_pMP3List = new tMP3Entry;
|
_pMP3List = new tMP3Entry;
|
||||||
|
|
||||||
if ( _pMP3List == NULL)
|
if (_pMP3List == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
nNumMP3s = 1;
|
nNumMP3s = 1;
|
||||||
|
|
||||||
strcpy(_pMP3List->aFilename, fd.cFileName);
|
strcpy(_pMP3List->aFilename, fd.cFileName);
|
||||||
|
|
||||||
_pMP3List->nTrackLength = total_ms;
|
_pMP3List->nTrackLength = total_ms;
|
||||||
_pMP3List->pNext = NULL;
|
_pMP3List->pNext = NULL;
|
||||||
|
|
||||||
if ( bShortcut )
|
if (bShortcut)
|
||||||
{
|
{
|
||||||
_pMP3List->pLinkPath = new char [MAX_PATH*2];
|
_pMP3List->pLinkPath = new char[MAX_PATH + sizeof(fd.cFileName)];
|
||||||
strcpy(_pMP3List->pLinkPath, filepath);
|
strcpy(_pMP3List->pLinkPath, filepath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pMP3List->pLinkPath = NULL;
|
_pMP3List->pLinkPath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pList = _pMP3List;
|
pList = _pMP3List;
|
||||||
|
|
||||||
bInitFirstEntry = FALSE;
|
bInitFirstEntry = FALSE;
|
||||||
|
@ -707,14 +661,11 @@ _FindMP3s(void)
|
||||||
OutputDebugString(filepath);
|
OutputDebugString(filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(filepath, _mp3DirectoryPath);
|
|
||||||
strcat(filepath, fd.cFileName);
|
|
||||||
|
|
||||||
size_t filepathlen = strlen(filepath);
|
|
||||||
|
|
||||||
if ( filepathlen > 0 )
|
if ( filepathlen > 0 )
|
||||||
{
|
{
|
||||||
if ( _ResolveLink(filepath, filepath) )
|
if ( _ResolveLink(filepath, filepath) )
|
||||||
|
@ -722,7 +673,8 @@ _FindMP3s(void)
|
||||||
OutputDebugString("Resolving Link");
|
OutputDebugString("Resolving Link");
|
||||||
OutputDebugString(filepath);
|
OutputDebugString(filepath);
|
||||||
bShortcut = TRUE;
|
bShortcut = TRUE;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
bShortcut = FALSE;
|
bShortcut = FALSE;
|
||||||
|
|
||||||
if (aStream[0] && aStream[0]->Open(filepath))
|
if (aStream[0] && aStream[0]->Open(filepath))
|
||||||
|
@ -747,7 +699,7 @@ _FindMP3s(void)
|
||||||
|
|
||||||
if ( bShortcut )
|
if ( bShortcut )
|
||||||
{
|
{
|
||||||
e->pLinkPath = new char [MAX_PATH*2];
|
e->pLinkPath = new char [MAX_PATH + sizeof(fd.cFileName)];
|
||||||
strcpy(e->pLinkPath, filepath);
|
strcpy(e->pLinkPath, filepath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -766,7 +718,7 @@ _FindMP3s(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (FindNextFile(hFind, &fd));
|
||||||
|
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
}
|
}
|
||||||
|
@ -1386,14 +1338,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
|
||||||
{
|
{
|
||||||
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
|
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
|
||||||
|
|
||||||
int8 slot;
|
|
||||||
|
|
||||||
for ( int32 i = 0; i < _TODOCONST(3); i++ )
|
for ( int32 i = 0; i < _TODOCONST(3); i++ )
|
||||||
{
|
{
|
||||||
slot = nCurrentPedSlot - i - 1;
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
|
int8 slot = (int8)nCurrentPedSlot - i - 1;
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
slot += ARRAY_SIZE(nPedSlotSfx);
|
slot += ARRAY_SIZE(nPedSlotSfx);
|
||||||
|
#else
|
||||||
|
uint8 slot = nCurrentPedSlot - i - 1;
|
||||||
#endif
|
#endif
|
||||||
if ( nComment == nPedSlotSfx[slot] )
|
if ( nComment == nPedSlotSfx[slot] )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1406,14 +1358,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
|
||||||
int32
|
int32
|
||||||
cSampleManager::_GetPedCommentSlot(uint32 nComment)
|
cSampleManager::_GetPedCommentSlot(uint32 nComment)
|
||||||
{
|
{
|
||||||
int8 slot;
|
|
||||||
|
|
||||||
for (int32 i = 0; i < _TODOCONST(3); i++)
|
for (int32 i = 0; i < _TODOCONST(3); i++)
|
||||||
{
|
{
|
||||||
slot = nCurrentPedSlot - i - 1;
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
|
int8 slot = (int8)nCurrentPedSlot - i - 1;
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
slot += ARRAY_SIZE(nPedSlotSfx);
|
slot += ARRAY_SIZE(nPedSlotSfx);
|
||||||
|
#else
|
||||||
|
uint8 slot = nCurrentPedSlot - i - 1;
|
||||||
#endif
|
#endif
|
||||||
if (nComment == nPedSlotSfx[slot])
|
if (nComment == nPedSlotSfx[slot])
|
||||||
return slot;
|
return slot;
|
||||||
|
@ -1537,7 +1489,7 @@ bool8 cSampleManager::UpdateReverb(void)
|
||||||
#undef CALCULATE_RATIO
|
#undef CALCULATE_RATIO
|
||||||
#undef MIN_DIST
|
#undef MIN_DIST
|
||||||
|
|
||||||
fRatio = clamp(fRatio, 0.0f, 0.6f);
|
fRatio = Clamp(fRatio, 0.0f, 0.6f);
|
||||||
|
|
||||||
if ( fRatio == _fPrevEaxRatioDestination )
|
if ( fRatio == _fPrevEaxRatioDestination )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "CarCtrl.h"
|
#include "CarCtrl.h"
|
||||||
#include "Curves.h"
|
#include "Curves.h"
|
||||||
#include "PathFind.h"
|
#include "PathFind.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
void CAutoPilot::ModifySpeed(float speed)
|
void CAutoPilot::ModifySpeed(float speed)
|
||||||
{
|
{
|
||||||
|
@ -92,43 +93,44 @@ void CAutoPilot::Save(uint8*& buf)
|
||||||
|
|
||||||
void CAutoPilot::Load(uint8*& buf)
|
void CAutoPilot::Load(uint8*& buf)
|
||||||
{
|
{
|
||||||
m_nCurrentRouteNode = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nCurrentRouteNode, buf);
|
||||||
m_nNextRouteNode = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nNextRouteNode, buf);
|
||||||
m_nPrevRouteNode = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nPrevRouteNode, buf);
|
||||||
m_nTimeEnteredCurve = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nTimeEnteredCurve, buf);
|
||||||
m_nTimeToSpendOnCurrentCurve = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nTimeToSpendOnCurrentCurve, buf);
|
||||||
m_nCurrentPathNodeInfo = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nCurrentPathNodeInfo, buf);
|
||||||
m_nNextPathNodeInfo = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nNextPathNodeInfo, buf);
|
||||||
m_nPreviousPathNodeInfo = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nPreviousPathNodeInfo, buf);
|
||||||
m_nAntiReverseTimer = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nAntiReverseTimer, buf);
|
||||||
m_nTimeToStartMission = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nTimeToStartMission, buf);
|
||||||
m_nPreviousDirection = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_nPreviousDirection, buf);
|
||||||
m_nCurrentDirection = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_nCurrentDirection, buf);
|
||||||
m_nNextDirection = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_nNextDirection, buf);
|
||||||
m_nCurrentLane = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_nCurrentLane, buf);
|
||||||
m_nNextLane = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_nNextLane, buf);
|
||||||
m_nDrivingStyle = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&m_nDrivingStyle, buf);
|
||||||
m_nCarMission = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&m_nCarMission, buf);
|
||||||
m_nTempAction = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&m_nTempAction, buf);
|
||||||
m_nTimeTempAction = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nTimeTempAction, buf);
|
||||||
m_fMaxTrafficSpeed = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_fMaxTrafficSpeed, buf);
|
||||||
m_nCruiseSpeed = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&m_nCruiseSpeed, buf);
|
||||||
m_nCruiseSpeedMultiplierType = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&m_nCruiseSpeedMultiplierType, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
m_fCruiseSpeedMultiplier = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_fCruiseSpeedMultiplier, buf);
|
||||||
uint8 flags = ReadSaveBuf<uint8>(buf);
|
uint8 flags;
|
||||||
|
ReadSaveBuf(&flags, buf);
|
||||||
m_bSlowedDownBecauseOfCars = !!(flags & BIT(0));
|
m_bSlowedDownBecauseOfCars = !!(flags & BIT(0));
|
||||||
m_bSlowedDownBecauseOfPeds = !!(flags & BIT(1));
|
m_bSlowedDownBecauseOfPeds = !!(flags & BIT(1));
|
||||||
m_bStayInCurrentLevel = !!(flags & BIT(2));
|
m_bStayInCurrentLevel = !!(flags & BIT(2));
|
||||||
m_bStayInFastLane = !!(flags & BIT(3));
|
m_bStayInFastLane = !!(flags & BIT(3));
|
||||||
m_bIgnorePathfinding = !!(flags & BIT(4));
|
m_bIgnorePathfinding = !!(flags & BIT(4));
|
||||||
m_nSwitchDistance = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&m_nSwitchDistance, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
m_vecDestinationCoors.x = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_vecDestinationCoors.x, buf);
|
||||||
m_vecDestinationCoors.y = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_vecDestinationCoors.y, buf);
|
||||||
m_vecDestinationCoors.z = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_vecDestinationCoors.z, buf);
|
||||||
SkipSaveBuf(buf, 32);
|
SkipSaveBuf(buf, 32);
|
||||||
m_nPathFindNodesCount = ReadSaveBuf<int16>(buf);
|
ReadSaveBuf(&m_nPathFindNodesCount, buf);
|
||||||
SkipSaveBuf(buf, 6);
|
SkipSaveBuf(buf, 6);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -2608,7 +2608,7 @@ void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CVehicle* pVehicle, float
|
||||||
float angleToTarget = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
float angleToTarget = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
|
||||||
float angleForward = GetATanOfXY(forward.x, forward.y);
|
float angleForward = GetATanOfXY(forward.x, forward.y);
|
||||||
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
|
||||||
steerAngle = clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE);
|
steerAngle = Clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE);
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
float speedTarget = pVehicle->AutoPilot.GetCruiseSpeed();
|
float speedTarget = pVehicle->AutoPilot.GetCruiseSpeed();
|
||||||
#else
|
#else
|
||||||
|
@ -2768,7 +2768,7 @@ void CCarCtrl::SteerAIPlaneTowardsTargetCoors(CAutomobile* pPlane)
|
||||||
{
|
{
|
||||||
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
|
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
|
||||||
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
|
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
|
||||||
fForwardZ = clamp(fForwardZ, -0.3f, 0.3f);
|
fForwardZ = Clamp(fForwardZ, -0.3f, 0.3f);
|
||||||
float angle = GetATanOfXY(vecToTarget.x, vecToTarget.y);
|
float angle = GetATanOfXY(vecToTarget.x, vecToTarget.y);
|
||||||
while (angle > TWOPI)
|
while (angle > TWOPI)
|
||||||
angle -= TWOPI;
|
angle -= TWOPI;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "Automobile.h"
|
#include "Automobile.h"
|
||||||
#include "MBlur.h"
|
#include "MBlur.h"
|
||||||
#include "screendroplets.h"
|
#include "screendroplets.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
uint8 CGameLogic::ActivePlayers;
|
uint8 CGameLogic::ActivePlayers;
|
||||||
uint8 CGameLogic::ShortCutState;
|
uint8 CGameLogic::ShortCutState;
|
||||||
|
@ -612,12 +613,12 @@ void
|
||||||
CGameLogic::Load(uint8* buf, uint32 size)
|
CGameLogic::Load(uint8* buf, uint32 size)
|
||||||
{
|
{
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
NumAfterDeathStartPoints = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&NumAfterDeathStartPoints, buf);
|
||||||
for (int i = 0; i < NUM_SHORTCUT_START_POINTS; i++) {
|
for (int i = 0; i < NUM_SHORTCUT_START_POINTS; i++) {
|
||||||
AfterDeathStartPoints[i].x = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&AfterDeathStartPoints[i].x, buf);
|
||||||
AfterDeathStartPoints[i].y = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&AfterDeathStartPoints[i].y, buf);
|
||||||
AfterDeathStartPoints[i].z = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&AfterDeathStartPoints[i].z, buf);
|
||||||
AfterDeathStartPointOrientation[i] = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&AfterDeathStartPointOrientation[i], buf);
|
||||||
}
|
}
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "Wanted.h"
|
#include "Wanted.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "VarConsole.h"
|
#include "VarConsole.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
#define CRUSHER_GARAGE_X1 (1135.5f)
|
#define CRUSHER_GARAGE_X1 (1135.5f)
|
||||||
#define CRUSHER_GARAGE_Y1 (57.0f)
|
#define CRUSHER_GARAGE_Y1 (57.0f)
|
||||||
|
@ -2650,22 +2651,25 @@ void CGarages::Load(uint8* buf, uint32 size)
|
||||||
assert(size == 10692);
|
assert(size == 10692);
|
||||||
//assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)));
|
//assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)));
|
||||||
CloseHideOutGaragesBeforeSave();
|
CloseHideOutGaragesBeforeSave();
|
||||||
NumGarages = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&NumGarages, buf);
|
||||||
BombsAreFree = ReadSaveBuf<uint32>(buf);
|
int32 tempInt;
|
||||||
RespraysAreFree = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&tempInt, buf);
|
||||||
CarsCollected = ReadSaveBuf<int32>(buf);
|
BombsAreFree = tempInt ? true : false;
|
||||||
BankVansCollected = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&tempInt, buf);
|
||||||
PoliceCarsCollected = ReadSaveBuf<int32>(buf);
|
RespraysAreFree = tempInt ? true : false;
|
||||||
|
ReadSaveBuf(&CarsCollected, buf);
|
||||||
|
ReadSaveBuf(&BankVansCollected, buf);
|
||||||
|
ReadSaveBuf(&PoliceCarsCollected, buf);
|
||||||
for (int i = 0; i < TOTAL_COLLECTCARS_GARAGES; i++)
|
for (int i = 0; i < TOTAL_COLLECTCARS_GARAGES; i++)
|
||||||
CarTypesCollected[i] = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&CarTypesCollected[i], buf);
|
||||||
LastTimeHelpMessage = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&LastTimeHelpMessage, buf);
|
||||||
for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) {
|
for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) {
|
||||||
for (int j = 0; j < TOTAL_HIDEOUT_GARAGES; j++) {
|
for (int j = 0; j < TOTAL_HIDEOUT_GARAGES; j++) {
|
||||||
aCarsInSafeHouses[j][i] = ReadSaveBuf<CStoredCar>(buf);
|
ReadSaveBuf(&aCarsInSafeHouses[j][i], buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < NUM_GARAGES; i++) {
|
for (int i = 0; i < NUM_GARAGES; i++) {
|
||||||
aGarages[i] = ReadSaveBuf<CGarage>(buf);
|
ReadSaveBuf(&aGarages[i], buf);
|
||||||
aGarages[i].m_pDoor1 = nil;
|
aGarages[i].m_pDoor1 = nil;
|
||||||
aGarages[i].m_pDoor2 = nil;
|
aGarages[i].m_pDoor2 = nil;
|
||||||
aGarages[i].m_pTarget = nil;
|
aGarages[i].m_pTarget = nil;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "RpAnimBlend.h"
|
#include "RpAnimBlend.h"
|
||||||
#include "AnimBlendAssociation.h"
|
#include "AnimBlendAssociation.h"
|
||||||
#include "soundlist.h"
|
#include "soundlist.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
#include "Replay.h"
|
#include "Replay.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -197,10 +198,10 @@ void
|
||||||
CPhoneInfo::Load(uint8 *buf, uint32 size)
|
CPhoneInfo::Load(uint8 *buf, uint32 size)
|
||||||
{
|
{
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
m_nMax = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nMax, buf);
|
||||||
m_nScriptPhonesMax = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nScriptPhonesMax, buf);
|
||||||
for (int i = 0; i < NUMPHONES; i++) {
|
for (int i = 0; i < NUMPHONES; i++) {
|
||||||
m_aPhones[i] = ReadSaveBuf<CPhone>(buf);
|
ReadSaveBuf(&m_aPhones[i], buf);
|
||||||
// It's saved as building pool index in save file, convert it to true entity
|
// It's saved as building pool index in save file, convert it to true entity
|
||||||
if (m_aPhones[i].m_pEntity) {
|
if (m_aPhones[i].m_pEntity) {
|
||||||
m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1);
|
m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "Hud.h"
|
#include "Hud.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
CPickup CPickups::aPickUps[NUMPICKUPS];
|
CPickup CPickups::aPickUps[NUMPICKUPS];
|
||||||
int16 CPickups::NumMessages;
|
int16 CPickups::NumMessages;
|
||||||
|
@ -1441,7 +1442,7 @@ CPickups::Load(uint8 *buf, uint32 size)
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
|
|
||||||
for (int32 i = 0; i < NUMPICKUPS; i++) {
|
for (int32 i = 0; i < NUMPICKUPS; i++) {
|
||||||
aPickUps[i] = ReadSaveBuf<CPickup>(buf);
|
ReadSaveBuf(&aPickUps[i], buf);
|
||||||
|
|
||||||
if (aPickUps[i].m_eType != PICKUP_NONE) {
|
if (aPickUps[i].m_eType != PICKUP_NONE) {
|
||||||
if (aPickUps[i].m_pObject != nil)
|
if (aPickUps[i].m_pObject != nil)
|
||||||
|
@ -1452,12 +1453,12 @@ INITSAVEBUF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CollectedPickUpIndex = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&CollectedPickUpIndex, buf);
|
||||||
ReadSaveBuf<uint16>(buf);
|
SkipSaveBuf(buf, 2);
|
||||||
NumMessages = 0;
|
NumMessages = 0;
|
||||||
|
|
||||||
for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++)
|
for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++)
|
||||||
aPickUpsCollected[i] = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&aPickUpsCollected[i], buf);
|
||||||
|
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,9 +425,9 @@ void CReplay::RecordParticle(tParticleType type, const CVector& vecPos, const CV
|
||||||
pp->pos_x = 4.0f * vecPos.x;
|
pp->pos_x = 4.0f * vecPos.x;
|
||||||
pp->pos_y = 4.0f * vecPos.y;
|
pp->pos_y = 4.0f * vecPos.y;
|
||||||
pp->pos_z = 4.0f * vecPos.z;
|
pp->pos_z = 4.0f * vecPos.z;
|
||||||
pp->dir_x = 120.0f * clamp(vecDir.x, -1.0f, 1.0f);
|
pp->dir_x = 120.0f * Clamp(vecDir.x, -1.0f, 1.0f);
|
||||||
pp->dir_y = 120.0f * clamp(vecDir.y, -1.0f, 1.0f);
|
pp->dir_y = 120.0f * Clamp(vecDir.y, -1.0f, 1.0f);
|
||||||
pp->dir_z = 120.0f * clamp(vecDir.z, -1.0f, 1.0f);
|
pp->dir_z = 120.0f * Clamp(vecDir.z, -1.0f, 1.0f);
|
||||||
pp->size = fSize;
|
pp->size = fSize;
|
||||||
pp->r = color.red;
|
pp->r = color.red;
|
||||||
pp->g = color.green;
|
pp->g = color.green;
|
||||||
|
@ -463,8 +463,8 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
|
||||||
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
|
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
|
||||||
if (main){
|
if (main){
|
||||||
state->animId = main->animId;
|
state->animId = main->animId;
|
||||||
state->time = 255.0f / 4.0f * clamp(main->currentTime, 0.0f, 4.0f);
|
state->time = 255.0f / 4.0f * Clamp(main->currentTime, 0.0f, 4.0f);
|
||||||
state->speed = 255.0f / 3.0f * clamp(main->speed, 0.0f, 3.0f);
|
state->speed = 255.0f / 3.0f * Clamp(main->speed, 0.0f, 3.0f);
|
||||||
state->groupId = main->groupId;
|
state->groupId = main->groupId;
|
||||||
}else{
|
}else{
|
||||||
state->animId = 3;
|
state->animId = 3;
|
||||||
|
@ -474,9 +474,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
|
||||||
}
|
}
|
||||||
if (second) {
|
if (second) {
|
||||||
state->secAnimId = second->animId;
|
state->secAnimId = second->animId;
|
||||||
state->secTime = 255.0f / 4.0f * clamp(second->currentTime, 0.0f, 4.0f);
|
state->secTime = 255.0f / 4.0f * Clamp(second->currentTime, 0.0f, 4.0f);
|
||||||
state->secSpeed = 255.0f / 3.0f * clamp(second->speed, 0.0f, 3.0f);
|
state->secSpeed = 255.0f / 3.0f * Clamp(second->speed, 0.0f, 3.0f);
|
||||||
state->blendAmount = 255.0f / 2.0f * clamp(blend_amount, 0.0f, 2.0f);
|
state->blendAmount = 255.0f / 2.0f * Clamp(blend_amount, 0.0f, 2.0f);
|
||||||
state->secGroupId = second->groupId;
|
state->secGroupId = second->groupId;
|
||||||
}else{
|
}else{
|
||||||
state->secAnimId = 0;
|
state->secAnimId = 0;
|
||||||
|
@ -488,9 +488,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
|
||||||
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
|
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
|
||||||
if (partial) {
|
if (partial) {
|
||||||
state->partAnimId = partial->animId;
|
state->partAnimId = partial->animId;
|
||||||
state->partAnimTime = 255.0f / 4.0f * clamp(partial->currentTime, 0.0f, 4.0f);
|
state->partAnimTime = 255.0f / 4.0f * Clamp(partial->currentTime, 0.0f, 4.0f);
|
||||||
state->partAnimSpeed = 255.0f / 3.0f * clamp(partial->speed, 0.0f, 3.0f);
|
state->partAnimSpeed = 255.0f / 3.0f * Clamp(partial->speed, 0.0f, 3.0f);
|
||||||
state->partBlendAmount = 255.0f / 2.0f * clamp(partial->blendAmount, 0.0f, 2.0f);
|
state->partBlendAmount = 255.0f / 2.0f * Clamp(partial->blendAmount, 0.0f, 2.0f);
|
||||||
state->partGroupId = partial->groupId;
|
state->partGroupId = partial->groupId;
|
||||||
}else{
|
}else{
|
||||||
state->partAnimId = 0;
|
state->partAnimId = 0;
|
||||||
|
@ -507,10 +507,10 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
|
||||||
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i);
|
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i);
|
||||||
if (assoc){
|
if (assoc){
|
||||||
state->aAnimId[i] = assoc->animId;
|
state->aAnimId[i] = assoc->animId;
|
||||||
state->aCurTime[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
|
state->aCurTime[i] = 255.0f / 4.0f * Clamp(assoc->currentTime, 0.0f, 4.0f);
|
||||||
state->aSpeed[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
|
state->aSpeed[i] = 255.0f / 3.0f * Clamp(assoc->speed, 0.0f, 3.0f);
|
||||||
state->aBlendAmount[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
|
state->aBlendAmount[i] = 255.0f / 2.0f * Clamp(assoc->blendAmount, 0.0f, 2.0f);
|
||||||
state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
state->aBlendDelta[i] = 127.0f / 32.0f * Clamp(assoc->blendDelta, -16.0f, 16.0f);
|
||||||
state->aFlags[i] = assoc->flags;
|
state->aFlags[i] = assoc->flags;
|
||||||
state->aGroupId[i] = assoc->groupId;
|
state->aGroupId[i] = assoc->groupId;
|
||||||
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
||||||
|
@ -533,10 +533,10 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
|
||||||
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i);
|
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i);
|
||||||
if (assoc) {
|
if (assoc) {
|
||||||
state->aAnimId2[i] = assoc->animId;
|
state->aAnimId2[i] = assoc->animId;
|
||||||
state->aCurTime2[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
|
state->aCurTime2[i] = 255.0f / 4.0f * Clamp(assoc->currentTime, 0.0f, 4.0f);
|
||||||
state->aSpeed2[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
|
state->aSpeed2[i] = 255.0f / 3.0f * Clamp(assoc->speed, 0.0f, 3.0f);
|
||||||
state->aBlendAmount2[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
|
state->aBlendAmount2[i] = 255.0f / 2.0f * Clamp(assoc->blendAmount, 0.0f, 2.0f);
|
||||||
state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
state->aBlendDelta2[i] = 127.0f / 16.0f * Clamp(assoc->blendDelta, -16.0f, 16.0f);
|
||||||
state->aFlags2[i] = assoc->flags;
|
state->aFlags2[i] = assoc->flags;
|
||||||
state->aGroupId2[i] = assoc->groupId;
|
state->aGroupId2[i] = assoc->groupId;
|
||||||
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "Restart.h"
|
#include "Restart.h"
|
||||||
#include "Zones.h"
|
#include "Zones.h"
|
||||||
#include "PathFind.h"
|
#include "PathFind.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
uint8 CRestart::OverrideHospitalLevel;
|
uint8 CRestart::OverrideHospitalLevel;
|
||||||
uint8 CRestart::OverridePoliceStationLevel;
|
uint8 CRestart::OverridePoliceStationLevel;
|
||||||
|
@ -173,29 +174,28 @@ INITSAVEBUF
|
||||||
CheckSaveHeader(buf, 'R','S','T','\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buf, 'R','S','T','\0', size - SAVE_HEADER_SIZE);
|
||||||
|
|
||||||
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
|
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
|
||||||
HospitalRestartPoints[i] = ReadSaveBuf<CVector>(buf);
|
ReadSaveBuf(&HospitalRestartPoints[i], buf);
|
||||||
HospitalRestartHeadings[i] = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&HospitalRestartHeadings[i], buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
|
for (int i = 0; i < NUM_RESTART_POINTS; i++) {
|
||||||
PoliceRestartPoints[i] = ReadSaveBuf<CVector>(buf);
|
ReadSaveBuf(&PoliceRestartPoints[i], buf);
|
||||||
PoliceRestartHeadings[i] = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&PoliceRestartHeadings[i], buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberOfHospitalRestarts = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&NumberOfHospitalRestarts, buf);
|
||||||
NumberOfPoliceRestarts = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&NumberOfPoliceRestarts, buf);
|
||||||
bOverrideRestart = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&bOverrideRestart, buf);
|
||||||
|
|
||||||
// skip something unused
|
// skip something unused
|
||||||
ReadSaveBuf<uint8>(buf);
|
SkipSaveBuf(buf, 3);
|
||||||
ReadSaveBuf<uint16>(buf);
|
|
||||||
|
|
||||||
OverridePosition = ReadSaveBuf<CVector>(buf);
|
ReadSaveBuf(&OverridePosition, buf);
|
||||||
OverrideHeading = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&OverrideHeading, buf);
|
||||||
bFadeInAfterNextDeath = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&bFadeInAfterNextDeath, buf);
|
||||||
bFadeInAfterNextArrest = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&bFadeInAfterNextArrest, buf);
|
||||||
OverrideHospitalLevel = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&OverrideHospitalLevel, buf);
|
||||||
OverridePoliceStationLevel = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&OverridePoliceStationLevel, buf);
|
||||||
VALIDATESAVEBUF(size);
|
VALIDATESAVEBUF(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -744,7 +744,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
|
||||||
CollectParameters(&m_nIp, 2);
|
CollectParameters(&m_nIp, 2);
|
||||||
CPlayerPed* pPlayerPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
|
CPlayerPed* pPlayerPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
|
||||||
script_assert(pPlayerPed);
|
script_assert(pPlayerPed);
|
||||||
pPlayerPed->m_fArmour = clamp(pPlayerPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMaxArmour);
|
pPlayerPed->m_fArmour = Clamp(pPlayerPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMaxArmour);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case COMMAND_ADD_ARMOUR_TO_CHAR:
|
case COMMAND_ADD_ARMOUR_TO_CHAR:
|
||||||
|
@ -752,7 +752,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
|
||||||
CollectParameters(&m_nIp, 2);
|
CollectParameters(&m_nIp, 2);
|
||||||
CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
|
CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
|
||||||
script_assert(pPed);
|
script_assert(pPed);
|
||||||
pPed->m_fArmour = clamp(pPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, 100.0f);
|
pPed->m_fArmour = Clamp(pPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, 100.0f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case COMMAND_OPEN_GARAGE:
|
case COMMAND_OPEN_GARAGE:
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "SpecialFX.h"
|
#include "SpecialFX.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
// LCS: file done except TODOs
|
// LCS: file done except TODOs
|
||||||
|
|
||||||
|
@ -2205,29 +2206,33 @@ bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
|
||||||
Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts
|
Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
|
||||||
uint32 varSpace = ReadSaveBuf<uint32>(buf);
|
uint32 varSpace, type, handle;
|
||||||
|
uint32 tmp;
|
||||||
|
|
||||||
|
ReadSaveBuf(&varSpace, buf);
|
||||||
if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) {
|
if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) {
|
||||||
printf("\n===================================================\nSave Game Mismatch!!!\n");
|
printf("\n===================================================\nSave Game Mismatch!!!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does
|
for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does
|
||||||
if (i < 8)
|
if (i < 8)
|
||||||
ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&ScriptSpace[i], buf);
|
||||||
else if (GetSaveVarIndex(i / 4 * 4) != -1)
|
else if (GetSaveVarIndex(i / 4 * 4) != -1)
|
||||||
ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&ScriptSpace[i], buf);
|
||||||
else
|
else
|
||||||
ReadSaveBuf<uint8>(buf);
|
SkipSaveBuf(buf, 1);
|
||||||
}
|
}
|
||||||
// everything else is... gone? TODO
|
// everything else is... gone? TODO
|
||||||
script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE);
|
ReadSaveBuf(&tmp, buf);
|
||||||
OnAMissionFlag = ReadSaveBuf<uint32>(buf);
|
script_assert(tmp == SCRIPT_DATA_SIZE);
|
||||||
LastMissionPassedTime = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&OnAMissionFlag, buf);
|
||||||
|
ReadSaveBuf(&LastMissionPassedTime, buf);
|
||||||
for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
|
for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
|
||||||
CollectiveArray[i] = ReadSaveBuf<tCollectiveData>(buf);
|
ReadSaveBuf(&CollectiveArray[i], buf);
|
||||||
NextFreeCollectiveIndex = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&NextFreeCollectiveIndex, buf);
|
||||||
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
|
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
|
||||||
uint32 type = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&type, buf);
|
||||||
uint32 handle = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&handle, buf);
|
||||||
/*
|
/*
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -2243,16 +2248,17 @@ INITSAVEBUF
|
||||||
script_assert(false);
|
script_assert(false);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/*BuildingSwapArray[i].m_nNewModel = */ReadSaveBuf<uint32>(buf);
|
/*BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);*/
|
||||||
/*BuildingSwapArray[i].m_nOldModel = */ReadSaveBuf<uint32>(buf);
|
/*BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);*/
|
||||||
|
SkipSaveBuf(buf, 8);
|
||||||
/*
|
/*
|
||||||
if (BuildingSwapArray[i].m_pBuilding)
|
if (BuildingSwapArray[i].m_pBuilding)
|
||||||
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
|
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
|
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
|
||||||
uint32 type = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&type, buf);
|
||||||
uint32 handle = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&handle, buf);
|
||||||
/*
|
/*
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -2277,14 +2283,25 @@ INITSAVEBUF
|
||||||
InvisibilitySettingArray[i]->bIsVisible = false;
|
InvisibilitySettingArray[i]->bIsVisible = false;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile);
|
bool tmpBool;
|
||||||
/*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&tmpBool, buf);
|
||||||
ReadSaveBuf<uint16>(buf);
|
script_assert(tmpBool == bUsingAMultiScriptFile);
|
||||||
script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize);
|
///*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
|
||||||
script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize);
|
//ReadSaveBuf<uint16>(buf);
|
||||||
script_assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts);
|
|
||||||
script_assert(ReadSaveBuf<uint16>(buf) == NumberOfExclusiveMissionScripts);
|
SkipSaveBuf(buf, 3);
|
||||||
uint32 runningScripts = ReadSaveBuf<uint32>(buf);
|
|
||||||
|
ReadSaveBuf(&tmp, buf);
|
||||||
|
script_assert(tmp == MainScriptSize);
|
||||||
|
ReadSaveBuf(&tmp, buf);
|
||||||
|
script_assert(tmp == LargestMissionScriptSize);
|
||||||
|
uint16 tmp16;
|
||||||
|
ReadSaveBuf(&tmp16, buf);
|
||||||
|
script_assert(tmp16 == NumberOfMissionScripts);
|
||||||
|
ReadSaveBuf(&tmp16, buf);
|
||||||
|
script_assert(tmp16 == NumberOfExclusiveMissionScripts);
|
||||||
|
uint32 runningScripts;
|
||||||
|
ReadSaveBuf(&runningScripts, buf);
|
||||||
for (uint32 i = 0; i < runningScripts; i++)
|
for (uint32 i = 0; i < runningScripts; i++)
|
||||||
CRunningScript().Load(buf);
|
CRunningScript().Load(buf);
|
||||||
StartTestScript(); // <- tmp hack
|
StartTestScript(); // <- tmp hack
|
||||||
|
@ -2335,38 +2352,38 @@ void CRunningScript::Load(uint8*& buf)
|
||||||
{
|
{
|
||||||
#ifdef COMPATIBLE_SAVES
|
#ifdef COMPATIBLE_SAVES
|
||||||
SkipSaveBuf(buf, 8);
|
SkipSaveBuf(buf, 8);
|
||||||
m_nId = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nId, buf);
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
m_abScriptName[i] = ReadSaveBuf<char>(buf);
|
ReadSaveBuf(&m_abScriptName[i], buf);
|
||||||
m_nIp = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nIp, buf);
|
||||||
#ifdef CHECK_STRUCT_SIZES
|
#ifdef CHECK_STRUCT_SIZES
|
||||||
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
|
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < MAX_STACK_DEPTH; i++)
|
for (int i = 0; i < MAX_STACK_DEPTH; i++)
|
||||||
m_anStack[i] = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_anStack[i], buf);
|
||||||
m_nStackPointer = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&m_nStackPointer, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
#ifdef CHECK_STRUCT_SIZES
|
#ifdef CHECK_STRUCT_SIZES
|
||||||
static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106");
|
static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106");
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
|
for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
|
||||||
m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_anLocalVariables[i], buf);
|
||||||
m_nLocalsPointer = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&m_nLocalsPointer, buf);
|
||||||
m_bIsActive = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bIsActive, buf);
|
||||||
m_bCondResult = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bCondResult, buf);
|
||||||
m_bIsMissionScript = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bIsMissionScript, buf);
|
||||||
m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bSkipWakeTime, buf);
|
||||||
m_nWakeTime = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nWakeTime, buf);
|
||||||
m_nAndOrState = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&m_nAndOrState, buf);
|
||||||
m_bNotFlag = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bNotFlag, buf);
|
||||||
m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bDeatharrestEnabled, buf);
|
||||||
m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bDeatharrestExecuted, buf);
|
||||||
m_bMissionFlag = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&m_bMissionFlag, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
#else
|
#else
|
||||||
CRunningScript* n = next;
|
CRunningScript* n = next;
|
||||||
CRunningScript* p = prev;
|
CRunningScript* p = prev;
|
||||||
*this = ReadSaveBuf<CRunningScript>(buf);
|
ReadSaveBuf(this, buf);
|
||||||
next = n;
|
next = n;
|
||||||
prev = p;
|
prev = p;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "Wanted.h"
|
#include "Wanted.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "VarConsole.h"
|
#include "VarConsole.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
#define TIME_BETWEEN_SETPIECE_SPAWNS 20000
|
#define TIME_BETWEEN_SETPIECE_SPAWNS 20000
|
||||||
|
|
||||||
|
@ -67,9 +68,9 @@ VALIDATESAVEBUF(*size)
|
||||||
void CSetPieces::Load(uint8* buf, uint32 size)
|
void CSetPieces::Load(uint8* buf, uint32 size)
|
||||||
{
|
{
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
NumSetPieces = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&NumSetPieces, buf);
|
||||||
for (int i = 0; i < NUM_SETPIECES; i++)
|
for (int i = 0; i < NUM_SETPIECES; i++)
|
||||||
aSetPieces[i] = ReadSaveBuf<CSetPiece>(buf);
|
ReadSaveBuf(&aSetPieces[i], buf);
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
|
||||||
|
|
||||||
float ReqSpeed = DeltaBeta * SpeedMultiplier;
|
float ReqSpeed = DeltaBeta * SpeedMultiplier;
|
||||||
// this is also added
|
// this is also added
|
||||||
ReqSpeed = clamp(ReqSpeed, -SpeedLimit, SpeedLimit);
|
ReqSpeed = Clamp(ReqSpeed, -SpeedLimit, SpeedLimit);
|
||||||
|
|
||||||
// Add or subtract absolute depending on sign, genius!
|
// Add or subtract absolute depending on sign, genius!
|
||||||
if(ReqSpeed - BetaSpeed > 0.0f)
|
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;
|
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)){
|
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;
|
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)
|
if(CarAlpha < 0.0f)
|
||||||
AlphaOffset += CarAlpha;
|
AlphaOffset += CarAlpha;
|
||||||
}
|
}
|
||||||
|
@ -1832,7 +1832,7 @@ CCam::Process_Cam_On_A_String(const CVector &CameraTarget, float TargetOrientati
|
||||||
if(DeltaBeta > PI) DeltaBeta -= TWOPI;
|
if(DeltaBeta > PI) DeltaBeta -= TWOPI;
|
||||||
else if(DeltaBeta < -PI) DeltaBeta += TWOPI;
|
else if(DeltaBeta < -PI) DeltaBeta += TWOPI;
|
||||||
float dist = (TargetCoors - Source).Magnitude();
|
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));
|
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;
|
if(BetaOffset > PI) BetaOffset -= TWOPI;
|
||||||
else 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;
|
Beta = NewBeta + BetaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3275,7 +3275,7 @@ CCam::Process_BehindBoat(const CVector &CameraTarget, float TargetOrientation, f
|
||||||
// useless call
|
// useless call
|
||||||
//CWaterLevel::GetWaterLevelNoWaves(TargetCoors.x, TargetCoors.y, TargetCoors.z, &Water);
|
//CWaterLevel::GetWaterLevelNoWaves(TargetCoors.x, TargetCoors.y, TargetCoors.z, &Water);
|
||||||
Water = (WaterLevel + WATER_Z_ADDITION_MIN - WaterLevelBuffered - WATER_Z_ADDITION)/(BoatDimensions.z/2.0f + MaxHeightUp);
|
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){
|
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]);
|
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;
|
float b = 1.0f - a;
|
||||||
*out = b*b*b * spline[marker-3] +
|
*out = b*b*b * spline[marker-3] +
|
||||||
3.0f*a*b*b * spline[marker-1] +
|
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]);
|
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;
|
float b = 1.0f - a;
|
||||||
out->x =
|
out->x =
|
||||||
b*b*b * spline[marker-9] +
|
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
|
// 0.98f: CAR_FOV_FADE_MULT
|
||||||
FOV = Pow(0.98f, CTimer::GetTimeStep()) * (FOV - DefaultFOV) + DefaultFOV;
|
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)
|
// 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 <= maxAlphaAllowed) {
|
||||||
if (targetAlpha < -CARCAM_SET[camSetArrPos][14])
|
if (targetAlpha < -CARCAM_SET[camSetArrPos][14])
|
||||||
targetAlpha = -CARCAM_SET[camSetArrPos][14];
|
targetAlpha = -CARCAM_SET[camSetArrPos][14];
|
||||||
|
|
|
@ -348,7 +348,7 @@ CCamera::Process(void)
|
||||||
currentTime = m_uiTransitionDuration;
|
currentTime = m_uiTransitionDuration;
|
||||||
float fractionInter = (float) currentTime / m_uiTransitionDuration;
|
float fractionInter = (float) currentTime / m_uiTransitionDuration;
|
||||||
float fractionInterTarget = (float) currentTime / m_uiTransitionDurationTargetCoors;
|
float fractionInterTarget = (float) currentTime / m_uiTransitionDurationTargetCoors;
|
||||||
fractionInterTarget = clamp(fractionInterTarget, 0.0f, 1.0f);
|
fractionInterTarget = Clamp(fractionInterTarget, 0.0f, 1.0f);
|
||||||
|
|
||||||
// Interpolate target separately
|
// Interpolate target separately
|
||||||
if(fractionInterTarget <= m_fFractionInterToStopMovingTarget){
|
if(fractionInterTarget <= m_fFractionInterToStopMovingTarget){
|
||||||
|
@ -552,7 +552,7 @@ CCamera::Process(void)
|
||||||
|
|
||||||
// Process Shake
|
// Process Shake
|
||||||
float shakeStrength = m_fCamShakeForce - 0.28f*(CTimer::GetTimeInMilliseconds()-m_uiCamShakeStart)/1000.0f;
|
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();
|
int shakeRand = CGeneral::GetRandomNumber();
|
||||||
float shakeOffset = shakeStrength*0.1f;
|
float shakeOffset = shakeStrength*0.1f;
|
||||||
GetMatrix().GetPosition().x += shakeOffset * ((shakeRand & 0xF) - 7);
|
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);
|
float curForce = mult*(m_fCamShakeForce - (CTimer::GetTimeInMilliseconds() - m_uiCamShakeStart)/1000.0f);
|
||||||
strength = mult*strength;
|
strength = mult*strength;
|
||||||
if(clamp(curForce, 0.0f, 2.0f) < strength){
|
if(Clamp(curForce, 0.0f, 2.0f) < strength){
|
||||||
m_fCamShakeForce = strength;
|
m_fCamShakeForce = strength;
|
||||||
m_uiCamShakeStart = CTimer::GetTimeInMilliseconds();
|
m_uiCamShakeStart = CTimer::GetTimeInMilliseconds();
|
||||||
}
|
}
|
||||||
|
@ -1925,7 +1925,7 @@ void
|
||||||
CamShakeNoPos(CCamera *cam, float strength)
|
CamShakeNoPos(CCamera *cam, float strength)
|
||||||
{
|
{
|
||||||
float curForce = cam->m_fCamShakeForce - (CTimer::GetTimeInMilliseconds() - cam->m_uiCamShakeStart)/1000.0f;
|
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_fCamShakeForce = strength;
|
||||||
cam->m_uiCamShakeStart = CTimer::GetTimeInMilliseconds();
|
cam->m_uiCamShakeStart = CTimer::GetTimeInMilliseconds();
|
||||||
}
|
}
|
||||||
|
@ -3987,7 +3987,7 @@ CCamera::Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source,
|
||||||
float
|
float
|
||||||
CCamera::Find3rdPersonQuickAimPitch(void)
|
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);
|
float rot = Asin(clampedFrontZ);
|
||||||
|
|
||||||
|
|
|
@ -1147,7 +1147,7 @@ CFileLoader::Load2dEffect(const char *line)
|
||||||
&probability);
|
&probability);
|
||||||
effect->attractor.type = flags;
|
effect->attractor.type = flags;
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
effect->attractor.probability = clamp(probability, 0, 255);
|
effect->attractor.probability = Clamp(probability, 0, 255);
|
||||||
#else
|
#else
|
||||||
effect->attractor.probability = probability;
|
effect->attractor.probability = probability;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -711,27 +711,27 @@ CMenuManager::CheckSliderMovement(int value)
|
||||||
switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) {
|
switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) {
|
||||||
case MENUACTION_BRIGHTNESS:
|
case MENUACTION_BRIGHTNESS:
|
||||||
m_PrefsBrightness += value * 32.0f;
|
m_PrefsBrightness += value * 32.0f;
|
||||||
m_PrefsBrightness = clamp(m_PrefsBrightness, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
|
m_PrefsBrightness = Clamp(m_PrefsBrightness, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
|
||||||
break;
|
break;
|
||||||
case MENUACTION_DRAWDIST:
|
case MENUACTION_DRAWDIST:
|
||||||
if(value > 0)
|
if(value > 0)
|
||||||
m_PrefsLOD += ((1.8f - 0.925f) / 16.0f);
|
m_PrefsLOD += ((1.8f - 0.925f) / 16.0f);
|
||||||
else
|
else
|
||||||
m_PrefsLOD -= ((1.8f - 0.925f) / 16.0f);
|
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;
|
CRenderer::ms_lodDistScale = m_PrefsLOD;
|
||||||
break;
|
break;
|
||||||
case MENUACTION_MUSICVOLUME:
|
case MENUACTION_MUSICVOLUME:
|
||||||
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
||||||
m_PrefsMusicVolume += value * (128 / 32);
|
m_PrefsMusicVolume += value * (128 / 32);
|
||||||
m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 65);
|
m_PrefsMusicVolume = Clamp(m_PrefsMusicVolume, 0, 65);
|
||||||
DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume);
|
DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENUACTION_SFXVOLUME:
|
case MENUACTION_SFXVOLUME:
|
||||||
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
||||||
m_PrefsSfxVolume += value * (128 / 32);
|
m_PrefsSfxVolume += value * (128 / 32);
|
||||||
m_PrefsSfxVolume = clamp(m_PrefsSfxVolume, 0, 65);
|
m_PrefsSfxVolume = Clamp(m_PrefsSfxVolume, 0, 65);
|
||||||
DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume);
|
DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -739,14 +739,14 @@ CMenuManager::CheckSliderMovement(int value)
|
||||||
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
||||||
if (DMAudio.IsMP3RadioChannelAvailable()) {
|
if (DMAudio.IsMP3RadioChannelAvailable()) {
|
||||||
m_PrefsMP3BoostVolume += value * (128 / 32);
|
m_PrefsMP3BoostVolume += value * (128 / 32);
|
||||||
m_PrefsMP3BoostVolume = clamp(m_PrefsMP3BoostVolume, 0, 65);
|
m_PrefsMP3BoostVolume = Clamp(m_PrefsMP3BoostVolume, 0, 65);
|
||||||
DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume);
|
DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENUACTION_MOUSESENS:
|
case MENUACTION_MOUSESENS:
|
||||||
TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ???
|
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
|
#ifdef FIX_BUGS
|
||||||
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
|
TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl + 0.0005f;
|
||||||
#endif
|
#endif
|
||||||
|
@ -3490,8 +3490,8 @@ CMenuManager::Process(void)
|
||||||
break; \
|
break; \
|
||||||
\
|
\
|
||||||
m_fMapSize *= z2; \
|
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_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_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)
|
} while(0)
|
||||||
|
|
||||||
#endif
|
#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_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_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_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_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 {
|
} else {
|
||||||
m_fMapSize = MENU_Y(MAP_MIN_SIZE);
|
m_fMapSize = MENU_Y(MAP_MIN_SIZE);
|
||||||
}
|
}
|
||||||
|
@ -3571,8 +3571,8 @@ CMenuManager::AdditionalOptionInput(bool &goBack)
|
||||||
if (!justResetPointer) {
|
if (!justResetPointer) {
|
||||||
m_fMapCenterX += m_nMousePosX - m_nMouseOldPosX;
|
m_fMapCenterX += m_nMousePosX - m_nMouseOldPosX;
|
||||||
m_fMapCenterY += m_nMousePosY - m_nMouseOldPosY;
|
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_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_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;
|
justResetPointer = false;
|
||||||
|
|
||||||
|
@ -5068,7 +5068,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u
|
||||||
case MENUACTION_SPEAKERCONF:
|
case MENUACTION_SPEAKERCONF:
|
||||||
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) {
|
||||||
m_PrefsSpeakers -= changeAmount;
|
m_PrefsSpeakers -= changeAmount;
|
||||||
m_PrefsSpeakers = clamp(m_PrefsSpeakers, 0, 2);
|
m_PrefsSpeakers = Clamp(m_PrefsSpeakers, 0, 2);
|
||||||
DMAudio.SetSpeakerConfig(m_PrefsSpeakers);
|
DMAudio.SetSpeakerConfig(m_PrefsSpeakers);
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
@ -5679,7 +5679,7 @@ CMenuManager::DrawQuitGameScreen(void)
|
||||||
static int32 exitSignalTimer = 0;
|
static int32 exitSignalTimer = 0;
|
||||||
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
int alpha = clamp(m_nMenuFadeAlpha, 0, 255);
|
int alpha = Clamp(m_nMenuFadeAlpha, 0, 255);
|
||||||
#else
|
#else
|
||||||
int alpha = m_nMenuFadeAlpha;
|
int alpha = m_nMenuFadeAlpha;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1375,7 +1375,7 @@ CMenuManager::DrawFrontEndNormal(void)
|
||||||
if ((m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) <= 1600)
|
if ((m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) <= 1600)
|
||||||
alpha = float(m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 400.0f;
|
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 )
|
switch ( m_nSlidingDir )
|
||||||
{
|
{
|
||||||
|
@ -1392,7 +1392,7 @@ CMenuManager::DrawFrontEndNormal(void)
|
||||||
float slide = float(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 800.0f;
|
float slide = float(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 800.0f;
|
||||||
float alpha = float((int32)(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) + -266) / 533.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 )
|
switch ( m_nSlidingDir )
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
static float LimitRadianAngle(float angle)
|
static float LimitRadianAngle(float angle)
|
||||||
{
|
{
|
||||||
float result = clamp(angle, -25.0f, 25.0f);
|
float result = Clamp(angle, -25.0f, 25.0f);
|
||||||
|
|
||||||
while (result >= PI) {
|
while (result >= PI) {
|
||||||
result -= 2 * PI;
|
result -= 2 * PI;
|
||||||
|
|
|
@ -299,7 +299,7 @@ CPlayerInfo::Process(void)
|
||||||
m_fRoadDensity = ThePaths.CalcRoadDensity(playerPos.x, playerPos.y);
|
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.
|
// Because vehicle enter/exit use same key binding.
|
||||||
bool enterOrExitVeh;
|
bool enterOrExitVeh;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "Wanted.h"
|
#include "Wanted.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "MemoryHeap.h"
|
#include "MemoryHeap.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
CCPtrNodePool *CPools::ms_pPtrNodePool;
|
CCPtrNodePool *CPools::ms_pPtrNodePool;
|
||||||
CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool;
|
CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool;
|
||||||
|
@ -137,15 +138,20 @@ CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
|
||||||
void CPools::LoadVehiclePool(uint8* buf, uint32 size)
|
void CPools::LoadVehiclePool(uint8* buf, uint32 size)
|
||||||
{
|
{
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
int nNumCars = ReadSaveBuf<int>(buf);
|
int nNumCars, nNumBoats, nNumBikes;
|
||||||
int nNumBoats = ReadSaveBuf<int>(buf);
|
ReadSaveBuf(&nNumCars, buf);
|
||||||
int nNumBikes = ReadSaveBuf<int>(buf);
|
ReadSaveBuf(&nNumBoats, buf);
|
||||||
|
ReadSaveBuf(&nNumBikes, buf);
|
||||||
for (int i = 0; i < nNumCars + nNumBoats + nNumBikes; i++) {
|
for (int i = 0; i < nNumCars + nNumBoats + nNumBikes; i++) {
|
||||||
uint32 type = ReadSaveBuf<uint32>(buf);
|
uint32 type;
|
||||||
int16 model = ReadSaveBuf<int16>(buf);
|
int16 model;
|
||||||
|
int32 slot;
|
||||||
|
|
||||||
|
ReadSaveBuf(&type, buf);
|
||||||
|
ReadSaveBuf(&model, buf);
|
||||||
CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY);
|
CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY);
|
||||||
CStreaming::LoadAllRequestedModels(false);
|
CStreaming::LoadAllRequestedModels(false);
|
||||||
int32 slot = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&slot, buf);
|
||||||
CVehicle* pVehicle;
|
CVehicle* pVehicle;
|
||||||
#ifdef COMPATIBLE_SAVES
|
#ifdef COMPATIBLE_SAVES
|
||||||
if (type == VEHICLE_TYPE_BOAT)
|
if (type == VEHICLE_TYPE_BOAT)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
#include "SpecialFX.h"
|
#include "SpecialFX.h"
|
||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
float CRadar::m_radarRange;
|
float CRadar::m_radarRange;
|
||||||
sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS];
|
sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS];
|
||||||
|
@ -1028,21 +1029,21 @@ INITSAVEBUF
|
||||||
CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE);
|
||||||
|
|
||||||
for (int i = 0; i < NUMRADARBLIPS; i++) {
|
for (int i = 0; i < NUMRADARBLIPS; i++) {
|
||||||
ms_RadarTrace[i].m_nColor = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_nColor, buf);
|
||||||
ms_RadarTrace[i].m_Radius = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_Radius, buf);
|
||||||
ms_RadarTrace[i].m_eBlipType = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_eBlipType, buf);
|
||||||
ms_RadarTrace[i].m_nEntityHandle = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_nEntityHandle, buf);
|
||||||
ms_RadarTrace[i].m_vec2DPos.x = ReadSaveBuf<float>(buf); // CVector2D
|
ReadSaveBuf(&ms_RadarTrace[i].m_vec2DPos.x, buf);
|
||||||
ms_RadarTrace[i].m_vec2DPos.y = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_vec2DPos.y, buf);
|
||||||
ms_RadarTrace[i].m_vecPos = ReadSaveBuf<CVector>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_vecPos, buf);
|
||||||
ms_RadarTrace[i].m_BlipIndex = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_BlipIndex, buf);
|
||||||
ms_RadarTrace[i].m_bDim = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_bDim, buf);
|
||||||
ms_RadarTrace[i].m_bInUse = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_bInUse, buf);
|
||||||
ms_RadarTrace[i].m_bShortRange = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_bShortRange, buf);
|
||||||
ms_RadarTrace[i].m_unused = ReadSaveBuf<bool>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_unused, buf);
|
||||||
ms_RadarTrace[i].m_wScale = ReadSaveBuf<int16>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_wScale, buf);
|
||||||
ms_RadarTrace[i].m_eBlipDisplay = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_eBlipDisplay, buf);
|
||||||
ms_RadarTrace[i].m_eRadarSprite = ReadSaveBuf<uint16>(buf);
|
ReadSaveBuf(&ms_RadarTrace[i].m_eRadarSprite, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALIDATESAVEBUF(size);
|
VALIDATESAVEBUF(size);
|
||||||
|
|
|
@ -150,7 +150,7 @@ CRopes::FindCoorsAlongRope(uintptr id, float t, CVector *coors)
|
||||||
float f;
|
float f;
|
||||||
for(i = 0; i < ARRAY_SIZE(aRopes); i++)
|
for(i = 0; i < ARRAY_SIZE(aRopes); i++)
|
||||||
if(aRopes[i].m_bActive && aRopes[i].m_id == id){
|
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;
|
j = t;
|
||||||
f = t - j;
|
f = t - j;
|
||||||
*coors = (1.0f-f)*aRopes[i].m_pos[j] + f*aRopes[i].m_pos[j+1];
|
*coors = (1.0f-f)*aRopes[i].m_pos[j] + f*aRopes[i].m_pos[j+1];
|
||||||
|
|
|
@ -399,8 +399,8 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C
|
||||||
CVector point2(point1.x, point1.y, z2);
|
CVector point2(point1.x, point1.y, z2);
|
||||||
int secX = GetSectorIndexX(point1.x);
|
int secX = GetSectorIndexX(point1.x);
|
||||||
int secY = GetSectorIndexY(point1.y);
|
int secY = GetSectorIndexY(point1.y);
|
||||||
secX = clamp(secX, 0, NUMSECTORS_X-1);
|
secX = Clamp(secX, 0, NUMSECTORS_X-1);
|
||||||
secY = clamp(secY, 0, NUMSECTORS_Y-1);
|
secY = Clamp(secY, 0, NUMSECTORS_Y-1);
|
||||||
return ProcessVerticalLineSector(*GetSector(secX, secY),
|
return ProcessVerticalLineSector(*GetSector(secX, secY),
|
||||||
CColLine(point1, point2), point, entity, checkBuildings, checkVehicles,
|
CColLine(point1, point2), point, entity, checkBuildings, checkVehicles,
|
||||||
checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly);
|
checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
eLevelName CTheZones::m_CurrLevel;
|
eLevelName CTheZones::m_CurrLevel;
|
||||||
int16 CTheZones::FindIndex;
|
int16 CTheZones::FindIndex;
|
||||||
|
@ -714,11 +715,11 @@ CTheZones::SaveOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zo
|
||||||
WriteSaveBuf(*buffer, *length, zone->zoneinfoNight);
|
WriteSaveBuf(*buffer, *length, zone->zoneinfoNight);
|
||||||
|
|
||||||
int32 zoneId;
|
int32 zoneId;
|
||||||
zoneId = GetIndexForZonePointer(zone->child);
|
zoneId = GetIndexForNavigationZonePointer(zone->child);
|
||||||
WriteSaveBuf(*buffer, *length, zoneId);
|
WriteSaveBuf(*buffer, *length, zoneId);
|
||||||
zoneId = GetIndexForZonePointer(zone->parent);
|
zoneId = GetIndexForNavigationZonePointer(zone->parent);
|
||||||
WriteSaveBuf(*buffer, *length, zoneId);
|
WriteSaveBuf(*buffer, *length, zoneId);
|
||||||
zoneId = GetIndexForZonePointer(zone->next);
|
zoneId = GetIndexForNavigationZonePointer(zone->next);
|
||||||
WriteSaveBuf(*buffer, *length, zoneId);
|
WriteSaveBuf(*buffer, *length, zoneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,9 +732,9 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
|
||||||
uint32 length = 0;
|
uint32 length = 0;
|
||||||
CheckSaveHeaderWithLength(buffer, length, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeaderWithLength(buffer, length, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
|
||||||
|
|
||||||
m_CurrLevel = ReadSaveBuf<eLevelName>(buffer, length);
|
ReadSaveBuf(&m_CurrLevel, buffer);
|
||||||
FindIndex = ReadSaveBuf<int16>(buffer, length);
|
ReadSaveBuf(&FindIndex, buffer);
|
||||||
ReadSaveBuf<int16>(buffer, length);
|
SkipSaveBuf(buffer, 2);
|
||||||
|
|
||||||
for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++)
|
for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++)
|
||||||
LoadOneZone(&NavigationZoneArray[i], &buffer, &length, ZONE_NAVIG);
|
LoadOneZone(&NavigationZoneArray[i], &buffer, &length, ZONE_NAVIG);
|
||||||
|
@ -742,21 +743,21 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
|
||||||
LoadOneZone(&InfoZoneArray[i], &buffer, &length, ZONE_INFO);
|
LoadOneZone(&InfoZoneArray[i], &buffer, &length, ZONE_INFO);
|
||||||
|
|
||||||
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
|
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
|
||||||
ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer, length);
|
ReadSaveBuf(&ZoneInfoArray[i], buffer);
|
||||||
|
|
||||||
TotalNumberOfNavigationZones = ReadSaveBuf<int16>(buffer, length);
|
ReadSaveBuf(&TotalNumberOfNavigationZones, buffer);
|
||||||
TotalNumberOfInfoZones = ReadSaveBuf<int16>(buffer, length);
|
ReadSaveBuf(&TotalNumberOfInfoZones, buffer);
|
||||||
TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer, length);
|
ReadSaveBuf(&TotalNumberOfZoneInfos, buffer);
|
||||||
ReadSaveBuf<int16>(buffer, length);
|
SkipSaveBuf(buffer, 2);
|
||||||
|
|
||||||
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++)
|
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++)
|
||||||
LoadOneZone(&MapZoneArray[i], &buffer, &length, ZONE_MAPZONE);
|
LoadOneZone(&MapZoneArray[i], &buffer, &length, ZONE_MAPZONE);
|
||||||
|
|
||||||
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
|
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
|
||||||
AudioZoneArray[i] = ReadSaveBuf<int16>(buffer, length);
|
ReadSaveBuf(&AudioZoneArray[i], buffer);
|
||||||
|
|
||||||
TotalNumberOfMapZones = ReadSaveBuf<uint16>(buffer, length);
|
ReadSaveBuf(&TotalNumberOfMapZones, buffer);
|
||||||
NumberOfAudioZones = ReadSaveBuf<uint16>(buffer, length);
|
ReadSaveBuf(&NumberOfAudioZones, buffer);
|
||||||
|
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
}
|
}
|
||||||
|
@ -764,26 +765,36 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
|
||||||
void
|
void
|
||||||
CTheZones::LoadOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType)
|
CTheZones::LoadOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType)
|
||||||
{
|
{
|
||||||
*(uint32*)&zone->name[0] = ReadSaveBuf<uint32>(*buffer, *length);
|
#ifdef THIS_IS_STUPID
|
||||||
*(uint32*)&zone->name[4] = ReadSaveBuf<uint32>(*buffer, *length);
|
uint32 part1, part2;
|
||||||
|
ReadSaveBuf(&part1, *buffer, *length);
|
||||||
|
ReadSaveBuf(&part2, *buffer, *length);
|
||||||
|
|
||||||
zone->minx = ReadSaveBuf<float>(*buffer, *length);
|
*(uint64 *)&zone->name[0] = (uint64)part2;
|
||||||
zone->miny = ReadSaveBuf<float>(*buffer, *length);
|
*(uint64 *)&zone->name[0] <<= 32;
|
||||||
zone->minz = ReadSaveBuf<float>(*buffer, *length);
|
*(uint64 *)&zone->name[0] |= (uint64)part1;
|
||||||
zone->maxx = ReadSaveBuf<float>(*buffer, *length);
|
#else
|
||||||
zone->maxy = ReadSaveBuf<float>(*buffer, *length);
|
for(int i = 0; i < sizeof(zone->name); i++)
|
||||||
zone->maxz = ReadSaveBuf<float>(*buffer, *length);
|
ReadSaveBuf(&zone->name[i], *buffer, *length);
|
||||||
|
#endif
|
||||||
|
|
||||||
zone->type = ReadSaveBuf<eZoneType>(*buffer, *length);
|
ReadSaveBuf(&zone->minx, *buffer, *length);
|
||||||
zone->level = ReadSaveBuf<eLevelName>(*buffer, *length);
|
ReadSaveBuf(&zone->miny, *buffer, *length);
|
||||||
zone->zoneinfoDay = ReadSaveBuf<int16>(*buffer, *length);
|
ReadSaveBuf(&zone->minz, *buffer, *length);
|
||||||
zone->zoneinfoNight = ReadSaveBuf<int16>(*buffer, *length);
|
ReadSaveBuf(&zone->maxx, *buffer, *length);
|
||||||
|
ReadSaveBuf(&zone->maxy, *buffer, *length);
|
||||||
|
ReadSaveBuf(&zone->maxz, *buffer, *length);
|
||||||
|
|
||||||
|
ReadSaveBuf(&zone->type, *buffer, *length);
|
||||||
|
ReadSaveBuf(&zone->level, *buffer, *length);
|
||||||
|
ReadSaveBuf(&zone->zoneinfoDay, *buffer, *length);
|
||||||
|
ReadSaveBuf(&zone->zoneinfoNight, *buffer, *length);
|
||||||
|
|
||||||
int32 zoneId;
|
int32 zoneId;
|
||||||
zoneId = ReadSaveBuf<int32>(*buffer, *length);
|
ReadSaveBuf(&zoneId, *buffer, *length);
|
||||||
zone->child = GetPointerForZoneIndex(zoneId);
|
zone->child = GetPointerForNavigationZoneIndex(zoneId);
|
||||||
zoneId = ReadSaveBuf<int32>(*buffer, *length);
|
ReadSaveBuf(&zoneId, *buffer, *length);
|
||||||
zone->parent = GetPointerForZoneIndex(zoneId);
|
zone->parent = GetPointerForNavigationZoneIndex(zoneId);
|
||||||
zoneId = ReadSaveBuf<int32>(*buffer, *length);
|
ReadSaveBuf(&zoneId, *buffer, *length);
|
||||||
zone->next = GetPointerForZoneIndex(zoneId);
|
zone->next = GetPointerForNavigationZoneIndex(zoneId);
|
||||||
}
|
}
|
|
@ -103,8 +103,8 @@ public:
|
||||||
static void SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity);
|
static void SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity);
|
||||||
static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup);
|
static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup);
|
||||||
static int16 FindAudioZone(CVector *pos);
|
static int16 FindAudioZone(CVector *pos);
|
||||||
static CZone *GetPointerForZoneIndex(ssize_t i) { return i == -1 ? nil : &NavigationZoneArray[i]; }
|
static CZone *GetPointerForNavigationZoneIndex(ssize_t i) { return i == -1 ? nil : &NavigationZoneArray[i]; }
|
||||||
static ssize_t GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - NavigationZoneArray; }
|
static ssize_t GetIndexForNavigationZonePointer(CZone *zone) { return zone == nil ? -1 : zone - NavigationZoneArray; }
|
||||||
static void AddZoneToAudioZoneArray(CZone *zone);
|
static void AddZoneToAudioZoneArray(CZone *zone);
|
||||||
static void InitialiseAudioZoneArray(void);
|
static void InitialiseAudioZoneArray(void);
|
||||||
static void SaveAllZones(uint8 *buffer, uint32 *length);
|
static void SaveAllZones(uint8 *buffer, uint32 *length);
|
||||||
|
|
|
@ -303,9 +303,9 @@ extern int strncasecmp(const char *str1, const char *str2, size_t len);
|
||||||
|
|
||||||
extern wchar *AllocUnicode(const char*src);
|
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; }
|
inline float sq(float x) { return x*x; }
|
||||||
#define SQR(x) ((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) x##y
|
||||||
#define CONCAT(x,y) CONCAT_(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*, ...);
|
|
||||||
|
|
|
@ -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_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
|
||||||
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
|
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
|
||||||
#define MULTITHREADED_AUDIO // for streams. requires C++11 or later
|
#define MULTITHREADED_AUDIO // for streams. requires C++11 or later
|
||||||
|
#define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused
|
||||||
|
|
||||||
#ifdef AUDIO_OPUS
|
#ifdef AUDIO_OPUS
|
||||||
#define AUDIO_OAL_USE_OPUS // enable support of opus files
|
#define AUDIO_OAL_USE_OPUS // enable support of opus files
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "Ped.h"
|
#include "Ped.h"
|
||||||
#include "Dummy.h"
|
#include "Dummy.h"
|
||||||
#include "WindModifiers.h"
|
#include "WindModifiers.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
#include "SpecialFX.h"
|
#include "SpecialFX.h"
|
||||||
#include "VisibilityPlugins.h"
|
#include "VisibilityPlugins.h"
|
||||||
#include "RpAnimBlend.h"
|
#include "RpAnimBlend.h"
|
||||||
|
@ -927,7 +928,8 @@ CEntity::SaveEntityFlags(uint8*& buf)
|
||||||
void
|
void
|
||||||
CEntity::LoadEntityFlags(uint8*& buf)
|
CEntity::LoadEntityFlags(uint8*& buf)
|
||||||
{
|
{
|
||||||
uint32 tmp = ReadSaveBuf<uint32>(buf);
|
uint32 tmp;
|
||||||
|
ReadSaveBuf(&tmp, buf);
|
||||||
m_type = (tmp & ((BIT(3) - 1)));
|
m_type = (tmp & ((BIT(3) - 1)));
|
||||||
m_status = ((tmp >> 3) & (BIT(5) - 1));
|
m_status = ((tmp >> 3) & (BIT(5) - 1));
|
||||||
|
|
||||||
|
@ -958,7 +960,7 @@ CEntity::LoadEntityFlags(uint8*& buf)
|
||||||
bStreamingDontDelete = !!(tmp & BIT(30));
|
bStreamingDontDelete = !!(tmp & BIT(30));
|
||||||
bRemoveFromWorld = !!(tmp & BIT(31));
|
bRemoveFromWorld = !!(tmp & BIT(31));
|
||||||
|
|
||||||
tmp = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&tmp, buf);
|
||||||
|
|
||||||
bHasHitWall = !!(tmp & BIT(0));
|
bHasHitWall = !!(tmp & BIT(0));
|
||||||
bImBeingRendered = !!(tmp & BIT(1));
|
bImBeingRendered = !!(tmp & BIT(1));
|
||||||
|
|
|
@ -454,9 +454,9 @@ void
|
||||||
CPhysical::ApplyMoveForce(float jx, float jy, float jz)
|
CPhysical::ApplyMoveForce(float jx, float jy, float jz)
|
||||||
{
|
{
|
||||||
m_vecMoveSpeed += CVector(jx, jy, jz)*(1.0f/m_fMass);
|
m_vecMoveSpeed += CVector(jx, jy, jz)*(1.0f/m_fMass);
|
||||||
m_vecTurnSpeed.x = clamp(m_vecTurnSpeed.x, -4.0f, 4.0f);
|
m_vecTurnSpeed.x = Clamp(m_vecTurnSpeed.x, -4.0f, 4.0f);
|
||||||
m_vecTurnSpeed.y = clamp(m_vecTurnSpeed.y, -4.0f, 4.0f);
|
m_vecTurnSpeed.y = Clamp(m_vecTurnSpeed.y, -4.0f, 4.0f);
|
||||||
m_vecTurnSpeed.z = clamp(m_vecTurnSpeed.z, -4.0f, 4.0f);
|
m_vecTurnSpeed.z = Clamp(m_vecTurnSpeed.z, -4.0f, 4.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--LCS: done
|
//--LCS: done
|
||||||
|
@ -466,9 +466,9 @@ CPhysical::ApplyTurnForce(float jx, float jy, float jz, float px, float py, floa
|
||||||
CVector com = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
|
CVector com = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
|
||||||
CVector turnimpulse = CrossProduct(CVector(px, py, pz)-com, CVector(jx, jy, jz));
|
CVector turnimpulse = CrossProduct(CVector(px, py, pz)-com, CVector(jx, jy, jz));
|
||||||
m_vecTurnSpeed += turnimpulse*(1.0f/m_fTurnMass);
|
m_vecTurnSpeed += turnimpulse*(1.0f/m_fTurnMass);
|
||||||
m_vecTurnSpeed.x = clamp(m_vecTurnSpeed.x, -4.0f, 4.0f);
|
m_vecTurnSpeed.x = Clamp(m_vecTurnSpeed.x, -4.0f, 4.0f);
|
||||||
m_vecTurnSpeed.y = clamp(m_vecTurnSpeed.y, -4.0f, 4.0f);
|
m_vecTurnSpeed.y = Clamp(m_vecTurnSpeed.y, -4.0f, 4.0f);
|
||||||
m_vecTurnSpeed.z = clamp(m_vecTurnSpeed.z, -4.0f, 4.0f);
|
m_vecTurnSpeed.z = Clamp(m_vecTurnSpeed.z, -4.0f, 4.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--LCS: done
|
//--LCS: done
|
||||||
|
@ -533,7 +533,7 @@ CPhysical::ApplySpringDampening(float damping, float dampingLimit, CVector &spri
|
||||||
damping *= step;
|
damping *= step;
|
||||||
if(bIsHeavy)
|
if(bIsHeavy)
|
||||||
damping *= 2.0f;
|
damping *= 2.0f;
|
||||||
damping = clamp(damping, -DAMPING_LIMIT_IN_FRAME, DAMPING_LIMIT_IN_FRAME);
|
damping = Clamp(damping, -DAMPING_LIMIT_IN_FRAME, DAMPING_LIMIT_IN_FRAME);
|
||||||
|
|
||||||
// what is this?
|
// what is this?
|
||||||
float fSpeed = -speedA * damping;
|
float fSpeed = -speedA * damping;
|
||||||
|
@ -575,7 +575,7 @@ CPhysical::ApplyGravity(void)
|
||||||
surfaceUp = point.normal;
|
surfaceUp = point.normal;
|
||||||
else
|
else
|
||||||
surfaceUp = CVector(0.0f, 0.0f, 1.0f);
|
surfaceUp = CVector(0.0f, 0.0f, 1.0f);
|
||||||
float t = clamp(CTimer::GetTimeStep() * 0.5f, 0.05f, 0.8f);
|
float t = Clamp(CTimer::GetTimeStep() * 0.5f, 0.05f, 0.8f);
|
||||||
gravityUp = gravityUp * (1.0f - t) + surfaceUp * t;
|
gravityUp = gravityUp * (1.0f - t) + surfaceUp * t;
|
||||||
if (gravityUp.MagnitudeSqr() < 0.1f)
|
if (gravityUp.MagnitudeSqr() < 0.1f)
|
||||||
gravityUp = CVector(0.0f, 0.0f, 1.0f);
|
gravityUp = CVector(0.0f, 0.0f, 1.0f);
|
||||||
|
|
|
@ -2,6 +2,120 @@
|
||||||
|
|
||||||
#ifdef DEBUGMENU
|
#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
|
||||||
|
|
||||||
typedef void (*TriggerFunc)(void);
|
typedef void (*TriggerFunc)(void);
|
||||||
|
|
||||||
struct Menu;
|
struct Menu;
|
||||||
|
|
|
@ -423,7 +423,7 @@ ScreenDroplets::ProcessCameraMovement(void)
|
||||||
ms_movingEnabled = !isTopDown && !isLookingInDirection;
|
ms_movingEnabled = !isTopDown && !isLookingInDirection;
|
||||||
|
|
||||||
// 0 when looking stright up, 180 when looking up or down
|
// 0 when looking stright up, 180 when looking up or down
|
||||||
ms_camUpAngle = RADTODEG(Acos(clamp(camUp.z, -1.0f, 1.0f)));
|
ms_camUpAngle = RADTODEG(Acos(Clamp(camUp.z, -1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -234,9 +234,9 @@ CObject::Render(void)
|
||||||
float green = (0.8f * CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj()) * 165.75f;
|
float green = (0.8f * CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj()) * 165.75f;
|
||||||
float blue = (0.8f * CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj()) * 165.75f;
|
float blue = (0.8f * CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj()) * 165.75f;
|
||||||
|
|
||||||
red = clamp(red, 0.0f, 255.0f);
|
red = Clamp(red, 0.0f, 255.0f);
|
||||||
green = clamp(green, 0.0f, 255.0f);
|
green = Clamp(green, 0.0f, 255.0f);
|
||||||
blue = clamp(blue, 0.0f, 255.0f);
|
blue = Clamp(blue, 0.0f, 255.0f);
|
||||||
|
|
||||||
int alpha = CGeneral::GetRandomNumberInRange(196, 225);
|
int alpha = CGeneral::GetRandomNumberInRange(196, 225);
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ CStinger::Process()
|
||||||
float degangle = progress * ARRAY_SIZE(m_vPositions);
|
float degangle = progress * ARRAY_SIZE(m_vPositions);
|
||||||
float angle1 = m_fMax_Z + DEGTORAD(degangle);
|
float angle1 = m_fMax_Z + DEGTORAD(degangle);
|
||||||
float angle2 = m_fMax_Z - DEGTORAD(degangle);
|
float angle2 = m_fMax_Z - DEGTORAD(degangle);
|
||||||
int pos = clamp(degangle, 0, ARRAY_SIZE(m_vPositions)-1);
|
int pos = Clamp(degangle, 0, ARRAY_SIZE(m_vPositions)-1);
|
||||||
|
|
||||||
CVector2D pos2d = m_vPositions[pos];
|
CVector2D pos2d = m_vPositions[pos];
|
||||||
CVector pos3d = m_vPos;
|
CVector pos3d = m_vPos;
|
||||||
|
|
|
@ -644,6 +644,9 @@ CCopPed::ProcessControl(void)
|
||||||
int numCopsNear = 0;
|
int numCopsNear = 0;
|
||||||
for (int i = 0; i < player->m_numNearPeds; ++i) {
|
for (int i = 0; i < player->m_numNearPeds; ++i) {
|
||||||
CPed *nearPed = player->m_nearPeds[i];
|
CPed *nearPed = player->m_nearPeds[i];
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
if (nearPed)
|
||||||
|
#endif
|
||||||
if (nearPed->m_nPedType == PEDTYPE_COP && nearPed->m_nPedState != PED_DEAD)
|
if (nearPed->m_nPedType == PEDTYPE_COP && nearPed->m_nPedState != PED_DEAD)
|
||||||
++numCopsNear;
|
++numCopsNear;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "General.h"
|
#include "General.h"
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
#include "Weapon.h"
|
#include "Weapon.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
CGangInfo CGangs::Gang[NUM_GANGS];
|
CGangInfo CGangs::Gang[NUM_GANGS];
|
||||||
bool CGangs::GangAttackWithCops[NUM_GANGS];
|
bool CGangs::GangAttackWithCops[NUM_GANGS];
|
||||||
|
@ -120,6 +121,6 @@ INITSAVEBUF
|
||||||
CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE);
|
||||||
|
|
||||||
for (int i = 0; i < NUM_GANGS; i++)
|
for (int i = 0; i < NUM_GANGS; i++)
|
||||||
Gang[i] = ReadSaveBuf<CGangInfo>(buf);
|
ReadSaveBuf(&Gang[i], buf);
|
||||||
VALIDATESAVEBUF(size);
|
VALIDATESAVEBUF(size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "CutsceneShadow.h"
|
#include "CutsceneShadow.h"
|
||||||
#include "Clock.h"
|
#include "Clock.h"
|
||||||
#include "Wanted.h"
|
#include "Wanted.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
CPed *gapTempPedList[50];
|
CPed *gapTempPedList[50];
|
||||||
uint16 gnNumTempPedList;
|
uint16 gnNumTempPedList;
|
||||||
|
|
|
@ -1309,7 +1309,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
|
||||||
if (IsPlayer())
|
if (IsPlayer())
|
||||||
moveAssoc->speed = 1.2f;
|
moveAssoc->speed = 1.2f;
|
||||||
|
|
||||||
m_takeAStepAfterAttack = 0;
|
m_takeAStepAfterAttack = false;
|
||||||
m_fightButtonPressure = 0;
|
m_fightButtonPressure = 0;
|
||||||
|
|
||||||
} else if (IsPlayer() && GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED && GetWeapon()->m_eWeaponType != WEAPONTYPE_BRASSKNUCKLE &&
|
} else if (IsPlayer() && GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED && GetWeapon()->m_eWeaponType != WEAPONTYPE_BRASSKNUCKLE &&
|
||||||
|
@ -3929,7 +3929,7 @@ CPed::DriveVehicle(void)
|
||||||
targetLRLean = 0.0f;
|
targetLRLean = 0.0f;
|
||||||
timeBlend = Pow(0.86f, CTimer::GetTimeStep());
|
timeBlend = Pow(0.86f, CTimer::GetTimeStep());
|
||||||
} else {
|
} else {
|
||||||
targetLRLean = clamp(bike->m_fLeanLRAngle / bike->pBikeHandling->fFullAnimLean, -1.0f, 1.0f);
|
targetLRLean = Clamp(bike->m_fLeanLRAngle / bike->pBikeHandling->fFullAnimLean, -1.0f, 1.0f);
|
||||||
timeBlend = Pow(0.86f, CTimer::GetTimeStep());
|
timeBlend = Pow(0.86f, CTimer::GetTimeStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4116,7 +4116,7 @@ CPed::DriveVehicle(void)
|
||||||
lDriveAssoc->blendAmount = 0.0f;
|
lDriveAssoc->blendAmount = 0.0f;
|
||||||
|
|
||||||
if (rDriveAssoc)
|
if (rDriveAssoc)
|
||||||
rDriveAssoc->blendAmount = clamp(steerAngle * -100.0f / 61.0f, 0.0f, 1.0f);
|
rDriveAssoc->blendAmount = Clamp(steerAngle * -100.0f / 61.0f, 0.0f, 1.0f);
|
||||||
else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT))
|
else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT))
|
||||||
CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE_RIGHT);
|
CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE_RIGHT);
|
||||||
else if (m_pMyVehicle->bLowVehicle)
|
else if (m_pMyVehicle->bLowVehicle)
|
||||||
|
@ -4129,7 +4129,7 @@ CPed::DriveVehicle(void)
|
||||||
rDriveAssoc->blendAmount = 0.0f;
|
rDriveAssoc->blendAmount = 0.0f;
|
||||||
|
|
||||||
if (lDriveAssoc)
|
if (lDriveAssoc)
|
||||||
lDriveAssoc->blendAmount = clamp(steerAngle * 100.0f / 61.0f, 0.0f, 1.0f);
|
lDriveAssoc->blendAmount = Clamp(steerAngle * 100.0f / 61.0f, 0.0f, 1.0f);
|
||||||
else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT))
|
else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT))
|
||||||
CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE_LEFT);
|
CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_BOAT_DRIVE_LEFT);
|
||||||
else if (m_pMyVehicle->bLowVehicle)
|
else if (m_pMyVehicle->bLowVehicle)
|
||||||
|
|
|
@ -79,7 +79,7 @@ CPedIK::MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, Limb
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limb.yaw > moveInfo.maxYaw || limb.yaw < moveInfo.minYaw) {
|
if (limb.yaw > moveInfo.maxYaw || limb.yaw < moveInfo.minYaw) {
|
||||||
limb.yaw = clamp(limb.yaw, moveInfo.minYaw, moveInfo.maxYaw);
|
limb.yaw = Clamp(limb.yaw, moveInfo.minYaw, moveInfo.maxYaw);
|
||||||
result = ANGLES_SET_TO_MAX;
|
result = ANGLES_SET_TO_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ CPedIK::MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, Limb
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limb.pitch > moveInfo.maxPitch || limb.pitch < moveInfo.minPitch) {
|
if (limb.pitch > moveInfo.maxPitch || limb.pitch < moveInfo.minPitch) {
|
||||||
limb.pitch = clamp(limb.pitch, moveInfo.minPitch, moveInfo.maxPitch);
|
limb.pitch = Clamp(limb.pitch, moveInfo.minPitch, moveInfo.maxPitch);
|
||||||
result = ANGLES_SET_TO_MAX;
|
result = ANGLES_SET_TO_MAX;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -122,14 +122,14 @@ CPedIK::LookInDirection(float targetYaw, float targetPitch)
|
||||||
m_headOrient.yaw = Atan2(-m->at.y, -m->at.x);
|
m_headOrient.yaw = Atan2(-m->at.y, -m->at.x);
|
||||||
m_headOrient.yaw -= m_ped->m_fRotationCur;
|
m_headOrient.yaw -= m_ped->m_fRotationCur;
|
||||||
m_headOrient.yaw = CGeneral::LimitRadianAngle(m_headOrient.yaw);
|
m_headOrient.yaw = CGeneral::LimitRadianAngle(m_headOrient.yaw);
|
||||||
float up = clamp(m->up.z, -1.0f, 1.0f);
|
float up = Clamp(m->up.z, -1.0f, 1.0f);
|
||||||
m_headOrient.pitch = Atan2(-up, Sqrt(1.0f - SQR(-up)));
|
m_headOrient.pitch = Atan2(-up, Sqrt(1.0f - SQR(-up)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// parent of head is neck
|
// parent of head is neck
|
||||||
RwMatrix *m = GetComponentMatrix(m_ped, PED_NECK);
|
RwMatrix *m = GetComponentMatrix(m_ped, PED_NECK);
|
||||||
yaw = CGeneral::LimitRadianAngle(Atan2(-m->at.y, -m->at.x));
|
yaw = CGeneral::LimitRadianAngle(Atan2(-m->at.y, -m->at.x));
|
||||||
float up = clamp(m->up.z, -1.0f, 1.0f);
|
float up = Clamp(m->up.z, -1.0f, 1.0f);
|
||||||
pitch = Atan2(-up, Sqrt(1.0f - SQR(-up)));
|
pitch = Atan2(-up, Sqrt(1.0f - SQR(-up)));
|
||||||
float headYaw = CGeneral::LimitRadianAngle(targetYaw - (yaw + m_torsoOrient.yaw));
|
float headYaw = CGeneral::LimitRadianAngle(targetYaw - (yaw + m_torsoOrient.yaw));
|
||||||
float headPitch = CGeneral::LimitRadianAngle(targetPitch - pitch) * Cos(Min(Abs(headYaw), HALFPI));
|
float headPitch = CGeneral::LimitRadianAngle(targetPitch - pitch) * Cos(Min(Abs(headYaw), HALFPI));
|
||||||
|
@ -336,11 +336,11 @@ CPedIK::RestoreLookAt(void)
|
||||||
void
|
void
|
||||||
CPedIK::ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch)
|
CPedIK::ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch)
|
||||||
{
|
{
|
||||||
float f = clamp(DotProduct(mat->up, CVector(0.0f, 1.0f, 0.0f)), -1.0f, 1.0f);
|
float f = Clamp(DotProduct(mat->up, CVector(0.0f, 1.0f, 0.0f)), -1.0f, 1.0f);
|
||||||
*yaw = Acos(f);
|
*yaw = Acos(f);
|
||||||
if (mat->up.x > 0.0f) *yaw = -*yaw;
|
if (mat->up.x > 0.0f) *yaw = -*yaw;
|
||||||
|
|
||||||
f = clamp(DotProduct(mat->right, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f);
|
f = Clamp(DotProduct(mat->right, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f);
|
||||||
*pitch = Acos(f);
|
*pitch = Acos(f);
|
||||||
if (mat->up.z > 0.0f) *pitch = -*pitch;
|
if (mat->up.z > 0.0f) *pitch = -*pitch;
|
||||||
}
|
}
|
||||||
|
@ -348,11 +348,11 @@ CPedIK::ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch)
|
||||||
void
|
void
|
||||||
CPedIK::ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch)
|
CPedIK::ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch)
|
||||||
{
|
{
|
||||||
float f = clamp(DotProduct(mat->at, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f);
|
float f = Clamp(DotProduct(mat->at, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f);
|
||||||
*yaw = Acos(f);
|
*yaw = Acos(f);
|
||||||
if (mat->at.y > 0.0f) *yaw = -*yaw;
|
if (mat->at.y > 0.0f) *yaw = -*yaw;
|
||||||
|
|
||||||
f = clamp(DotProduct(mat->right, CVector(1.0f, 0.0f, 0.0f)), -1.0f, 1.0f);
|
f = Clamp(DotProduct(mat->right, CVector(1.0f, 0.0f, 0.0f)), -1.0f, 1.0f);
|
||||||
*pitch = Acos(f);
|
*pitch = Acos(f);
|
||||||
if (mat->up.x > 0.0f) *pitch = -*pitch;
|
if (mat->up.x > 0.0f) *pitch = -*pitch;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "General.h"
|
#include "General.h"
|
||||||
#include "FileMgr.h"
|
#include "FileMgr.h"
|
||||||
#include "PedType.h"
|
#include "PedType.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
CPedType *CPedType::ms_apPedType[NUM_PEDTYPES];
|
CPedType *CPedType::ms_apPedType[NUM_PEDTYPES];
|
||||||
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
|
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
|
||||||
|
@ -201,7 +202,7 @@ INITSAVEBUF
|
||||||
CheckSaveHeader(buf, 'P', 'T', 'P', '\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buf, 'P', 'T', 'P', '\0', size - SAVE_HEADER_SIZE);
|
||||||
|
|
||||||
for(int i = 0; i < NUM_PEDTYPES; i++)
|
for(int i = 0; i < NUM_PEDTYPES; i++)
|
||||||
*ms_apPedType[i] = ReadSaveBuf<CPedType>(buf);
|
ReadSaveBuf(ms_apPedType[i], buf);
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "Replay.h"
|
#include "Replay.h"
|
||||||
#include "PedPlacement.h"
|
#include "PedPlacement.h"
|
||||||
#include "VarConsole.h"
|
#include "VarConsole.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
#define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f
|
#define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f
|
||||||
|
|
||||||
|
@ -836,8 +837,8 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed)
|
||||||
|
|
||||||
if (padMove > 0.0f) {
|
if (padMove > 0.0f) {
|
||||||
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
|
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
|
||||||
m_takeAStepAfterAttack = padMove > 2 * PAD_MOVE_TO_GAME_WORLD_MOVE;
|
m_takeAStepAfterAttack = padMove > (2 * PAD_MOVE_TO_GAME_WORLD_MOVE);
|
||||||
if (padUsed->GetSprint() && padMove > 1 * PAD_MOVE_TO_GAME_WORLD_MOVE)
|
if (padUsed->GetSprint() && padMove > (1 * PAD_MOVE_TO_GAME_WORLD_MOVE))
|
||||||
bIsAttacking = false;
|
bIsAttacking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2080,13 +2081,13 @@ CPlayerPed::UpdateMeleeAttackers(void)
|
||||||
void
|
void
|
||||||
CPlayerPed::RemovePedFromMeleeList(CPed *ped)
|
CPlayerPed::RemovePedFromMeleeList(CPed *ped)
|
||||||
{
|
{
|
||||||
int i = 0;
|
for (uint16 i = 0; i < ARRAY_SIZE(m_pMeleeList); i++) {
|
||||||
for (; m_pMeleeList[i] != ped; i++) {
|
if (m_pMeleeList[i] == ped) {
|
||||||
if (i >= ARRAY_SIZE(m_pMeleeList))
|
m_pMeleeList[i] = nil;
|
||||||
|
ped->m_attackTimer = 0;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_pMeleeList[i] = nil;
|
|
||||||
ped->m_attackTimer = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -413,7 +413,7 @@ CPopulation::PedCreationDistMultiplier()
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
float vehSpeed = veh->m_vecMoveSpeed.Magnitude2D();
|
float vehSpeed = veh->m_vecMoveSpeed.Magnitude2D();
|
||||||
return clamp(vehSpeed - 0.1f + 1.0f, 1.0f, 1.5f);
|
return Clamp(vehSpeed - 0.1f + 1.0f, 1.0f, 1.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPed*
|
CPed*
|
||||||
|
|
|
@ -23,3 +23,5 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CConsole TheConsole;
|
extern CConsole TheConsole;
|
||||||
|
|
||||||
|
void cprintf(char*, ...);
|
|
@ -493,7 +493,7 @@ CCoronas::RenderReflections(void)
|
||||||
if(spriteCoors.z < drawDist){
|
if(spriteCoors.z < drawDist){
|
||||||
float fadeDistance = drawDist / 2.0f;
|
float fadeDistance = drawDist / 2.0f;
|
||||||
float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance;
|
float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance;
|
||||||
distanceFade = clamp(distanceFade, 0.0f, 1.0f);
|
distanceFade = Clamp(distanceFade, 0.0f, 1.0f);
|
||||||
float recipz = 1.0f/RwCameraGetNearClipPlane(Scene.camera);
|
float recipz = 1.0f/RwCameraGetNearClipPlane(Scene.camera);
|
||||||
float heightFade = (20.0f - aCoronas[i].heightAboveRoad)/20.0f;
|
float heightFade = (20.0f - aCoronas[i].heightAboveRoad)/20.0f;
|
||||||
int intensity = distanceFade*heightFade * 230.0 * CWeather::WetRoads;
|
int intensity = distanceFade*heightFade * 230.0 * CWeather::WetRoads;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Replay.h"
|
#include "Replay.h"
|
||||||
#include "Coronas.h"
|
#include "Coronas.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
CPlaneTrail CPlaneTrails::aArray[6];
|
CPlaneTrail CPlaneTrails::aArray[6];
|
||||||
RwImVertexIndex TrailIndices[32] = {
|
RwImVertexIndex TrailIndices[32] = {
|
||||||
|
@ -1155,7 +1156,7 @@ void CScriptPath::Update(void) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_fPosition += m_fSpeed * CTimer::GetTimeStepInSeconds();
|
m_fPosition += m_fSpeed * CTimer::GetTimeStepInSeconds();
|
||||||
m_fPosition = clamp(m_fPosition, 0.0f, m_fTotalLength);
|
m_fPosition = Clamp(m_fPosition, 0.0f, m_fTotalLength);
|
||||||
|
|
||||||
if (m_pObjects[0] || m_pObjects[1] || m_pObjects[2] || m_pObjects[3]
|
if (m_pObjects[0] || m_pObjects[1] || m_pObjects[2] || m_pObjects[3]
|
||||||
|| m_pObjects[4] || m_pObjects[5]) {
|
|| m_pObjects[4] || m_pObjects[5]) {
|
||||||
|
@ -1268,7 +1269,7 @@ INITSAVEBUF
|
||||||
aArray[i].Clear();
|
aArray[i].Clear();
|
||||||
|
|
||||||
for (int32 i = 0; i < 3; i++) {
|
for (int32 i = 0; i < 3; i++) {
|
||||||
aArray[i] = ReadSaveBuf<CScriptPath>(buf);
|
ReadSaveBuf(&aArray[i], buf);
|
||||||
|
|
||||||
for (int32 j = 0; j < 6; j++) {
|
for (int32 j = 0; j < 6; j++) {
|
||||||
CScriptPath *pPath = &aArray[i];
|
CScriptPath *pPath = &aArray[i];
|
||||||
|
@ -1280,7 +1281,7 @@ INITSAVEBUF
|
||||||
|
|
||||||
aArray[i].m_pNode = new CPlaneNode[aArray[i].m_numNodes];
|
aArray[i].m_pNode = new CPlaneNode[aArray[i].m_numNodes];
|
||||||
for (int32 j = 0; j < aArray[i].m_numNodes; j++) {
|
for (int32 j = 0; j < aArray[i].m_numNodes; j++) {
|
||||||
aArray[i].m_pNode[j] = ReadSaveBuf<CPlaneNode>(buf);
|
ReadSaveBuf(&aArray[i].m_pNode[j], buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
|
|
|
@ -151,9 +151,9 @@ CFallingGlassPane::Render(void)
|
||||||
uint8 alpha = CGlass::CalcAlphaWithNormal(&fwdNorm);
|
uint8 alpha = CGlass::CalcAlphaWithNormal(&fwdNorm);
|
||||||
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
uint16 time = clamp(CTimer::GetTimeInMilliseconds() > m_nTimer ? CTimer::GetTimeInMilliseconds() - m_nTimer : 0u, 0u, 500u);
|
uint16 time = Clamp(CTimer::GetTimeInMilliseconds() > m_nTimer ? CTimer::GetTimeInMilliseconds() - m_nTimer : 0u, 0u, 500u);
|
||||||
#else
|
#else
|
||||||
uint16 time = clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500);
|
uint16 time = Clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8 color = int32( float(alpha) * (float(time) / 500) );
|
uint8 color = int32( float(alpha) * (float(time) / 500) );
|
||||||
|
|
|
@ -1407,7 +1407,7 @@ CHud::DrawHealthBar(int16 value)
|
||||||
}
|
}
|
||||||
float fHealth = value;
|
float fHealth = value;
|
||||||
float fMaxHealth = CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth;
|
float fMaxHealth = CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth;
|
||||||
fHealth = clamp(fHealth, 0.0f, fMaxHealth);
|
fHealth = Clamp(fHealth, 0.0f, fMaxHealth);
|
||||||
float fWidth = (fHealth / fMaxHealth) * 40.0f + 16.0f + 4.0f;
|
float fWidth = (fHealth / fMaxHealth) * 40.0f + 16.0f + 4.0f;
|
||||||
float u = fWidth / 64.0f;
|
float u = fWidth / 64.0f;
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
|
@ -1477,7 +1477,7 @@ CHud::DrawArmourBar(int16 value)
|
||||||
}
|
}
|
||||||
float fArmour = value;
|
float fArmour = value;
|
||||||
float fMaxArmour = CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour;
|
float fMaxArmour = CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour;
|
||||||
fArmour = clamp(fArmour, 0.0f, fMaxArmour);
|
fArmour = Clamp(fArmour, 0.0f, fMaxArmour);
|
||||||
float fWidth = (fArmour / fMaxArmour) * 40.0f + 16.0f + 4.0f;
|
float fWidth = (fArmour / fMaxArmour) * 40.0f + 16.0f + 4.0f;
|
||||||
float u = fWidth / 64.0f;
|
float u = fWidth / 64.0f;
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
|
@ -2252,7 +2252,7 @@ float CHud::DrawFadeState(DRAW_FADE_STATE fadingElement, int forceFadingIn)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clamp(alpha, 0.0f, 255.0f);
|
return Clamp(alpha, 0.0f, 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -283,10 +283,10 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect, RwIm2DVertex *verts
|
||||||
v1 = y1/height + v1Off;
|
v1 = y1/height + v1Off;
|
||||||
u2 = x2/width + u2Off;
|
u2 = x2/width + u2Off;
|
||||||
v2 = y2/height + v2Off;
|
v2 = y2/height + v2Off;
|
||||||
u1 = clamp(u1, 0.0f, 1.0f);
|
u1 = Clamp(u1, 0.0f, 1.0f);
|
||||||
v1 = clamp(v1, 0.0f, 1.0f);
|
v1 = Clamp(v1, 0.0f, 1.0f);
|
||||||
u2 = clamp(u2, 0.0f, 1.0f);
|
u2 = Clamp(u2, 0.0f, 1.0f);
|
||||||
v2 = clamp(v2, 0.0f, 1.0f);
|
v2 = Clamp(v2, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float recipz = 1.0f/z;
|
float recipz = 1.0f/z;
|
||||||
|
@ -517,7 +517,7 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type,
|
||||||
void
|
void
|
||||||
CMBlur::SetDrunkBlur(float drunkness)
|
CMBlur::SetDrunkBlur(float drunkness)
|
||||||
{
|
{
|
||||||
Drunkness = clamp(drunkness, 0.0f, 1.0f);
|
Drunkness = Clamp(drunkness, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -600,9 +600,9 @@ CMBlur::OverlayRenderFx(RwCamera *cam, RwRaster *frontBuf)
|
||||||
int red = (0.75f*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed())*0.55f * 255;
|
int red = (0.75f*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed())*0.55f * 255;
|
||||||
int green = (0.75f*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen())*0.55f * 255;
|
int green = (0.75f*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen())*0.55f * 255;
|
||||||
int blue = (0.75f*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue())*0.55f * 255;
|
int blue = (0.75f*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue())*0.55f * 255;
|
||||||
red = clamp(red, 0, 255);
|
red = Clamp(red, 0, 255);
|
||||||
green = clamp(green, 0, 255);
|
green = Clamp(green, 0, 255);
|
||||||
blue = clamp(blue, 0, 255);
|
blue = Clamp(blue, 0, 255);
|
||||||
|
|
||||||
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
|
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
|
||||||
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
|
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
|
||||||
|
@ -697,7 +697,7 @@ CMBlur::OverlayRenderFx(RwCamera *cam, RwRaster *frontBuf)
|
||||||
int alpha = FrontEndMenuManager.m_PrefsBrightness > 255 ?
|
int alpha = FrontEndMenuManager.m_PrefsBrightness > 255 ?
|
||||||
FrontEndMenuManager.m_PrefsBrightness - 90 :
|
FrontEndMenuManager.m_PrefsBrightness - 90 :
|
||||||
FrontEndMenuManager.m_PrefsBrightness - 130;
|
FrontEndMenuManager.m_PrefsBrightness - 130;
|
||||||
alpha = clamp(alpha, 16, 200)/2;
|
alpha = Clamp(alpha, 16, 200)/2;
|
||||||
|
|
||||||
CreateImmediateModeData(cam, &fxRect[i], verts, CRGBA(0, 0, 0, alpha), 0.0f, 0.0f, 0.0f, 0.0f, fxZ[i], true);
|
CreateImmediateModeData(cam, &fxRect[i], verts, CRGBA(0, 0, 0, alpha), 0.0f, 0.0f, 0.0f, 0.0f, fxZ[i], true);
|
||||||
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gpHeatHazeRaster);
|
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gpHeatHazeRaster);
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
#include "ParticleObject.h"
|
#include "ParticleObject.h"
|
||||||
#include "Particle.h"
|
#include "Particle.h"
|
||||||
#include "soundlist.h"
|
#include "soundlist.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
#include "debugmenu.h"
|
||||||
|
|
||||||
#define MAX_PARTICLES_ON_SCREEN (750)
|
#define MAX_PARTICLES_ON_SCREEN (750)
|
||||||
|
|
||||||
|
@ -1095,15 +1096,15 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe
|
||||||
int32 ColorVariation = CGeneral::GetRandomNumberInRange(-psystem->m_InitialColorVariation, psystem->m_InitialColorVariation);
|
int32 ColorVariation = CGeneral::GetRandomNumberInRange(-psystem->m_InitialColorVariation, psystem->m_InitialColorVariation);
|
||||||
//float ColorVariation = CGeneral::GetRandomNumberInRange((float)-psystem->m_InitialColorVariation, (float)psystem->m_InitialColorVariation);
|
//float ColorVariation = CGeneral::GetRandomNumberInRange((float)-psystem->m_InitialColorVariation, (float)psystem->m_InitialColorVariation);
|
||||||
|
|
||||||
pParticle->m_Color.red = clamp(pParticle->m_Color.red +
|
pParticle->m_Color.red = Clamp(pParticle->m_Color.red +
|
||||||
PERCENT(pParticle->m_Color.red, ColorVariation),
|
PERCENT(pParticle->m_Color.red, ColorVariation),
|
||||||
0, 255);
|
0, 255);
|
||||||
|
|
||||||
pParticle->m_Color.green = clamp(pParticle->m_Color.green +
|
pParticle->m_Color.green = Clamp(pParticle->m_Color.green +
|
||||||
PERCENT(pParticle->m_Color.green, ColorVariation),
|
PERCENT(pParticle->m_Color.green, ColorVariation),
|
||||||
0, 255);
|
0, 255);
|
||||||
|
|
||||||
pParticle->m_Color.blue = clamp(pParticle->m_Color.blue +
|
pParticle->m_Color.blue = Clamp(pParticle->m_Color.blue +
|
||||||
PERCENT(pParticle->m_Color.blue, ColorVariation),
|
PERCENT(pParticle->m_Color.blue, ColorVariation),
|
||||||
0, 255);
|
0, 255);
|
||||||
}
|
}
|
||||||
|
@ -1388,15 +1389,15 @@ void CParticle::Update()
|
||||||
{
|
{
|
||||||
float colorMul = 1.0f - float(particle->m_nTimeWhenColorWillBeChanged - CTimer::GetTimeInMilliseconds()) / float(psystem->m_ColorFadeTime);
|
float colorMul = 1.0f - float(particle->m_nTimeWhenColorWillBeChanged - CTimer::GetTimeInMilliseconds()) / float(psystem->m_ColorFadeTime);
|
||||||
|
|
||||||
particle->m_Color.red = clamp(
|
particle->m_Color.red = Clamp(
|
||||||
psystem->m_RenderColouring.red + int32(float(psystem->m_FadeDestinationColor.red - psystem->m_RenderColouring.red) * colorMul),
|
psystem->m_RenderColouring.red + int32(float(psystem->m_FadeDestinationColor.red - psystem->m_RenderColouring.red) * colorMul),
|
||||||
0, 255);
|
0, 255);
|
||||||
|
|
||||||
particle->m_Color.green = clamp(
|
particle->m_Color.green = Clamp(
|
||||||
psystem->m_RenderColouring.green + int32(float(psystem->m_FadeDestinationColor.green - psystem->m_RenderColouring.green) * colorMul),
|
psystem->m_RenderColouring.green + int32(float(psystem->m_FadeDestinationColor.green - psystem->m_RenderColouring.green) * colorMul),
|
||||||
0, 255);
|
0, 255);
|
||||||
|
|
||||||
particle->m_Color.blue = clamp(
|
particle->m_Color.blue = Clamp(
|
||||||
psystem->m_RenderColouring.blue + int32(float(psystem->m_FadeDestinationColor.blue - psystem->m_RenderColouring.blue) * colorMul),
|
psystem->m_RenderColouring.blue + int32(float(psystem->m_FadeDestinationColor.blue - psystem->m_RenderColouring.blue) * colorMul),
|
||||||
0, 255);
|
0, 255);
|
||||||
}
|
}
|
||||||
|
@ -1703,13 +1704,13 @@ void CParticle::Update()
|
||||||
|
|
||||||
if ( particle->m_nFadeToBlackTimer != 0 )
|
if ( particle->m_nFadeToBlackTimer != 0 )
|
||||||
{
|
{
|
||||||
particle->m_nColorIntensity = clamp(particle->m_nColorIntensity - particle->m_nFadeToBlackTimer,
|
particle->m_nColorIntensity = Clamp(particle->m_nColorIntensity - particle->m_nFadeToBlackTimer,
|
||||||
0, 255);
|
0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( particle->m_nFadeAlphaTimer != 0 )
|
if ( particle->m_nFadeAlphaTimer != 0 )
|
||||||
{
|
{
|
||||||
particle->m_nAlpha = clamp(particle->m_nAlpha - particle->m_nFadeAlphaTimer,
|
particle->m_nAlpha = Clamp(particle->m_nAlpha - particle->m_nFadeAlphaTimer,
|
||||||
0, 255);
|
0, 255);
|
||||||
if ( particle->m_nAlpha == 0 )
|
if ( particle->m_nAlpha == 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,7 +214,6 @@ CSpecialFX::Render2DFXs(void)
|
||||||
CFont::SetPropOn();
|
CFont::SetPropOn();
|
||||||
CFont::SetColor(CRGBA(100, 100, 100, 200));
|
CFont::SetColor(CRGBA(100, 100, 100, 200));
|
||||||
CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD));
|
CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD));
|
||||||
CFont::PrintString(SCREEN_WIDTH * 8 / 10, SCREEN_HEIGHT * 8 / 10, gUString);
|
|
||||||
for (int32 i = 0; i < SCREEN_HEIGHT; i += 4) {
|
for (int32 i = 0; i < SCREEN_HEIGHT; i += 4) {
|
||||||
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
|
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
|
||||||
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
|
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
|
||||||
|
|
|
@ -414,13 +414,13 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, f
|
||||||
|
|
||||||
// Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2
|
// Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2
|
||||||
cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f;
|
cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f;
|
||||||
cf[0] = clamp(cf[0], 0.0f, 1.0f);
|
cf[0] = Clamp(cf[0], 0.0f, 1.0f);
|
||||||
cf[1] = (cx*(-c+s) + cy*( c+s))*0.5f + 0.5f;
|
cf[1] = (cx*(-c+s) + cy*( c+s))*0.5f + 0.5f;
|
||||||
cf[1] = clamp(cf[1], 0.0f, 1.0f);
|
cf[1] = Clamp(cf[1], 0.0f, 1.0f);
|
||||||
cf[2] = (cx*( c+s) + cy*( c-s))*0.5f + 0.5f;
|
cf[2] = (cx*( c+s) + cy*( c-s))*0.5f + 0.5f;
|
||||||
cf[2] = clamp(cf[2], 0.0f, 1.0f);
|
cf[2] = Clamp(cf[2], 0.0f, 1.0f);
|
||||||
cf[3] = (cx*( c-s) + cy*(-c-s))*0.5f + 0.5f;
|
cf[3] = (cx*( c-s) + cy*(-c-s))*0.5f + 0.5f;
|
||||||
cf[3] = clamp(cf[3], 0.0f, 1.0f);
|
cf[3] = Clamp(cf[3], 0.0f, 1.0f);
|
||||||
|
|
||||||
float screenz = m_f2DNearScreenZ +
|
float screenz = m_f2DNearScreenZ +
|
||||||
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() /
|
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() /
|
||||||
|
|
|
@ -179,10 +179,10 @@ CWaterLevel::Initialise(Const char *pWaterDat)
|
||||||
int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top);
|
int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top);
|
||||||
int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f;
|
int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f;
|
||||||
|
|
||||||
l = clamp(l, 0, MAX_SMALL_SECTORS - 1);
|
l = Clamp(l, 0, MAX_SMALL_SECTORS - 1);
|
||||||
r = clamp(r, 0, MAX_SMALL_SECTORS - 1);
|
r = Clamp(r, 0, MAX_SMALL_SECTORS - 1);
|
||||||
t = clamp(t, 0, MAX_SMALL_SECTORS - 1);
|
t = Clamp(t, 0, MAX_SMALL_SECTORS - 1);
|
||||||
b = clamp(b, 0, MAX_SMALL_SECTORS - 1);
|
b = Clamp(b, 0, MAX_SMALL_SECTORS - 1);
|
||||||
|
|
||||||
for (int32 x = l; x <= r; x++)
|
for (int32 x = l; x <= r; x++)
|
||||||
{
|
{
|
||||||
|
@ -991,10 +991,10 @@ CWaterLevel::RenderWater()
|
||||||
if ( bUseCamEndY )
|
if ( bUseCamEndY )
|
||||||
nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y);
|
nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y);
|
||||||
|
|
||||||
nStartX = clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
|
nStartX = Clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
|
||||||
nEndX = clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
|
nEndX = Clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
|
||||||
nStartY = clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
|
nStartY = Clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
|
||||||
nEndY = clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
|
nEndY = Clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
|
||||||
|
|
||||||
for ( int32 x = nStartX; x <= nEndX; x++ )
|
for ( int32 x = nStartX; x <= nEndX; x++ )
|
||||||
{
|
{
|
||||||
|
@ -1259,10 +1259,10 @@ CWaterLevel::RenderTransparentWater(void)
|
||||||
if ( bUseCamEndY )
|
if ( bUseCamEndY )
|
||||||
nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y );
|
nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y );
|
||||||
|
|
||||||
nStartX = clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
|
nStartX = Clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
|
||||||
nEndX = clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
|
nEndX = Clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
|
||||||
nStartY = clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
|
nStartY = Clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
|
||||||
nEndY = clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
|
nEndY = Clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
|
||||||
|
|
||||||
|
|
||||||
for ( int32 x = nStartX; x <= nEndX; x++ )
|
for ( int32 x = nStartX; x <= nEndX; x++ )
|
||||||
|
@ -2161,10 +2161,10 @@ CWaterLevel::PreCalcWaterGeometry(void)
|
||||||
float signX = CamFwdDir.x * 1.4144272f;
|
float signX = CamFwdDir.x * 1.4144272f;
|
||||||
float signY = CamFwdDir.y * 1.4144272f;
|
float signY = CamFwdDir.y * 1.4144272f;
|
||||||
|
|
||||||
signX = clamp(signX, -1.0f, 1.0f);
|
signX = Clamp(signX, -1.0f, 1.0f);
|
||||||
fCamX += 0.4f * signX * float(SMALL_SECTOR_SIZE * 2.0f);
|
fCamX += 0.4f * signX * float(SMALL_SECTOR_SIZE * 2.0f);
|
||||||
|
|
||||||
signY = clamp(signY, -1.0f, 1.0f);
|
signY = Clamp(signY, -1.0f, 1.0f);
|
||||||
fCamY += 0.4f * signY * float(SMALL_SECTOR_SIZE * 2.0f);
|
fCamY += 0.4f * signY * float(SMALL_SECTOR_SIZE * 2.0f);
|
||||||
|
|
||||||
int32 nBlock;
|
int32 nBlock;
|
||||||
|
@ -2578,7 +2578,7 @@ CWaterLevel::RenderBoatWakes(void)
|
||||||
float val = 500.0f - (CBoat::WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[wake])
|
float val = 500.0f - (CBoat::WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[wake])
|
||||||
* 600.0f / CBoat::WAKE_LIFETIME;
|
* 600.0f / CBoat::WAKE_LIFETIME;
|
||||||
|
|
||||||
fAplhaB = clamp(val, 0.0f, 255.0f);
|
fAplhaB = Clamp(val, 0.0f, 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector2D vecDistB = pBoat->m_avec2dWakePoints[wake - 1] - pBoat->m_avec2dWakePoints[wake];
|
CVector2D vecDistB = pBoat->m_avec2dWakePoints[wake - 1] - pBoat->m_avec2dWakePoints[wake];
|
||||||
|
@ -2888,10 +2888,10 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
|
||||||
int32 nStartY = WATER_TO_SMALL_SECTOR_Y(fY - fSectorMaxRenderDist) - 1;
|
int32 nStartY = WATER_TO_SMALL_SECTOR_Y(fY - fSectorMaxRenderDist) - 1;
|
||||||
int32 nEndY = WATER_TO_SMALL_SECTOR_Y(fY + fSectorMaxRenderDist) + 1;
|
int32 nEndY = WATER_TO_SMALL_SECTOR_Y(fY + fSectorMaxRenderDist) + 1;
|
||||||
|
|
||||||
nStartX = clamp(nStartX, 0, MAX_SMALL_SECTORS - 1);
|
nStartX = Clamp(nStartX, 0, MAX_SMALL_SECTORS - 1);
|
||||||
nEndX = clamp(nEndX, 0, MAX_SMALL_SECTORS - 1);
|
nEndX = Clamp(nEndX, 0, MAX_SMALL_SECTORS - 1);
|
||||||
nStartY = clamp(nStartY, 0, MAX_SMALL_SECTORS - 1);
|
nStartY = Clamp(nStartY, 0, MAX_SMALL_SECTORS - 1);
|
||||||
nEndY = clamp(nEndY, 0, MAX_SMALL_SECTORS - 1);
|
nEndY = Clamp(nEndY, 0, MAX_SMALL_SECTORS - 1);
|
||||||
|
|
||||||
float fDistSqr = 1.0e10f;
|
float fDistSqr = 1.0e10f;
|
||||||
|
|
||||||
|
@ -2915,7 +2915,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist);
|
return Clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -286,7 +286,7 @@ void CWeather::Update(void)
|
||||||
|
|
||||||
if (SunGlare > 0.0f) {
|
if (SunGlare > 0.0f) {
|
||||||
SunGlare *= Min(1.0f, 7.0 * CTimeCycle::GetSunDirection().z);
|
SunGlare *= Min(1.0f, 7.0 * CTimeCycle::GetSunDirection().z);
|
||||||
SunGlare = clamp(SunGlare, 0.0f, 1.0f);
|
SunGlare = Clamp(SunGlare, 0.0f, 1.0f);
|
||||||
if (!CSpecialFX::bSnapShotActive)
|
if (!CSpecialFX::bSnapShotActive)
|
||||||
SunGlare *= (1.0f - (CGeneral::GetRandomNumber()&0x1F)*0.007f);
|
SunGlare *= (1.0f - (CGeneral::GetRandomNumber()&0x1F)*0.007f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,11 +321,7 @@ ConvertingTexturesScreen(uint32 num, uint32 count, const char *text)
|
||||||
splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255));
|
splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255));
|
||||||
|
|
||||||
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), SCREEN_SCALE_FROM_RIGHT(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(64, 64, 64, 255));
|
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), SCREEN_SCALE_FROM_RIGHT(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(64, 64, 64, 255));
|
||||||
#ifdef FIX_BUGS
|
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), (SCREEN_SCALE_FROM_RIGHT(200.0f) - SCREEN_SCALE_X(200.0f)) * ((float)num / (float)count) + SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(97, 194, 247, 255));
|
||||||
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), (SCREEN_SCALE_FROM_RIGHT(200.0f) - SCREEN_SCALE_X(200.0f)) * ((float)num / (float)count) + SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(255, 150, 225, 255));
|
|
||||||
#else
|
|
||||||
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), (SCREEN_SCALE_FROM_RIGHT(200.0f) - SCREEN_SCALE_X(200.0f)) * ((float)num / (float)count) + SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(255, 217, 106, 255));
|
|
||||||
#endif
|
|
||||||
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_HEIGHT - SCREEN_SCALE_Y(220.0f)), CRGBA(50, 50, 50, 210));
|
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_HEIGHT - SCREEN_SCALE_Y(220.0f)), CRGBA(50, 50, 50, 210));
|
||||||
|
|
||||||
CFont::SetBackgroundOff();
|
CFont::SetBackgroundOff();
|
||||||
|
@ -334,11 +330,7 @@ ConvertingTexturesScreen(uint32 num, uint32 count, const char *text)
|
||||||
CFont::SetCentreOff();
|
CFont::SetCentreOff();
|
||||||
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f));
|
CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f));
|
||||||
CFont::SetJustifyOff();
|
CFont::SetJustifyOff();
|
||||||
#ifdef FIX_BUGS
|
CFont::SetColor(CRGBA(115, 173, 216, 255));
|
||||||
CFont::SetColor(CRGBA(255, 150, 225, 255));
|
|
||||||
#else
|
|
||||||
CFont::SetColor(CRGBA(255, 217, 106, 255));
|
|
||||||
#endif
|
|
||||||
CFont::SetBackGroundOnlyTextOff();
|
CFont::SetBackGroundOnlyTextOff();
|
||||||
CFont::SetFontStyle(FONT_STANDARD);
|
CFont::SetFontStyle(FONT_STANDARD);
|
||||||
CFont::PrintString(SCREEN_SCALE_X(170.0f), SCREEN_SCALE_Y(160.0f), TheText.Get(text));
|
CFont::PrintString(SCREEN_SCALE_X(170.0f), SCREEN_SCALE_Y(160.0f), TheText.Get(text));
|
||||||
|
|
|
@ -540,7 +540,11 @@ GetNameOfSavedGame(int32 slot)
|
||||||
bool
|
bool
|
||||||
CheckDataNotCorrupt(int32 slot, char *name)
|
CheckDataNotCorrupt(int32 slot, char *name)
|
||||||
{
|
{
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
char filename[MAX_PATH];
|
||||||
|
#else
|
||||||
char filename[100];
|
char filename[100];
|
||||||
|
#endif
|
||||||
|
|
||||||
int32 blocknum = 0;
|
int32 blocknum = 0;
|
||||||
eLevelName level = LEVEL_GENERIC;
|
eLevelName level = LEVEL_GENERIC;
|
||||||
|
|
|
@ -25,7 +25,11 @@ C_PcSave::SetSaveDirectory(const char *path)
|
||||||
bool
|
bool
|
||||||
C_PcSave::DeleteSlot(int32 slot)
|
C_PcSave::DeleteSlot(int32 slot)
|
||||||
{
|
{
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
char FileName[MAX_PATH];
|
||||||
|
#else
|
||||||
char FileName[200];
|
char FileName[200];
|
||||||
|
#endif
|
||||||
|
|
||||||
PcSaveHelper.nErrorCode = SAVESTATUS_SUCCESSFUL;
|
PcSaveHelper.nErrorCode = SAVESTATUS_SUCCESSFUL;
|
||||||
sprintf(FileName, "%s%i.b", DefaultPCSaveFileName, slot + 1);
|
sprintf(FileName, "%s%i.b", DefaultPCSaveFileName, slot + 1);
|
||||||
|
|
115
src/save/SaveBuf.h
Normal file
115
src/save/SaveBuf.h
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#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 void
|
||||||
|
ReadSaveBuf(T *out, uint8 *&buf)
|
||||||
|
{
|
||||||
|
*out = *(T *)buf;
|
||||||
|
SkipSaveBuf(buf, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline void
|
||||||
|
ReadSaveBuf(T *out, uint8 *&buf, uint32 &length)
|
||||||
|
{
|
||||||
|
*out = *(T *)buf;
|
||||||
|
SkipSaveBuf(buf, length, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
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(buf, len, (uint32)(size));
|
||||||
|
|
||||||
|
#ifdef VALIDATE_SAVE_SIZE
|
||||||
|
#define CheckSaveHeader(buf, a, b, c, d, size) do { \
|
||||||
|
char _C; uint32 _size;\
|
||||||
|
ReadSaveBuf(&_C, buf);\
|
||||||
|
assert(_C == a);\
|
||||||
|
ReadSaveBuf(&_C, buf);\
|
||||||
|
assert(_C == b);\
|
||||||
|
ReadSaveBuf(&_C, buf);\
|
||||||
|
assert(_C == c);\
|
||||||
|
ReadSaveBuf(&_C, buf);\
|
||||||
|
assert(_C == d);\
|
||||||
|
ReadSaveBuf(&_size, buf);\
|
||||||
|
assert(_size == size);\
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define CheckSaveHeaderWithLength(buf,len,a,b,c,d,size) do { \
|
||||||
|
char _C; uint32 _size;\
|
||||||
|
ReadSaveBuf(&_C, buf, len);\
|
||||||
|
assert(_C == a);\
|
||||||
|
ReadSaveBuf(&_C, buf, len);\
|
||||||
|
assert(_C == b);\
|
||||||
|
ReadSaveBuf(&_C, buf, len);\
|
||||||
|
assert(_C == c);\
|
||||||
|
ReadSaveBuf(&_C, buf, len);\
|
||||||
|
assert(_C == d);\
|
||||||
|
ReadSaveBuf(&_size, buf, len);\
|
||||||
|
assert(_size == size);\
|
||||||
|
} while(0)
|
||||||
|
#else
|
||||||
|
#define CheckSaveHeader(buf, a, b, c, d, size) SkipSaveBuf(buf, 8);
|
||||||
|
#define CheckSaveHeaderWithLength(buf, len, a, b, c, d, size) SkipSaveBuf(buf, 8);
|
||||||
|
#endif
|
|
@ -147,7 +147,7 @@ typedef void* HANDLE;
|
||||||
|
|
||||||
struct WIN32_FIND_DATA {
|
struct WIN32_FIND_DATA {
|
||||||
char extension[32]; // for searching
|
char extension[32]; // for searching
|
||||||
char folder[32]; // for searching
|
char folder[MAX_PATH]; // for searching
|
||||||
char cFileName[256]; // because tSkinInfo has it 256
|
char cFileName[256]; // because tSkinInfo has it 256
|
||||||
time_t ftLastWriteTime;
|
time_t ftLastWriteTime;
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "Automobile.h"
|
#include "Automobile.h"
|
||||||
#include "Bike.h"
|
#include "Bike.h"
|
||||||
#include "Wanted.h"
|
#include "Wanted.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
bool bAllCarCheat;
|
bool bAllCarCheat;
|
||||||
|
|
||||||
|
@ -932,7 +933,7 @@ CAutomobile::ProcessControl(void)
|
||||||
float adhesion = CSurfaceTable::GetAdhesiveLimit(point);
|
float adhesion = CSurfaceTable::GetAdhesiveLimit(point);
|
||||||
// i have no idea what's going on here
|
// i have no idea what's going on here
|
||||||
float magic = traction * adhesion * 16.0f / SQR(fwdSpeed);
|
float magic = traction * adhesion * 16.0f / SQR(fwdSpeed);
|
||||||
magic = clamp(magic, -1.0f, 1.0f);
|
magic = Clamp(magic, -1.0f, 1.0f);
|
||||||
magic = Asin(magic);
|
magic = Asin(magic);
|
||||||
if(m_fSteerAngle < 0.0f && rightSpeed > 0.05f ||
|
if(m_fSteerAngle < 0.0f && rightSpeed > 0.05f ||
|
||||||
m_fSteerAngle > 0.0f && rightSpeed < -0.05f ||
|
m_fSteerAngle > 0.0f && rightSpeed < -0.05f ||
|
||||||
|
@ -2080,7 +2081,7 @@ CAutomobile::PreRender(void)
|
||||||
|
|
||||||
// 1.0 if directly behind car, -1.0 if in front
|
// 1.0 if directly behind car, -1.0 if in front
|
||||||
float behindness = DotProduct(lookVector, GetForward());
|
float behindness = DotProduct(lookVector, GetForward());
|
||||||
behindness = clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary
|
behindness = Clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary
|
||||||
// 0.0 if behind car, PI if in front
|
// 0.0 if behind car, PI if in front
|
||||||
// Abs not necessary
|
// Abs not necessary
|
||||||
float angle = Abs(Acos(behindness));
|
float angle = Abs(Acos(behindness));
|
||||||
|
@ -2438,7 +2439,7 @@ CAutomobile::PreRender(void)
|
||||||
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
||||||
if(GetModelIndex() == MI_VOODOO)
|
if(GetModelIndex() == MI_VOODOO)
|
||||||
groundOffset *= 0.6f;
|
groundOffset *= 0.6f;
|
||||||
mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
|
mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pHandling->Flags & HANDLING_FAT_REARW)
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
||||||
|
@ -2479,7 +2480,7 @@ CAutomobile::PreRender(void)
|
||||||
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
||||||
if(GetModelIndex() == MI_VOODOO)
|
if(GetModelIndex() == MI_VOODOO)
|
||||||
groundOffset *= 0.6f;
|
groundOffset *= 0.6f;
|
||||||
mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
|
mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pHandling->Flags & HANDLING_FAT_REARW)
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
||||||
|
@ -2512,7 +2513,7 @@ CAutomobile::PreRender(void)
|
||||||
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
||||||
if(GetModelIndex() == MI_VOODOO)
|
if(GetModelIndex() == MI_VOODOO)
|
||||||
groundOffset *= 0.6f;
|
groundOffset *= 0.6f;
|
||||||
mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
|
mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pHandling->Flags & HANDLING_FAT_REARW)
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
||||||
|
@ -2546,7 +2547,7 @@ CAutomobile::PreRender(void)
|
||||||
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
||||||
if(GetModelIndex() == MI_VOODOO)
|
if(GetModelIndex() == MI_VOODOO)
|
||||||
groundOffset *= 0.6f;
|
groundOffset *= 0.6f;
|
||||||
mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
|
mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pHandling->Flags & HANDLING_FAT_REARW)
|
if(pHandling->Flags & HANDLING_FAT_REARW)
|
||||||
|
@ -2680,7 +2681,7 @@ CAutomobile::PreRender(void)
|
||||||
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
||||||
if(GetModelIndex() == MI_VOODOO)
|
if(GetModelIndex() == MI_VOODOO)
|
||||||
groundOffset *= 0.6f;
|
groundOffset *= 0.6f;
|
||||||
mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
|
mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
|
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
|
||||||
|
@ -2721,7 +2722,7 @@ CAutomobile::PreRender(void)
|
||||||
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
|
||||||
if(GetModelIndex() == MI_VOODOO)
|
if(GetModelIndex() == MI_VOODOO)
|
||||||
groundOffset *= 0.6f;
|
groundOffset *= 0.6f;
|
||||||
mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
|
mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
|
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
|
||||||
|
@ -2947,7 +2948,7 @@ CAutomobile::ProcessControlInputs(uint8 pad)
|
||||||
0.2f*CTimer::GetTimeStep();
|
0.2f*CTimer::GetTimeStep();
|
||||||
nLastControlInput = 0;
|
nLastControlInput = 0;
|
||||||
}
|
}
|
||||||
m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
|
m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f);
|
||||||
|
|
||||||
// Accelerate/Brake
|
// Accelerate/Brake
|
||||||
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
|
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
|
||||||
|
@ -3067,7 +3068,7 @@ CAutomobile::FireTruckControl(void)
|
||||||
m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep();
|
m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep();
|
||||||
m_fCarGunUD += CPad::GetPad(0)->GetCarGunUpDown() * 0.0001f * CTimer::GetTimeStep();
|
m_fCarGunUD += CPad::GetPad(0)->GetCarGunUpDown() * 0.0001f * CTimer::GetTimeStep();
|
||||||
}
|
}
|
||||||
m_fCarGunUD = clamp(m_fCarGunUD, 0.05f, 0.3f);
|
m_fCarGunUD = Clamp(m_fCarGunUD, 0.05f, 0.3f);
|
||||||
|
|
||||||
|
|
||||||
CVector cannonPos(0.0f, 1.5f, 1.9f);
|
CVector cannonPos(0.0f, 1.5f, 1.9f);
|
||||||
|
@ -3492,7 +3493,7 @@ CAutomobile::HydraulicControl(void)
|
||||||
float limitDiff = extendedLowerLimit - normalLowerLimit;
|
float limitDiff = extendedLowerLimit - normalLowerLimit;
|
||||||
if(limitDiff != 0.0f && Abs(maxDelta/limitDiff) > 0.01f){
|
if(limitDiff != 0.0f && Abs(maxDelta/limitDiff) > 0.01f){
|
||||||
float f = (maxDelta + limitDiff)/2.0f/limitDiff;
|
float f = (maxDelta + limitDiff)/2.0f/limitDiff;
|
||||||
f = clamp(f, 0.0f, 1.0f);
|
f = Clamp(f, 0.0f, 1.0f);
|
||||||
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_3, f);
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_3, f);
|
||||||
if(f < 0.4f || f > 0.6f)
|
if(f < 0.4f || f > 0.6f)
|
||||||
setPrevRatio = true;
|
setPrevRatio = true;
|
||||||
|
@ -5723,7 +5724,7 @@ void
|
||||||
CAutomobile::Save(uint8*& buf)
|
CAutomobile::Save(uint8*& buf)
|
||||||
{
|
{
|
||||||
CVehicle::Save(buf);
|
CVehicle::Save(buf);
|
||||||
WriteSaveBuf<CDamageManager>(buf, Damage);
|
WriteSaveBuf(buf, Damage);
|
||||||
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
|
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5731,7 +5732,7 @@ void
|
||||||
CAutomobile::Load(uint8*& buf)
|
CAutomobile::Load(uint8*& buf)
|
||||||
{
|
{
|
||||||
CVehicle::Load(buf);
|
CVehicle::Load(buf);
|
||||||
Damage = ReadSaveBuf<CDamageManager>(buf);
|
ReadSaveBuf(&Damage, buf);
|
||||||
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
|
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
|
||||||
SetupDamageAfterLoad();
|
SetupDamageAfterLoad();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "Automobile.h"
|
#include "Automobile.h"
|
||||||
#include "Bike.h"
|
#include "Bike.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
const uint32 CBike::nSaveStructSize =
|
const uint32 CBike::nSaveStructSize =
|
||||||
#ifdef COMPATIBLE_SAVES
|
#ifdef COMPATIBLE_SAVES
|
||||||
|
@ -535,7 +536,7 @@ CBike::ProcessControl(void)
|
||||||
m_fWheelAngle += DEGTORAD(1.0f)*CTimer::GetTimeStep();
|
m_fWheelAngle += DEGTORAD(1.0f)*CTimer::GetTimeStep();
|
||||||
if(bIsStanding){
|
if(bIsStanding){
|
||||||
float f = Pow(0.97f, CTimer::GetTimeStep());
|
float f = Pow(0.97f, CTimer::GetTimeStep());
|
||||||
m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f);
|
m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(Clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f);
|
||||||
m_fLeanLRAngle = m_fLeanLRAngle2;
|
m_fLeanLRAngle = m_fLeanLRAngle2;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -1030,9 +1031,9 @@ CBike::ProcessControl(void)
|
||||||
lean = DotProduct(m_vecMoveSpeed-initialMoveSpeed, m_vecAvgSurfaceRight);
|
lean = DotProduct(m_vecMoveSpeed-initialMoveSpeed, m_vecAvgSurfaceRight);
|
||||||
lean /= GRAVITY*Max(CTimer::GetTimeStep(), 0.01f);
|
lean /= GRAVITY*Max(CTimer::GetTimeStep(), 0.01f);
|
||||||
if(m_wheelStatus[BIKEWHEEL_FRONT] == WHEEL_STATUS_BURST)
|
if(m_wheelStatus[BIKEWHEEL_FRONT] == WHEEL_STATUS_BURST)
|
||||||
lean = clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean);
|
lean = Clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean);
|
||||||
else
|
else
|
||||||
lean = clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean);
|
lean = Clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean);
|
||||||
float f = Pow(pBikeHandling->fDesLean, CTimer::GetTimeStep());
|
float f = Pow(pBikeHandling->fDesLean, CTimer::GetTimeStep());
|
||||||
m_fLeanLRAngle2 = (Asin(lean) - idleAngle)*(1.0f-f) + m_fLeanLRAngle2*f;
|
m_fLeanLRAngle2 = (Asin(lean) - idleAngle)*(1.0f-f) + m_fLeanLRAngle2*f;
|
||||||
}else{
|
}else{
|
||||||
|
@ -1055,11 +1056,11 @@ CBike::ProcessControl(void)
|
||||||
if(m_aSuspensionSpringRatio[BIKESUSP_R1] < 1.0f || m_aSuspensionSpringRatio[BIKESUSP_R2] < 1.0f){
|
if(m_aSuspensionSpringRatio[BIKESUSP_R1] < 1.0f || m_aSuspensionSpringRatio[BIKESUSP_R2] < 1.0f){
|
||||||
// BUG: this clamp makes no sense and the arguments seem swapped too
|
// BUG: this clamp makes no sense and the arguments seem swapped too
|
||||||
ApplyTurnForce(contactPoints[BIKESUSP_R1],
|
ApplyTurnForce(contactPoints[BIKESUSP_R1],
|
||||||
m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep());
|
m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep());
|
||||||
}else{
|
}else{
|
||||||
// BUG: this clamp makes no sense and the arguments seem swapped too
|
// BUG: this clamp makes no sense and the arguments seem swapped too
|
||||||
ApplyTurnForce(contactPoints[BIKESUSP_R1],
|
ApplyTurnForce(contactPoints[BIKESUSP_R1],
|
||||||
m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep());
|
m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep());
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
m_fBrakeDestabilization = 0.0f;
|
m_fBrakeDestabilization = 0.0f;
|
||||||
|
@ -1222,7 +1223,7 @@ CBike::ProcessControl(void)
|
||||||
// Balance bike
|
// Balance bike
|
||||||
if(bBalancedByRider || bIsBeingPickedUp || bIsStanding){
|
if(bBalancedByRider || bIsBeingPickedUp || bIsStanding){
|
||||||
float onSideness = DotProduct(GetRight(), m_vecAvgSurfaceNormal);
|
float onSideness = DotProduct(GetRight(), m_vecAvgSurfaceNormal);
|
||||||
onSideness = clamp(onSideness, -1.0f, 1.0f);
|
onSideness = Clamp(onSideness, -1.0f, 1.0f);
|
||||||
CVector worldCOM = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
|
CVector worldCOM = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
|
||||||
// Keep bike upright
|
// Keep bike upright
|
||||||
if(bBalancedByRider){
|
if(bBalancedByRider){
|
||||||
|
@ -1842,7 +1843,7 @@ CBike::ProcessControlInputs(uint8 pad)
|
||||||
0.2f*CTimer::GetTimeStep();
|
0.2f*CTimer::GetTimeStep();
|
||||||
nLastControlInput = 0;
|
nLastControlInput = 0;
|
||||||
}
|
}
|
||||||
m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
|
m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f);
|
||||||
|
|
||||||
// Lean forward/backward
|
// Lean forward/backward
|
||||||
float updown;
|
float updown;
|
||||||
|
@ -1852,7 +1853,7 @@ CBike::ProcessControlInputs(uint8 pad)
|
||||||
#endif
|
#endif
|
||||||
updown = -CPad::GetPad(pad)->GetSteeringUpDown()/128.0f + CPad::GetPad(pad)->GetCarGunUpDown()/128.0f;
|
updown = -CPad::GetPad(pad)->GetSteeringUpDown()/128.0f + CPad::GetPad(pad)->GetCarGunUpDown()/128.0f;
|
||||||
m_fLeanInput += (updown - m_fLeanInput)*0.2f*CTimer::GetTimeStep();
|
m_fLeanInput += (updown - m_fLeanInput)*0.2f*CTimer::GetTimeStep();
|
||||||
m_fLeanInput = clamp(m_fLeanInput, -1.0f, 1.0f);
|
m_fLeanInput = Clamp(m_fLeanInput, -1.0f, 1.0f);
|
||||||
|
|
||||||
// Accelerate/Brake
|
// Accelerate/Brake
|
||||||
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
|
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
#include "Shadows.h"
|
#include "Shadows.h"
|
||||||
#include "Wanted.h"
|
#include "Wanted.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
#define INVALID_ORIENTATION (-9999.99f)
|
#define INVALID_ORIENTATION (-9999.99f)
|
||||||
|
|
||||||
|
@ -157,9 +158,9 @@ CBoat::ProcessControl(void)
|
||||||
r = 127.5f*(CTimeCycle::GetAmbientRed_Obj() + 0.5f*CTimeCycle::GetDirectionalRed());
|
r = 127.5f*(CTimeCycle::GetAmbientRed_Obj() + 0.5f*CTimeCycle::GetDirectionalRed());
|
||||||
g = 127.5f*(CTimeCycle::GetAmbientGreen_Obj() + 0.5f*CTimeCycle::GetDirectionalGreen());
|
g = 127.5f*(CTimeCycle::GetAmbientGreen_Obj() + 0.5f*CTimeCycle::GetDirectionalGreen());
|
||||||
b = 127.5f*(CTimeCycle::GetAmbientBlue_Obj() + 0.5f*CTimeCycle::GetDirectionalBlue());
|
b = 127.5f*(CTimeCycle::GetAmbientBlue_Obj() + 0.5f*CTimeCycle::GetDirectionalBlue());
|
||||||
r = clamp(r, 0, 255);
|
r = Clamp(r, 0, 255);
|
||||||
g = clamp(g, 0, 255);
|
g = Clamp(g, 0, 255);
|
||||||
b = clamp(b, 0, 255);
|
b = Clamp(b, 0, 255);
|
||||||
splashColor.red = r;
|
splashColor.red = r;
|
||||||
splashColor.green = g;
|
splashColor.green = g;
|
||||||
splashColor.blue = b;
|
splashColor.blue = b;
|
||||||
|
@ -168,9 +169,9 @@ CBoat::ProcessControl(void)
|
||||||
r = 229.5f*(CTimeCycle::GetAmbientRed() + 0.85f*CTimeCycle::GetDirectionalRed());
|
r = 229.5f*(CTimeCycle::GetAmbientRed() + 0.85f*CTimeCycle::GetDirectionalRed());
|
||||||
g = 229.5f*(CTimeCycle::GetAmbientGreen() + 0.85f*CTimeCycle::GetDirectionalGreen());
|
g = 229.5f*(CTimeCycle::GetAmbientGreen() + 0.85f*CTimeCycle::GetDirectionalGreen());
|
||||||
b = 229.5f*(CTimeCycle::GetAmbientBlue() + 0.85f*CTimeCycle::GetDirectionalBlue());
|
b = 229.5f*(CTimeCycle::GetAmbientBlue() + 0.85f*CTimeCycle::GetDirectionalBlue());
|
||||||
r = clamp(r, 0, 255);
|
r = Clamp(r, 0, 255);
|
||||||
g = clamp(g, 0, 255);
|
g = Clamp(g, 0, 255);
|
||||||
b = clamp(b, 0, 255);
|
b = Clamp(b, 0, 255);
|
||||||
jetColor.red = r;
|
jetColor.red = r;
|
||||||
jetColor.green = g;
|
jetColor.green = g;
|
||||||
jetColor.blue = b;
|
jetColor.blue = b;
|
||||||
|
@ -386,7 +387,7 @@ CBoat::ProcessControl(void)
|
||||||
if(CPad::GetPad(0)->GetHandBrake())
|
if(CPad::GetPad(0)->GetHandBrake())
|
||||||
steerLoss *= 0.5f;
|
steerLoss *= 0.5f;
|
||||||
steerFactor -= steerLoss;
|
steerFactor -= steerLoss;
|
||||||
steerFactor = clamp(steerFactor, 0.0f, 1.0f);
|
steerFactor = Clamp(steerFactor, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector boundMin = GetColModel()->boundingBox.min;
|
CVector boundMin = GetColModel()->boundingBox.min;
|
||||||
|
@ -771,17 +772,17 @@ CBoat::ProcessControlInputs(uint8 pad)
|
||||||
m_nPadID = 3;
|
m_nPadID = 3;
|
||||||
|
|
||||||
m_fBrake += (CPad::GetPad(pad)->GetBrake()/255.0f - m_fBrake)*0.1f;
|
m_fBrake += (CPad::GetPad(pad)->GetBrake()/255.0f - m_fBrake)*0.1f;
|
||||||
m_fBrake = clamp(m_fBrake, 0.0f, 1.0f);
|
m_fBrake = Clamp(m_fBrake, 0.0f, 1.0f);
|
||||||
|
|
||||||
if(m_fBrake < 0.05f){
|
if(m_fBrake < 0.05f){
|
||||||
m_fBrake = 0.0f;
|
m_fBrake = 0.0f;
|
||||||
m_fAccelerate += (CPad::GetPad(pad)->GetAccelerate()/255.0f - m_fAccelerate)*0.1f;
|
m_fAccelerate += (CPad::GetPad(pad)->GetAccelerate()/255.0f - m_fAccelerate)*0.1f;
|
||||||
m_fAccelerate = clamp(m_fAccelerate, 0.0f, 1.0f);
|
m_fAccelerate = Clamp(m_fAccelerate, 0.0f, 1.0f);
|
||||||
}else
|
}else
|
||||||
m_fAccelerate = -m_fBrake*0.3f;
|
m_fAccelerate = -m_fBrake*0.3f;
|
||||||
|
|
||||||
m_fSteeringLeftRight += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteeringLeftRight)*0.2f;
|
m_fSteeringLeftRight += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteeringLeftRight)*0.2f;
|
||||||
m_fSteeringLeftRight = clamp(m_fSteeringLeftRight, -1.0f, 1.0f);
|
m_fSteeringLeftRight = Clamp(m_fSteeringLeftRight, -1.0f, 1.0f);
|
||||||
|
|
||||||
float steeringSq = m_fSteeringLeftRight < 0.0f ? -SQR(m_fSteeringLeftRight) : SQR(m_fSteeringLeftRight);
|
float steeringSq = m_fSteeringLeftRight < 0.0f ? -SQR(m_fSteeringLeftRight) : SQR(m_fSteeringLeftRight);
|
||||||
m_fSteerAngle = pHandling->fSteeringLock * DEGTORAD(steeringSq);
|
m_fSteerAngle = pHandling->fSteeringLock * DEGTORAD(steeringSq);
|
||||||
|
@ -1064,7 +1065,7 @@ CBoat::PreRender(void)
|
||||||
rot = CGeneral::LimitRadianAngle(rot);
|
rot = CGeneral::LimitRadianAngle(rot);
|
||||||
if(rot > HALFPI) rot = PI;
|
if(rot > HALFPI) rot = PI;
|
||||||
else if(rot < -HALFPI) rot = -PI;
|
else if(rot < -HALFPI) rot = -PI;
|
||||||
rot = clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f));
|
rot = Clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f));
|
||||||
m_fMovingSpeed += (0.008f * CWeather::Wind + 0.002f) * rot;
|
m_fMovingSpeed += (0.008f * CWeather::Wind + 0.002f) * rot;
|
||||||
m_fMovingSpeed *= Pow(0.9985f, CTimer::GetTimeStep())/(500.0f*SQR(m_fMovingSpeed) + 1.0f);
|
m_fMovingSpeed *= Pow(0.9985f, CTimer::GetTimeStep())/(500.0f*SQR(m_fMovingSpeed) + 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Zones.h"
|
#include "Zones.h"
|
||||||
#include "Occlusion.h"
|
#include "Occlusion.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
uint8 CTheCarGenerators::ProcessCounter;
|
uint8 CTheCarGenerators::ProcessCounter;
|
||||||
uint32 CTheCarGenerators::NumOfCarGenerators;
|
uint32 CTheCarGenerators::NumOfCarGenerators;
|
||||||
|
@ -292,14 +293,17 @@ void CTheCarGenerators::LoadAllCarGenerators(uint8* buffer, uint32 size)
|
||||||
Init();
|
Init();
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
CheckSaveHeader(buffer, 'C','G','N','\0', size - SAVE_HEADER_SIZE);
|
CheckSaveHeader(buffer, 'C','G','N','\0', size - SAVE_HEADER_SIZE);
|
||||||
assert(ReadSaveBuf<uint32>(buffer) == nGeneralDataSize);
|
uint32 tmp;
|
||||||
NumOfCarGenerators = ReadSaveBuf<uint32>(buffer);
|
ReadSaveBuf(&tmp, buffer);
|
||||||
CurrentActiveCount = ReadSaveBuf<uint32>(buffer);
|
assert(tmp == nGeneralDataSize);
|
||||||
ProcessCounter = ReadSaveBuf<uint8>(buffer);
|
ReadSaveBuf(&NumOfCarGenerators, buffer);
|
||||||
GenerateEvenIfPlayerIsCloseCounter = ReadSaveBuf<uint8>(buffer);
|
ReadSaveBuf(&CurrentActiveCount, buffer);
|
||||||
ReadSaveBuf<int16>(buffer); // alignment
|
ReadSaveBuf(&ProcessCounter, buffer);
|
||||||
assert(ReadSaveBuf<uint32>(buffer) == sizeof(CarGeneratorArray));
|
ReadSaveBuf(&GenerateEvenIfPlayerIsCloseCounter, buffer);
|
||||||
|
SkipSaveBuf(buffer, 2);
|
||||||
|
ReadSaveBuf(&tmp, buffer);
|
||||||
|
assert(tmp == sizeof(CarGeneratorArray));
|
||||||
for (int i = 0; i < NUM_CARGENS; i++)
|
for (int i = 0; i < NUM_CARGENS; i++)
|
||||||
CarGeneratorArray[i] = ReadSaveBuf<CCarGenerator>(buffer);
|
ReadSaveBuf(&CarGeneratorArray[i], buffer);
|
||||||
VALIDATESAVEBUF(size)
|
VALIDATESAVEBUF(size)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "Replay.h"
|
#include "Replay.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
#define MAX_DISTANCE_TO_FIND_CRANE (100.0f)
|
#define MAX_DISTANCE_TO_FIND_CRANE (100.0f)
|
||||||
#define CRANE_UPDATE_RADIUS (300.0f)
|
#define CRANE_UPDATE_RADIUS (300.0f)
|
||||||
|
@ -643,10 +644,10 @@ void CCranes::Load(uint8* buf, uint32 size)
|
||||||
{
|
{
|
||||||
INITSAVEBUF
|
INITSAVEBUF
|
||||||
|
|
||||||
NumCranes = ReadSaveBuf<int32>(buf);
|
ReadSaveBuf(&NumCranes, buf);
|
||||||
CarsCollectedMilitaryCrane = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&CarsCollectedMilitaryCrane, buf);
|
||||||
for (int i = 0; i < NUM_CRANES; i++)
|
for (int i = 0; i < NUM_CRANES; i++)
|
||||||
aCranes[i] = ReadSaveBuf<CCrane>(buf);
|
ReadSaveBuf(&aCranes[i], buf);
|
||||||
for (int i = 0; i < NUM_CRANES; i++) {
|
for (int i = 0; i < NUM_CRANES; i++) {
|
||||||
CCrane *pCrane = &aCranes[i];
|
CCrane *pCrane = &aCranes[i];
|
||||||
if (pCrane->m_pCraneEntity != nil)
|
if (pCrane->m_pCraneEntity != nil)
|
||||||
|
|
|
@ -52,11 +52,11 @@ CDoor::Process(CVehicle *vehicle)
|
||||||
fSpeedDiff = vecSpeedDiff.y - vecSpeedDiff.x;
|
fSpeedDiff = vecSpeedDiff.y - vecSpeedDiff.x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fSpeedDiff = clamp(fSpeedDiff, -0.2f, 0.2f);
|
fSpeedDiff = Clamp(fSpeedDiff, -0.2f, 0.2f);
|
||||||
if(Abs(fSpeedDiff) > 0.002f)
|
if(Abs(fSpeedDiff) > 0.002f)
|
||||||
m_fAngVel += fSpeedDiff;
|
m_fAngVel += fSpeedDiff;
|
||||||
m_fAngVel *= 0.945f;
|
m_fAngVel *= 0.945f;
|
||||||
m_fAngVel = clamp(m_fAngVel, -0.3f, 0.3f);
|
m_fAngVel = Clamp(m_fAngVel, -0.3f, 0.3f);
|
||||||
|
|
||||||
m_fAngle += m_fAngVel;
|
m_fAngle += m_fAngVel;
|
||||||
m_nDoorState = DOORST_SWINGING;
|
m_nDoorState = DOORST_SWINGING;
|
||||||
|
|
|
@ -260,7 +260,7 @@ CHeli::ProcessControl(void)
|
||||||
// Move up if too low
|
// Move up if too low
|
||||||
if(GetPosition().z - 2.0f < groundZ && m_heliStatus != HELI_STATUS_SHOT_DOWN)
|
if(GetPosition().z - 2.0f < groundZ && m_heliStatus != HELI_STATUS_SHOT_DOWN)
|
||||||
m_vecMoveSpeed.z += CTimer::GetTimeStep()*0.01f;
|
m_vecMoveSpeed.z += CTimer::GetTimeStep()*0.01f;
|
||||||
m_vecMoveSpeed.z = clamp(m_vecMoveSpeed.z, -0.3f, 0.3f);
|
m_vecMoveSpeed.z = Clamp(m_vecMoveSpeed.z, -0.3f, 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float fTargetDist = vTargetDist.Magnitude();
|
float fTargetDist = vTargetDist.Magnitude();
|
||||||
|
|
|
@ -150,7 +150,7 @@ cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, fl
|
||||||
else if(cheat == 2)
|
else if(cheat == 2)
|
||||||
inertiaMult *= TRANSMISSION_NITROS_INERTIA_MULT;
|
inertiaMult *= TRANSMISSION_NITROS_INERTIA_MULT;
|
||||||
float var2target = 1.0f - inertiaMult*fEngineInertia;
|
float var2target = 1.0f - inertiaMult*fEngineInertia;
|
||||||
var2target = clamp(var2target, 0.1f, 1.0f);
|
var2target = Clamp(var2target, 0.1f, 1.0f);
|
||||||
*inertiaVar2 = (1.0f-TRANSMISSION_SMOOTHER_FRAC)*var2target + TRANSMISSION_SMOOTHER_FRAC*(*inertiaVar2);
|
*inertiaVar2 = (1.0f-TRANSMISSION_SMOOTHER_FRAC)*var2target + TRANSMISSION_SMOOTHER_FRAC*(*inertiaVar2);
|
||||||
*inertiaVar1 = var1;
|
*inertiaVar1 = var1;
|
||||||
fAcceleration *= *inertiaVar2;
|
fAcceleration *= *inertiaVar2;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "Timecycle.h"
|
#include "Timecycle.h"
|
||||||
#include "Weather.h"
|
#include "Weather.h"
|
||||||
#include "Coronas.h"
|
#include "Coronas.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
bool CVehicle::bWheelsOnlyCheat;
|
bool CVehicle::bWheelsOnlyCheat;
|
||||||
bool CVehicle::bAllDodosCheat;
|
bool CVehicle::bAllDodosCheat;
|
||||||
|
@ -479,11 +480,11 @@ CVehicle::FlyingControl(eFlightModel flightModel)
|
||||||
ApplyMoveForce(GRAVITY * GetUp() * fThrust * m_fMass * CTimer::GetTimeStep());
|
ApplyMoveForce(GRAVITY * GetUp() * fThrust * m_fMass * CTimer::GetTimeStep());
|
||||||
|
|
||||||
if (GetUp().z > 0.0f){
|
if (GetUp().z > 0.0f){
|
||||||
float upRight = clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
|
float upRight = Clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
|
||||||
float upImpulseRight = -upRight * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
|
float upImpulseRight = -upRight * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
|
||||||
ApplyTurnForce(upImpulseRight * GetUp(), GetRight());
|
ApplyTurnForce(upImpulseRight * GetUp(), GetRight());
|
||||||
|
|
||||||
float upFwd = clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
|
float upFwd = Clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
|
||||||
float upImpulseFwd = -upFwd * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
|
float upImpulseFwd = -upFwd * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
|
||||||
ApplyTurnForce(upImpulseFwd * GetUp(), GetForward());
|
ApplyTurnForce(upImpulseFwd * GetUp(), GetForward());
|
||||||
}else{
|
}else{
|
||||||
|
@ -522,8 +523,8 @@ CVehicle::FlyingControl(eFlightModel flightModel)
|
||||||
fPitch = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f;
|
fPitch = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f;
|
||||||
if (CPad::GetPad(0)->GetHorn()) {
|
if (CPad::GetPad(0)->GetHorn()) {
|
||||||
fYaw = 0.0f;
|
fYaw = 0.0f;
|
||||||
fPitch = clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f);
|
fPitch = Clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f);
|
||||||
fRoll = clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f);
|
fRoll = Clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f);
|
||||||
}
|
}
|
||||||
ApplyTurnForce(fPitch * GetUp() * flyingHandling->fPitch * m_fTurnMass * CTimer::GetTimeStep(), GetForward());
|
ApplyTurnForce(fPitch * GetUp() * flyingHandling->fPitch * m_fTurnMass * CTimer::GetTimeStep(), GetForward());
|
||||||
ApplyTurnForce(fRoll * GetUp() * flyingHandling->fRoll * m_fTurnMass * CTimer::GetTimeStep(), GetRight());
|
ApplyTurnForce(fRoll * GetUp() * flyingHandling->fRoll * m_fTurnMass * CTimer::GetTimeStep(), GetRight());
|
||||||
|
@ -2173,9 +2174,9 @@ CVehicle::HeliDustGenerate(CEntity *heli, float radius, float ground, int rnd)
|
||||||
float red = (0.3*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed_Obj())*255.0f/4.0f;
|
float red = (0.3*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed_Obj())*255.0f/4.0f;
|
||||||
float green = (0.3*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj())*255.0f/4.0f;
|
float green = (0.3*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj())*255.0f/4.0f;
|
||||||
float blue = (0.3*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj())*255.0f/4.0f;
|
float blue = (0.3*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj())*255.0f/4.0f;
|
||||||
r = clamp(red, 0.0f, 255.0f);
|
r = Clamp(red, 0.0f, 255.0f);
|
||||||
g = clamp(green, 0.0f, 255.0f);
|
g = Clamp(green, 0.0f, 255.0f);
|
||||||
b = clamp(blue, 0.0f, 255.0f);
|
b = Clamp(blue, 0.0f, 255.0f);
|
||||||
RwRGBA col1 = { r, g, b, (RwUInt8)CGeneral::GetRandomNumberInRange(8, 32) };
|
RwRGBA col1 = { r, g, b, (RwUInt8)CGeneral::GetRandomNumberInRange(8, 32) };
|
||||||
RwRGBA col2 = { 255, 255, 255, 32 };
|
RwRGBA col2 = { 255, 255, 255, 32 };
|
||||||
|
|
||||||
|
@ -2438,43 +2439,44 @@ CVehicle::Load(uint8*& buf)
|
||||||
{
|
{
|
||||||
CMatrix tmp;
|
CMatrix tmp;
|
||||||
SkipSaveBuf(buf, 4);
|
SkipSaveBuf(buf, 4);
|
||||||
tmp.GetRight().x = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetRight().x, buf);
|
||||||
tmp.GetRight().y = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetRight().y, buf);
|
||||||
tmp.GetRight().z = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetRight().z, buf);
|
||||||
SkipSaveBuf(buf, 4);
|
SkipSaveBuf(buf, 4);
|
||||||
tmp.GetForward().x = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetForward().x, buf);
|
||||||
tmp.GetForward().y = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetForward().y, buf);
|
||||||
tmp.GetForward().z = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetForward().z, buf);
|
||||||
SkipSaveBuf(buf, 4);
|
SkipSaveBuf(buf, 4);
|
||||||
tmp.GetUp().x = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetUp().x, buf);
|
||||||
tmp.GetUp().y = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetUp().y, buf);
|
||||||
tmp.GetUp().z = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetUp().z, buf);
|
||||||
SkipSaveBuf(buf, 4);
|
SkipSaveBuf(buf, 4);
|
||||||
tmp.GetPosition().x = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetPosition().x, buf);
|
||||||
tmp.GetPosition().y = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetPosition().y, buf);
|
||||||
tmp.GetPosition().z = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&tmp.GetPosition().z, buf);
|
||||||
m_matrix = tmp;
|
m_matrix = tmp;
|
||||||
SkipSaveBuf(buf, 16);
|
SkipSaveBuf(buf, 16);
|
||||||
LoadEntityFlags(buf);
|
LoadEntityFlags(buf);
|
||||||
SkipSaveBuf(buf, 208);
|
SkipSaveBuf(buf, 208);
|
||||||
AutoPilot.Load(buf);
|
AutoPilot.Load(buf);
|
||||||
m_currentColour1 = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_currentColour1, buf);
|
||||||
m_currentColour2 = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_currentColour2, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
m_nAlarmState = ReadSaveBuf<int16>(buf);
|
ReadSaveBuf(&m_nAlarmState, buf);
|
||||||
SkipSaveBuf(buf, 42);
|
SkipSaveBuf(buf, 42);
|
||||||
m_nNumMaxPassengers = ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&m_nNumMaxPassengers, buf);
|
||||||
SkipSaveBuf(buf, 3);
|
SkipSaveBuf(buf, 3);
|
||||||
field_1D0[0] = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&field_1D0[0], buf);
|
||||||
field_1D0[1] = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&field_1D0[1], buf);
|
||||||
field_1D0[2] = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&field_1D0[2], buf);
|
||||||
field_1D0[3] = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&field_1D0[3], buf);
|
||||||
SkipSaveBuf(buf, 8);
|
SkipSaveBuf(buf, 8);
|
||||||
m_fSteerAngle = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_fSteerAngle, buf);
|
||||||
m_fGasPedal = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_fGasPedal, buf);
|
||||||
m_fBrakePedal = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_fBrakePedal, buf);
|
||||||
VehicleCreatedBy = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&VehicleCreatedBy, buf);
|
||||||
uint8 flags = ReadSaveBuf<uint8>(buf);
|
uint8 flags;
|
||||||
|
ReadSaveBuf(&flags, buf);
|
||||||
bIsLawEnforcer = !!(flags & BIT(0));
|
bIsLawEnforcer = !!(flags & BIT(0));
|
||||||
bIsLocked = !!(flags & BIT(3));
|
bIsLocked = !!(flags & BIT(3));
|
||||||
bEngineOn = !!(flags & BIT(4));
|
bEngineOn = !!(flags & BIT(4));
|
||||||
|
@ -2482,16 +2484,17 @@ CVehicle::Load(uint8*& buf)
|
||||||
bLightsOn = !!(flags & BIT(6));
|
bLightsOn = !!(flags & BIT(6));
|
||||||
bFreebies = !!(flags & BIT(7));
|
bFreebies = !!(flags & BIT(7));
|
||||||
SkipSaveBuf(buf, 10);
|
SkipSaveBuf(buf, 10);
|
||||||
m_fHealth = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_fHealth, buf);
|
||||||
m_nCurrentGear = ReadSaveBuf<uint8>(buf);
|
ReadSaveBuf(&m_nCurrentGear, buf);
|
||||||
SkipSaveBuf(buf, 3);
|
SkipSaveBuf(buf, 3);
|
||||||
m_fChangeGearTime = ReadSaveBuf<float>(buf);
|
ReadSaveBuf(&m_fChangeGearTime, buf);
|
||||||
SkipSaveBuf(buf, 12);
|
SkipSaveBuf(buf, 12);
|
||||||
m_nTimeOfDeath = ReadSaveBuf<uint32>(buf);
|
ReadSaveBuf(&m_nTimeOfDeath, buf);
|
||||||
SkipSaveBuf(buf, 2);
|
SkipSaveBuf(buf, 2);
|
||||||
m_nBombTimer = ReadSaveBuf<int16>(buf);
|
ReadSaveBuf(&m_nBombTimer, buf);
|
||||||
SkipSaveBuf(buf, 12);
|
SkipSaveBuf(buf, 12);
|
||||||
m_nDoorLock = (eCarLock)ReadSaveBuf<int8>(buf);
|
ReadSaveBuf(&flags, buf);
|
||||||
|
m_nDoorLock = (eCarLock)flags;
|
||||||
SkipSaveBuf(buf, 111);
|
SkipSaveBuf(buf, 111);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "Glass.h"
|
#include "Glass.h"
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "Pickups.h"
|
#include "Pickups.h"
|
||||||
|
#include "SaveBuf.h"
|
||||||
|
|
||||||
float fReloadAnimSampleFraction[5] = { 0.5f, 0.7f, 0.75f, 0.75f, 0.7f };
|
float fReloadAnimSampleFraction[5] = { 0.5f, 0.7f, 0.75f, 0.75f, 0.7f };
|
||||||
float fSeaSparrowAimingAngle = 10.0f;
|
float fSeaSparrowAimingAngle = 10.0f;
|
||||||
|
@ -251,7 +252,7 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
|
||||||
else if ( shooter->IsPed() && ((CPed*)shooter)->m_pSeekTarget != nil )
|
else if ( shooter->IsPed() && ((CPed*)shooter)->m_pSeekTarget != nil )
|
||||||
{
|
{
|
||||||
float distToTarget = (shooter->GetPosition() - ((CPed*)shooter)->m_pSeekTarget->GetPosition()).Magnitude();
|
float distToTarget = (shooter->GetPosition() - ((CPed*)shooter)->m_pSeekTarget->GetPosition()).Magnitude();
|
||||||
float power = clamp((distToTarget-10.0f)*0.02f, 0.2f, 1.0f);
|
float power = Clamp((distToTarget-10.0f)*0.02f, 0.2f, 1.0f);
|
||||||
|
|
||||||
fired = FireProjectile(shooter, source, power);
|
fired = FireProjectile(shooter, source, power);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue