Fixes and style changes from miami

This commit is contained in:
erorcun 2020-10-18 19:16:37 +03:00
parent 4c305fd48b
commit a6aa782d6d
18 changed files with 861 additions and 248 deletions

View file

@ -330,14 +330,12 @@ project "re3"
links { "rw" }
filter "platforms:*d3d9*"
defines { "USE_D3D9" }
links { "d3d9" }
filter "platforms:*x86*d3d*"
includedirs { "sdk/dx8sdk/include" }
libdirs { "sdk/dx8sdk/lib" }
filter "platforms:*amd64*d3d9*"
defines { "USE_D3D9" }
filter "platforms:win-x86*gl3_glfw*"
libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/Win32") }

View file

@ -321,8 +321,13 @@ cAudioManager::Get3DProviderName(uint8 id) const
{
if (!m_bIsInitialised)
return nil;
#ifdef AUDIO_OAL
id = clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1);
#else
// We don't want that either since it will crash the game, but skipping for now
if (id >= SampleManager.GetNum3DProvidersAvailable())
return nil;
#endif
return SampleManager.Get3DProviderName(id);
}

View file

@ -118,7 +118,12 @@ int8 cDMAudio::AutoDetect3DProviders(void)
for ( int32 i = 0; i < GetNum3DProvidersAvailable(); i++ )
{
wchar buff[64];
#ifdef AUDIO_OAL
if (defaultProvider >= 0 && defaultProvider < GetNum3DProvidersAvailable()) {
return i;
}
#endif
char *name = Get3DProviderName(i);
AsciiToUnicode(name, buff);
char *providername = UnicodeToAscii(buff);

View file

@ -323,8 +323,8 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF
#endif
else
m_pSoundFile = nil;
ASSERT(m_pSoundFile != nil);
if (m_pSoundFile && m_pSoundFile->IsOpened() )
if ( IsOpened() )
{
m_pBuffer = malloc(m_pSoundFile->GetBufferSize());
ASSERT(m_pBuffer!=nil);
@ -371,14 +371,14 @@ bool CStream::HasSource()
bool CStream::IsOpened()
{
return m_pSoundFile->IsOpened();
return m_pSoundFile && m_pSoundFile->IsOpened();
}
bool CStream::IsPlaying()
{
if ( !HasSource() || !IsOpened() ) return false;
if ( m_pSoundFile->IsOpened() && !m_bPaused )
if ( !m_bPaused )
{
ALint sourceState;
alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState);
@ -446,7 +446,7 @@ void CStream::SetPan(uint8 nPan)
void CStream::SetPosMS(uint32 nPos)
{
if ( !m_pSoundFile->IsOpened() ) return;
if ( !IsOpened() ) return;
m_pSoundFile->Seek(nPos);
ClearBuffers();
}
@ -454,7 +454,7 @@ void CStream::SetPosMS(uint32 nPos)
uint32 CStream::GetPosMS()
{
if ( !HasSource() ) return 0;
if ( !m_pSoundFile->IsOpened() ) return 0;
if ( !IsOpened() ) return 0;
ALint offset;
//alGetSourcei(m_alSource, AL_SAMPLE_OFFSET, &offset);
@ -467,7 +467,7 @@ uint32 CStream::GetPosMS()
uint32 CStream::GetLengthMS()
{
if ( !m_pSoundFile->IsOpened() ) return 0;
if ( !IsOpened() ) return 0;
return m_pSoundFile->GetLength();
}
@ -475,7 +475,7 @@ bool CStream::FillBuffer(ALuint alBuffer)
{
if ( !HasSource() )
return false;
if ( !m_pSoundFile->IsOpened() )
if ( !IsOpened() )
return false;
if ( !(alBuffer != AL_NONE && alIsBuffer(alBuffer)) )
return false;
@ -517,7 +517,7 @@ void CStream::ClearBuffers()
bool CStream::Setup()
{
if ( m_pSoundFile->IsOpened() )
if ( IsOpened() )
{
m_pSoundFile->Seek(0);
alSourcei(m_alSource, AL_SOURCE_RELATIVE, AL_TRUE);

View file

@ -218,6 +218,10 @@ public:
extern cSampleManager SampleManager;
extern uint32 BankStartOffset[MAX_SFX_BANKS];
#ifdef AUDIO_OAL
extern int defaultProvider;
#endif
#ifdef AUDIO_OPUS
static char StreamedNameTable[][25] = {
"AUDIO\\HEAD.OPUS", "AUDIO\\CLASS.OPUS", "AUDIO\\KJAH.OPUS", "AUDIO\\RISE.OPUS", "AUDIO\\LIPS.OPUS", "AUDIO\\GAME.OPUS",

View file

@ -2176,7 +2176,8 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
nStreamLoopedFlag[nStream] = true;
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}

View file

@ -1,4 +1,3 @@
#include "common.h"
//#define JUICY_OAL
#ifdef AUDIO_OAL
@ -9,6 +8,10 @@
#include "eax.h"
#include "eax-util.h"
#define WITHWINDOWS
#include "common.h"
#include "crossplatform.h"
#ifdef _WIN32
#include <io.h>
#include <AL/al.h>
@ -27,20 +30,27 @@
#include "MusicManager.h"
#include "Frontend.h"
#include "Timer.h"
#include "crossplatform.h"
#ifdef AUDIO_OPUS
#include <opusfile.h>
#endif
//TODO: fix eax3 reverb
//TODO: max channals
//TODO: max channels
//TODO: loop count
//TODO: mp3 player
#ifdef _WIN32
#pragma comment( lib, "OpenAL32.lib" )
#endif
// for user MP3s
#ifdef _WIN32
#include <direct.h>
#include <shobjidl.h>
#include <shlguid.h>
#else
#define _getcwd getcwd
#endif
cSampleManager SampleManager;
bool _bSampmanInitialised = false;
@ -128,11 +138,27 @@ struct
}
}ALBuffers[SAMPLEBANK_MAX];
uint32 nNumMP3s;
struct tMP3Entry
{
char aFilename[MAX_PATH];
uint32 nTrackLength;
uint32 nTrackStreamPos;
tMP3Entry* pNext;
char* pLinkPath;
};
uint32 nNumMP3s;
tMP3Entry* _pMP3List;
char _mp3DirectoryPath[MAX_PATH];
CStream *aStream[MAX_STREAMS];
uint8 nStreamPan [MAX_STREAMS];
uint8 nStreamVolume[MAX_STREAMS];
uint8 nStreamLoopedFlag[MAX_STREAMS];
uint32 _CurMP3Index;
int32 _CurMP3Pos;
bool _bIsMp3Active;
///////////////////////////////////////////////////////////////
// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS
EAXLISTENERPROPERTIES StartEAX3 =
@ -451,24 +477,421 @@ int8 cSampleManager::GetCurrent3DProviderIndex(void)
int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider)
{
if (nProvider >= m_nNumberOfProviders)
nProvider = 0;
ASSERT( nProvider < m_nNumberOfProviders );
int savedprovider = curprovider;
if ( nProvider < m_nNumberOfProviders )
{
if ( set_new_provider(nProvider) )
return curprovider;
else if ( savedprovider != -1 && savedprovider < m_nNumberOfProviders && set_new_provider(savedprovider) )
return curprovider;
else
return -1;
}
nProvider = clamp(nProvider, 0, m_nNumberOfProviders - 1);
if ( set_new_provider(nProvider) )
return curprovider;
else if ( savedprovider != -1 && savedprovider < m_nNumberOfProviders && set_new_provider(savedprovider) )
return curprovider;
else
return curprovider;
}
static bool
_ResolveLink(char const *path, char *out)
{
#ifdef _WIN32
size_t len = strlen(path);
if (len < 4 || strcmp(&path[len - 4], ".lnk") != 0)
return false;
IShellLink* psl;
WIN32_FIND_DATA fd;
char filepath[MAX_PATH];
CoInitialize(NULL);
if (SUCCEEDED( CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl ) ))
{
IPersistFile *ppf;
if (SUCCEEDED(psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf)))
{
WCHAR wpath[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
if (SUCCEEDED(ppf->Load(wpath, STGM_READ)))
{
/* Resolve the link */
if (SUCCEEDED(psl->Resolve(NULL, SLR_ANY_MATCH|SLR_NO_UI|SLR_NOSEARCH)))
{
strcpy(filepath, path);
if (SUCCEEDED(psl->GetPath(filepath, MAX_PATH, &fd, SLGP_UNCPRIORITY)))
{
OutputDebugString(fd.cFileName);
strcpy(out, filepath);
// FIX: Release the objects. Taken from SA.
#ifdef FIX_BUGS
ppf->Release();
psl->Release();
#endif
return true;
}
}
}
ppf->Release();
}
psl->Release();
}
return false;
#else
struct stat sb;
if (lstat(path, &sb) == -1) {
perror("lstat: ");
return false;
}
if (S_ISLNK(sb.st_mode)) {
char* linkname = (char*)alloca(sb.st_size + 1);
if (linkname == NULL) {
fprintf(stderr, "insufficient memory\n");
return false;
}
if (readlink(path, linkname, sb.st_size + 1) < 0) {
perror("readlink: ");
return false;
}
linkname[sb.st_size] = '\0';
strcpy(out, linkname);
return true;
} else {
return false;
}
#endif
}
static void
_FindMP3s(void)
{
tMP3Entry *pList;
bool bShortcut;
bool bInitFirstEntry;
HANDLE hFind;
char path[MAX_PATH];
char filepath[MAX_PATH*2];
int total_ms;
WIN32_FIND_DATA fd;
if (getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) {
perror("getcwd: ");
return;
}
OutputDebugString("Finding MP3s...");
strcpy(path, _mp3DirectoryPath);
strcat(path, "\\MP3\\");
strcpy(_mp3DirectoryPath, path);
OutputDebugString(_mp3DirectoryPath);
strcat(path, "*");
hFind = FindFirstFile(path, &fd);
if ( hFind == INVALID_HANDLE_VALUE )
{
return;
}
strcpy(filepath, _mp3DirectoryPath);
strcat(filepath, fd.cFileName);
size_t filepathlen = strlen(filepath);
if ( filepathlen <= 0)
{
FindClose(hFind);
return;
}
if ( _ResolveLink(filepath, filepath) )
{
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
bShortcut = true;
} else
bShortcut = false;
aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]);
if (aStream[0] && aStream[0]->IsOpened())
{
total_ms = aStream[0]->GetLengthMS();
delete aStream[0];
aStream[0] = NULL;
OutputDebugString(fd.cFileName);
_pMP3List = new tMP3Entry;
if ( _pMP3List == NULL )
{
FindClose(hFind);
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;
}
else
{
strcat(filepath, " - NOT A VALID MP3");
OutputDebugString(filepath);
bInitFirstEntry = true;
}
while ( true )
{
if ( !FindNextFile(hFind, &fd) )
break;
if ( bInitFirstEntry )
{
strcpy(filepath, _mp3DirectoryPath);
strcat(filepath, fd.cFileName);
size_t filepathlen = strlen(filepath);
if ( filepathlen > 0 )
{
if ( _ResolveLink(filepath, filepath) )
{
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
bShortcut = true;
} else {
bShortcut = false;
if (filepathlen > MAX_PATH) {
continue;
}
}
aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]);
if (aStream[0] && aStream[0]->IsOpened())
{
total_ms = aStream[0]->GetLengthMS();
delete aStream[0];
aStream[0] = NULL;
OutputDebugString(fd.cFileName);
_pMP3List = new tMP3Entry;
if ( _pMP3List == NULL)
break;
nNumMP3s = 1;
strcpy(_pMP3List->aFilename, fd.cFileName);
_pMP3List->nTrackLength = total_ms;
_pMP3List->pNext = NULL;
if ( bShortcut )
{
_pMP3List->pLinkPath = new char [MAX_PATH*2];
strcpy(_pMP3List->pLinkPath, filepath);
}
else
{
_pMP3List->pLinkPath = NULL;
}
pList = _pMP3List;
bInitFirstEntry = false;
}
else
{
strcat(filepath, " - NOT A VALID MP3");
OutputDebugString(filepath);
}
}
}
else
{
strcpy(filepath, _mp3DirectoryPath);
strcat(filepath, fd.cFileName);
size_t filepathlen = strlen(filepath);
if ( filepathlen > 0 )
{
if ( _ResolveLink(filepath, filepath) )
{
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
bShortcut = true;
} else
bShortcut = false;
aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]);
if (aStream[0] && aStream[0]->IsOpened())
{
total_ms = aStream[0]->GetLengthMS();
delete aStream[0];
aStream[0] = NULL;
OutputDebugString(fd.cFileName);
pList->pNext = new tMP3Entry;
tMP3Entry *e = pList->pNext;
if ( e == NULL )
break;
pList = pList->pNext;
strcpy(e->aFilename, fd.cFileName);
e->nTrackLength = total_ms;
e->pNext = NULL;
if ( bShortcut )
{
e->pLinkPath = new char [MAX_PATH*2];
strcpy(e->pLinkPath, filepath);
}
else
{
e->pLinkPath = NULL;
}
nNumMP3s++;
OutputDebugString(fd.cFileName);
}
else
{
strcat(filepath, " - NOT A VALID MP3");
OutputDebugString(filepath);
}
}
}
}
FindClose(hFind);
}
static void
_DeleteMP3Entries(void)
{
tMP3Entry *e = _pMP3List;
while ( e != NULL )
{
tMP3Entry *next = e->pNext;
if ( next == NULL )
next = NULL;
if ( e->pLinkPath != NULL )
{
#ifndef FIX_BUGS
delete e->pLinkPath; // BUG: should be delete []
#else
delete[] e->pLinkPath;
#endif
e->pLinkPath = NULL;
}
delete e;
if ( next )
e = next;
else
e = NULL;
nNumMP3s--;
}
if ( nNumMP3s != 0 )
{
OutputDebugString("Not all MP3 entries were deleted");
nNumMP3s = 0;
}
_pMP3List = NULL;
}
static tMP3Entry *
_GetMP3EntryByIndex(uint32 idx)
{
uint32 n = ( idx < nNumMP3s ) ? idx : 0;
if ( _pMP3List != NULL )
{
tMP3Entry *e = _pMP3List;
for ( uint32 i = 0; i < n; i++ )
e = e->pNext;
return e;
}
return NULL;
}
static inline bool
_GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry)
{
_CurMP3Index = 0;
for ( *pEntry = _pMP3List; *pEntry != NULL; *pEntry = (*pEntry)->pNext )
{
if ( *pPosition >= (*pEntry)->nTrackStreamPos
&& *pPosition < (*pEntry)->nTrackLength + (*pEntry)->nTrackStreamPos )
{
*pPosition -= (*pEntry)->nTrackStreamPos;
_CurMP3Pos = *pPosition;
return true;
}
_CurMP3Index++;
}
*pPosition = 0;
*pEntry = _pMP3List;
_CurMP3Pos = 0;
_CurMP3Index = 0;
return false;
}
bool
cSampleManager::IsMP3RadioChannelAvailable(void)
{
@ -566,56 +989,15 @@ cSampleManager::Initialise(void)
nChannelVolume[i] = 0;
}
{
for ( int32 i = 0; i < MAX_STREAMS; i++ )
{
aStream[i] = NULL;
nStreamVolume[i] = 100;
nStreamPan[i] = 63;
}
{
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
nStreamLength[i] = 0;
}
{
add_providers();
if ( !InitialiseSampleBanks() )
{
Terminate();
return false;
}
nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0);
if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 )
{
Terminate();
return false;
}
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0);
}
{
_bSampmanInitialised = true;
if ( 0 >= defaultProvider && defaultProvider < m_nNumberOfProviders )
{
set_new_provider(defaultProvider);
}
else
{
Terminate();
return false;
}
}
#ifdef AUDIO_CACHE
FILE *cacheFile = fopen("audio\\sound.cache", "rb");
FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb");
if (cacheFile) {
fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile);
@ -639,13 +1021,116 @@ cSampleManager::Initialise(void)
USERERROR("Can't open '%s'\n", StreamedNameTable[i]);
}
#ifdef AUDIO_CACHE
cacheFile = fopen("audio\\sound.cache", "wb");
cacheFile = fcaseopen("audio\\sound.cache", "wb");
fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile);
#endif
}
{
if ( !InitialiseSampleBanks() )
{
Terminate();
return false;
}
LoadSampleBank(SFX_BANK_0);
nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0);
if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 )
{
Terminate();
return false;
}
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0);
LoadSampleBank(SFX_BANK_0);
}
{
for ( int32 i = 0; i < MAX_STREAMS; i++ )
{
aStream[i] = NULL;
nStreamVolume[i] = 100;
nStreamPan[i] = 63;
}
}
{
_bSampmanInitialised = true;
if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders )
{
set_new_provider(defaultProvider);
}
else
{
Terminate();
return false;
}
}
{
nNumMP3s = 0;
_pMP3List = NULL;
_FindMP3s();
if ( nNumMP3s != 0 )
{
nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0;
for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext )
{
e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER];
nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength;
}
time_t t = time(NULL);
tm *localtm;
bool bUseRandomTable;
if ( t == -1 )
bUseRandomTable = true;
else
{
bUseRandomTable = false;
localtm = localtime(&t);
}
int32 randval;
if ( bUseRandomTable )
randval = AudioManager.GetRandomNumber(1);
else
randval = localtm->tm_sec * localtm->tm_min;
_CurMP3Index = randval % nNumMP3s;
tMP3Entry *randmp3 = _pMP3List;
for ( int32 i = randval % nNumMP3s; i > 0; --i)
randmp3 = randmp3->pNext;
if ( bUseRandomTable )
_CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength;
else
{
if ( localtm->tm_sec > 0 )
{
int32 s = localtm->tm_sec;
_CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength;
}
else
_CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength;
}
}
else
_CurMP3Pos = 0;
_bIsMp3Active = false;
}
return true;
}
@ -653,8 +1138,6 @@ cSampleManager::Initialise(void)
void
cSampleManager::Terminate(void)
{
release_existing();
for (int32 i = 0; i < MAX_STREAMS; i++)
{
CStream *stream = aStream[i];
@ -665,6 +1148,10 @@ cSampleManager::Terminate(void)
}
}
release_existing();
_DeleteMP3Entries();
CStream::Terminate();
if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 )
@ -752,7 +1239,7 @@ cSampleManager::SetMonoMode(uint8 nMode)
bool
cSampleManager::LoadSampleBank(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS );
ASSERT( nBank < MAX_SFX_BANKS);
if ( CTimer::GetIsCodePaused() )
return false;
@ -793,7 +1280,7 @@ cSampleManager::LoadSampleBank(uint8 nBank)
void
cSampleManager::UnloadSampleBank(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS );
ASSERT( nBank < MAX_SFX_BANKS);
bSampleBankLoaded[nBank] = false;
}
@ -801,7 +1288,7 @@ cSampleManager::UnloadSampleBank(uint8 nBank)
bool
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS );
ASSERT( nBank < MAX_SFX_BANKS);
return bSampleBankLoaded[nBank];
}
@ -1225,7 +1712,7 @@ cSampleManager::StopChannel(uint32 nChannel)
void
cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream)
{
char filename[256];
char filename[MAX_PATH];
ASSERT( nStream < MAX_STREAMS );
@ -1283,6 +1770,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
uint32 position = nPos;
char filename[256];
ASSERT( nStream < MAX_STREAMS );
@ -1295,6 +1783,135 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
aStream[nStream] = NULL;
}
if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
{
uint32 i = 0;
do {
if(i != 0 || _bIsMp3Active) {
if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
_CurMP3Pos = 0;
tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
if(mp3) {
mp3 = _pMP3List;
if(mp3 == NULL) {
_bIsMp3Active = false;
nFile = 0;
strcat(filename, StreamedNameTable[nFile]);
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
ASSERT(stream != NULL);
aStream[nStream] = stream;
if (stream->IsOpened()) {
if (stream->Setup()) {
if (position != 0)
stream->SetPosMS(position);
stream->Start();
}
return true;
} else {
delete stream;
aStream[nStream] = NULL;
}
return false;
}
}
if (mp3->pLinkPath != NULL)
aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, mp3->aFilename);
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
}
if (aStream[nStream]->IsOpened()) {
if (aStream[nStream]->Setup()) {
aStream[nStream]->Start();
}
return true;
} else {
delete aStream[nStream];
aStream[nStream] = NULL;
}
_bIsMp3Active = false;
continue;
}
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0;
tMP3Entry *e;
if ( !_GetMP3PosFromStreamPos(&position, &e) )
{
if ( e == NULL )
{
nFile = 0;
strcat(filename, StreamedNameTable[nFile]);
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
ASSERT(stream != NULL);
aStream[nStream] = stream;
if (stream->IsOpened()) {
if (stream->Setup()) {
if (position != 0)
stream->SetPosMS(position);
stream->Start();
}
return true;
} else {
delete stream;
aStream[nStream] = NULL;
}
return false;
}
}
if (e->pLinkPath != NULL)
aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, e->aFilename);
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
}
if (aStream[nStream]->IsOpened()) {
if (aStream[nStream]->Setup()) {
if (position != 0)
aStream[nStream]->SetPosMS(position);
aStream[nStream]->Start();
}
_bIsMp3Active = true;
return true;
} else {
delete aStream[nStream];
aStream[nStream] = NULL;
}
_bIsMp3Active = false;
} while(++i < nNumMP3s);
position = 0;
nFile = 0;
}
strcpy(filename, StreamedNameTable[nFile]);
CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
@ -1302,21 +1919,16 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
aStream[nStream] = stream;
if ( stream->IsOpened() )
{
nStreamLength[nFile] = stream->GetLengthMS();
if ( stream->Setup() )
{
if ( nPos != 0 )
stream->SetPosMS(nPos);
if ( stream->IsOpened() ) {
if ( stream->Setup() ) {
if (position != 0)
stream->SetPosMS(position);
stream->Start();
}
return true;
}
else
{
} else {
delete stream;
aStream[nStream] = NULL;
}
@ -1468,5 +2080,4 @@ cSampleManager::InitialiseSampleBanks(void)
return true;
}
#endif

View file

@ -2399,7 +2399,7 @@ bool CPad::GetAnaloguePadLeftJustUp(void)
if ( X == 0 && oldfStickX < 0 )
{
oldfStickX = X;
oldfStickX = 0;
return true;
}
@ -2419,7 +2419,7 @@ bool CPad::GetAnaloguePadRightJustUp(void)
if ( X == 0 && oldfStickX > 0 )
{
oldfStickX = X;
oldfStickX = 0;
return true;
}

View file

@ -84,10 +84,6 @@ static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not
#define RADAR_MAX_SPEED (0.9f)
#ifdef MENU_MAP
CRGBA CRadar::ArrowBlipColour1;
CRGBA CRadar::ArrowBlipColour2;
uint16 CRadar::MapLegendCounter;
uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS];
int CRadar::TargetMarkerId = -1;
CVector CRadar::TargetMarkerPos;
#endif
@ -116,7 +112,7 @@ void RequestMapSection(int32 x, int32 y)
void RemoveMapSection(int32 x, int32 y)
{
if (x >= 0 && x <= 7 && y >= 0 && y <= 7)
if (x >= 0 && x <= RADAR_NUM_TILES - 1 && y >= 0 && y <= RADAR_NUM_TILES - 1)
CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]);
}
@ -709,6 +705,7 @@ void CRadar::DrawBlips()
if (CMenuManager::bMenuMapActive) {
CVector2D in, out;
TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift());
LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in);
DrawYouAreHereSprite(out.x, out.y);
}
@ -782,14 +779,20 @@ void CRadar::DrawRadarMask()
};
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
#if !defined(GTA_PS2_STUFF) && defined(RWLIBS)
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_ALWAYS);
#else
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
#endif
CVector2D out[8];
CVector2D in;
@ -810,7 +813,10 @@ void CRadar::DrawRadarMask()
CSprite2d::SetMaskVertices(8, (float *)out);
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 8);
};
}
#if !defined(GTA_PS2_STUFF) && defined(RWLIBS)
RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
#endif
}
void CRadar::DrawRadarSection(int32 x, int32 y)
@ -860,46 +866,22 @@ void CRadar::DrawRadarSection(int32 x, int32 y)
void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha)
{
RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha));
#ifdef MENU_MAP
if (CMenuManager::bMenuMapActive) {
bool alreadyThere = false;
for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
if (MapLegendList[i] == sprite)
alreadyThere = true;
}
if (!alreadyThere) {
MapLegendList[MapLegendCounter] = sprite;
MapLegendCounter++;
}
}
#endif
}
void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha)
{
CVector curPosn[4];
CVector oldPosn[4];
curPosn[0].x = x - SCREEN_SCALE_X(5.6f);
curPosn[0].y = y + SCREEN_SCALE_Y(5.6f);
curPosn[1].x = x + SCREEN_SCALE_X(5.6f);
curPosn[1].y = y + SCREEN_SCALE_Y(5.6f);
curPosn[2].x = x - SCREEN_SCALE_X(5.6f);
curPosn[2].y = y - SCREEN_SCALE_Y(5.6f);
curPosn[3].x = x + SCREEN_SCALE_X(5.6f);
curPosn[3].y = y - SCREEN_SCALE_Y(5.6f);
const float sizeX = SCREEN_SCALE_X(8.0f);
const float correctedAngle = angle - PI / 4.f;
const float sizeY = SCREEN_SCALE_Y(8.0f);
for (uint32 i = 0; i < 4; i++) {
oldPosn[i] = curPosn[i];
curPosn[i].x = x + (oldPosn[i].x - x) * Cos(angle) + (oldPosn[i].y - y) * Sin(angle);
curPosn[i].y = y - (oldPosn[i].x - x) * Sin(angle) + (oldPosn[i].y - y) * Cos(angle);
const float cornerAngle = i * HALFPI + correctedAngle;
curPosn[i].x = x + (0.0f * Cos(cornerAngle) + 1.0f * Sin(cornerAngle)) * sizeX;
curPosn[i].y = y - (0.0f * Sin(cornerAngle) - 1.0f * Cos(cornerAngle)) * sizeY;
}
sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha));
sprite->Draw(curPosn[3].x, curPosn[3].y, curPosn[2].x, curPosn[2].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha));
}
int32 CRadar::GetActualBlipArrayIndex(int32 i)
@ -925,43 +907,43 @@ uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright)
{
int32 c;
switch (color) {
case 0:
case RADAR_TRACE_RED:
if (bright)
c = 0x712B49FF;
else
c = 0x7F0000FF;
break;
case 1:
case RADAR_TRACE_GREEN:
if (bright)
c = 0x5FA06AFF;
else
c = 0x007F00FF;
break;
case 2:
case RADAR_TRACE_LIGHT_BLUE:
if (bright)
c = 0x80A7F3FF;
else
c = 0x00007FFF;
break;
case 3:
case RADAR_TRACE_GRAY:
if (bright)
c = 0xE1E1E1FF;
else
c = 0x7F7F7FFF;
break;
case 4:
case RADAR_TRACE_YELLOW:
if (bright)
c = 0xFFFF00FF;
else
c = 0x7F7F00FF;
break;
case 5:
case RADAR_TRACE_MAGENTA:
if (bright)
c = 0xFF00FFFF;
else
c = 0x7F007FFF;
break;
case 6:
case RADAR_TRACE_CYAN:
if (bright)
c = 0x00FFFFFF;
else
@ -1215,21 +1197,6 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red,
CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size), y - SCREEN_SCALE_Y(size), SCREEN_SCALE_X(size) + x, SCREEN_SCALE_Y(size) + y), CRGBA(red, green, blue, alpha));
break;
}
#ifdef MENU_MAP
// VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips
if (CMenuManager::bMenuMapActive) {
bool alreadyThere = false;
for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
if (MapLegendList[i] == -1)
alreadyThere = true;
}
if (!alreadyThere) {
MapLegendList[MapLegendCounter] = -1;
MapLegendCounter++;
ArrowBlipColour1 = CRGBA(red, green, blue, alpha);
}
}
#endif
}
void CRadar::Shutdown()
@ -1415,12 +1382,6 @@ CRadar::InitFrontEndMap()
vec2DRadarOrigin.x = 0.0f;
vec2DRadarOrigin.y = 0.0f;
m_radarRange = 1000.0f; // doesn't mean anything, just affects the calculation in TransformRadarPointToScreenSpace
for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
MapLegendList[i] = RADAR_SPRITE_NONE;
}
MapLegendCounter = 0;
ArrowBlipColour1 = CRGBA(0, 0, 0, 0);
ArrowBlipColour2 = CRGBA(0, 0, 0, 0);
}
void
@ -1448,7 +1409,6 @@ CRadar::DrawYouAreHereSprite(float x, float y)
float bottom = y - SCREEN_SCALE_Y(24.0f);
CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255));
}
MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE;
}
void
@ -1465,8 +1425,8 @@ CRadar::ToggleTargetMarker(float x, float y)
return;
#endif
ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD;
ms_RadarTrace[nextBlip].m_nColor = 0x333333FF;
ms_RadarTrace[nextBlip].m_bDim = 1;
ms_RadarTrace[nextBlip].m_nColor = RADAR_TRACE_GRAY;
ms_RadarTrace[nextBlip].m_bDim = 0;
ms_RadarTrace[nextBlip].m_bInUse = 1;
ms_RadarTrace[nextBlip].m_Radius = 1.0f;
CVector pos(x, y, CWorld::FindGroundZForCoord(x,y));

View file

@ -49,6 +49,17 @@ enum eRadarSprite
RADAR_SPRITE_COUNT
};
enum
{
RADAR_TRACE_RED,
RADAR_TRACE_GREEN,
RADAR_TRACE_LIGHT_BLUE,
RADAR_TRACE_GRAY,
RADAR_TRACE_YELLOW,
RADAR_TRACE_MAGENTA,
RADAR_TRACE_CYAN
};
enum
{
BLIP_MODE_TRIANGULAR_UP = 0,
@ -108,11 +119,6 @@ public:
static float cachedCos;
static float cachedSin;
#ifdef MENU_MAP
#define NUM_MAP_LEGENDS 75
static CRGBA ArrowBlipColour1;
static CRGBA ArrowBlipColour2;
static uint16 MapLegendList[NUM_MAP_LEGENDS];
static uint16 MapLegendCounter;
static int TargetMarkerId;
static CVector TargetMarkerPos;

View file

@ -631,7 +631,7 @@ CPed::ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer)
// BUG: This condition will always return true. Even fixing it won't work, because these states are unused.
// if (m_nPedState != PED_PASSENGER || m_nPedState != PED_TAXI_PASSENGER) {
CPed::SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
// }
bBodyPartJustCameOff = true;
@ -814,15 +814,15 @@ CPed::Avoid(void)
// Get distance to ped we want to avoid
CVector2D distToPed = CVector2D(nearestPed->GetPosition()) - testPosition;
if (distToPed.Magnitude() <= 1.0f && CPed::OurPedCanSeeThisOne((CEntity*)nearestPed)) {
if (distToPed.Magnitude() <= 1.0f && OurPedCanSeeThisOne((CEntity*)nearestPed)) {
m_nPedStateTimer = CTimer::GetTimeInMilliseconds()
+ 500 + (m_randomSeed + 3 * CTimer::GetFrameCounter())
% 1000 / 5;
m_fRotationDest += DEGTORAD(45.0f);
if (!bIsLooking) {
CPed::SetLookFlag(nearestPed, false);
CPed::SetLookTimer(CGeneral::GetRandomNumberInRange(500, 800));
SetLookFlag(nearestPed, false);
SetLookTimer(CGeneral::GetRandomNumberInRange(500, 800));
}
}
}
@ -861,8 +861,7 @@ CPed::ClearLookFlag(void) {
m_lookTimer = CTimer::GetTimeInMilliseconds() + 4000;
if (m_nPedState == PED_LOOK_HEADING || m_nPedState == PED_LOOK_ENTITY) {
RestorePreviousState();
ClearLookFlag();
ClearLook();
}
}
}
@ -985,7 +984,7 @@ CPed::Attack(void)
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ourWeapon->m_Anim2ToPlay, 8.0f);
}
weaponAnimAssoc->SetFinishCallback(CPed::FinishedAttackCB, this);
weaponAnimAssoc->SetFinishCallback(FinishedAttackCB, this);
weaponAnimAssoc->SetRun();
if (weaponAnimAssoc->currentTime == weaponAnimAssoc->hierarchy->totalLength)
@ -2900,7 +2899,7 @@ CPed::ReactToAttack(CEntity *attacker)
#ifdef VC_PED_PORTS
if (m_nPedState == PED_DRIVING && InVehicle()
&& (m_pMyVehicle->pDriver == this || m_pMyVehicle->pDriver && m_pMyVehicle->pDriver->m_nPedState == PED_DRIVING)) {
&& (m_pMyVehicle->pDriver == this || m_pMyVehicle->pDriver && m_pMyVehicle->pDriver->m_nPedState == PED_DRIVING && m_pMyVehicle->pDriver->m_objective != OBJECTIVE_LEAVE_CAR_AND_DIE)) {
if (m_pMyVehicle->VehicleCreatedBy == RANDOM_VEHICLE
&& (m_pMyVehicle->GetStatus() == STATUS_SIMPLE || m_pMyVehicle->GetStatus() == STATUS_PHYSICS)
@ -4435,11 +4434,11 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
bool vehPressedHorn = false;
if (neededTurn > PI)
neededTurn = 2 * PI - neededTurn;
neededTurn = TWOPI - neededTurn;
CVehicle *veh = (CVehicle*)reason;
if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR) {
if (veh->m_nCarHornTimer) {
if (veh->m_nCarHornTimer != 0) {
vehPressedHorn = true;
if (!IsPlayer())
animType = 1;
@ -4459,7 +4458,7 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
angleToFace += PI;
if (angleToFace > PI)
angleToFace -= 2*PI;
angleToFace -= TWOPI;
// We don't want to run towards car's direction
float dangerZone = angleToFace - vehDirection;
@ -4467,16 +4466,15 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
// So, add or subtract 90deg (jump to left/right) according to that
if (dangerZone <= 0.0f)
angleToFace = 0.5f*PI + vehDirection;
angleToFace = HALFPI + vehDirection;
else
angleToFace = vehDirection - 0.5f*PI;
angleToFace = vehDirection - HALFPI;
if (animType == 2)
stepAnim = ANIM_HANDSCOWER;
else if (animType < 2)
stepAnim = NUM_ANIMS;
if (animType == 0 || animType == 1)
stepAnim = ANIM_EV_STEP;
else
stepAnim = NUM_ANIMS;
else if (animType == 2)
stepAnim = ANIM_HANDSCOWER;
}
if (!RpAnimBlendClumpGetAssociation(GetClump(), stepAnim)) {
CAnimBlendAssociation *stepAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, stepAnim, 8.0f);
@ -4506,7 +4504,7 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump)
angleToFace = m_fRotationCur;
CVehicle *veh = (CVehicle*) reason;
if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR && veh->m_nCarHornTimer && !IsPlayer()) {
if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR && veh->m_nCarHornTimer != 0 && !IsPlayer()) {
onlyRandomJump = true;
}
@ -8341,7 +8339,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
CPad::GetPad(0)->StartShake(40000 / shakeFreq, shakeFreq);
}
bIsStanding = false;
damageDir = CPed::GetLocalDirection(-m_vecMoveSpeed);
damageDir = GetLocalDirection(-m_vecMoveSpeed);
vehModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(car->GetModelIndex());
vehColModel = vehModel->GetColModel();
float carRightAndDistDotProd = DotProduct(distVec, car->GetRight());
@ -8477,7 +8475,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
pieceToDamage = PEDPIECE_MID;
break;
}
CPed::InflictDamage(car, killMethod, 1000.0f, pieceToDamage, damageDir);
InflictDamage(car, killMethod, 1000.0f, pieceToDamage, damageDir);
if (DyingOrDead()
&& bIsPedDieAnimPlaying && !m_pCollidingEntity) {
@ -8507,8 +8505,8 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
else
damage = 30.0f;
CPed::InflictDamage(car, WEAPONTYPE_RAMMEDBYCAR, damage, PEDPIECE_TORSO, fallDirection);
CPed::SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true);
InflictDamage(car, WEAPONTYPE_RAMMEDBYCAR, damage, PEDPIECE_TORSO, fallDirection);
SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true);
if (OnGround() && !m_pCollidingEntity &&
(!IsPlayer() || bHasHitWall || car->GetModelIndex() == MI_TRAIN || m_vecDamageNormal.z < -0.8f)) {
@ -9680,7 +9678,7 @@ CPed::ProcessControl(void)
} else if (CTimer::GetTimeInMilliseconds() >= CWorld::Players[CWorld::PlayerInFocus].m_nLastBumpPlayerCarTimer
|| m_nPedStateTimer >= CTimer::GetTimeInMilliseconds()) {
CPed::SetDirectionToWalkAroundObject(collidingVeh);
SetDirectionToWalkAroundObject(collidingVeh);
CWorld::Players[CWorld::PlayerInFocus].m_nLastBumpPlayerCarTimer = m_nPedStateTimer;
} else if (m_fleeFrom != collidingVeh) {
@ -9906,7 +9904,7 @@ CPed::ProcessControl(void)
SetHeading(m_fRotationCur);
if (m_nPedState != PED_FALL && !bIsPedDieAnimPlaying) {
CPed::SetFall(1000, ANIM_KO_SKID_BACK, true);
SetFall(1000, ANIM_KO_SKID_BACK, true);
}
bIsInTheAir = false;
} else if (m_vecDamageNormal.z > 0.4f) {
@ -10217,19 +10215,19 @@ CPed::ProcessControl(void)
Flee();
break;
case PED_FOLLOW_PATH:
CPed::FollowPath();
FollowPath();
break;
case PED_PAUSE:
CPed::Pause();
Pause();
break;
case PED_ATTACK:
CPed::Attack();
Attack();
break;
case PED_FIGHT:
CPed::Fight();
Fight();
break;
case PED_CHAT:
CPed::Chat();
Chat();
break;
case PED_AIM_GUN:
if (m_pPointGunAt && m_pPointGunAt->IsPed()
@ -15982,7 +15980,7 @@ CPed::SeekCar(void)
if (m_vehEnterType == CAR_DOOR_RF && vehToSeek->pPassengers[0]) {
if (vehToSeek->pPassengers[0]->bDontDragMeOutCar) {
if (IsPlayer())
CPed::SetEnterCar(vehToSeek, m_vehEnterType);
SetEnterCar(vehToSeek, m_vehEnterType);
} else {
SetCarJack(vehToSeek);
}
@ -16152,15 +16150,15 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
case HITLEVEL_LOW:
#ifndef VC_PED_PORTS
if (direction == 2) {
CPed::SetFall(1000, ANIM_KO_SKID_BACK, false);
SetFall(1000, ANIM_KO_SKID_BACK, false);
return;
}
#else
if (direction == 2 && (!IsPlayer() || ((CGeneral::GetRandomNumber() & 1) && m_fHealth < 30.0f))) {
CPed::SetFall(1000, ANIM_KO_SKID_BACK, false);
SetFall(1000, ANIM_KO_SKID_BACK, false);
return;
} else if (direction != 2 && !IsPlayer() && (CGeneral::GetRandomNumber() & 1) && m_fHealth < 30.0f) {
CPed::SetFall(1000, ANIM_KO_SHOT_STOM, false);
SetFall(1000, ANIM_KO_SHOT_STOM, false);
return;
}
#endif
@ -17366,12 +17364,12 @@ CPed::SetExitBoat(CVehicle *boat)
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 100.0f);
if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f);
m_pVehicleAnim->SetFinishCallback(CPed::PedSetOutCarCB, this);
m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this);
m_vehEnterType = CAR_DOOR_RF;
m_nPedState = PED_EXIT_CAR;
} else {
m_vehEnterType = CAR_DOOR_RF;
CPed::PedSetOutCarCB(nil, this);
PedSetOutCarCB(nil, this);
bIsStanding = true;
m_pCurSurface = boat;
m_pCurSurface->RegisterReference((CEntity**)&m_pCurSurface);

View file

@ -41,13 +41,13 @@ CRGBA ODDJOB_COLOR(89, 115, 150, 255);
CRGBA ODDJOB2_COLOR(156, 91, 40, 255);
CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255);
wchar CHud::m_HelpMessage[256];
wchar CHud::m_LastHelpMessage[256];
wchar CHud::m_HelpMessage[HELP_MSG_LENGTH];
wchar CHud::m_LastHelpMessage[HELP_MSG_LENGTH];
uint32 CHud::m_HelpMessageState;
uint32 CHud::m_HelpMessageTimer;
int32 CHud::m_HelpMessageFadeTimer;
wchar CHud::m_HelpMessageToPrint[256];
float CHud::m_fHelpMessageTime;
wchar CHud::m_HelpMessageToPrint[HELP_MSG_LENGTH];
float CHud::m_HelpMessageDisplayTime;
bool CHud::m_HelpMessageQuick;
uint32 CHud::m_ZoneState;
int32 CHud::m_ZoneFadeTimer;
@ -1047,14 +1047,14 @@ void CHud::DrawAfterFade()
return;
if (m_HelpMessage[0]) {
if (!CMessages::WideStringCompare(m_HelpMessage, m_LastHelpMessage, 256)) {
if (!CMessages::WideStringCompare(m_HelpMessage, m_LastHelpMessage, HELP_MSG_LENGTH)) {
switch (m_HelpMessageState) {
case 0:
m_HelpMessageFadeTimer = 0;
m_HelpMessageState = 2;
m_HelpMessageTimer = 0;
CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, 256);
m_fHelpMessageTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f;
CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, HELP_MSG_LENGTH);
m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f;
if (TheCamera.m_ScreenReductionPercentage == 0.0f)
DMAudio.PlayFrontEndSound(SOUND_HUD, 0);
@ -1069,7 +1069,7 @@ void CHud::DrawAfterFade()
default:
break;
}
CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, 256);
CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, HELP_MSG_LENGTH);
}
float fAlpha = 225.0f;
@ -1079,7 +1079,7 @@ void CHud::DrawAfterFade()
case 1:
fAlpha = 225.0f;
m_HelpMessageFadeTimer = 600;
if (m_HelpMessageTimer > m_fHelpMessageTime * 1000.0f || m_HelpMessageQuick && m_HelpMessageTimer > 1500.0f) {
if (m_HelpMessageTimer > m_HelpMessageDisplayTime * 1000.0f || m_HelpMessageQuick && m_HelpMessageTimer > 1500.0f) {
m_HelpMessageFadeTimer = 600;
m_HelpMessageState = 3;
}
@ -1105,7 +1105,7 @@ void CHud::DrawAfterFade()
if (m_HelpMessageFadeTimer < 0) {
m_HelpMessageState = 2;
m_HelpMessageFadeTimer = 0;
CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, 256);
CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, HELP_MSG_LENGTH);
}
fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f;
break;
@ -1371,7 +1371,7 @@ void CHud::GetRidOfAllHudMessages()
m_ZoneNameTimer = 0;
m_pZoneName = nil;
for (int i = 0; i < 256; i++) {
for (int i = 0; i < HELP_MSG_LENGTH; i++) {
m_HelpMessage[i] = 0;
m_LastHelpMessage[i] = 0;
m_HelpMessageToPrint[i] = 0;
@ -1381,7 +1381,7 @@ void CHud::GetRidOfAllHudMessages()
m_HelpMessageFadeTimer = 0;
m_HelpMessageState = 0;
m_HelpMessageQuick = 0;
m_fHelpMessageTime = 1.0f;
m_HelpMessageDisplayTime = 1.0f;
m_VehicleName = nil;
m_pLastVehicleName = nil;
m_pVehicleNameToPrint = nil;
@ -1389,7 +1389,7 @@ void CHud::GetRidOfAllHudMessages()
m_VehicleFadeTimer = 0;
m_VehicleState = 0;
for (int i = 0; i < 256; i++)
for (int i = 0; i < ARRAY_SIZE(m_Message); i++)
m_Message[i] = 0;
for (int i = 0; i < 6; i++) {
@ -1464,7 +1464,7 @@ void CHud::ReInitialise() {
wchar LastBigMessage[6][128];
void CHud::SetBigMessage(wchar *message, int16 style)
void CHud::SetBigMessage(wchar *message, uint16 style)
{
int i = 0;
@ -1495,10 +1495,10 @@ void CHud::SetBigMessage(wchar *message, int16 style)
void CHud::SetHelpMessage(wchar *message, bool quick)
{
if (!CReplay::IsPlayingBack()) {
CMessages::WideStringCopy(m_HelpMessage, message, 256);
CMessages::WideStringCopy(m_HelpMessage, message, HELP_MSG_LENGTH);
CMessages::InsertPlayerControlKeysInString(m_HelpMessage);
for (int i = 0; i < 256; i++) {
for (int i = 0; i < HELP_MSG_LENGTH; i++) {
m_LastHelpMessage[i] = 0;
}
@ -1510,7 +1510,7 @@ void CHud::SetHelpMessage(wchar *message, bool quick)
void CHud::SetMessage(wchar *message)
{
int i = 0;
for (i = 0; i < 256; i++) {
for (i = 0; i < ARRAY_SIZE(m_Message); i++) {
if (message[i] == 0)
break;
@ -1522,7 +1522,7 @@ void CHud::SetMessage(wchar *message)
void CHud::SetPagerMessage(wchar *message)
{
int i = 0;
for (i = 0; i < 256; i++) {
for (i = 0; i < ARRAY_SIZE(m_PagerMessage); i++) {
if (message[i] == 0)
break;

View file

@ -1,6 +1,8 @@
#pragma once
#include "Sprite2d.h"
#define HELP_MSG_LENGTH 256
enum eItems
{
ITEM_NONE = -1,
@ -36,14 +38,13 @@ class CHud
{
public:
static CSprite2d Sprites[NUM_HUD_SPRITES];
static wchar m_HelpMessage[256];
static wchar m_LastHelpMessage[256];
static wchar m_HelpMessage[HELP_MSG_LENGTH];
static wchar m_LastHelpMessage[HELP_MSG_LENGTH];
static uint32 m_HelpMessageState;
static uint32 m_HelpMessageTimer;
static int32 m_HelpMessageFadeTimer;
static wchar m_HelpMessageToPrint[256];
static float &m_HelpMessageDisplayTime;
static float m_fHelpMessageTime;
static wchar m_HelpMessageToPrint[HELP_MSG_LENGTH];
static float m_HelpMessageDisplayTime;
static bool m_HelpMessageQuick;
static uint32 m_ZoneState;
static int32 m_ZoneFadeTimer;
@ -88,7 +89,7 @@ public:
static void GetRidOfAllHudMessages();
static void Initialise();
static void ReInitialise();
static void SetBigMessage(wchar *message, int16 style);
static void SetBigMessage(wchar *message, uint16 style);
static void SetHelpMessage(wchar *message, bool quick);
static void SetMessage(wchar *message);
static void SetPagerMessage(wchar *message);

View file

@ -302,8 +302,8 @@ void CParticle::Initialise()
{
float angle = DEGTORAD(float(i) * float(360.0f / SIN_COS_TABLE_SIZE));
m_SinTable[i] = Sin(angle);
m_CosTable[i] = Cos(angle);
m_SinTable[i] = ::Sin(angle);
m_CosTable[i] = ::Cos(angle);
}
int32 slot = CTxdStore::FindTxdSlot("particle");

View file

@ -64,7 +64,7 @@ void CWaterCannon::Update_OncePerFrame(int16 index)
if (CTimer::GetTimeInMilliseconds() > m_nTimeCreated + WATERCANNON_LIFETIME )
{
m_nCur = (m_nCur + 1) % -NUM_SEGMENTPOINTS;
m_nCur = (m_nCur + 1) % NUM_SEGMENTPOINTS;
m_abUsed[m_nCur] = false;
}
@ -124,7 +124,7 @@ void CWaterCannon::Render(void)
RwIm3DVertexSetV(&WaterCannonVertices[2], v);
RwIm3DVertexSetV(&WaterCannonVertices[3], v);
int16 pointA = m_nCur % -NUM_SEGMENTPOINTS;
int16 pointA = m_nCur % NUM_SEGMENTPOINTS;
int16 pointB = pointA - 1;
if ( (pointA - 1) < 0 )

View file

@ -431,11 +431,13 @@ CameraSize(RwCamera * camera, RwRect * rect,
}
}
if (( origSize.w != rect->w ) && ( origSize.h != rect->h ))
if (( origSize.w != rect->w ) || ( origSize.h != rect->h ))
{
RwRaster *raster;
RwRaster *zRaster;
// BUG: game just changes camera raster's sizes, but this is a hack
#ifdef FIX_BUGS
/*
* Destroy rasters...
*/
@ -493,6 +495,13 @@ CameraSize(RwCamera * camera, RwRect * rect,
RwCameraSetRaster(camera, raster);
RwCameraSetZRaster(camera, zRaster);
}
#else
raster = RwCameraGetRaster(camera);
zRaster = RwCameraGetZRaster(camera);
raster->width = zRaster->width = rect->w;
raster->height = zRaster->height = rect->h;
#endif
}
/* Figure out the view window */

View file

@ -418,7 +418,7 @@ psInitialize(void)
}
else if ( verInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
{
if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion == 1 )
if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion != 0 )
{
debug("Operating System is Win98\n");
_dwOperatingSystemVersion = OS_WIN98;
@ -1220,14 +1220,17 @@ void resizeCB(GLFWwindow* window, int width, int height) {
* memory things don't work.
*/
/* redraw window */
if (RwInitialised && (gGameState == GS_PLAYING_GAME
#ifndef MASTER
|| gGameState == GS_ANIMVIEWER
#endif
))
if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER))
{
RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void*)TRUE);
RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE);
}
#else
if (RwInitialised && gGameState == GS_PLAYING_GAME)
{
RsEventHandler(rsIDLE, (void *)TRUE);
}
#endif
if (RwInitialised && height > 0 && width > 0) {
RwRect r;

View file

@ -684,7 +684,7 @@ psInitialize(void)
}
else if ( verInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
{
if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion == 1 )
if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion != 0 )
{
debug("Operating System is Win98\n");
_dwOperatingSystemVersion = OS_WIN98;
@ -1012,11 +1012,17 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
RECT rect;
/* redraw window */
#ifndef MASTER
if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER))
{
RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE);
}
#else
if (RwInitialised && gGameState == GS_PLAYING_GAME)
{
RsEventHandler(rsIDLE, (void *)TRUE);
}
#endif
/* Manually resize window */
rect.left = rect.top = 0;
rect.bottom = newPos->bottom - newPos->top;
@ -1369,14 +1375,20 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth)
#endif
if ( mode.Width == width && mode.Height == height && mode.Format == format )
{
if ( mode.RefreshRate == 0 )
if ( mode.RefreshRate == 0 ) {
// From VC
#ifdef FIX_BUGS
d3d->Release();
#endif
return 0;
}
if ( mode.RefreshRate < refreshRate && mode.RefreshRate >= 60 )
refreshRate = mode.RefreshRate;
}
}
// From VC
#ifdef FIX_BUGS
d3d->Release();
#endif