90% fixes, 10% skel refactoring

This commit is contained in:
eray orçunus 2020-07-24 20:43:51 +03:00
parent bcb2b7a534
commit 15918feb8e
8 changed files with 68 additions and 46 deletions

View File

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

View File

@ -8,6 +8,7 @@
#include "common.h"
#include "crossplatform.h"
#include "platform.h"
#ifdef XINPUT
#include <xinput.h>
#pragma comment( lib, "Xinput9_1_0.lib" )
@ -544,9 +545,9 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
void CPad::UpdateMouse()
{
#if defined RW_D3D9 || defined RWLIBS
if ( IsForegroundApp() )
{
#if defined RW_D3D9 || defined RWLIBS
if ( PSGLOBAL(mouse) == nil )
_InputInitialiseMouse();
@ -583,7 +584,10 @@ void CPad::UpdateMouse()
OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState;
}
}
#else
if ( IsForegroundApp() && PSGLOBAL(cursorIsInWindow) )
{
double xpos = 1.0f, ypos;
glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos);
if (xpos == 0.f)
@ -621,8 +625,8 @@ void CPad::UpdateMouse()
OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState;
#endif
}
#endif
}
CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &State1, CControllerState const &State2)
@ -1072,6 +1076,13 @@ void CPad::UpdatePads(void)
#else
CapturePad(0);
#endif
// Improve keyboard input latency part 1
#ifdef FIX_BUGS
OldKeyState = NewKeyState;
NewKeyState = TempKeyState;
#endif
#ifdef DETECT_PAD_INPUT_SWITCH
if (GetPad(0)->PCTempJoyState.CheckForInput())
IsAffectedByController = true;
@ -1101,8 +1112,11 @@ void CPad::UpdatePads(void)
GetPad(1)->OldState.Clear();
#endif
// Improve keyboard input latency part 2
#ifndef FIX_BUGS
OldKeyState = NewKeyState;
NewKeyState = TempKeyState;
#endif
}
void CPad::ProcessPCSpecificStuff(void)

View File

@ -210,11 +210,7 @@ CStreaming::Init2(void)
desiredNumVehiclesLoaded = (int32)((ms_memoryAvailable / MB - 50) / 3 + 12);
if(desiredNumVehiclesLoaded > MAXVEHICLESLOADED)
desiredNumVehiclesLoaded = MAXVEHICLESLOADED;
#if defined(__LP64__) || defined(_WIN64)
debug("Memory allocated to Streaming is %lluMB", ms_memoryAvailable/MB);
#else
debug("Memory allocated to Streaming is %dMB", ms_memoryAvailable/MB);
#endif
debug("Memory allocated to Streaming is %zuMB", ms_memoryAvailable/MB); // original modifier was %d
#undef MB
#endif
@ -2497,11 +2493,7 @@ CStreaming::UpdateForAnimViewer(void)
if (CStreaming::ms_channelError == -1) {
CStreaming::AddModelsToRequestList(CVector(0.0f, 0.0f, 0.0f));
CStreaming::LoadRequestedModels();
#if defined(__LP64__) || defined(_WIN64)
sprintf(gString, "Requested %d, memory size %lluK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed);
#else
sprintf(gString, "Requested %d, memory size %dK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed);
#endif
sprintf(gString, "Requested %d, memory size %zuK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed); // original modifier was %d
}
else {
CStreaming::RetryLoadFile(CStreaming::ms_channelError);

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.)
// 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
// 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"
#endif
extern DWORD _dwOperatingSystemVersion;
#else
char *strupr(char *str);
char *strlwr(char *str);
enum {
OS_WIN98,
OS_WIN2000,
OS_WINNT,
OS_WINXP,
};
enum {
LANG_OTHER,
@ -42,6 +57,7 @@ typedef struct
RwBool fullScreen;
RwV2d lastMousePos;
double mouseWheel; // glfw doesn't cache it
bool cursorIsInWindow;
RwInt8 joy1id;
RwInt8 joy2id;
}

View File

@ -278,6 +278,7 @@ psInitialize(void)
RsGlobal.ps = &PsGlobal;
PsGlobal.fullScreen = FALSE;
PsGlobal.cursorIsInWindow = TRUE;
PsGlobal.joy1id = -1;
PsGlobal.joy2id = -1;
@ -786,6 +787,7 @@ void keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods)
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 joysChangeCB(int jid, int event);
bool IsThisJoystickBlacklisted(int i)
@ -821,9 +823,10 @@ void _InputInitialiseJoys()
}
}
void _InputInitialiseMouse()
long _InputInitialiseMouse()
{
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
return 0;
}
void psPostRWinit(void)
@ -835,6 +838,7 @@ void psPostRWinit(void)
glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB);
glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB);
glfwSetJoystickCallback(joysChangeCB);
_InputInitialiseJoys();
@ -1340,13 +1344,18 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) {
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
cursorCB(GLFWwindow* window, double xpos, double ypos) {
FrontEndMenuManager.m_nMouseTempPosX = xpos;
FrontEndMenuManager.m_nMouseTempPosY = ypos;
}
void
cursorEnterCB(GLFWwindow* window, int entered) {
PSGLOBAL(cursorIsInWindow) = !!entered;
}
/*
*****************************************************************************
*/

View File

@ -1,6 +1,8 @@
#ifndef 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 "skeleton.h"
@ -35,6 +37,8 @@ extern RwBool psInstallFileSystem(void);
extern RwBool psNativeTextureSupport(void);
extern void _InputTranslateShiftKeyUpDown(RsKeyCodes* rs);
extern long _InputInitialiseMouse(); // returns HRESULT on Windows actually
extern void _InputInitialiseJoys();
extern void HandleExit();

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))
#define _PLATFORM_WIN_H
@ -8,25 +8,6 @@
#define RSREGSETBREAKALLOC(_name) /* No op */
#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__
/* platform specfic global data */
typedef struct
@ -87,14 +68,12 @@ extern "C"
{
#endif /* __cplusplus */
#ifdef __DINPUT_INCLUDED__
extern LRESULT CALLBACK
MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
#ifdef __DINPUT_INCLUDED__
HRESULT _InputInitialise();
HRESULT _InputInitialiseMouse();
HRESULT CapturePad(RwInt32 padID);
void _InputInitialiseJoys();
void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num);
HRESULT _InputAddJoys();
HRESULT _InputGetMouseState(DIMOUSESTATE2 *state);

View File

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