Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Nikolay Korolev 2020-05-03 01:43:12 +03:00
commit 926e216dd4
7 changed files with 120 additions and 64 deletions

View File

@ -528,9 +528,14 @@ void CGarage::Update()
CGarages::GivePlayerDetonator();
CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
}
#ifdef DETECT_PAD_INPUT_SWITCH
int16 Mode = CPad::IsAffectedByController ? CPad::GetPad(0)->Mode : 0;
#else
int16 Mode = CPad::GetPad(0)->Mode;
#endif
switch (m_eGarageType) {
case GARAGE_BOMBSHOP1:
switch (CPad::GetPad(0)->Mode) {
switch (Mode) {
case 0:
case 1:
case 2:
@ -542,7 +547,7 @@ void CGarage::Update()
}
break;
case GARAGE_BOMBSHOP2:
switch (CPad::GetPad(0)->Mode) {
switch (Mode) {
case 0:
case 1:
case 2:

View File

@ -5258,7 +5258,11 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
return 0;
}
case COMMAND_GET_CONTROLLER_MODE:
#if defined(GTA_PC) && !defined(DETECT_PAD_INPUT_SWITCH)
ScriptParams[0] = 0;
#else
ScriptParams[0] = CPad::IsAffectedByController ? CPad::GetPad(0)->Mode : 0;
#endif
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_SET_CAN_RESPRAY_CAR:

View File

@ -55,6 +55,10 @@ CMouseControllerState CPad::OldMouseControllerState;
CMouseControllerState CPad::NewMouseControllerState;
CMouseControllerState CPad::PCTempMouseControllerState;
#ifdef DETECT_PAD_INPUT_SWITCH
bool CPad::IsAffectedByController = false;
#endif
_TODO("gbFastTime");
extern bool gbFastTime;
@ -325,6 +329,16 @@ void AltDodoCheat(void)
}
#endif
#ifdef DETECT_PAD_INPUT_SWITCH
bool
CControllerState::IsAnyButtonPressed(void)
{
return !!LeftStickX || !!LeftStickY || !!RightStickX || !!RightStickY || !!LeftShoulder1 || !!LeftShoulder2 || !!RightShoulder1 || !!RightShoulder2 ||
!!DPadUp || !!DPadDown || !!DPadLeft || !!DPadRight || !!Start || !!Select || !!Square || !!Triangle || !!Cross || !!Circle || !!LeftShock ||
!!RightShock || !!NetworkTalk;
}
#endif
void
CControllerState::Clear(void)
{
@ -1002,7 +1016,7 @@ void CPad::AffectFromXinput(uint32 pad)
if (Abs(rx) > 0.3f || Abs(ry) > 0.3f) {
PCTempJoyState.RightStickX = (int32)(rx * 128.0f);
PCTempJoyState.RightStickY = (int32)(ry * 128.0f);
PCTempJoyState.RightStickY = (int32)(-ry * 128.0f);
}
XINPUT_VIBRATION VibrationState;
@ -1037,12 +1051,21 @@ void CPad::UpdatePads(void)
#else
CapturePad(0);
#endif
#ifdef DETECT_PAD_INPUT_SWITCH
if (GetPad(0)->PCTempJoyState.IsAnyButtonPressed())
IsAffectedByController = true;
else {
#endif
ControlsManager.ClearSimButtonPressCheckers();
ControlsManager.AffectPadFromKeyBoard();
ControlsManager.AffectPadFromMouse();
#ifdef DETECT_PAD_INPUT_SWITCH
}
if (IsAffectedByController && (GetPad(0)->PCTempKeyState.IsAnyButtonPressed() || GetPad(0)->PCTempMouseState.IsAnyButtonPressed()))
IsAffectedByController = false;
#endif
if ( CReplay::IsPlayingBackFromFile() )
bUpdate = false;
@ -1096,6 +1119,9 @@ void CPad::Update(int16 unk)
void CPad::DoCheats(void)
{
#ifdef DETECT_PAD_INPUT_SWITCH
if (IsAffectedByController)
#endif
GetPad(0)->DoCheats(0);
}
@ -1154,13 +1180,19 @@ CPad *CPad::GetPad(int32 pad)
{
return &Pads[pad];
}
#ifdef DETECT_PAD_INPUT_SWITCH
#define CURMODE (IsAffectedByController ? Mode : 0)
#else
#define CURMODE (Mode)
#endif
int16 CPad::GetSteeringLeftRight(void)
{
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1193,7 +1225,7 @@ int16 CPad::GetSteeringUpDown(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1226,7 +1258,7 @@ int16 CPad::GetCarGunUpDown(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1253,7 +1285,7 @@ int16 CPad::GetCarGunLeftRight(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1280,7 +1312,7 @@ int16 CPad::GetPedWalkLeftRight(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1314,7 +1346,7 @@ int16 CPad::GetPedWalkUpDown(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1344,7 +1376,7 @@ int16 CPad::GetPedWalkUpDown(void)
int16 CPad::GetAnalogueUpDown(void)
{
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1410,7 +1442,7 @@ bool CPad::GetHorn(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
{
@ -1449,7 +1481,7 @@ bool CPad::HornJustDown(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
{
@ -1489,7 +1521,7 @@ bool CPad::GetCarGunFired(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1516,7 +1548,7 @@ bool CPad::CarGunJustDown(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1543,7 +1575,7 @@ int16 CPad::GetHandBrake(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1576,7 +1608,7 @@ int16 CPad::GetBrake(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1614,7 +1646,7 @@ bool CPad::GetExitVehicle(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1641,7 +1673,7 @@ bool CPad::ExitVehicleJustDown(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1668,7 +1700,7 @@ int32 CPad::GetWeapon(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1701,7 +1733,7 @@ bool CPad::WeaponJustDown(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1734,7 +1766,7 @@ int16 CPad::GetAccelerate(void)
if ( ArePlayerControlsDisabled() )
return 0;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1769,7 +1801,7 @@ int16 CPad::GetAccelerate(void)
bool CPad::CycleCameraModeUpJustDown(void)
{
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1793,7 +1825,7 @@ bool CPad::CycleCameraModeUpJustDown(void)
bool CPad::CycleCameraModeDownJustDown(void)
{
switch ( Mode )
switch (CURMODE)
{
case 0:
case 2:
@ -1820,7 +1852,7 @@ bool CPad::ChangeStationJustDown(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
{
@ -1876,7 +1908,7 @@ bool CPad::GetTarget(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1903,7 +1935,7 @@ bool CPad::TargetJustDown(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -1938,7 +1970,7 @@ bool CPad::GetSprint(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -2093,7 +2125,7 @@ bool CPad::ForceCameraBehindPlayer(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -2126,7 +2158,7 @@ bool CPad::SniperZoomIn(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -2153,7 +2185,7 @@ bool CPad::SniperZoomOut(void)
if ( ArePlayerControlsDisabled() )
return false;
switch ( Mode )
switch (CURMODE)
{
case 0:
case 1:
@ -2175,6 +2207,7 @@ bool CPad::SniperZoomOut(void)
return false;
}
#undef CURMODE
int16 CPad::SniperModeLookLeftRight(void)
{
@ -2190,6 +2223,9 @@ int16 CPad::SniperModeLookLeftRight(void)
int16 CPad::SniperModeLookUpDown(void)
{
int16 axis = NewState.LeftStickY;
#ifdef FIX_BUGS
axis = -axis;
#endif
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
if ( Abs(axis) > Abs(dpad) )
@ -2217,6 +2253,10 @@ int16 CPad::LookAroundUpDown(void)
{
int16 axis = GetPad(0)->NewState.RightStickY;
#ifdef FIX_BUGS
axis = -axis;
#endif
if ( Abs(axis) > 85 && !GetLookBehindForPed() )
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
* (127.0f / 32.0f) ); // 3.96875f

View File

@ -29,6 +29,9 @@ public:
float GetRightStickX(void) { return RightStickX/32767.0f; };
float GetRightStickY(void) { return RightStickY/32767.0f; };
#ifdef DETECT_PAD_INPUT_SWITCH
bool IsAnyButtonPressed();
#endif
void Clear(void);
};
VALIDATE_SIZE(CControllerState, 0x2A);
@ -159,6 +162,9 @@ public:
int32 AverageWeapon;
int32 AverageEntries;
#ifdef DETECT_PAD_INPUT_SWITCH
static bool IsAffectedByController;
#endif
CPad() { }
~CPad() { }

View File

@ -204,6 +204,7 @@ enum Config {
#ifndef RW_GL3
#define XINPUT
#endif
#define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m
#define KANGAROO_CHEAT
#define ALLCARSHELI_CHEAT
#define ALT_DODO_CHEAT

View File

@ -164,7 +164,7 @@ GenericSave(int file)
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMonth);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nYear);
WriteDataToBufferPointer(buf, CWeather::WeatherTypeInList);
#ifdef FIX_BUGS
#ifdef COMPATIBLE_SAVES
// converted to float for compatibility with original format
// TODO: maybe remove this? not really gonna break anything vital
float f = TheCamera.CarZoomIndicator;
@ -283,7 +283,7 @@ GenericLoad()
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nMonth);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nYear);
ReadDataFromBufferPointer(buf, CWeather::WeatherTypeInList);
#ifdef FIX_BUGS
#ifdef COMPATIBLE_SAVES
// converted to float for compatibility with original format
// TODO: maybe remove this? not really gonna break anything vital
float f;

View File

@ -424,7 +424,7 @@ CMessages::InsertStringInString(wchar *str1, wchar *str2)
for (i = 0; i < total_size; ) {
#ifdef MORE_LANGUAGES
if ((CFont::IsJapanese() && *_str1 == (0x8000 | '~') && *(_str1 + 1) == (0x8000 | 'a') && *(_str1 + 2) == (0x8000 | '~'))
|| (CFont::IsJapanese() && *_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~'))
|| (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~'))
{
#else
if (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~') {