summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-12-29 07:49:39 +0100
committerGitHub <noreply@github.com>2020-12-29 07:49:39 +0100
commitc1caf380de9e064215087faabbb294c9ee645e52 (patch)
tree7996140007dcc64f41adedaeff782c55af79ac5f
parentfix neo screendroplet moving (diff)
parentEnable BIND_VEHICLE_FIREWEAPON with gta3.set size check (diff)
downloadre3-c1caf380de9e064215087faabbb294c9ee645e52.tar
re3-c1caf380de9e064215087faabbb294c9ee645e52.tar.gz
re3-c1caf380de9e064215087faabbb294c9ee645e52.tar.bz2
re3-c1caf380de9e064215087faabbb294c9ee645e52.tar.lz
re3-c1caf380de9e064215087faabbb294c9ee645e52.tar.xz
re3-c1caf380de9e064215087faabbb294c9ee645e52.tar.zst
re3-c1caf380de9e064215087faabbb294c9ee645e52.zip
Diffstat (limited to '')
-rw-r--r--src/core/ControllerConfig.cpp43
-rw-r--r--src/core/config.h2
2 files changed, 43 insertions, 2 deletions
diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp
index b56a19f0..bf4893ea 100644
--- a/src/core/ControllerConfig.cpp
+++ b/src/core/ControllerConfig.cpp
@@ -132,6 +132,10 @@ void CControllerConfigManager::LoadSettings(int32 file)
{
bool bValid = true;
+#ifdef BIND_VEHICLE_FIREWEAPON
+ bool skipVehicleFireWeapon = false;
+#endif
+
if (file)
{
char buff[29];
@@ -139,18 +143,55 @@ void CControllerConfigManager::LoadSettings(int32 file)
if (!strncmp(buff, TopLineEmptyFile, sizeof(TopLineEmptyFile)-1))
bValid = false;
- else
+ else {
CFileMgr::Seek(file, 0, 0);
+
+#ifdef BIND_VEHICLE_FIREWEAPON
+ // HACK!
+ // All of this is hacky as fuck.
+ // We are checking the file size to read the .set file correctly.
+ // But because .set file is opened in text mode we have to read
+ // the WHOLE file to get the size we should be working with.
+ // Joy, ain't it?
+ char tempBuf[0x1000];
+ size_t fileSize = 0, blockSize;
+ do
+ {
+ blockSize = CFileMgr::Read(file, tempBuf, sizeof(tempBuf));
+ fileSize += blockSize;
+ } while (blockSize == sizeof(tempBuf));
+
+ CFileMgr::Seek(file, 0, 0);
+
+ if (fileSize == 0x671)
+ skipVehicleFireWeapon = true;
+#endif
+ }
}
if (bValid)
{
ControlsManager.MakeControllerActionsBlank();
+#ifdef BIND_VEHICLE_FIREWEAPON
+ // Set the default settings of VEHICLE_FIREWEAPON
+ if (skipVehicleFireWeapon) {
+ SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsPADINS, KEYBOARD);
+ SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsLCTRL, OPTIONAL_EXTRA);
+ if (m_bMouseAssociated)
+ SetMouseButtonAssociatedWithAction(VEHICLE_FIREWEAPON, 1);
+ }
+#endif
+
for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++)
{
for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++)
{
+#ifdef BIND_VEHICLE_FIREWEAPON
+ // Skip file read
+ if (skipVehicleFireWeapon && j == VEHICLE_FIREWEAPON)
+ continue;
+#endif
CFileMgr::Read(file, (char *)&ControlsManager.m_aSettings[j][i], sizeof(tControllerConfigBind));
}
}
diff --git a/src/core/config.h b/src/core/config.h
index d3196f9b..a9bb1a17 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -274,7 +274,7 @@ enum Config {
#define ALLCARSHELI_CHEAT
#define ALT_DODO_CHEAT
#define REGISTER_START_BUTTON
-//#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls
+#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls
#define BUTTON_ICONS // use textures to show controller buttons
// Hud, frontend and radar