summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio/AudioManager.h2
-rw-r--r--src/audio/MusicManager.cpp10
-rw-r--r--src/audio/PolRadio.cpp (renamed from src/audio/PoliceRadio.cpp)2
-rw-r--r--src/audio/PolRadio.h (renamed from src/audio/PoliceRadio.h)0
-rw-r--r--src/audio/sampman_miles.cpp186
-rw-r--r--src/audio/sampman_oal.cpp177
-rw-r--r--src/control/CarCtrl.cpp2
-rw-r--r--src/control/Script8.cpp2
-rw-r--r--src/core/Frontend.cpp7
-rw-r--r--src/core/MenuScreensCustom.cpp37
-rw-r--r--src/core/Ropes.cpp3
-rw-r--r--src/core/config.h3
-rw-r--r--src/core/main.cpp23
-rw-r--r--src/core/main.h19
-rw-r--r--src/core/re3.cpp85
-rw-r--r--src/extras/postfx.cpp5
-rw-r--r--src/objects/Stinger.cpp6
-rw-r--r--src/render/Antennas.cpp4
-rw-r--r--src/render/Clouds.cpp13
-rw-r--r--src/render/Coronas.cpp8
-rw-r--r--src/render/Fluff.cpp2
-rw-r--r--src/render/Font.h20
-rw-r--r--src/render/Glass.cpp4
-rw-r--r--src/render/MBlur.cpp3
-rw-r--r--src/render/Particle.cpp5
-rw-r--r--src/render/PointLights.cpp4
-rw-r--r--src/render/Renderer.cpp33
-rw-r--r--src/render/Rubbish.cpp4
-rw-r--r--src/render/Shadows.cpp8
-rw-r--r--src/render/Skidmarks.cpp4
-rw-r--r--src/render/SpecialFX.cpp2
-rw-r--r--src/render/WaterCannon.cpp2
-rw-r--r--src/render/WaterLevel.cpp8
-rw-r--r--src/rw/RwHelper.cpp31
-rw-r--r--src/rw/RwHelper.h1
-rw-r--r--src/rw/VisibilityPlugins.cpp2
-rw-r--r--src/skel/glfw/glfw.cpp310
-rw-r--r--src/skel/win/win.cpp18
-rw-r--r--src/text/Text.cpp6
-rw-r--r--src/weapons/WeaponEffects.cpp5
40 files changed, 792 insertions, 274 deletions
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 2eb2220b..98a9b32d 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -2,7 +2,7 @@
#include "audio_enums.h"
#include "AudioCollision.h"
-#include "PoliceRadio.h"
+#include "PolRadio.h"
#include "VehicleModelInfo.h"
#include "Vehicle.h"
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index 34eae77c..e15bde94 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -1265,7 +1265,8 @@ cMusicManager::DisplayRadioStationName()
if (vehicle)
{
-#if defined RADIO_SCROLL_TO_PREV_STATION || defined FIX_BUGS // Because m_nFrontendTrack can have NO_TRACK
+ // Prev scroll needs it to be signed, and m_nFrontendTrack can be NO_TRACK thus FIX_BUGS
+#if defined RADIO_SCROLL_TO_PREV_STATION || defined FIX_BUGS
int track;
#else
uint8 track;
@@ -1281,13 +1282,16 @@ cMusicManager::DisplayRadioStationName()
#endif
while (track >= NUM_RADIOS + 1) track -= NUM_RADIOS + 1;
- // We already handle this condition while scrolling back, on key press. No need to change this.
+ // On scrolling back we handle this condition on key press. No need to change this.
if (!DMAudio.IsMP3RadioChannelAvailable() && track == USERTRACK)
gNumRetunePresses++;
}
else
+#ifdef RADIO_OFF_TEXT
+ track = GetCarTuning(); // gStreamedSound or veh->m_nRadioStation would also work, but these don't cover police/taxi radios
+#else
track = m_nFrontendTrack;
-
+#endif
wchar* string = nil;
switch (track) {
case WILDSTYLE: string = TheText.Get("FEA_FM0"); break;
diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PolRadio.cpp
index b8f44f60..17bf95e8 100644
--- a/src/audio/PoliceRadio.cpp
+++ b/src/audio/PolRadio.cpp
@@ -7,7 +7,7 @@
#include "AudioSamples.h"
#include "MusicManager.h"
#include "PlayerPed.h"
-#include "PoliceRadio.h"
+#include "PolRadio.h"
#include "Replay.h"
#include "Vehicle.h"
#include "World.h"
diff --git a/src/audio/PoliceRadio.h b/src/audio/PolRadio.h
index d7c928e2..d7c928e2 100644
--- a/src/audio/PoliceRadio.h
+++ b/src/audio/PolRadio.h
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index bf91a874..b115654a 100644
--- a/src/audio/sampman_miles.cpp
+++ b/src/audio/sampman_miles.cpp
@@ -2082,142 +2082,136 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
{
+ int i = 0;
uint32 position = nPos;
char filename[MAX_PATH];
- if ( m_bInitialised && nFile < TOTAL_STREAMED_SOUNDS )
+ if ( !m_bInitialised || nFile >= TOTAL_STREAMED_SOUNDS )
+ return false;
+
+ if ( mp3Stream[nStream] )
{
- if ( mp3Stream[nStream] )
- {
- AIL_pause_stream(mp3Stream[nStream], 1);
- AIL_close_stream(mp3Stream[nStream]);
- }
-
- if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ AIL_pause_stream(mp3Stream[nStream], 1);
+ AIL_close_stream(mp3Stream[nStream]);
+ }
+ if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ {
+ do
{
- uint32 i = 0;
- do {
- if(i != 0 || _bIsMp3Active) {
- if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
-
- _CurMP3Pos = 0;
-
- tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
-
- if(mp3) {
- mp3 = _pMP3List;
- if(mp3 == NULL) {
- _bIsMp3Active = false;
- nFile = 0;
- strcpy(filename, m_MiscomPath);
- strcat(filename, StreamedNameTable[nFile]);
-
- mp3Stream[nStream] =
- AIL_open_stream(DIG, filename, 0);
- if(mp3Stream[nStream]) {
- AIL_set_stream_loop_count(
- mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- AIL_set_stream_ms_position(
- mp3Stream[nStream], position);
- AIL_pause_stream(mp3Stream[nStream],
- 0);
- return true;
- }
-
- return false;
- }
+ // Just switched to MP3 player
+ if ( !_bIsMp3Active && i == 0 )
+ {
+ if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
+ position = 0;
+ tMP3Entry *e = _pMP3List;
+
+ // Try to continue from previous song, if already started
+ if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
+ nFile = 0;
+ strcpy(filename, m_MiscomPath);
+ strcat(filename, StreamedNameTable[nFile]);
+ mp3Stream[nStream] =
+ AIL_open_stream(DIG, filename, 0);
+ if(mp3Stream[nStream]) {
+ AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ AIL_set_stream_ms_position(mp3Stream[nStream], position);
+ AIL_pause_stream(mp3Stream[nStream], 0);
+ return true;
}
+ return false;
- if(mp3->pLinkPath != NULL)
- mp3Stream[nStream] =
- AIL_open_stream(DIG, mp3->pLinkPath, 0);
+ } else {
+ if ( e->pLinkPath != NULL )
+ mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0);
else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, mp3->aFilename);
-
- mp3Stream[nStream] =
- AIL_open_stream(DIG, filename, 0);
+ strcat(filename, e->aFilename);
+
+ mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
}
-
- if(mp3Stream[nStream]) {
+
+ if ( mp3Stream[nStream] ) {
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
- AIL_set_stream_ms_position(mp3Stream[nStream], 0);
+ AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
+
+ _bIsMp3Active = true;
+
return true;
}
-
- _bIsMp3Active = false;
- continue;
+ // fall through, start playing from another song
}
- if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
- position = 0;
-
- tMP3Entry *e;
- if ( !_GetMP3PosFromStreamPos(&position, &e) )
+ } else {
+ if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
+
+ _CurMP3Pos = 0;
+
+ tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
+ if ( !mp3 )
{
- if ( e == NULL )
+ mp3 = _pMP3List;
+ if ( !_pMP3List )
{
nFile = 0;
+ _bIsMp3Active = 0;
strcpy(filename, m_MiscomPath);
strcat(filename, StreamedNameTable[nFile]);
+
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
if(mp3Stream[nStream]) {
- AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
+ AIL_set_stream_loop_count(
+ mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
nStreamLoopedFlag[nStream] = true;
- AIL_set_stream_ms_position(mp3Stream[nStream], position);
- AIL_pause_stream(mp3Stream[nStream], 0);
+ AIL_set_stream_ms_position(
+ mp3Stream[nStream], position);
+ AIL_pause_stream(mp3Stream[nStream],
+ 0);
return true;
}
-
return false;
}
}
-
- if ( e->pLinkPath != NULL )
- mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0);
- else
- {
+ if(mp3->pLinkPath != NULL)
+ mp3Stream[nStream] = AIL_open_stream(DIG, mp3->pLinkPath, 0);
+ else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, e->aFilename);
-
- mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ strcat(filename, mp3->aFilename);
+
+ mp3Stream[nStream] =
+ AIL_open_stream(DIG, filename, 0);
}
-
- if ( mp3Stream[nStream] )
- {
+
+ if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
- AIL_set_stream_ms_position(mp3Stream[nStream], position);
+ AIL_set_stream_ms_position(mp3Stream[nStream], 0);
AIL_pause_stream(mp3Stream[nStream], 0);
-
+#ifdef FIX_BUGS
_bIsMp3Active = true;
-
+#endif
return true;
}
-
- _bIsMp3Active = false;
- } while(++i < nNumMP3s);
-
- position = 0;
- nFile = 0;
- }
-
- strcpy(filename, m_MiscomPath);
- strcat(filename, StreamedNameTable[nFile]);
-
- mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
- if ( mp3Stream[nStream] )
- {
- AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- AIL_set_stream_ms_position(mp3Stream[nStream], position);
- AIL_pause_stream(mp3Stream[nStream], 0);
- return true;
+ }
+ _bIsMp3Active = 0;
}
+ while ( ++i < nNumMP3s );
+ position = 0;
+ nFile = 0;
}
+ strcpy(filename, m_MiscomPath);
+ strcat(filename, StreamedNameTable[nFile]);
+ mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ if ( mp3Stream[nStream] )
+ {
+ AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ AIL_set_stream_ms_position(mp3Stream[nStream], position);
+ AIL_pause_stream(mp3Stream[nStream], 0);
+ return true;
+ }
return false;
}
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 57a70246..921cbfad 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -1734,93 +1734,94 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
{
+ int i = 0;
uint32 position = nPos;
- char filename[256];
-
- ASSERT( nStream < MAX_STREAMS );
+ char filename[MAX_PATH];
- if ( nFile < TOTAL_STREAMED_SOUNDS )
+ if ( nFile >= TOTAL_STREAMED_SOUNDS )
+ return false;
+
+ if ( aStream[nStream] )
{
- if ( aStream[nStream] )
- {
- delete aStream[nStream];
- aStream[nStream] = NULL;
- }
-
- if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ delete aStream[nStream];
+ aStream[nStream] = NULL;
+ }
+ if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ {
+ do
{
- uint32 i = 0;
- do {
- if(i != 0 || _bIsMp3Active) {
- if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
-
- _CurMP3Pos = 0;
-
- tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
-
- if(mp3) {
- mp3 = _pMP3List;
- if(mp3 == NULL) {
- _bIsMp3Active = false;
- nFile = 0;
- strcat(filename, StreamedNameTable[nFile]);
+ // Just switched to MP3 player
+ if ( !_bIsMp3Active && i == 0 )
+ {
+ if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
+ position = 0;
+ tMP3Entry *e = _pMP3List;
- CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- ASSERT(stream != NULL);
+ // Try to continue from previous song, if already started
+ if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
+ nFile = 0;
- aStream[nStream] = stream;
+ strcpy(filename, StreamedNameTable[nFile]);
+ CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- if (stream->Setup()) {
- stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- if (position != 0)
- stream->SetPosMS(position);
+ aStream[nStream] = stream;
- stream->Start();
+ if (stream->Setup()) {
+ stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ if (position != 0)
+ stream->SetPosMS(position);
- return true;
- } else {
- delete stream;
- aStream[nStream] = NULL;
- }
+ stream->Start();
- return false;
- }
+ return true;
+ } else {
+ delete stream;
+ aStream[nStream] = NULL;
}
+ return false;
- if (mp3->pLinkPath != NULL)
- aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ } else {
+
+ if (e->pLinkPath != NULL)
+ aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, mp3->aFilename);
+ strcat(filename, e->aFilename);
- aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
}
if (aStream[nStream]->Setup()) {
+ if (position != 0)
+ aStream[nStream]->SetPosMS(position);
+
aStream[nStream]->Start();
+ _bIsMp3Active = true;
return true;
} else {
delete aStream[nStream];
aStream[nStream] = NULL;
}
-
- _bIsMp3Active = false;
- continue;
+ // fall through, start playing from another song
}
- if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
- position = 0;
-
- tMP3Entry *e;
- if ( !_GetMP3PosFromStreamPos(&position, &e) )
+ } else {
+ if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
+
+ _CurMP3Pos = 0;
+
+ tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
+ if ( !mp3 )
{
- if ( e == NULL )
+ mp3 = _pMP3List;
+ if ( !_pMP3List )
{
nFile = 0;
- strcat(filename, StreamedNameTable[nFile]);
+ _bIsMp3Active = 0;
+ strcpy(filename, StreamedNameTable[nFile]);
+
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- ASSERT(stream != NULL);
aStream[nStream] = stream;
@@ -1837,63 +1838,55 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
delete stream;
aStream[nStream] = NULL;
}
-
return false;
}
}
-
- if (e->pLinkPath != NULL)
- aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ if (mp3->pLinkPath != NULL)
+ aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, e->aFilename);
+ strcat(filename, mp3->aFilename);
- aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
}
if (aStream[nStream]->Setup()) {
- if (position != 0)
- aStream[nStream]->SetPosMS(position);
-
aStream[nStream]->Start();
-
+#ifdef FIX_BUGS
_bIsMp3Active = true;
+#endif
return true;
} else {
delete aStream[nStream];
aStream[nStream] = NULL;
}
-
- _bIsMp3Active = false;
-
- } while(++i < nNumMP3s);
- position = 0;
- nFile = 0;
+ }
+ _bIsMp3Active = 0;
}
+ while ( ++i < nNumMP3s );
+ position = 0;
+ nFile = 0;
+ }
+ strcpy(filename, StreamedNameTable[nFile]);
+
+ CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- strcpy(filename, StreamedNameTable[nFile]);
-
- CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- ASSERT(stream != NULL);
+ aStream[nStream] = stream;
+
+ if ( stream->Setup() ) {
+ stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ if (position != 0)
+ stream->SetPosMS(position);
- aStream[nStream] = stream;
+ stream->Start();
- if ( stream->Setup() ) {
- stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- if (position != 0)
- stream->SetPosMS(position);
-
- stream->Start();
-
- return true;
- } else {
- delete stream;
- aStream[nStream] = NULL;
- }
+ return true;
+ } else {
+ delete stream;
+ aStream[nStream] = NULL;
}
-
return false;
}
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index ac02abec..b11a23fb 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -3273,7 +3273,7 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos)
attempts += 1;
}
if (attempts >= 5)
- return nil;
+ return false;
CAutomobile* pVehicle = new CAutomobile(mi, RANDOM_VEHICLE);
pVehicle->AutoPilot.m_vecDestinationCoors = vecPos;
pVehicle->SetPosition(spawnPos);
diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp
index 6c7cbe91..38c28069 100644
--- a/src/control/Script8.cpp
+++ b/src/control/Script8.cpp
@@ -386,7 +386,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
}
case COMMAND_IS_JAPANESE_GAME:
#ifdef MORE_LANGUAGES
- UpdateCompareFlag(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_JAPANESE);
+ UpdateCompareFlag(FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_JAPANESE);
#elif (defined GTAVC_JP_PATCH)
UpdateCompareFlag(true);
#else
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index e6419069..7b159e17 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -3114,11 +3114,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/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/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/config.h b/src/core/config.h
index 1d4bf574..9e42fb9e 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -235,7 +235,6 @@ enum Config {
// not in master builds
#define VALIDATE_SAVE_SIZE
- #define NO_MOVIES // disable intro videos
#define DEBUGMENU
#endif
@@ -254,6 +253,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 53deeb70..49c9a8e6 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -103,7 +103,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;
@@ -1082,7 +1085,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
@@ -1277,6 +1280,7 @@ if(gbRenderEverythingBarRoads)
void
RenderScene_new(void)
{
+ PUSH_RENDERGROUP("RenderScene_new");
CClouds::Render();
DoRWRenderHorizon();
@@ -1284,6 +1288,7 @@ RenderScene_new(void)
DefinedState();
// CMattRenderer::ResetRenderStates
// moved CRenderer::RenderBoats to before transparent water
+ POP_RENDERGROUP();
}
// TODO
@@ -1291,6 +1296,7 @@ bool FredIsInFirstPersonCam(void) { return false; }
void
RenderEffects_new(void)
{
+ PUSH_RENDERGROUP("RenderEffects_new");
CShadows::RenderStaticShadows();
CShadows::RenderStoredShadows();
CSkidmarks::Render();
@@ -1334,6 +1340,7 @@ if(gbRenderFadingInEntities)
CPointLights::RenderFogEffect();
CMovingThings::Render();
CRenderer::RenderFirstPersonVehicle();
+ POP_RENDERGROUP();
}
#endif
@@ -1346,6 +1353,7 @@ RenderScene(void)
return;
}
#endif
+ PUSH_RENDERGROUP("RenderScene");
CClouds::Render();
DoRWRenderHorizon();
CRenderer::RenderRoads();
@@ -1361,11 +1369,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)
@@ -1374,6 +1384,7 @@ RenderDebugShit(void)
CDebug::DrawLines();
DefinedState();
#endif
+ POP_RENDERGROUP();
}
void
@@ -1385,6 +1396,7 @@ RenderEffects(void)
return;
}
#endif
+ PUSH_RENDERGROUP("RenderEffects");
CGlass::Render();
CWaterCannons::Render();
CSpecialFX::Render();
@@ -1401,11 +1413,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);
@@ -1477,6 +1491,7 @@ Render2dStuff(void)
#ifdef DEBUGMENU
DebugMenuRender();
#endif
+ POP_RENDERGROUP();
}
void
@@ -1484,7 +1499,9 @@ RenderMenus(void)
{
if (FrontEndMenuManager.m_bMenuActive)
{
+ PUSH_RENDERGROUP("RenderMenus");
FrontEndMenuManager.DrawFrontEnd();
+ POP_RENDERGROUP();
}
#ifndef MASTER
else
@@ -1495,6 +1512,7 @@ RenderMenus(void)
void
Render2dStuffAfterFade(void)
{
+ PUSH_RENDERGROUP("Render2dStuffAfterFade");
#ifndef MASTER
DisplayGameDebugText();
#endif
@@ -1505,6 +1523,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 8e4123ff..3fa26e78 100644
--- a/src/core/main.h
+++ b/src/core/main.h
@@ -1,5 +1,16 @@
#pragma once
+#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()
+#endif
+
struct GlobalScene
{
RpWorld *world;
@@ -63,3 +74,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 3d077ba1..27382c98 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 *pipelineNames[] = { "FED_PSP", "FED_PS2","FED_MOB" };
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);
@@ -117,6 +152,38 @@ CustomFrontendOptionsPopulate(void)
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
}
#endif
@@ -466,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
@@ -563,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++) {
@@ -993,14 +1064,14 @@ extern bool gbRenderDebugEnvMap;
#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
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);
diff --git a/src/extras/postfx.cpp b/src/extras/postfx.cpp
index 1ccd8ac5..563865b5 100644
--- a/src/extras/postfx.cpp
+++ b/src/extras/postfx.cpp
@@ -7,6 +7,7 @@
#error "Need librw for EXTENDED_COLOURFILTER"
#endif
+#include "main.h"
#include "RwHelper.h"
#include "Camera.h"
#include "MBlur.h"
@@ -407,6 +408,8 @@ CPostFX::GetBackBuffer(RwCamera *cam)
void
CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha)
{
+ PUSH_RENDERGROUP("CPostFX::Render");
+
// LCS PS2 blur is drawn in three passes:
// blend frame with current frame 3 times to blur a bit
// blend one more time with colour filter
@@ -475,6 +478,8 @@ CPostFX::Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blu
bJustInitialised = false;
}else
bJustInitialised = true;
+
+ POP_RENDERGROUP();
}
int CPostFX::PrevRed[NUMAVERAGE], CPostFX::AvgRed;
diff --git a/src/objects/Stinger.cpp b/src/objects/Stinger.cpp
index 79730c89..848a7cf7 100644
--- a/src/objects/Stinger.cpp
+++ b/src/objects/Stinger.cpp
@@ -75,10 +75,16 @@ CStinger::Remove()
for (int32 i = 0; i < NUM_STINGER_SEGMENTS; i++) {
CStingerSegment *spikeSegment = pSpikes[i];
+
+#ifdef FIX_BUGS
+ CWorld::Remove(spikeSegment);
+ delete spikeSegment;
+#else
if (spikeSegment->m_entryInfoList.first != nil)
spikeSegment->bRemoveFromWorld = true;
else
delete spikeSegment;
+#endif
}
bIsDeployed = false;
}
diff --git a/src/render/Antennas.cpp b/src/render/Antennas.cpp
index 452069a0..5e30aca2 100644
--- a/src/render/Antennas.cpp
+++ b/src/render/Antennas.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "main.h"
#include "Antennas.h"
CAntenna CAntennas::aAntennas[NUMANTENNAS];
@@ -70,6 +71,7 @@ CAntennas::Render(void)
{
int i, j;
+ PUSH_RENDERGROUP("CAntennas::Render");
for(i = 0; i < NUMANTENNAS; i++){
if(!aAntennas[i].active)
continue;
@@ -101,6 +103,8 @@ CAntennas::Render(void)
}
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+
+ POP_RENDERGROUP();
}
void
diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp
index e3a8c86e..9cd32c5f 100644
--- a/src/render/Clouds.cpp
+++ b/src/render/Clouds.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "main.h"
#include "Sprite.h"
#include "Sprite2d.h"
#include "General.h"
@@ -119,6 +120,8 @@ CClouds::Render(void)
if(!CGame::CanSeeOutSideFromCurrArea())
return;
+ PUSH_RENDERGROUP("CClouds::Render");
+
CCoronas::SunBlockedByClouds = false;
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
@@ -301,6 +304,8 @@ CClouds::Render(void)
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+
+ POP_RENDERGROUP();
}
bool
@@ -313,6 +318,8 @@ void
CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
int16 botred, int16 botgreen, int16 botblue, int16 alpha)
{
+ PUSH_RENDERGROUP("CClouds::RenderBackground");
+
CVector right = CrossProduct(TheCamera.GetUp(), TheCamera.GetForward());
right.Normalise();
float c = right.Magnitude2D();
@@ -415,6 +422,8 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
ms_colourBottom.g = fogg;
ms_colourBottom.b = fogb;
}
+
+ POP_RENDERGROUP();
}
void
@@ -423,6 +432,8 @@ CClouds::RenderHorizon(void)
if(UseDarkBackground())
return;
+ PUSH_RENDERGROUP("CClouds::RenderHorizon");
+
ms_colourBottom.a = 230;
ms_colourTop.a = 80;
@@ -457,4 +468,6 @@ CClouds::RenderHorizon(void)
CSprite2d::DrawAnyRect(0.0f, topleft, SCREEN_WIDTH, topright, 0.0f, botleft, SCREEN_WIDTH, botright,
ms_colourBkGrd, ms_colourBkGrd, ms_colourBkGrd, ms_colourBkGrd);
+
+ POP_RENDERGROUP();
}
diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp
index e3d3416c..8b137aad 100644
--- a/src/render/Coronas.cpp
+++ b/src/render/Coronas.cpp
@@ -249,6 +249,8 @@ CCoronas::Render(void)
int i, j;
int screenw, screenh;
+ PUSH_RENDERGROUP("CCoronas::Render");
+
screenw = RwRasterGetWidth(RwCameraGetRaster(Scene.camera));
screenh = RwRasterGetHeight(RwCameraGetRaster(Scene.camera));
@@ -432,6 +434,8 @@ CCoronas::Render(void)
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
+
+ POP_RENDERGROUP();
}
void
@@ -442,6 +446,8 @@ CCoronas::RenderReflections(void)
CEntity *entity;
if(CWeather::WetRoads > 0.0f){
+ PUSH_RENDERGROUP("CCoronas::RenderReflections");
+
CSprite::InitSpriteBuffer();
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
@@ -517,6 +523,8 @@ CCoronas::RenderReflections(void)
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
+
+ POP_RENDERGROUP();
}else{
for(i = 0; i < NUMCORONAS; i++)
aCoronas[i].renderReflection = false;
diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp
index e28ebc8e..ef167708 100644
--- a/src/render/Fluff.cpp
+++ b/src/render/Fluff.cpp
@@ -460,6 +460,7 @@ void CMovingThings::Update()
void CMovingThings::Render()
{
+ PUSH_RENDERGROUP("CMovingThings::Render");
CSmokeTrails::Update();
int i;
@@ -472,6 +473,7 @@ void CMovingThings::Render()
CPlaneTrails::Render();
CSmokeTrails::Render();
CPlaneBanners::Render();
+ POP_RENDERGROUP();
}
void CMovingThings::RegisterOne(CEntity *pEnt, uint16 nType) {
diff --git a/src/render/Font.h b/src/render/Font.h
index a433e053..fdf5f3f2 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -126,7 +126,7 @@ enum
class CFont
{
#ifdef MORE_LANGUAGES
- static int16 Size[LANGSET_MAX][MAX_FONTS][193];
+ static int16 Size[LANGSET_MAX][MAX_FONTS][210];
static uint8 LanguageSet;
static int32 Slot;
#else
@@ -158,11 +158,11 @@ public:
#endif
static int GetNumberLines(float xstart, float ystart, wchar *s);
static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s);
-#ifdef MORE_LANGUAGES
- static bool PrintString(float x, float y, wchar *start, wchar* &end, float spwidth, float japX);
-#else
+//#ifdef MORE_LANGUAGES
+// static bool PrintString(float x, float y, wchar *start, wchar* &end, float spwidth, float japX);
+//#else
static void PrintString(float x, float y, uint32, wchar *start, wchar *end, float spwidth);
-#endif
+//#endif
static void PrintStringFromBottom(float x, float y, wchar *str);
static float GetCharacterWidth(wchar c, bool forceProportional = false);
static float GetCharacterSize(wchar c);
@@ -171,12 +171,12 @@ public:
static float GetStringWidth_Jap(wchar* s);
#endif
static uint16 *GetNextSpace(wchar *s);
-#ifdef MORE_LANGUAGES
- static uint16 *ParseToken(wchar *s, bool japShit = false);
-#else
+//#ifdef MORE_LANGUAGES
+// static uint16 *ParseToken(wchar *s, bool japShit = false);
+//#else
static uint16 *ParseToken(wchar *s);
static uint16 *ParseToken(wchar *s, CRGBA &color, bool &flash, bool &bold);
-#endif
+//#endif
static void DrawFonts(void);
static void RenderFontBuffer(void);
static uint16 character_code(uint8 c);
@@ -221,6 +221,6 @@ public:
static bool IsAnsiCharacter(wchar* s);
static bool IsJapanesePunctuation(wchar* str);
static bool IsJapanese() { return LanguageSet == FONT_LANGSET_JAPANESE; }
- static bool IsJapaneseFont() { return IsJapanese() && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER); }
+ static bool IsJapaneseFont() { return IsJapanese() && (Details.style == FONT_JAPANESE); }
#endif
};
diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp
index c6d02755..3409a058 100644
--- a/src/render/Glass.cpp
+++ b/src/render/Glass.cpp
@@ -276,6 +276,8 @@ CGlass::Render(void)
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
+ PUSH_RENDERGROUP("CGlass::Render");
+
for ( int32 i = 0; i < NUM_GLASSPANES; i++ )
{
if ( aGlassPanes[i].m_bActive )
@@ -285,6 +287,8 @@ CGlass::Render(void)
for ( uint32 i = 0; i < NumGlassEntities; i++ )
RenderEntityInGlass(apEntitiesToBeRendered[i]);
+ POP_RENDERGROUP();
+
NumGlassEntities = 0;
RenderHiLightPolys();
diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp
index ab77bf9b..dc88164b 100644
--- a/src/render/MBlur.cpp
+++ b/src/render/MBlur.cpp
@@ -6,6 +6,7 @@
#include <d3d8caps.h>
#endif
+#include "main.h"
#include "General.h"
#include "RwHelper.h"
#include "Camera.h"
@@ -333,6 +334,7 @@ CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, u
#ifdef EXTENDED_COLOURFILTER
CPostFX::Render(cam, red, green, blue, blur, type, bluralpha);
#else
+ PUSH_RENDERGROUP("CMBlur::MotionBlurRender");
RwRGBA color = { (RwUInt8)red, (RwUInt8)green, (RwUInt8)blue, (RwUInt8)blur };
#ifdef GTA_PS2
if( pFrontBuffer )
@@ -348,6 +350,7 @@ CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, u
RwRasterPopContext();
}
#endif
+ POP_RENDERGROUP();
#endif
}
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index 3ce00639..2e709f42 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "main.h"
#include "General.h"
#include "Timer.h"
#include "TxdStore.h"
@@ -1749,6 +1750,8 @@ void CParticle::Update()
void CParticle::Render()
{
+ PUSH_RENDERGROUP("CParticle::Render");
+
RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void *)rwTEXTUREADDRESSWRAP);
RwRenderStateSet(rwRENDERSTATETEXTUREPERSPECTIVE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void *)FALSE);
@@ -2105,6 +2108,8 @@ void CParticle::Render()
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA);
+
+ POP_RENDERGROUP();
}
void CParticle::RemovePSystem(tParticleType type)
diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp
index 3e73c57f..13872401 100644
--- a/src/render/PointLights.cpp
+++ b/src/render/PointLights.cpp
@@ -159,6 +159,8 @@ CPointLights::RenderFogEffect(void)
if(CCutsceneMgr::IsRunning())
return;
+ PUSH_RENDERGROUP("CPointLights::RenderFogEffect");
+
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
@@ -302,6 +304,8 @@ CPointLights::RenderFogEffect(void)
}
CSprite::FlushSpriteBuffer();
+
+ POP_RENDERGROUP();
}
bool
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index a320748a..6e4b3a3e 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -134,8 +134,13 @@ CRenderer::RenderOneRoad(CEntity *e)
return;
if(gbShowCollisionPolys)
CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
- else
+ else{
+ PUSH_RENDERGROUP(CModelInfo::GetModelInfo(e->GetModelIndex())->GetModelName());
+
e->Render();
+
+ POP_RENDERGROUP();
+ }
}
void
@@ -182,6 +187,8 @@ CRenderer::RenderOneNonRoad(CEntity *e)
}
#endif
+ PUSH_RENDERGROUP(CModelInfo::GetModelInfo(e->GetModelIndex())->GetModelName());
+
resetLights = e->SetupLighting();
if(e->IsVehicle()){
@@ -210,6 +217,8 @@ CRenderer::RenderOneNonRoad(CEntity *e)
}
e->RemoveLighting(resetLights);
+
+ POP_RENDERGROUP();
}
void
@@ -235,6 +244,7 @@ CRenderer::RenderRoads(void)
int i;
CEntity *e;
+ PUSH_RENDERGROUP("CRenderer::RenderRoads");
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
SetCullMode(rwCULLMODECULLBACK);
@@ -246,6 +256,7 @@ CRenderer::RenderRoads(void)
if(IsRoad(e))
RenderOneRoad(e);
}
+ POP_RENDERGROUP();
}
inline bool PutIntoSortedVehicleList(CVehicle *veh)
@@ -268,6 +279,7 @@ CRenderer::RenderEverythingBarRoads(void)
CEntity *e;
EntityInfo ei;
+ PUSH_RENDERGROUP("CRenderer::RenderEverythingBarRoads");
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
SetCullMode(rwCULLMODECULLBACK);
@@ -299,6 +311,7 @@ CRenderer::RenderEverythingBarRoads(void)
}else
RenderOneNonRoad(e);
}
+ POP_RENDERGROUP();
}
void
@@ -306,6 +319,7 @@ CRenderer::RenderBoats(void)
{
CLink<EntityInfo> *node;
+ PUSH_RENDERGROUP("CRenderer::RenderBoats");
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
SetCullMode(rwCULLMODECULLBACK);
@@ -334,6 +348,7 @@ CRenderer::RenderBoats(void)
CVehicle *v = (CVehicle*)node->item.ent;
RenderOneNonRoad(v);
}
+ POP_RENDERGROUP();
}
#ifdef NEW_RENDERER
@@ -437,6 +452,7 @@ CRenderer::RenderWorld(int pass)
switch(pass){
case 0:
// Roads
+ PUSH_RENDERGROUP("CRenderer::RenderWorld - Roads");
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
e = ms_aVisibleBuildingPtrs[i];
@@ -450,9 +466,11 @@ CRenderer::RenderWorld(int pass)
if(e->bIsBIGBuilding || IsRoad(e))
RenderOneBuilding(e, node->item.sort);
}
+ POP_RENDERGROUP();
break;
case 1:
// Opaque
+ PUSH_RENDERGROUP("CRenderer::RenderWorld - Opaque");
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
e = ms_aVisibleBuildingPtrs[i];
@@ -473,14 +491,17 @@ CRenderer::RenderWorld(int pass)
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
WorldRender::RenderBlendPass(PASS_NOZ);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
+ POP_RENDERGROUP();
break;
case 2:
// Transparent
+ PUSH_RENDERGROUP("CRenderer::RenderWorld - Transparent");
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
WorldRender::RenderBlendPass(PASS_ADD);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
WorldRender::RenderBlendPass(PASS_BLEND);
+ POP_RENDERGROUP();
break;
}
}
@@ -491,11 +512,13 @@ CRenderer::RenderPeds(void)
int i;
CEntity *e;
+ PUSH_RENDERGROUP("CRenderer::RenderPeds");
for(i = 0; i < ms_nNoOfVisibleVehicles; i++){
e = ms_aVisibleVehiclePtrs[i];
if(e->IsPed())
RenderOneNonRoad(e);
}
+ POP_RENDERGROUP();
}
void
@@ -506,6 +529,7 @@ CRenderer::RenderVehicles(void)
EntityInfo ei;
CLink<EntityInfo> *node;
+ PUSH_RENDERGROUP("CRenderer::RenderVehicles");
// not the real thing
for(i = 0; i < ms_nNoOfVisibleVehicles; i++){
e = ms_aVisibleVehiclePtrs[i];
@@ -522,6 +546,7 @@ CRenderer::RenderVehicles(void)
node != &gSortedVehiclesAndPeds.head;
node = node->prev)
RenderOneNonRoad(node->item.ent);
+ POP_RENDERGROUP();
}
void
@@ -530,6 +555,7 @@ CRenderer::RenderTransparentWater(void)
int i;
CEntity *e;
+ PUSH_RENDERGROUP("CRenderer::RenderTransparentWater");
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
@@ -553,6 +579,7 @@ CRenderer::RenderTransparentWater(void)
CWaterLevel::RenderTransparentWater();
SetStencilState(0);
+ POP_RENDERGROUP();
}
void
@@ -573,20 +600,24 @@ CRenderer::ClearForFrame(void)
void
CRenderer::RenderFadingInEntities(void)
{
+ PUSH_RENDERGROUP("CRenderer::RenderFadingInEntities");
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
SetCullMode(rwCULLMODECULLBACK);
DeActivateDirectional();
SetAmbientColours();
CVisibilityPlugins::RenderFadingEntities();
+ POP_RENDERGROUP();
}
void
CRenderer::RenderFadingInUnderwaterEntities(void)
{
+ PUSH_RENDERGROUP("CRenderer::RenderFadingInUnderwaterEntities");
DeActivateDirectional();
SetAmbientColours();
CVisibilityPlugins::RenderFadingUnderwaterEntities();
+ POP_RENDERGROUP();
}
void
diff --git a/src/render/Rubbish.cpp b/src/render/Rubbish.cpp
index bd69f875..147c97b1 100644
--- a/src/render/Rubbish.cpp
+++ b/src/render/Rubbish.cpp
@@ -54,6 +54,8 @@ CRubbish::Render(void)
if(RubbishVisibility == 0)
return;
+ PUSH_RENDERGROUP("CRubbish::Render");
+
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
@@ -150,6 +152,8 @@ CRubbish::Render(void)
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+
+ POP_RENDERGROUP();
}
void
diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp
index d4f75a2d..64b09395 100644
--- a/src/render/Shadows.cpp
+++ b/src/render/Shadows.cpp
@@ -1068,6 +1068,8 @@ CShadows::SetRenderModeForShadowType(uint8 ShadowType)
void
CShadows::RenderStoredShadows(void)
{
+ PUSH_RENDERGROUP("CShadows::RenderStoredShadows");
+
RenderBuffer::ClearRenderBuffer();
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
@@ -1241,12 +1243,16 @@ CShadows::RenderStoredShadows(void)
RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void *)rwTEXTUREADDRESSWRAP);
ShadowsStoredToBeRendered = 0;
+
+ POP_RENDERGROUP();
}
void
CShadows::RenderStaticShadows(void)
{
+ PUSH_RENDERGROUP("CShadows::RenderStaticShadows");
+
RenderBuffer::ClearRenderBuffer();
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
@@ -1313,6 +1319,8 @@ CShadows::RenderStaticShadows(void)
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)TRUE);
+
+ POP_RENDERGROUP();
}
diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp
index 07039c17..08df330d 100644
--- a/src/render/Skidmarks.cpp
+++ b/src/render/Skidmarks.cpp
@@ -96,6 +96,8 @@ CSkidmarks::Render(void)
{
int i, j;
+ PUSH_RENDERGROUP("CSkidmarks::Render");
+
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
@@ -152,6 +154,8 @@ CSkidmarks::Render(void)
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
+
+ POP_RENDERGROUP();
}
void
diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp
index 161bf168..e27a783e 100644
--- a/src/render/SpecialFX.cpp
+++ b/src/render/SpecialFX.cpp
@@ -164,6 +164,7 @@ CSpecialFX::Shutdown(void)
void
CSpecialFX::Render(void)
{
+ PUSH_RENDERGROUP("CSpecialFX::Render");
CMotionBlurStreaks::Render();
CBulletTraces::Render();
CBrightLights::Render();
@@ -173,6 +174,7 @@ CSpecialFX::Render(void)
if(!(gbNewRenderer && FredIsInFirstPersonCam()))
#endif
C3dMarkers::Render();
+ POP_RENDERGROUP();
}
void
diff --git a/src/render/WaterCannon.cpp b/src/render/WaterCannon.cpp
index 74fd7be6..4aaa8d6f 100644
--- a/src/render/WaterCannon.cpp
+++ b/src/render/WaterCannon.cpp
@@ -331,9 +331,11 @@ void CWaterCannons::Update(void)
void CWaterCannons::Render(void)
{
+ PUSH_RENDERGROUP("CWaterCannons::Render");
for ( int32 i = 0; i < NUM_WATERCANNONS; i++ )
{
if ( aCannons[i].m_nId != 0 )
aCannons[i].Render();
}
+ POP_RENDERGROUP();
}
diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp
index 6bd89ad9..d4b3b91f 100644
--- a/src/render/WaterLevel.cpp
+++ b/src/render/WaterLevel.cpp
@@ -611,14 +611,14 @@ CWaterLevel::TestVisibilityForFineWaterBlocks(const CVector &worldPos)
if ((lineEnd.x > WORLD_MIN_X && lineEnd.x < WORLD_MAX_X) && (lineEnd.y > WORLD_MIN_Y && lineEnd.y < WORLD_MAX_Y))
{
- if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
+ if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false))
{
lineStart.x += 0.4f;
lineStart.y += 0.4f;
lineEnd.x += 0.4f;
lineEnd.y += 0.4f;
- if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
+ if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false))
{
return false;
}
@@ -1202,6 +1202,8 @@ CWaterLevel::RenderTransparentWater(void)
if ( !CGame::CanSeeWaterFromCurrArea() )
return;
+ PUSH_RENDERGROUP("CWaterLevel::RenderTransparentWater");
+
float fWaterDrawDist = _GetWavyDrawDist();
float fWaterDrawDistLarge = fWaterDrawDist + 90.0f;
float fWavySectorMaxRenderDistSqr = SQR(fWaterDrawDist);
@@ -1485,6 +1487,8 @@ CWaterLevel::RenderTransparentWater(void)
DefinedState();
#endif
+
+ POP_RENDERGROUP();
}
void CWaterLevel::RenderOneFlatSmallWaterPoly(float fX, float fY, float fZ, RwRGBA const &color)
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index 186ed870..12816c29 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -9,6 +9,7 @@
#endif
#ifndef FINAL
RtCharset *debugCharset;
+bool bDebugRenderGroups;
#endif
#ifdef PS2_ALPHA_TEST
@@ -102,6 +103,36 @@ SetCullMode(uint32 mode)
RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE);
}
+#ifndef FINAL
+void
+PushRendergroup(const char *name)
+{
+ if(!bDebugRenderGroups)
+ return;
+#if defined(RW_OPENGL)
+ if(GLAD_GL_KHR_debug)
+ glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, name);
+#elif defined(RW_D3D9)
+ static WCHAR tmp[256];
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, tmp, sizeof(tmp));
+ D3DPERF_BeginEvent(0xFFFFFFFF, tmp);
+#endif
+}
+
+void
+PopRendergroup(void)
+{
+ if(!bDebugRenderGroups)
+ return;
+#if defined(RW_OPENGL)
+ if(GLAD_GL_KHR_debug)
+ glPopDebugGroup();
+#elif defined(RW_D3D9)
+ D3DPERF_EndEvent();
+#endif
+}
+#endif
+
RwFrame*
GetFirstFrameCallback(RwFrame *child, void *data)
{
diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h
index 9352d1fd..a3a1928c 100644
--- a/src/rw/RwHelper.h
+++ b/src/rw/RwHelper.h
@@ -1,5 +1,6 @@
#pragma once
+extern bool bDebugRenderGroups;
extern bool gPS2alphaTest;
extern bool gBackfaceCulling;
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 69e30c1b..eebbb93b 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -233,7 +233,9 @@ CVisibilityPlugins::RenderFadingEntities(CLinkList<AlphaObjectInfo> &list)
DeActivateDirectional();
SetAmbientColours();
e->bImBeingRendered = true;
+ PUSH_RENDERGROUP(mi->GetModelName());
RenderFadingAtomic((RpAtomic*)e->m_rwObject, node->item.sort);
+ POP_RENDERGROUP();
e->bImBeingRendered = false;
}else
CRenderer::RenderOneNonRoad(e);
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index a703ed5d..af3a46b1 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -50,16 +50,30 @@ long _dwOperatingSystemVersion;
#include "Font.h"
#include "MemoryMgr.h"
-#define MAX_SUBSYSTEMS (16)
+// We found out that GLFW's keyboard input handling is still pretty delayed/not stable, so now we fetch input from X11 directly on Linux.
+#if !defined _WIN32 && !defined __APPLE__ && !defined __SWITCH__ // && !defined WAYLAND
+#define GET_KEYBOARD_INPUT_FROM_X11
+#endif
+
+#ifdef GET_KEYBOARD_INPUT_FROM_X11
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#define GLFW_EXPOSE_NATIVE_X11
+#include <GLFW/glfw3native.h>
+#endif
#ifdef _WIN32
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>
#endif
+#define MAX_SUBSYSTEMS (16)
+
rw::EngineOpenParams openParams;
static RwBool ForegroundApp = TRUE;
+static RwBool WindowIconified = FALSE;
+static RwBool WindowFocused = TRUE;
static RwBool RwInitialised = FALSE;
@@ -325,7 +339,9 @@ psInitialize(void)
RsGlobal.ps = &PsGlobal;
PsGlobal.fullScreen = FALSE;
- PsGlobal.cursorIsInWindow = TRUE;
+ PsGlobal.cursorIsInWindow = FALSE;
+ WindowFocused = TRUE;
+ WindowIconified = FALSE;
PsGlobal.joy1id = -1;
PsGlobal.joy2id = -1;
@@ -849,11 +865,15 @@ psSelectDevice()
return TRUE;
}
+#ifndef GET_KEYBOARD_INPUT_FROM_X11
void keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods);
+#endif
void resizeCB(GLFWwindow* window, int width, int height);
void scrollCB(GLFWwindow* window, double xoffset, double yoffset);
void cursorCB(GLFWwindow* window, double xpos, double ypos);
void cursorEnterCB(GLFWwindow* window, int entered);
+void windowFocusCB(GLFWwindow* window, int focused);
+void windowIconifyCB(GLFWwindow* window, int iconified);
void joysChangeCB(int jid, int event);
bool IsThisJoystickBlacklisted(int i)
@@ -962,11 +982,15 @@ void psPostRWinit(void)
RwVideoMode vm;
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
+#ifndef GET_KEYBOARD_INPUT_FROM_X11
glfwSetKeyCallback(PSGLOBAL(window), keypressCB);
+#endif
glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB);
glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB);
+ glfwSetWindowIconifyCallback(PSGLOBAL(window), windowIconifyCB);
+ glfwSetWindowFocusCallback(PSGLOBAL(window), windowFocusCB);
glfwSetJoystickCallback(joysChangeCB);
_InputInitialiseJoys();
@@ -1318,6 +1342,10 @@ void scrollCB(GLFWwindow* window, double xoffset, double yoffset) {
PSGLOBAL(mouseWheel) = yoffset;
}
+bool lshiftStatus = false;
+bool rshiftStatus = false;
+
+#ifndef GET_KEYBOARD_INPUT_FROM_X11
int keymap[GLFW_KEY_LAST + 1];
static void
@@ -1448,9 +1476,6 @@ initkeymap(void)
keymap[GLFW_KEY_MENU] = rsNULL;
}
-bool lshiftStatus = false;
-bool rshiftStatus = false;
-
void
keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods)
{
@@ -1468,6 +1493,266 @@ keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods)
}
}
+#else
+
+uint32 keymap[512]; // 256 ascii + 256 KeySyms between 0xff00 - 0xffff
+bool keyStates[512];
+uint32 keyCodeToKeymapIndex[256]; // cache for physical keys
+
+#define KEY_MAP_OFFSET (0xff00 - 256)
+static void
+initkeymap(void)
+{
+ Display *display = glfwGetX11Display();
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(keymap); i++)
+ keymap[i] = rsNULL;
+
+ // You can add new ASCII mappings to here freely (but beware that if right hand side of assignment isn't supported on CFont, it'll be blank/won't work on binding screen)
+ // Right hand side of assigments should always be uppercase counterpart of character
+ keymap[XK_space] = ' ';
+ keymap[XK_apostrophe] = '\'';
+ keymap[XK_ampersand] = '&';
+ keymap[XK_percent] = '%';
+ keymap[XK_dollar] = '$';
+ keymap[XK_comma] = ',';
+ keymap[XK_minus] = '-';
+ keymap[XK_period] = '.';
+ keymap[XK_slash] = '/';
+ keymap[XK_question] = '?';
+ keymap[XK_exclam] = '!';
+ keymap[XK_quotedbl] = '"';
+ keymap[XK_colon] = ':';
+ keymap[XK_semicolon] = ';';
+ keymap[XK_equal] = '=';
+ keymap[XK_bracketleft] = '[';
+ keymap[XK_backslash] = '\\';
+ keymap[XK_bracketright] = ']';
+ keymap[XK_grave] = '`';
+ keymap[XK_0] = '0';
+ keymap[XK_1] = '1';
+ keymap[XK_2] = '2';
+ keymap[XK_3] = '3';
+ keymap[XK_4] = '4';
+ keymap[XK_5] = '5';
+ keymap[XK_6] = '6';
+ keymap[XK_7] = '7';
+ keymap[XK_8] = '8';
+ keymap[XK_9] = '9';
+ keymap[XK_a] = 'A';
+ keymap[XK_b] = 'B';
+ keymap[XK_c] = 'C';
+ keymap[XK_d] = 'D';
+ keymap[XK_e] = 'E';
+ keymap[XK_f] = 'F';
+ keymap[XK_g] = 'G';
+ keymap[XK_h] = 'H';
+ keymap[XK_i] = 'I';
+ keymap[XK_I] = 'I'; // Turkish I problem
+ keymap[XK_j] = 'J';
+ keymap[XK_k] = 'K';
+ keymap[XK_l] = 'L';
+ keymap[XK_m] = 'M';
+ keymap[XK_n] = 'N';
+ keymap[XK_o] = 'O';
+ keymap[XK_p] = 'P';
+ keymap[XK_q] = 'Q';
+ keymap[XK_r] = 'R';
+ keymap[XK_s] = 'S';
+ keymap[XK_t] = 'T';
+ keymap[XK_u] = 'U';
+ keymap[XK_v] = 'V';
+ keymap[XK_w] = 'W';
+ keymap[XK_x] = 'X';
+ keymap[XK_y] = 'Y';
+ keymap[XK_z] = 'Z';
+
+ // Some of regional but ASCII characters that GTA supports
+ keymap[XK_agrave] = 0x00c0;
+ keymap[XK_aacute] = 0x00c1;
+ keymap[XK_acircumflex] = 0x00c2;
+ keymap[XK_adiaeresis] = 0x00c4;
+
+ keymap[XK_ae] = 0x00c6;
+
+ keymap[XK_egrave] = 0x00c8;
+ keymap[XK_eacute] = 0x00c9;
+ keymap[XK_ecircumflex] = 0x00ca;
+ keymap[XK_ediaeresis] = 0x00cb;
+
+ keymap[XK_igrave] = 0x00cc;
+ keymap[XK_iacute] = 0x00cd;
+ keymap[XK_icircumflex] = 0x00ce;
+ keymap[XK_idiaeresis] = 0x00cf;
+
+ keymap[XK_ccedilla] = 0x00c7;
+ keymap[XK_odiaeresis] = 0x00d6;
+ keymap[XK_udiaeresis] = 0x00dc;
+
+ // These are 0xff00 - 0xffff range of KeySym's, and subtracting KEY_MAP_OFFSET is needed
+ keymap[XK_Escape - KEY_MAP_OFFSET] = rsESC;
+ keymap[XK_Return - KEY_MAP_OFFSET] = rsENTER;
+ keymap[XK_Tab - KEY_MAP_OFFSET] = rsTAB;
+ keymap[XK_BackSpace - KEY_MAP_OFFSET] = rsBACKSP;
+ keymap[XK_Insert - KEY_MAP_OFFSET] = rsINS;
+ keymap[XK_Delete - KEY_MAP_OFFSET] = rsDEL;
+ keymap[XK_Right - KEY_MAP_OFFSET] = rsRIGHT;
+ keymap[XK_Left - KEY_MAP_OFFSET] = rsLEFT;
+ keymap[XK_Down - KEY_MAP_OFFSET] = rsDOWN;
+ keymap[XK_Up - KEY_MAP_OFFSET] = rsUP;
+ keymap[XK_Page_Up - KEY_MAP_OFFSET] = rsPGUP;
+ keymap[XK_Page_Down - KEY_MAP_OFFSET] = rsPGDN;
+ keymap[XK_Home - KEY_MAP_OFFSET] = rsHOME;
+ keymap[XK_End - KEY_MAP_OFFSET] = rsEND;
+ keymap[XK_Caps_Lock - KEY_MAP_OFFSET] = rsCAPSLK;
+ keymap[XK_Scroll_Lock - KEY_MAP_OFFSET] = rsSCROLL;
+ keymap[XK_Num_Lock - KEY_MAP_OFFSET] = rsNUMLOCK;
+ keymap[XK_Pause - KEY_MAP_OFFSET] = rsPAUSE;
+
+ keymap[XK_F1 - KEY_MAP_OFFSET] = rsF1;
+ keymap[XK_F2 - KEY_MAP_OFFSET] = rsF2;
+ keymap[XK_F3 - KEY_MAP_OFFSET] = rsF3;
+ keymap[XK_F4 - KEY_MAP_OFFSET] = rsF4;
+ keymap[XK_F5 - KEY_MAP_OFFSET] = rsF5;
+ keymap[XK_F6 - KEY_MAP_OFFSET] = rsF6;
+ keymap[XK_F7 - KEY_MAP_OFFSET] = rsF7;
+ keymap[XK_F8 - KEY_MAP_OFFSET] = rsF8;
+ keymap[XK_F9 - KEY_MAP_OFFSET] = rsF9;
+ keymap[XK_F10 - KEY_MAP_OFFSET] = rsF10;
+ keymap[XK_F11 - KEY_MAP_OFFSET] = rsF11;
+ keymap[XK_F12 - KEY_MAP_OFFSET] = rsF12;
+ keymap[XK_F13 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F14 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F15 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F16 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F17 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F18 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F19 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F20 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F21 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F22 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F23 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F24 - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_F25 - KEY_MAP_OFFSET] = rsNULL;
+
+ keymap[XK_KP_0 - KEY_MAP_OFFSET] = rsPADINS;
+ keymap[XK_KP_1 - KEY_MAP_OFFSET] = rsPADEND;
+ keymap[XK_KP_2 - KEY_MAP_OFFSET] = rsPADDOWN;
+ keymap[XK_KP_3 - KEY_MAP_OFFSET] = rsPADPGDN;
+ keymap[XK_KP_4 - KEY_MAP_OFFSET] = rsPADLEFT;
+ keymap[XK_KP_5 - KEY_MAP_OFFSET] = rsPAD5;
+ keymap[XK_KP_6 - KEY_MAP_OFFSET] = rsPADRIGHT;
+ keymap[XK_KP_7 - KEY_MAP_OFFSET] = rsPADHOME;
+ keymap[XK_KP_8 - KEY_MAP_OFFSET] = rsPADUP;
+ keymap[XK_KP_9 - KEY_MAP_OFFSET] = rsPADPGUP;
+ keymap[XK_KP_Insert - KEY_MAP_OFFSET] = rsPADINS;
+ keymap[XK_KP_End - KEY_MAP_OFFSET] = rsPADEND;
+ keymap[XK_KP_Down - KEY_MAP_OFFSET] = rsPADDOWN;
+ keymap[XK_KP_Page_Down - KEY_MAP_OFFSET] = rsPADPGDN;
+ keymap[XK_KP_Left - KEY_MAP_OFFSET] = rsPADLEFT;
+ keymap[XK_KP_Begin - KEY_MAP_OFFSET] = rsPAD5;
+ keymap[XK_KP_Right - KEY_MAP_OFFSET] = rsPADRIGHT;
+ keymap[XK_KP_Home - KEY_MAP_OFFSET] = rsPADHOME;
+ keymap[XK_KP_Up - KEY_MAP_OFFSET] = rsPADUP;
+ keymap[XK_KP_Page_Up - KEY_MAP_OFFSET] = rsPADPGUP;
+
+ keymap[XK_KP_Decimal - KEY_MAP_OFFSET] = rsPADDEL;
+ keymap[XK_KP_Divide - KEY_MAP_OFFSET] = rsDIVIDE;
+ keymap[XK_KP_Multiply - KEY_MAP_OFFSET] = rsTIMES;
+ keymap[XK_KP_Subtract - KEY_MAP_OFFSET] = rsMINUS;
+ keymap[XK_KP_Add - KEY_MAP_OFFSET] = rsPLUS;
+ keymap[XK_KP_Enter - KEY_MAP_OFFSET] = rsPADENTER;
+ keymap[XK_KP_Equal - KEY_MAP_OFFSET] = rsNULL;
+ keymap[XK_Shift_L - KEY_MAP_OFFSET] = rsLSHIFT;
+ keymap[XK_Control_L - KEY_MAP_OFFSET] = rsLCTRL;
+ keymap[XK_Alt_L - KEY_MAP_OFFSET] = rsLALT;
+ keymap[XK_Super_L - KEY_MAP_OFFSET] = rsLWIN;
+ keymap[XK_Shift_R - KEY_MAP_OFFSET] = rsRSHIFT;
+ keymap[XK_Control_R - KEY_MAP_OFFSET] = rsRCTRL;
+ keymap[XK_Alt_R - KEY_MAP_OFFSET] = rsRALT;
+ keymap[XK_Super_R - KEY_MAP_OFFSET] = rsRWIN;
+ keymap[XK_Menu - KEY_MAP_OFFSET] = rsNULL;
+
+ // Cache the key codes' key symbol equivelants, otherwise we will have to do it on each frame
+ // KeyCode is always in [0,255], and represents a physical key
+
+ int min_keycode, max_keycode, keysyms_per_keycode;
+ KeySym *keymap, *origkeymap;
+
+ char *keyboardLang = setlocale (LC_CTYPE, NULL);
+ setlocale(LC_CTYPE, "");
+
+ XDisplayKeycodes(display, &min_keycode, &max_keycode);
+ origkeymap = XGetKeyboardMapping(display, min_keycode, (max_keycode - min_keycode + 1), &keysyms_per_keycode);
+ keymap = origkeymap;
+ for (int i = min_keycode; i <= max_keycode; i++) {
+ int j, lastKeysym;
+
+ lastKeysym = keysyms_per_keycode - 1;
+ while ((lastKeysym >= 0) && (keymap[lastKeysym] == NoSymbol))
+ lastKeysym--;
+
+ for (j = 0; j <= lastKeysym; j++) {
+ KeySym ks = keymap[j];
+
+ if (ks == NoSymbol)
+ continue;
+
+ if (ks < 256) {
+ keyCodeToKeymapIndex[i] = ks;
+ break;
+ } else if (ks >= 0xff00 && ks < 0xffff) {
+ keyCodeToKeymapIndex[i] = ks - KEY_MAP_OFFSET;
+ break;
+ }
+ }
+ keymap += keysyms_per_keycode;
+ }
+ XFree(origkeymap);
+
+ setlocale(LC_CTYPE, keyboardLang);
+}
+#undef KEY_MAP_OFFSET
+
+void checkKeyPresses()
+{
+ Display *display = glfwGetX11Display();
+ char keys[32];
+ XQueryKeymap(display, keys);
+ for (int i = 0; i < sizeof(keys); i++) {
+ for (int j = 0; j < 8; j++) {
+ KeyCode keycode = 8 * i + j;
+ uint32 keymapIndex = keyCodeToKeymapIndex[keycode];
+ if (keymapIndex != 0) {
+ int rsCode = keymap[keymapIndex];
+ if (rsCode == rsNULL)
+ continue;
+
+ bool pressed = WindowFocused && !!(keys[i] & (1 << j));
+
+ // idk why R* does that
+ if (rsCode == rsLSHIFT)
+ lshiftStatus = pressed;
+ else if (rsCode == rsRSHIFT)
+ rshiftStatus = pressed;
+
+ if (keyStates[keymapIndex] != pressed) {
+ if (pressed) {
+ RsKeyboardEventHandler(rsKEYDOWN, &rsCode);
+ } else {
+ RsKeyboardEventHandler(rsKEYUP, &rsCode);
+ }
+ }
+
+ keyStates[keymapIndex] = pressed;
+ }
+ }
+ }
+
+}
+#endif
+
// R* calls that in ControllerConfig, idk why
void
_InputTranslateShiftKeyUpDown(RsKeyCodes *rs) {
@@ -1492,6 +1777,16 @@ cursorEnterCB(GLFWwindow* window, int entered) {
PSGLOBAL(cursorIsInWindow) = !!entered;
}
+void
+windowFocusCB(GLFWwindow* window, int focused) {
+ WindowFocused = !!focused;
+}
+
+void
+windowIconifyCB(GLFWwindow* window, int iconified) {
+ WindowIconified = !!iconified;
+}
+
/*
*****************************************************************************
*/
@@ -1744,6 +2039,9 @@ main(int argc, char *argv[])
#endif
{
glfwPollEvents();
+#ifdef GET_KEYBOARD_INPUT_FROM_X11
+ checkKeyPresses();
+#endif
#ifndef MASTER
if (gbModelViewer) {
// This is TheModelViewerCore in LCS
@@ -1882,7 +2180,7 @@ main(int argc, char *argv[])
case GS_FRONTEND:
{
- if(!glfwGetWindowAttrib(PSGLOBAL(window), GLFW_ICONIFIED))
+ if(!WindowIconified)
RsEventHandler(rsFRONTENDIDLE, nil);
#ifdef PS2_MENU
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 9fdfb1e7..9597e9c2 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -915,14 +915,14 @@ void WaitForState(FILTER_STATE State)
*/
void HandleGraphEvent(void)
{
- LONG evCode, evParam1, evParam2;
+ LONG evCode;
+ LONG_PTR evParam1, evParam2;
HRESULT hr=S_OK;
ASSERT(pME != nil);
// Process all queued events
- while (SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR *)&evParam1,
- (LONG_PTR *)&evParam2, 0)))
+ while (SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0)))
{
// Free memory associated with callback, since we're not using it
hr = pME->FreeEventParams(evCode, evParam1, evParam2);
@@ -2273,7 +2273,7 @@ WinMain(HINSTANCE instance,
case GS_START_UP:
{
#ifdef NO_MOVIES
- gGameState = GS_INIT_ONCE;
+ gGameState = gbNoMovies ? GS_INIT_ONCE : GS_INIT_LOGO_MPEG;
#else
gGameState = GS_INIT_LOGO_MPEG;
#endif
@@ -2314,8 +2314,11 @@ WinMain(HINSTANCE instance,
case GS_INIT_INTRO_MPEG:
{
-#ifndef NO_MOVIES
+#ifdef NO_MOVIES
+ if (!gbNoMovies)
+#endif
CloseClip();
+#ifndef FIX_BUGS
CoUninitialize();
#endif
@@ -2353,8 +2356,11 @@ WinMain(HINSTANCE instance,
case GS_INIT_ONCE:
{
-#ifndef NO_MOVIES
+#ifdef NO_MOVIES
+ if (!gbNoMovies)
+#endif
CloseClip();
+#ifndef FIX_BUGS
CoUninitialize();
#endif
diff --git a/src/text/Text.cpp b/src/text/Text.cpp
index ad512104..e387fe01 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -260,13 +260,13 @@ CText::LoadMissionText(char *MissionTableName)
sprintf(filename, "SPANISH.GXT");
break;
#ifdef MORE_LANGUAGES
- case LANGUAGE_POLISH:
+ case CMenuManager::LANGUAGE_POLISH:
sprintf(filename, "POLISH.GXT");
break;
- case LANGUAGE_RUSSIAN:
+ case CMenuManager::LANGUAGE_RUSSIAN:
sprintf(filename, "RUSSIAN.GXT");
break;
- case LANGUAGE_JAPANESE:
+ case CMenuManager::LANGUAGE_JAPANESE:
sprintf(filename, "JAPANESE.GXT");
break;
#endif
diff --git a/src/weapons/WeaponEffects.cpp b/src/weapons/WeaponEffects.cpp
index b0df610f..bb95ea85 100644
--- a/src/weapons/WeaponEffects.cpp
+++ b/src/weapons/WeaponEffects.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "main.h"
#include "WeaponEffects.h"
#include "TxdStore.h"
#include "Sprite.h"
@@ -103,6 +104,8 @@ CWeaponEffects::Render(void)
float w, h;
if ( CSprite::CalcScreenCoors(gCrossHair.m_vecPos, &pos, &w, &h, true) )
{
+ PUSH_RENDERGROUP("CWeaponEffects::Render");
+
float recipz = 1.0f / pos.z;
CSprite::RenderOneXLUSprite_Rotate_Aspect(pos.x, pos.y, pos.z,
w, h,
@@ -119,6 +122,8 @@ CWeaponEffects::Render(void)
gCrossHair.m_fRotation += 0.02f;
if ( gCrossHair.m_fRotation > TWOPI )
gCrossHair.m_fRotation = 0.0;
+
+ POP_RENDERGROUP();
}
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);