2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Added new natives:

rh_emit_sound2, rg_set_account_rules, rg_get_account_rules, rg_is_bomb_planted,
rg_join_team, rg_balance_teams, rg_swap_all_players, rg_switch_team, rg_switch_weapon
Update CSSDK for regamedll
Refactoring
This commit is contained in:
s1lentq 2016-06-15 04:36:35 +07:00
parent 28dcc802d4
commit bc6383fce4
32 changed files with 557 additions and 120 deletions

View File

@ -876,6 +876,7 @@ enum WinStatus
// bypass warning: 200 on amxmodx 1.8.2
#if AMXX_VERSION_NUM < 183
#define ROUND_ESCAPING_TERRORISTS_NEUTRALIZED ROUND_ESCAPING_TERRORISTS_NEUTR
#define RR_ESCAPING_TERRORISTS_NEUTRALIZED RR_ESCAPING_TERRORISTS_NEUTR
#endif
// used for EndRoundMessage() logged messages
@ -1024,3 +1025,30 @@ enum Bullet
BULLET_PLAYER_57MM,
BULLET_PLAYER_357SIG,
};
enum RewardRules
{
RR_CTS_WIN,
RR_TERRORISTS_WIN,
RR_TARGET_BOMB,
RR_VIP_ESCAPED,
RR_VIP_ASSASSINATED,
RR_TERRORISTS_ESCAPED,
RR_CTS_PREVENT_ESCAPE,
RR_ESCAPING_TERRORISTS_NEUTRALIZED,
RR_BOMB_DEFUSED,
RR_BOMB_PLANTED,
RR_BOMB_EXPLODED,
RR_ALL_HOSTAGES_RESCUED,
RR_TARGET_BOMB_SAVED,
RR_HOSTAGE_NOT_RESCUED,
RR_VIP_NOT_ESCAPED,
RR_LOSER_BONUS_DEFAULT,
RR_LOSER_BONUS_MIN,
RR_LOSER_BONUS_MAX,
RR_LOSER_BONUS_ADD,
RR_RESCUED_HOSTAGE,
RR_TOOK_HOSTAGE_ACC,
RR_TOOK_HOSTAGE,
RR_END
};

View File

@ -13,6 +13,34 @@
#pragma library reapi
#endif
enum hooks_tables_e
{
ht_engine,
ht_gamedll,
ht_animating,
ht_player,
ht_gamerules
};
enum members_tables_e
{
mt_gamerules,
mt_base,
mt_animating,
mt_basemonster,
mt_player,
mt_entvars,
mt_playermove,
mt_movevars,
mt_usercmd,
mt_pmtrace
};
#define MAX_REGION_RANGE 1024
#define BEGIN_FUNC_REGION(%0) (any:MAX_REGION_RANGE * hooks_tables_e:ht_%0)
#define BEGIN_MEMBER_REGION(%0) (any:MAX_REGION_RANGE * members_tables_e:mt_%0)
#include <cssdk_const>
#include <reapi_engine> // NOTE: only for ReHLDS

View File

@ -60,3 +60,21 @@ native rh_get_mapname(output[], len, MapNameType:type = MNT_SET);
*
*/
native rh_reset_mapname();
/*
* Emits a sound from an entity from the engine.
*
* @param entity Entity index or use 0 to emit from worldspawn at the specified position
* @param recipient Recipient index or use 0 to heard for all clients
* @param channel Channel to emit from
* @param sample Sound file to emit
* @param vol Volume in percent
* @param attn Sound attenuation
* @param flags Emit flags
* @param pitch Sound pitch
* @param emitFlags Additional Emit2 flags, look at the defines like SND_EMIT2_*
* @return 1 if successfully sounds are emitted, 0 otherwise
*
*/
native rh_emit_sound2(const entity, const recipient, const channel, const sample[], Float:vol = VOL_NORM, Float:attn = ATTN_NORM, const flags = 0, const pitch = PITCH_NORM, emitFlags = 0, const Float:origin[3] = {0.0,0.0,0.0});

View File

@ -7,13 +7,17 @@
// for natives rh_get_mapname
enum MapNameType { MNT_TRUE, MNT_SET };
// rh_emit_sound2 flags
#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS
#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker
enum EngineFunc
{
/*
* Description: -
* Params: (const recipients, const entity, const channel, const sample[], const volume, Float:attenuation, const fFlags, const pitch)
*/
RH_SV_StartSound = 0 * 1024,
RH_SV_StartSound = BEGIN_FUNC_REGION(engine),
/*
* Description: -
@ -32,9 +36,6 @@ enum EngineFunc
* Params: (pcvar, const value[])
*/
RH_Cvar_DirectSet,
// [...]
RH_EngineFunc_End
};
enum EntVars
@ -45,7 +46,7 @@ enum EntVars
* Get params: get_entvar(index, EntVars:var, dest[], const lenght);
* Set params: set_entvar(index, EntVars:var, const source[]);
*/
var_classname = 5 * 1024,
var_classname = BEGIN_MEMBER_REGION(entvars),
/*
* Description: -
@ -1032,7 +1033,7 @@ enum UCmd
* Get params: get_ucmd(const ucmd, UserCmd:var);
* Set params: set_ucmd(const ucmd, UserCmd:var, value);
*/
ucmd_lerp_msec = 8 * 1024,
ucmd_lerp_msec = BEGIN_MEMBER_REGION(usercmd),
/*
* Description: -

View File

@ -125,10 +125,11 @@ native rg_add_account(const index, amount, AccountSet:typeSet = AS_ADD, bool:bTr
*
* @param index Client index
* @param pszName Classname item
* @param type Look at the enum's with name GiveType
*
* @noreturn
* @return 1 if successfully, 0 otherwise
*/
native rg_give_item(index, const pszName[], GiveType:type = GT_APPEND);
native rg_give_item(const index, const pszName[], GiveType:type = GT_APPEND);
/*
* Give the player default items
@ -318,7 +319,7 @@ native rg_set_weapon_info(const {WeaponIdType,_}:weapon_id, WpnInfo:type, any:..
* @noreturn
*
*/
native rg_remove_all_items(const index, bool:bRemoveSuit);
native rg_remove_all_items(const index, bool:bRemoveSuit = false);
/*
* Remove specifed the player's item by class name
@ -444,9 +445,87 @@ native rg_transfer_c4(const index, const receiver = 0);
* Instant reload weapons
*
* @param index Client index
* @param weapon Entity weapons, if 0 then all the weapons
* @param weapon Weapon entity-index, if 0 then all the weapons
*
* @return 1 if successfully, 0 otherwise
*
*/
native rg_instant_reload_weapons(const index, const weapon = 0);
/*
* Sets the amount of reward in the game account for all players.
*
* @param rules_index Look at the enum's with name RewardRules
* @param amount The amount money
*
* @noreturn
*
*/
native rg_set_account_rules(const RewardRules:rules_index, const amount);
/*
* Get the amount of reward from account
*
* @param rules_index Look at the enum's with name RewardRules
*
* @return The amount of reward from account
*
*/
native rg_get_account_rules(const RewardRules:rules_index);
/*
* If the bomb is planted
*
* @return 1 if successfully, 0 otherwise
*
*/
native bool:rg_is_bomb_planted();
/*
* Join team
*
* @param index Client index
* @param team Team id
*
* @return 1 if successfully joined the team, 0 otherwise
*
*/
native rg_join_team(const index, const TeamName:team);
/*
* Instantly balances the team.
*
* @noreturn
*
*/
native rg_balance_teams();
/*
* To swap players, without reset frags/deaths and the amount wins.
*
* @noreturn
*
*/
native rg_swap_all_players();
/*
* Instantly switches to the opposite team for one player.
* @note Switch from CT to TERRORIST also opposite.
*
* @param index Client index
*
* @noreturn
*
*/
native rg_switch_team(const index);
/*
* Switch to specific weapon
*
* @param index Client index
* @param weapon Weapon entity-index
*
* @return 1 if successfully switched, 0 otherwise
*
*/
native rg_switch_weapon(const index, const weapon);

View File

@ -138,7 +138,7 @@ enum GamedllFunc
* Return type: int
* Params: (const pObserver)
*/
RG_GetForceCamera = 1 * 1024,
RG_GetForceCamera = BEGIN_FUNC_REGION(gamedll),
/*
* Description: -
@ -196,12 +196,9 @@ enum GamedllFunc
/*
* Description: -
* Params: (const index, VGUIMenu:menuType, const bitsSlots, szOldMenu[])
* Params: (const index, VGUIMenu:menuType, const bitsSlots, szOldMenu[], bool:bForceOldMenu)
*/
RG_ShowVGUIMenu,
// [...]
RG_End
RG_ShowVGUIMenu
};
enum GamedllFunc_CBaseAnimating
@ -210,10 +207,7 @@ enum GamedllFunc_CBaseAnimating
* Description: -
* Params: (const this)
*/
RG_CBaseAnimating_ResetSequenceInfo = 2 * 1024,
// [...]
RG_CBaseAnimating_End
RG_CBaseAnimating_ResetSequenceInfo = BEGIN_FUNC_REGION(animating)
};
enum GamedllFunc_CBasePlayer
@ -222,7 +216,7 @@ enum GamedllFunc_CBasePlayer
* Description: -
* Params: (const this)
*/
RG_CBasePlayer_Spawn = 3 * 1024,
RG_CBasePlayer_Spawn = BEGIN_FUNC_REGION(player),
/*
* Description: -
@ -402,10 +396,7 @@ enum GamedllFunc_CBasePlayer
* Description: -
* Params: (const this, bool:bDeploy)
*/
RG_CBasePlayer_GiveShield,
// [...]
RG_CBasePlayer_End
RG_CBasePlayer_GiveShield
};
enum GamedllFunc_CSGameRules
@ -414,7 +405,7 @@ enum GamedllFunc_CSGameRules
* Description: -
* Params: (const index, const weapon)
*/
RG_CSGameRules_FShouldSwitchWeapon = 4 * 1024,
RG_CSGameRules_FShouldSwitchWeapon = BEGIN_FUNC_REGION(gamerules),
/*
* Description: -
@ -540,10 +531,7 @@ enum GamedllFunc_CSGameRules
* Description: -
* Params: ()
*/
RG_CSGameRules_BalanceTeams,
// [...]
RG_CSGameRules_End
RG_CSGameRules_BalanceTeams
};
// CSGameRules
@ -555,7 +543,7 @@ enum CSGameRules_Members
* Get params: get_member_game(member);
* Set params: set_member_game(member, value);
*/
m_bFreezePeriod = 0 * 1024,
m_bFreezePeriod = BEGIN_MEMBER_REGION(gamerules),
/*
* Description: -
@ -565,6 +553,14 @@ enum CSGameRules_Members
*/
m_bBombDropped,
/*
* Description: -
* Member type: char *
* Get params: get_member_game(member, dest[], const lenght);
* Set params: set_member_game(member, const source[]);
*/
m_GameDesc,
/*
* Description: -
* Member type: int
@ -1200,7 +1196,7 @@ enum CBaseEntity_Members
* Get params: Float:get_member(index, member);
* Set params: set_member(index, member, Float:value);
*/
currentammo = 1 * 1024,
currentammo = BEGIN_MEMBER_REGION(base),
/*
* Description: -
@ -1404,7 +1400,7 @@ enum CBaseAnimating_Members
* Get params: Float:get_member(index, member);
* Set params: set_member(index, member, Float:value);
*/
m_flFrameRate = 2 * 1024,
m_flFrameRate = BEGIN_MEMBER_REGION(animating),
/*
* Description: -
@ -1448,7 +1444,7 @@ enum CBaseMonster_Members
* Get params: get_member(index, member);
* Set params: set_member(index, member, value);
*/
m_Activity = 3 * 1024,
m_Activity = BEGIN_MEMBER_REGION(basemonster),
/*
* Description: -
@ -1580,7 +1576,7 @@ enum CBasePlayer_Members
* Get params: get_member(index, member);
* Set params: set_member(index, member, value);
*/
random_seed = 4 * 1024,
random_seed = BEGIN_MEMBER_REGION(player),
/*
* Description: -
@ -3079,7 +3075,7 @@ enum PlayerMove
* Get params: get_pmove(member);
* Set params: set_pmove(const PlayerMove:var, value);
*/
pm_player_index = 6 * 1024,
pm_player_index = BEGIN_MEMBER_REGION(playermove),
/*
* Description: -
@ -3562,7 +3558,7 @@ enum MoveVars
* Get params: Float:get_mvar(const MoveVars:var);
* Set params: set_mvar(const MoveVars:var, Float:value);
*/
mv_gravity = 7 * 1024,
mv_gravity = BEGIN_MEMBER_REGION(movevars),
/*
* Description: -
@ -3773,7 +3769,7 @@ enum PMTrace
* Get params: get_pmtrace(const tr, const PMTrace:var);
* Set params: set_pmtrace(const tr, const PMTrace:var, value);
*/
pmt_allsolid = 9 * 1024,
pmt_allsolid = BEGIN_MEMBER_REGION(pmtrace),
/*
* Description: -

View File

@ -71,6 +71,9 @@
#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time
#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client
// SV_EmitSound2 flags
#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS
#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker
// Engine edict->spawnflags
#define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file

View File

@ -209,6 +209,8 @@ enum
class CItem;
class CGameRules {
protected:
virtual ~CGameRules() {};
public:
virtual void RefreshSkillData() = 0;
virtual void Think() = 0;
@ -280,9 +282,14 @@ public:
public:
BOOL m_bFreezePeriod;
BOOL m_bBombDropped;
// custom
char *m_GameDesc;
};
class CHalfLifeRules: public CGameRules {
protected:
virtual ~CHalfLifeRules() {};
public:
virtual void Think() = 0;
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0;
@ -328,6 +335,8 @@ public:
};
class CHalfLifeMultiplay: public CGameRules {
protected:
virtual ~CHalfLifeMultiplay() {};
public:
virtual void RefreshSkillData() = 0;
virtual void Think() = 0;
@ -407,6 +416,7 @@ public:
virtual void UpdateTeamScores() = 0;
virtual void EndRoundMessage(const char *sentence, int event) = 0;
virtual void SetAccountRules(RewardRules rules, int amount) = 0;
virtual RewardAccount GetAccountRules(RewardRules rules) const = 0;
// BOMB MAP FUNCTIONS
virtual BOOL IsThereABomber() = 0;

View File

@ -342,6 +342,10 @@ public:
virtual void Blind(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha) = 0;
virtual void OnTouchingWeapon(CWeaponBox *pWeapon) = 0;
public:
static CBasePlayer *Instance(edict_t *pent) { return (CBasePlayer *)GET_PRIVATE(pent ? pent : ENT(0)); }
static CBasePlayer *Instance(entvars_t *pev) { return Instance(ENT(pev)); }
static CBasePlayer *Instance(int offset) { return Instance(ENT(offset)); }
int IsObserver() { return pev->iuser1; }
void SetWeaponAnimType(const char *szExtention) { strcpy(m_szAnimExtention, szExtention); }
bool IsProtectedByShield() { return m_bOwnsShield && m_bShieldDrawn; }

View File

@ -210,8 +210,8 @@ typedef IVoidHookChain<class CBasePlayer *, int, int, BOOL, char *> IReGameHook_
typedef IVoidHookChainRegistry<class CBasePlayer *, int, int, BOOL, char *> IReGameHookRegistry_ShowMenu;
// ShowVGUIMenu hook
typedef IVoidHookChain<class CBasePlayer *, int, int, char *> IReGameHook_ShowVGUIMenu;
typedef IVoidHookChainRegistry<class CBasePlayer *, int, int, char *> IReGameHookRegistry_ShowVGUIMenu;
typedef IVoidHookChain<class CBasePlayer *, int, int, char *, bool> IReGameHook_ShowVGUIMenu;
typedef IVoidHookChainRegistry<class CBasePlayer *, int, int, char *, bool> IReGameHookRegistry_ShowVGUIMenu;
// CHalfLifeMultiplay::FShouldSwitchWeapon hook
typedef IHookChain<BOOL, class CBasePlayer *, class CBasePlayerItem *> IReGameHook_CSGameRules_FShouldSwitchWeapon;
@ -379,20 +379,17 @@ public:
struct ReGameFuncs_t {
class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex);
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
void (*ChangeString)(char *&dest, const char *source);
void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType);
void (*ClearMultiDamage)();
void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker);
void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
};
class IReGameApi {
public:
virtual ~IReGameApi() { }
virtual ~IReGameApi() {}
virtual int GetMajorVersion() = 0;
virtual int GetMinorVersion() = 0;
@ -405,7 +402,6 @@ public:
virtual struct playermove_s* GetPlayerMove() = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0;
};
#define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001"

View File

@ -78,7 +78,14 @@ public:
virtual void SetBombIcon(bool bFlash = false);
virtual void SetScoreAttrib(CBasePlayer *dest);
virtual void SendItemStatus();
virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr);
virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr, bool bForceReload = false, bool bForceRefill = false);
virtual void Observer_SetMode(int iMode);
virtual bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot);
virtual bool SwitchWeapon(CBasePlayerItem *pWeapon);
virtual void SwitchTeam();
virtual bool JoinTeam(TeamName team);
virtual void StartObserver(Vector& vecPosition, Vector& vecViewAngle);
virtual void TeamChangeUpdate();
CBasePlayer *BasePlayer() const;
public:

View File

@ -28,6 +28,8 @@
#pragma once
class CHalfLifeTraining: public CHalfLifeMultiplay {
protected:
virtual ~CHalfLifeTraining() {};
public:
virtual BOOL IsMultiplayer() = 0;
virtual BOOL IsDeathmatch() = 0;

View File

@ -185,6 +185,10 @@ typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f;
typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHookRegistry_SV_CreatePacketEntities;
//SV_EmitSound2 hook
typedef IHookChain<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHook_SV_EmitSound2;
typedef IHookChainRegistry<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHookRegistry_SV_EmitSound2;
class IRehldsHookchains {
public:
virtual ~IRehldsHookchains() { }
@ -226,6 +230,7 @@ public:
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0;
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0;
};
struct RehldsFuncs_t {
@ -273,6 +278,8 @@ struct RehldsFuncs_t {
qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist);
qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key);
void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
};
class IRehldsApi {

View File

@ -39,6 +39,7 @@ public:
// invoked when killed
virtual void Killed(entvars_t *pevAttacker, int iGib) = 0;
virtual BOOL IsNetClient() = 0;
virtual void Think() = 0;
virtual BOOL IsBot() = 0;
virtual Vector GetAutoaimVector(float flDelta) = 0;

View File

@ -263,6 +263,7 @@
<ResourceCompile Include="reapi.rc" />
</ItemGroup>
<ItemGroup>
<None Include="..\extra\amxmodx\scripting\include\cssdk_const.inc" />
<None Include="..\extra\amxmodx\scripting\include\reapi.inc" />
<None Include="..\extra\amxmodx\scripting\include\reapi_engine.inc" />
<None Include="..\extra\amxmodx\scripting\include\reapi_engine_const.inc" />

View File

@ -764,6 +764,9 @@
<None Include="..\src\reapi_version.inc">
<Filter>src</Filter>
</None>
<None Include="..\extra\amxmodx\scripting\include\cssdk_const.inc">
<Filter>amxmodx\scripting\include</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="reapi.rc" />

View File

@ -684,14 +684,14 @@ void ShowMenu(IReGameHook_ShowMenu *chain, CBasePlayer *pPlayer, int bitsValidSl
callVoidForward(RG_ShowMenu, original, indexOfEdict(pPlayer->pev), bitsValidSlots, nDisplayTime, fNeedMore, pszText);
}
void ShowVGUIMenu(IReGameHook_ShowVGUIMenu *chain, CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu)
void ShowVGUIMenu(IReGameHook_ShowVGUIMenu *chain, CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu, bool bForceOldMenu)
{
auto original = [chain](int _pPlayer, int _MenuType, int _BitMask, char *_szOldMenu)
auto original = [chain](int _pPlayer, int _MenuType, int _BitMask, char *_szOldMenu, bool _bForceOldMenu)
{
chain->callNext(getPrivate<CBasePlayer>(_pPlayer), _MenuType, _BitMask, _szOldMenu);
chain->callNext(getPrivate<CBasePlayer>(_pPlayer), _MenuType, _BitMask, _szOldMenu, _bForceOldMenu);
};
callVoidForward(RG_ShowVGUIMenu, original, indexOfEdict(pPlayer->pev), MenuType, BitMask, szOldMenu);
callVoidForward(RG_ShowVGUIMenu, original, indexOfEdict(pPlayer->pev), MenuType, BitMask, szOldMenu, bForceOldMenu);
}
int g_iClientStartSpeak, g_iClientStopSpeak;

View File

@ -306,7 +306,7 @@ void CBasePlayer_SetClientUserInfoName(IReGameHook_CBasePlayer_SetClientUserInfo
void HandleMenu_ChooseAppearance(IReGameHook_HandleMenu_ChooseAppearance *chain, CBasePlayer *pPlayer, int slot);
BOOL HandleMenu_ChooseTeam(IReGameHook_HandleMenu_ChooseTeam *chain, CBasePlayer *pPlayer, int slot);
void ShowMenu(IReGameHook_ShowMenu *chain, CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText);
void ShowVGUIMenu(IReGameHook_ShowVGUIMenu *chain, CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu);
void ShowVGUIMenu(IReGameHook_ShowVGUIMenu *chain, CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu, bool bForceOldMenu);
extern int g_iClientStartSpeak;
extern int g_iClientStopSpeak;

View File

@ -3,7 +3,7 @@
edict_t* g_pEdicts;
playermove_t* g_pMove;
char g_szMapName[32];
int gmsgSendAudio, gmsgTeamScore, gmsgStatusIcon, gmsgArmorType, gmsgTeamInfo, gmsgItemStatus;
int gmsgSendAudio, gmsgStatusIcon, gmsgArmorType, gmsgTeamInfo, gmsgItemStatus;
struct
{
@ -11,7 +11,6 @@ struct
int& id;
} g_RegUserMsg[] = {
{ "SendAudio", gmsgSendAudio },
{ "TeamScore", gmsgTeamScore },
{ "StatusIcon", gmsgStatusIcon },
{ "ArmorType", gmsgArmorType },
{ "TeamInfo", gmsgTeamInfo },

View File

@ -4,7 +4,6 @@ extern char g_szMapName[32];
extern edict_t* g_pEdicts;
extern playermove_t* g_pMove;
extern int gmsgSendAudio;
extern int gmsgTeamScore;
extern int gmsgStatusIcon;
extern int gmsgArmorType;
extern int gmsgTeamInfo;

View File

@ -86,6 +86,7 @@ int regmember::current_cell = 1;
member_t memberlist_gamerules[] = {
GM_MEMBERS(m_bFreezePeriod),
GM_MEMBERS(m_bBombDropped),
GM_MEMBERS(m_GameDesc),
// m_VoiceGameMgr ->
GM_VOICE_MEMBERS(m_msgPlayerVoiceMask),
GM_VOICE_MEMBERS(m_msgRequestState),
@ -663,7 +664,7 @@ memberlist_t memberlist;
member_t *memberlist_t::operator[](size_t members) const
{
#define CASE(h) case ht_##h: if (index < arraysize(memberlist_##h)) return &memberlist_##h[index]; else break;
#define CASE(h) case mt_##h: if (index < arraysize(memberlist_##h)) return &memberlist_##h[index]; else break;
const auto table = members_tables_e(members / MAX_REGION_RANGE);
const auto index = members & (MAX_REGION_RANGE - 1);

View File

@ -1,6 +1,6 @@
#pragma once
#define BEGIN_MEMBER_REGION(x) (MAX_REGION_RANGE * memberlist_t::members_tables_e::ht_##x)
#define BEGIN_MEMBER_REGION(x) (MAX_REGION_RANGE * memberlist_t::members_tables_e::mt_##x)
// member types
enum MType
@ -40,16 +40,16 @@ struct memberlist_t
enum members_tables_e
{
ht_gamerules,
ht_base,
ht_animating,
ht_basemonster,
ht_player,
ht_entvars,
ht_playermove,
ht_movevars,
ht_usercmd,
ht_pmtrace
mt_gamerules,
mt_base,
mt_animating,
mt_basemonster,
mt_player,
mt_entvars,
mt_playermove,
mt_movevars,
mt_usercmd,
mt_pmtrace
};
};
@ -60,6 +60,7 @@ enum CSGameRules_Members
{
m_bFreezePeriod = BEGIN_MEMBER_REGION(gamerules),
m_bBombDropped,
m_GameDesc,
// m_VoiceGameMgr -> CVoiceGameMgr
m_msgPlayerVoiceMask,

View File

@ -8,24 +8,16 @@ CGameRules *g_pGameRules = nullptr;
bool RegamedllApi_Init()
{
const char *szGameDLLModule = GET_GAME_INFO(PLID, GINFO_REALDLL_FULLPATH);
if (szGameDLLModule == NULL)
{
if (!szGameDLLModule)
return false;
}
CSysModule *gameModule = Sys_LoadModule(szGameDLLModule);
if (!gameModule)
{
return false;
}
CreateInterfaceFn ifaceFactory = Sys_GetFactory(gameModule);
if (!ifaceFactory)
{
return false;
}
int retCode = 0;
g_ReGameApi = (IReGameApi *)ifaceFactory(VRE_GAMEDLL_API_VERSION, &retCode);
@ -40,13 +32,13 @@ bool RegamedllApi_Init()
if (majorVersion != REGAMEDLL_API_VERSION_MAJOR)
{
UTIL_LogPrintf("[%s]: ReGameDLL Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REGAMEDLL_API_VERSION_MAJOR, majorVersion);
UTIL_ServerPrint("[%s]: ReGameDLL Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REGAMEDLL_API_VERSION_MAJOR, majorVersion);
return false;
}
if (minorVersion < REGAMEDLL_API_VERSION_MINOR)
{
UTIL_LogPrintf("[%s]: ReGameDLL Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REGAMEDLL_API_VERSION_MINOR, minorVersion);
UTIL_ServerPrint("[%s]: ReGameDLL Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REGAMEDLL_API_VERSION_MINOR, minorVersion);
return false;
}

View File

@ -15,36 +15,30 @@ bool RehldsApi_Init()
#endif
if (!engineModule)
{
return false;
}
CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule);
if (!ifaceFactory)
{
return false;
}
int retCode = 0;
g_RehldsApi = (IRehldsApi*)ifaceFactory(VREHLDS_HLDS_API_VERSION, &retCode);
if (!g_RehldsApi)
{
return false;
}
int majorVersion = g_RehldsApi->GetMajorVersion();
int minorVersion = g_RehldsApi->GetMinorVersion();
if (majorVersion != REHLDS_API_VERSION_MAJOR)
{
UTIL_LogPrintf("[%s]: ReHLDS Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR, majorVersion);
UTIL_ServerPrint("[%s]: ReHLDS Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REHLDS_API_VERSION_MAJOR, majorVersion);
return false;
}
if (minorVersion < REHLDS_API_VERSION_MINOR)
{
UTIL_LogPrintf("[%s]: ReHLDS Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REHLDS_API_VERSION_MINOR, minorVersion);
UTIL_ServerPrint("[%s]: ReHLDS Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REHLDS_API_VERSION_MINOR, minorVersion);
return false;
}

View File

@ -4,22 +4,21 @@ IReunionApi* g_ReunionApi;
bool ReunionApi_Init()
{
if (g_RehldsApi == nullptr)
if (!g_RehldsApi)
return false;
g_ReunionApi = (IReunionApi *)g_RehldsApi->GetFuncs()->GetPluginApi("reunion");
if (g_ReunionApi == nullptr) {
if (!g_ReunionApi)
return false;
}
if (g_ReunionApi->version_major != REUNION_API_VERSION_MAJOR) {
UTIL_LogPrintf("[%s]: Reunion Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MAJOR, g_ReunionApi->version_major);
UTIL_ServerPrint("[%s]: Reunion Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MAJOR, g_ReunionApi->version_major);
return false;
}
if (g_ReunionApi->version_minor < REUNION_API_VERSION_MINOR) {
UTIL_LogPrintf("[%s]: Reunion Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MINOR, g_ReunionApi->version_minor);
UTIL_ServerPrint("[%s]: Reunion Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MINOR, g_ReunionApi->version_minor);
return false;
}

View File

@ -4,25 +4,24 @@ IVoiceTranscoderAPI *g_pVoiceTranscoderApi;
bool VTC_Api_Init()
{
if (g_RehldsApi == nullptr)
if (!g_RehldsApi)
return false;
g_pVoiceTranscoderApi = (IVoiceTranscoderAPI *)g_RehldsApi->GetFuncs()->GetPluginApi("VoiceTranscoder");
if (g_pVoiceTranscoderApi == nullptr) {
if (!g_pVoiceTranscoderApi)
return false;
}
int majorVersion = g_pVoiceTranscoderApi->GetMajorVersion();
int minorVersion = g_pVoiceTranscoderApi->GetMinorVersion();
if (majorVersion != VOICETRANSCODER_API_VERSION_MAJOR) {
UTIL_LogPrintf("[%s]: VTC Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MAJOR, majorVersion);
UTIL_ServerPrint("[%s]: VTC Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MAJOR, majorVersion);
return false;
}
if (minorVersion < VOICETRANSCODER_API_VERSION_MINOR) {
UTIL_LogPrintf("[%s]: VTC Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MINOR, minorVersion);
UTIL_ServerPrint("[%s]: VTC Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MINOR, minorVersion);
return false;
}

View File

@ -9,7 +9,7 @@ public:
CAmxArg(AMX* amx, cell value) : m_amx(amx), m_value(value) {}
operator float() const
{
return *(float *)m_value;
return *(float *)&m_value;
}
operator Vector&() const
{
@ -44,9 +44,32 @@ public:
return nullptr;
return g_ReGameFuncs->UTIL_PlayerByIndex(m_value);
}
operator TeamName() const { return static_cast<TeamName>(m_value); }
operator ModelName() const { return static_cast<ModelName>(m_value); }
operator PLAYER_ANIM() const { return static_cast<PLAYER_ANIM>(m_value); }
operator IGameClient *() const
{
if (m_value <= 0)
return nullptr;
return g_RehldsSvs->GetClient(m_value - 1); // id: 0 - 31
}
operator edict_t *() const
{
return edictByIndexAmx(m_value);
}
operator const float *() const
{
return (float *)getAmxAddr(m_amx, m_value);
}
operator TeamName() const
{
return static_cast<TeamName>(m_value);
}
operator ModelName() const
{
return static_cast<ModelName>(m_value);
}
operator PLAYER_ANIM() const
{
return static_cast<PLAYER_ANIM>(m_value);
}
Vector& vector() const
{
return operator Vector&();

View File

@ -66,8 +66,9 @@ enum GiveType { GT_APPEND, GT_REPLACE, GT_DROP_AND_REPLACE };
*
* @param index Client index
* @param pszName Classname item
* @param type Look at the enum's with name GiveType
*
* @noreturn
* @return 1 if successfully, 0 otherwise
*
* native rg_give_item(index, const pszName[], GiveType:type = GT_APPEND);
*/
@ -443,7 +444,7 @@ cell AMX_NATIVE_CALL rg_update_teamscores(AMX *amx, cell *params)
CSGameRules()->m_iNumCTWins = ((params[arg_add] != 0) ? CSGameRules()->m_iNumCTWins : 0) + params[arg_cts];
CSGameRules()->m_iNumTerroristWins = ((params[arg_add] != 0) ? CSGameRules()->m_iNumTerroristWins : 0) + params[arg_ts];
UpdateTeamScores();
CSGameRules()->UpdateTeamScores();
return TRUE;
}
@ -1147,13 +1148,197 @@ cell AMX_NATIVE_CALL rg_transfer_c4(AMX *amx, cell *params)
* Instant reload weapons
*
* @param index Client index
* @param weapon Entity weapons, if 0 then all the weapons
* @param weapon Weapon entity-index, if 0 then all the weapons
*
* @return 1 if successfully, 0 otherwise
*
* native rg_instant_reload_weapons(const index, const weapon = 0);
*/
cell AMX_NATIVE_CALL rg_instant_reload_weapons(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_weapon, arg_force_reload, arg_force_refill };
CHECK_ISPLAYER(arg_index);
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
if (pPlayer == nullptr || pPlayer->has_disconnected) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
return FALSE;
}
CBasePlayerWeapon *pWeapon = nullptr;
if (params[arg_weapon] != 0)
{
pWeapon = getPrivate<CBasePlayerWeapon>(params[arg_weapon]);
if (pWeapon == nullptr || !pWeapon->IsWeapon()) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid entity weapon", __FUNCTION__);
return FALSE;
}
}
pPlayer->CSPlayer()->ReloadWeapons(pWeapon, true, true);
return TRUE;
}
/*
* Sets the amount of reward in the game account for all players.
*
* @param rules_index Look at the enum's with name RewardRules
* @param amount The amount money
*
* @noreturn
*
* native rg_set_account_rules(const RewardRules:rules_index, const amount);
*/
cell AMX_NATIVE_CALL rg_set_account_rules(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_rules_index, arg_amount };
if (g_pGameRules == nullptr) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__);
return FALSE;
}
CSGameRules()->SetAccountRules(static_cast<RewardRules>(params[arg_rules_index]), params[arg_amount]);
return TRUE;
}
/*
* Get the amount of reward from account
*
* @param rules_index Look at the enum's with name RewardRules
*
* @return The amount of reward from account
*
* native rg_get_account_rules(const RewardRules:rules_index);
*/
cell AMX_NATIVE_CALL rg_get_account_rules(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_rules_index };
if (g_pGameRules == nullptr) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__);
return FALSE;
}
return (cell)CSGameRules()->GetAccountRules(static_cast<RewardRules>(params[arg_rules_index]));
}
/*
* If the bomb is planted
*
* @return 1 if successfully, 0 otherwise
*
* native bool:rg_is_bomb_planted();
*/
cell AMX_NATIVE_CALL rg_is_bomb_planted(AMX *amx, cell *params)
{
if (g_pGameRules == nullptr) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__);
return FALSE;
}
return (cell)CSGameRules()->IsBombPlanted();
}
/*
* Join team
*
* @param index Client index
* @param team Team id
*
* @return 1 if successfully joined the team, 0 otherwise
*
* native rg_join_team(const index, const TeamName:team);
*/
cell AMX_NATIVE_CALL rg_join_team(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_team };
CHECK_ISPLAYER(arg_index);
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
if (pPlayer == nullptr || pPlayer->has_disconnected) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
return FALSE;
}
return (cell)pPlayer->CSPlayer()->JoinTeam(static_cast<TeamName>(params[arg_team]));
}
/*
* Instantly balances the team.
*
* @noreturn
*
* native rg_balance_teams();
*/
cell AMX_NATIVE_CALL rg_balance_teams(AMX *amx, cell *params)
{
if (g_pGameRules == nullptr) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__);
return FALSE;
}
CSGameRules()->BalanceTeams();
return TRUE;
}
/*
* To swap players, without reset frags/deaths and the amount wins.
*
* @noreturn
*
* native rg_swap_all_players();
*/
cell AMX_NATIVE_CALL rg_swap_all_players(AMX *amx, cell *params)
{
if (g_pGameRules == nullptr) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__);
return FALSE;
}
CSGameRules()->SwapAllPlayers();
return TRUE;
}
/*
* Instantly switches to the opposite team for one player.
* @note Switch from CT to TERRORIST also opposite.
*
* @param index Client index
*
* @noreturn
*
* native rg_switch_team(const index);
*/
cell AMX_NATIVE_CALL rg_switch_team(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index };
CHECK_ISPLAYER(arg_index);
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
if (pPlayer == nullptr || pPlayer->has_disconnected) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
return FALSE;
}
pPlayer->CSPlayer()->SwitchTeam();
return TRUE;
}
/*
* Switch to specific weapon
*
* @param index Client index
* @param weapon Weapon entity-index
*
* @return 1 if successfully switched, 0 otherwise
*
* native rg_switch_weapon(const index, const weapon);
*/
cell AMX_NATIVE_CALL rg_switch_weapon(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_weapon };
@ -1166,13 +1351,12 @@ cell AMX_NATIVE_CALL rg_instant_reload_weapons(AMX *amx, cell *params)
}
auto pWeapon = getPrivate<CBasePlayerWeapon>(params[arg_weapon]);
if (params[arg_weapon] != 0 && pWeapon == nullptr) {
if (pWeapon == nullptr || !pWeapon->IsWeapon()) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid entity weapon", __FUNCTION__);
return FALSE;
}
pPlayer->CSPlayer()->ReloadWeapons(pWeapon);
return TRUE;
return (cell)pPlayer->CSPlayer()->SwitchWeapon(pWeapon);
}
AMX_NATIVE_INFO Misc_Natives_RG[] =
@ -1220,6 +1404,16 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
{ "rg_transfer_c4", rg_transfer_c4 },
{ "rg_instant_reload_weapons", rg_instant_reload_weapons },
{ "rg_set_account_rules", rg_set_account_rules },
{ "rg_get_account_rules", rg_get_account_rules },
{ "rg_is_bomb_planted", rg_is_bomb_planted },
{ "rg_join_team", rg_join_team },
{ "rg_balance_teams", rg_balance_teams },
{ "rg_swap_all_players", rg_swap_all_players },
{ "rg_switch_team", rg_switch_team },
{ "rg_switch_weapon", rg_switch_weapon },
{ nullptr, nullptr }
};
@ -1290,11 +1484,62 @@ cell AMX_NATIVE_CALL rh_reset_mapname(AMX *amx, cell *params)
return TRUE;
}
/*
* Emits a sound from an entity from the engine.
*
* @param entity Entity index or use 0 to emit from worldspawn at the specified position
* @param recipients Recipient index or use 0 to heard for all clients
* @param channel Channel to emit from
* @param sample Sound file to emit
* @param vol Volume in percent
* @param attn Sound attenuation
* @param flags Emit flags
* @param pitch Sound pitch
* @param emitFlags Additional Emit2 flags, look at the defines like SND_EMIT2_*
* @return 1 if successfully sounds are emitted, 0 otherwise
*
* native rh_emit_sound2(const entity, const recipient, const channel, const sample[], Float:vol = VOL_NORM, Float:attn = ATTN_NORM, const flags = 0, const pitch = PITCH_NORM, emitFlags = 0, const Float:origin[3] = {0.0,0.0,0.0});
*/
cell AMX_NATIVE_CALL rh_emit_sound2(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_entity, arg_recipient, arg_channel, arg_sample, arg_vol, arg_attn, arg_flags, arg_pitch, arg_emitFlags, arg_origin };
CBasePlayer *pRecipient = getPrivate<CBasePlayer>(params[arg_recipient]);
if (pRecipient != nullptr && pRecipient->has_disconnected) {
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_recipient]);
return FALSE;
}
// ignore bots
if ((pRecipient != nullptr && pRecipient->IsBot()) || !pRecipient->IsNetClient()) {
return FALSE;
}
CAmxArgs args(amx, params);
const char *sample = getAmxString(amx, params[arg_sample]);
return g_RehldsFuncs->SV_EmitSound2
(
args[arg_entity], // entity
args[arg_recipient], // recipient
args[arg_channel], // channel
sample, // sample
args[arg_vol], // volume
args[arg_attn], // attn
args[arg_flags], // flags
args[arg_pitch], // pitch
args[arg_emitFlags], // emitFlags
args[arg_origin] // pOrigin
);
}
AMX_NATIVE_INFO Misc_Natives_RH[] =
{
{ "rh_set_mapname", rh_set_mapname },
{ "rh_get_mapname", rh_get_mapname },
{ "rh_reset_mapname", rh_reset_mapname },
{ "rh_emit_sound2", rh_emit_sound2 },
{ nullptr, nullptr }
};
@ -1363,4 +1608,5 @@ void RegisterNatives_Misc()
if (api_cfg.hasReHLDS())
g_amxxapi.AddNatives(Misc_Natives_RH);
g_amxxapi.AddNatives(Misc_Natives_Checks);}
g_amxxapi.AddNatives(Misc_Natives_Checks);
}

View File

@ -12,19 +12,6 @@ void Broadcast(const char *sentence)
g_pengfuncsTable->pfnMessageEnd();
}
void UpdateTeamScores()
{
g_pengfuncsTable->pfnMessageBegin(MSG_ALL, gmsgTeamScore, NULL, NULL);
g_pengfuncsTable->pfnWriteString("CT");
g_pengfuncsTable->pfnWriteShort(CSGameRules()->m_iNumCTWins);
g_pengfuncsTable->pfnMessageEnd();
g_pengfuncsTable->pfnMessageBegin(MSG_ALL, gmsgTeamScore, NULL, NULL);
g_pengfuncsTable->pfnWriteString("TERRORIST");
g_pengfuncsTable->pfnWriteShort(CSGameRules()->m_iNumTerroristWins);
g_pengfuncsTable->pfnMessageEnd();
}
struct {
TeamName team;
ModelName model;

View File

@ -120,5 +120,6 @@ inline const char *GetTeamName(TeamName team)
void Broadcast(const char *sentence);
void UpdateTeamScores();
ModelName GetModelAuto(TeamName team);
void UTIL_ServerPrint(const char *fmt, ...);
extern void __declspec(noreturn) UTIL_SysError(const char *fmt, ...);

View File

@ -4,5 +4,5 @@
#define _reapi_version_included
// reapi version
#define REAPI_VERSION_MAJOR 2
#define REAPI_VERSION_MAJOR 3
#define REAPI_VERSION_MINOR 0

View File

@ -40,3 +40,15 @@ void UTIL_LogPrintf(const char *fmt, ...)
ALERT(at_logged, "%s", string);
}
void UTIL_ServerPrint(const char *fmt, ...)
{
va_list argptr;
char string[1024];
va_start(argptr, fmt);
vsprintf(string, fmt, argptr);
va_end(argptr);
SERVER_PRINT(string);
}