summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio/MusicManager.cpp4
-rw-r--r--src/collision/Collision.cpp21
-rw-r--r--src/control/Garages.cpp8
-rw-r--r--src/control/Script3.cpp1
-rw-r--r--src/core/CdStream.h2
-rw-r--r--src/core/CdStreamPosix.cpp41
-rw-r--r--src/core/Radar.cpp2
-rw-r--r--src/core/Streaming.cpp86
-rw-r--r--src/core/Streaming.h4
-rw-r--r--src/core/World.cpp4
-rw-r--r--src/core/config.h15
-rw-r--r--src/core/main.cpp8
-rw-r--r--src/core/re3.cpp8
-rw-r--r--src/extras/custompipes_gl.cpp7
-rw-r--r--src/peds/Ped.cpp2
-rw-r--r--src/render/Renderer.cpp4
-rw-r--r--src/rw/TexRead.cpp1
-rw-r--r--src/rw/VisibilityPlugins.cpp4
-rw-r--r--src/skel/crossplatform.cpp8
-rw-r--r--src/skel/glfw/glfw.cpp10
20 files changed, 176 insertions, 64 deletions
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index 54c1b0bc..ad304985 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -163,13 +163,13 @@ cMusicManager::DisplayRadioStationName()
case CHATTERBOX: string = TheText.Get("FEA_FM8"); break;
case USERTRACK: string = TheText.Get("FEA_FM9"); break;
#ifdef RADIO_OFF_TEXT
- case RADIO_OFF: case POLICE_RADIO: string = TheText.Get("FEM_OFF"); break;
+ case RADIO_OFF: case POLICE_RADIO: string = TheText.Get("FEA_FMN"); break;
#endif
default: return;
};
#ifdef RADIO_OFF_TEXT
- if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { string = TheText.Get("FEM_OFF"); }
+ if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { string = TheText.Get("FEA_FMN"); }
#else
if(pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) { return; }
#endif
diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp
index 396e3b85..9d656581 100644
--- a/src/collision/Collision.cpp
+++ b/src/collision/Collision.cpp
@@ -477,8 +477,16 @@ CCollision::TestLineTriangle(const CColLine &line, const CompressedVector *verts
if(plane.CalcPoint(line.p0) * plane.CalcPoint(line.p1) > 0.0f)
return false;
+ float p0dist = DotProduct(line.p1 - line.p0, normal);
+
+#ifdef FIX_BUGS
+ // line lines in the plane, assume no collision
+ if (p0dist == 0.0f)
+ return false;
+#endif
+
// intersection parameter on line
- t = -plane.CalcPoint(line.p0) / DotProduct(line.p1 - line.p0, normal);
+ t = -plane.CalcPoint(line.p0) / p0dist;
// find point of intersection
CVector p = line.p0 + (line.p1-line.p0)*t;
@@ -1286,8 +1294,17 @@ CCollision::ProcessLineTriangle(const CColLine &line,
if(plane.CalcPoint(line.p0) * plane.CalcPoint(line.p1) > 0.0f)
return false;
+ float p0dist = DotProduct(line.p1 - line.p0, normal);
+
+#ifdef FIX_BUGS
+ // line lines in the plane, assume no collision
+ if (p0dist == 0.0f)
+ return false;
+#endif
+
// intersection parameter on line
- t = -plane.CalcPoint(line.p0) / DotProduct(line.p1 - line.p0, normal);
+ t = -plane.CalcPoint(line.p0) / p0dist;
+
// early out if we're beyond the mindist
if(t >= mindist)
return false;
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index afbae005..d6e36875 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -2034,7 +2034,11 @@ float CGarages::FindDoorHeightForMI(int32 mi)
void CGarage::TidyUpGarage()
{
uint32 i = CPools::GetVehiclePool()->GetSize();
+#ifdef FIX_BUGS
while (i--) {
+#else
+ while (--i) {
+#endif
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle || !pVehicle->IsCar())
continue;
@@ -2052,7 +2056,11 @@ void CGarage::TidyUpGarage()
void CGarage::TidyUpGarageClose()
{
uint32 i = CPools::GetVehiclePool()->GetSize();
+#ifdef FIX_BUGS
while (i--) {
+#else
+ while (--i) {
+#endif
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle || !pVehicle->IsCar())
continue;
diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp
index b166403c..ac88347b 100644
--- a/src/control/Script3.cpp
+++ b/src/control/Script3.cpp
@@ -1671,6 +1671,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
pBoat->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_ASTHECROWSWIMS;
pBoat->AutoPilot.m_vecDestinationCoors = pos;
pBoat->SetStatus(STATUS_PHYSICS);
+ pBoat->bEngineOn = true;
pBoat->AutoPilot.m_nCruiseSpeed = Max(6, pBoat->AutoPilot.m_nCruiseSpeed);
pBoat->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
return 0;
diff --git a/src/core/CdStream.h b/src/core/CdStream.h
index d0f9a855..516cef48 100644
--- a/src/core/CdStream.h
+++ b/src/core/CdStream.h
@@ -43,6 +43,6 @@ char *CdStreamGetImageName(int32 cd);
void CdStreamRemoveImages(void);
int32 CdStreamGetNumImages(void);
-#ifndef _WIN32
+#ifdef FLUSHABLE_STREAMING
extern bool flushStream[MAX_CDCHANNELS];
#endif
diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp
index 0854d850..e18280e5 100644
--- a/src/core/CdStreamPosix.cpp
+++ b/src/core/CdStreamPosix.cpp
@@ -21,9 +21,9 @@
#define CDDEBUG(f, ...) debug ("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
#define CDTRACE(f, ...) printf("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-// #define ONE_THREAD_PER_CHANNEL // Don't use if you're not on SSD/Flash. (Also you may want to benefit from this via using all channels in Streaming.cpp)
-
+#ifdef FLUSHABLE_STREAMING
bool flushStream[MAX_CDCHANNELS];
+#endif
struct CdReadInfo
{
@@ -76,7 +76,7 @@ CdStreamInitThread(void)
gChannelRequestQ.tail = 0;
gChannelRequestQ.size = gNumChannels + 1;
ASSERT(gChannelRequestQ.items != nil );
- gCdStreamSema = sem_open("/semaphore_cd_stream", O_CREAT, 0644, 1);
+ gCdStreamSema = sem_open("/semaphore_cd_stream", O_CREAT, 0644, 0);
if (gCdStreamSema == SEM_FAILED) {
@@ -91,7 +91,7 @@ CdStreamInitThread(void)
for ( int32 i = 0; i < gNumChannels; i++ )
{
sprintf(semName,"/semaphore_done%d",i);
- gpReadInfo[i].pDoneSemaphore = sem_open(semName, O_CREAT, 0644, 1);
+ gpReadInfo[i].pDoneSemaphore = sem_open(semName, O_CREAT, 0644, 0);
if (gpReadInfo[i].pDoneSemaphore == SEM_FAILED)
{
@@ -99,9 +99,10 @@ CdStreamInitThread(void)
ASSERT(0);
return;
}
+
#ifdef ONE_THREAD_PER_CHANNEL
sprintf(semName,"/semaphore_start%d",i);
- gpReadInfo[i].pStartSemaphore = sem_open(semName, O_CREAT, 0644, 1);
+ gpReadInfo[i].pStartSemaphore = sem_open(semName, O_CREAT, 0644, 0);
if (gpReadInfo[i].pStartSemaphore == SEM_FAILED)
{
@@ -170,6 +171,7 @@ CdStreamInit(int32 numChannels)
gNumImages = 0;
gNumChannels = numChannels;
+ ASSERT( gNumChannels != 0 );
gpReadInfo = (CdReadInfo *)calloc(numChannels, sizeof(CdReadInfo));
ASSERT( gpReadInfo != nil );
@@ -245,10 +247,12 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size)
if ( pChannel->nSectorsToRead != 0 || pChannel->bReading ) {
if (pChannel->hFile == hImage - 1 && pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size)
return STREAM_SUCCESS;
-
+#ifdef FLUSHABLE_STREAMING
flushStream[channel] = 1;
CdStreamSync(channel);
- //return STREAM_NONE;
+#else
+ return STREAM_NONE;
+#endif
}
pChannel->hFile = hImage - 1;
@@ -316,34 +320,34 @@ CdStreamSync(int32 channel)
CdReadInfo *pChannel = &gpReadInfo[channel];
ASSERT( pChannel != nil );
+#ifdef FLUSHABLE_STREAMING
if (flushStream[channel]) {
-#ifdef ONE_THREAD_PER_CHANNEL
pChannel->nSectorsToRead = 0;
+#ifdef ONE_THREAD_PER_CHANNEL
pthread_kill(pChannel->pChannelThread, SIGUSR1);
if (pChannel->bReading) {
pChannel->bLocked = true;
- while (pChannel->bLocked)
- sem_wait(pChannel->pDoneSemaphore);
- }
#else
- pChannel->nSectorsToRead = 0;
if (pChannel->bReading) {
pChannel->bLocked = true;
pthread_kill(_gCdStreamThread, SIGUSR1);
+#endif
while (pChannel->bLocked)
sem_wait(pChannel->pDoneSemaphore);
}
-#endif
pChannel->bReading = false;
flushStream[channel] = false;
return STREAM_NONE;
}
+#endif
if ( pChannel->nSectorsToRead != 0 )
{
pChannel->bLocked = true;
- while (pChannel->bLocked)
+ while (pChannel->bLocked && pChannel->nSectorsToRead != 0){
sem_wait(pChannel->pDoneSemaphore);
+ }
+ pChannel->bLocked = false;
}
pChannel->bReading = false;
@@ -395,7 +399,12 @@ void *CdStreamThread(void *param)
#ifndef ONE_THREAD_PER_CHANNEL
while (gCdStreamThreadStatus != 2) {
sem_wait(gCdStreamSema);
+
int32 channel = GetFirstInQueue(&gChannelRequestQ);
+
+ // spurious wakeup
+ if (channel == -1)
+ continue;
#else
int channel = *((int*)param);
while (gpReadInfo[channel].nThreadStatus != 2){
@@ -447,7 +456,7 @@ void *CdStreamThread(void *param)
if ( pChannel->bLocked )
{
pChannel->bLocked = 0;
- sem_post(pChannel->pDoneSemaphore);
+ sem_post(pChannel->pDoneSemaphore);
}
pChannel->bReading = false;
}
@@ -524,7 +533,9 @@ void
CdStreamRemoveImages(void)
{
for ( int32 i = 0; i < gNumChannels; i++ ) {
+#ifdef FLUSHABLE_STREAMING
flushStream[i] = 1;
+#endif
CdStreamSync(i);
}
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 116e9e94..4fd7f1a5 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -908,7 +908,7 @@ int32 CRadar::GetNewUniqueBlipIndex(int32 i)
uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright)
{
- int32 c;
+ uint32 c;
switch (color) {
case RADAR_TRACE_RED:
if (bright)
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index 7b4218ba..9ac22096 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -202,11 +202,15 @@ CStreaming::Init2(void)
// allocate streaming buffers
if(ms_streamingBufferSize & 1) ms_streamingBufferSize++;
+#ifndef ONE_THREAD_PER_CHANNEL
ms_pStreamingBuffer[0] = (int8*)RwMallocAlign(ms_streamingBufferSize*CDSTREAM_SECTOR_SIZE, CDSTREAM_SECTOR_SIZE);
ms_streamingBufferSize /= 2;
ms_pStreamingBuffer[1] = ms_pStreamingBuffer[0] + ms_streamingBufferSize*CDSTREAM_SECTOR_SIZE;
-#ifdef ONE_THREAD_PER_CHANNEL
- ms_pStreamingBuffer[2] = (int8*)RwMallocAlign(ms_streamingBufferSize*2*CDSTREAM_SECTOR_SIZE, CDSTREAM_SECTOR_SIZE);
+#else
+ ms_pStreamingBuffer[0] = (int8*)RwMallocAlign(ms_streamingBufferSize*2*CDSTREAM_SECTOR_SIZE, CDSTREAM_SECTOR_SIZE);
+ ms_streamingBufferSize /= 2;
+ ms_pStreamingBuffer[1] = ms_pStreamingBuffer[0] + ms_streamingBufferSize*CDSTREAM_SECTOR_SIZE;
+ ms_pStreamingBuffer[2] = ms_pStreamingBuffer[1] + ms_streamingBufferSize*CDSTREAM_SECTOR_SIZE;
ms_pStreamingBuffer[3] = ms_pStreamingBuffer[2] + ms_streamingBufferSize*CDSTREAM_SECTOR_SIZE;
#endif
debug("Streaming buffer size is %d sectors", ms_streamingBufferSize);
@@ -1932,9 +1936,10 @@ CStreaming::LoadRequestedModels(void)
}
-// Let's load models first, then process it. Unfortunately processing models are still single-threaded.
+// Let's load models in 4 threads; when one of them becomes idle, process the file, and fill thread with another file. Unfortunately processing models are still single-threaded.
// Currently only supported on POSIX streamer.
-#ifdef ONE_THREAD_PER_CHANNEL
+// WIP - some files are loaded swapped (CdStreamPosix problem?)
+#if 0 //def ONE_THREAD_PER_CHANNEL
void
CStreaming::LoadAllRequestedModels(bool priority)
{
@@ -1952,14 +1957,18 @@ CStreaming::LoadAllRequestedModels(bool priority)
int streamIds[ARRAY_SIZE(ms_pStreamingBuffer)];
int streamSizes[ARRAY_SIZE(ms_pStreamingBuffer)];
int streamPoses[ARRAY_SIZE(ms_pStreamingBuffer)];
- bool first = true;
+ int readOrder[4] = {-1}; // Channel IDs ordered by read time
+ int readI = 0;
int processI = 0;
+ bool first = true;
+
+ // All those "first" checks are because of variables aren't initialized in first pass.
while (true) {
- // Enumerate files and start reading
for (int i=0; i<ARRAY_SIZE(ms_pStreamingBuffer); i++) {
+
+ // Channel has file to load
if (!first && streamIds[i] != -1) {
- processI = i;
continue;
}
@@ -1972,12 +1981,16 @@ CStreaming::LoadAllRequestedModels(bool priority)
if (ms_aInfoForModel[streamId].GetCdPosnAndSize(posn, size)) {
streamIds[i] = -1;
+
+ // Big file, needs 2 buffer
if (size > (uint32)ms_streamingBufferSize) {
if (i + 1 == ARRAY_SIZE(ms_pStreamingBuffer))
- continue;
+ break;
else if (!first && streamIds[i+1] != -1)
continue;
+
} else {
+ // Buffer of current channel is part of a "big file", pass
if (i != 0 && streamIds[i-1] != -1 && streamSizes[i-1] > (uint32)ms_streamingBufferSize)
continue;
}
@@ -1987,8 +2000,18 @@ CStreaming::LoadAllRequestedModels(bool priority)
streamIds[i] = streamId;
streamSizes[i] = size;
streamPoses[i] = posn;
+
+ if (!first)
+ assert(readOrder[readI] == -1);
+
+ //printf("read: order %d, ch %d, id %d, size %d\n", readI, i, streamId, size);
+
CdStreamRead(i, ms_pStreamingBuffer[i], imgOffset+posn, size);
- processI = i;
+ readOrder[readI] = i;
+ if (first && readI+1 != ARRAY_SIZE(readOrder))
+ readOrder[readI+1] = -1;
+
+ readI = (readI + 1) % ARRAY_SIZE(readOrder);
} else {
ms_aInfoForModel[streamId].RemoveFromList();
DecrementRef(streamId);
@@ -1996,33 +2019,40 @@ CStreaming::LoadAllRequestedModels(bool priority)
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED;
streamIds[i] = -1;
}
- } else
+ } else {
streamIds[i] = -1;
+ break;
+ }
}
first = false;
+ int nextChannel = readOrder[processI];
- // Now process
- if (streamIds[processI] == -1)
+ // Now start processing
+ if (nextChannel == -1 || streamIds[nextChannel] == -1)
break;
+ //printf("process: order %d, ch %d, id %d\n", processI, nextChannel, streamIds[nextChannel]);
+
// Try again on error
- while (CdStreamSync(processI) != STREAM_NONE) {
- CdStreamRead(processI, ms_pStreamingBuffer[processI], imgOffset+streamPoses[processI], streamSizes[processI]);
- }
- ms_aInfoForModel[streamIds[processI]].m_loadState = STREAMSTATE_READING;
-
- MakeSpaceFor(streamSizes[processI] * CDSTREAM_SECTOR_SIZE);
- ConvertBufferToObject(ms_pStreamingBuffer[processI], streamIds[processI]);
- if(ms_aInfoForModel[streamIds[processI]].m_loadState == STREAMSTATE_STARTED)
- FinishLoadingLargeFile(ms_pStreamingBuffer[processI], streamIds[processI]);
-
- if(streamIds[processI] < STREAM_OFFSET_TXD){
- CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(streamIds[processI]);
+ while (CdStreamSync(nextChannel) != STREAM_NONE) {
+ CdStreamRead(nextChannel, ms_pStreamingBuffer[nextChannel], imgOffset+streamPoses[nextChannel], streamSizes[nextChannel]);
+ }
+ ms_aInfoForModel[streamIds[nextChannel]].m_loadState = STREAMSTATE_READING;
+
+ MakeSpaceFor(streamSizes[nextChannel] * CDSTREAM_SECTOR_SIZE);
+ ConvertBufferToObject(ms_pStreamingBuffer[nextChannel], streamIds[nextChannel]);
+ if(ms_aInfoForModel[streamIds[nextChannel]].m_loadState == STREAMSTATE_STARTED)
+ FinishLoadingLargeFile(ms_pStreamingBuffer[nextChannel], streamIds[nextChannel]);
+
+ if(streamIds[nextChannel] < STREAM_OFFSET_TXD){
+ CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(streamIds[nextChannel]);
if(mi->IsSimple())
mi->m_alpha = 255;
}
- streamIds[processI] = -1;
+ streamIds[nextChannel] = -1;
+ readOrder[processI] = -1;
+ processI = (processI + 1) % ARRAY_SIZE(readOrder);
}
ms_bLoadingBigModel = false;
@@ -2061,7 +2091,7 @@ CStreaming::LoadAllRequestedModels(bool priority)
status = CdStreamRead(0, ms_pStreamingBuffer[0], imgOffset+posn, size);
while(CdStreamSync(0) || status == STREAM_NONE);
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_READING;
-
+
MakeSpaceFor(size * CDSTREAM_SECTOR_SIZE);
ConvertBufferToObject(ms_pStreamingBuffer[0], streamId);
if(ms_aInfoForModel[streamId].m_loadState == STREAMSTATE_STARTED)
@@ -2118,7 +2148,7 @@ CStreaming::FlushRequestList(void)
next = si->m_next;
RemoveModel(si - ms_aInfoForModel);
}
-#ifndef _WIN32
+#ifdef FLUSHABLE_STREAMING
if(ms_channel[0].state == CHANNELSTATE_READING) {
flushStream[0] = 1;
}
@@ -2798,4 +2828,4 @@ CStreaming::PrintStreamingBufferState()
DoRWStuffEndOfFrame();
}
CTimer::Update();
-} \ No newline at end of file
+}
diff --git a/src/core/Streaming.h b/src/core/Streaming.h
index 0e2e89be..3294a88e 100644
--- a/src/core/Streaming.h
+++ b/src/core/Streaming.h
@@ -85,7 +85,11 @@ public:
static int32 ms_oldSectorX;
static int32 ms_oldSectorY;
static int32 ms_streamingBufferSize;
+#ifndef ONE_THREAD_PER_CHANNEL
static int8 *ms_pStreamingBuffer[2];
+#else
+ static int8 *ms_pStreamingBuffer[4];
+#endif
static size_t ms_memoryUsed;
static CStreamingChannel ms_channel[2];
static int32 ms_channelError;
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 78b0f8ee..90d73b09 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -360,7 +360,7 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP
} else if(e->bUsesCollision)
colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
- if(colmodel && CCollision::ProcessLineOfSight(line, e->GetMatrix(), *colmodel, point, dist,
+ if(colmodel && CCollision::ProcessLineOfSight(line, e->GetMatrix(), *colmodel, point, mindist,
ignoreSeeThrough))
entity = e;
}
@@ -445,7 +445,7 @@ CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CCol
e->m_scanCode = GetCurrentScanCode();
colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
- if(CCollision::ProcessVerticalLine(line, e->GetMatrix(), *colmodel, point, dist,
+ if(CCollision::ProcessVerticalLine(line, e->GetMatrix(), *colmodel, point, mindist,
ignoreSeeThrough, poly))
entity = e;
}
diff --git a/src/core/config.h b/src/core/config.h
index b2c7135a..8a500fd5 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -340,6 +340,10 @@ enum Config {
#define USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
#define SCRIPT_LOG_FILE_LEVEL 0 // 0 == no log, 1 == overwrite every frame, 2 == full log
+#if SCRIPT_LOG_FILE_LEVEL == 0
+#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+#endif
+
#ifndef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
#define USE_BASIC_SCRIPT_DEBUG_OUTPUT
#endif
@@ -392,8 +396,13 @@ enum Config {
#endif
#endif
-// IMG
-#define BIG_IMG // allows to read larger img files
+
+// Streaming
+#if !defined(_WIN32) && !defined(__SWITCH__)
+ //#define ONE_THREAD_PER_CHANNEL // Don't use if you're not on SSD/Flash - also not utilized too much right now(see commented LoadAllRequestedModels in Streaming.cpp)
+ #define FLUSHABLE_STREAMING // Make it possible to interrupt reading when processing file isn't needed anymore.
+#endif
+#define BIG_IMG // Not complete - allows to read larger img files
//#define SQUEEZE_PERFORMANCE
#ifdef SQUEEZE_PERFORMANCE
@@ -404,6 +413,8 @@ enum Config {
#define VC_RAIN_NERF // Reduces number of rain particles
#endif
+// -------
+
#if defined __MWERKS__ || defined VANILLA_DEFINES
#define FINAL
#undef CHATTYSPLASH
diff --git a/src/core/main.cpp b/src/core/main.cpp
index f1346fc0..af0d556a 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -201,6 +201,9 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
if(!RsCameraBeginUpdate(Scene.camera))
return false;
+#ifdef FIX_BUGS
+ CSprite2d::SetRecipNearClip();
+#endif
CSprite2d::InitPerFrame();
if(Alpha != 0)
@@ -1107,8 +1110,13 @@ DisplayGameDebugText()
#endif // #ifdef DRAW_GAME_VERSION_TEXT
FrameSamples++;
+#ifdef FIX_BUGS
+ FramesPerSecondCounter += frameTime / 1000.f; // convert to seconds
+ FramesPerSecond = FrameSamples / FramesPerSecondCounter;
+#else
FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f);
FramesPerSecond = FramesPerSecondCounter / FrameSamples;
+#endif
if ( FrameSamples > 30 )
{
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 7c780516..474a4644 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -396,6 +396,9 @@ bool LoadINISettings()
ReadIniIfExists("CustomPipesValues", "LightmapMult", &CustomPipes::LightmapMult);
ReadIniIfExists("CustomPipesValues", "GlossMult", &CustomPipes::GlossMult);
#endif
+#ifdef NEW_RENDERER
+ ReadIniIfExists("Rendering", "NewRenderer", &gbNewRenderer);
+#endif
#ifdef PROPER_SCALING
ReadIniIfExists("Draw", "ProperScaling", &CDraw::ms_bProperScaling);
@@ -479,6 +482,9 @@ void SaveINISettings()
StoreIni("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult);
StoreIni("CustomPipesValues", "GlossMult", CustomPipes::GlossMult);
#endif
+#ifdef NEW_RENDERER
+ StoreIni("Rendering", "NewRenderer", gbNewRenderer);
+#endif
#ifdef PROPER_SCALING
StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling);
@@ -684,7 +690,7 @@ void CTweakVars::Add(CTweakVar *var)
TweakVarsListSize = 0;
}
if(TweakVarsListSize > 63)
- TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(*var));
+ TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(CTweakVar*));
TweakVarsList[TweakVarsListSize++] = var;
// TweakVarsList.push_back(var);
diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp
index 0c092c5f..caf9eb27 100644
--- a/src/extras/custompipes_gl.cpp
+++ b/src/extras/custompipes_gl.cpp
@@ -332,7 +332,12 @@ glossRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header)
V3d eyePos = rw::engine->currentCamera->getFrame()->getLTM()->pos;
glUniform3fv(U(u_eye), 1, (float*)&eyePos);
- glUniform4fv(U(u_reflProps), 1, (float*)&GlossMult);
+ float reflProps[4];
+ reflProps[0] = GlossMult;
+ reflProps[1] = 0.0f;
+ reflProps[2] = 0.0f;
+ reflProps[3] = 0.0f;
+ glUniform4fv(U(u_reflProps), 1, reflProps);
SetRenderState(VERTEXALPHA, TRUE);
SetRenderState(SRCBLEND, BLENDONE);
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 5da41a9c..e0d60304 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -1545,7 +1545,7 @@ CPed::ProcessBuoyancy(void)
CRGBA color(((0.5f * CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed()) * 127.5f),
((0.5f * CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue()) * 127.5f),
((0.5f * CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen()) * 127.5f),
- (CGeneral::GetRandomNumber() % 256 * 48.0f) + 48);
+ CGeneral::GetRandomNumberInRange(48.0f, 96.0f));
if (bInVehicle)
return;
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index d41f27e3..2c224677 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -1396,6 +1396,10 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
void
CRenderer::InsertEntityIntoList(CEntity *ent)
{
+#ifdef FIX_BUGS
+ if (!ent->m_rwObject) return;
+#endif
+
#ifdef NEW_RENDERER
// TODO: there are more flags being checked here
if(gbNewRenderer && (ent->IsVehicle() || ent->IsPed()))
diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp
index c009af96..98e7d180 100644
--- a/src/rw/TexRead.cpp
+++ b/src/rw/TexRead.cpp
@@ -1,6 +1,7 @@
#pragma warning( push )
#pragma warning( disable : 4005)
#pragma warning( pop )
+#define FORCE_PC_SCALING
#include "common.h"
#ifdef ANISOTROPIC_FILTERING
#include "rpanisot.h"
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 32461d1c..051a6883 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -192,6 +192,10 @@ CVisibilityPlugins::InitAlphaEntityList(void)
bool
CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist)
{
+#ifdef FIX_BUGS
+ if (!e->m_rwObject) return true;
+#endif
+
AlphaObjectInfo item;
item.entity = e;
item.sort = dist;
diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp
index f2f9d5ee..1d49ebd2 100644
--- a/src/skel/crossplatform.cpp
+++ b/src/skel/crossplatform.cpp
@@ -32,8 +32,8 @@ HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) {
char *folder = strtok(pathCopy, "*");
char *extension = strtok(NULL, "*");
- // because strtok doesn't return NULL for last delimiter
- if (extension - folder == strlen(pathname))
+ // because I remember like strtok might not return NULL for last delimiter
+ if (extension && extension - folder == strlen(pathname))
extension = nil;
// Case-sensitivity and backslashes...
@@ -187,7 +187,7 @@ char* casepath(char const* path, bool checkPathFirst)
rl = 1;
}
- bool cantProceed = false; // just convert slashes in what's left in string, not case sensitivity
+ bool cantProceed = false; // just convert slashes in what's left in string, don't correct case of letters(because we can't)
bool mayBeTrailingSlash = false;
char* c;
while (c = strsep(&p, "/\\"))
@@ -251,7 +251,7 @@ char* casepath(char const* path, bool checkPathFirst)
}
if (rl > l + 2) {
- printf("\n\ncasepath: Corrected path length is longer then original+2:\n\tOriginal: %s (%d chars)\n\tCorrected: %s (%d chars)\n\n", path, l, out, rl);
+ printf("\n\ncasepath: Corrected path length is longer then original+2:\n\tOriginal: %s (%zu chars)\n\tCorrected: %s (%zu chars)\n\n", path, l, out, rl);
}
return out;
}
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 938cc328..9643c63b 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -1239,10 +1239,11 @@ void terminateHandler(int sig, siginfo_t *info, void *ucontext) {
RsGlobal.quit = TRUE;
}
+#ifdef FLUSHABLE_STREAMING
void dummyHandler(int sig){
// Don't kill the app pls
}
-
+#endif
#endif
void resizeCB(GLFWwindow* window, int width, int height) {
@@ -1415,7 +1416,7 @@ bool rshiftStatus = false;
void
keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods)
{
- if (key >= 0 && key <= GLFW_KEY_LAST) {
+ if (key >= 0 && key <= GLFW_KEY_LAST && action != GLFW_REPEAT) {
RsKeyCodes ks = (RsKeyCodes)keymap[key];
if (key == GLFW_KEY_LEFT_SHIFT)
@@ -1426,7 +1427,6 @@ keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods)
if (action == GLFW_RELEASE) RsKeyboardEventHandler(rsKEYUP, &ks);
else if (action == GLFW_PRESS) RsKeyboardEventHandler(rsKEYDOWN, &ks);
- else if (action == GLFW_REPEAT) RsKeyboardEventHandler(rsKEYDOWN, &ks);
}
}
@@ -1496,11 +1496,13 @@ main(int argc, char *argv[])
act.sa_sigaction = terminateHandler;
act.sa_flags = SA_SIGINFO;
sigaction(SIGTERM, &act, NULL);
+#ifdef FLUSHABLE_STREAMING
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_handler = dummyHandler;
sa.sa_flags = 0;
- sigaction(SIGUSR1, &sa, NULL); // Needed for CdStreamPosix
+ sigaction(SIGUSR1, &sa, NULL);
+#endif
#endif
/*