diff --git a/saco/game/address.h b/saco/game/address.h new file mode 100644 index 0000000..d64ecbd --- /dev/null +++ b/saco/game/address.h @@ -0,0 +1,4 @@ + +#pragma once + +#define ADDR_KEYSTATES 0xB73458 diff --git a/saco/game/common.h b/saco/game/common.h new file mode 100644 index 0000000..ad93318 --- /dev/null +++ b/saco/game/common.h @@ -0,0 +1,6 @@ + +#pragma once + +#define PLAYER_PED_SLOTS 210 + + diff --git a/saco/game/keystuff.cpp b/saco/game/keystuff.cpp new file mode 100644 index 0000000..33278b4 --- /dev/null +++ b/saco/game/keystuff.cpp @@ -0,0 +1,118 @@ + +#include +#include +#include "common.h" +#include "keystuff.h" +#include "address.h" + +//----------------------------------------------------------- + +GTA_CONTROLSET *pGcsInternalKeys = (GTA_CONTROLSET *)ADDR_KEYSTATES; +GTA_CONTROLSET GcsLocalPlayerKeys; +GTA_CONTROLSET GcsRemotePlayerKeys[PLAYER_PED_SLOTS]; + +BYTE byteSaveDriveByLeft; +BYTE byteSaveDriveByRight; +BYTE *pbyteDriveByLeft = (BYTE *)0xB6F1A4; +BYTE *pbyteDriveByRight = (BYTE *)0xB6F1A5; + +//----------------------------------------------------------- + +void GameKeyStatesInit() +{ + int x=0; + memset(&GcsLocalPlayerKeys,0,sizeof(GTA_CONTROLSET)); + while(x!=PLAYER_PED_SLOTS) { + memset(&GcsRemotePlayerKeys[x],0,sizeof(GTA_CONTROLSET)); + x++; + } +} + +//----------------------------------------------------------- + +void GameStoreLocalPlayerKeys() +{ + memcpy(&GcsLocalPlayerKeys,pGcsInternalKeys,sizeof(GTA_CONTROLSET)); + + // save current driveby state + byteSaveDriveByLeft = *pbyteDriveByLeft; + byteSaveDriveByRight = *pbyteDriveByRight; +} + +//----------------------------------------------------------- + +void GameSetLocalPlayerKeys() +{ + memcpy(pGcsInternalKeys,&GcsLocalPlayerKeys,sizeof(GTA_CONTROLSET)); + + // restore the driveby state also + *pbyteDriveByLeft = byteSaveDriveByLeft; + *pbyteDriveByRight = byteSaveDriveByRight; +} + +//----------------------------------------------------------- + +void GameStoreRemotePlayerKeys(int iPlayer, GTA_CONTROLSET * pGcsKeyStates) +{ + memcpy(&GcsRemotePlayerKeys[iPlayer],pGcsKeyStates,sizeof(GTA_CONTROLSET)); +} + +//----------------------------------------------------------- + +void GameSetRemotePlayerKeys(int iPlayer) +{ + // Use this to sync between player and remote player. + //memcpy(&GcsRemotePlayerKeys[iPlayer],&GcsLocalPlayerKeys,96); + + memcpy(pGcsInternalKeys,&GcsRemotePlayerKeys[iPlayer],sizeof(GTA_CONTROLSET)); + + if(GcsRemotePlayerKeys[iPlayer].wKeys1[5]) { // lookl + *pbyteDriveByLeft = 1; + } else { + *pbyteDriveByLeft = 0; + } + + if(GcsRemotePlayerKeys[iPlayer].wKeys1[7]) { // lookr + *pbyteDriveByRight = 1; + } else { + *pbyteDriveByRight = 0; + } +} + +//----------------------------------------------------------- + +GTA_CONTROLSET * GameGetInternalKeys() +{ + return pGcsInternalKeys; +} + +//----------------------------------------------------------- + +GTA_CONTROLSET * GameGetLocalPlayerKeys() +{ + return &GcsLocalPlayerKeys; +} + +//----------------------------------------------------------- + +GTA_CONTROLSET * GameGetPlayerKeys(int iPlayer) +{ + return &GcsRemotePlayerKeys[iPlayer]; +} + +//----------------------------------------------------------- + +void GameResetPlayerKeys(int iPlayer) +{ + memset(&GcsRemotePlayerKeys[iPlayer],0,sizeof(GTA_CONTROLSET)); +} + +//----------------------------------------------------------- + +void GameResetInternalKeys() +{ + GTA_CONTROLSET *pInternals = GameGetInternalKeys(); + memset((PVOID)pInternals,0,48 * sizeof(WORD)); +} + +//----------------------------------------------------------- diff --git a/saco/game/keystuff.h b/saco/game/keystuff.h new file mode 100644 index 0000000..d642481 --- /dev/null +++ b/saco/game/keystuff.h @@ -0,0 +1,22 @@ + +typedef struct _GTA_CONTROLSET +{ + WORD wKeys1[24]; + WORD wKeys2[24]; + BYTE bytePadding1[212]; +} GTA_CONTROLSET; + +//----------------------------------------------------------- + +void GameKeyStatesInit(); +void GameStoreLocalPlayerKeys(); +void GameSetLocalPlayerKeys(); +void GameStoreRemotePlayerKeys(int iPlayer, GTA_CONTROLSET *pGcsKeyStates); +void GameSetRemotePlayerKeys(int iPlayer); +GTA_CONTROLSET *GameGetInternalKeys(); +GTA_CONTROLSET *GameGetLocalPlayerKeys(); +GTA_CONTROLSET *GameGetPlayerKeys(int iPlayer); +void GameResetPlayerKeys(int iPlayer); +void GameResetInternalKeys(); + +//----------------------------------------------------------- diff --git a/saco/saco.vcproj b/saco/saco.vcproj index 7290532..5656ca9 100644 --- a/saco/saco.vcproj +++ b/saco/saco.vcproj @@ -113,6 +113,9 @@ + + @@ -125,12 +128,21 @@ + + + + + +