Skip to content

Commit

Permalink
Fixed CSSDK and MetaMod SDK
Browse files Browse the repository at this point in the history
Fixed CSSDK and MetaMod SDK
  • Loading branch information
SmileYzn committed Dec 19, 2023
1 parent 878258e commit e91bd0a
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 18 deletions.
6 changes: 5 additions & 1 deletion AccuracyFix/include/cssdk/dlls/API/CSEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CCSEntity
CCSEntity() :
m_pContainingEntity(nullptr)
{
m_ucDmgPenetrationLevel = 0;
}

virtual ~CCSEntity() {}
Expand All @@ -45,12 +46,15 @@ class CCSEntity

public:
CBaseEntity *m_pContainingEntity;
unsigned char m_ucDmgPenetrationLevel; // penetration level of the damage caused by the inflictor
entvars_t *m_pevLastInflictor;

private:
#if defined(_MSC_VER)
#pragma region reserve_data_Region
#endif
int CCSEntity_Reserve[0x1000];
char CCSEntity_Reserve[0x3FF7];

virtual void func_reserve1() {};
virtual void func_reserve2() {};
virtual void func_reserve3() {};
Expand Down
41 changes: 33 additions & 8 deletions AccuracyFix/include/cssdk/dlls/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <API/CSPlayerItem.h>
#include <API/CSPlayerWeapon.h>
#include <utlarray.h>

enum WeaponInfiniteAmmoMode
{
Expand All @@ -52,9 +53,21 @@ class CCSPlayer: public CCSMonster
m_bAutoBunnyHopping(false),
m_bMegaBunnyJumping(false),
m_bPlantC4Anywhere(false),
m_bSpawnProtectionEffects(false)
m_bSpawnProtectionEffects(false),
m_flJumpHeight(0),
m_flLongJumpHeight(0),
m_flLongJumpForce(0),
m_flDuckSpeedMultiplier(0),
m_iUserID(-1)
{
m_szModel[0] = '\0';

// Resets the kill history for this player
for (int i = 0; i < MAX_CLIENTS; i++)
{
m_iNumKilledByUnanswered[i] = 0;
m_bPlayerDominated[i] = false;
}
}

virtual bool IsConnected() const = 0;
Expand All @@ -64,8 +77,8 @@ class CCSPlayer: public CCSMonster
virtual CBaseEntity *GiveNamedItemEx(const char *pszName) = 0;
virtual void GiveDefaultItems() = 0;
virtual void GiveShield(bool bDeploy = true) = 0;
virtual void DropShield(bool bDeploy = true) = 0;
virtual void DropPlayerItem(const char *pszItemName) = 0;
virtual CBaseEntity *DropShield(bool bDeploy = true) = 0;
virtual CBaseEntity *DropPlayerItem(const char *pszItemName) = 0;
virtual bool RemoveShield() = 0;
virtual void RemoveAllItems(bool bRemoveSuit) = 0;
virtual bool RemovePlayerItem(const char* pszItemName) = 0;
Expand Down Expand Up @@ -106,11 +119,6 @@ class CCSPlayer: public CCSMonster
virtual void OnSpawnEquip(bool addDefault = true, bool equipGame = true) = 0;
virtual void SetScoreboardAttributes(CBasePlayer *destination = nullptr) = 0;

void ResetVars();

void OnSpawn();
void OnKilled();

CBasePlayer *BasePlayer() const;

public:
Expand Down Expand Up @@ -138,6 +146,23 @@ class CCSPlayer: public CCSMonster
bool m_bMegaBunnyJumping;
bool m_bPlantC4Anywhere;
bool m_bSpawnProtectionEffects;
double m_flJumpHeight;
double m_flLongJumpHeight;
double m_flLongJumpForce;
double m_flDuckSpeedMultiplier;

int m_iUserID;
struct CDamageRecord_t
{
float flDamage = 0.0f;
float flFlashDurationTime = 0.0f;
int userId = -1;
};
using DamageList_t = CUtlArray<CDamageRecord_t, MAX_CLIENTS>;
DamageList_t m_DamageList; // A unified array of recorded damage that includes giver and taker in each entry
DamageList_t &GetDamageList() { return m_DamageList; }
int m_iNumKilledByUnanswered[MAX_CLIENTS]; // [0-31] how many unanswered kills this player has been dealt by each other player
bool m_bPlayerDominated[MAX_CLIENTS]; // [0-31] array of state per other player whether player is dominating other players
};

// Inlines
Expand Down
1 change: 1 addition & 0 deletions AccuracyFix/include/cssdk/dlls/API/CSPlayerItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CCSPlayerItem: public CCSAnimating
}

virtual void SetItemInfo(ItemInfo *pInfo) = 0;
virtual int GetItemInfo(ItemInfo *pInfo) = 0;

CBasePlayerItem *BasePlayerItem() const;

Expand Down
18 changes: 16 additions & 2 deletions AccuracyFix/include/cssdk/dlls/API/CSPlayerWeapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,33 @@

#pragma once

enum SecondaryAtkState : uint8_t
{
WEAPON_SECONDARY_ATTACK_NONE = 0,
WEAPON_SECONDARY_ATTACK_SET,
WEAPON_SECONDARY_ATTACK_BLOCK
};

class CBasePlayerWeapon;
class CCSPlayerWeapon: public CCSPlayerItem
{
DECLARE_CLASS_TYPES(CCSPlayerWeapon, CCSPlayerItem);
public:
CCSPlayerWeapon() :
m_bHasSecondaryAttack(false)
m_iStateSecondaryAttack(WEAPON_SECONDARY_ATTACK_NONE)
{
}

virtual BOOL DefaultDeploy(char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0) = 0;
virtual int DefaultReload(int iClipSize, int iAnim, float fDelay) = 0;
virtual bool DefaultShotgunReload(int iAnim, int iStartAnim, float fDelay, float fStartDelay, const char *pszReloadSound1 = nullptr, const char *pszReloadSound2 = nullptr) = 0;
virtual void KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change) = 0;
virtual void SendWeaponAnim(int iAnim, int skiplocal = 0) = 0;

CBasePlayerWeapon *BasePlayerWeapon() const;

public:
bool m_bHasSecondaryAttack;
SecondaryAtkState m_iStateSecondaryAttack;
float m_flBaseDamage;
};

Expand Down
2 changes: 1 addition & 1 deletion AccuracyFix/include/cssdk/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ class CHalfLifeMultiplay: public CGameRules
// check if the scenario has been won/lost
virtual void CheckWinConditions() = 0;
virtual void RemoveGuns() = 0;
virtual void GiveC4() = 0;
virtual CBasePlayer *GiveC4() = 0;
virtual void ChangeLevel() = 0;
virtual void GoToIntermission() = 0;

Expand Down
135 changes: 129 additions & 6 deletions AccuracyFix/include/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <gamerules.h>
#include <client.h>
#include <gib.h>
#include <GameEvent.h>
#include <API/CSInterfaces.h>

#define REGAMEDLL_API_VERSION_MAJOR 5
Expand Down Expand Up @@ -237,10 +238,6 @@ typedef IHookChainRegistry<void, struct playermove_s *, int> IReGameHookRegistry
typedef IHookChain<void, int> IReGameHook_PM_AirMove;
typedef IHookChainRegistry<void, int> IReGameHookRegistry_PM_AirMove;

// PM_LadderMove hook
typedef IHookChain<void, struct physent_s *> IReGameHook_PM_LadderMove;
typedef IHookChainRegistry<void, struct physent_s *> IReGameHookRegistry_PM_LadderMove;

// HandleMenu_ChooseAppearance hook
typedef IHookChain<void, class CBasePlayer *, int> IReGameHook_HandleMenu_ChooseAppearance;
typedef IHookChainRegistry<void, class CBasePlayer *, int> IReGameHookRegistry_HandleMenu_ChooseAppearance;
Expand Down Expand Up @@ -342,8 +339,8 @@ typedef IHookChain<void> IReGameHook_CSGameRules_RemoveGuns;
typedef IHookChainRegistry<void> IReGameHookRegistry_CSGameRules_RemoveGuns;

// CHalfLifeMultiplay::GiveC4 hook
typedef IHookChain<void> IReGameHook_CSGameRules_GiveC4;
typedef IHookChainRegistry<void> IReGameHookRegistry_CSGameRules_GiveC4;
typedef IHookChain<CBasePlayer *> IReGameHook_CSGameRules_GiveC4;
typedef IHookChainRegistry<CBasePlayer *> IReGameHookRegistry_CSGameRules_GiveC4;

// CHalfLifeMultiplay::ChangeLevel hook
typedef IHookChain<void> IReGameHook_CSGameRules_ChangeLevel;
Expand Down Expand Up @@ -529,6 +526,102 @@ typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBa
typedef IHookChain<void, class CGameRules **> IReGameHook_FreeGameRules;
typedef IHookChainRegistry<void, class CGameRules **> IReGameHookRegistry_FreeGameRules;

// PM_LadderMove hook
typedef IHookChain<void, struct physent_s *> IReGameHook_PM_LadderMove;
typedef IHookChainRegistry<void, struct physent_s *> IReGameHookRegistry_PM_LadderMove;

// PM_WaterJump hook
typedef IHookChain<void> IReGameHook_PM_WaterJump;
typedef IHookChainRegistry<void> IReGameHookRegistry_PM_WaterJump;

// PM_CheckWaterJump hook
typedef IHookChain<void> IReGameHook_PM_CheckWaterJump;
typedef IHookChainRegistry<void> IReGameHookRegistry_PM_CheckWaterJump;

// PM_Jump hook
typedef IHookChain<void> IReGameHook_PM_Jump;
typedef IHookChainRegistry<void> IReGameHookRegistry_PM_Jump;

// PM_Duck hook
typedef IHookChain<void> IReGameHook_PM_Duck;
typedef IHookChainRegistry<void> IReGameHookRegistry_PM_Duck;

// PM_UnDuck hook
typedef IHookChain<void> IReGameHook_PM_UnDuck;
typedef IHookChainRegistry<void> IReGameHookRegistry_PM_UnDuck;

// PM_PlayStepSound hook
typedef IHookChain<void, int, float> IReGameHook_PM_PlayStepSound;
typedef IHookChainRegistry<void, int, float> IReGameHookRegistry_PM_PlayStepSound;

// PM_AirAccelerate hook
typedef IHookChain<void, vec_t *, float, float> IReGameHook_PM_AirAccelerate;
typedef IHookChainRegistry<void, vec_t *, float, float> IReGameHookRegistry_PM_AirAccelerate;

// ClearMultiDamage hook
typedef IHookChain<void> IReGameHook_ClearMultiDamage;
typedef IHookChainRegistry<void> IReGameHookRegistry_ClearMultiDamage;

// AddMultiDamage hook
typedef IHookChain<void, entvars_t *, CBaseEntity *, float, int> IReGameHook_AddMultiDamage;
typedef IHookChainRegistry<void, entvars_t *, CBaseEntity *, float, int> IReGameHookRegistry_AddMultiDamage;

// ApplyMultiDamage hook
typedef IHookChain<void, entvars_t *, entvars_t *> IReGameHook_ApplyMultiDamage;
typedef IHookChainRegistry<void, entvars_t *, entvars_t *> IReGameHookRegistry_ApplyMultiDamage;

// BuyItem hook
typedef IHookChain<void, CBasePlayer *, int> IReGameHook_BuyItem;
typedef IHookChainRegistry<void, CBasePlayer *, int> IReGameHookRegistry_BuyItem;

// CHalfLifeMultiplay::Think hook
typedef IHookChain<void> IReGameHook_CSGameRules_Think;
typedef IHookChainRegistry<void> IReGameHookRegistry_CSGameRules_Think;

// CHalfLifeMultiplay::TeamFull hook
typedef IHookChain<BOOL, int> IReGameHook_CSGameRules_TeamFull;
typedef IHookChainRegistry<BOOL, int> IReGameHookRegistry_CSGameRules_TeamFull;

// CHalfLifeMultiplay::TeamStacked hook
typedef IHookChain<BOOL, int, int> IReGameHook_CSGameRules_TeamStacked;
typedef IHookChainRegistry<BOOL, int, int> IReGameHookRegistry_CSGameRules_TeamStacked;

// CHalfLifeMultiplay::PlayerGotWeapon hook
typedef IHookChain<void, CBasePlayer *, CBasePlayerItem *> IReGameHook_CSGameRules_PlayerGotWeapon;
typedef IHookChainRegistry<void, CBasePlayer *, CBasePlayerItem *> IReGameHookRegistry_CSGameRules_PlayerGotWeapon;

// CBotManager::OnEvent hook
typedef IHookChain<void, GameEventType, CBaseEntity *, CBaseEntity *> IReGameHook_CBotManager_OnEvent;
typedef IHookChainRegistry<void, GameEventType, CBaseEntity*, CBaseEntity*> IReGameHookRegistry_CBotManager_OnEvent;

// CBasePlayer::CheckTimeBasedDamage hook
typedef IHookChainClass<void, CBasePlayer> IReGameHook_CBasePlayer_CheckTimeBasedDamage;
typedef IHookChainRegistryClass<void, CBasePlayer> IReGameHookRegistry_CBasePlayer_CheckTimeBasedDamage;

// CBasePlayer::EntSelectSpawnPoint hook
typedef IHookChainClass<edict_t *, CBasePlayer> IReGameHook_CBasePlayer_EntSelectSpawnPoint;
typedef IHookChainRegistryClass<edict_t *, CBasePlayer> IReGameHookRegistry_CBasePlayer_EntSelectSpawnPoint;

// CBasePlayerWeapon::ItemPostFrame hook
typedef IHookChainClass<void, CBasePlayerWeapon> IReGameHook_CBasePlayerWeapon_ItemPostFrame;
typedef IHookChainRegistryClass<void, CBasePlayerWeapon> IReGameHookRegistry_CBasePlayerWeapon_ItemPostFrame;

// CBasePlayerWeapon::KickBack hook
typedef IHookChainClass<void, CBasePlayerWeapon, float, float, float, float, float, float, int> IReGameHook_CBasePlayerWeapon_KickBack;
typedef IHookChainRegistryClass<void, CBasePlayerWeapon, float, float, float, float, float, float, int> IReGameHookRegistry_CBasePlayerWeapon_KickBack;

// CBasePlayerWeapon::SendWeaponAnim hook
typedef IHookChainClass<void, CBasePlayerWeapon, int, int> IReGameHook_CBasePlayerWeapon_SendWeaponAnim;
typedef IHookChainRegistryClass<void, CBasePlayerWeapon, int, int> IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim;

// CHalfLifeMultiplay::SendDeathMessage hook
typedef IHookChain<void, class CBaseEntity *, class CBasePlayer *, class CBasePlayer *, struct entvars_s *, const char *, int, int> IReGameHook_CSGameRules_SendDeathMessage;
typedef IHookChainRegistry<void, class CBaseEntity *, class CBasePlayer *, class CBasePlayer *, struct entvars_s *, const char *, int, int> IReGameHookRegistry_CSGameRules_SendDeathMessage;

// CBasePlayer::PlayerDeathThink hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_PlayerDeathThink;

class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -665,6 +758,30 @@ class IReGameHookchains {

virtual IReGameHookRegistry_FreeGameRules *FreeGameRules() = 0;
virtual IReGameHookRegistry_PM_LadderMove *PM_LadderMove() = 0;
virtual IReGameHookRegistry_PM_WaterJump *PM_WaterJump() = 0;
virtual IReGameHookRegistry_PM_CheckWaterJump *PM_CheckWaterJump() = 0;
virtual IReGameHookRegistry_PM_Jump *PM_Jump() = 0;
virtual IReGameHookRegistry_PM_Duck *PM_Duck() = 0;
virtual IReGameHookRegistry_PM_UnDuck *PM_UnDuck() = 0;
virtual IReGameHookRegistry_PM_PlayStepSound *PM_PlayStepSound() = 0;
virtual IReGameHookRegistry_PM_AirAccelerate *PM_AirAccelerate() = 0;
virtual IReGameHookRegistry_ClearMultiDamage *ClearMultiDamage() = 0;
virtual IReGameHookRegistry_AddMultiDamage *AddMultiDamage() = 0;
virtual IReGameHookRegistry_ApplyMultiDamage *ApplyMultiDamage() = 0;
virtual IReGameHookRegistry_BuyItem *BuyItem() = 0;
virtual IReGameHookRegistry_CSGameRules_Think *CSGameRules_Think() = 0;
virtual IReGameHookRegistry_CSGameRules_TeamFull *CSGameRules_TeamFull() = 0;
virtual IReGameHookRegistry_CSGameRules_TeamStacked *CSGameRules_TeamStacked() = 0;
virtual IReGameHookRegistry_CSGameRules_PlayerGotWeapon *CSGameRules_PlayerGotWeapon() = 0;
virtual IReGameHookRegistry_CBotManager_OnEvent *CBotManager_OnEvent() = 0;
virtual IReGameHookRegistry_CBasePlayer_CheckTimeBasedDamage *CBasePlayer_CheckTimeBasedDamage() = 0;
virtual IReGameHookRegistry_CBasePlayer_EntSelectSpawnPoint *CBasePlayer_EntSelectSpawnPoint() = 0;
virtual IReGameHookRegistry_CBasePlayerWeapon_ItemPostFrame *CBasePlayerWeapon_ItemPostFrame() = 0;
virtual IReGameHookRegistry_CBasePlayerWeapon_KickBack *CBasePlayerWeapon_KickBack() = 0;
virtual IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim *CBasePlayerWeapon_SendWeaponAnim() = 0;
virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage() = 0;

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
};

struct ReGameFuncs_t {
Expand All @@ -685,6 +802,12 @@ struct ReGameFuncs_t {
void (*UTIL_RestartOther)(const char *szClassname);
void (*UTIL_ResetEntities)();
void (*UTIL_RemoveOther)(const char *szClassname, int nCount);
void (*UTIL_DecalTrace)(TraceResult *pTrace, int decalNumber);
void (*UTIL_Remove)(CBaseEntity *pEntity);
int (*AddAmmoNameToAmmoRegistry)(const char *szAmmoname);
void (*TextureTypePlaySound)(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType);
class CWeaponBox *(*CreateWeaponBox)(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo);
class CGrenade *(*SpawnGrenade)(WeaponIdType weaponId, entvars_t *pevOwner, Vector &vecSrc, Vector &vecThrow, float time, int iTeam, unsigned short usEvent);
};

class IReGameApi {
Expand Down
8 changes: 8 additions & 0 deletions AccuracyFix/include/cssdk/public/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ void *Sys_GetProcAddress(void *pModuleHandle, const char *pName)
return GetProcAddress((HMODULE)pModuleHandle, pName);
}

// Purpose: Returns a module handle by its name.
// Input : pModuleName - module name
// Output : the module handle or NULL in case of an error
CSysModule *Sys_GetModuleHandle(const char *pModuleName)
{
return reinterpret_cast<CSysModule *>(GetModuleHandle(pModuleName));
}

// Purpose: Loads a DLL/component from disk and returns a handle to it
// Input : *pModuleName - filename of the component
// Output : opaque handle to the module (hides system dependency)
Expand Down
2 changes: 2 additions & 0 deletions AccuracyFix/include/cssdk/public/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ extern CreateInterfaceFn Sys_GetFactory(const char *pModuleName);
// load/unload components
class CSysModule;

extern CSysModule *Sys_GetModuleHandle(const char *pModuleName);

// Load & Unload should be called in exactly one place for each module
// The factory for that module should be passed on to dependent components for
// proper versioning.
Expand Down
Loading

0 comments on commit e91bd0a

Please sign in to comment.