From 97351ad2c2a05f9221601b27432aaf7b51507103 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 27 Jan 2021 18:50:24 +0200 Subject: Use original animation names from VCS --- src/core/AnimViewer.cpp | 8 ++++---- src/core/Ropes.cpp | 2 +- src/core/World.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index 854ec7d4..562b9c15 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -245,7 +245,7 @@ CAnimViewer::Update(void) if (modelInfo->GetModelType() == MITYPE_PED) { int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup; - if (animId > ANIM_IDLE_STANCE) + if (animId > ANIM_STD_IDLE) animGroup = ASSOCGRP_STD; if (reloadIFP) { @@ -334,14 +334,14 @@ CAnimViewer::Update(void) CMessages::AddMessage(gUString, 1000, 0); } else if (pad->GetCircleJustDown()) { - PlayAnimation(pTarget->GetClump(), animGroup, ANIM_IDLE_STANCE); + PlayAnimation(pTarget->GetClump(), animGroup, ANIM_STD_IDLE); AsciiToUnicode("Idle animation playing", gUString); CMessages::AddMessage(gUString, 1000, 0); } else if (pad->GetDPadUpJustDown()) { animId--; if (animId < 0) { - animId = NUM_STD_ANIMS - 1; + animId = ANIM_STD_NUM - 1; } PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); @@ -350,7 +350,7 @@ CAnimViewer::Update(void) CMessages::AddMessage(gUString, 1000, 0); } else if (pad->GetDPadDownJustDown()) { - animId = (animId == (NUM_STD_ANIMS - 1) ? 0 : animId + 1); + animId = (animId == (ANIM_STD_NUM - 1) ? 0 : animId + 1); PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); sprintf(gString, "Current anim: %d", animId); diff --git a/src/core/Ropes.cpp b/src/core/Ropes.cpp index ffce36f9..52427fc3 100644 --- a/src/core/Ropes.cpp +++ b/src/core/Ropes.cpp @@ -167,7 +167,7 @@ CRopes::CreateRopeWithSwatComingDown(CVector pos) swat->bUsesCollision = false; swat->m_pRopeEntity = (CEntity*)1; swat->m_nRopeID = 100 + ropeId; - CAnimManager::BlendAnimation(swat->GetClump(), ASSOCGRP_STD, ANIM_ABSEIL, 4.0f); + CAnimManager::BlendAnimation(swat->GetClump(), ASSOCGRP_STD, ANIM_STD_ABSEIL, 4.0f); ropeId++; return true; } diff --git a/src/core/World.cpp b/src/core/World.cpp index bc698c83..959d0259 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -2213,7 +2213,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa PEDPIECE_TORSO, direction); if(pPed->m_nPedState != PED_DIE) pPed->SetFall(2000, - (AnimationId)(direction + ANIM_KO_SKID_FRONT), 0); + (AnimationId)(direction + ANIM_STD_HIGHIMPACT_FRONT), 0); if(pCreator && pCreator->IsPed()) { eEventType eventType = EVENT_SHOOT_PED; if(pPed->m_nPedType == PEDTYPE_COP) eventType = EVENT_SHOOT_COP; -- cgit v1.2.3 From ab939e059b4263fec4e26425bce6a12ecf88d2e6 Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 27 Jan 2021 18:26:08 +0300 Subject: Clean up POSIX streaming code --- src/core/CdStream.h | 2 +- src/core/CdStreamPosix.cpp | 29 +++++++++------- src/core/Streaming.cpp | 82 +++++++++++++++++++++++++++++++--------------- src/core/Streaming.h | 4 +++ src/core/config.h | 11 ++++--- 5 files changed, 85 insertions(+), 43 deletions(-) (limited to 'src/core') 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..8a27665a 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 { @@ -99,6 +99,7 @@ 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); @@ -245,10 +246,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 +319,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; @@ -447,7 +450,7 @@ void *CdStreamThread(void *param) if ( pChannel->bLocked ) { pChannel->bLocked = 0; - sem_post(pChannel->pDoneSemaphore); + sem_post(pChannel->pDoneSemaphore); } pChannel->bReading = false; } @@ -524,7 +527,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/Streaming.cpp b/src/core/Streaming.cpp index 6f0e3153..b28a99fc 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -207,11 +207,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); @@ -2305,9 +2309,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) { @@ -2326,14 +2331,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 (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; } @@ -2361,8 +2374,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); @@ -2370,33 +2393,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]); + while (CdStreamSync(nextChannel) != STREAM_NONE) { + CdStreamRead(nextChannel, ms_pStreamingBuffer[nextChannel], imgOffset+streamPoses[nextChannel], streamSizes[nextChannel]); } - 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]); + 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[processI] < STREAM_OFFSET_TXD){ - CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(streamIds[processI]); + 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; @@ -2443,7 +2473,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) @@ -2500,7 +2530,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; } @@ -3216,4 +3246,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 a67384f6..4ddf0b3b 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -88,7 +88,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/config.h b/src/core/config.h index 7e039ef6..329d70b9 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -393,11 +393,12 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #endif -#ifdef LIBRW -// these are not supported with librw yet +// 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 -// IMG -#define BIG_IMG // allows to read larger img files +#define BIG_IMG // Not complete - allows to read larger img files //#define SQUEEZE_PERFORMANCE #ifdef SQUEEZE_PERFORMANCE @@ -405,6 +406,8 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef NO_ISLAND_LOADING #endif +// ------- + #if defined __MWERKS__ || defined VANILLA_DEFINES #define FINAL #undef CHATTYSPLASH -- cgit v1.2.3 From be88a42bad207a2c723c3cdb152a872e1a7f14af Mon Sep 17 00:00:00 2001 From: erorcun Date: Thu, 28 Jan 2021 00:51:43 +0300 Subject: Fix some Collision NaN/inf's --- src/core/World.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index bc698c83..9da36e7a 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -452,10 +452,10 @@ CWorld::ProcessVerticalLineSector(CSector §or, const CColLine &line, CColPoi } bool -CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, +CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &mindist, CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly) { - float mindist = dist; + float dist = mindist; CPtrNode *node; CEntity *e; CColModel *colmodel; @@ -472,8 +472,8 @@ CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CCol } } - if(mindist < dist) { - dist = mindist; + if(dist < mindist) { + mindist = dist; return true; } else return false; -- cgit v1.2.3 From e1e4be9017246cc6b4d14d5b5d346c5c142941c0 Mon Sep 17 00:00:00 2001 From: erorcun Date: Thu, 28 Jan 2021 03:49:50 +0300 Subject: Use previous naming & fix LineOfSightSectorList too --- src/core/World.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index 9da36e7a..ef1cc948 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -367,7 +367,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, ignoreShootThrough)) entity = e; if(carTyres && ((CVehicle*)e)->SetUpWheelColModel(&tyreCol) && CCollision::ProcessLineOfSight(line, e->GetMatrix(), tyreCol, tyreColPoint, tyreDist, false, ignoreShootThrough)){ @@ -452,10 +452,10 @@ CWorld::ProcessVerticalLineSector(CSector §or, const CColLine &line, CColPoi } bool -CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &mindist, +CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly) { - float dist = mindist; + float mindist = dist; CPtrNode *node; CEntity *e; CColModel *colmodel; @@ -466,14 +466,14 @@ 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, false, poly)) entity = e; } } - if(dist < mindist) { - mindist = dist; + if(mindist < dist) { + dist = mindist; return true; } else return false; -- cgit v1.2.3 From 810bad9fd8cf344f7d73b82f042910a4c443b0f7 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 29 Jan 2021 01:44:33 +0300 Subject: Fix some UBs --- src/core/Frontend.cpp | 25 ++++++++++++++++--------- src/core/main.cpp | 5 +++++ 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 5fe3d6be..f38efb66 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5567,33 +5567,40 @@ void CMenuManager::DrawQuitGameScreen(void) { static int32 exitSignalTimer = 0; + +#ifdef FIX_BUGS + int alpha = clamp(m_nMenuFadeAlpha, 0, 255); +#else + int alpha = m_nMenuFadeAlpha; +#endif + #ifndef MUCH_SHORTER_OUTRO_SCREEN static PauseModeTime lastTickIncrease = 0; - if (m_nMenuFadeAlpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - lastTickIncrease > 10) { + if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - lastTickIncrease > 10) { exitSignalTimer++; lastTickIncrease = CTimer::GetTimeInMillisecondsPauseMode(); } #else - static PauseModeTime sincePress = 0; - sincePress += frameTime; - if (sincePress > 500) + static PauseModeTime firstTick = CTimer::GetTimeInMillisecondsPauseMode(); + if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - firstTick > 1000) { exitSignalTimer = 150; + } #endif static CSprite2d *splash = nil; if (splash == nil) splash = LoadSplash("OUTRO"); - m_aFrontEndSprites[MENUSPRITE_VCLOGO].Draw(CRect(MENU_X(28.0f), MENU_Y(8.0f), MENU_X(157.0f), MENU_Y(138.0f)), CRGBA(255, 255, 255, -(m_nMenuFadeAlpha + 1))); + m_aFrontEndSprites[MENUSPRITE_VCLOGO].Draw(CRect(MENU_X(28.0f), MENU_Y(8.0f), MENU_X(157.0f), MENU_Y(138.0f)), CRGBA(255, 255, 255, 255 - alpha)); // Or we can see menu background from sides #ifdef ASPECT_RATIO_SCALE - CSprite2d::DrawRect(CRect(0, 0, MENU_X_LEFT_ALIGNED(0.f), SCREEN_HEIGHT), CRGBA(0, 0, 0, m_nMenuFadeAlpha)); - CSprite2d::DrawRect(CRect(MENU_X_RIGHT_ALIGNED(0.f), 0, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, m_nMenuFadeAlpha)); + CSprite2d::DrawRect(CRect(0, 0, MENU_X_LEFT_ALIGNED(0.f), SCREEN_HEIGHT), CRGBA(0, 0, 0, alpha)); + CSprite2d::DrawRect(CRect(MENU_X_RIGHT_ALIGNED(0.f), 0, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, alpha)); #endif - splash->Draw(CRect(MENU_X_LEFT_ALIGNED(0.f), 0, MENU_X_RIGHT_ALIGNED(0.f), SCREEN_HEIGHT), CRGBA(255, 255, 255, m_nMenuFadeAlpha)); - if (m_nMenuFadeAlpha == 255 && exitSignalTimer == 150) + splash->Draw(CRect(MENU_X_LEFT_ALIGNED(0.f), 0, MENU_X_RIGHT_ALIGNED(0.f), SCREEN_HEIGHT), CRGBA(255, 255, 255, alpha)); + if (alpha == 255 && exitSignalTimer == 150) RsEventHandler(rsQUITAPP, nil); m_bShowMouse = false; diff --git a/src/core/main.cpp b/src/core/main.cpp index 9a0308dd..a08a9535 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1065,8 +1065,13 @@ DisplayGameDebugText() #endif FrameSamples++; +#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND + 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 ) { -- cgit v1.2.3 From 595a000f6a72a0bf376f5c019a76bcec9dc98c2f Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 29 Jan 2021 13:43:50 +0100 Subject: fix shutdown --- src/core/Game.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 83d30bb4..ed9d67f4 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -591,7 +591,6 @@ bool CGame::ShutDown(void) gPhoneInfo.Shutdown(); CWeapon::ShutdownWeapons(); CPedType::Shutdown(); - CMBlur::MotionBlurClose(); for (int32 i = 0; i < NUMPLAYERS; i++) { @@ -617,7 +616,7 @@ bool CGame::ShutDown(void) CStreaming::Shutdown(); CTxdStore::GameShutdown(); CCollision::Shutdown(); - CWaterLevel::DestroyWavyAtomic(); + CWaterLevel::Shutdown(); CRubbish::Shutdown(); CClouds::Shutdown(); CShadows::Shutdown(); @@ -626,6 +625,7 @@ bool CGame::ShutDown(void) CWeaponEffects::Shutdown(); CParticle::Shutdown(); CPools::ShutDown(); + CHud::ReInitialise(); CTxdStore::RemoveTxdSlot(gameTxdSlot); CMBlur::MotionBlurClose(); CdStreamRemoveImages(); -- cgit v1.2.3 From 982b024c5c7564251358293e160bc674e555d9cd Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 29 Jan 2021 16:25:32 +0300 Subject: CdStreamPosix fixes --- src/core/CdStreamPosix.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index 8a27665a..e18280e5 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -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) { @@ -102,7 +102,7 @@ CdStreamInitThread(void) #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) { @@ -171,6 +171,7 @@ CdStreamInit(int32 numChannels) gNumImages = 0; gNumChannels = numChannels; + ASSERT( gNumChannels != 0 ); gpReadInfo = (CdReadInfo *)calloc(numChannels, sizeof(CdReadInfo)); ASSERT( gpReadInfo != nil ); @@ -398,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){ -- cgit v1.2.3 From 934aa92a9b9c2bfd2bf4af8316bf12fb83416902 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 29 Jan 2021 16:41:34 +0100 Subject: add NewRenderer ini read/write, fix backfaceculling read --- src/core/re3.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index d0006fd3..83ef7c88 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -406,6 +406,10 @@ bool LoadINISettings() ReadIniIfExists("CustomPipesValues", "LightmapMult", &CustomPipes::LightmapMult); ReadIniIfExists("CustomPipesValues", "GlossMult", &CustomPipes::GlossMult); #endif + ReadIniIfExists("Rendering", "BackfaceCulling", &gBackfaceCulling); +#ifdef NEW_RENDERER + ReadIniIfExists("Rendering", "NewRender", &gbNewRenderer); +#endif #ifdef PROPER_SCALING ReadIniIfExists("Draw", "ProperScaling", &CDraw::ms_bProperScaling); @@ -495,6 +499,9 @@ void SaveINISettings() StoreIni("CustomPipesValues", "GlossMult", CustomPipes::GlossMult); #endif StoreIni("Rendering", "BackfaceCulling", gBackfaceCulling); +#ifdef NEW_RENDERER + StoreIni("Rendering", "NewRenderer", gbNewRenderer); +#endif #ifdef PROPER_SCALING StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling); -- cgit v1.2.3 From 7db28f9f7f46431fcad9d977275f540e3cbc5a6f Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 29 Jan 2021 16:43:17 +0100 Subject: fix NewRender typo --- src/core/re3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 83ef7c88..87aca59c 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -408,7 +408,7 @@ bool LoadINISettings() #endif ReadIniIfExists("Rendering", "BackfaceCulling", &gBackfaceCulling); #ifdef NEW_RENDERER - ReadIniIfExists("Rendering", "NewRender", &gbNewRenderer); + ReadIniIfExists("Rendering", "NewRenderer", &gbNewRenderer); #endif #ifdef PROPER_SCALING -- cgit v1.2.3 From c4328afce7e2a0b48b9d0d2b225496e29fff1c0a Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 29 Jan 2021 03:44:12 +0300 Subject: Even more fixes & shorten quit screen --- src/core/Frontend.cpp | 2 +- src/core/Radar.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index f38efb66..16a70697 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5582,7 +5582,7 @@ CMenuManager::DrawQuitGameScreen(void) } #else static PauseModeTime firstTick = CTimer::GetTimeInMillisecondsPauseMode(); - if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - firstTick > 1000) { + if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - firstTick > 750) { exitSignalTimer = 150; } #endif diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 8cd86344..4bb9c966 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -824,7 +824,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) -- cgit v1.2.3 From dbf5c06144d6ccc74fce696ea20571939be3ad4a Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 30 Jan 2021 14:53:51 +0300 Subject: fixed bike bomb --- src/core/World.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index ef1cc948..40c060c0 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -2239,8 +2239,12 @@ CWorld::UseDetonator(CEntity *pEntity) { int32 i = CPools::GetVehiclePool()->GetSize(); while(--i >= 0) { +#ifdef FIX_BUGS + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); +#else CAutomobile *pVehicle = (CAutomobile *)CPools::GetVehiclePool()->GetSlot(i); - if(pVehicle && !pVehicle->m_vehType && pVehicle->m_bombType == CARBOMB_REMOTE && +#endif + if(pVehicle && pVehicle->m_bombType == CARBOMB_REMOTE && pVehicle->m_pBombRigger == pEntity) { pVehicle->m_bombType = CARBOMB_NONE; pVehicle->m_nBombTimer = 500; -- cgit v1.2.3 From 264d7d98d72dd89f8259fbedad56c42b5bdefd55 Mon Sep 17 00:00:00 2001 From: shfil Date: Sun, 31 Jan 2021 15:01:46 +0100 Subject: fix realloc --- src/core/re3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 87aca59c..4b828171 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -713,7 +713,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); -- cgit v1.2.3 From 902e539c0d25ec418cd36c735079561f378c712c Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 30 Jan 2021 14:52:48 +0300 Subject: Overhaul MusicManager - fix radio bugs, scroll to prev station, radio off text --- src/core/Camera.cpp | 2 +- src/core/ControllerConfig.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++ src/core/ControllerConfig.h | 4 ++++ src/core/config.h | 6 +++++- 4 files changed, 55 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 25d2e5c3..5b3f9aa5 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -1768,7 +1768,7 @@ CCamera::CamControl(void) (m_bLookingAtPlayer || WhoIsInControlOfTheCamera == CAMCONTROL_OBBE) && !m_WideScreenOn && (WhoIsInControlOfTheCamera != CAMCONTROL_OBBE || bSwitchedToObbeCam)) - DMAudio.PlayFrontEndSound(SOUND_HUD_SOUND, 0); + DMAudio.PlayFrontEndSound(SOUND_HUD, 0); } // What a mess! diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 23e86a79..7f634619 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -1765,6 +1765,51 @@ void CControllerConfigManager::DeleteMatching1rstPersonControls(e_ControllerActi #undef CLEAR_ACTION_IF_NEEDED +#ifdef RADIO_SCROLL_TO_PREV_STATION +#define CHECK_ACTION(action) \ +if (key == GetControllerKeyAssociatedWithAction(action, type))\ + return true; + +bool CControllerConfigManager::IsAnyVehicleActionAssignedToMouseKey(int32 key) +{ + const eControllerType type = MOUSE; + if (!GetIsKeyBlank(key, type)) + { +#ifdef BIND_VEHICLE_FIREWEAPON + CHECK_ACTION(VEHICLE_FIREWEAPON); +#endif + CHECK_ACTION(VEHICLE_LOOKBEHIND); + CHECK_ACTION(VEHICLE_LOOKLEFT); + CHECK_ACTION(VEHICLE_LOOKRIGHT); + CHECK_ACTION(VEHICLE_HORN); + CHECK_ACTION(VEHICLE_HANDBRAKE); + CHECK_ACTION(VEHICLE_ACCELERATE); + CHECK_ACTION(VEHICLE_BRAKE); + CHECK_ACTION(VEHICLE_CHANGE_RADIO_STATION); + CHECK_ACTION(TOGGLE_SUBMISSIONS); + CHECK_ACTION(VEHICLE_TURRETLEFT); + CHECK_ACTION(VEHICLE_TURRETRIGHT); + CHECK_ACTION(VEHICLE_TURRETUP); + CHECK_ACTION(VEHICLE_TURRETDOWN); + CHECK_ACTION(VEHICLE_ENTER_EXIT); + CHECK_ACTION(CAMERA_CHANGE_VIEW_ALL_SITUATIONS); +#ifndef BIND_VEHICLE_FIREWEAPON + CHECK_ACTION(PED_FIREWEAPON); +#endif + CHECK_ACTION(GO_LEFT); + CHECK_ACTION(GO_RIGHT); + CHECK_ACTION(NETWORK_TALK); + CHECK_ACTION(SWITCH_DEBUG_CAM_ON); + CHECK_ACTION(TOGGLE_DPAD); + CHECK_ACTION(TAKE_SCREEN_SHOT); + CHECK_ACTION(SHOW_MOUSE_POINTER_TOGGLE); + } + return false; +} + +#undef CHECK_ACTION +#endif + void CControllerConfigManager::DeleteMatchingActionInitiators(e_ControllerAction action, int32 key, eControllerType type) { if (!GetIsKeyBlank(key, type)) diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index 604fb5cc..d61e23e6 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -195,6 +195,10 @@ public: void DeleteMatching1rstPersonControls (e_ControllerAction action, int32 key, eControllerType type); void DeleteMatchingActionInitiators (e_ControllerAction action, int32 key, eControllerType type); +#ifdef RADIO_SCROLL_TO_PREV_STATION + bool IsAnyVehicleActionAssignedToMouseKey(int32 key); +#endif + bool GetIsKeyBlank(int32 key, eControllerType type); e_ControllerActionType GetActionType(e_ControllerAction action); diff --git a/src/core/config.h b/src/core/config.h index 329d70b9..f64a7602 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -306,8 +306,8 @@ enum Config { // Hud, frontend and radar #define PC_MENU - #define FIX_RADAR // use radar size from early version before R* broke it +#define RADIO_OFF_TEXT // Won't work without FIX_BUGS #ifndef PC_MENU # define PS2_MENU @@ -376,6 +376,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #define FREE_CAM // Rotating cam // Audio +#define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS #define AUDIO_CACHE // cache sound lengths to speed up the cold boot //#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) //#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder @@ -462,6 +463,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef BUTTON_ICONS #undef FIX_RADAR +#undef RADIO_OFF_TEXT #undef MAP_ENHANCEMENTS #undef MUCH_SHORTER_OUTRO_SCREEN @@ -490,4 +492,6 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef IMPROVED_CAMERA #undef FREE_CAM #undef BIG_IMG + +#undef RADIO_SCROLL_TO_PREV_STATION #endif -- cgit v1.2.3 From 1b293a3cfb914748a217f36a98ac650d28424697 Mon Sep 17 00:00:00 2001 From: withmorten Date: Tue, 2 Feb 2021 11:32:20 +0100 Subject: no advanced script log when log level is 0 --- src/core/config.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index f64a7602..e75cdfb0 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -347,6 +347,10 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #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 -- cgit v1.2.3 From 713562685a89578ae5e4008f0a283c39175429fc Mon Sep 17 00:00:00 2001 From: erorcun Date: Tue, 2 Feb 2021 16:39:08 +0300 Subject: OAL Loops, fixes --- src/core/Frontend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 16a70697..4eae64b7 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5591,7 +5591,7 @@ CMenuManager::DrawQuitGameScreen(void) if (splash == nil) splash = LoadSplash("OUTRO"); - m_aFrontEndSprites[MENUSPRITE_VCLOGO].Draw(CRect(MENU_X(28.0f), MENU_Y(8.0f), MENU_X(157.0f), MENU_Y(138.0f)), CRGBA(255, 255, 255, 255 - alpha)); + m_aFrontEndSprites[MENUSPRITE_VCLOGO].Draw(CRect(SCREEN_STRETCH_X(28.0f), MENU_Y(8.0f), SCREEN_STRETCH_X(27.0f) + MENU_X(130.f), MENU_Y(138.0f)), CRGBA(255, 255, 255, 255 - alpha)); // Or we can see menu background from sides #ifdef ASPECT_RATIO_SCALE -- cgit v1.2.3 From 8553120fdbfd74eb2d1609326acbdd8aaa382bea Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 4 Feb 2021 19:47:47 +0100 Subject: add missing ASCII_STRCMP stuff --- src/core/config.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index e75cdfb0..cc82f8d6 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -251,6 +251,12 @@ enum Config { #define FIX_BUGS_64 // Must have fixes to be able to run 64 bit build #endif +#define ASCII_STRCMP // use faster ascii str comparisons + +#if !defined _WIN32 || defined __MWERKS__ || defined __MINGW32__ || defined VANILLA_DEFINES +#undef ASCII_STRCMP +#endif + // Just debug menu entries #ifdef DEBUGMENU #define RELOADABLES // some debug menu options to reload TXD files -- cgit v1.2.3 From a78212ea800fe1919d5380beb25514e3887bcdea Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 4 Feb 2021 23:43:04 +0100 Subject: fix MASTER crashes --- src/core/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/common.h b/src/core/common.h index 75ba8863..d39531cc 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -355,7 +355,7 @@ __inline__ void TRACE(char *f, ...) { } // this is re3 only, and so the function #ifndef MASTER #define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) ) #else -#define assert(_Expression) +#define assert(_Expression) (_Expression) #endif #define ASSERT assert -- cgit v1.2.3 From 9125e604b9225a9cb5efd4a615f10b3c73c1d104 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 5 Feb 2021 10:58:01 +0100 Subject: fix generic.txd crash --- src/core/Game.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index ed9d67f4..43bd3d11 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -381,6 +381,11 @@ bool CGame::Initialise(const char* datFile) CTxdStore::Create(gameTxdSlot); CTxdStore::AddRef(gameTxdSlot); +#ifdef EXTENDED_PIPELINES + // for generic fallback + CustomPipes::SetTxdFindCallback(); +#endif + LoadingScreen("Loading the Game", "Loading particles", nil); int particleTxdSlot = CTxdStore::AddTxdSlot("particle"); CTxdStore::LoadTxd(particleTxdSlot, "MODELS/PARTICLE.TXD"); @@ -440,10 +445,7 @@ bool CGame::Initialise(const char* datFile) CFileLoader::LoadLevel("DATA\\DEFAULT.DAT"); CFileLoader::LoadLevel(datFile); -#ifdef EXTENDED_PIPELINES - // for generic fallback - CustomPipes::SetTxdFindCallback(); -#endif + LoadingScreen("Loading the Game", "Add Particles", nil); CWorld::AddParticles(); CVehicleModelInfo::LoadVehicleColours(); -- cgit v1.2.3 From 675aef29cf85f956052a150792d4d56f91ff692c Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 5 Feb 2021 17:51:57 +0300 Subject: Detect joystick menu for XInput --- src/core/ControllerConfig.cpp | 5 +++++ src/core/Frontend.h | 2 +- src/core/MenuScreensCustom.cpp | 51 +++++++++++++++++++++++++++++++++++++++--- src/core/Pad.cpp | 6 +++++ src/core/Pad.h | 2 ++ src/core/config.h | 4 ++-- src/core/re3.cpp | 42 +++++++++++++++++++++++++++++++--- 7 files changed, 103 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 7f634619..fda435ae 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -326,6 +326,11 @@ uint32 CControllerConfigManager::ms_padButtonsInited = 0; void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) { +#ifdef XINPUT + // No manual bindings for you, honey. + return; +#endif + m_bFirstCapture = true; uint32 btn = buttons; diff --git a/src/core/Frontend.h b/src/core/Frontend.h index c1c3983e..060b70da 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -206,7 +206,7 @@ enum eMenuScreen #ifdef GRAPHICS_MENU_OPTIONS MENUPAGE_GRAPHICS_SETTINGS, #endif -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU MENUPAGE_DETECT_JOYSTICK, #endif diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 770e8ec1..c73d64b4 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -1,4 +1,13 @@ #include "common.h" +#if defined DETECT_JOYSTICK_MENU && defined XINPUT +#include +#include +#if !defined(PSAPI_VERSION) || (PSAPI_VERSION > 1) +#pragma comment( lib, "Xinput9_1_0.lib" ) +#else +#pragma comment( lib, "Xinput.lib" ) +#endif +#endif #include "platform.h" #include "crossplatform.h" #include "Renderer.h" @@ -277,11 +286,13 @@ void ScreenModeAfterChange(int8 before, int8 after) #endif -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU wchar selectedJoystickUnicode[128]; int cachedButtonNum = -1; wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { + +#if defined RW_GL3 && !defined LIBRW_SDL2 int numButtons; int found = -1; const char *joyname; @@ -312,6 +323,40 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { } } if (PSGLOBAL(joy1id) == -1) +#elif defined XINPUT + int found = -1; + XINPUT_STATE xstate; + memset(&xstate, 0, sizeof(XINPUT_STATE)); + if (userHovering) { + for (int i = 0; i <= 3; i++) { + if (XInputGetState(i, &xstate) == ERROR_SUCCESS) { + if (xstate.Gamepad.bLeftTrigger || xstate.Gamepad.bRightTrigger) { + found = i; + break; + } + for (int j = XINPUT_GAMEPAD_DPAD_UP; j != XINPUT_GAMEPAD_Y << 1; j = (j << 1)) { + if (xstate.Gamepad.wButtons & j) { + found = i; + break; + } + } + if (found != -1) + break; + } + } + if (found != -1 && CPad::XInputJoy1 != found) { + if (CPad::XInputJoy1 != -1 && CPad::XInputJoy1 != found) + CPad::XInputJoy2 = CPad::XInputJoy1; + else + CPad::XInputJoy2 = -1; + + CPad::XInputJoy1 = found; + cachedButtonNum = 0; // fake too, because xinput bypass CControllerConfig + } + } + sprintf(gSelectedJoystickName, "%d", CPad::XInputJoy1); // fake, on xinput we only store gamepad ids(thanks MS) so this is a temp variable to be used below + if (CPad::XInputJoy1 == -1) +#endif AsciiToUnicode("Not found", selectedJoystickUnicode); else AsciiToUnicode(gSelectedJoystickName, selectedJoystickUnicode); @@ -567,7 +612,7 @@ CMenuScreenCustom aScreens[] = { #else MENUACTION_KEYBOARDCTRLS,"FEC_RED", {nil, SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS}, 320, 150, MENUALIGN_CENTER, #endif -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU MENUACTION_CHANGEMENU, "FEC_JOD", {nil, SAVESLOT_NONE, MENUPAGE_DETECT_JOYSTICK}, 0, 0, MENUALIGN_CENTER, #endif MENUACTION_CHANGEMENU, "FEC_MOU", {nil, SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS}, 0, 0, MENUALIGN_CENTER, @@ -715,7 +760,7 @@ CMenuScreenCustom aScreens[] = { }, #endif -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU // MENUPAGE_DETECT_JOYSTICK { "FEC_JOD", MENUPAGE_CONTROLLER_PC, new CCustomScreenLayout({0, 0, 0, false, false, 30}), DetectJoystickGoBack, MENUACTION_LABEL, "FEC_JPR", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, 0, 0, 0, diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 5c79c0d3..e75510e5 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -1585,8 +1585,14 @@ void CPad::AddToPCCheatString(char c) } #ifdef XINPUT +int CPad::XInputJoy1 = 0; +int CPad::XInputJoy2 = 1; void CPad::AffectFromXinput(uint32 pad) { + pad = pad == 0 ? XInputJoy1 : XInputJoy2; + if (pad == -1) // LoadINIControllerSettings can set it to -1 + return; + XINPUT_STATE xstate; memset(&xstate, 0, sizeof(XINPUT_STATE)); if (XInputGetState(pad, &xstate) == ERROR_SUCCESS) diff --git a/src/core/Pad.h b/src/core/Pad.h index 9f9f81b6..f141ed6c 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -276,6 +276,8 @@ public: void SetDrunkInputDelay(int32 delay) { DrunkDrivingBufferUsed = delay; } #ifdef XINPUT + static int XInputJoy1; + static int XInputJoy2; void AffectFromXinput(uint32 pad); #endif diff --git a/src/core/config.h b/src/core/config.h index cc82f8d6..abb819f9 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -298,8 +298,8 @@ enum Config { #if !defined(RW_GL3) && defined(_WIN32) #define XINPUT #endif -#if !defined(_WIN32) && !defined(__SWITCH__) -#define DONT_TRUST_RECOGNIZED_JOYSTICKS // Then we'll only rely on GLFW gamepad DB, and expect user to enter Controller->Detect joysticks if his joystick isn't on that list. +#if defined XINPUT || (defined RW_GL3 && !defined LIBRW_SDL2 && !defined __SWITCH__) +#define DETECT_JOYSTICK_MENU // Then we'll expect user to enter Controller->Detect joysticks if his joystick isn't detected at the start. #endif #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m #define KANGAROO_CHEAT diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 4b828171..3388b56a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,6 +1,14 @@ #include #define WITHWINDOWS #include "common.h" +#if defined DETECT_JOYSTICK_MENU && defined XINPUT +#include +#if !defined(PSAPI_VERSION) || (PSAPI_VERSION > 1) +#pragma comment( lib, "Xinput9_1_0.lib" ) +#else +#pragma comment( lib, "Xinput.lib" ) +#endif +#endif #include "Renderer.h" #include "Occlusion.h" #include "Credits.h" @@ -37,7 +45,7 @@ #include "MBlur.h" #include "ControllerConfig.h" -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU #include "crossplatform.h" #endif @@ -249,8 +257,32 @@ const char *iniKeyboardButtons[] = {"ESC","F1","F2","F3","F4","F5","F6","F7","F8 void LoadINIControllerSettings() { -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU +#ifdef XINPUT + int storedJoy1 = -1; + if (ReadIniIfExists("Controller", "JoystickName", &storedJoy1)) { + CPad::XInputJoy1 = -1; + CPad::XInputJoy2 = -1; + XINPUT_STATE xstate; + memset(&xstate, 0, sizeof(XINPUT_STATE)); + + // Firstly confirm & set joy 1 + if (XInputGetState(storedJoy1, &xstate) == ERROR_SUCCESS) { + CPad::XInputJoy1 = storedJoy1; + } + + for (int i = 0; i <= 3; i++) { + if (XInputGetState(i, &xstate) == ERROR_SUCCESS) { + if (CPad::XInputJoy1 == -1) + CPad::XInputJoy1 = i; + else if (CPad::XInputJoy2 == -1 && i != CPad::XInputJoy1) + CPad::XInputJoy2 = i; + } + } + } +#else ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif #endif // force to default GTA behaviour (never overwrite bindings on joy change/initialization) if user init'ed/set bindings before we introduced that if (!ReadIniIfExists("Controller", "PadButtonsInited", &ControlsManager.ms_padButtonsInited)) { @@ -348,8 +380,12 @@ void SaveINIControllerSettings() StoreIni("Bindings", iniControllerActions[i], value, 128); } -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU +#ifdef XINPUT + StoreIni("Controller", "JoystickName", CPad::XInputJoy1); +#else StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif #endif StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited); cfg.write_file("reVC.ini"); -- cgit v1.2.3 From 26bbbe003761490d16a75e4f4e06199e8bc47b70 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Feb 2021 20:02:29 +0100 Subject: fix clouds --- src/core/FileLoader.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index 4d1cd921..bf017256 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -317,6 +317,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) buf += 4; if(model.numLines > 0){ //model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine)); + REGISTER_MEMPTR(&model.lines); for(i = 0; i < model.numLines; i++){ //model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12)); buf += 24; -- cgit v1.2.3 From 12330e38cb3c2a023bc1327cb89afd19efed0a43 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 10 Feb 2021 08:57:51 +0200 Subject: Controller menu --- src/core/ControllerConfig.cpp | 50 ++- src/core/Frontend.cpp | 819 ++++++++++++++++++++++++++++++++++++++++- src/core/Frontend.h | 29 +- src/core/MenuScreensCustom.cpp | 41 ++- src/core/config.h | 3 + 5 files changed, 911 insertions(+), 31 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 7f634619..727ad06b 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2416,7 +2416,7 @@ int32 CControllerConfigManager::GetNumOfSettingsForAction(e_ControllerAction act #define VFB(b) #endif -#define CONTROLLER_BUTTONS(T, O, X, Q, L1, L2, L3, R1, R2, R3, SELECT, RSL, RSR) \ +#define CONTROLLER_BUTTONS(T, O, X, Q, L1, L2, L3, R1, R2, R3, SELECT, RSU, RSD, RSL, RSR) \ {{ \ O, /* PED_FIREWEAPON */ \ R2, /* PED_CYCLE_WEAPON_RIGHT */ \ @@ -2576,8 +2576,8 @@ int32 CControllerConfigManager::GetNumOfSettingsForAction(e_ControllerAction act L3, /* PED_DUCK */ \ L1, /* PED_ANSWER_PHONE */ \ VFB(R1) /* VEHICLE_FIREWEAPON */ \ - nil, /* VEHICLE_ACCELERATE */ \ - nil, /* VEHICLE_BRAKE */ \ + RSU, /* VEHICLE_ACCELERATE */ \ + RSD, /* VEHICLE_BRAKE */ \ O, /* VEHICLE_CHANGE_RADIO_STATION */ \ L3, /* VEHICLE_HORN */ \ Q, /* TOGGLE_SUBMISSIONS */ \ @@ -2618,10 +2618,10 @@ int32 CControllerConfigManager::GetNumOfSettingsForAction(e_ControllerAction act #define RIGHT "RIGHT" #endif -const char *XboxButtons_noIcons[][MAX_CONTROLLERACTIONS] = CONTROLLER_BUTTONS("Y", "B", "A", "X", "LB", "LT", "LS", "RB", "RT", "RS", "BACK", "right stick left", "right stick right"); +const char *XboxButtons_noIcons[][MAX_CONTROLLERACTIONS] = CONTROLLER_BUTTONS("Y", "B", "A", "X", "LB", "LT", "LS", "RB", "RT", "RS", "BACK", "right stick up", "right stick down", "right stick left", "right stick right"); #ifdef BUTTON_ICONS -const char *XboxButtons[][MAX_CONTROLLERACTIONS] = CONTROLLER_BUTTONS("~T~", "~O~", "~X~", "~Q~", "~K~", "~M~", "~A~", "~J~", "~V~", "~C~", "BACK", "~(~", "~)~"); +const char *XboxButtons[][MAX_CONTROLLERACTIONS] = CONTROLLER_BUTTONS("~T~", "~O~", "~X~", "~Q~", "~K~", "~M~", "~A~", "~J~", "~V~", "~C~", "BACK", "~H~", "~L~", "~(~", "~)~"); #endif @@ -2630,11 +2630,6 @@ const char *XboxButtons[][MAX_CONTROLLERACTIONS] = CONTROLLER_BUTTONS("~T~", "~O #define PS2_CIRCLE "|" #define PS2_CROSS "/" #define PS2_SQUARE "^" -#elif defined(BUTTON_ICONS) -#define PS2_TRIANGLE "~T~" -#define PS2_CIRCLE "~O~" -#define PS2_CROSS "~X~" -#define PS2_SQUARE "~Q~" #else #define PS2_TRIANGLE "TRIANGLE" #define PS2_CIRCLE "CIRCLE" @@ -2643,11 +2638,11 @@ const char *XboxButtons[][MAX_CONTROLLERACTIONS] = CONTROLLER_BUTTONS("~T~", "~O #endif const char *PlayStationButtons_noIcons[][MAX_CONTROLLERACTIONS] = - CONTROLLER_BUTTONS(PS2_TRIANGLE, PS2_CIRCLE, PS2_CROSS, PS2_SQUARE, "L1", "L2", "L3", "R1", "R2", "R3", "SELECT", "right stick left", "right stick right"); + CONTROLLER_BUTTONS(PS2_TRIANGLE, PS2_CIRCLE, PS2_CROSS, PS2_SQUARE, "L1", "L2", "L3", "R1", "R2", "R3", "SELECT", "right stick up", "right stick down", "right stick left", "right stick right"); #ifdef BUTTON_ICONS const char *PlayStationButtons[][MAX_CONTROLLERACTIONS] = - CONTROLLER_BUTTONS(PS2_TRIANGLE, PS2_CIRCLE, PS2_CROSS, PS2_SQUARE, "~K~", "~M~", "~A~", "~J~", "~V~", "~C~", "SELECT", "~(~", "~)~"); + CONTROLLER_BUTTONS("~T~", "~O~", "~X~", "~Q~", "~K~", "~M~", "~A~", "~J~", "~V~", "~C~", "SELECT", "~H~", "~L~", "~(~", "~)~"); #endif #undef PS2_TRIANGLE @@ -2669,11 +2664,36 @@ void CControllerConfigManager::GetWideStringOfCommandKeys(uint16 action, wchar * if (CPad::GetPad(0)->IsAffectedByController) { wchar wstr[16]; - // TODO: INI and/or menu setting for Xbox/PS switch + const char* (*Buttons)[MAX_CONTROLLERACTIONS]; + #ifdef BUTTON_ICONS - const char *(*Buttons)[MAX_CONTROLLERACTIONS] = CFont::ButtonsSlot != -1 ? XboxButtons : XboxButtons_noIcons; + #ifdef GAMEPAD_MENU + switch (FrontEndMenuManager.m_PrefsControllerType) + { + case CMenuManager::CONTROLLER_DUALSHOCK2: + case CMenuManager::CONTROLLER_DUALSHOCK3: + case CMenuManager::CONTROLLER_DUALSHOCK4: + Buttons = CFont::ButtonsSlot != -1 ? PlayStationButtons : PlayStationButtons_noIcons; + break; + default: + #endif + Buttons = CFont::ButtonsSlot != -1 ? XboxButtons : XboxButtons_noIcons; + #ifdef GAMEPAD_MENU + break; + } + #endif #else - const char *(*Buttons)[MAX_CONTROLLERACTIONS] = XboxButtons_noIcons; + switch (FrontEndMenuManager.m_PrefsControllerType) + { + case CMenuManager::CONTROLLER_DUALSHOCK2: + case CMenuManager::CONTROLLER_DUALSHOCK3: + case CMenuManager::CONTROLLER_DUALSHOCK4: + Buttons = PlayStationButtons_noIcons; + break; + default: + Buttons = XboxButtons_noIcons; + break; + } #endif assert(Buttons[CPad::GetPad(0)->Mode][action] != nil); // we cannot use these diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 4eae64b7..141f46f8 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -125,6 +125,10 @@ bool CMenuManager::m_PrefsMarketing = false; bool CMenuManager::m_PrefsDisableTutorials = false; #endif // !MASTER +#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +uint32 TimeToStopPadShaking; +#endif + const char* FrontendFilenames[][2] = { {"background", ""}, {"vc_logo", "vc_logom"}, @@ -151,7 +155,14 @@ const char* FrontendFilenames[][2] = { {"downOff", "buttonA"}, {"downOn", "buttonA"}, {"upOff", "buttonA"}, - {"upOn", "buttonA"} + {"upOn", "buttonA"}, +#ifdef GAMEPAD_MENU + {"fe_controller", "" }, + {"fe_arrows1", "" }, + {"fe_arrows2", "" }, + {"fe_arrows3", "" }, + {"fe_arrows4", "" }, +#endif }; #define MENU_X_RIGHT_ALIGNED(x) SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - (x)) @@ -526,6 +537,10 @@ CMenuManager::CMenuManager() #ifdef NO_ISLAND_LOADING m_PrefsIslandLoading = ISLAND_LOADING_LOW; #endif + +#ifdef GAMEPAD_MENU + m_PrefsControllerType = CONTROLLER_XBOXONE; +#endif } void @@ -1074,7 +1089,7 @@ CMenuManager::DrawStandardMenus(bool activeScreen) } switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { -#ifdef LEGACY_MENU_OPTIONS +#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) case MENUACTION_CTRLVIBRATION: if (m_PrefsUseVibration) rightText = TheText.Get("FEM_ON"); @@ -1539,6 +1554,11 @@ CMenuManager::DrawStandardMenus(bool activeScreen) #endif switch (m_nCurrScreen) { +#ifdef GAMEPAD_MENU + case MENUPAGE_CONTROLLER_SETTINGS: + PrintController(); + break; +#endif case MENUPAGE_STATS: case MENUPAGE_CONTROLLER_PC: case MENUPAGE_SOUND_SETTINGS: @@ -2280,6 +2300,9 @@ CMenuManager::DrawBackground(bool transitionCall) break; case MENUPAGE_SKIN_SELECT: case MENUPAGE_KEYBOARD_CONTROLS: +#ifdef GAMEPAD_MENU + case MENUPAGE_CONTROLLER_SETTINGS: +#endif menuBg.topLeft_x = 14.0f; menuBg.topLeft_y = 39.0f; menuBg.topRight_x = 636.0f; @@ -2948,12 +2971,19 @@ CMenuManager::LoadAllTextures() CTxdStore::AddRef(frontendTxdSlot2); CTxdStore::SetCurrentTxd(frontendTxdSlot2); +#ifdef GAMEPAD_MENU + for (int i = 3; i < MENUSPRITE_CONTROLLER; i++) { +#else for (int i = 3; i < NUM_MENU_SPRITES; i++) { +#endif m_aFrontEndSprites[i].SetTexture(FrontendFilenames[i][0], FrontendFilenames[i][1]); m_aFrontEndSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); } CTxdStore::PopCurrentTxd(); +#ifdef GAMEPAD_MENU + LoadController(m_PrefsControllerType); +#endif CStreaming::IHaveUsedStreamingMemory(); } @@ -4896,6 +4926,16 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u if (changeAmount != 0) { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { +#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) + case MENUACTION_CTRLCONFIG: + CPad::GetPad(0)->Mode += changeAmount; + if (CPad::GetPad(0)->Mode > 3) + CPad::GetPad(0)->Mode = 0; + else if (CPad::GetPad(0)->Mode < 0) + CPad::GetPad(0)->Mode = 3; + SaveSettings(); + break; +#endif case MENUACTION_RADIO: ChangeRadioStation(changeAmount); break; @@ -5037,14 +5077,14 @@ void CMenuManager::ProcessOnOffMenuOptions() { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { -#ifdef LEGACY_MENU_OPTIONS +#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) case MENUACTION_CTRLVIBRATION: m_PrefsUseVibration = !m_PrefsUseVibration; - break; - case MENUACTION_CTRLCONFIG: - CPad::GetPad(0)->Mode++; - if (CPad::GetPad(0)->Mode > 3) - CPad::GetPad(0)->Mode = 0; + if (m_PrefsUseVibration) { + CPad::GetPad(0)->StartShake(350, 150); + TimeToStopPadShaking = CTimer::GetTimeInMillisecondsPauseMode() + 500; + } + SaveSettings(); break; #endif case MENUACTION_INVERTPADY: @@ -5510,6 +5550,14 @@ CMenuManager::SwitchMenuOnAndOff() m_bStartUpFrontEndRequested = false; m_bShutDownFrontEndRequested = false; + +#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) + // Reset pad shaking. + if (TimeToStopPadShaking && TimeToStopPadShaking < CTimer::GetTimeInMillisecondsPauseMode()) { + CPad::StopPadsShaking(); + TimeToStopPadShaking = 0; + } +#endif } void @@ -5534,6 +5582,13 @@ CMenuManager::UnloadTextures() m_aFrontEndSprites[i].Delete(); CTxdStore::RemoveTxd(frontend2); + +#ifdef GAMEPAD_MENU + // Unload controller txd + int frontend_controller = CTxdStore::FindTxdSlot("frontend_controller"); + if (frontend_controller != -1) + CTxdStore::RemoveTxd(frontend_controller); +#endif } m_bSpritesLoaded = false; @@ -5781,5 +5836,753 @@ uint8 CMenuManager::GetNumberOfMenuOptions() } #endif +#ifdef GAMEPAD_MENU +const char* controllerTypesPaths[] = { + "MODELS/FRONTEND_DS2.TXD", + "MODELS/FRONTEND_DS3.TXD", + "MODELS/FRONTEND_DS4.TXD", + "MODELS/FRONTEND_X360.TXD", + "MODELS/FRONTEND_XONE.TXD", +}; + +void +CMenuManager::PrintController(void) +{ + // Don't print anything if controller texture is missing + if (!m_aFrontEndSprites[MENUSPRITE_CONTROLLER].m_pTexture) return; + + const float scale = 0.9f; + const float CONTROLLER_SIZE_X = 235.2f; + const float CONTROLLER_SIZE_Y = 175.2f; + const float CONTROLLER_POS_X = (DEFAULT_SCREEN_WIDTH - CONTROLLER_SIZE_X) / 2.0f; + const float CONTROLLER_POS_Y = 220.0f; + + float centerX = CONTROLLER_POS_X + CONTROLLER_SIZE_X / 2; + float centerY = CONTROLLER_POS_Y + CONTROLLER_SIZE_Y / 2; + +#define X(f) ((f)*scale + centerX) +#define Y(f) ((f)*scale + centerY) + + m_aFrontEndSprites[MENUSPRITE_CONTROLLER].Draw(MENU_X_LEFT_ALIGNED(X(-CONTROLLER_SIZE_X / 2)), MENU_Y(Y(-CONTROLLER_SIZE_Y / 2)), MENU_X(CONTROLLER_SIZE_X * scale), MENU_Y(CONTROLLER_SIZE_Y * scale), CRGBA(255, 255, 255, FadeIn(255))); + if (m_DisplayControllerOnFoot) { + if ((int)CTimer::GetTimeInMillisecondsPauseMode() & 0x400) + m_aFrontEndSprites[MENUSPRITE_ARROWS1].Draw(MENU_X_LEFT_ALIGNED(X(-CONTROLLER_SIZE_X / 2)), MENU_Y(Y(-CONTROLLER_SIZE_Y / 2)), MENU_X(CONTROLLER_SIZE_X * scale), MENU_Y(CONTROLLER_SIZE_Y * scale), CRGBA(255, 255, 255, FadeIn(255))); + else + m_aFrontEndSprites[MENUSPRITE_ARROWS3].Draw(MENU_X_LEFT_ALIGNED(X(-CONTROLLER_SIZE_X / 2)), MENU_Y(Y(-CONTROLLER_SIZE_Y / 2)), MENU_X(CONTROLLER_SIZE_X * scale), MENU_Y(CONTROLLER_SIZE_Y * scale), CRGBA(255, 255, 255, FadeIn(255))); + } + else { + if ((int)CTimer::GetTimeInMillisecondsPauseMode() & 0x400) + m_aFrontEndSprites[MENUSPRITE_ARROWS2].Draw(MENU_X_LEFT_ALIGNED(X(-CONTROLLER_SIZE_X / 2)), MENU_Y(Y(-CONTROLLER_SIZE_Y / 2)), MENU_X(CONTROLLER_SIZE_X * scale), MENU_Y(CONTROLLER_SIZE_Y * scale), CRGBA(255, 255, 255, FadeIn(255))); + else + m_aFrontEndSprites[MENUSPRITE_ARROWS4].Draw(MENU_X_LEFT_ALIGNED(X(-CONTROLLER_SIZE_X / 2)), MENU_Y(Y(-CONTROLLER_SIZE_Y / 2)), MENU_X(CONTROLLER_SIZE_X * scale), MENU_Y(CONTROLLER_SIZE_Y * scale), CRGBA(255, 255, 255, FadeIn(255))); + } + + CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); + + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.9f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.9f)); // X + + CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetDropShadowPosition(0); + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetWrapx(SCREEN_WIDTH); + + float TEXT_L2_X = 85.0f + CONTROLLER_POS_X - centerX, TEXT_L2_Y = -14.0f + CONTROLLER_POS_Y - centerY; + float TEXT_L1_X = -4.0f + CONTROLLER_POS_X - centerX, TEXT_L1_Y = 27.0f + CONTROLLER_POS_Y - centerY, TEXT_L1_Y_VEH = 3.0f + TEXT_L1_Y; + float TEXT_DPAD_X = -4.0f + CONTROLLER_POS_X - centerX, TEXT_DPAD_Y = 67.0f + CONTROLLER_POS_Y - centerY; + float TEXT_LSTICK_X = -4.0f + CONTROLLER_POS_X - centerX, TEXT_LSTICK_Y = 97.0f + CONTROLLER_POS_Y - centerY; + float TEXT_SELECT_X = 170.0f + CONTROLLER_POS_X - centerX, TEXT_SELECT_Y = 141.0f + CONTROLLER_POS_Y - centerY; + float TEXT_START_X = 130.0f + CONTROLLER_POS_X - centerX, TEXT_START_Y = 128.0f + CONTROLLER_POS_Y - centerY; + float TEXT_R2_X = 164.0f + CONTROLLER_POS_X - centerX, TEXT_R2_Y = -14.0f + CONTROLLER_POS_Y - centerY; + float TEXT_R1_X = 242.0f + CONTROLLER_POS_X - centerX, TEXT_R1_Y = 27.0f + CONTROLLER_POS_Y - centerY; + + float TEXT_SQUARE_X = 147.0f + CONTROLLER_POS_X - centerX, TEXT_SQUARE_Y = 30.0f + CONTROLLER_POS_Y - centerY; + float TEXT_TRIANGLE_X = 242.0f + CONTROLLER_POS_X - centerX, TEXT_TRIANGLE_Y = 55.0f + CONTROLLER_POS_Y - centerY; + float TEXT_CIRCLE_X = 242.0f + CONTROLLER_POS_X - centerX, TEXT_CIRCLE_Y = 67.0f + CONTROLLER_POS_Y - centerY; + float TEXT_CROSS_X = 242.0f + CONTROLLER_POS_X - centerX, TEXT_CROSS_Y = 80.0f + CONTROLLER_POS_Y - centerY; + float TEXT_RSTICK_X = 242.0f + CONTROLLER_POS_X - centerX, TEXT_RSTICK_Y = 97.0f + CONTROLLER_POS_Y - centerY; + float TEXT_R3_X = 242.0f + CONTROLLER_POS_X - centerX, TEXT_R3_Y = 110.0f + CONTROLLER_POS_Y - centerY; + float TEXT_L3_X = 94.0f + CONTROLLER_POS_X - centerX, TEXT_L3_Y = 162.0f + CONTROLLER_POS_Y - centerY; + float TEXT_L2R2_X = 120.0f + CONTROLLER_POS_X - centerX, TEXT_L2R2_Y = -4.0f + CONTROLLER_POS_Y - centerY; + + switch (m_PrefsControllerType) + { + case CONTROLLER_DUALSHOCK4: + TEXT_L1_Y += 7.0f; + TEXT_L1_Y_VEH = TEXT_L1_Y; + TEXT_R1_Y += 7.0f; + TEXT_TRIANGLE_Y -= 1.0f; + TEXT_CIRCLE_Y -= 1.0f; + TEXT_CROSS_Y -= 1.0f; + TEXT_RSTICK_Y -= 4.0f; + TEXT_R3_Y -= 4.0f; + TEXT_DPAD_Y -= 2.0f; + TEXT_LSTICK_Y -= 6.0f; + TEXT_L3_X -= 2.0f; + break; + case CONTROLLER_XBOXONE: + TEXT_L2_X -= 2.0f; + TEXT_R2_X += 2.0f; + TEXT_L1_Y += 15.0f; + TEXT_L1_Y_VEH = TEXT_L1_Y; + TEXT_R1_Y += 15.0f; + TEXT_TRIANGLE_Y += 4.0f; + TEXT_CIRCLE_Y += 4.0f; + TEXT_CROSS_Y += 4.0f; + TEXT_RSTICK_Y += 1.0f; + TEXT_R3_Y += 1.0f; + TEXT_DPAD_Y += 29.0f; + TEXT_LSTICK_Y -= 20.0f; + TEXT_L3_X -= 36.0f; + TEXT_L2R2_Y += 5.0f; + TEXT_SELECT_X += 4.0f; + break; + case CONTROLLER_XBOX360: + TEXT_L2_X += 8.0f; + TEXT_R2_X -= 8.0f; + TEXT_L1_Y += 15.0f; + TEXT_L1_Y_VEH = TEXT_L1_Y; + TEXT_R1_Y += 15.0f; + TEXT_TRIANGLE_Y += 4.0f; + TEXT_CIRCLE_Y += 4.0f; + TEXT_CROSS_Y += 4.0f; + TEXT_RSTICK_Y += 4.0f; + TEXT_R3_Y += 4.0f; + TEXT_DPAD_Y += 30.0f; + TEXT_LSTICK_Y -= 19.0f; + TEXT_L3_X -= 36.0f; + TEXT_L2R2_Y += 5.0f; + TEXT_SELECT_X += 3.0f; + break; + }; + + if (m_DisplayControllerOnFoot) { + switch (CPad::GetPad(0)->Mode) { + case 0: + CFont::SetRightJustifyOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_L2_X -= 45.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)) - SCREEN_SCALE_X(85)); + break; + default: + CFont::SetRightJustifyWrap(0); + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_CWL")); + CFont::SetRightJustifyWrap(0); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y)), TheText.Get("FEC_LOF")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_MOV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_MOV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_CR3")); + CFont::SetRightJustifyOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_GERMAN: + TEXT_SELECT_X += 20.0f; + break; + case LANGUAGE_SPANISH: + TEXT_SELECT_X += 15.0f; + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_CAM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_R2_X += 30.0f; + CFont::SetJustifyOff(); + CFont::SetWrapx(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)) + SCREEN_SCALE_X(120)); + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_CWR")); + CFont::SetJustifyOn(); + CFont::SetWrapx(SCREEN_WIDTH); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_TAR")); + CFont::SetRightJustifyOn(); + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_JUM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_ENV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_ATT")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_RUN")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_FPC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_LB3")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y + 13.0f)), TheText.Get("FEC_R3")); + break; + case 1: + CFont::SetRightJustifyOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_L2_X -= 45.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)) - SCREEN_SCALE_X(85)); + break; + default: + CFont::SetRightJustifyWrap(0); + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_CWL")); + CFont::SetRightJustifyWrap(0); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y)), TheText.Get("FEC_LOF")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_CAM")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_MOV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_CR3")); + switch (m_PrefsLanguage) + { + case LANGUAGE_GERMAN: + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_NA")); + break; + default: + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X - 50)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_NA")); + break; + } + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_R2_X += 30.0f; + CFont::SetJustifyOff(); + CFont::SetWrapx(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)) + SCREEN_SCALE_X(120)); + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_CWR")); + CFont::SetJustifyOn(); + CFont::SetWrapx(SCREEN_WIDTH); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_TAR")); + CFont::SetRightJustifyOn(); + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_JUM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_ENV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_ATT")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_RUN")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_FPC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_LB3")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y + 13.0f)), TheText.Get("FEC_R3")); + break; + case 2: + CFont::SetRightJustifyOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_L2_X -= 45.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)) - SCREEN_SCALE_X(85)); + break; + default: + CFont::SetRightJustifyWrap(0); + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_CWL")); + CFont::SetRightJustifyWrap(0); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y)), TheText.Get("FEC_ENV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_MOV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_MOV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_CR3")); + CFont::SetRightJustifyOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_GERMAN: + TEXT_SELECT_X += 20.0f; + break; + case LANGUAGE_SPANISH: + TEXT_SELECT_X += 15.0f; + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_CAM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_R2_X += 30.0f; + CFont::SetJustifyOff(); + CFont::SetWrapx(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)) + SCREEN_SCALE_X(120)); + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_CWR")); + CFont::SetJustifyOn(); + CFont::SetWrapx(SCREEN_WIDTH); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_TAR")); + CFont::SetRightJustifyOn(); + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_JUM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_LOF")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_RUN")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_ATT")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_FPC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_LB3")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y + 13.0f)), TheText.Get("FEC_R3")); + break; + case 3: + CFont::SetRightJustifyOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_L2_X -= 45.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)) - SCREEN_SCALE_X(85)); + break; + default: + CFont::SetRightJustifyWrap(0); + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_CWL")); + CFont::SetRightJustifyWrap(0); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y)), TheText.Get("FEC_TAR")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_NA")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_MOV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_CR3")); + CFont::SetRightJustifyOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_GERMAN: + TEXT_SELECT_X += 20.0f; + break; + case LANGUAGE_SPANISH: + TEXT_SELECT_X += 15.0f; + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_CAM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + case LANGUAGE_SPANISH: + TEXT_R2_X += 30.0f; + CFont::SetJustifyOff(); + CFont::SetWrapx(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)) + SCREEN_SCALE_X(120)); + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_CWR")); + CFont::SetJustifyOn(); + CFont::SetWrapx(SCREEN_WIDTH); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_TAR")); + CFont::SetRightJustifyOn(); + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_JUM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_LOF")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_RUN")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_ATT")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_FPC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_LB3")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y + 13.0f)), TheText.Get("FEC_R3")); + break; + default: + return; + } + } + else { + CFont::SetCentreOn(); + switch (m_PrefsLanguage) + { + case LANGUAGE_ITALIAN: + if (m_PrefsControllerType != CONTROLLER_XBOX360) + break; + case LANGUAGE_FRENCH: + case LANGUAGE_GERMAN: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + break; + default: + break; + } + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(0.0f)), MENU_Y(Y(TEXT_L2R2_Y)), TheText.Get("FEC_LB")); + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.9f), MENU_Y(SMALLESTTEXT_Y_SCALE* scale * 0.9f)); + switch (CPad::GetPad(0)->Mode) { + case 0: + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_LL")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y_VEH)), TheText.Get("FEC_RSC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_VES")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_VES")); + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L3_X)), MENU_Y(Y(TEXT_L3_Y)), TheText.Get("FEC_HO3")); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SELECT_X -= 5.0f; + break; + case LANGUAGE_GERMAN: + TEXT_SELECT_X += 20.0f; + break; + case LANGUAGE_SPANISH: + TEXT_SELECT_X += 15.0f; + break; + default: + break; + } + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)) - SCREEN_SCALE_X(80)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_CAM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_LR")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_HAB")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_EXV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_CAW")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_ACC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_TUC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_SM3")); + CFont::SetRightJustifyOn(); + switch (m_PrefsControllerType) + { + case CONTROLLER_XBOXONE: + case CONTROLLER_XBOX360: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SQUARE_X += 3.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(90)); + break; + case LANGUAGE_GERMAN: + case LANGUAGE_SPANISH: + TEXT_SQUARE_X += 18.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(90)); + break; + default: + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + } + break; + default: + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SQUARE_X -= 15.0f; + TEXT_SQUARE_Y += 5.0f; + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + case LANGUAGE_GERMAN: + TEXT_SQUARE_X -= 15.0f; + TEXT_SQUARE_Y += 10.0f; + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE* scale * 0.65f)); + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + case LANGUAGE_SPANISH: + TEXT_SQUARE_X += 15.0f; + case LANGUAGE_ITALIAN: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + default: + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(100)); + break; + } + break; + } + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_BRA")); + break; + case 1: + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_LL")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y_VEH)), TheText.Get("FEC_HOR")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_CAM")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_VES")); + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L3_X)), MENU_Y(Y(TEXT_L3_Y)), TheText.Get("FEC_NA")); + switch (m_PrefsLanguage) + { + case LANGUAGE_GERMAN: + TEXT_SELECT_X += 20.0f; + break; + case LANGUAGE_SPANISH: + TEXT_SELECT_X += 12.0f; + break; + default: + break; + } + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)) - SCREEN_SCALE_X(80)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_RSC")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_LR")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_HAB")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_EXV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_CAW")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_ACC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_TUC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_SM3")); + CFont::SetRightJustifyOn(); + switch (m_PrefsControllerType) + { + case CONTROLLER_XBOXONE: + case CONTROLLER_XBOX360: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SQUARE_X += 3.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(90)); + break; + case LANGUAGE_GERMAN: + case LANGUAGE_SPANISH: + TEXT_SQUARE_X += 18.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(90)); + break; + default: + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + } + break; + default: + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SQUARE_X -= 15.0f; + TEXT_SQUARE_Y += 5.0f; + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + case LANGUAGE_GERMAN: + TEXT_SQUARE_X -= 15.0f; + TEXT_SQUARE_Y += 10.0f; + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + case LANGUAGE_SPANISH: + TEXT_SQUARE_X += 15.0f; + case LANGUAGE_ITALIAN: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + default: + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(100)); + break; + } + break; + } + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_BRA")); + break; + case 2: + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_LL")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y_VEH)), TheText.Get("FEC_EXV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_VES")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_VES")); + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L3_X)), MENU_Y(Y(TEXT_L3_Y)), TheText.Get("FEC_RS3")); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SELECT_X -= 5.0f; + break; + case LANGUAGE_GERMAN: + TEXT_SELECT_X += 20.0f; + break; + case LANGUAGE_SPANISH: + TEXT_SELECT_X += 15.0f; + break; + default: + break; + } + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)) - SCREEN_SCALE_X(80)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_CAM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_LR")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_HOR")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_HAB")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_CAW")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_ACC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_TUC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_SM3")); + CFont::SetRightJustifyOn(); + switch (m_PrefsControllerType) + { + case CONTROLLER_XBOXONE: + case CONTROLLER_XBOX360: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SQUARE_X += 3.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(90)); + break; + case LANGUAGE_GERMAN: + case LANGUAGE_SPANISH: + TEXT_SQUARE_X += 18.0f; + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(90)); + break; + default: + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + } + break; + default: + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SQUARE_X -= 15.0f; + TEXT_SQUARE_Y += 5.0f; + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + case LANGUAGE_GERMAN: + TEXT_SQUARE_X -= 15.0f; + TEXT_SQUARE_Y += 10.0f; + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(60)); + break; + case LANGUAGE_SPANISH: + TEXT_SQUARE_X += 15.0f; + case LANGUAGE_ITALIAN: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + default: + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)) - SCREEN_SCALE_X(100)); + break; + } + break; + } + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_BRA")); + break; + case 3: + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L2_X)), MENU_Y(Y(TEXT_L2_Y)), TheText.Get("FEC_LL")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L1_X)), MENU_Y(Y(TEXT_L1_Y_VEH)), TheText.Get("FEC_HAB")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_DPAD_X)), MENU_Y(Y(TEXT_DPAD_Y)), TheText.Get("FEC_TUC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_LSTICK_X)), MENU_Y(Y(TEXT_LSTICK_Y)), TheText.Get("FEC_VES")); + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_L3_X)), MENU_Y(Y(TEXT_L3_Y)), TheText.Get("FEC_HO3")); + switch (m_PrefsLanguage) + { + case LANGUAGE_FRENCH: + TEXT_SELECT_X -= 5.0f; + break; + case LANGUAGE_GERMAN: + TEXT_SELECT_X += 20.0f; + break; + case LANGUAGE_SPANISH: + TEXT_SELECT_X += 15.0f; + break; + default: + break; + } + CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)) - SCREEN_SCALE_X(80)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_SELECT_X)), MENU_Y(Y(TEXT_SELECT_Y)), TheText.Get("FEC_CAM")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_START_X)), MENU_Y(Y(TEXT_START_Y)), TheText.Get("FEC_PAU")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_LR")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_CAW")); + CFont::SetJustifyOn(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_EXV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_RSC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_NA")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_ACC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_BRA")); + CFont::SetRightJustifyOn(); + CFont::SetRightJustifyWrap(0); + switch (m_PrefsControllerType) + { + case CONTROLLER_XBOXONE: + case CONTROLLER_XBOX360: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_SMT")); + break; + default: + switch (m_PrefsLanguage) + { + case LANGUAGE_GERMAN: + TEXT_SQUARE_X += 5.0f; + case LANGUAGE_FRENCH: + case LANGUAGE_ITALIAN: + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE * 2 * scale * 0.65f), MENU_Y(SMALLESTTEXT_Y_SCALE * scale * 0.65f)); + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_SMT")); + break; + default: + CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X + 16.0f)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_SMT")); + break; + } + break; + } + break; + default: + return; + } + } + + CFont::SetDropShadowPosition(0); // X + +#undef X +#undef Y +} + + +void +CMenuManager::LoadController(int8 type) +{ + switch (type) + { + case CONTROLLER_DUALSHOCK2: + case CONTROLLER_DUALSHOCK3: + case CONTROLLER_DUALSHOCK4: + CFont::LoadButtons("MODELS/PS3BTNS.TXD"); + break; + default: + CFont::LoadButtons("MODELS/X360BTNS.TXD"); + break; + } + + // Unload current textures + for (int i = MENUSPRITE_CONTROLLER; i <= MENUSPRITE_ARROWS4; i++) + m_aFrontEndSprites[i].Delete(); + + // Unload txd + int frontend_controller = CTxdStore::FindTxdSlot("frontend_controller"); + if (frontend_controller != -1) + CTxdStore::RemoveTxd(frontend_controller); + + // Find the new txd to load + bool bTxdMissing = true; + if (controllerTypesPaths[type]) + if (int file = CFileMgr::OpenFile(controllerTypesPaths[type])) { + CFileMgr::CloseFile(file); + bTxdMissing = false; + } + + int txdSlot = -1; + + if (bTxdMissing) + // Not found, fall back to original textures + txdSlot = CTxdStore::FindTxdSlot("frontend2"); + else { + // Found, load txd + txdSlot = frontend_controller; + if (txdSlot == -1) + txdSlot = CTxdStore::AddTxdSlot("frontend_controller"); + CTxdStore::LoadTxd(txdSlot, controllerTypesPaths[type]); + CTxdStore::AddRef(txdSlot); + } + + assert(txdSlot != -1); + // Load new textures + CTxdStore::SetCurrentTxd(txdSlot); + for (int i = MENUSPRITE_CONTROLLER; i <= MENUSPRITE_ARROWS4; i++) { + m_aFrontEndSprites[i].SetTexture(FrontendFilenames[i][0], FrontendFilenames[i][1]); + m_aFrontEndSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); + } +} +#endif // GAMEPAD_MENU + #undef GetBackJustUp #undef GetBackJustDown diff --git a/src/core/Frontend.h b/src/core/Frontend.h index c1c3983e..6457ce29 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -137,6 +137,13 @@ enum eMenuSprites MENUSPRITE_DOWNON, MENUSPRITE_UPOFF, MENUSPRITE_UPON, +#ifdef GAMEPAD_MENU + MENUSPRITE_CONTROLLER, + MENUSPRITE_ARROWS1, + MENUSPRITE_ARROWS2, + MENUSPRITE_ARROWS3, + MENUSPRITE_ARROWS4, +#endif NUM_MENU_SPRITES }; @@ -192,8 +199,10 @@ enum eMenuScreen MENUPAGE_MOUSE_CONTROLS = 31, MENUPAGE_PAUSE_MENU = 32, MENUPAGE_NONE = 33, // Then chooses main menu or pause menu -#ifdef LEGACY_MENU_OPTIONS +#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) MENUPAGE_CONTROLLER_SETTINGS, +#endif +#ifdef LEGACY_MENU_OPTIONS MENUPAGE_DEBUG_MENU, MENUPAGE_CONTROLLER_PC_OLD1, MENUPAGE_CONTROLLER_PC_OLD2, @@ -275,7 +284,7 @@ enum eMenuAction MENUACTION_DRAWDIST, MENUACTION_MOUSESENS, MENUACTION_MP3VOLUMEBOOST, -#ifdef LEGACY_MENU_OPTIONS +#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) MENUACTION_CTRLVIBRATION, MENUACTION_CTRLCONFIG, #endif @@ -668,6 +677,18 @@ public: int8 m_nDisplayMSAALevel; #endif +#ifdef GAMEPAD_MENU + enum + { + CONTROLLER_DUALSHOCK2 = 0, + CONTROLLER_DUALSHOCK3, + CONTROLLER_DUALSHOCK4, + CONTROLLER_XBOX360, + CONTROLLER_XBOXONE, + }; + + int8 m_PrefsControllerType; +#endif enum LANGUAGE { LANGUAGE_AMERICAN, @@ -788,6 +809,10 @@ public: int8 GetPreviousPageOption(); // uint8 GetNumberOfMenuOptions(); +#ifdef GAMEPAD_MENU + void LoadController(int8 type); + void PrintController(void); +#endif }; #ifndef IMPROVED_VIDEOMODE diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 770e8ec1..5b2f3d16 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -69,11 +69,17 @@ #endif #ifdef INVERT_LOOK_FOR_PAD - #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_ILU", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "Controller", "InvertPad", off_on, 2, false) }, 150, 0, MENUALIGN_LEFT, + #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_ILU", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "Controller", "InvertPad", off_on, 2, false) }, 0, 0, MENUALIGN_LEFT, #else #define INVERT_PAD_SELECTOR #endif +#ifdef GAMEPAD_MENU + #define SELECT_CONTROLLER_TYPE MENUACTION_CFO_SELECT, "FEC_TYP", { new CCFOSelect((int8*)&FrontEndMenuManager.m_PrefsControllerType, "Controller", "Type", controllerTypes, ARRAY_SIZE(controllerTypes), false, ControllerTypeAfterChange) }, 0, 0, MENUALIGN_LEFT, +#else + #define SELECT_CONTROLLER_TYPE +#endif + const char *filterNames[] = { "FEM_NON", "FEM_SIM", "FEM_NRM", "FEM_MOB" }; const char *off_on[] = { "FEM_OFF", "FEM_ON" }; @@ -332,6 +338,14 @@ void DetectJoystickGoBack() { } #endif +#ifdef GAMEPAD_MENU +const char* controllerTypes[] = { "FEC_DS2", "FEC_DS3", "FEC_DS4", "FEC_360", "FEC_ONE" }; +void ControllerTypeAfterChange(int8 before, int8 after) +{ + FrontEndMenuManager.LoadController(after); +} +#endif + CMenuScreenCustom aScreens[] = { // MENUPAGE_STATS = 0 { "FEH_STA", MENUPAGE_NONE, nil, nil, @@ -567,11 +581,13 @@ CMenuScreenCustom aScreens[] = { #else MENUACTION_KEYBOARDCTRLS,"FEC_RED", {nil, SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS}, 320, 150, MENUALIGN_CENTER, #endif +#ifdef GAMEPAD_MENU + MENUACTION_CHANGEMENU, "FET_AGS", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS}, 0, 0, MENUALIGN_CENTER, +#endif #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS MENUACTION_CHANGEMENU, "FEC_JOD", {nil, SAVESLOT_NONE, MENUPAGE_DETECT_JOYSTICK}, 0, 0, MENUALIGN_CENTER, #endif MENUACTION_CHANGEMENU, "FEC_MOU", {nil, SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS}, 0, 0, MENUALIGN_CENTER, - INVERT_PAD_SELECTOR MENUACTION_RESTOREDEF, "FET_DEF", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC}, 320, 0, MENUALIGN_CENTER, MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, 0}, 320, 0, MENUALIGN_CENTER, }, @@ -611,8 +627,12 @@ CMenuScreenCustom aScreens[] = { { "FEC_MOU", MENUPAGE_CONTROLLER_PC, nil, nil, MENUACTION_MOUSESENS, "FEC_MSH", {nil, SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS}, 40, 170, MENUALIGN_LEFT, MENUACTION_INVVERT, "FEC_IVV", {nil, SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS}, 0, 0, MENUALIGN_LEFT, +#ifndef GAMEPAD_MENU + INVERT_PAD_SELECTOR +#endif MENUACTION_MOUSESTEER, "FET_MST", {nil, SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS}, 0, 0, MENUALIGN_LEFT, - MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, 0}, 320, 260, MENUALIGN_CENTER, + MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, 0}, 320, 0, MENUALIGN_CENTER, + //MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, 0}, 320, 260, MENUALIGN_CENTER, // original y }, // MENUPAGE_PAUSE_MENU = 32 @@ -629,15 +649,24 @@ CMenuScreenCustom aScreens[] = { // MENUPAGE_NONE = 33 { "", 0, nil, nil, }, - -#ifdef LEGACY_MENU_OPTIONS +#ifdef GAMEPAD_MENU + { "FET_AGS", MENUPAGE_CONTROLLER_PC, new CCustomScreenLayout({40, 78, 25, true}), nil, + MENUACTION_CTRLCONFIG, "FEC_CCF", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, 40, 76, MENUALIGN_LEFT, + MENUACTION_CTRLDISPLAY, "FEC_CDP", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, 0, 0, MENUALIGN_LEFT, + INVERT_PAD_SELECTOR + MENUACTION_CTRLVIBRATION, "FEC_VIB", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, 0, 0, MENUALIGN_LEFT, + SELECT_CONTROLLER_TYPE + MENUACTION_GOBACK, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, 0, 0, MENUALIGN_LEFT, + }, +#elif defined(LEGACY_MENU_OPTIONS) // MENUPAGE_CONTROLLER_SETTINGS = 4 { "FET_CON", MENUPAGE_OPTIONS, nil, nil, MENUACTION_CTRLCONFIG, "FEC_CCF", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS}, 0, 0, 0, MENUACTION_CTRLVIBRATION, "FEC_VIB", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS}, 0, 0, 0, MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 0, 0, 0, }, - +#endif +#ifdef LEGACY_MENU_OPTIONS // MENUPAGE_DEBUG_MENU = 18 { "FED_DBG", MENUPAGE_NONE, nil, nil, MENUACTION_RELOADIDE, "FED_RID", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 0, 0, 0, diff --git a/src/core/config.h b/src/core/config.h index cc82f8d6..7adbdd63 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -320,6 +320,9 @@ enum Config { //# define PS2_MENU_USEALLPAGEICONS #else # define MAP_ENHANCEMENTS // Adding waypoint and better mouse support +# ifdef XINPUT +# define GAMEPAD_MENU // Add gamepad menu +# endif # define TRIANGLE_BACK_BUTTON //# define CIRCLE_BACK_BUTTON #define LEGACY_MENU_OPTIONS // i.e. frame sync(vsync) -- cgit v1.2.3 From d6068c421d436c05a8aa562bb46b3242e5d0a78a Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 10 Feb 2021 09:08:02 +0200 Subject: Add undef --- src/core/config.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 84e8e603..152ba336 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -479,6 +479,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef RADIO_OFF_TEXT #undef MAP_ENHANCEMENTS +#undef GAMEPAD_MENU #undef MUCH_SHORTER_OUTRO_SCREEN #undef CUSTOM_FRONTEND_OPTIONS -- cgit v1.2.3 From 5f3e68ec45cd7cd30e94719a9ff9625bb7545e5a Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 10 Feb 2021 09:16:04 +0200 Subject: Save vibration setting --- src/core/re3.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 3388b56a..779a7d13 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -409,6 +409,7 @@ bool LoadINISettings() ReadIniIfExists("Controller", "HorizantalMouseSens", &TheCamera.m_fMouseAccelHorzntl); ReadIniIfExists("Controller", "InvertMouseVertically", &MousePointerStateHelper.bInvertVertically); ReadIniIfExists("Controller", "DisableMouseSteering", &CVehicle::m_bDisableMouseSteering); + ReadIniIfExists("Controller", "Vibration", &FrontEndMenuManager.m_PrefsUseVibration); ReadIniIfExists("Audio", "SfxVolume", &FrontEndMenuManager.m_PrefsSfxVolume); ReadIniIfExists("Audio", "MusicVolume", &FrontEndMenuManager.m_PrefsMusicVolume); ReadIniIfExists("Audio", "MP3BoostVolume", &FrontEndMenuManager.m_PrefsMP3BoostVolume); @@ -501,6 +502,7 @@ void SaveINISettings() StoreIni("Controller", "HorizantalMouseSens", TheCamera.m_fMouseAccelHorzntl); StoreIni("Controller", "InvertMouseVertically", MousePointerStateHelper.bInvertVertically); StoreIni("Controller", "DisableMouseSteering", CVehicle::m_bDisableMouseSteering); + StoreIni("Controller", "Vibration", FrontEndMenuManager.m_PrefsUseVibration); StoreIni("Audio", "SfxVolume", FrontEndMenuManager.m_PrefsSfxVolume); StoreIni("Audio", "MusicVolume", FrontEndMenuManager.m_PrefsMusicVolume); StoreIni("Audio", "MP3BoostVolume", FrontEndMenuManager.m_PrefsMP3BoostVolume); -- cgit v1.2.3 From 3c7a7bc8a7ca5a9bfff709fc53d3036597cc2248 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 10 Feb 2021 13:29:02 +0200 Subject: Fixes --- src/core/Frontend.cpp | 13 +++++-------- src/core/Frontend.h | 4 ++-- src/core/MenuScreens.cpp | 7 ------- src/core/MenuScreensCustom.cpp | 9 +-------- 4 files changed, 8 insertions(+), 25 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 141f46f8..31580e0e 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -125,7 +125,7 @@ bool CMenuManager::m_PrefsMarketing = false; bool CMenuManager::m_PrefsDisableTutorials = false; #endif // !MASTER -#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +#ifdef GAMEPAD_MENU uint32 TimeToStopPadShaking; #endif @@ -1089,7 +1089,7 @@ CMenuManager::DrawStandardMenus(bool activeScreen) } switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { -#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +#ifdef GAMEPAD_MENU case MENUACTION_CTRLVIBRATION: if (m_PrefsUseVibration) rightText = TheText.Get("FEM_ON"); @@ -2300,9 +2300,6 @@ CMenuManager::DrawBackground(bool transitionCall) break; case MENUPAGE_SKIN_SELECT: case MENUPAGE_KEYBOARD_CONTROLS: -#ifdef GAMEPAD_MENU - case MENUPAGE_CONTROLLER_SETTINGS: -#endif menuBg.topLeft_x = 14.0f; menuBg.topLeft_y = 39.0f; menuBg.topRight_x = 636.0f; @@ -4926,7 +4923,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u if (changeAmount != 0) { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { -#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +#ifdef GAMEPAD_MENU case MENUACTION_CTRLCONFIG: CPad::GetPad(0)->Mode += changeAmount; if (CPad::GetPad(0)->Mode > 3) @@ -5077,7 +5074,7 @@ void CMenuManager::ProcessOnOffMenuOptions() { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { -#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +#ifdef GAMEPAD_MENU case MENUACTION_CTRLVIBRATION: m_PrefsUseVibration = !m_PrefsUseVibration; if (m_PrefsUseVibration) { @@ -5551,7 +5548,7 @@ CMenuManager::SwitchMenuOnAndOff() m_bStartUpFrontEndRequested = false; m_bShutDownFrontEndRequested = false; -#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +#ifdef GAMEPAD_MENU // Reset pad shaking. if (TimeToStopPadShaking && TimeToStopPadShaking < CTimer::GetTimeInMillisecondsPauseMode()) { CPad::StopPadsShaking(); diff --git a/src/core/Frontend.h b/src/core/Frontend.h index fc09f2dc..112ea7ad 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -199,7 +199,7 @@ enum eMenuScreen MENUPAGE_MOUSE_CONTROLS = 31, MENUPAGE_PAUSE_MENU = 32, MENUPAGE_NONE = 33, // Then chooses main menu or pause menu -#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +#ifdef GAMEPAD_MENU MENUPAGE_CONTROLLER_SETTINGS, #endif #ifdef LEGACY_MENU_OPTIONS @@ -284,7 +284,7 @@ enum eMenuAction MENUACTION_DRAWDIST, MENUACTION_MOUSESENS, MENUACTION_MP3VOLUMEBOOST, -#if defined(LEGACY_MENU_OPTIONS) || defined(GAMEPAD_MENU) +#ifdef GAMEPAD_MENU MENUACTION_CTRLVIBRATION, MENUACTION_CTRLCONFIG, #endif diff --git a/src/core/MenuScreens.cpp b/src/core/MenuScreens.cpp index 72e19c49..20484389 100644 --- a/src/core/MenuScreens.cpp +++ b/src/core/MenuScreens.cpp @@ -277,13 +277,6 @@ CMenuScreen aScreens[] = { { "", 0, 0, }, #ifdef LEGACY_MENU_OPTIONS - // MENUPAGE_CONTROLLER_SETTINGS - { "FET_CON", MENUPAGE_OPTIONS, 0, - MENUACTION_CTRLCONFIG, "FEC_CCF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, 0, 0, 0, - MENUACTION_CTRLVIBRATION, "FEC_VIB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, 0, 0, 0, - MENUACTION_GOBACK, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, 0, 0, 0, - }, - // MENUPAGE_DEBUG_MENU { "FED_DBG", MENUPAGE_NONE, 0, MENUACTION_RELOADIDE, "FED_RID", SAVESLOT_NONE, MENUPAGE_NONE, 0, 0, 0, diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 69af9acf..c4a415c2 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -629,7 +629,7 @@ CMenuScreenCustom aScreens[] = { #ifdef GAMEPAD_MENU MENUACTION_CHANGEMENU, "FET_AGS", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS}, 0, 0, MENUALIGN_CENTER, #endif -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU MENUACTION_CHANGEMENU, "FEC_JOD", {nil, SAVESLOT_NONE, MENUPAGE_DETECT_JOYSTICK}, 0, 0, MENUALIGN_CENTER, #endif MENUACTION_CHANGEMENU, "FEC_MOU", {nil, SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS}, 0, 0, MENUALIGN_CENTER, @@ -703,13 +703,6 @@ CMenuScreenCustom aScreens[] = { SELECT_CONTROLLER_TYPE MENUACTION_GOBACK, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, 0, 0, MENUALIGN_LEFT, }, -#elif defined(LEGACY_MENU_OPTIONS) - // MENUPAGE_CONTROLLER_SETTINGS = 4 - { "FET_CON", MENUPAGE_OPTIONS, nil, nil, - MENUACTION_CTRLCONFIG, "FEC_CCF", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS}, 0, 0, 0, - MENUACTION_CTRLVIBRATION, "FEC_VIB", {nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS}, 0, 0, 0, - MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 0, 0, 0, - }, #endif #ifdef LEGACY_MENU_OPTIONS // MENUPAGE_DEBUG_MENU = 18 -- cgit v1.2.3 From 9f3f0ee2d278aa405414e6dc046fde61747488c1 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 11 Feb 2021 04:36:00 +0200 Subject: Fix borders --- src/core/MenuScreensCustom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index c4a415c2..7d6f5d13 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -695,7 +695,7 @@ CMenuScreenCustom aScreens[] = { { "", 0, nil, nil, }, #ifdef GAMEPAD_MENU - { "FET_AGS", MENUPAGE_CONTROLLER_PC, new CCustomScreenLayout({40, 78, 25, true}), nil, + { "FET_AGS", MENUPAGE_CONTROLLER_PC, new CCustomScreenLayout({40, 78, 25, true, true}), nil, MENUACTION_CTRLCONFIG, "FEC_CCF", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, 40, 76, MENUALIGN_LEFT, MENUACTION_CTRLDISPLAY, "FEC_CDP", { nil, SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS }, 0, 0, MENUALIGN_LEFT, INVERT_PAD_SELECTOR -- cgit v1.2.3 From 4f27a28762d3700946c064a315cd9ed0f104f321 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 11 Feb 2021 05:03:41 +0200 Subject: More fixes --- src/core/ControllerConfig.cpp | 4 ++-- src/core/Frontend.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index d95abd24..2c79b6aa 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2532,7 +2532,7 @@ int32 CControllerConfigManager::GetNumOfSettingsForAction(e_ControllerAction act O, /* PED_SPRINT */ \ R3, /* PED_LOOKBEHIND */ \ L3, /* PED_DUCK */ \ - L1, /* PED_ANSWER_PHONE */ \ + T, /* PED_ANSWER_PHONE */ \ VFB(O) /* VEHICLE_FIREWEAPON */ \ X, /* VEHICLE_ACCELERATE */ \ Q, /* VEHICLE_BRAKE */ \ @@ -2579,7 +2579,7 @@ int32 CControllerConfigManager::GetNumOfSettingsForAction(e_ControllerAction act X, /* PED_SPRINT */ \ R3, /* PED_LOOKBEHIND */ \ L3, /* PED_DUCK */ \ - L1, /* PED_ANSWER_PHONE */ \ + O, /* PED_ANSWER_PHONE */ \ VFB(R1) /* VEHICLE_FIREWEAPON */ \ RSU, /* VEHICLE_ACCELERATE */ \ RSD, /* VEHICLE_BRAKE */ \ diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 31580e0e..97525388 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -6175,13 +6175,13 @@ CMenuManager::PrintController(void) CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R2_X)), MENU_Y(Y(TEXT_R2_Y)), TheText.Get("FEC_CWR")); CFont::SetJustifyOn(); CFont::SetWrapx(SCREEN_WIDTH); - CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_TAR")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R1_X)), MENU_Y(Y(TEXT_R1_Y)), TheText.Get("FEC_ATT")); CFont::SetRightJustifyOn(); CFont::PrintStringFromBottom(MENU_X_LEFT_ALIGNED(X(TEXT_SQUARE_X)), MENU_Y(Y(TEXT_SQUARE_Y)), TheText.Get("FEC_JUM")); CFont::SetJustifyOn(); - CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_LOF")); - CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_RUN")); - CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_ATT")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_TRIANGLE_X)), MENU_Y(Y(TEXT_TRIANGLE_Y)), TheText.Get("FEC_ENV")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CIRCLE_X)), MENU_Y(Y(TEXT_CIRCLE_Y)), TheText.Get("FEC_LOF")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_CROSS_X)), MENU_Y(Y(TEXT_CROSS_Y)), TheText.Get("FEC_RUN")); CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_RSTICK_X)), MENU_Y(Y(TEXT_RSTICK_Y)), TheText.Get("FEC_FPC")); CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y)), TheText.Get("FEC_LB3")); CFont::PrintString(MENU_X_LEFT_ALIGNED(X(TEXT_R3_X)), MENU_Y(Y(TEXT_R3_Y + 13.0f)), TheText.Get("FEC_R3")); -- cgit v1.2.3 From e4320c02cf695afdd48c6fa54f0d82273306cf53 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 11 Feb 2021 17:16:01 +0200 Subject: Enable BIND_VEHICLE_FIREWEAPON --- src/core/ControllerConfig.cpp | 18 ++++++++++++++++++ src/core/Frontend.cpp | 4 ++++ src/core/config.h | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 2c79b6aa..72d31137 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -131,6 +131,9 @@ void CControllerConfigManager::LoadSettings(int32 file) { bool bValid = true; int nVersion = 0; +#ifdef BIND_VEHICLE_FIREWEAPON + bool skipVehicleFireWeapon = false; +#endif if (file) { @@ -148,11 +151,26 @@ void CControllerConfigManager::LoadSettings(int32 file) if (bValid && nVersion >= 3) { ControlsManager.MakeControllerActionsBlank(); +#ifdef BIND_VEHICLE_FIREWEAPON + skipVehicleFireWeapon = nVersion < 4; + // Set the default settings of VEHICLE_FIREWEAPON + if (skipVehicleFireWeapon) { + SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsPADINS, KEYBOARD); + SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsLCTRL, OPTIONAL_EXTRA); + if (m_bMouseAssociated) + SetMouseButtonAssociatedWithAction(VEHICLE_FIREWEAPON, 1); + } +#endif for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++) { for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++) { +#ifdef BIND_VEHICLE_FIREWEAPON + // Skip file read + if (skipVehicleFireWeapon && j == VEHICLE_FIREWEAPON) + continue; +#endif CFileMgr::Read(file, (char *)&ControlsManager.m_aSettings[j][i], sizeof(tControllerConfigBind)); } } diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 97525388..4c847596 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3135,7 +3135,11 @@ CMenuManager::SaveSettings() { #ifndef LOAD_INI_SETTINGS static char RubbishString[48] = "stuffmorestuffevenmorestuff etc"; +#ifdef BIND_VEHICLE_FIREWEAPON + static int SomeVersion = 4; +#else static int SomeVersion = 3; +#endif CFileMgr::SetDirMyDocuments(); diff --git a/src/core/config.h b/src/core/config.h index 152ba336..4d2ad3bf 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -307,7 +307,7 @@ enum Config { #define BETTER_ALLCARSAREDODO_CHEAT #define WALLCLIMB_CHEAT #define REGISTER_START_BUTTON -//#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls +#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls #define BUTTON_ICONS // use textures to show controller buttons // Hud, frontend and radar -- cgit v1.2.3 From 879838c9f20d9f166353d4dd5ea486dda6f91921 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 12 Feb 2021 00:29:09 +0100 Subject: enable screenshots with F12 --- src/core/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/core') diff --git a/src/core/main.cpp b/src/core/main.cpp index a08a9535..bb94ca5d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1,8 +1,10 @@ #include "common.h" +#include #include "rpmatfx.h" #include "rphanim.h" #include "rpskin.h" #include "rtbmp.h" +#include "rtpng.h" #ifdef ANISOTROPIC_FILTERING #include "rpanisot.h" #endif @@ -331,7 +333,11 @@ RwGrabScreen(RwCamera *camera, RwChar *filename) strcpy(temp, CFileMgr::GetRootDirName()); strcat(temp, filename); +#ifdef THIS_IS_STUPID if (RtBMPImageWrite(pImage, &temp[0]) == nil) +#else + if (RtPNGImageWrite(pImage, &temp[0]) == nil) +#endif result = false; RwImageDestroy(pImage); return result; @@ -350,6 +356,7 @@ DoRWStuffEndOfFrame(void) RsCameraShowRaster(Scene.camera); #ifndef MASTER char s[48]; +#ifdef THIS_IS_STUPID if (CPad::GetPad(1)->GetLeftShockJustDown()) { // try using both controllers for this thing... crazy bastards if (CPad::GetPad(0)->GetRightStickY() > 0) { @@ -361,6 +368,12 @@ DoRWStuffEndOfFrame(void) RwGrabScreen(Scene.camera, s); } } +#else + if (CPad::GetPad(1)->GetLeftShockJustDown() || CPad::GetPad(0)->GetFJustDown(11)) { + sprintf(s, "screen_%11lld.png", time(nil)); + RwGrabScreen(Scene.camera, s); + } +#endif #endif // !MASTER } -- cgit v1.2.3 From 9e22eaf79834dc6a462790b78768f5cd0f522428 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 12 Feb 2021 08:06:34 +0200 Subject: Fix RW34 --- src/core/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/main.cpp b/src/core/main.cpp index bb94ca5d..bf0ce5fe 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -333,7 +333,7 @@ RwGrabScreen(RwCamera *camera, RwChar *filename) strcpy(temp, CFileMgr::GetRootDirName()); strcat(temp, filename); -#ifdef THIS_IS_STUPID +#ifndef LIBRW if (RtBMPImageWrite(pImage, &temp[0]) == nil) #else if (RtPNGImageWrite(pImage, &temp[0]) == nil) -- cgit v1.2.3 From c5042dcdf66ea1da380d5fa0964081688a217d50 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 12 Feb 2021 08:14:10 +0200 Subject: Add english strings to translations as stubs, also translation notice --- src/core/MenuScreensCustom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 7d6f5d13..a5dbd0d5 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -643,7 +643,7 @@ CMenuScreenCustom aScreens[] = { MENUACTION_LOADRADIO, "FEO_AUD", {nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS}, 0, 0, MENUALIGN_CENTER, MENUACTION_CHANGEMENU, "FEO_DIS", {nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS}, 0, 0, MENUALIGN_CENTER, #ifdef GRAPHICS_MENU_OPTIONS - MENUACTION_CHANGEMENU, "FET_GRA", {nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS}, 0, 0, MENUALIGN_CENTER, + MENUACTION_CHANGEMENU, "FET_GFX", {nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS}, 0, 0, MENUALIGN_CENTER, #endif MENUACTION_CHANGEMENU, "FEO_LAN", {nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS}, 0, 0, MENUALIGN_CENTER, MENUACTION_PLAYERSETUP, "FET_PS", {nil, SAVESLOT_NONE, MENUPAGE_SKIN_SELECT}, 0, 0, MENUALIGN_CENTER, @@ -759,7 +759,7 @@ CMenuScreenCustom aScreens[] = { #ifdef GRAPHICS_MENU_OPTIONS // MENUPAGE_GRAPHICS_SETTINGS - { "FET_GRA", MENUPAGE_OPTIONS, new CCustomScreenLayout({40, 78, 25, true, true}), GraphicsGoBack, + { "FET_GFX", MENUPAGE_OPTIONS, new CCustomScreenLayout({40, 78, 25, true, true}), GraphicsGoBack, MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, 0, 0, MENUALIGN_LEFT, MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS }, 0, 0, MENUALIGN_LEFT, -- cgit v1.2.3 From e98164ec41c3629c592bb31d8b110d85626c5e3c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 12 Feb 2021 18:00:20 +0200 Subject: Sync aspect ratio setting with master --- src/core/Frontend.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 4c847596..861e67d1 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1138,18 +1138,34 @@ CMenuManager::DrawStandardMenus(bool activeScreen) #else switch (m_PrefsUseWideScreen) { case AR_AUTO: - sprintf(asciiTemp, "AUTO"); + rightText = TheText.Get("FEM_AUT"); break; case AR_4_3: sprintf(asciiTemp, "4:3"); + AsciiToUnicode(asciiTemp, unicodeTemp); + rightText = unicodeTemp; + break; + case AR_5_4: + sprintf(asciiTemp, "5:4"); + AsciiToUnicode(asciiTemp, unicodeTemp); + rightText = unicodeTemp; + break; + case AR_16_10: + sprintf(asciiTemp, "16:10"); + AsciiToUnicode(asciiTemp, unicodeTemp); + rightText = unicodeTemp; break; case AR_16_9: sprintf(asciiTemp, "16:9"); + AsciiToUnicode(asciiTemp, unicodeTemp); + rightText = unicodeTemp; + break; + case AR_21_9: + sprintf(asciiTemp, "21:9"); + AsciiToUnicode(asciiTemp, unicodeTemp); + rightText = unicodeTemp; break; } - - AsciiToUnicode(asciiTemp, unicodeTemp); - rightText = unicodeTemp; #endif break; @@ -4951,12 +4967,12 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u case MENUACTION_WIDESCREEN: if (changeAmount > 0) { m_PrefsUseWideScreen++; - if (m_PrefsUseWideScreen > 2) + if (m_PrefsUseWideScreen > AR_MAX - 1) m_PrefsUseWideScreen = 0; } else { m_PrefsUseWideScreen--; if (m_PrefsUseWideScreen < 0) - m_PrefsUseWideScreen = 2; + m_PrefsUseWideScreen = AR_MAX - 1; } SaveSettings(); break; -- cgit v1.2.3 From 2c784d979a88035176082edf986a2c02b9073338 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 12 Feb 2021 01:49:09 +0300 Subject: Remove version text, add toggleable debug info(with commit hash!) --- src/core/config.h | 4 ++++ src/core/main.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/core/re3.cpp | 14 +++++++++++++- 3 files changed, 72 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 4d2ad3bf..506df4c5 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -194,6 +194,10 @@ enum Config { // those infamous texts #define DRAW_GAME_VERSION_TEXT +#ifdef DRAW_GAME_VERSION_TEXT + #define TOGGLEABLE_VERSION_TEXT + #define USE_OUR_VERSIONING // If you disable this then game will fetch version peds.col, as R* did while in development +#endif // Memory allocation and compression // #define USE_CUSTOM_ALLOCATOR // use CMemoryHeap for allocation. use with care, not finished yet diff --git a/src/core/main.cpp b/src/core/main.cpp index bf0ce5fe..bb9bd296 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -75,6 +75,9 @@ #include "custompipes.h" #include "screendroplets.h" #include "VarConsole.h" +#ifdef USE_OUR_VERSIONING +#include "GitSHA1.h" +#endif GlobalScene Scene; @@ -91,6 +94,9 @@ bool gbModelViewer; #ifdef TIMEBARS bool gbShowTimebars; #endif +#ifdef TOGGLEABLE_VERSION_TEXT +bool gDrawVersionText; +#endif volatile int32 frameCount; @@ -1061,13 +1067,58 @@ DisplayGameDebugText() #ifdef DRAW_GAME_VERSION_TEXT wchar ver[200]; - + +#ifdef TOGGLEABLE_VERSION_TEXT + if(gDrawVersionText) +#endif + { + +#ifdef USE_OUR_VERSIONING + char verA[200]; + sprintf(verA, +#if defined _WIN32 + "Win " +#elif defined __linux__ + "Linux " +#elif defined __APPLE__ + "Mac OS X " +#elif defined __FreeBSD__ + "FreeBSD " +#else + "Posix-compliant " +#endif +#if defined __LP64__ || defined _WIN64 + "64-bit " +#else + "32-bit " +#endif +#if defined RW_D3D9 + "D3D9 " +#elif defined RWLIBS + "D3D8 " +#elif defined RW_GL3 + "OpenGL " +#endif +#if defined AUDIO_OAL + "OAL " +#elif defined AUDIO_MSS + "MSS " +#endif +#if defined _DEBUG || defined DEBUG + "DEBUG " +#endif + "%.8s", + g_GIT_SHA1); + AsciiToUnicode(verA, ver); + CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.7f)); +#else AsciiToUnicode(version_name, ver); + CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.5f)); +#endif CFont::SetPropOn(); CFont::SetBackgroundOff(); CFont::SetFontStyle(FONT_STANDARD); - CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.5f)); CFont::SetCentreOff(); CFont::SetRightJustifyOff(); CFont::SetWrapx(SCREEN_WIDTH); @@ -1076,6 +1127,8 @@ DisplayGameDebugText() CFont::SetColor(CRGBA(255, 108, 0, 255)); CFont::PrintString(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(10.0f), ver); #endif + } +#endif // #ifdef DRAW_GAME_VERSION_TEXT FrameSamples++; #ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 779a7d13..9773b880 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -457,6 +457,10 @@ bool LoadINISettings() #ifdef FIX_SPRITES ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif +#ifdef TOGGLEABLE_VERSION_TEXT + extern bool gDrawVersionText; + ReadIniIfExists("General", "DrawVersionText", &gDrawVersionText); +#endif #ifdef CUSTOM_FRONTEND_OPTIONS bool migrate = cfg.category_size("FrontendOptions") != 0; @@ -550,6 +554,10 @@ void SaveINISettings() #ifdef FIX_SPRITES StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif +#ifdef TOGGLEABLE_VERSION_TEXT + extern bool gDrawVersionText; + StoreIni("General", "DrawVersionText", gDrawVersionText); +#endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { for (int j = 0; j < NUM_MENUROWS; j++) { @@ -988,7 +996,11 @@ extern bool gbRenderWorld2; #ifdef FIX_SPRITES DebugMenuAddVarBool8("Draw", "Fix Sprites", &CDraw::ms_bFixSprites, nil); #endif - + +#ifdef TOGGLEABLE_VERSION_TEXT + extern bool gDrawVersionText; + DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); +#endif #ifndef FINAL DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); #ifdef USE_CUSTOM_ALLOCATOR -- cgit v1.2.3 From 0c60ceeb33c06c17b35773ca4095c2d4c342a0dc Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 12 Feb 2021 02:04:31 +0100 Subject: Cmake version for hash --- src/core/config.h | 4 ++-- src/core/main.cpp | 8 +++----- src/core/re3.cpp | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 506df4c5..71316439 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -195,8 +195,8 @@ enum Config { // those infamous texts #define DRAW_GAME_VERSION_TEXT #ifdef DRAW_GAME_VERSION_TEXT - #define TOGGLEABLE_VERSION_TEXT - #define USE_OUR_VERSIONING // If you disable this then game will fetch version peds.col, as R* did while in development + // unlike R* development builds, ours has runtime switch on debug menu & .ini, and disabled as default. + #define USE_OUR_VERSIONING // If you disable this then game will fetch version from peds.col, as R* did while in development #endif // Memory allocation and compression diff --git a/src/core/main.cpp b/src/core/main.cpp index bb9bd296..52988afc 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -94,8 +94,8 @@ bool gbModelViewer; #ifdef TIMEBARS bool gbShowTimebars; #endif -#ifdef TOGGLEABLE_VERSION_TEXT -bool gDrawVersionText; +#ifdef DRAW_GAME_VERSION_TEXT +bool gDrawVersionText; // Our addition, we think it was always enabled on !MASTER builds #endif volatile int32 frameCount; @@ -1068,9 +1068,7 @@ DisplayGameDebugText() #ifdef DRAW_GAME_VERSION_TEXT wchar ver[200]; -#ifdef TOGGLEABLE_VERSION_TEXT - if(gDrawVersionText) -#endif + if(gDrawVersionText) // This realtime switch is our thing { #ifdef USE_OUR_VERSIONING diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 9773b880..06789e4a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -457,7 +457,7 @@ bool LoadINISettings() #ifdef FIX_SPRITES ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif -#ifdef TOGGLEABLE_VERSION_TEXT +#ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; ReadIniIfExists("General", "DrawVersionText", &gDrawVersionText); #endif @@ -554,7 +554,7 @@ void SaveINISettings() #ifdef FIX_SPRITES StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif -#ifdef TOGGLEABLE_VERSION_TEXT +#ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; StoreIni("General", "DrawVersionText", gDrawVersionText); #endif @@ -997,7 +997,7 @@ extern bool gbRenderWorld2; DebugMenuAddVarBool8("Draw", "Fix Sprites", &CDraw::ms_bFixSprites, nil); #endif -#ifdef TOGGLEABLE_VERSION_TEXT +#ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); #endif -- cgit v1.2.3 From 0ec16a5b0ecb85808553141c2657c957fc585dc9 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 12 Feb 2021 19:50:26 +0300 Subject: Fix XInput hotplug --- src/core/MenuScreensCustom.cpp | 7 ++----- src/core/re3.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index a5dbd0d5..cdfb3c85 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -351,11 +351,8 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { } } if (found != -1 && CPad::XInputJoy1 != found) { - if (CPad::XInputJoy1 != -1 && CPad::XInputJoy1 != found) - CPad::XInputJoy2 = CPad::XInputJoy1; - else - CPad::XInputJoy2 = -1; - + // We should never leave pads -1, so we can process them when they're connected and kinda support hotplug. + CPad::XInputJoy2 = (CPad::XInputJoy1 == -1 ? (found + 1) % 4 : CPad::XInputJoy1); CPad::XInputJoy1 = found; cachedButtonNum = 0; // fake too, because xinput bypass CControllerConfig } diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 06789e4a..bd9a46df 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -279,6 +279,14 @@ void LoadINIControllerSettings() CPad::XInputJoy2 = i; } } + + // There is no plug event on XInput, so let's leave XInputJoy1/2 as 0/1 respectively, and hotplug will be possible. + if (CPad::XInputJoy1 == -1) { + CPad::XInputJoy1 = 0; + CPad::XInputJoy2 = 1; + } else if (CPad::XInputJoy2 == -1) { + CPad::XInputJoy2 = (CPad::XInputJoy1 + 1) % 4; + } } #else ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128); -- cgit v1.2.3 From 035f0010d8d526ae4a5cd2254bd55e1486fca4f2 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 12 Feb 2021 21:26:03 +0300 Subject: fix --- src/core/main.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core') diff --git a/src/core/main.cpp b/src/core/main.cpp index 52988afc..3ab97450 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1124,7 +1124,6 @@ DisplayGameDebugText() CFont::SetBackGroundOnlyTextOff(); CFont::SetColor(CRGBA(255, 108, 0, 255)); CFont::PrintString(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(10.0f), ver); -#endif } #endif // #ifdef DRAW_GAME_VERSION_TEXT -- cgit v1.2.3 From 65f9917b651fa8b44a90899a6cc1fa650f053ab1 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 13 Feb 2021 14:22:34 +0100 Subject: clean up debug menu --- src/core/main.cpp | 2 +- src/core/re3.cpp | 113 ++++++++++++++++++++++++------------------------------ 2 files changed, 51 insertions(+), 64 deletions(-) (limited to 'src/core') diff --git a/src/core/main.cpp b/src/core/main.cpp index 3ab97450..f6d27bd9 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1053,7 +1053,7 @@ DisplayGameDebugText() #ifndef FINAL { - SETTWEAKPATH("GameDebugText"); + SETTWEAKPATH("Debug"); TWEAKBOOL(bDisplayPosn); TWEAKBOOL(bDisplayCheatStr); } diff --git a/src/core/re3.cpp b/src/core/re3.cpp index bd9a46df..94004a84 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -694,18 +694,6 @@ SwitchCarCollision(void) FindPlayerVehicle()->bUsesCollision = !FindPlayerVehicle()->bUsesCollision; } -static int engineStatus; -static void -SetEngineStatus(void) -{ - CVehicle *veh = FindPlayerVehicle(); - if(veh == nil) - return; - if(!veh->IsCar()) - return; - ((CAutomobile*)veh)->Damage.SetEngineStatus(engineStatus); -} - static void ToggleComedy(void) { @@ -928,13 +916,22 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Spawn", "Spawn Skimmer", [](){ SpawnCar(MI_SKIMMER); }); DebugMenuAddVarBool8("Render", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil); +#ifdef PROPER_SCALING + DebugMenuAddVarBool8("Render", "Proper Scaling", &CDraw::ms_bProperScaling, nil); +#endif +#ifdef FIX_RADAR + DebugMenuAddVarBool8("Render", "Fix Radar", &CDraw::ms_bFixRadar, nil); +#endif +#ifdef FIX_SPRITES + DebugMenuAddVarBool8("Render", "Fix Sprites", &CDraw::ms_bFixSprites, nil); +#endif DebugMenuAddVarBool8("Render", "Backface Culling", &gBackfaceCulling, nil); DebugMenuAddVarBool8("Render", "PS2 Alpha test Emu", &gPS2alphaTest, nil); DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil); DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil); DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil); #ifdef NEW_RENDERER - DebugMenuAddVarBool8("Render", "new renderer", &gbNewRenderer, nil); + DebugMenuAddVarBool8("Render", "New Renderer", &gbNewRenderer, nil); extern bool gbRenderRoads; extern bool gbRenderEverythingBarRoads; extern bool gbRenderFadingInUnderwaterEntities; @@ -945,16 +942,16 @@ extern bool gbRenderVehicles; extern bool gbRenderWorld0; extern bool gbRenderWorld1; extern bool gbRenderWorld2; - DebugMenuAddVarBool8("Render", "gbRenderRoads", &gbRenderRoads, nil); - DebugMenuAddVarBool8("Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil); - DebugMenuAddVarBool8("Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil); - DebugMenuAddVarBool8("Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil); - DebugMenuAddVarBool8("Render", "gbRenderWater", &gbRenderWater, nil); - DebugMenuAddVarBool8("Render", "gbRenderBoats", &gbRenderBoats, nil); - DebugMenuAddVarBool8("Render", "gbRenderVehicles", &gbRenderVehicles, nil); - DebugMenuAddVarBool8("Render", "gbRenderWorld0", &gbRenderWorld0, nil); - DebugMenuAddVarBool8("Render", "gbRenderWorld1", &gbRenderWorld1, nil); - DebugMenuAddVarBool8("Render", "gbRenderWorld2", &gbRenderWorld2, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderRoads", &gbRenderRoads, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWater", &gbRenderWater, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderBoats", &gbRenderBoats, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderVehicles", &gbRenderVehicles, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWorld0", &gbRenderWorld0, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWorld1", &gbRenderWorld1, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWorld2", &gbRenderWorld2, nil); #endif #ifdef EXTENDED_COLOURFILTER @@ -983,31 +980,26 @@ extern bool gbRenderWorld2; DebugMenuAddVarBool8("Render", "Neo Road Gloss enable", &CustomPipes::GlossEnable, nil); DebugMenuAddVar("Render", "Mult", &CustomPipes::GlossMult, nil, 0.1f, 0, 1.0f); #endif - DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil); - DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil); - DebugMenuAddVarBool8("Render", "Show Car Path Links", &gbShowCarPathsLinks, nil); - DebugMenuAddVarBool8("Render", "Show Collision Lines", &gbShowCollisionLines, nil); - DebugMenuAddVarBool8("Render", "Show Collision Polys", &gbShowCollisionPolys, nil); - DebugMenuAddVarBool8("Render", "Don't render Buildings", &gbDontRenderBuildings, nil); - DebugMenuAddVarBool8("Render", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil); - DebugMenuAddVarBool8("Render", "Don't render Peds", &gbDontRenderPeds, nil); - DebugMenuAddVarBool8("Render", "Don't render Vehicles", &gbDontRenderVehicles, nil); - DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil); - DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil); + DebugMenuAddVarBool8("Debug Render", "Show Ped Paths", &gbShowPedPaths, nil); + DebugMenuAddVarBool8("Debug Render", "Show Car Paths", &gbShowCarPaths, nil); + DebugMenuAddVarBool8("Debug Render", "Show Car Path Links", &gbShowCarPathsLinks, nil); + DebugMenuAddVarBool8("Debug Render", "Show Collision Lines", &gbShowCollisionLines, nil); + DebugMenuAddVarBool8("Debug Render", "Show Collision Polys", &gbShowCollisionPolys, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Buildings", &gbDontRenderBuildings, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Peds", &gbDontRenderPeds, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Vehicles", &gbDontRenderVehicles, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Objects", &gbDontRenderObjects, nil); + DebugMenuAddVarBool8("Debug Render", "Don't Render Water", &gbDontRenderWater, nil); -#ifdef PROPER_SCALING - DebugMenuAddVarBool8("Draw", "Proper Scaling", &CDraw::ms_bProperScaling, nil); -#endif -#ifdef FIX_RADAR - DebugMenuAddVarBool8("Draw", "Fix Radar", &CDraw::ms_bFixRadar, nil); -#endif -#ifdef FIX_SPRITES - DebugMenuAddVarBool8("Draw", "Fix Sprites", &CDraw::ms_bFixSprites, nil); -#endif #ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); +#endif + DebugMenuAddVarBool8("Debug", "Show DebugStuffInRelease", &gbDebugStuffInRelease, nil); +#ifdef TIMEBARS + DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil); #endif #ifndef FINAL DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); @@ -1020,28 +1012,23 @@ extern bool gbRenderWorld2; #ifdef GTA_SCENE_EDIT DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil); #endif -#ifdef MAP_ENHANCEMENTS - DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); -#endif - DebugMenuAddCmd("Debug", "Switch car collision", SwitchCarCollision); - DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); - DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); - DebugMenuAddCmd("Debug", "Fix Car", FixCar); - DebugMenuAddCmd("Debug", "Toggle Comedy Controls", ToggleComedy); - DebugMenuAddCmd("Debug", "Place Car on Road", PlaceOnRoad); - - DebugMenuAddVarBool8("Debug", "Script Heli On", &CHeli::ScriptHeliOn, nil); - - DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); - DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); + //DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); + //DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); #ifdef RELOADABLES - DebugMenuAddCmd("Reload", "HUD.TXD", CHud::ReloadTXD); +// maybe put it back if we have more to reload +// DebugMenuAddCmd("Reload", "HUD.TXD", CHud::ReloadTXD); #endif - DebugMenuAddVarBool8("Debug", "Show DebugStuffInRelease", &gbDebugStuffInRelease, nil); -#ifdef TIMEBARS - DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil); + +#ifdef MAP_ENHANCEMENTS + DebugMenuAddCmd("Game", "Teleport to map waypoint", TeleportToWaypoint); #endif + DebugMenuAddCmd("Game", "Fix Car", FixCar); + DebugMenuAddCmd("Game", "Place Car on Road", PlaceOnRoad); + DebugMenuAddCmd("Game", "Switch car collision", SwitchCarCollision); + DebugMenuAddCmd("Game", "Toggle Comedy Controls", ToggleComedy); + + #ifdef MISSION_SWITCHER DebugMenuEntry *missionEntry; static const char* missions[] = { @@ -1065,9 +1052,9 @@ extern bool gbRenderWorld2; "PIZZA BOY", "RC Raider Pickup", "RC Bandit Race", "RC Baron Race", "Checkpoint Charlie" }; - missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions); + missionEntry = DebugMenuAddVar("Game", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions); DebugMenuEntrySetWrap(missionEntry, true); - DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission); + DebugMenuAddCmd("Game", "Start selected mission ", SwitchToMission); #endif extern bool PrintDebugCode; extern int16 DebugCamMode; -- cgit v1.2.3 From 4368841f02792abb423255fa29cb1d5a352d0d41 Mon Sep 17 00:00:00 2001 From: erorcun Date: Tue, 16 Feb 2021 17:11:12 +0300 Subject: Fix rare stream deadlock on Windows --- src/core/CdStream.cpp | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src/core') diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index da85a238..977f16c2 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -14,9 +14,9 @@ struct CdReadInfo void *pBuffer; char field_C; bool bLocked; - bool bInUse; + bool bReading; int32 nStatus; - HANDLE hSemaphore; // used for CdStreamSync + HANDLE pDoneSemaphore; // used for CdStreamSync HANDLE hFile; OVERLAPPED Overlapped; }; @@ -53,9 +53,9 @@ CdStreamInitThread(void) { for ( int32 i = 0; i < gNumChannels; i++ ) { - gpReadInfo[i].hSemaphore = CreateSemaphore(nil, 0, 2, nil); + gpReadInfo[i].pDoneSemaphore = CreateSemaphore(nil, 0, 2, nil); - if ( gpReadInfo[i].hSemaphore == nil ) + if ( gpReadInfo[i].pDoneSemaphore == nil ) { printf("%s: failed to create sync semaphore\n", "cdvd_stream"); ASSERT(0); @@ -183,7 +183,7 @@ CdStreamShutdown(void) CloseHandle(_gCdStreamThread); for ( int32 i = 0; i < gNumChannels; i++ ) - CloseHandle(gpReadInfo[i].hSemaphore); + CloseHandle(gpReadInfo[i].pDoneSemaphore); } LocalFree(gpReadInfo); @@ -213,7 +213,7 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size) if ( _gbCdStreamAsync ) { - if ( pChannel->nSectorsToRead != 0 || pChannel->bInUse ) + if ( pChannel->nSectorsToRead != 0 || pChannel->bReading ) return STREAM_NONE; pChannel->nStatus = STREAM_NONE; @@ -271,7 +271,7 @@ CdStreamGetStatus(int32 channel) if ( _gbCdStreamAsync ) { - if ( pChannel->bInUse ) + if ( pChannel->bReading ) return STREAM_READING; if ( pChannel->nSectorsToRead != 0 ) @@ -321,12 +321,21 @@ CdStreamSync(int32 channel) { pChannel->bLocked = true; - ASSERT( pChannel->hSemaphore != nil ); + ASSERT( pChannel->pDoneSemaphore != nil ); - WaitForSingleObject(pChannel->hSemaphore, INFINITE); + // Deadlock fix 1 +#ifdef FIX_BUGS + // This is while loop on Posix streamer, for spurious wakeups + if (pChannel->bLocked && pChannel->nSectorsToRead != 0){ + WaitForSingleObject(pChannel->pDoneSemaphore, INFINITE); + } + pChannel->bLocked = false; +#else + WaitForSingleObject(pChannel->pDoneSemaphore, INFINITE); +#endif } - pChannel->bInUse = false; + pChannel->bReading = false; return pChannel->nStatus; } @@ -398,7 +407,7 @@ WINAPI CdStreamThread(LPVOID lpThreadParameter) CdReadInfo *pChannel = &gpReadInfo[channel]; ASSERT( pChannel != nil ); - pChannel->bInUse = true; + pChannel->bReading = true; if ( pChannel->nStatus == STREAM_NONE ) { @@ -455,11 +464,15 @@ WINAPI CdStreamThread(LPVOID lpThreadParameter) if ( pChannel->bLocked ) { - ASSERT( pChannel->hSemaphore != nil ); - ReleaseSemaphore(pChannel->hSemaphore, 1, NULL); + ASSERT( pChannel->pDoneSemaphore != nil ); + // Deadlock fix 2 +#ifdef FIX_BUGS + pChannel->bLocked = 0; +#endif + ReleaseSemaphore(pChannel->pDoneSemaphore, 1, NULL); } - pChannel->bInUse = false; + pChannel->bReading = false; } } -- cgit v1.2.3 From 48227bd350ab894b11dc362f7f3954bae40776cc Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sun, 24 Jan 2021 14:02:15 +0100 Subject: Add unnamed semaphore define toggle for CdStreamPosix --- src/core/CdStreamPosix.cpp | 77 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 17 deletions(-) (limited to 'src/core') diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index e18280e5..09611fba 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "CdStream.h" @@ -25,6 +26,58 @@ bool flushStream[MAX_CDCHANNELS]; #endif +#ifdef USE_UNNAMED_SEM + +#define RE3_SEM_OPEN(name, ...) re3_sem_open() +sem_t* +re3_sem_open(void) +{ + sem_t* sem = (sem_t*)malloc(sizeof(sem_t)); + if (sem_init(sem, 0, 1) == -1) { + sem = SEM_FAILED; + } + + return sem; +} + +#define RE3_SEM_CLOSE(sem, format, ...) re3_sem_close(sem) +void +re3_sem_close(sem_t* sem) +{ + sem_destroy(sem); + free(sem); +} + +#else + +#define RE3_SEM_OPEN re3_sem_open +sem_t* +re3_sem_open(const char* format, ...) +{ + char semName[20]; + va_list va; + va_start(va, format); + vsprintf(semName, format, va); + + return sem_open(semName, O_CREAT, 0644, 1); +} + +#define RE3_SEM_CLOSE re3_sem_close +void +re3_sem_close(sem_t* sem, const char* format, ...) +{ + sem_close(sem); + + char semName[20]; + va_list va; + va_start(va, format); + vsprintf(semName, format, va); + + sem_unlink(semName); +} + +#endif + struct CdReadInfo { uint32 nSectorOffset; @@ -69,14 +122,13 @@ void CdStreamInitThread(void) { int status; - char semName[20]; #ifndef ONE_THREAD_PER_CHANNEL gChannelRequestQ.items = (int32 *)calloc(gNumChannels + 1, sizeof(int32)); gChannelRequestQ.head = 0; gChannelRequestQ.tail = 0; gChannelRequestQ.size = gNumChannels + 1; ASSERT(gChannelRequestQ.items != nil ); - gCdStreamSema = sem_open("/semaphore_cd_stream", O_CREAT, 0644, 0); + gCdStreamSema = RE3_SEM_OPEN("/semaphore_cd_stream"); if (gCdStreamSema == SEM_FAILED) { @@ -90,8 +142,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, 0); + gpReadInfo[i].pDoneSemaphore = RE3_SEM_OPEN("/semaphore_done%d", i); if (gpReadInfo[i].pDoneSemaphore == SEM_FAILED) { @@ -101,8 +152,7 @@ CdStreamInitThread(void) } #ifdef ONE_THREAD_PER_CHANNEL - sprintf(semName,"/semaphore_start%d",i); - gpReadInfo[i].pStartSemaphore = sem_open(semName, O_CREAT, 0644, 0); + gpReadInfo[i].pStartSemaphore = RE3_SEM_OPEN("/semaphore_start%d", i); if (gpReadInfo[i].pStartSemaphore == SEM_FAILED) { @@ -464,21 +514,14 @@ void *CdStreamThread(void *param) #ifndef ONE_THREAD_PER_CHANNEL for ( int32 i = 0; i < gNumChannels; i++ ) { - sem_close(gpReadInfo[i].pDoneSemaphore); - sprintf(semName,"/semaphore_done%d",i); - sem_unlink(semName); + RE3_SEM_CLOSE(gpReadInfo[i].pDoneSemaphore, "/semaphore_done%d", i); } - sem_close(gCdStreamSema); - sem_unlink("/semaphore_cd_stream"); + RE3_SEM_CLOSE(gCdStreamSema, "/semaphore_cd_stream"); free(gChannelRequestQ.items); #else - sem_close(gpReadInfo[channel].pStartSemaphore); - sprintf(semName,"/semaphore_start%d",channel); - sem_unlink(semName); + RE3_SEM_CLOSE(gpReadInfo[channel].pStartSemaphore, "/semaphore_start%d", channel); - sem_close(gpReadInfo[channel].pDoneSemaphore); - sprintf(semName,"/semaphore_done%d",channel); - sem_unlink(semName); + RE3_SEM_CLOSE(gpReadInfo[channel].pDoneSemaphore, "/semaphore_done%d", channel); #endif if (gpReadInfo) free(gpReadInfo); -- cgit v1.2.3 From ee287f61202c1684af730daa283ae18068ec8864 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sun, 24 Jan 2021 16:34:47 +0100 Subject: Only include sys/syscall.h when __linux__ is defined --- src/core/CdStreamPosix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index 09611fba..50d823d2 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -1,8 +1,8 @@ #ifndef _WIN32 #include "common.h" #include "crossplatform.h" -#include #include +#include #include #include #include @@ -13,7 +13,10 @@ #include #include #include + +#ifdef __linux__ #include +#endif #include "CdStream.h" #include "rwcore.h" -- cgit v1.2.3 From 88c11e92d393337303eec0e6273d7e5c71ad6cf5 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Tue, 16 Feb 2021 18:12:21 +0100 Subject: Fix buffer overflow on re3_sem_open/close --- src/core/CdStreamPosix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index 50d823d2..30fe06a0 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -57,7 +57,7 @@ re3_sem_close(sem_t* sem) sem_t* re3_sem_open(const char* format, ...) { - char semName[20]; + char semName[21]; va_list va; va_start(va, format); vsprintf(semName, format, va); @@ -71,7 +71,7 @@ re3_sem_close(sem_t* sem, const char* format, ...) { sem_close(sem); - char semName[20]; + char semName[21]; va_list va; va_start(va, format); vsprintf(semName, format, va); -- cgit v1.2.3 From 2b6628aa652ae58f0fddf618a2b6b0b716d0f069 Mon Sep 17 00:00:00 2001 From: Steve Wills Date: Wed, 17 Feb 2021 01:02:44 +0300 Subject: Fix seg fault when configuring controller --- src/core/Frontend.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 861e67d1..0f66178b 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1864,8 +1864,13 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 } // Print bindings, including seperator (-) between them + CFont::SetScale(MENU_X(0.25f), MENU_Y(LISTITEM_Y_SCALE)); +#ifdef FIX_BUGS + for (; contSetOrder < MAX_SETORDERS && controllerAction >= 0; contSetOrder++) { +#else for (; contSetOrder < MAX_SETORDERS && controllerAction != -1; contSetOrder++) { +#endif wchar *settingText = ControlsManager.GetControllerSettingTextWithOrderNumber((e_ControllerAction)controllerAction, (eContSetOrder)contSetOrder); if (settingText) { ++bindingsForThisOpt; -- cgit v1.2.3 From ac88a00f060abdb252c6aadea2af2dabb7c5dd71 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 17 Feb 2021 15:09:16 +0200 Subject: Fix endless vibration in pause menu --- src/core/Frontend.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 0f66178b..3e79b418 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5490,6 +5490,9 @@ CMenuManager::SwitchMenuOnAndOff() } Initialise(); LoadAllTextures(); +#ifdef FIX_BUGS + CPad::StopPadsShaking(); +#endif } else { #ifdef EXTENDED_COLOURFILTER // we always expect CPostFX to be open -- cgit v1.2.3 From cba1f85026ab1992c4deff04e9cac5d4eb805165 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 18 Feb 2021 11:34:23 +0200 Subject: Add russian support --- src/core/MenuScreensCustom.cpp | 37 ---------------------- src/core/config.h | 2 +- src/core/re3.cpp | 69 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 39 deletions(-) (limited to 'src/core') diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index cdfb3c85..0534e34a 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -181,38 +181,6 @@ void IslandLoadingAfterChange(int8 before, int8 after) { } #endif -#ifdef MORE_LANGUAGES -void LangPolSelect(int8 action) -{ - if (action == FEOPTION_ACTION_SELECT) { - FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_POLISH; - FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; - FrontEndMenuManager.InitialiseChangedLanguageSettings(); - FrontEndMenuManager.SaveSettings(); - } -} - -void LangRusSelect(int8 action) -{ - if (action == FEOPTION_ACTION_SELECT) { - FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_RUSSIAN; - FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; - FrontEndMenuManager.InitialiseChangedLanguageSettings(); - FrontEndMenuManager.SaveSettings(); - } -} - -void LangJapSelect(int8 action) -{ - if (action == FEOPTION_ACTION_SELECT) { - FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_JAPANESE; - FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; - FrontEndMenuManager.InitialiseChangedLanguageSettings(); - FrontEndMenuManager.SaveSettings(); - } -} -#endif - #ifndef MULTISAMPLING void GraphicsGoBack() { } @@ -471,11 +439,6 @@ CMenuScreenCustom aScreens[] = { MENUACTION_LANG_GER, "FEL_GER", {nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS}, 0, 0, MENUALIGN_CENTER, MENUACTION_LANG_ITA, "FEL_ITA", {nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS}, 0, 0, MENUALIGN_CENTER, MENUACTION_LANG_SPA, "FEL_SPA", {nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS}, 0, 0, MENUALIGN_CENTER, -#ifdef MORE_LANGUAGES - MENUACTION_CFO_DYNAMIC, "FEL_POL", { new CCFODynamic(nil, nil, nil, nil, LangPolSelect) }, 0, 0, MENUALIGN_CENTER, - MENUACTION_CFO_DYNAMIC, "FEL_RUS", { new CCFODynamic(nil, nil, nil, nil, LangRusSelect) }, 0, 0, MENUALIGN_CENTER - MENUACTION_CFO_DYNAMIC, "FEL_JAP", { new CCFODynamic(nil, nil, nil, nil, LangJapSelect) }, 0, 0, MENUALIGN_CENTER, -#endif MENUACTION_GOBACK, "FEDS_TB", {nil, SAVESLOT_NONE, MENUPAGE_NONE}, 0, 0, MENUALIGN_CENTER, }, diff --git a/src/core/config.h b/src/core/config.h index 71316439..44322496 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -246,7 +246,7 @@ enum Config { #endif #define FIX_BUGS // fixes bugs that we've came across during reversing. You can undefine this only on release builds. -//#define MORE_LANGUAGES // Add more translations to the game +#define MORE_LANGUAGES // Add more translations to the game #define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible #define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS #define FIX_HIGH_FPS_BUGS_ON_FRONTEND diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 94004a84..66930f19 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -90,16 +90,51 @@ mysrand(unsigned int seed) #ifdef CUSTOM_FRONTEND_OPTIONS #include "frontendoption.h" + + +#ifdef MORE_LANGUAGES +void LangPolSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_POLISH; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} + +void LangRusSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_RUSSIAN; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} + +void LangJapSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_JAPANESE; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} +#endif + void CustomFrontendOptionsPopulate(void) { // Moved to an array in MenuScreensCustom.cpp, but APIs are still available. see frontendoption.h + int fd; // These work only if we have neo folder, so they're dynamically added #ifdef EXTENDED_PIPELINES const char *vehPipelineNames[] = { "FED_MFX", "FED_NEO" }; const char *off_on[] = { "FEM_OFF", "FEM_ON" }; - int fd = CFileMgr::OpenFile("neo/neo.txd","r"); + fd = CFileMgr::OpenFile("neo/neo.txd","r"); if (fd) { #ifdef GRAPHICS_MENU_OPTIONS FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false); @@ -116,6 +151,38 @@ CustomFrontendOptionsPopulate(void) #endif CFileMgr::CloseFile(fd); } +#endif + // Add outsourced language translations, if files are found +#ifdef MORE_LANGUAGES + int fd2; + FrontendOptionSetCursor(MENUPAGE_LANGUAGE_SETTINGS, 5, false); +#if 0 + if (fd = CFileMgr::OpenFile("text/polish.gxt")) { + if (fd2 = CFileMgr::OpenFile("models/fonts_p.txd")) { + FrontendOptionAddDynamic("FEL_POL", 0, 0, MENUALIGN_CENTER, nil, nil, LangPolSelect, nil, nil); + CFileMgr::CloseFile(fd2); + } + CFileMgr::CloseFile(fd); + } +#endif + + if (fd = CFileMgr::OpenFile("text/russian.gxt")) { + if (fd2 = CFileMgr::OpenFile("models/fonts_r.txd")) { + FrontendOptionAddDynamic("FEL_RUS", 0, 0, MENUALIGN_CENTER, nil, nil, LangRusSelect, nil, nil); + CFileMgr::CloseFile(fd2); + } + CFileMgr::CloseFile(fd); + } + +#if 0 + if (fd = CFileMgr::OpenFile("text/japanese.gxt")) { + if (fd2 = CFileMgr::OpenFile("models/fonts_j.txd")) { + FrontendOptionAddDynamic("FEL_JAP", 0, 0, MENUALIGN_CENTER, nil, nil, LangJapSelect, nil, nil); + CFileMgr::CloseFile(fd2); + } + CFileMgr::CloseFile(fd); + } +#endif #endif } -- cgit v1.2.3 From 996772faf2b7ed17269af194c6d9dcbdb37732fe Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 18 Feb 2021 12:21:52 +0100 Subject: add debug render groups --- src/core/Ropes.cpp | 3 +++ src/core/main.cpp | 16 ++++++++++++++++ src/core/main.h | 6 ++++++ 3 files changed, 25 insertions(+) (limited to 'src/core') diff --git a/src/core/Ropes.cpp b/src/core/Ropes.cpp index 52427fc3..e390a917 100644 --- a/src/core/Ropes.cpp +++ b/src/core/Ropes.cpp @@ -1,5 +1,6 @@ #include "common.h" +#include "main.h" #include "Timer.h" #include "ModelIndices.h" #include "Streaming.h" @@ -91,9 +92,11 @@ void CRopes::Render(void) { int i; + PUSH_RENDERGROUP("CRopes::Render"); for(i = 0; i < ARRAY_SIZE(aRopes); i++) if(aRopes[i].m_bActive) aRopes[i].Render(); + POP_RENDERGROUP(); } bool diff --git a/src/core/main.cpp b/src/core/main.cpp index f6d27bd9..da2017c3 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1261,6 +1261,7 @@ if(gbRenderEverythingBarRoads) void RenderScene_new(void) { + PUSH_RENDERGROUP("RenderScene_new"); CClouds::Render(); DoRWRenderHorizon(); @@ -1268,6 +1269,7 @@ RenderScene_new(void) DefinedState(); // CMattRenderer::ResetRenderStates // moved CRenderer::RenderBoats to before transparent water + POP_RENDERGROUP(); } // TODO @@ -1275,6 +1277,7 @@ bool FredIsInFirstPersonCam(void) { return false; } void RenderEffects_new(void) { + PUSH_RENDERGROUP("RenderEffects_new"); CShadows::RenderStaticShadows(); // CRenderer::GenerateEnvironmentMap CShadows::RenderStoredShadows(); @@ -1319,6 +1322,7 @@ if(gbRenderFadingInEntities) CPointLights::RenderFogEffect(); CMovingThings::Render(); CRenderer::RenderFirstPersonVehicle(); + POP_RENDERGROUP(); } #endif @@ -1331,6 +1335,7 @@ RenderScene(void) return; } #endif + PUSH_RENDERGROUP("RenderScene"); CClouds::Render(); DoRWRenderHorizon(); CRenderer::RenderRoads(); @@ -1346,11 +1351,13 @@ RenderScene(void) RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); CWeather::RenderRainStreaks(); CCoronas::RenderSunReflection(); + POP_RENDERGROUP(); } void RenderDebugShit(void) { + PUSH_RENDERGROUP("RenderDebugShit"); CTheScripts::RenderTheScriptDebugLines(); #ifndef FINAL if(gbShowCollisionLines) @@ -1359,6 +1366,7 @@ RenderDebugShit(void) CDebug::DrawLines(); DefinedState(); #endif + POP_RENDERGROUP(); } void @@ -1370,6 +1378,7 @@ RenderEffects(void) return; } #endif + PUSH_RENDERGROUP("RenderEffects"); CGlass::Render(); CWaterCannons::Render(); CSpecialFX::Render(); @@ -1386,11 +1395,13 @@ RenderEffects(void) CPointLights::RenderFogEffect(); CMovingThings::Render(); CRenderer::RenderFirstPersonVehicle(); + POP_RENDERGROUP(); } void Render2dStuff(void) { + PUSH_RENDERGROUP("Render2dStuff"); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); @@ -1462,6 +1473,7 @@ Render2dStuff(void) #ifdef DEBUGMENU DebugMenuRender(); #endif + POP_RENDERGROUP(); } void @@ -1469,7 +1481,9 @@ RenderMenus(void) { if (FrontEndMenuManager.m_bMenuActive) { + PUSH_RENDERGROUP("RenderMenus"); FrontEndMenuManager.DrawFrontEnd(); + POP_RENDERGROUP(); } #ifndef MASTER else @@ -1480,6 +1494,7 @@ RenderMenus(void) void Render2dStuffAfterFade(void) { + PUSH_RENDERGROUP("Render2dStuffAfterFade"); #ifndef MASTER DisplayGameDebugText(); #endif @@ -1490,6 +1505,7 @@ Render2dStuffAfterFade(void) CHud::DrawAfterFade(); CFont::DrawFonts(); CCredits::Render(); + POP_RENDERGROUP(); } void diff --git a/src/core/main.h b/src/core/main.h index 9f181101..787d4f52 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -1,5 +1,11 @@ #pragma once +#if defined(RW_OPENGL) +#define PUSH_RENDERGROUP(str) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, str) +#define POP_RENDERGROUP() glPopDebugGroup() +#else +#endif + struct GlobalScene { RpWorld *world; -- cgit v1.2.3 From 146ad3b4a1ece09ebe0df3d3a479d60c4b4b22db Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 18 Feb 2021 12:23:33 +0100 Subject: fix last commit --- src/core/main.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core') diff --git a/src/core/main.h b/src/core/main.h index 787d4f52..60ccc116 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -4,6 +4,8 @@ #define PUSH_RENDERGROUP(str) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, str) #define POP_RENDERGROUP() glPopDebugGroup() #else +#define PUSH_RENDERGROUP(str) +#define POP_RENDERGROUP() #endif struct GlobalScene -- cgit v1.2.3 From 3457ff48ce2ca0cb7bcda1e8a585e120843095c8 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 18 Feb 2021 13:08:29 +0100 Subject: d3d9 debug render groups --- src/core/main.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/main.h b/src/core/main.h index 60ccc116..311c0302 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -1,8 +1,11 @@ #pragma once -#if defined(RW_OPENGL) -#define PUSH_RENDERGROUP(str) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, str) -#define POP_RENDERGROUP() glPopDebugGroup() +#ifndef FINAL +// defined in RwHelpder.cpp +void PushRendergroup(const char *name); +void PopRendergroup(void); +#define PUSH_RENDERGROUP(str) PushRendergroup(str) +#define POP_RENDERGROUP() PopRendergroup() #else #define PUSH_RENDERGROUP(str) #define POP_RENDERGROUP() -- cgit v1.2.3 From 781617d484ae7f7966ee7d3f1abe557c9ad9230c Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 18 Feb 2021 22:55:26 +0100 Subject: add NoMovies ini option, rename gDrawVersionText, always save ini after loading --- src/core/Frontend.cpp | 7 +++---- src/core/config.h | 3 ++- src/core/main.cpp | 7 +++++-- src/core/main.h | 8 ++++++++ src/core/re3.cpp | 15 +++++++++------ 5 files changed, 27 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 3e79b418..d6c2649f 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3097,11 +3097,10 @@ CMenuManager::LoadSettings() #ifdef LOAD_INI_SETTINGS if (LoadINISettings()) { LoadINIControllerSettings(); - } else { - // no re3.ini, create it - SaveINISettings(); - SaveINIControllerSettings(); } + // if no reVC.ini, create it, or update it with new values + SaveINISettings(); + SaveINIControllerSettings(); #endif #ifdef FIX_BUGS diff --git a/src/core/config.h b/src/core/config.h index 44322496..6d30a65f 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -232,7 +232,6 @@ enum Config { // not in master builds #define VALIDATE_SAVE_SIZE - #define NO_MOVIES // disable intro videos #define DEBUGMENU #endif @@ -251,6 +250,8 @@ enum Config { #define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS #define FIX_HIGH_FPS_BUGS_ON_FRONTEND +#define NO_MOVIES // add option to disable intro videos + #if defined(__LP64__) || defined(_WIN64) #define FIX_BUGS_64 // Must have fixes to be able to run 64 bit build #endif diff --git a/src/core/main.cpp b/src/core/main.cpp index da2017c3..a38fe72a 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -95,7 +95,10 @@ bool gbModelViewer; bool gbShowTimebars; #endif #ifdef DRAW_GAME_VERSION_TEXT -bool gDrawVersionText; // Our addition, we think it was always enabled on !MASTER builds +bool gbDrawVersionText; // Our addition, we think it was always enabled on !MASTER builds +#endif +#ifdef NO_MOVIES +bool gbNoMovies; #endif volatile int32 frameCount; @@ -1068,7 +1071,7 @@ DisplayGameDebugText() #ifdef DRAW_GAME_VERSION_TEXT wchar ver[200]; - if(gDrawVersionText) // This realtime switch is our thing + if(gbDrawVersionText) // This realtime switch is our thing { #ifdef USE_OUR_VERSIONING diff --git a/src/core/main.h b/src/core/main.h index 311c0302..803afb14 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -66,3 +66,11 @@ void SaveINIControllerSettings(); extern bool gbNewRenderer; bool FredIsInFirstPersonCam(void); #endif + +#ifdef DRAW_GAME_VERSION_TEXT +extern bool gbDrawVersionText; +#endif + +#ifdef NO_MOVIES +extern bool gbNoMovies; +#endif diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 66930f19..a6e4f267 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -533,8 +533,10 @@ bool LoadINISettings() ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif #ifdef DRAW_GAME_VERSION_TEXT - extern bool gDrawVersionText; - ReadIniIfExists("General", "DrawVersionText", &gDrawVersionText); + ReadIniIfExists("General", "DrawVersionText", &gbDrawVersionText); +#endif +#ifdef NO_MOVIES + ReadIniIfExists("General", "NoMovies", &gbNoMovies); #endif #ifdef CUSTOM_FRONTEND_OPTIONS @@ -630,8 +632,10 @@ void SaveINISettings() StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif #ifdef DRAW_GAME_VERSION_TEXT - extern bool gDrawVersionText; - StoreIni("General", "DrawVersionText", gDrawVersionText); + StoreIni("General", "DrawVersionText", gbDrawVersionText); +#endif +#ifdef NO_MOVIES + StoreIni("General", "NoMovies", gbNoMovies); #endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { @@ -1061,8 +1065,7 @@ extern bool gbRenderWorld2; #ifdef DRAW_GAME_VERSION_TEXT - extern bool gDrawVersionText; - DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); + DebugMenuAddVarBool8("Debug", "Version Text", &gbDrawVersionText, nil); #endif DebugMenuAddVarBool8("Debug", "Show DebugStuffInRelease", &gbDebugStuffInRelease, nil); #ifdef TIMEBARS -- cgit v1.2.3 From 4eea06e6200f0c42c9c79ff6c806a1e56222fce4 Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 18 Feb 2021 22:59:40 +0100 Subject: name error strings to REVC --- src/core/re3.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index a6e4f267..3f99b793 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1177,7 +1177,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con strcat_s(re3_buff, re3_buffsize, "(Press Retry to debug the application)"); - nCode = ::MessageBoxA(nil, re3_buff, "RE3 Assertion Failed!", + nCode = ::MessageBoxA(nil, re3_buff, "REVC Assertion Failed!", MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); if (nCode == IDABORT) @@ -1198,7 +1198,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con abort(); #else // TODO - printf("\nRE3 ASSERT FAILED\n\tFile: %s\n\tLine: %d\n\tFunction: %s\n\tExpression: %s\n",filename,lineno,func,expr); + printf("\nREVC ASSERT FAILED\n\tFile: %s\n\tLine: %d\n\tFunction: %s\n\tExpression: %s\n",filename,lineno,func,expr); assert(false); #endif } @@ -1250,14 +1250,14 @@ void re3_usererror(const char *format, ...) vsprintf_s(re3_buff, re3_buffsize, format, va); va_end(va); - ::MessageBoxA(nil, re3_buff, "RE3 Error!", + ::MessageBoxA(nil, re3_buff, "REVC Error!", MB_OK|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); raise(SIGABRT); _exit(3); #else vsprintf(re3_buff, format, va); - printf("\nRE3 Error!\n\t%s\n",re3_buff); + printf("\nREVC Error!\n\t%s\n",re3_buff); assert(false); #endif } -- cgit v1.2.3 From 82322293fe65682c32ee18a82296e8727f42d788 Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 18 Feb 2021 23:01:46 +0100 Subject: rename error strings to RELCS --- src/core/re3.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 771a44f5..3d077ba1 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1112,7 +1112,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con strcat_s(re3_buff, re3_buffsize, "(Press Retry to debug the application)"); - nCode = ::MessageBoxA(nil, re3_buff, "RE3 Assertion Failed!", + nCode = ::MessageBoxA(nil, re3_buff, "RELCS Assertion Failed!", MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); if (nCode == IDABORT) @@ -1133,7 +1133,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con abort(); #else // TODO - printf("\nRE3 ASSERT FAILED\n\tFile: %s\n\tLine: %d\n\tFunction: %s\n\tExpression: %s\n",filename,lineno,func,expr); + printf("\nRELCS ASSERT FAILED\n\tFile: %s\n\tLine: %d\n\tFunction: %s\n\tExpression: %s\n",filename,lineno,func,expr); assert(false); #endif } @@ -1185,14 +1185,14 @@ void re3_usererror(const char *format, ...) vsprintf_s(re3_buff, re3_buffsize, format, va); va_end(va); - ::MessageBoxA(nil, re3_buff, "RE3 Error!", + ::MessageBoxA(nil, re3_buff, "RELCS Error!", MB_OK|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); raise(SIGABRT); _exit(3); #else vsprintf(re3_buff, format, va); - printf("\nRE3 Error!\n\t%s\n",re3_buff); + printf("\nRELCS Error!\n\t%s\n",re3_buff); assert(false); #endif } -- cgit v1.2.3 From b88cf7b93990788a1b7cd9d4163bec7e60614716 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 19 Feb 2021 18:41:47 +0100 Subject: make debug render groups optional --- src/core/re3.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 3f99b793..0ce7f834 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1072,6 +1072,7 @@ extern bool gbRenderWorld2; DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil); #endif #ifndef FINAL + DebugMenuAddVarBool8("Debug", "Use debug render groups", &bDebugRenderGroups, nil); DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); #ifdef USE_CUSTOM_ALLOCATOR DebugMenuAddCmd("Debug", "Parse Heap", ParseHeap); -- cgit v1.2.3 From a311f643f9a0a7377e27f49b18739fe5de5a6291 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 28 Feb 2021 15:50:51 +0300 Subject: Fixes --- src/core/Pools.cpp | 2 +- src/core/Streaming.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index bf35f8ef..d824d498 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -105,7 +105,7 @@ CPools::CheckPoolsEmpty() printf("pools have been cleared\n"); } - +// Thankfully unused, it would break the game! void CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot) { diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index b28a99fc..ee286278 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1724,7 +1724,13 @@ CStreaming::StreamVehiclesAndPeds(void) for(i = 0; i < CCarCtrl::TOTAL_CUSTOM_CLASSES; i++){ if(CCarCtrl::NumRequestsOfCarRating[i] > maxReq && ((i == 0 && zone.carThreshold[0] != 0) || +#ifdef FIX_BUGS + (i < CCarCtrl::NUM_CAR_CLASSES && zone.carThreshold[i] != zone.carThreshold[i-1]) || + (i == CCarCtrl::NUM_CAR_CLASSES && zone.boatThreshold[i - CCarCtrl::NUM_CAR_CLASSES] != 0) || + (i > CCarCtrl::NUM_CAR_CLASSES && i < CCarCtrl::TOTAL_CUSTOM_CLASSES && zone.boatThreshold[i - CCarCtrl::NUM_CAR_CLASSES] != zone.boatThreshold[i - CCarCtrl::NUM_CAR_CLASSES - 1]))) { +#else (i != 0 && zone.carThreshold[i] != zone.carThreshold[i-1]))) { +#endif maxReq = CCarCtrl::NumRequestsOfCarRating[i]; mostRequestedRating = i; } -- cgit v1.2.3 From d2b5a422e464a202c58d330976fecddf1ee0f7f4 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 28 Feb 2021 14:17:14 +0100 Subject: update librw --- src/core/Game.cpp | 10 ++++++++-- src/core/re3.cpp | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 43bd3d11..bffc620c 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -245,10 +245,16 @@ CGame::InitialiseRenderWare(void) #ifdef LIBRW #ifdef PS2_MATFX - rw::MatFX::modulateEnvMap = true; + rw::MatFX::envMapApplyLight = true; + rw::MatFX::envMapUseMatColor = true; + rw::MatFX::envMapFlipU = true; #else - rw::MatFX::modulateEnvMap = false; + rw::MatFX::envMapApplyLight = false; + rw::MatFX::envMapUseMatColor = false; + rw::MatFX::envMapFlipU = false; #endif + rw::RGBA envcol = { 64, 64, 64, 255 }; + rw::MatFX::envMapColor = envcol; #else #ifdef PS2_MATFX ReplaceMatFxCallback(); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 0ce7f834..e2220467 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1037,6 +1037,11 @@ extern bool gbRenderWorld2; #ifndef MASTER DebugMenuAddVarBool8("Render", "Occlusion debug", &bDispayOccDebugStuff, nil); #endif +#ifdef LIBRW + DebugMenuAddVarBool32("Render", "MatFX env map apply light", &rw::MatFX::envMapApplyLight, nil); + DebugMenuAddVarBool32("Render", "MatFX env map flip U", &rw::MatFX::envMapFlipU, nil); + DebugMenuAddVarBool32("Render", "MatFX env map use matcolor", &rw::MatFX::envMapUseMatColor, nil); +#endif #ifdef EXTENDED_PIPELINES static const char *vehpipenames[] = { "MatFX", "Neo" }; e = DebugMenuAddVar("Render", "Vehicle Pipeline", &CustomPipes::VehiclePipeSwitch, nil, -- cgit v1.2.3 From 82245789ed0d10c4cd99bb10606963806d62ca74 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 28 Feb 2021 14:55:14 +0100 Subject: proper radar clipping --- src/core/Radar.cpp | 181 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 113 insertions(+), 68 deletions(-) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 4bb9c966..473f4dae 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -184,6 +184,75 @@ void GetTextureCorners(int32 x, int32 y, CVector2D *out) out[3].y = RADAR_TILE_SIZE * (y); } +uint8 CRadar::CalculateBlipAlpha(float dist) +{ + if (FrontEndMenuManager.m_bMenuMapActive) + return 255; + + if (dist <= 1.0f) + return 255; + + if (dist <= 10.0f) + return (128.0f * ((dist - 1.0f) / 9.0f)) + ((1.0f - (dist - 1.0f) / 9.0f) * 255.0f); + + return 128; +} + +void CRadar::ChangeBlipBrightness(int32 i, int32 bright) +{ + int index = GetActualBlipArrayIndex(i); + if (index != -1) + ms_RadarTrace[index].m_bDim = bright != 1; +} + +void CRadar::ChangeBlipColour(int32 i, int32 color) +{ + int index = GetActualBlipArrayIndex(i); + if (index != -1) + ms_RadarTrace[index].m_nColor = color; +} + +void CRadar::ChangeBlipDisplay(int32 i, eBlipDisplay display) +{ + int index = GetActualBlipArrayIndex(i); + if (index != -1) + ms_RadarTrace[index].m_eBlipDisplay = display; +} + +void CRadar::ChangeBlipScale(int32 i, int32 scale) +{ + int index = GetActualBlipArrayIndex(i); + if (index != -1) + ms_RadarTrace[index].m_wScale = scale; +} + +void CRadar::ClearBlip(int32 i) +{ + int index = GetActualBlipArrayIndex(i); + if (index != -1) { + SetRadarMarkerState(index, false); + ms_RadarTrace[index].m_bInUse = false; + ms_RadarTrace[index].m_eBlipType = BLIP_NONE; + ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; + ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE; + } +} + +void CRadar::ClearBlipForEntity(eBlipType type, int32 id) +{ + for (int i = 0; i < NUMRADARBLIPS; i++) { + if (type == ms_RadarTrace[i].m_eBlipType && id == ms_RadarTrace[i].m_nEntityHandle) { + SetRadarMarkerState(i, false); + ms_RadarTrace[i].m_bInUse = false; + ms_RadarTrace[i].m_eBlipType = BLIP_NONE; + ms_RadarTrace[i].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; + ms_RadarTrace[i].m_eRadarSprite = RADAR_SPRITE_NONE; + } + }; +} + +// Why not a proper clipping algorithm? +#ifdef THIS_IS_STUPID bool IsPointInsideRadar(const CVector2D &point) { @@ -264,74 +333,6 @@ int LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVector2D & return edge; } -uint8 CRadar::CalculateBlipAlpha(float dist) -{ - if (FrontEndMenuManager.m_bMenuMapActive) - return 255; - - if (dist <= 1.0f) - return 255; - - if (dist <= 10.0f) - return (128.0f * ((dist - 1.0f) / 9.0f)) + ((1.0f - (dist - 1.0f) / 9.0f) * 255.0f); - - return 128; -} - -void CRadar::ChangeBlipBrightness(int32 i, int32 bright) -{ - int index = GetActualBlipArrayIndex(i); - if (index != -1) - ms_RadarTrace[index].m_bDim = bright != 1; -} - -void CRadar::ChangeBlipColour(int32 i, int32 color) -{ - int index = GetActualBlipArrayIndex(i); - if (index != -1) - ms_RadarTrace[index].m_nColor = color; -} - -void CRadar::ChangeBlipDisplay(int32 i, eBlipDisplay display) -{ - int index = GetActualBlipArrayIndex(i); - if (index != -1) - ms_RadarTrace[index].m_eBlipDisplay = display; -} - -void CRadar::ChangeBlipScale(int32 i, int32 scale) -{ - int index = GetActualBlipArrayIndex(i); - if (index != -1) - ms_RadarTrace[index].m_wScale = scale; -} - -void CRadar::ClearBlip(int32 i) -{ - int index = GetActualBlipArrayIndex(i); - if (index != -1) { - SetRadarMarkerState(index, false); - ms_RadarTrace[index].m_bInUse = false; - ms_RadarTrace[index].m_eBlipType = BLIP_NONE; - ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; - ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE; - } -} - -void CRadar::ClearBlipForEntity(eBlipType type, int32 id) -{ - for (int i = 0; i < NUMRADARBLIPS; i++) { - if (type == ms_RadarTrace[i].m_eBlipType && id == ms_RadarTrace[i].m_nEntityHandle) { - SetRadarMarkerState(i, false); - ms_RadarTrace[i].m_bInUse = false; - ms_RadarTrace[i].m_eBlipType = BLIP_NONE; - ms_RadarTrace[i].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; - ms_RadarTrace[i].m_eRadarSprite = RADAR_SPRITE_NONE; - } - }; -} - -// Why not a proper clipping algorithm? int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect) { CVector2D corners[4] = { @@ -410,6 +411,50 @@ int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect) return n; } +#else + +int +ClipPolyPlane(const CVector2D *in, int nin, CVector2D *out, CVector *plane) +{ + int j; + int nout; + int x1, x2; + float d1, d2, t; + + nout = 0; + for(j = 0; j < nin; j++){ + x1 = j; + x2 = (j+1) % nin; + + d1 = plane->x*in[x1].x + plane->y*in[x1].y + plane->z; + d2 = plane->x*in[x2].x + plane->y*in[x2].y + plane->z; + if(d1*d2 < 0.0f){ + t = d1/(d1 - d2); + out[nout++] = in[x1]*(1.0f-t) + in[x2]*t; + } + if(d2 >= 0.0f) + out[nout++] = in[x2]; + } + return nout; +} + +int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect) +{ + CVector planes[4] = { + CVector(-1.0f, 0.0f, 1.0f), + CVector( 1.0f, 0.0f, 1.0f), + CVector(0.0f, -1.0f, 1.0f), + CVector(0.0f, 1.0f, 1.0f) + }; + CVector2D tmp[8]; + int n; + if(n = ClipPolyPlane(rect, 4, tmp, &planes[0]), n == 0) return 0; + if(n = ClipPolyPlane(tmp, n, poly, &planes[1]), n == 0) return 0; + if(n = ClipPolyPlane(poly, n, tmp, &planes[2]), n == 0) return 0; + if(n = ClipPolyPlane(tmp, n, poly, &planes[3]), n == 0) return 0; + return n; +} +#endif bool CRadar::DisplayThisBlip(int32 counter) { -- cgit v1.2.3 From 6122f6980b056cc3f777606e75c7db62531369db Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 28 Feb 2021 19:07:46 +0100 Subject: fix new renderer --- src/core/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/core') diff --git a/src/core/main.cpp b/src/core/main.cpp index a38fe72a..2221b691 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1281,11 +1281,13 @@ void RenderEffects_new(void) { PUSH_RENDERGROUP("RenderEffects_new"); +/* // stupid to do this before the whole world is drawn! CShadows::RenderStaticShadows(); // CRenderer::GenerateEnvironmentMap CShadows::RenderStoredShadows(); CSkidmarks::Render(); CRubbish::Render(); +*/ // these aren't really effects DefinedState(); @@ -1308,6 +1310,13 @@ if(gbRenderFadingInEntities) CRenderer::RenderFadingInEntities(); // actual effects here + + // from above + CShadows::RenderStaticShadows(); + CShadows::RenderStoredShadows(); + CSkidmarks::Render(); + CRubbish::Render(); + CGlass::Render(); // CMattRenderer::ResetRenderStates DefinedState(); -- cgit v1.2.3 From 62b8f0f553917bf2db467941b5a055e08872913f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 6 Mar 2021 19:28:59 +0300 Subject: Pool fixes + peds not forming circle fix --- src/core/Streaming.cpp | 3 +-- src/core/Zones.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index ee286278..6d980e18 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1873,8 +1873,7 @@ CStreaming::RemoveCurrentZonesModels(void) if (ms_currentPedGrp != -1) for (i = 0; i < NUMMODELSPERPEDGROUP; i++) { ms_bIsPedFromPedGroupLoaded[i] = false; - if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1 && - CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != MI_MALE01) { + if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1) { SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); } diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 85564f03..26d3efb0 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -452,6 +452,7 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info) assert(d >= 0.0f && d <= 1.0f); n = 1.0f - d; } +#ifdef FIX_BUGS info->carDensity = day->carDensity * d + night->carDensity * n; for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++) info->carThreshold[i] = day->carThreshold[i] * d + night->carThreshold[i] * n; @@ -465,6 +466,22 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info) info->copPedThreshold = day->copPedThreshold * d + night->copPedThreshold * n; for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++) info->gangPedThreshold[i] = day->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n; +#else + // This is a complete mess. + info->carDensity = day->carDensity * n + night->carDensity * d; + for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++) + info->carThreshold[i] = night->carThreshold[i] * d + night->carThreshold[i] * n; + for(i = 0; i < ARRAY_SIZE(info->boatThreshold); i++) + info->boatThreshold[i] = night->boatThreshold[i] * d + night->boatThreshold[i] * n; + for(i = 0; i < ARRAY_SIZE(info->gangThreshold); i++) + info->gangThreshold[i] = night->gangThreshold[i] * d + night->gangThreshold[i] * n; + + info->copThreshold = night->copThreshold * d + night->copThreshold * n; + info->pedDensity = night->pedDensity * d + night->pedDensity * n; + info->copPedThreshold = night->copPedThreshold * d + night->copPedThreshold * n; + for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++) + info->gangPedThreshold[i] = night->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n; +#endif } if(CClock::GetIsTimeInRange(5, 19)) info->pedGroup = day->pedGroup; -- cgit v1.2.3 From 1817727a66a8834b8291957ca8178ee36e7544a2 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 10 May 2021 02:36:18 +0300 Subject: Small Acos fix --- src/core/FileLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index bf017256..4ad53572 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -1206,7 +1206,7 @@ CFileLoader::LoadObjectInstance(const char *line) if(!CStreaming::IsObjectInCdImage(id)) debug("Not in cdimage %s\n", mi->GetModelName()); - angle = -RADTODEG(2.0f * acosf(angle)); + angle = -RADTODEG(2.0f * Acos(angle)); xform = RwMatrixCreate(); RwMatrixRotate(xform, &axis, angle, rwCOMBINEREPLACE); RwMatrixTranslate(xform, &trans, rwCOMBINEPOSTCONCAT); -- cgit v1.2.3 From 3dda658e4296c0b009f0670d6a9c6d2da2878569 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 10 May 2021 02:34:21 +0300 Subject: Use some GetMatrix/SetMatrix logic based on SA # Conflicts: # src/control/Pickups.cpp # src/control/RoadBlocks.cpp # src/core/World.cpp # src/entities/Entity.cpp # src/objects/CutsceneHead.cpp # src/objects/Object.cpp --- src/core/Camera.cpp | 4 ++-- src/core/Placeable.h | 6 ++++-- src/core/World.cpp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 5b3f9aa5..50ac2b5b 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -213,7 +213,7 @@ CCamera::Init(void) m_iModeToGoTo = CCam::MODE_FOLLOWPED; m_bJust_Switched = false; m_bUseTransitionBeta = false; - m_matrix.SetScale(1.0f); + GetMatrix().SetScale(1.0f); m_bTargetJustBeenOnTrain = false; m_bInitialNoNodeStaticsSet = false; m_uiLongestTimeInMill = 5000; @@ -4017,7 +4017,7 @@ CCamera::SetRwCamera(RwCamera *cam) void CCamera::CalculateDerivedValues(void) { - m_cameraMatrix = Invert(m_matrix); + m_cameraMatrix = Invert(GetMatrix()); float hfov = DEGTORAD(CDraw::GetScaledFOV()/2.0f); float c = Cos(hfov); diff --git a/src/core/Placeable.h b/src/core/Placeable.h index b0f9a15a..9c8c292a 100644 --- a/src/core/Placeable.h +++ b/src/core/Placeable.h @@ -2,12 +2,13 @@ class CPlaceable { +protected: + CMatrix m_matrix; + public: // disable allocation static void *operator new(size_t); - CMatrix m_matrix; - CPlaceable(void); const CVector &GetPosition(void) { return m_matrix.GetPosition(); } void SetPosition(float x, float y, float z) { @@ -20,6 +21,7 @@ public: CVector &GetForward(void) { return m_matrix.GetForward(); } CVector &GetUp(void) { return m_matrix.GetUp(); } CMatrix &GetMatrix(void) { return m_matrix; } + void SetMatrix(CMatrix &newMatrix) { m_matrix = newMatrix; } void SetTransform(RwMatrix *m) { m_matrix = CMatrix(m, false); } void SetHeading(float angle); void SetOrientation(float x, float y, float z){ diff --git a/src/core/World.cpp b/src/core/World.cpp index 2683a28d..1a693c5c 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1486,7 +1486,7 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList &list, float x1, float y1 CColModel *pColModel = pVehicle->GetColModel(); bool bInsideSphere = false; for(int32 i = 0; i < pColModel->numSpheres; i++) { - CVector pos = pVehicle->m_matrix * pColModel->spheres[i].center; + CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center; float fRadius = pColModel->spheres[i].radius; if(pos.x + fRadius > x1 && pos.x - fRadius < x2 && pos.y + fRadius > y1 && pos.y - fRadius < y2) @@ -1803,7 +1803,7 @@ CWorld::RepositionOneObject(CEntity *pEntity) position.z = FindGroundZFor3DCoord(position.x, position.y, position.z + fHeight, nil) - fBoundingBoxMinZ; - pEntity->m_matrix.UpdateRW(); + pEntity->GetMatrix().UpdateRW(); pEntity->UpdateRwFrame(); } else if(IsLightThatNeedsRepositioning(modelId)) { CVector position = pEntity->GetMatrix().GetPosition(); -- cgit v1.2.3 From 618d689dff9a22d9385abf36f5e364b38273b7cf Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 6 Mar 2021 19:28:59 +0300 Subject: Pool fixes + peds not forming circle fix --- src/core/Streaming.cpp | 3 +-- src/core/Zones.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index ee286278..6d980e18 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1873,8 +1873,7 @@ CStreaming::RemoveCurrentZonesModels(void) if (ms_currentPedGrp != -1) for (i = 0; i < NUMMODELSPERPEDGROUP; i++) { ms_bIsPedFromPedGroupLoaded[i] = false; - if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1 && - CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != MI_MALE01) { + if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1) { SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); } diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 85564f03..26d3efb0 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -452,6 +452,7 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info) assert(d >= 0.0f && d <= 1.0f); n = 1.0f - d; } +#ifdef FIX_BUGS info->carDensity = day->carDensity * d + night->carDensity * n; for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++) info->carThreshold[i] = day->carThreshold[i] * d + night->carThreshold[i] * n; @@ -465,6 +466,22 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info) info->copPedThreshold = day->copPedThreshold * d + night->copPedThreshold * n; for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++) info->gangPedThreshold[i] = day->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n; +#else + // This is a complete mess. + info->carDensity = day->carDensity * n + night->carDensity * d; + for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++) + info->carThreshold[i] = night->carThreshold[i] * d + night->carThreshold[i] * n; + for(i = 0; i < ARRAY_SIZE(info->boatThreshold); i++) + info->boatThreshold[i] = night->boatThreshold[i] * d + night->boatThreshold[i] * n; + for(i = 0; i < ARRAY_SIZE(info->gangThreshold); i++) + info->gangThreshold[i] = night->gangThreshold[i] * d + night->gangThreshold[i] * n; + + info->copThreshold = night->copThreshold * d + night->copThreshold * n; + info->pedDensity = night->pedDensity * d + night->pedDensity * n; + info->copPedThreshold = night->copPedThreshold * d + night->copPedThreshold * n; + for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++) + info->gangPedThreshold[i] = night->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n; +#endif } if(CClock::GetIsTimeInRange(5, 19)) info->pedGroup = day->pedGroup; -- cgit v1.2.3 From bd94c16e78739d2d58cec63186f1f0e4ee722169 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 08:35:29 +0300 Subject: Fix C3dMarkers::PlaceMarker calls in Radar --- src/core/Radar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 473f4dae..ec3335fa 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -478,7 +478,7 @@ void CRadar::Draw3dMarkers() if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { CVector pos = entity->GetPosition(); pos.z += 1.2f * CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 2.5f; - C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 2.5f, CARBLIP_MARKER_COLOR_R, CARBLIP_MARKER_COLOR_G, CARBLIP_MARKER_COLOR_B, CARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); + C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_ARROW, pos, 2.5f, CARBLIP_MARKER_COLOR_R, CARBLIP_MARKER_COLOR_G, CARBLIP_MARKER_COLOR_B, CARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); } break; } @@ -492,7 +492,7 @@ void CRadar::Draw3dMarkers() if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { CVector pos = entity->GetPosition(); pos.z += 3.0f; - C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.5f, CHARBLIP_MARKER_COLOR_R, CHARBLIP_MARKER_COLOR_G, CHARBLIP_MARKER_COLOR_B, CHARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); + C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_ARROW, pos, 1.5f, CHARBLIP_MARKER_COLOR_R, CHARBLIP_MARKER_COLOR_G, CHARBLIP_MARKER_COLOR_B, CHARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); } break; } @@ -502,7 +502,7 @@ void CRadar::Draw3dMarkers() if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { CVector pos = entity->GetPosition(); pos.z += CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 1.0f + 1.0f; - C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.0f, OBJECTBLIP_MARKER_COLOR_R, OBJECTBLIP_MARKER_COLOR_G, OBJECTBLIP_MARKER_COLOR_B, OBJECTBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); + C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_ARROW, pos, 1.0f, OBJECTBLIP_MARKER_COLOR_R, OBJECTBLIP_MARKER_COLOR_G, OBJECTBLIP_MARKER_COLOR_B, OBJECTBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); } break; } @@ -511,7 +511,7 @@ void CRadar::Draw3dMarkers() case BLIP_CONTACT_POINT: if (!CTheScripts::IsPlayerOnAMission()) { if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) - C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), 4, ms_RadarTrace[i].m_vecPos, 2.0f, COORDBLIP_MARKER_COLOR_R, COORDBLIP_MARKER_COLOR_G, COORDBLIP_MARKER_COLOR_B, COORDBLIP_MARKER_COLOR_A, 2048, 0.2f, 0); + C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_CYLINDER, ms_RadarTrace[i].m_vecPos, 2.0f, COORDBLIP_MARKER_COLOR_R, COORDBLIP_MARKER_COLOR_G, COORDBLIP_MARKER_COLOR_B, COORDBLIP_MARKER_COLOR_A, 2048, 0.2f, 0); } break; } -- cgit v1.2.3 From 5bcdb933a78abb2b9b8d6648d17502240bd9fd29 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 13:08:26 +0300 Subject: Use bool8 in audio code --- src/core/Frontend.cpp | 6 +++--- src/core/FrontendTriggers.h | 2 +- src/core/Frontend_PS2.cpp | 2 +- src/core/Game.cpp | 2 +- src/core/World.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index d6c2649f..798c1d8b 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3968,7 +3968,7 @@ CMenuManager::PrintRadioSelector(void) if (radioChangeRequested) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastRadioChange > 50) { DMAudio.SetRadioInCar(m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); OutputDebugString("FRONTEND RADIO STATION CHANGED"); lastRadioChange = CTimer::GetTimeInMillisecondsPauseMode(); radioChangeRequested = false; @@ -4702,7 +4702,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u case MENUACTION_LOADRADIO: if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { SwitchToNewScreen(MENUPAGE_SOUND_SETTINGS); - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); OutputDebugString("STARTED PLAYING FRONTEND AUDIO TRACK"); } break; @@ -4807,7 +4807,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); DMAudio.SetRadioInCar(m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); SaveSettings(); } else if (m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { m_PrefsBrightness = 256; diff --git a/src/core/FrontendTriggers.h b/src/core/FrontendTriggers.h index b2bde09c..bbafb4be 100644 --- a/src/core/FrontendTriggers.h +++ b/src/core/FrontendTriggers.h @@ -779,7 +779,7 @@ TriggerAudio_RadioStation(CMenuMultiChoicePicturedTriggered *widget) if ( CMenuManager::m_PrefsRadioStation != widget->GetMenuSelection() ) { CMenuManager::m_PrefsRadioStation = widget->GetMenuSelection(); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, TRUE); DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); } } diff --git a/src/core/Frontend_PS2.cpp b/src/core/Frontend_PS2.cpp index c0fcc652..c635c21f 100644 --- a/src/core/Frontend_PS2.cpp +++ b/src/core/Frontend_PS2.cpp @@ -2858,7 +2858,7 @@ CMenuManager::ProcessDPadCrossJustDown(void) { if ( !gMusicPlaying ) { - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); gMusicPlaying = true; } } diff --git a/src/core/Game.cpp b/src/core/Game.cpp index bffc620c..c5e5224d 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -577,7 +577,7 @@ bool CGame::Initialise(const char* datFile) #endif - DMAudio.SetStartingTrackPositions(true); + DMAudio.SetStartingTrackPositions(TRUE); DMAudio.ChangeMusicMode(MUSICMODE_GAME); return true; } diff --git a/src/core/World.cpp b/src/core/World.cpp index 1a693c5c..82f03541 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -65,7 +65,7 @@ CWorld::Initialise() void CWorld::Add(CEntity *ent) { - if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, true); + if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, TRUE); if(ent->bIsBIGBuilding) ms_bigBuildingsList[ent->m_level].InsertItem(ent); @@ -80,7 +80,7 @@ CWorld::Add(CEntity *ent) void CWorld::Remove(CEntity *ent) { - if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, false); + if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, FALSE); if(ent->bIsBIGBuilding) ms_bigBuildingsList[ent->m_level].RemoveItem(ent); -- cgit v1.2.3 From 02655313e9726a044dcecdeb143c261614d00f0f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 23 May 2021 16:47:16 +0300 Subject: Increase the number of audio channels to PS2 count and some small audio fixes --- src/core/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 6d30a65f..69e9c8fd 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -131,7 +131,6 @@ enum Config { NUM_PED_COMMENTS_SLOTS = 20, NUM_SOUNDS_SAMPLES_BANKS = 2, - NUM_SOUNDS_SAMPLES_SLOTS = 27, NUM_AUDIOENTITIES = 250, NUM_AUDIO_REFLECTIONS = 8, @@ -396,6 +395,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually // Audio #define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS #define AUDIO_CACHE // cache sound lengths to speed up the cold boot +#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 43 (PC has 28 originally) //#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) //#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 -- cgit v1.2.3 From be019c61269e34d9c9a45bd83e854bb8f38e92ae Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 23 May 2021 17:14:12 +0300 Subject: Undef PS2_AUDIO_CHANNELS for SQUEEZE_PERFORMANCE and VANILLA_DEFINES # Conflicts: # src/core/config.h --- src/core/config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 69e9c8fd..f8e63d31 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -423,6 +423,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #ifdef SQUEEZE_PERFORMANCE #undef PS2_ALPHA_TEST #undef NO_ISLAND_LOADING + #undef PS2_AUDIO_CHANNELS #endif // ------- @@ -511,6 +512,6 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef IMPROVED_CAMERA #undef FREE_CAM #undef BIG_IMG - +#undef PS2_AUDIO_CHANNELS #undef RADIO_SCROLL_TO_PREV_STATION #endif -- cgit v1.2.3 From 93e99299250fbc5e459883b514b871f6009edfc6 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 23 May 2021 17:49:55 +0200 Subject: CEntity and C(Vu)Vector fixes and cleanup --- src/core/Camera.cpp | 9 ++------- src/core/Camera.h | 6 +----- src/core/References.cpp | 2 -- src/core/common.h | 6 ++++++ 4 files changed, 9 insertions(+), 14 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 50ac2b5b..baf31f04 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -4101,16 +4101,11 @@ CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat bool CCamera::IsSphereVisible(const CVector ¢er, float radius) { - CMatrix mat = m_cameraMatrix; - return IsSphereVisible(center, radius, &mat); + return IsSphereVisible(center, radius, &m_cameraMatrix); } bool -#ifdef GTA_PS2 -CCamera::IsBoxVisible(CVuVector *box, const CMatrix *mat) -#else -CCamera::IsBoxVisible(CVector *box, const CMatrix *mat) -#endif +CCamera::IsBoxVisible(CVUVECTOR *box, const CMatrix *mat) { int i; int frustumTests[6] = { 0 }; diff --git a/src/core/Camera.h b/src/core/Camera.h index 538ff067..39ecb760 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -633,11 +633,7 @@ public: bool IsPointVisible(const CVector ¢er, const CMatrix *mat); bool IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat); bool IsSphereVisible(const CVector ¢er, float radius); -#ifdef GTA_PS2 - bool IsBoxVisible(CVuVector *box, const CMatrix *mat); -#else - bool IsBoxVisible(CVector *box, const CMatrix *mat); -#endif + bool IsBoxVisible(CVUVECTOR *box, const CMatrix *mat); }; VALIDATE_SIZE(CCamera, 0xE9D8); diff --git a/src/core/References.cpp b/src/core/References.cpp index dc83d96d..09913817 100644 --- a/src/core/References.cpp +++ b/src/core/References.cpp @@ -39,9 +39,7 @@ CEntity::RegisterReference(CEntity **pent) ref->pentity = pent; ref->next = m_pFirstReference; m_pFirstReference = ref; - return; } - return; } // Clean up the reference from *pent -> 'this' diff --git a/src/core/common.h b/src/core/common.h index d39531cc..38ba7ea8 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -214,6 +214,12 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #include "maths.h" #include "Vector.h" +#ifdef GTA_PS2 +#include "VuVector.h" +#define CVUVECTOR CVuVector +#else +#define CVUVECTOR CVector +#endif #include "Vector2D.h" #include "Matrix.h" #include "Rect.h" -- cgit v1.2.3 From f2c8522daa51f49bffa358914802b0220b6f4604 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Jun 2021 13:00:45 +0300 Subject: Fix IsSphereVisible calls --- src/core/Camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index baf31f04..d94efb03 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -4101,7 +4101,7 @@ CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat bool CCamera::IsSphereVisible(const CVector ¢er, float radius) { - return IsSphereVisible(center, radius, &m_cameraMatrix); + return IsSphereVisible(center, radius, &GetCameraMatrix()); } bool -- cgit v1.2.3 From 6e4a2947ea55fc19ba1ba7f10c08a2ed1d54d135 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Jun 2021 13:03:14 +0300 Subject: Fix sin & cos calls --- src/core/Cam.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index fdfe2275..448da46e 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -4952,9 +4952,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, AlphaSpeed = 0.0; Distance = 1000.0; - Front.x = -(cos(Beta) * cos(Alpha)); - Front.y = -(sin(Beta) * cos(Alpha)); - Front.z = sin(Alpha); + Front.x = -(Cos(Beta) * Cos(Alpha)); + Front.y = -(Sin(Beta) * Cos(Alpha)); + Front.z = Sin(Alpha); m_aTargetHistoryPosOne = TargetCoors - nextDistance * Front; @@ -5228,9 +5228,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, lastBeta = Beta; - Front.x = -(cos(Beta) * cos(Alpha)); - Front.y = -(sin(Beta) * cos(Alpha)); - Front.z = sin(Alpha); + Front.x = -(Cos(Beta) * Cos(Alpha)); + Front.y = -(Sin(Beta) * Cos(Alpha)); + Front.z = Sin(Alpha); GetVectorsReadyForRW(); TheCamera.m_bCamDirectlyBehind = false; TheCamera.m_bCamDirectlyInFront = false; @@ -5240,9 +5240,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, m_cvecTargetCoorsForFudgeInter = TargetCoors; m_aTargetHistoryPosThree = m_aTargetHistoryPosOne; float nextAlpha = alphaWithSpeedAccounted + zoomModeAlphaOffset; - float nextFrontX = -(cos(Beta) * cos(nextAlpha)); - float nextFrontY = -(sin(Beta) * cos(nextAlpha)); - float nextFrontZ = sin(nextAlpha); + float nextFrontX = -(Cos(Beta) * Cos(nextAlpha)); + float nextFrontY = -(Sin(Beta) * Cos(nextAlpha)); + float nextFrontZ = Sin(nextAlpha); m_aTargetHistoryPosOne.x = TargetCoors.x - nextFrontX * nextDistance; m_aTargetHistoryPosOne.y = TargetCoors.y - nextFrontY * nextDistance; -- cgit v1.2.3 From fad64667a7b0199786a6c031248ad726fdc9d22d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Jun 2021 13:13:27 +0300 Subject: Fix some timer calls --- src/core/Cam.cpp | 2 +- src/core/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 448da46e..ad315029 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -5395,7 +5395,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, float alphaToFace = Atan2(hi.z, hi.Magnitude2D()) + DEGTORAD(15.0f); float neededAlphaTurn = alphaToFace - carGunUD; - float alphaTurnPerFrame = CTimer::GetTimeStep() * 0.02f; + float alphaTurnPerFrame = CTimer::GetTimeStepInSeconds(); if (neededAlphaTurn > alphaTurnPerFrame) { neededTurn = alphaTurnPerFrame; diff --git a/src/core/main.cpp b/src/core/main.cpp index 2221b691..90efdb62 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1135,7 +1135,7 @@ DisplayGameDebugText() FramesPerSecondCounter += frameTime / 1000.f; // convert to seconds FramesPerSecond = FrameSamples / FramesPerSecondCounter; #else - FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f); + FramesPerSecondCounter += 1000.0f / CTimer::GetTimeStepNonClippedInMilliseconds(); FramesPerSecond = FramesPerSecondCounter / FrameSamples; #endif -- cgit v1.2.3 From 499b16678f1e36eb4a938fe519d472806745f489 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 17 May 2021 20:40:58 +0300 Subject: Fix engine sounds, player and male01 ped comments --- src/core/config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 9e42fb9e..a7407bb4 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -399,8 +399,8 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually // Audio #define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS -#define AUDIO_CACHE // cache sound lengths to speed up the cold boot -#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) +//#define AUDIO_CACHE // cache sound lengths to speed up the cold boot +//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) //#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 -- cgit v1.2.3 From 714cd47db97dc7500e373e475301fc7d56d0b3c0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 08:41:41 +0300 Subject: Original pool sizes --- src/core/config.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index a7407bb4..d5b21713 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -10,9 +10,9 @@ enum Config { MAX_CDIMAGES = 8, // additional cdimages MAX_CDCHANNELS = 5, - MODELINFOSIZE = 6500, // only 4900 - TXDSTORESIZE = 1385, // only 1200 - COLSTORESIZE = 31, // only 15 + MODELINFOSIZE = 4900, + TXDSTORESIZE = 1200, + COLSTORESIZE = 15, EXTRADIRSIZE = 256, CUTSCENEDIRSIZE = 512, @@ -100,7 +100,7 @@ enum Config { NUMPACMANPICKUPS = 256, NUMEVENTS = 64, - NUM_CARGENS = 500, + NUM_CARGENS = 195, // 500 on mobile NUM_PATH_NODES_IN_AUTOPILOT = 8, -- cgit v1.2.3 From 0c3ee871f47e84d372d7be57b34022c1f8c5100c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 08:35:29 +0300 Subject: Fix C3dMarkers::PlaceMarker calls in Radar --- src/core/Radar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 1be7d2fa..a2cf212f 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -533,7 +533,7 @@ void CRadar::Draw3dMarkers() if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { CVector pos = entity->GetPosition(); pos.z += 1.2f * CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 2.5f; - C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 2.5f, CARBLIP_MARKER_COLOR_R, CARBLIP_MARKER_COLOR_G, CARBLIP_MARKER_COLOR_B, CARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); + C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_ARROW, pos, 2.5f, CARBLIP_MARKER_COLOR_R, CARBLIP_MARKER_COLOR_G, CARBLIP_MARKER_COLOR_B, CARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); } break; } @@ -547,7 +547,7 @@ void CRadar::Draw3dMarkers() if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { CVector pos = entity->GetPosition(); pos.z += 3.0f; - C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.5f, CHARBLIP_MARKER_COLOR_R, CHARBLIP_MARKER_COLOR_G, CHARBLIP_MARKER_COLOR_B, CHARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); + C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_ARROW, pos, 1.5f, CHARBLIP_MARKER_COLOR_R, CHARBLIP_MARKER_COLOR_G, CHARBLIP_MARKER_COLOR_B, CHARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); } break; } @@ -557,7 +557,7 @@ void CRadar::Draw3dMarkers() if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { CVector pos = entity->GetPosition(); pos.z += CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 1.0f + 1.0f; - C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.0f, OBJECTBLIP_MARKER_COLOR_R, OBJECTBLIP_MARKER_COLOR_G, OBJECTBLIP_MARKER_COLOR_B, OBJECTBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); + C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_ARROW, pos, 1.0f, OBJECTBLIP_MARKER_COLOR_R, OBJECTBLIP_MARKER_COLOR_G, OBJECTBLIP_MARKER_COLOR_B, OBJECTBLIP_MARKER_COLOR_A, 1024, 0.2f, 5); } break; } @@ -566,7 +566,7 @@ void CRadar::Draw3dMarkers() case BLIP_CONTACT_POINT: if (!CTheScripts::IsPlayerOnAMission()) { if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) - C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), 4, ms_RadarTrace[i].m_vecPos, 2.0f, COORDBLIP_MARKER_COLOR_R, COORDBLIP_MARKER_COLOR_G, COORDBLIP_MARKER_COLOR_B, COORDBLIP_MARKER_COLOR_A, 2048, 0.2f, 0); + C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), MARKERTYPE_CYLINDER, ms_RadarTrace[i].m_vecPos, 2.0f, COORDBLIP_MARKER_COLOR_R, COORDBLIP_MARKER_COLOR_G, COORDBLIP_MARKER_COLOR_B, COORDBLIP_MARKER_COLOR_A, 2048, 0.2f, 0); } break; } -- cgit v1.2.3 From 1fa0116f5f856b4dbe68bb289443e28ae4012543 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 13:08:26 +0300 Subject: Use bool8 in audio code --- src/core/Frontend.cpp | 6 +++--- src/core/FrontendTriggers.h | 2 +- src/core/Frontend_PS2.cpp | 2 +- src/core/Game.cpp | 2 +- src/core/World.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 7b159e17..368ee002 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3985,7 +3985,7 @@ CMenuManager::PrintRadioSelector(void) if (radioChangeRequested) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastRadioChange > 50) { DMAudio.SetRadioInCar(m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); OutputDebugString("FRONTEND RADIO STATION CHANGED"); lastRadioChange = CTimer::GetTimeInMillisecondsPauseMode(); radioChangeRequested = false; @@ -4719,7 +4719,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u case MENUACTION_LOADRADIO: if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { SwitchToNewScreen(MENUPAGE_SOUND_SETTINGS); - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); OutputDebugString("STARTED PLAYING FRONTEND AUDIO TRACK"); } break; @@ -4825,7 +4825,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); DMAudio.SetRadioInCar(m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); SaveSettings(); } else if (m_nCurrScreen == MENUPAGE_DISPLAY_SETTINGS) { m_PrefsBrightness = DEFAULT_BRIGHTNESS; diff --git a/src/core/FrontendTriggers.h b/src/core/FrontendTriggers.h index b2bde09c..bbafb4be 100644 --- a/src/core/FrontendTriggers.h +++ b/src/core/FrontendTriggers.h @@ -779,7 +779,7 @@ TriggerAudio_RadioStation(CMenuMultiChoicePicturedTriggered *widget) if ( CMenuManager::m_PrefsRadioStation != widget->GetMenuSelection() ) { CMenuManager::m_PrefsRadioStation = widget->GetMenuSelection(); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, TRUE); DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); } } diff --git a/src/core/Frontend_PS2.cpp b/src/core/Frontend_PS2.cpp index c0fcc652..c635c21f 100644 --- a/src/core/Frontend_PS2.cpp +++ b/src/core/Frontend_PS2.cpp @@ -2858,7 +2858,7 @@ CMenuManager::ProcessDPadCrossJustDown(void) { if ( !gMusicPlaying ) { - DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, TRUE); gMusicPlaying = true; } } diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 8dee29e2..49e9c0da 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -580,7 +580,7 @@ bool CGame::Initialise(const char* datFile) #endif - DMAudio.SetStartingTrackPositions(true); + DMAudio.SetStartingTrackPositions(TRUE); DMAudio.ChangeMusicMode(MUSICMODE_GAME); return true; } diff --git a/src/core/World.cpp b/src/core/World.cpp index 9ea999dc..9e7a6fc4 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -65,7 +65,7 @@ CWorld::Initialise() void CWorld::Add(CEntity *ent) { - if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, true); + if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, TRUE); if(ent->bIsBIGBuilding) ms_bigBuildingsList[ent->m_level].InsertItem(ent); @@ -80,7 +80,7 @@ CWorld::Add(CEntity *ent) void CWorld::Remove(CEntity *ent) { - if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, false); + if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, FALSE); if(ent->bIsBIGBuilding) ms_bigBuildingsList[ent->m_level].RemoveItem(ent); -- cgit v1.2.3 From 60bb16d26c720bc9f122824f6cdb373e2c359e2d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 23 May 2021 16:47:16 +0300 Subject: Increase the number of audio channels to PS2 count and some small audio fixes --- src/core/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index d5b21713..edc9ad49 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -131,7 +131,6 @@ enum Config { NUM_PED_COMMENTS_SLOTS = 20, NUM_SOUNDS_SAMPLES_BANKS = 2, - NUM_SOUNDS_SAMPLES_SLOTS = 27, NUM_AUDIOENTITIES = 250, NUM_AUDIO_REFLECTIONS = 8, @@ -400,6 +399,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually // Audio #define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS //#define AUDIO_CACHE // cache sound lengths to speed up the cold boot +#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 43 (PC has 28 originally) //#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) //#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 -- cgit v1.2.3 From fb03ee45b5adbab6c59aa56f98992c69e0ade4b4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 23 May 2021 17:14:12 +0300 Subject: Undef PS2_AUDIO_CHANNELS for SQUEEZE_PERFORMANCE and VANILLA_DEFINES # Conflicts: # src/core/config.h --- src/core/config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index edc9ad49..cdc91dc0 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -427,6 +427,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #ifdef SQUEEZE_PERFORMANCE #undef PS2_ALPHA_TEST #undef NO_ISLAND_LOADING + #undef PS2_AUDIO_CHANNELS #endif // ------- @@ -515,6 +516,6 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef IMPROVED_CAMERA #undef FREE_CAM #undef BIG_IMG - +#undef PS2_AUDIO_CHANNELS #undef RADIO_SCROLL_TO_PREV_STATION #endif -- cgit v1.2.3 From e014bb5359ae464f14a413dd5ee98f0b5a385f67 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 23 May 2021 17:55:55 +0200 Subject: CEntity done; C(Vu)Vector fixes and cleanup --- src/core/Camera.cpp | 9 ++------- src/core/Camera.h | 6 +----- src/core/References.cpp | 2 -- src/core/World.cpp | 47 ++++++++++++++++++++++++++--------------------- src/core/World.h | 1 + src/core/common.h | 6 ++++++ 6 files changed, 36 insertions(+), 35 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 373ede7d..35d4ea7d 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -4103,16 +4103,11 @@ CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat bool CCamera::IsSphereVisible(const CVector ¢er, float radius) { - CMatrix mat = m_cameraMatrix; - return IsSphereVisible(center, radius, &mat); + return IsSphereVisible(center, radius, &m_cameraMatrix); } bool -#ifdef GTA_PS2 -CCamera::IsBoxVisible(CVuVector *box, const CMatrix *mat) -#else -CCamera::IsBoxVisible(CVector *box, const CMatrix *mat) -#endif +CCamera::IsBoxVisible(CVUVECTOR *box, const CMatrix *mat) { int i; int frustumTests[6] = { 0 }; diff --git a/src/core/Camera.h b/src/core/Camera.h index 9354e8ed..66a89f21 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -634,11 +634,7 @@ public: bool IsPointVisible(const CVector ¢er, const CMatrix *mat); bool IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat); bool IsSphereVisible(const CVector ¢er, float radius); -#ifdef GTA_PS2 - bool IsBoxVisible(CVuVector *box, const CMatrix *mat); -#else - bool IsBoxVisible(CVector *box, const CMatrix *mat); -#endif + bool IsBoxVisible(CVUVECTOR *box, const CMatrix *mat); }; VALIDATE_SIZE(CCamera, 0xE9D8); diff --git a/src/core/References.cpp b/src/core/References.cpp index dc83d96d..09913817 100644 --- a/src/core/References.cpp +++ b/src/core/References.cpp @@ -39,9 +39,7 @@ CEntity::RegisterReference(CEntity **pent) ref->pentity = pent; ref->next = m_pFirstReference; m_pFirstReference = ref; - return; } - return; } // Clean up the reference from *pent -> 'this' diff --git a/src/core/World.cpp b/src/core/World.cpp index 9e7a6fc4..9e2c4345 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1906,16 +1906,7 @@ CWorld::Process(void) for(int i = 0; i < NUMCUTSCENEOBJECTS; i++) { CCutsceneObject *csObj = CCutsceneMgr::GetCutsceneObject(i); if(csObj && csObj->m_entryInfoList.first) { - if(csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP && - RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) { - if (csObj->IsObject()) - RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), CTimer::GetTimeStepNonClippedInSeconds()); - else { - if (!csObj->bOffscreen) - csObj->bOffscreen = !csObj->GetIsOnScreen(); - RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), CTimer::GetTimeStepInSeconds(), !csObj->bOffscreen); - } - } + csObj->UpdateAnim(); csObj->ProcessControl(); csObj->ProcessCollision(); csObj->GetMatrix().UpdateRW(); @@ -1927,26 +1918,40 @@ CWorld::Process(void) } else { for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { CEntity *movingEnt = (CEntity *)node->item; - if(!movingEnt->bRemoveFromWorld && movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP && - RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { - if (movingEnt->IsObject()) - RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), CTimer::GetTimeStepNonClippedInSeconds()); - else { - if (!movingEnt->bOffscreen) - movingEnt->bOffscreen = !movingEnt->GetIsOnScreen(); - RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), CTimer::GetTimeStepInSeconds(), !movingEnt->bOffscreen); - } - } + if(!movingEnt->bRemoveFromWorld) + movingEnt->UpdateAnim(); } for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { CPhysical *movingEnt = (CPhysical *)node->item; if(movingEnt->bRemoveFromWorld) { RemoveEntityInsteadOfProcessingIt(movingEnt); } else { - movingEnt->ProcessControl(); + if(!CCutsceneMgr::IsCutsceneProcessing() || movingEnt->UpdatesInCutscene()) + movingEnt->ProcessControl(); if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); } } } + for(int y = 0; y < NUMSECTORS_Y; y++) + for(int x = 0; x < NUMSECTORS_X; x++){ + CPtrNode *node; + CSector *sect = CWorld::GetSector(x, y); + for(node = sect->m_lists[ENTITYLIST_PEDS].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + for(node = sect->m_lists[ENTITYLIST_PEDS_OVERLAP].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + for(node = sect->m_lists[ENTITYLIST_VEHICLES].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + for(node = sect->m_lists[ENTITYLIST_VEHICLES_OVERLAP].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + for(node = sect->m_lists[ENTITYLIST_OBJECTS].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + for(node = sect->m_lists[ENTITYLIST_OBJECTS_OVERLAP].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + for(node = sect->m_lists[ENTITYLIST_DUMMIES].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + for(node = sect->m_lists[ENTITYLIST_DUMMIES_OVERLAP].first; node; node = node->next) + ((CEntity*)node->item)->UpdateDistanceFade(); + } bForceProcessControl = true; for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { CPhysical *movingEnt = (CPhysical *)node->item; diff --git a/src/core/World.h b/src/core/World.h index b75b6a6c..c90bb3a1 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -29,6 +29,7 @@ enum { ENTITYLIST_BUILDINGS, ENTITYLIST_BUILDINGS_OVERLAP, + ENTITYLIST_UNKNOWN, ENTITYLIST_OBJECTS, ENTITYLIST_OBJECTS_OVERLAP, ENTITYLIST_VEHICLES, diff --git a/src/core/common.h b/src/core/common.h index 268bc836..51170986 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -228,6 +228,12 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #include "maths.h" #include "Vector.h" +#ifdef GTA_PS2 +#include "VuVector.h" +#define CVUVECTOR CVuVector +#else +#define CVUVECTOR CVector +#endif #include "Vector2D.h" #include "Matrix.h" #include "Rect.h" -- cgit v1.2.3 From 1558788df122d9c8df23a8127572d4bfcf68ca15 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Jun 2021 13:00:45 +0300 Subject: Fix IsSphereVisible calls --- src/core/Camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 35d4ea7d..987efe04 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -4103,7 +4103,7 @@ CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat bool CCamera::IsSphereVisible(const CVector ¢er, float radius) { - return IsSphereVisible(center, radius, &m_cameraMatrix); + return IsSphereVisible(center, radius, &GetCameraMatrix()); } bool -- cgit v1.2.3 From 3aac4ea62aaa4b2c032ebc446bc0a729b9cc0572 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Jun 2021 13:03:14 +0300 Subject: Fix sin & cos calls --- src/core/Cam.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 4895ef6e..c741081f 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -4956,9 +4956,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, AlphaSpeed = 0.0; Distance = 1000.0; - Front.x = -(cos(Beta) * cos(Alpha)); - Front.y = -(sin(Beta) * cos(Alpha)); - Front.z = sin(Alpha); + Front.x = -(Cos(Beta) * Cos(Alpha)); + Front.y = -(Sin(Beta) * Cos(Alpha)); + Front.z = Sin(Alpha); m_aTargetHistoryPosOne = TargetCoors - nextDistance * Front; @@ -5232,9 +5232,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, lastBeta = Beta; - Front.x = -(cos(Beta) * cos(Alpha)); - Front.y = -(sin(Beta) * cos(Alpha)); - Front.z = sin(Alpha); + Front.x = -(Cos(Beta) * Cos(Alpha)); + Front.y = -(Sin(Beta) * Cos(Alpha)); + Front.z = Sin(Alpha); GetVectorsReadyForRW(); TheCamera.m_bCamDirectlyBehind = false; TheCamera.m_bCamDirectlyInFront = false; @@ -5244,9 +5244,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, m_cvecTargetCoorsForFudgeInter = TargetCoors; m_aTargetHistoryPosThree = m_aTargetHistoryPosOne; float nextAlpha = alphaWithSpeedAccounted + zoomModeAlphaOffset; - float nextFrontX = -(cos(Beta) * cos(nextAlpha)); - float nextFrontY = -(sin(Beta) * cos(nextAlpha)); - float nextFrontZ = sin(nextAlpha); + float nextFrontX = -(Cos(Beta) * Cos(nextAlpha)); + float nextFrontY = -(Sin(Beta) * Cos(nextAlpha)); + float nextFrontZ = Sin(nextAlpha); m_aTargetHistoryPosOne.x = TargetCoors.x - nextFrontX * nextDistance; m_aTargetHistoryPosOne.y = TargetCoors.y - nextFrontY * nextDistance; -- cgit v1.2.3 From 776e8ff2eeb96a068383f5802e0d86f56b69c1f0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 5 Jun 2021 13:13:27 +0300 Subject: Fix some timer calls --- src/core/Cam.cpp | 2 +- src/core/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index c741081f..56409af4 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -5399,7 +5399,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, float alphaToFace = Atan2(hi.z, hi.Magnitude2D()) + DEGTORAD(15.0f); float neededAlphaTurn = alphaToFace - carGunUD; - float alphaTurnPerFrame = CTimer::GetTimeStep() * 0.02f; + float alphaTurnPerFrame = CTimer::GetTimeStepInSeconds(); if (neededAlphaTurn > alphaTurnPerFrame) { neededTurn = alphaTurnPerFrame; diff --git a/src/core/main.cpp b/src/core/main.cpp index e8188cec..8267a1b2 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1149,7 +1149,7 @@ DisplayGameDebugText() FramesPerSecondCounter += frameTime / 1000.f; // convert to seconds FramesPerSecond = FrameSamples / FramesPerSecondCounter; #else - FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f); + FramesPerSecondCounter += 1000.0f / CTimer::GetTimeStepNonClippedInMilliseconds(); FramesPerSecond = FramesPerSecondCounter / FrameSamples; #endif -- cgit v1.2.3 From 74867af2e73b8cbbef97ff9395c3b0b157ec79ee Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 24 Jun 2021 21:50:09 +0300 Subject: Fixes --- src/core/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index cdc91dc0..7b8a15d4 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -399,7 +399,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually // Audio #define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS //#define AUDIO_CACHE // cache sound lengths to speed up the cold boot -#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 43 (PC has 28 originally) +#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 41 (PSP and mobile have 21 originally) //#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) //#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 -- cgit v1.2.3 From 14c71f39ff97684e6c6933cf18781e8d162d1be6 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 24 Jun 2021 13:47:10 +0300 Subject: High FPS Fixes --- src/core/Frontend.cpp | 34 ++++++++++---------- src/core/Frontend.h | 2 +- src/core/Radar.cpp | 4 +-- src/core/Timer.cpp | 86 +++++++++++++++++++++++++++++++++++++++------------ src/core/Timer.h | 20 +++++------- src/core/main.cpp | 7 +++-- 6 files changed, 100 insertions(+), 53 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 798c1d8b..2160d8ce 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -181,7 +181,7 @@ const char* FrontendFilenames[][2] = { #ifdef XBOX_MESSAGE_SCREEN bool CMenuManager::m_bDialogOpen = false; uint32 CMenuManager::m_nDialogHideTimer = 0; -PauseModeTime CMenuManager::m_nDialogHideTimerPauseMode = 0; +uint32 CMenuManager::m_nDialogHideTimerPauseMode = 0; bool CMenuManager::m_bSaveWasSuccessful = false; wchar* CMenuManager::m_pDialogText = nil; #endif @@ -750,7 +750,7 @@ CMenuManager::DisplayHelperText(char *text) return; // there was a unused static bool - static PauseModeTime LastFlash = 0; + static uint32 LastFlash = 0; int32 alpha = 255; CFont::SetRightJustifyOn(); @@ -1425,7 +1425,7 @@ CMenuManager::DrawStandardMenus(bool activeScreen) } } - static PauseModeTime lastBlendChange = 0; + static uint32 lastBlendChange = 0; if (m_nOptionHighlightTransitionBlend <= 255) { static uint32 blendChangeCounter = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastBlendChange > 20 @@ -1928,7 +1928,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 CFont::PrintString(nextX, nextY, seperator); nextX += CFont::GetStringWidth(seperator, true) + bindingMargin; } - static PauseModeTime lastWaitingTextFlash = 0; + static uint32 lastWaitingTextFlash = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastWaitingTextFlash > 150) { showWaitingText = !showWaitingText; lastWaitingTextFlash = CTimer::GetTimeInMillisecondsPauseMode(); @@ -1993,7 +1993,7 @@ CMenuManager::DrawControllerScreenExtraText(int yStart, int xStart, int lineHeig CFont::PrintString(nextX, MENU_Y(yStart), TheText.Get("FEC_IBT")); nextX = CFont::GetStringWidth(TheText.Get("FEC_IBT"), true) + spacing + nextX; } - static PauseModeTime lastStateChange = 0; + static uint32 lastStateChange = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastStateChange > 150) { waitingTextVisible = !waitingTextVisible; lastStateChange = CTimer::GetTimeInMillisecondsPauseMode(); @@ -2377,7 +2377,7 @@ CMenuManager::DrawBackground(bool transitionCall) m_nOptionHighlightTransitionBlend = 0; } - static PauseModeTime LastFade = 0; + static uint32 LastFade = 0; if (m_nMenuFadeAlpha < 255) { static uint8 forceFadeInCounter = 0; @@ -2448,7 +2448,7 @@ CMenuManager::DrawBackground(bool transitionCall) } if (m_ShowEmptyBindingError) { - static PauseModeTime lastBindingError = CTimer::GetTimeInMillisecondsPauseMode(); + static uint32 lastBindingError = CTimer::GetTimeInMillisecondsPauseMode(); static bool bindingErrorShown = false; if (bindingErrorShown) { lastBindingError = CTimer::GetTimeInMillisecondsPauseMode(); @@ -3332,7 +3332,7 @@ CMenuManager::PrintStats() else CFont::SetScale(MENU_X(0.37f), MENU_Y(0.75f)); - static PauseModeTime lastCheck = 0; + static uint32 lastCheck = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastCheck > 40) { @@ -3473,7 +3473,7 @@ CMenuManager::AdditionalOptionInput(bool &goBack) switch (m_nCurrScreen) { case MENUPAGE_MAP: { - static PauseModeTime lastMapTick = 0; + static uint32 lastMapTick = 0; // FIX: All those macros were hardcoded values originally. @@ -3802,7 +3802,7 @@ CMenuManager::ExportStats() void CMenuManager::PrintRadioSelector(void) { - static PauseModeTime lastRadioChange = 0; + static uint32 lastRadioChange = 0; CSprite2d::Draw2DPolygon(MENU_X_LEFT_ALIGNED(418.f), MENU_Y(MENURADIO_SELECTOR_START_Y + MENURADIO_SELECTOR_HEIGHT), MENU_X_LEFT_ALIGNED(228.f), MENU_Y(MENURADIO_SELECTOR_START_Y + MENURADIO_SELECTOR_HEIGHT), @@ -3925,7 +3925,7 @@ CMenuManager::PrintRadioSelector(void) #endif static bool radioChangeRequested = false; - static PauseModeTime lastScrollCheck = 0; + static uint32 lastScrollCheck = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastScrollCheck > 17) { if (m_ScrollRadioBy == 1) { if (m_LeftMostRadioX > MENU_X_LEFT_ALIGNED(MENURADIO_ICON_FIRST_X - MENURADIO_ICON_SIZE)) { @@ -4009,7 +4009,7 @@ CMenuManager::ProcessList(bool &optionSelected, bool &goBack) field_159 = false; } - static PauseModeTime lastTimeClickedScrollButton = 0; + static uint32 lastTimeClickedScrollButton = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastTimeClickedScrollButton >= 200) { m_bPressedPgUpOnList = false; @@ -4395,7 +4395,7 @@ CMenuManager::UserInput(void) int curAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; if (CPad::GetPad(0)->GetLeft() || CPad::GetPad(0)->GetPedWalkLeftRight() < 0 || CPad::GetPad(0)->GetDPadLeft()) { - static PauseModeTime lastSliderDecrease = 0; + static uint32 lastSliderDecrease = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderDecrease > 150) { if (curAction == MENUACTION_BRIGHTNESS || curAction == MENUACTION_MUSICVOLUME || curAction == MENUACTION_SFXVOLUME || curAction == MENUACTION_RADIO || @@ -4406,7 +4406,7 @@ CMenuManager::UserInput(void) lastSliderDecrease = CTimer::GetTimeInMillisecondsPauseMode(); } } else if (CPad::GetPad(0)->GetRight() || CPad::GetPad(0)->GetPedWalkLeftRight() > 0 || CPad::GetPad(0)->GetDPadRight()) { - static PauseModeTime lastSliderIncrease = 0; + static uint32 lastSliderIncrease = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderIncrease > 150) { if (curAction == MENUACTION_BRIGHTNESS || curAction == MENUACTION_MUSICVOLUME || curAction == MENUACTION_SFXVOLUME || curAction == MENUACTION_RADIO || @@ -5396,7 +5396,7 @@ CMenuManager::ProcessFileActions() { #ifdef XBOX_MESSAGE_SCREEN if (m_bDialogOpen && DialogTextCmp("FESZ_WR")) { - PauseModeTime startTime = CTimer::GetTimeInMillisecondsPauseMode(); + uint32 startTime = CTimer::GetTimeInMillisecondsPauseMode(); int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); PcSaveHelper.PopulateSlotInfo(); @@ -5654,13 +5654,13 @@ CMenuManager::DrawQuitGameScreen(void) #endif #ifndef MUCH_SHORTER_OUTRO_SCREEN - static PauseModeTime lastTickIncrease = 0; + static uint32 lastTickIncrease = 0; if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - lastTickIncrease > 10) { exitSignalTimer++; lastTickIncrease = CTimer::GetTimeInMillisecondsPauseMode(); } #else - static PauseModeTime firstTick = CTimer::GetTimeInMillisecondsPauseMode(); + static uint32 firstTick = CTimer::GetTimeInMillisecondsPauseMode(); if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - firstTick > 750) { exitSignalTimer = 150; } diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 112ea7ad..b4e70613 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -735,7 +735,7 @@ public: #ifdef XBOX_MESSAGE_SCREEN static uint32 m_nDialogHideTimer; - static PauseModeTime m_nDialogHideTimerPauseMode; + static uint32 m_nDialogHideTimerPauseMode; static bool m_bDialogOpen; static wchar *m_pDialogText; static bool m_bSaveWasSuccessful; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index ec3335fa..fadca215 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1382,7 +1382,7 @@ CRadar::InitFrontEndMap() void CRadar::DrawYouAreHereSprite(float x, float y) { - static PauseModeTime lastChange = 0; + static uint32 lastChange = 0; static bool show = true; if (show) { @@ -1582,7 +1582,7 @@ void CRadar::DrawLegend(int32 x, int32 y, int32 sprite) { if (sprite < 0) { - static PauseModeTime lastChange = 0; + static uint32 lastChange = 0; static int8 blipMode = 0; CRGBA color; diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index 5ebe3f53..ac897da6 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -8,7 +8,7 @@ #include "SpecialFX.h" uint32 CTimer::m_snTimeInMilliseconds; -PauseModeTime CTimer::m_snTimeInMillisecondsPauseMode = 1; +uint32 CTimer::m_snTimeInMillisecondsPauseMode = 1; uint32 CTimer::m_snTimeInMillisecondsNonClipped; uint32 CTimer::m_snPreviousTimeInMilliseconds; @@ -17,7 +17,11 @@ float CTimer::ms_fTimeScale; float CTimer::ms_fTimeStep; float CTimer::ms_fTimeStepNonClipped; bool CTimer::m_UserPause; -bool CTimer::m_CodePause; +bool CTimer::m_CodePause; +#ifdef FIX_BUGS +uint32 CTimer::m_LogicalFrameCounter; +uint32 CTimer::m_LogicalFramesPassed; +#endif uint32 _nCyclesPerMS = 1; @@ -35,10 +39,6 @@ RsTimerType suspendPcTimer; uint32 suspendDepth; -#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND -double frameTime; -#endif - void CTimer::Initialise(void) { debug("Initialising CTimer...\n"); @@ -51,6 +51,10 @@ void CTimer::Initialise(void) m_snTimeInMillisecondsNonClipped = 0; m_snPreviousTimeInMilliseconds = 0; m_snTimeInMilliseconds = 1; +#ifdef FIX_BUGS + m_LogicalFrameCounter = 0; + m_LogicalFramesPassed = 0; +#endif #ifdef _WIN32 LARGE_INTEGER perfFreq; @@ -83,7 +87,13 @@ void CTimer::Shutdown(void) } void CTimer::Update(void) -{ +{ +#ifdef FIX_BUGS + static double frameTimeLogical = 0.0; + static double frameTimeFraction = 0.0; + static double frameTimeFractionScaled = 0.0; +#endif + m_snPreviousTimeInMilliseconds = m_snTimeInMilliseconds; #ifdef _WIN32 @@ -98,22 +108,43 @@ void CTimer::Update(void) float updInCyclesScaled = GetIsPaused() ? updInCycles : updInCycles * ms_fTimeScale; - // We need that real frame time to fix transparent menu bug. -#ifndef FIX_HIGH_FPS_BUGS_ON_FRONTEND - double -#endif - frameTime = updInCyclesScaled / (double)_nCyclesPerMS; + double frameTime = updInCyclesScaled / (double)_nCyclesPerMS; + +#ifdef FIX_BUGS + // count frames as if we're running at 30 fps + m_LogicalFramesPassed = 0; + frameTimeLogical += ((double)updInCycles / (double)_nCyclesPerMS); + while (frameTimeLogical >= 1000.0 / 30.0) { + frameTimeLogical -= 1000.0 / 30.0; + m_LogicalFramesPassed++; + } + m_LogicalFrameCounter += m_LogicalFramesPassed; + + frameTimeFraction += (double)updInCycles / (double)_nCyclesPerMS; + frameTimeFractionScaled += frameTime; + m_snTimeInMillisecondsPauseMode += uint32(frameTimeFraction); +#else m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; +#endif if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { +#ifdef FIX_BUGS + m_snTimeInMilliseconds += uint32(frameTimeFractionScaled); + m_snTimeInMillisecondsNonClipped += uint32(frameTimeFractionScaled); +#else m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; +#endif ms_fTimeStep = frameTime / 1000.0f * 50.0f; } +#ifdef FIX_BUGS + frameTimeFraction -= uint32(frameTimeFraction); + frameTimeFractionScaled -= uint32(frameTimeFractionScaled); +#endif } else #endif @@ -122,22 +153,39 @@ void CTimer::Update(void) RsTimerType updInMs = timer - oldPcTimer; - // We need that real frame time to fix transparent menu bug. -#ifndef FIX_HIGH_FPS_BUGS_ON_FRONTEND - double -#endif - frameTime = (double)updInMs * ms_fTimeScale; + double frameTime = (double)updInMs * ms_fTimeScale; oldPcTimer = timer; - + +#ifdef FIX_BUGS + // count frames as if we're running at 30 fps + m_LogicalFramesPassed = 0; + frameTimeLogical += (double)updInMs; + while(frameTimeLogical >= 1000.0 / 30.0) { + frameTimeLogical -= 1000.0 / 30.0; + m_LogicalFramesPassed++; + } + m_LogicalFrameCounter += m_LogicalFramesPassed; + + frameTimeFraction += (double)updInMs; + frameTimeFractionScaled += frameTime; + + m_snTimeInMillisecondsPauseMode += uint32(frameTimeFraction); +#else m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; - +#endif + if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { +#ifdef FIX_BUGS + m_snTimeInMilliseconds += uint32(frameTimeFractionScaled); + m_snTimeInMillisecondsNonClipped += uint32(frameTimeFractionScaled); +#else m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; +#endif ms_fTimeStep = frameTime / 1000.0f * 50.0f; } } diff --git a/src/core/Timer.h b/src/core/Timer.h index 53591c4f..819bd30c 100644 --- a/src/core/Timer.h +++ b/src/core/Timer.h @@ -1,22 +1,20 @@ #pragma once -#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND -#define PauseModeTime double -#else -#define PauseModeTime uint32 -#endif - class CTimer { static uint32 m_snTimeInMilliseconds; - static PauseModeTime m_snTimeInMillisecondsPauseMode; + static uint32 m_snTimeInMillisecondsPauseMode; static uint32 m_snTimeInMillisecondsNonClipped; static uint32 m_snPreviousTimeInMilliseconds; static uint32 m_FrameCounter; static float ms_fTimeScale; static float ms_fTimeStep; static float ms_fTimeStepNonClipped; +#ifdef FIX_BUGS + static uint32 m_LogicalFrameCounter; + static uint32 m_LogicalFramesPassed; +#endif public: static bool m_UserPause; static bool m_CodePause; @@ -35,7 +33,7 @@ public: static void SetTimeInMilliseconds(uint32 t) { m_snTimeInMilliseconds = t; } static uint32 GetTimeInMillisecondsNonClipped(void) { return m_snTimeInMillisecondsNonClipped; } static void SetTimeInMillisecondsNonClipped(uint32 t) { m_snTimeInMillisecondsNonClipped = t; } - static PauseModeTime GetTimeInMillisecondsPauseMode(void) { return m_snTimeInMillisecondsPauseMode; } + static uint32 GetTimeInMillisecondsPauseMode(void) { return m_snTimeInMillisecondsPauseMode; } static void SetTimeInMillisecondsPauseMode(uint32 t) { m_snTimeInMillisecondsPauseMode = t; } static uint32 GetPreviousTimeInMilliseconds(void) { return m_snPreviousTimeInMilliseconds; } static void SetPreviousTimeInMilliseconds(uint32 t) { m_snPreviousTimeInMilliseconds = t; } @@ -67,9 +65,7 @@ public: #ifdef FIX_BUGS static float GetDefaultTimeStep(void) { return 50.0f / 30.0f; } static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); } + static uint32 GetLogicalFrameCounter(void) { return m_LogicalFrameCounter; } + static uint32 GetLogicalFramesPassed(void) { return m_LogicalFramesPassed; } #endif }; - -#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND -extern double frameTime; -#endif diff --git a/src/core/main.cpp b/src/core/main.cpp index 90efdb62..4902c156 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1131,8 +1131,11 @@ DisplayGameDebugText() #endif // #ifdef DRAW_GAME_VERSION_TEXT FrameSamples++; -#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND - FramesPerSecondCounter += frameTime / 1000.f; // convert to seconds +#ifdef FIX_BUGS + // this is inaccurate with over 1000 fps + static uint32 PreviousTimeInMillisecondsPauseMode = 0; + FramesPerSecondCounter += (CTimer::GetTimeInMillisecondsPauseMode() - PreviousTimeInMillisecondsPauseMode) / 1000.0f; // convert to seconds + PreviousTimeInMillisecondsPauseMode = CTimer::GetTimeInMillisecondsPauseMode(); FramesPerSecond = FrameSamples / FramesPerSecondCounter; #else FramesPerSecondCounter += 1000.0f / CTimer::GetTimeStepNonClippedInMilliseconds(); -- cgit v1.2.3 From e5aa150557e44466158a680216102adf687e1f0b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 24 Jun 2021 21:19:12 +0300 Subject: Frontend fix --- src/core/Frontend.cpp | 15 +++++++++++---- src/core/config.h | 2 -- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 2160d8ce..190cdf32 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1429,15 +1429,17 @@ CMenuManager::DrawStandardMenus(bool activeScreen) if (m_nOptionHighlightTransitionBlend <= 255) { static uint32 blendChangeCounter = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastBlendChange > 20 -#ifndef FIX_HIGH_FPS_BUGS_ON_FRONTEND // Dirty dirty hack || blendChangeCounter > 20 -#endif ) { m_nOptionHighlightTransitionBlend += 50; lastBlendChange = CTimer::GetTimeInMillisecondsPauseMode(); blendChangeCounter = 0; } +#ifdef FIX_BUGS + blendChangeCounter += CTimer::GetLogicalFramesPassed(); +#else ++blendChangeCounter; +#endif } } @@ -2382,17 +2384,22 @@ CMenuManager::DrawBackground(bool transitionCall) if (m_nMenuFadeAlpha < 255) { static uint8 forceFadeInCounter = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - LastFade > 30 -#ifndef FIX_HIGH_FPS_BUGS_ON_FRONTEND // Dirty dirty hack || forceFadeInCounter > 30 -#endif ) { m_nMenuFadeAlpha += 20; if (m_firstStartCounter < 255) { m_firstStartCounter = Min(m_firstStartCounter + 20, 255); } LastFade = CTimer::GetTimeInMillisecondsPauseMode(); +#ifdef FIX_BUGS + forceFadeInCounter = 0; +#endif } +#ifdef FIX_BUGS + forceFadeInCounter += CTimer::GetLogicalFramesPassed(); +#else forceFadeInCounter++; +#endif } else if (m_nMenuFadeAlpha > 255) m_nMenuFadeAlpha = 255; diff --git a/src/core/config.h b/src/core/config.h index f8e63d31..006ebad5 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -247,7 +247,6 @@ enum Config { #define MORE_LANGUAGES // Add more translations to the game #define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible #define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS -#define FIX_HIGH_FPS_BUGS_ON_FRONTEND #define NO_MOVIES // add option to disable intro videos @@ -453,7 +452,6 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef MORE_LANGUAGES #undef COMPATIBLE_SAVES #undef LOAD_INI_SETTINGS -#undef FIX_HIGH_FPS_BUGS_ON_FRONTEND #undef ASPECT_RATIO_SCALE #undef PROPER_SCALING -- cgit v1.2.3 From 4660491243048d22fc22f01becc08ffcd327a6cc Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Jun 2021 02:22:07 +0300 Subject: Timer fix --- src/core/Timer.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core') diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index ac897da6..b0947d65 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -188,6 +188,10 @@ void CTimer::Update(void) #endif ms_fTimeStep = frameTime / 1000.0f * 50.0f; } +#ifdef FIX_BUGS + frameTimeFraction -= uint32(frameTimeFraction); + frameTimeFractionScaled -= uint32(frameTimeFractionScaled); +#endif } if ( ms_fTimeStep < 0.01f && !GetIsPaused() && !CSpecialFX::bSnapShotActive) -- cgit v1.2.3 From f46461331ca96cc894020a559b0a9642ebd2f53d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Jun 2021 02:40:56 +0300 Subject: Refactor CTimer::Update --- src/core/Timer.cpp | 133 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 50 deletions(-) (limited to 'src/core') diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index b0947d65..77f26a8b 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -86,13 +86,14 @@ void CTimer::Shutdown(void) ; } +#ifdef FIX_BUGS void CTimer::Update(void) { -#ifdef FIX_BUGS static double frameTimeLogical = 0.0; static double frameTimeFraction = 0.0; static double frameTimeFractionScaled = 0.0; -#endif + double frameTime; + double dblUpdInMs; m_snPreviousTimeInMilliseconds = m_snTimeInMilliseconds; @@ -108,43 +109,99 @@ void CTimer::Update(void) float updInCyclesScaled = GetIsPaused() ? updInCycles : updInCycles * ms_fTimeScale; - double frameTime = updInCyclesScaled / (double)_nCyclesPerMS; + frameTime = updInCyclesScaled / (double)_nCyclesPerMS; -#ifdef FIX_BUGS - // count frames as if we're running at 30 fps - m_LogicalFramesPassed = 0; - frameTimeLogical += ((double)updInCycles / (double)_nCyclesPerMS); - while (frameTimeLogical >= 1000.0 / 30.0) { - frameTimeLogical -= 1000.0 / 30.0; - m_LogicalFramesPassed++; - } - m_LogicalFrameCounter += m_LogicalFramesPassed; + dblUpdInMs = (double)updInCycles / (double)_nCyclesPerMS; + } + else +#endif + { + RsTimerType timer = RsTimer(); + + RsTimerType updInMs = timer - oldPcTimer; + + frameTime = (double)updInMs * ms_fTimeScale; + + oldPcTimer = timer; + + dblUpdInMs = (double)updInMs; + } + + // count frames as if we're running at 30 fps + m_LogicalFramesPassed = 0; + frameTimeLogical += dblUpdInMs; + while (frameTimeLogical >= 1000.0 / 30.0) { + frameTimeLogical -= 1000.0 / 30.0; + m_LogicalFramesPassed++; + } + m_LogicalFrameCounter += m_LogicalFramesPassed; - frameTimeFraction += (double)updInCycles / (double)_nCyclesPerMS; - frameTimeFractionScaled += frameTime; + frameTimeFraction += dblUpdInMs; + frameTimeFractionScaled += frameTime; - m_snTimeInMillisecondsPauseMode += uint32(frameTimeFraction); + m_snTimeInMillisecondsPauseMode += uint32(frameTimeFraction); + + if ( GetIsPaused() ) + ms_fTimeStep = 0.0f; + else + { + m_snTimeInMilliseconds += uint32(frameTimeFractionScaled); + m_snTimeInMillisecondsNonClipped += uint32(frameTimeFractionScaled); + ms_fTimeStep = frameTime / 1000.0f * 50.0f; + } + frameTimeFraction -= uint32(frameTimeFraction); + frameTimeFractionScaled -= uint32(frameTimeFractionScaled); + + if ( ms_fTimeStep < 0.01f && !GetIsPaused() && !CSpecialFX::bSnapShotActive) + ms_fTimeStep = 0.01f; + + ms_fTimeStepNonClipped = ms_fTimeStep; + + if ( !CRecordDataForGame::IsPlayingBack() ) + { + ms_fTimeStep = Min(3.0f, ms_fTimeStep); + + if ( (m_snTimeInMilliseconds - m_snPreviousTimeInMilliseconds) > 60 ) + m_snTimeInMilliseconds = m_snPreviousTimeInMilliseconds + 60; + } + + if ( CRecordDataForChase::IsRecording() ) + { + ms_fTimeStep = 1.0f; + m_snTimeInMilliseconds = m_snPreviousTimeInMilliseconds + 16; + } + + m_FrameCounter++; +} #else +void CTimer::Update(void) +{ + m_snPreviousTimeInMilliseconds = m_snTimeInMilliseconds; + +#ifdef _WIN32 + if ( (double)_nCyclesPerMS != 0.0 ) + { + LARGE_INTEGER pc; + QueryPerformanceCounter(&pc); + + int32 updInCycles = (pc.LowPart - _oldPerfCounter.LowPart); // & 0x7FFFFFFF; pointless + + _oldPerfCounter = pc; + + float updInCyclesScaled = GetIsPaused() ? updInCycles : updInCycles * ms_fTimeScale; + + double frameTime = updInCyclesScaled / (double)_nCyclesPerMS; + m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; -#endif if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { -#ifdef FIX_BUGS - m_snTimeInMilliseconds += uint32(frameTimeFractionScaled); - m_snTimeInMillisecondsNonClipped += uint32(frameTimeFractionScaled); -#else m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; -#endif ms_fTimeStep = frameTime / 1000.0f * 50.0f; } -#ifdef FIX_BUGS - frameTimeFraction -= uint32(frameTimeFraction); - frameTimeFractionScaled -= uint32(frameTimeFractionScaled); -#endif } else #endif @@ -157,41 +214,16 @@ void CTimer::Update(void) oldPcTimer = timer; -#ifdef FIX_BUGS - // count frames as if we're running at 30 fps - m_LogicalFramesPassed = 0; - frameTimeLogical += (double)updInMs; - while(frameTimeLogical >= 1000.0 / 30.0) { - frameTimeLogical -= 1000.0 / 30.0; - m_LogicalFramesPassed++; - } - m_LogicalFrameCounter += m_LogicalFramesPassed; - - frameTimeFraction += (double)updInMs; - frameTimeFractionScaled += frameTime; - - m_snTimeInMillisecondsPauseMode += uint32(frameTimeFraction); -#else m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; -#endif if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { -#ifdef FIX_BUGS - m_snTimeInMilliseconds += uint32(frameTimeFractionScaled); - m_snTimeInMillisecondsNonClipped += uint32(frameTimeFractionScaled); -#else m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; -#endif ms_fTimeStep = frameTime / 1000.0f * 50.0f; } -#ifdef FIX_BUGS - frameTimeFraction -= uint32(frameTimeFraction); - frameTimeFractionScaled -= uint32(frameTimeFractionScaled); -#endif } if ( ms_fTimeStep < 0.01f && !GetIsPaused() && !CSpecialFX::bSnapShotActive) @@ -215,6 +247,7 @@ void CTimer::Update(void) m_FrameCounter++; } +#endif void CTimer::Suspend(void) { -- cgit v1.2.3