Refactoring ReGame-API

This commit is contained in:
s1lentq 2016-05-17 19:35:16 +06:00
parent ab4a8437ce
commit d75089461c
6 changed files with 18 additions and 35 deletions

View File

@ -268,7 +268,10 @@ public:
virtual int GetMinorVersion() = 0;
virtual const ReGameFuncs_t* GetFuncs() = 0;
virtual IReGameHookchains* GetHookchains() = 0;
virtual IReGameData* GetGameData() = 0;
virtual class CGameRules* GetGameRules() = 0;
virtual struct WeaponInfoStruct *GetWeaponInfo(int weaponID) = 0;
virtual struct playermove_s *GetPlayerMove() = 0;
};

View File

@ -2071,12 +2071,3 @@ public:
virtual void Spawn() = 0;
virtual void KeyValue(struct KeyValueData_s *pkvd) = 0;
};
class IReGameData {
public:
virtual ~IReGameData() {}
virtual class CGameRules* GetGameRules() = 0;
virtual struct WeaponInfoStruct *GetWeaponInfo(int weaponID) = 0;
virtual struct playermove_s *GetPlayerMove() = 0;
};

View File

@ -28,7 +28,6 @@
#include "precompiled.h"
CReGameHookchains g_ReGameHookchains;
CReGameData g_ReGameData;
ReGameFuncs_t g_ReGameApiFuncs = {
&UTIL_PlayerByIndex,
@ -113,9 +112,16 @@ IReGameHookchains *CReGameApi::GetHookchains()
return &g_ReGameHookchains;
}
IReGameData *CReGameApi::GetGameData()
{
return &g_ReGameData;
CGameRules* EXT_FUNC CReGameApi::GetGameRules() {
return g_pGameRules;
}
WeaponInfoStruct* EXT_FUNC CReGameApi::GetWeaponInfo(int weaponID) {
return ::GetWeaponInfo(weaponID);
}
playermove_t* EXT_FUNC CReGameApi::GetPlayerMove() {
return pmove;
}
void EXT_FUNC Regamedll_ChangeString_api(char *&dest, const char *source)

View File

@ -279,7 +279,6 @@ public:
};
extern CReGameHookchains g_ReGameHookchains;
extern CReGameData g_ReGameData;
extern ReGameFuncs_t g_ReGameApiFuncs;
class CReGameApi: public IReGameApi {
@ -289,7 +288,10 @@ public:
virtual const ReGameFuncs_t *GetFuncs();
virtual IReGameHookchains *GetHookchains();
virtual IReGameData* GetGameData();
virtual CGameRules* GetGameRules();
virtual WeaponInfoStruct *GetWeaponInfo(int weaponID);
virtual playermove_t *GetPlayerMove();
};
void Regamedll_ChangeString_api(char *&dest, const char *source);

View File

@ -134,15 +134,3 @@ ICSEntity *EXT_FUNC INDEX_TO_CSENTITY(int iEntityIndex)
CBaseEntity *pEntity = CBaseEntity::Instance(INDEXENT(iEntityIndex));
return CBASE_TO_CSENTITY(pEntity);
}
CGameRules* EXT_FUNC CReGameData::GetGameRules() {
return g_pGameRules;
}
WeaponInfoStruct* EXT_FUNC CReGameData::GetWeaponInfo(int weaponID) {
return ::GetWeaponInfo(weaponID);
}
playermove_t* EXT_FUNC CReGameData::GetPlayerMove() {
return pmove;
}

View File

@ -2520,13 +2520,6 @@ public:
virtual void KeyValue(KeyValueData *pkvd) { m_pEntity->KeyValue(pkvd); }
};
class CReGameData: public IReGameData {
public:
virtual CGameRules* GetGameRules();
virtual WeaponInfoStruct *GetWeaponInfo(int weaponID);
virtual playermove_t *GetPlayerMove();
};
template <class T>
inline T *Regamedll_InitializeEntities(CBaseEntity *a)
{