Compare commits

...

4 Commits

Author SHA1 Message Date
withmorten 8128e8e817 tiny sync with miami 2021-02-19 16:33:37 +01:00
withmorten 73fce903b8 nil -> false 2021-02-19 16:23:52 +01:00
erorcun b52356f6b5 Update librw to fix Mac hi-dpi 2021-02-19 16:56:42 +03:00
erorcun 139c6bfcf3 Fix MP3 player 2021-02-19 14:30:41 +03:00
5 changed files with 180 additions and 200 deletions

View File

@ -2046,141 +2046,131 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
int i = 0;
uint32 position = nPos;
char filename[MAX_PATH];
if ( m_bInitialised && nFile < TOTAL_STREAMED_SOUNDS )
if ( !m_bInitialised || nFile >= TOTAL_STREAMED_SOUNDS )
return false;
if ( mp3Stream[nStream] )
{
if ( mp3Stream[nStream] )
AIL_pause_stream(mp3Stream[nStream], 1);
AIL_close_stream(mp3Stream[nStream]);
}
if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
{
do
{
AIL_pause_stream(mp3Stream[nStream], 1);
AIL_close_stream(mp3Stream[nStream]);
}
if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
{
uint32 i = 0;
do {
if(i != 0 || _bIsMp3Active) {
if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
// Just switched to MP3 player
if ( !_bIsMp3Active && i == 0 )
{
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0;
tMP3Entry *e = _pMP3List;
_CurMP3Pos = 0;
tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
if(mp3) {
mp3 = _pMP3List;
if(mp3 == NULL) {
_bIsMp3Active = false;
nFile = 0;
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(
mp3Stream[nStream], 1);
AIL_set_stream_ms_position(
mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream],
0);
return true;
}
return false;
}
}
if(mp3->pLinkPath != NULL)
mp3Stream[nStream] =
AIL_open_stream(DIG, mp3->pLinkPath, 0);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, mp3->aFilename);
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
}
if(mp3Stream[nStream]) {
// Try to continue from previous song, if already started
if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
nFile = 0;
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], 0);
AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
return false;
_bIsMp3Active = false;
continue;
}
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0;
} else {
if ( e->pLinkPath != NULL )
mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, e->aFilename);
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
}
if ( mp3Stream[nStream] ) {
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
_bIsMp3Active = true;
tMP3Entry *e;
if ( !_GetMP3PosFromStreamPos(&position, &e) )
return true;
}
// fall through, start playing from another song
}
} else {
if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
_CurMP3Pos = 0;
tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
if ( !mp3 )
{
if ( e == NULL )
mp3 = _pMP3List;
if ( !_pMP3List )
{
nFile = 0;
_bIsMp3Active = 0;
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(
mp3Stream[nStream], 1);
AIL_set_stream_ms_position(
mp3Stream[nStream], position);
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
return false;
}
}
if ( e->pLinkPath != NULL )
mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0);
else
{
if(mp3->pLinkPath != NULL)
mp3Stream[nStream] = AIL_open_stream(DIG, mp3->pLinkPath, 0);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, e->aFilename);
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
strcat(filename, mp3->aFilename);
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
}
if ( mp3Stream[nStream] )
{
if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_set_stream_ms_position(mp3Stream[nStream], 0);
AIL_pause_stream(mp3Stream[nStream], 0);
#ifdef FIX_BUGS
_bIsMp3Active = true;
#endif
return true;
}
_bIsMp3Active = false;
} while(++i < nNumMP3s);
position = 0;
nFile = 0;
}
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
_bIsMp3Active = 0;
}
while ( ++i < nNumMP3s );
position = 0;
nFile = 0;
}
strcpy(filename, m_szCDRomRootPath);
strcat(filename, StreamedNameTable[nFile]);
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
return true;
}
return false;
}

View File

@ -730,8 +730,6 @@ _FindMP3s(void)
delete aStream[0];
aStream[0] = NULL;
OutputDebugString(fd.cFileName);
pList->pNext = new tMP3Entry;
tMP3Entry *e = pList->pNext;
@ -1706,91 +1704,91 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
int i = 0;
uint32 position = nPos;
char filename[256];
ASSERT( nStream < MAX_STREAMS );
if ( nFile < TOTAL_STREAMED_SOUNDS )
char filename[MAX_PATH];
if ( nFile >= TOTAL_STREAMED_SOUNDS )
return false;
if ( aStream[nStream] )
{
if ( aStream[nStream] )
delete aStream[nStream];
aStream[nStream] = NULL;
}
if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
{
do
{
delete aStream[nStream];
aStream[nStream] = NULL;
}
if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
{
uint32 i = 0;
do {
if(i != 0 || _bIsMp3Active) {
if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
// Switched to MP3 player just now
if ( !_bIsMp3Active && i == 0 )
{
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0;
tMP3Entry *e = _pMP3List;
_CurMP3Pos = 0;
// Try to continue from previous song, if already started
if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
nFile = 0;
strcpy(filename, StreamedNameTable[nFile]);
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
aStream[nStream] = stream;
if(mp3) {
mp3 = _pMP3List;
if(mp3 == NULL) {
_bIsMp3Active = false;
nFile = 0;
strcat(filename, StreamedNameTable[nFile]);
if (stream->Setup()) {
if (position != 0)
stream->SetPosMS(position);
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
ASSERT(stream != NULL);
stream->Start();
aStream[nStream] = stream;
if (stream->Setup()) {
if (position != 0)
stream->SetPosMS(position);
stream->Start();
return true;
} else {
delete stream;
aStream[nStream] = NULL;
}
return false;
}
return true;
} else {
delete stream;
aStream[nStream] = NULL;
}
return false;
if (mp3->pLinkPath != NULL)
aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
} else {
if ( e->pLinkPath != NULL )
aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, mp3->aFilename);
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
strcat(filename, e->aFilename);
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
}
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;
continue;
// fall through, start playing from another song
}
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0;
tMP3Entry *e;
if ( !_GetMP3PosFromStreamPos(&position, &e) )
} else {
if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
_CurMP3Pos = 0;
tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
if ( !mp3 )
{
if ( e == NULL )
mp3 = _pMP3List;
if ( !_pMP3List )
{
nFile = 0;
strcat(filename, StreamedNameTable[nFile]);
_bIsMp3Active = 0;
strcpy(filename, StreamedNameTable[nFile]);
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
ASSERT(stream != NULL);
aStream[nStream] = stream;
@ -1805,61 +1803,53 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
delete stream;
aStream[nStream] = NULL;
}
return false;
}
}
if (e->pLinkPath != NULL)
aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
if(mp3->pLinkPath != NULL)
aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, e->aFilename);
strcat(filename, mp3->aFilename);
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
}
if (aStream[nStream]->Setup()) {
if (position != 0)
aStream[nStream]->SetPosMS(position);
aStream[nStream]->Start();
#ifdef FIX_BUGS
_bIsMp3Active = true;
#endif
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], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
ASSERT(stream != NULL);
aStream[nStream] = stream;
if ( stream->Setup() ) {
if (position != 0)
stream->SetPosMS(position);
stream->Start();
return true;
} else {
delete stream;
aStream[nStream] = NULL;
}
_bIsMp3Active = 0;
}
while ( ++i < nNumMP3s );
position = 0;
nFile = 0;
}
strcpy(filename, StreamedNameTable[nFile]);
CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
aStream[nStream] = stream;
if ( stream->Setup() ) {
if (position != 0)
stream->SetPosMS(position);
stream->Start();
return true;
} else {
delete stream;
aStream[nStream] = NULL;
}
return false;
}

View File

@ -2718,7 +2718,7 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos)
attempts += 1;
}
if (attempts >= 5)
return nil;
return false;
CAutomobile* pVehicle = new CAutomobile(mi, RANDOM_VEHICLE);
pVehicle->AutoPilot.m_vecDestinationCoors = vecPos;
pVehicle->SetPosition(spawnPos);

View File

@ -432,14 +432,14 @@ CWaterLevel::TestVisibilityForFineWaterBlocks(const CVector &worldPos)
if ((lineEnd.x > WORLD_MIN_X && lineEnd.x < WORLD_MAX_X) && (lineEnd.y > WORLD_MIN_Y && lineEnd.y < WORLD_MAX_Y))
{
if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false))
{
lineStart.x += 0.4f;
lineStart.y += 0.4f;
lineEnd.x += 0.4f;
lineEnd.y += 0.4f;
if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false))
{
return false;
}

2
vendor/librw vendored

@ -1 +1 @@
Subproject commit cc550ff69c06ec03aae9ac7ac1f634703800660f
Subproject commit 8b2caf8f86b4f793d07fbc6b7d0bd4aafd22162f