1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-26 18:15:27 +00:00

Merge pull request #662 from erorcun/miami

90% fixes, 10% skel refactoring
This commit is contained in:
erorcun 2020-07-24 21:07:23 +03:00 committed by GitHub
commit b05cb3f1a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 104 additions and 50 deletions

View file

@ -137,6 +137,9 @@ void CGarages::Init(void)
MessageStartTime = 0; MessageStartTime = 0;
PlayerInGarage = false; PlayerInGarage = false;
BombsAreFree = false; BombsAreFree = false;
#ifdef FIX_BUGS
RespraysAreFree = false;
#endif
CarsCollected = 0; CarsCollected = 0;
BankVansCollected = 0; BankVansCollected = 0;
PoliceCarsCollected = 0; PoliceCarsCollected = 0;

View file

@ -5155,13 +5155,10 @@ CMenuManager::SwitchMenuOnAndOff()
m_bMenuActive = !m_bMenuActive; m_bMenuActive = !m_bMenuActive;
if (m_bMenuActive) { if (m_bMenuActive) {
#if defined RW_D3D9 || defined RWLIBS
if (_InputMouseNeedsExclusive()) { if (_InputMouseNeedsExclusive()) {
_InputShutdownMouse(); _InputShutdownMouse();
_InputInitialiseMouse(false); _InputInitialiseMouse(false);
} }
#endif
Initialise(); Initialise();
LoadAllTextures(); LoadAllTextures();
} else { } else {
@ -5173,12 +5170,10 @@ CMenuManager::SwitchMenuOnAndOff()
DoRWStuffEndOfFrame(); DoRWStuffEndOfFrame();
DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255); DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255);
DoRWStuffEndOfFrame(); DoRWStuffEndOfFrame();
#if defined RW_D3D9 || defined RWLIBS
if (_InputMouseNeedsExclusive()) { if (_InputMouseNeedsExclusive()) {
_InputShutdownMouse(); _InputShutdownMouse();
_InputInitialiseMouse(true); _InputInitialiseMouse(true);
} }
#endif
#ifdef PS2_LIKE_MENU #ifdef PS2_LIKE_MENU
bottomBarActive = false; bottomBarActive = false;
@ -5223,12 +5218,10 @@ CMenuManager::SwitchMenuOnAndOff()
m_bMenuActive = true; m_bMenuActive = true;
m_OnlySaveMenu = true; m_OnlySaveMenu = true;
#if defined RW_D3D9 || defined RWLIBS
if (_InputMouseNeedsExclusive()) { if (_InputMouseNeedsExclusive()) {
_InputShutdownMouse(); _InputShutdownMouse();
_InputInitialiseMouse(false); _InputInitialiseMouse(false);
} }
#endif
Initialise(); Initialise();
LoadAllTextures(); LoadAllTextures();

View file

@ -722,9 +722,9 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
void CPad::UpdateMouse() void CPad::UpdateMouse()
{ {
#if defined RW_D3D9 || defined RWLIBS
if ( IsForegroundApp() ) if ( IsForegroundApp() )
{ {
#if defined RW_D3D9 || defined RWLIBS
if ( PSGLOBAL(mouse) == nil ) if ( PSGLOBAL(mouse) == nil )
_InputInitialiseMouse(!FrontEndMenuManager.m_bMenuActive && _InputMouseNeedsExclusive()); _InputInitialiseMouse(!FrontEndMenuManager.m_bMenuActive && _InputMouseNeedsExclusive());
@ -761,7 +761,10 @@ void CPad::UpdateMouse()
OldMouseControllerState = NewMouseControllerState; OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState; NewMouseControllerState = PCTempMouseControllerState;
} }
}
#else #else
if ( IsForegroundApp() && PSGLOBAL(cursorIsInWindow) )
{
double xpos = 1.0f, ypos; double xpos = 1.0f, ypos;
glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos); glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos);
if (xpos == 0.f) if (xpos == 0.f)
@ -799,8 +802,8 @@ void CPad::UpdateMouse()
OldMouseControllerState = NewMouseControllerState; OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState; NewMouseControllerState = PCTempMouseControllerState;
#endif
} }
#endif
} }
CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &State1, CControllerState const &State2) CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &State1, CControllerState const &State2)
@ -1451,6 +1454,13 @@ void CPad::UpdatePads(void)
#else #else
CapturePad(0); CapturePad(0);
#endif #endif
// Improve keyboard input latency part 1
#ifdef FIX_BUGS
OldKeyState = NewKeyState;
NewKeyState = TempKeyState;
#endif
#ifdef DETECT_PAD_INPUT_SWITCH #ifdef DETECT_PAD_INPUT_SWITCH
if (GetPad(0)->PCTempJoyState.CheckForInput()) if (GetPad(0)->PCTempJoyState.CheckForInput())
IsAffectedByController = true; IsAffectedByController = true;
@ -1472,7 +1482,7 @@ void CPad::UpdatePads(void)
if ( bUpdate ) if ( bUpdate )
{ {
GetPad(0)->Update(0); GetPad(0)->Update(0);
GetPad(1)->Update(0); // GetPad(1)->Update(0); // not in VC
} }
#if defined(MASTER) && !defined(XINPUT) #if defined(MASTER) && !defined(XINPUT)
@ -1480,8 +1490,11 @@ void CPad::UpdatePads(void)
GetPad(1)->OldState.Clear(); GetPad(1)->OldState.Clear();
#endif #endif
// Improve keyboard input latency part 2
#ifndef FIX_BUGS
OldKeyState = NewKeyState; OldKeyState = NewKeyState;
NewKeyState = TempKeyState; NewKeyState = TempKeyState;
#endif
} }
void CPad::ProcessPCSpecificStuff(void) void CPad::ProcessPCSpecificStuff(void)

View file

@ -689,7 +689,11 @@ ChooseComponent(int32 rule, int32 comps)
return COMPRULE_COMPN(comps, n-1); return COMPRULE_COMPN(comps, n-1);
return -1; return -1;
case 4: case 4:
#ifdef FIX_BUGS
return CGeneral::GetRandomNumberInRange(0, 6);
#else
return CGeneral::GetRandomNumberInRange(0, 5); return CGeneral::GetRandomNumberInRange(0, 5);
#endif
} }
return -1; return -1;
} }

View file

@ -137,8 +137,8 @@ void CPedAttractorManager::RemoveIceCreamVanEffects(C2dEffect* pEffect)
for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend();) { for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend();) {
if (assoc->GetVehicle() != pVehicle) if (assoc->GetVehicle() != pVehicle)
return; return;
int total = 0; uint32 total = 0;
for (int j = 0; j < NUM_ATTRACTORS_FOR_ICECREAM_VAN; j++) { for (uint32 j = 0; j < NUM_ATTRACTORS_FOR_ICECREAM_VAN; j++) {
if (FindAssociatedAttractor(assoc->GetEffect(j), vIceCreamAttractors)) if (FindAssociatedAttractor(assoc->GetEffect(j), vIceCreamAttractors))
total++; total++;
} }
@ -355,13 +355,13 @@ bool CPedAttractor::BroadcastArrival(CPed* pPed)
bool CPedAttractor::BroadcastDeparture(CPed* pPed) bool CPedAttractor::BroadcastDeparture(CPed* pPed)
{ {
int qid = -1; int qid = -1;
for (int i = 0; i < vWaitingQueue.size(); i++){ for (uint32 i = 0; i < vWaitingQueue.size(); i++){
if (vWaitingQueue[i] == pPed) if (vWaitingQueue[i] == pPed)
qid = i; qid = i;
} }
if (qid < 0) if (qid < 0)
return false; return false;
for (int i = qid + 1; i < vWaitingQueue.size(); i++) { for (uint32 i = qid + 1; i < vWaitingQueue.size(); i++) {
CVector pos; CVector pos;
float heading; float heading;
float time; float time;
@ -401,7 +401,7 @@ bool CPedAttractor::BroadcastDeparture(CPed* pPed)
bool CPedShelterAttractor::BroadcastDeparture(CPed* pPed) bool CPedShelterAttractor::BroadcastDeparture(CPed* pPed)
{ {
int qid = -1; int qid = -1;
for (int i = 0; i < vWaitingQueue.size(); i++) { for (uint32 i = 0; i < vWaitingQueue.size(); i++) {
if (vWaitingQueue[i] == pPed) if (vWaitingQueue[i] == pPed)
qid = i; qid = i;
} }

View file

@ -1133,7 +1133,11 @@ CFont::ParseToken(wchar *s)
case 'r': SetColor(CRGBA(255, 150, 225, 255)); Details.anonymous_23 = true; break; case 'r': SetColor(CRGBA(255, 150, 225, 255)); Details.anonymous_23 = true; break;
case 't': SetColor(CRGBA(86, 212, 146, 255)); Details.anonymous_23 = true; break; case 't': SetColor(CRGBA(86, 212, 146, 255)); Details.anonymous_23 = true; break;
case 'w': SetColor(CRGBA(175, 175, 175, 255)); Details.anonymous_23 = true; break; case 'w': SetColor(CRGBA(175, 175, 175, 255)); Details.anonymous_23 = true; break;
#ifdef FIX_BUGS
case 'x': SetColor(CRGBA(0, 255, 255, 255)); Details.anonymous_23 = true; break;
#else
case 'x': SetColor(CRGBA(132, 146, 197, 255)); Details.anonymous_23 = true; break; case 'x': SetColor(CRGBA(132, 146, 197, 255)); Details.anonymous_23 = true; break;
#endif
case 'y': SetColor(CRGBA(255, 227, 79, 255)); Details.anonymous_23 = true; break; case 'y': SetColor(CRGBA(255, 227, 79, 255)); Details.anonymous_23 = true; break;
} }
while(*s != '~') s++; while(*s != '~') s++;
@ -1208,11 +1212,19 @@ CFont::ParseToken(wchar* str, CRGBA &color, bool &flash, bool &bold)
color.g = 175; color.g = 175;
color.b = 175; color.b = 175;
break; break;
#ifdef FIX_BUGS
case 'x':
color.r = 0;
color.g = 255;
color.b = 255;
break;
#else
case 'x': case 'x':
color.r = 132; color.r = 132;
color.g = 146; color.g = 146;
color.b = 197; color.b = 197;
break; break;
#endif
case 'y': case 'y':
color.r = 255; color.r = 255;
color.g = 227; color.g = 227;

View file

@ -3,19 +3,34 @@
// This is the common include for platform/renderer specific skeletons(glfw.cpp, win.cpp etc.) and using cross platform things (like Windows directories wrapper, platform specific global arrays etc.) // This is the common include for platform/renderer specific skeletons(glfw.cpp, win.cpp etc.) and using cross platform things (like Windows directories wrapper, platform specific global arrays etc.)
// Functions that's different on glfw and win but have same signature, should be located on platform.h. // Functions that's different on glfw and win but have same signature, should be located on platform.h.
enum eWinVersion
{
OS_WIN95 = 0,
OS_WIN98,
OS_WINNT,
OS_WIN2000,
OS_WINXP,
};
#ifdef _WIN32 #ifdef _WIN32
// This only has <windef.h> as Windows header, which is lighter (as long as WITHWINDOWS isn't defined / <Windows.h> isn't included).
// As long as WITHWINDOWS isn't defined / <Windows.h> isn't included, include <windef.h>, which is lighter.
#ifndef _INC_WINDOWS
#ifdef _WIN64
#define _ARM64_
#else
#define _X86_
#endif
#include <windef.h>
#endif
#if defined RW_D3D9 || defined RWLIBS
#include "win.h" #include "win.h"
#endif
extern DWORD _dwOperatingSystemVersion; extern DWORD _dwOperatingSystemVersion;
#else #else
char *strupr(char *str); char *strupr(char *str);
char *strlwr(char *str); char *strlwr(char *str);
enum {
OS_WIN98,
OS_WIN2000,
OS_WINNT,
OS_WINXP,
};
enum { enum {
LANG_OTHER, LANG_OTHER,
@ -42,6 +57,7 @@ typedef struct
RwBool fullScreen; RwBool fullScreen;
RwV2d lastMousePos; RwV2d lastMousePos;
double mouseWheel; // glfw doesn't cache it double mouseWheel; // glfw doesn't cache it
bool cursorIsInWindow;
RwInt8 joy1id; RwInt8 joy1id;
RwInt8 joy2id; RwInt8 joy2id;
} }

View file

@ -282,6 +282,7 @@ psInitialize(void)
RsGlobal.ps = &PsGlobal; RsGlobal.ps = &PsGlobal;
PsGlobal.fullScreen = FALSE; PsGlobal.fullScreen = FALSE;
PsGlobal.cursorIsInWindow = TRUE;
PsGlobal.joy1id = -1; PsGlobal.joy1id = -1;
PsGlobal.joy2id = -1; PsGlobal.joy2id = -1;
@ -790,6 +791,7 @@ void keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods)
void resizeCB(GLFWwindow* window, int width, int height); void resizeCB(GLFWwindow* window, int width, int height);
void scrollCB(GLFWwindow* window, double xoffset, double yoffset); void scrollCB(GLFWwindow* window, double xoffset, double yoffset);
void cursorCB(GLFWwindow* window, double xpos, double ypos); void cursorCB(GLFWwindow* window, double xpos, double ypos);
void cursorEnterCB(GLFWwindow* window, int entered);
void joysChangeCB(int jid, int event); void joysChangeCB(int jid, int event);
bool IsThisJoystickBlacklisted(int i) bool IsThisJoystickBlacklisted(int i)
@ -831,6 +833,17 @@ long _InputInitialiseMouse(bool exclusive)
return 0; return 0;
} }
void _InputShutdownMouse()
{
// Not needed
}
bool _InputMouseNeedsExclusive()
{
// That was the cause of infamous mouse bug on Win. Not supported on glfw anyway
return false;
}
void psPostRWinit(void) void psPostRWinit(void)
{ {
RwVideoMode vm; RwVideoMode vm;
@ -840,6 +853,7 @@ void psPostRWinit(void)
glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB); glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB);
glfwSetScrollCallback(PSGLOBAL(window), scrollCB); glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB); glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB);
glfwSetJoystickCallback(joysChangeCB); glfwSetJoystickCallback(joysChangeCB);
_InputInitialiseJoys(); _InputInitialiseJoys();
@ -1345,13 +1359,18 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) {
RsKeyboardEventHandler(rshiftStatus ? rsKEYDOWN : rsKEYUP, &(*rs = rsRSHIFT)); RsKeyboardEventHandler(rshiftStatus ? rsKEYDOWN : rsKEYUP, &(*rs = rsRSHIFT));
} }
// TODO this only works in frontend(and luckily only frontend use this), maybe because of glfw knows that mouse pos is > 32000 in game?? // TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000
void void
cursorCB(GLFWwindow* window, double xpos, double ypos) { cursorCB(GLFWwindow* window, double xpos, double ypos) {
FrontEndMenuManager.m_nMouseTempPosX = xpos; FrontEndMenuManager.m_nMouseTempPosX = xpos;
FrontEndMenuManager.m_nMouseTempPosY = ypos; FrontEndMenuManager.m_nMouseTempPosY = ypos;
} }
void
cursorEnterCB(GLFWwindow* window, int entered) {
PSGLOBAL(cursorIsInWindow) = !!entered;
}
/* /*
***************************************************************************** *****************************************************************************
*/ */

View file

@ -1,6 +1,8 @@
#ifndef PLATFORM_H #ifndef PLATFORM_H
#define PLATFORM_H #define PLATFORM_H
// Functions that's different on glfw/win etc. but have same signature (but if a function only used in win.cpp you can keep in win.h)
#include "rwcore.h" #include "rwcore.h"
#include "skeleton.h" #include "skeleton.h"
@ -36,6 +38,9 @@ extern RwBool psNativeTextureSupport(void);
extern void _InputTranslateShiftKeyUpDown(RsKeyCodes* rs); extern void _InputTranslateShiftKeyUpDown(RsKeyCodes* rs);
extern long _InputInitialiseMouse(bool exclusive); // returns HRESULT on Windows actually extern long _InputInitialiseMouse(bool exclusive); // returns HRESULT on Windows actually
extern void _InputShutdownMouse();
extern bool _InputMouseNeedsExclusive();
extern void _InputInitialiseJoys();
extern void HandleExit(); extern void HandleExit();

View file

@ -2883,8 +2883,13 @@ void _InputShutdownMouse()
SAFE_RELEASE(PSGLOBAL(mouse)); SAFE_RELEASE(PSGLOBAL(mouse));
} }
BOOL _InputMouseNeedsExclusive(void) bool _InputMouseNeedsExclusive(void)
{ {
// FIX: I don't know why R* needed that, but it causes infamous mouse bug on modern systems.
// Probably DirectInput bug, since Acquire() and GetDeviceState() reports everything A-OK.
#ifdef FIX_BUGS
return false;
#endif
RwVideoMode vm; RwVideoMode vm;
RwEngineGetVideoModeInfo(&vm, GcurSelVM); RwEngineGetVideoModeInfo(&vm, GcurSelVM);

View file

@ -1,5 +1,5 @@
// DON'T include directly. crossplatform.h includes this if you're on Windows. // DON'T include directly. crossplatform.h includes this if you're using D3D9 backend(win.cpp).
#if (!defined(_PLATFORM_WIN_H)) #if (!defined(_PLATFORM_WIN_H))
#define _PLATFORM_WIN_H #define _PLATFORM_WIN_H
@ -8,25 +8,6 @@
#define RSREGSETBREAKALLOC(_name) /* No op */ #define RSREGSETBREAKALLOC(_name) /* No op */
#endif /* (!defined(RSREGSETBREAKALLOC)) */ #endif /* (!defined(RSREGSETBREAKALLOC)) */
#ifndef _INC_WINDOWS
#ifdef _WIN64
#define _AMD64_
#else
#define _X86_
#endif
#include <windef.h>
#endif
enum eWinVersion
{
OS_WIN95 = 0,
OS_WIN98,
OS_WINNT,
OS_WIN2000,
OS_WINXP,
};
#ifdef __DINPUT_INCLUDED__ #ifdef __DINPUT_INCLUDED__
/* platform specfic global data */ /* platform specfic global data */
typedef struct typedef struct
@ -87,19 +68,16 @@ extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef __DINPUT_INCLUDED__
extern LRESULT CALLBACK extern LRESULT CALLBACK
MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam); MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
#ifdef __DINPUT_INCLUDED__
HRESULT _InputInitialise(); HRESULT _InputInitialise();
HRESULT CapturePad(RwInt32 padID); HRESULT CapturePad(RwInt32 padID);
void _InputInitialiseJoys();
void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num); void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num);
HRESULT _InputAddJoys(); HRESULT _InputAddJoys();
HRESULT _InputGetMouseState(DIMOUSESTATE2 *state); HRESULT _InputGetMouseState(DIMOUSESTATE2 *state);
void _InputShutdown(); void _InputShutdown();
void _InputShutdownMouse();
BOOL _InputMouseNeedsExclusive();
BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ); BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext );
BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key); BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key);
BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown); BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown);

View file

@ -32,7 +32,7 @@ void CCarGenerator::SwitchOff()
void CCarGenerator::SwitchOn() void CCarGenerator::SwitchOn()
{ {
m_nUsesRemaining = -1; m_nUsesRemaining = 255;
m_nTimer = CalcNextGen(); m_nTimer = CalcNextGen();
++CTheCarGenerators::CurrentActiveCount; ++CTheCarGenerators::CurrentActiveCount;
} }
@ -141,8 +141,14 @@ void CCarGenerator::DoInternalProcessing()
} }
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0); CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0);
m_nVehicleHandle = CPools::GetVehiclePool()->GetIndex(pVehicle); m_nVehicleHandle = CPools::GetVehiclePool()->GetIndex(pVehicle);
if (m_nUsesRemaining < -1) /* I don't think this is a correct comparasion */ /* I don't think this is a correct comparasion */
#ifdef FIX_BUGS
if (m_nUsesRemaining != 0)
--m_nUsesRemaining; --m_nUsesRemaining;
#else
if (m_nUsesRemaining < -1)
--m_nUsesRemaining;
#endif
m_nTimer = CalcNextGen(); m_nTimer = CalcNextGen();
if (m_nUsesRemaining == 0) if (m_nUsesRemaining == 0)
--CTheCarGenerators::CurrentActiveCount; --CTheCarGenerators::CurrentActiveCount;