Skip to content

Commit

Permalink
Merge pull request rehlds#7 from s1lentq/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
SergeyShorokhov authored Dec 2, 2019
2 parents eaaa3fd + fd06d65 commit 44e7758
Show file tree
Hide file tree
Showing 27 changed files with 425 additions and 198 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
<pre>ReGameDLL_CS also have beta version with latest changes from official version of Counter-Strike.</pre>
* Enter `-beta` option at the command line HLDS.

## Commands
| Command | Description |
| :---------------------------------- | :---------------------------------------------- |
| game version | Will show GameDLL build version, date & URL. |
| endround | Args:<br/>`T` force round end with Terrorists win. <br/>`CT` force round end with Counter-Terrorists win. <br/> or terminate round draw when called without arguments. |
| mp_swapteams | Swap the teams and restart the game. |

## Configuration (cvars)
<details>
<summary>Click to expand</summary>
Expand Down Expand Up @@ -76,6 +83,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
| mp_radio_timeout | 1.5 | 0.0 | - | Delay between player Radio messages. (in seconds).<br/>`0` disable delay |
| mp_radio_maxinround | 60 | - | - | Maximum Radio messages count for player per round.<br/>`0` disable radio messages |
| mp_buy_anywhere | 0 | 0 | 3 | When set, players can buy anywhere, not only in buyzones.<br/> `0` disabled.<br/>`1` both teams <br/>`2` only Terrorists team <br/>`3` only CT team |
| mp_weapons_allow_map_placed | 1 | 0 | 1 | When set, map weapons (located on the floor by map) will be shown.<br/> `0` hide all map weapons.<br/>`1` enabled<br/>`NOTE`: Effect will work after round restart. |
</details>

## How to install zBot for CS 1.6?
Expand Down
8 changes: 8 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,11 @@ mp_buy_anywhere 0
//
// Default value: "0"
mp_unduck_method 0
// When set, map weapons (located on the floor) will be shown.
// NOTE: Effect will work after round restart.
// 0 - hide all map weapons
// 1 - enabled (default behaviour)
//
// Default value: "1"
mp_weapons_allow_map_placed 1
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
majorVersion=5
minorVersion=11
minorVersion=12
maintenanceVersion=0
5 changes: 5 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ GAMEHOOK_REGISTRY(CBasePlayer_RemoveSpawnProtection);
GAMEHOOK_REGISTRY(IsPenetrableEntity);
GAMEHOOK_REGISTRY(CBasePlayer_HintMessageEx);
GAMEHOOK_REGISTRY(CBasePlayer_UseEmpty);
GAMEHOOK_REGISTRY(CBasePlayerWeapon_CanDeploy);
GAMEHOOK_REGISTRY(CBasePlayerWeapon_DefaultDeploy);
GAMEHOOK_REGISTRY(CBasePlayerWeapon_DefaultReload);
GAMEHOOK_REGISTRY(CBasePlayerWeapon_DefaultShotgunReload);
GAMEHOOK_REGISTRY(CBasePlayer_DropIdlePlayer);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
Expand Down
36 changes: 36 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
return g_ReGameHookchains.m_##className##_##functionName.callChain(&className::functionName##_OrigFunc, this);\
}

#define LINK_HOOK_CLASS_CHAIN3(ret, className, subClassName, functionName)\
ret subClassName::functionName() {\
return g_ReGameHookchains.m_##className##_##functionName.callChain(reinterpret_cast<ret (className::*)()>(&subClassName::functionName##_OrigFunc), this);\
}

#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(className, customPrefix, functionName, args, ...)\
void className::functionName args {\
g_ReGameHookchains.m_##customPrefix##_##functionName.callChain(&className::functionName##_OrigFunc, this, __VA_ARGS__);\
Expand Down Expand Up @@ -123,6 +128,7 @@
#define LINK_HOOK_CLASS_VOID_CHAIN2(...)
#define LINK_HOOK_CLASS_CHAIN(...)
#define LINK_HOOK_CLASS_CHAIN2(...)
#define LINK_HOOK_CLASS_CHAIN3(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(...)
#define LINK_HOOK_CLASS_CUSTOM_CHAIN(...)
Expand Down Expand Up @@ -541,6 +547,26 @@ typedef IHookChainRegistryClassImpl<bool, CBasePlayer, const char *, float, bool
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_UseEmpty;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_UseEmpty;

// CBasePlayerWeapon::CanDeploy hook
typedef IHookChainClassImpl<BOOL, CBasePlayerWeapon> CReGameHook_CBasePlayerWeapon_CanDeploy;
typedef IHookChainRegistryClassImpl<BOOL, CBasePlayerWeapon> CReGameHookRegistry_CBasePlayerWeapon_CanDeploy;

// CBasePlayerWeapon::DefaultDeploy hook
typedef IHookChainClassImpl<BOOL, CBasePlayerWeapon, char *, char *, int, char *, int> CReGameHook_CBasePlayerWeapon_DefaultDeploy;
typedef IHookChainRegistryClassImpl<BOOL, CBasePlayerWeapon, char *, char *, int, char *, int> CReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy;

// CBasePlayerWeapon::DefaultReload hook
typedef IHookChainClassImpl<int, CBasePlayerWeapon, int, int, float> CReGameHook_CBasePlayerWeapon_DefaultReload;
typedef IHookChainRegistryClassImpl<int, CBasePlayerWeapon, int, int, float> CReGameHookRegistry_CBasePlayerWeapon_DefaultReload;

// CBasePlayerWeapon::DefaultShotgunReload hook
typedef IHookChainClassImpl<bool, CBasePlayerWeapon, int, int, float, float, const char *, const char *> CReGameHook_CBasePlayerWeapon_DefaultShotgunReload;
typedef IHookChainRegistryClassImpl<bool, CBasePlayerWeapon, int, int, float, float, const char *, const char *> CReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload;

// CBasePlayer::DropIdlePlayer hook
typedef IHookChainClassImpl<void, CBasePlayer, const char *> CReGameHook_CBasePlayer_DropIdlePlayer;
typedef IHookChainRegistryClassImpl<void, CBasePlayer, const char *> CReGameHookRegistry_CBasePlayer_DropIdlePlayer;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -650,6 +676,11 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_IsPenetrableEntity m_IsPenetrableEntity;
CReGameHookRegistry_CBasePlayer_HintMessageEx m_CBasePlayer_HintMessageEx;
CReGameHookRegistry_CBasePlayer_UseEmpty m_CBasePlayer_UseEmpty;
CReGameHookRegistry_CBasePlayerWeapon_CanDeploy m_CBasePlayerWeapon_CanDeploy;
CReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy m_CBasePlayerWeapon_DefaultDeploy;
CReGameHookRegistry_CBasePlayerWeapon_DefaultReload m_CBasePlayerWeapon_DefaultReload;
CReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload m_CBasePlayerWeapon_DefaultShotgunReload;
CReGameHookRegistry_CBasePlayer_DropIdlePlayer m_CBasePlayer_DropIdlePlayer;

public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
Expand Down Expand Up @@ -758,6 +789,11 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity();
virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx();
virtual IReGameHookRegistry_CBasePlayer_UseEmpty *CBasePlayer_UseEmpty();
virtual IReGameHookRegistry_CBasePlayerWeapon_CanDeploy *CBasePlayerWeapon_CanDeploy();
virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy *CBasePlayerWeapon_DefaultDeploy();
virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultReload *CBasePlayerWeapon_DefaultReload();
virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload *CBasePlayerWeapon_DefaultShotgunReload();
virtual IReGameHookRegistry_CBasePlayer_DropIdlePlayer *CBasePlayer_DropIdlePlayer();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
5 changes: 5 additions & 0 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov

if (pPlayer->RemovePlayerItem(pItem)) {
pPlayer->pev->weapons &= ~(1 << pItem->m_iId);
// No more weapon
if ((pPlayer->pev->weapons & ~(1 << WEAPON_SUIT)) == 0) {
pPlayer->m_iHideHUD |= HIDEHUD_WEAPONS;
}

pItem->Kill();

if (!pPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]) {
Expand Down
7 changes: 0 additions & 7 deletions regamedll/dlls/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ void CBasePlayerAmmo::DefaultTouch(CBaseEntity *pOther)
#endif
}
}
else if (gEvilImpulse101)
{
// evil impulse 101 hack, kill always
SetTouch(nullptr);
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 0.1f;
}
}

void C9MMAmmo::Spawn()
Expand Down
14 changes: 9 additions & 5 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "precompiled.h"

int giPrecacheGrunt = 0;
int gmsgWeapPickup = 0;
int gmsgHudText = 0;
int gmsgHudTextPro = 0;
Expand Down Expand Up @@ -1843,7 +1842,11 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *pPlayer, int slot)
}

pPlayer->RemoveAllItems(TRUE);

#ifndef REGAMEDLL_FIXES
// NOTE: It is already does reset inside RemoveAllItems
pPlayer->m_bHasC4 = false;
#endif

#ifdef REGAMEDLL_FIXES
if (pPlayer->m_iTeam != SPECTATOR)
Expand Down Expand Up @@ -3151,7 +3154,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
}
else if (FStrEq(pcmd, "become_vip"))
{
if (pPlayer->m_iJoiningState != JOINED || pPlayer->m_iTeam != CT)
if (pPlayer->m_iJoiningState != JOINED || pPlayer->m_iTeam != CT
#ifdef REGAMEDLL_FIXES
|| !CSGameRules()->m_bMapHasVIPSafetyZone
#endif
)
{
ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Command_Not_Available");
return;
Expand Down Expand Up @@ -4168,9 +4175,6 @@ void ClientPrecache()
PRECACHE_SOUND("player/geiger2.wav");
PRECACHE_SOUND("player/geiger1.wav");

if (giPrecacheGrunt)
UTIL_PrecacheOther("enemy_terrorist");

g_iShadowSprite = PRECACHE_MODEL("sprites/shadow_circle.spr");

PRECACHE_MODEL("sprites/wall_puff1.spr");
Expand Down
1 change: 0 additions & 1 deletion regamedll/dlls/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ inline const char *GetTeamName(int team)
}
}

extern int giPrecacheGrunt;
extern int gmsgWeapPickup;
extern int gmsgHudText;
extern int gmsgHudTextPro;
Expand Down
14 changes: 12 additions & 2 deletions regamedll/dlls/doors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,12 @@ void CBaseDoor::DoorGoUp()

if (TheBots)
{
TheBots->OnEvent(EVENT_DOOR, m_hActivator);
#ifdef REGAMEDLL_FIXES
if (m_hActivator && m_hActivator->IsPlayer())
#endif
{
TheBots->OnEvent(EVENT_DOOR, m_hActivator);
}
}
}
}
Expand Down Expand Up @@ -680,7 +685,12 @@ void CBaseDoor::DoorGoDown()

if (TheBots)
{
TheBots->OnEvent(EVENT_DOOR, m_hActivator);
#ifdef REGAMEDLL_FIXES
if (m_hActivator && m_hActivator->IsPlayer())
#endif
{
TheBots->OnEvent(EVENT_DOOR, m_hActivator);
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ cvar_t respawn_immunity_effects = { "mp_respawn_immunity_effects", "1", FCVAR_S
cvar_t kill_filled_spawn = { "mp_kill_filled_spawn", "1", 0, 0.0f, nullptr };
cvar_t afk_bomb_drop_time = { "mp_afk_bomb_drop_time", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t buy_anywhere = { "mp_buy_anywhere", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t weapons_allow_map_placed = { "mp_weapons_allow_map_placed", "1", FCVAR_SERVER, 0.0f, nullptr };

cvar_t allow_point_servercommand = { "mp_allow_point_servercommand", "0", 0, 0.0f, nullptr };
cvar_t hullbounds_sets = { "mp_hullbounds_sets", "1", 0, 0.0f, nullptr };
Expand Down Expand Up @@ -172,6 +173,12 @@ void GameDLL_EndRound_f()
CSGameRules()->OnRoundEnd_Intercept(WINSTATUS_DRAW, ROUND_END_DRAW, CSGameRules()->GetRoundRestartDelay());
}

void GameDLL_SwapTeams_f()
{
CSGameRules()->SwapAllPlayers();
CVAR_SET_FLOAT("sv_restartround", 1.0);
}

#endif // REGAMEDLL_ADD

void EXT_FUNC GameDLLInit()
Expand Down Expand Up @@ -298,6 +305,7 @@ void EXT_FUNC GameDLLInit()

ADD_SERVER_COMMAND("game", GameDLL_Version_f);
ADD_SERVER_COMMAND("endround", GameDLL_EndRound_f);
ADD_SERVER_COMMAND("mp_swapteams", GameDLL_SwapTeams_f);

CVAR_REGISTER(&game_version);
CVAR_REGISTER(&maxmoney);
Expand Down Expand Up @@ -335,6 +343,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&allow_point_servercommand);
CVAR_REGISTER(&hullbounds_sets);
CVAR_REGISTER(&unduck_method);
CVAR_REGISTER(&weapons_allow_map_placed);

CVAR_REGISTER(&ff_damage_reduction_bullets);
CVAR_REGISTER(&ff_damage_reduction_grenade);
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ extern cvar_t respawn_immunity_effects;
extern cvar_t kill_filled_spawn;
extern cvar_t afk_bomb_drop_time;
extern cvar_t buy_anywhere;
extern cvar_t weapons_allow_map_placed;
extern cvar_t allow_point_servercommand;
extern cvar_t hullbounds_sets;
extern cvar_t unduck_method;
Expand Down
4 changes: 0 additions & 4 deletions regamedll/dlls/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ void CItem::ItemTouch(CBaseEntity *pOther)
else
UTIL_Remove(this);
}
else if (gEvilImpulse101)
{
UTIL_Remove(this);
}
}

CBaseEntity *CItem::Respawn()
Expand Down
14 changes: 14 additions & 0 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,23 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)()
const int grenadesRemoveCount = 20;
UTIL_RemoveOther("grenade", grenadesRemoveCount);

#ifndef REGAMEDLL_FIXES
// Remove defuse kit
// Old code only removed 4 kits and stopped.
UTIL_RemoveOther("item_thighpack");
#else
// Don't remove level items
CItemThighPack *pDefuser = nullptr;

while ((pDefuser = UTIL_FindEntityByClassname(pDefuser, "item_thighpack")))
{
if (pDefuser->pev->spawnflags & SF_NORESPAWN)
{
pDefuser->SetThink(&CBaseEntity::SUB_Remove);
pDefuser->pev->nextthink = gpGlobals->time + 0.1;
}
}
#endif

#ifdef REGAMEDLL_FIXES
UTIL_RemoveOther("gib");
Expand Down
Loading

0 comments on commit 44e7758

Please sign in to comment.