Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge remote-tracking branch 'upstream/master'
  • Loading branch information
Nick007J committed Oct 5, 2020
2 parents 2bfb54b + 9db0d7b commit 6853be36c8bd293c8ee0b18cd411fc5a3ebe1099
@@ -161,7 +161,7 @@ cMusicManager::DisplayRadioStationName()
CFont::SetPropOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_STRETCH_X(640.0f));
CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation);

@@ -155,13 +155,13 @@ class CMP3File : public IDecoder
void Seek(uint32 milliseconds)
{
if ( !IsOpened() ) return;
mpg123_seek(m_pMH, ms2samples(milliseconds)*GetSampleSize(), SEEK_SET);
mpg123_seek(m_pMH, ms2samples(milliseconds), SEEK_SET);
}

uint32 Tell()
{
if ( !IsOpened() ) return 0;
return samples2ms(mpg123_tell(m_pMH)/GetSampleSize());
return samples2ms(mpg123_tell(m_pMH));
}

uint32 Decode(void *buffer)
@@ -247,13 +247,13 @@ class COpusFile : public IDecoder
void Seek(uint32 milliseconds)
{
if ( !IsOpened() ) return;
op_pcm_seek(m_FileH, ms2samples(milliseconds) * GetSampleSize());
op_pcm_seek(m_FileH, ms2samples(milliseconds) / GetChannels());
}

uint32 Tell()
{
if ( !IsOpened() ) return 0;
return samples2ms(op_pcm_tell(m_FileH)/GetSampleSize());
return samples2ms(op_pcm_tell(m_FileH) * GetChannels());
}

uint32 Decode(void *buffer)
@@ -461,8 +461,8 @@ uint32 CStream::GetPosMS()
alGetSourcei(m_alSource, AL_BYTE_OFFSET, &offset);

return m_pSoundFile->Tell()
- m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS-1))
+ m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize());
- m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS-1)) / m_pSoundFile->GetChannels()
+ m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize()) / m_pSoundFile->GetChannels();
}

uint32 CStream::GetLengthMS()
@@ -24,12 +24,12 @@ class IDecoder

uint32 ms2samples(uint32 ms)
{
return float(ms) / 1000.0f * float(GetChannels()) * float(GetSampleRate());
return float(ms) / 1000.0f * float(GetSampleRate());
}

uint32 samples2ms(uint32 sm)
{
return float(sm) * 1000.0f / float(GetChannels()) / float(GetSampleRate());
return float(sm) * 1000.0f / float(GetSampleRate());
}

uint32 GetBufferSamples()
@@ -108,4 +108,4 @@ class CStream
void ProviderTerm();
};

#endif
#endif
@@ -27,6 +27,7 @@
#include "MusicManager.h"
#include "Frontend.h"
#include "Timer.h"
#include "crossplatform.h"
#ifdef AUDIO_OPUS
#include <opusfile.h>
#endif
@@ -1423,11 +1424,11 @@ cSampleManager::InitialiseSampleBanks(void)
{
int32 nBank = SFX_BANK_0;

fpSampleDescHandle = fopen(SampleBankDescFilename, "rb");
fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb");
if ( fpSampleDescHandle == NULL )
return false;
#ifndef AUDIO_OPUS
fpSampleDataHandle = fopen(SampleBankDataFilename, "rb");
fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb");
if ( fpSampleDataHandle == NULL )
{
fclose(fpSampleDescHandle);
@@ -854,6 +854,13 @@ CMenuManager::Draw()
str = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[0].m_EntryName);
break;
default:
#ifdef CUSTOM_FRONTEND_OPTIONS
if (aScreens[m_nCurrScreen].m_aEntries[0].m_SaveSlot == SAVESLOT_CFO) {
FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[0].m_TargetMenu];
str = (wchar*)option.leftText;
}
else
#endif
str = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[0].m_EntryName);
break;
}
@@ -3443,19 +3450,6 @@ CMenuManager::LoadSettings()
CFileMgr::Read(fileHandle, m_PrefsSkinFile, 256);
CFileMgr::Read(fileHandle, (char*)&m_ControlMethod, 1);
CFileMgr::Read(fileHandle, (char*)&m_PrefsLanguage, 1);
#ifdef CUSTOM_FRONTEND_OPTIONS
for (int i = 0; i < numCustomFrontendOptions; i++) {
FrontendOption& option = customFrontendOptions[i];
if (option.save) {
CFileMgr::Read(fileHandle, (char*)option.value, 1);
option.lastSavedValue = option.displayedValue = *option.value;
}
}
#endif
#ifdef NO_ISLAND_LOADING
CFileMgr::Read(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1);
CMenuManager::m_DisplayIslandLoading = CMenuManager::m_PrefsIslandLoading;
#endif
}
}

@@ -3472,8 +3466,11 @@ CMenuManager::LoadSettings()
m_bLanguageLoaded = false;
else {
m_bLanguageLoaded = true;
// Already called in InitialiseChangedLanguageSettings
/*
TheText.Unload();
TheText.Load();
*/
m_bFrontEnd_ReloadObrTxtGxt = true;
InitialiseChangedLanguageSettings();

@@ -3546,21 +3543,14 @@ CMenuManager::SaveSettings()
CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256);
CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1);
CFileMgr::Write(fileHandle, (char*)&m_PrefsLanguage, 1);
#ifdef CUSTOM_FRONTEND_OPTIONS
for (int i = 0; i < numCustomFrontendOptions; i++) {
FrontendOption &option = customFrontendOptions[i];
if (option.save) {
CFileMgr::Write(fileHandle, (char*)option.value, 1);
}
}
#endif
#ifdef NO_ISLAND_LOADING
CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_PrefsIslandLoading, 1);
#endif
}

CFileMgr::CloseFile(fileHandle);
CFileMgr::SetDir("");

#ifdef LOAD_INI_SETTINGS
SaveINISettings();
#endif
}

bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
@@ -3880,7 +3870,10 @@ CMenuManager::Process(void)
MouseButtonJustClicked = 4;
else if (CPad::GetPad(0)->GetMouseWheelDownJustUp())
MouseButtonJustClicked = 5;
// TODO two more buttons
else if (CPad::GetPad(0)->GetMouseX1JustUp())
MouseButtonJustClicked = 6;
else if (CPad::GetPad(0)->GetMouseX2JustUp())
MouseButtonJustClicked = 7;

JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown();

@@ -5106,7 +5099,8 @@ CMenuManager::ProcessButtonPresses(void)
*option.value = option.lastSavedValue = option.displayedValue;

} else if (option.type == FEOPTION_DYNAMIC) {
option.buttonPressFunc(FEOPTION_ACTION_SELECT);
if (option.buttonPressFunc)
option.buttonPressFunc(FEOPTION_ACTION_SELECT);
} else if (option.type == FEOPTION_REDIRECT) {
ChangeScreen(option.to, option.option, true, option.fadeIn);
} else if (option.type == FEOPTION_GOBACK) {
@@ -5349,7 +5343,7 @@ CMenuManager::ProcessButtonPresses(void)
option.changeFunc(option.displayedValue);
*option.value = option.lastSavedValue = option.displayedValue;
}
} else if (option.type == FEOPTION_DYNAMIC) {
} else if (option.type == FEOPTION_DYNAMIC && option.buttonPressFunc) {
option.buttonPressFunc(changeValueBy > 0 ? FEOPTION_ACTION_RIGHT : FEOPTION_ACTION_LEFT);
}
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
@@ -6317,4 +6311,4 @@ CMenuManager::ConstructStatLine(int rowIdx)
#undef GetBackJustDown
#undef ChangeScreen

#endif
#endif
@@ -295,10 +295,14 @@ bool CGame::InitialiseOnceAfterRW(void)
CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile);

#ifdef CUSTOM_FRONTEND_OPTIONS
// Apparently this func. can be run multiple times at the start.
if (numCustomFrontendOptions == 0 && numCustomFrontendScreens == 0) {
// needs stored language and TheText to be loaded, and last TheText reload is at the start of here
CustomFrontendOptionsPopulate();
FrontEndMenuManager.LoadSettings();
}
#endif
#ifdef LOAD_INI_SETTINGS
LoadINISettings(); // needs frontend options to be loaded
#endif
return true;
}
@@ -277,6 +277,8 @@ class CPad
bool GetMiddleMouseJustUp() { return !!(!NewMouseControllerState.MMB && OldMouseControllerState.MMB); }
bool GetMouseWheelUpJustUp() { return !!(!NewMouseControllerState.WHEELUP && OldMouseControllerState.WHEELUP); }
bool GetMouseWheelDownJustUp() { return !!(!NewMouseControllerState.WHEELDN && OldMouseControllerState.WHEELDN); }
bool GetMouseX1JustUp() { return !!(!NewMouseControllerState.MXB1 && OldMouseControllerState.MXB1); }
bool GetMouseX2JustUp() { return !!(!NewMouseControllerState.MXB2 && OldMouseControllerState.MXB2); }

bool GetLeftMouse() { return NewMouseControllerState.LMB; }
bool GetRightMouse() { return NewMouseControllerState.RMB; }
@@ -2436,12 +2436,17 @@ CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem)
void
CStreaming::MakeSpaceFor(int32 size)
{
// BUG: ms_memoryAvailable can be uninitialized
// the code still happens to work in that case because ms_memoryAvailable is unsigned
// but it's not nice....

#ifdef FIX_BUGS
#define MB (1024 * 1024)
if(ms_memoryAvailable == 0) {
extern size_t _dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10 * MB) / 2;
if(ms_memoryAvailable < 50 * MB) ms_memoryAvailable = 50 * MB;
}
#undef MB
#endif
while(ms_memoryUsed >= ms_memoryAvailable - size)
if(!RemoveLeastUsedModel()){
if(!RemoveLeastUsedModel()) {
DeleteRwObjectsBehindCamera(ms_memoryAvailable - size);
return;
}
@@ -219,6 +219,8 @@ class CRGBA
extern int strcasecmp(const char *str1, const char *str2);
#endif

extern wchar *AllocUnicode(const char*src);

#define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v))

inline float sq(float x) { return x*x; }
@@ -444,4 +446,4 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
assert(ReadSaveBuf<uint32>(buf) == size);


void cprintf(char*, ...);
void cprintf(char*, ...);
@@ -198,6 +198,7 @@ enum Config {
#define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more
#define MORE_LANGUAGES // Add more translations to the game
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
#define LOAD_INI_SETTINGS

// Rendering/display
#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
@@ -226,6 +227,9 @@ 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.
#endif
#define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m
#define KANGAROO_CHEAT
#define ALLCARSHELI_CHEAT
@@ -306,4 +310,4 @@ enum Config {
#undef NO_ISLAND_LOADING
#define PC_PARTICLE
#define VC_PED_PORTS // To not process collisions always. But should be tested if that's really beneficial
#endif
#endif
@@ -36,3 +36,8 @@ void ResetLoadingScreenBar(void);
#ifndef MASTER
void TheModelViewer(void);
#endif

#ifdef LOAD_INI_SETTINGS
void LoadINISettings();
void SaveINISettings();
#endif

0 comments on commit 6853be3

Please sign in to comment.