Skip to content

Commit

Permalink
[Personal v1] Merge last changes till commit rehlds#577. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenKal authored Mar 18, 2023
1 parent 6f73d3b commit 017a237
Show file tree
Hide file tree
Showing 26 changed files with 219 additions and 70 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -38,7 +38,7 @@ jobs:
- run: nuget restore '${{ env.solution }}'

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v1.1.3
with:
vs-version: '16.8'

Expand Down Expand Up @@ -66,19 +66,19 @@ jobs:
move msvc\${{ env.buildRelease }}\mp.pdb publish\debug\mp.pdb
- name: Deploy artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: win32
path: publish/*

linux:
name: 'Linux'
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
container: s1lentq/linux86buildtools:latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
shell: bash

- name: Deploy artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
id: upload-job
with:
name: linux32
Expand All @@ -154,17 +154,17 @@ jobs:
publish:
name: 'Publish'
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [windows, linux]

steps:
- name: Deploying linux artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: linux32

- name: Deploying windows artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: win32

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| sv_enablebunnyhopping | 0 | 0 | 1 | Allow player speed to exceed maximum running speed.<br/>`0` disabled <br/>`1` enabled |
| mp_plant_c4_anywhere | 0 | 0 | 1 | When set, players can plant anywhere, not only in bombsites.<br/>`0` disabled <br/>`1` enabled |
| mp_give_c4_frags | 3 | - | - | How many bonuses (frags) will get the player who defused or exploded the bomb. |
| mp_hostages_rescued_ratio | 1.0 | 0.0 | 1.0 | Ratio of hostages rescued to win the round. |
| mp_legacy_vehicle_block | 1 | 0 | 1 | Legacy func_vehicle behavior when blocked by another entity.<br/>`0` New behavior <br/>`1` Legacy behavior |
</details>

## How to install zBot for CS 1.6?
Expand Down
14 changes: 14 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,17 @@ mp_plant_c4_anywhere 0
//
// Default value: "3"
mp_give_c4_frags 3
// Ratio of hostages rescued to win the round.
//
// Default value: "1.0"
mp_hostages_rescued_ratio "1.0"
// Legacy func_vehicle behavior when blocked by another entity.
// New one is more useful for playing multiplayer.
//
// 0 - New behavior
// 1 - Legacy behavior
//
// Default value: "1"
mp_legacy_vehicle_block "1"
8 changes: 7 additions & 1 deletion regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ ReGameFuncs_t g_ReGameApiFuncs = {
PlantBomb_api,

SpawnHeadGib_api,
SpawnRandomGibs_api
SpawnRandomGibs_api,

UTIL_RestartOther,
UTIL_ResetEntities,
UTIL_RemoveOther,
};

GAMEHOOK_REGISTRY(CBasePlayer_Spawn);
Expand Down Expand Up @@ -207,6 +211,8 @@ GAMEHOOK_REGISTRY(CBasePlayer_Pain);
GAMEHOOK_REGISTRY(CBasePlayer_DeathSound);
GAMEHOOK_REGISTRY(CBasePlayer_JoiningThink);

GAMEHOOK_REGISTRY(FreeGameRules);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
}
Expand Down
8 changes: 8 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBase
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_JoiningThink;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_JoiningThink;

// FreeGameRules hook
typedef IHookChainImpl<void, CGameRules **> CReGameHook_FreeGameRules;
typedef IHookChainRegistryImpl<void, CGameRules **> CReGameHookRegistry_FreeGameRules;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -774,6 +778,8 @@ class CReGameHookchains: public IReGameHookchains {
CReGameHookRegistry_CBasePlayer_DeathSound m_CBasePlayer_DeathSound;
CReGameHookRegistry_CBasePlayer_JoiningThink m_CBasePlayer_JoiningThink;

CReGameHookRegistry_FreeGameRules m_FreeGameRules;

public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache();
Expand Down Expand Up @@ -904,6 +910,8 @@ class CReGameHookchains: public IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain();
virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound();
virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink();

virtual IReGameHookRegistry_FreeGameRules *FreeGameRules();
};

C_DLLEXPORT CReGameHookchains g_ReGameHookchains;
Expand Down
24 changes: 21 additions & 3 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ EXT_FUNC bool CCSPlayer::JoinTeam(TeamName team)

if (pPlayer->pev->deadflag == DEAD_NO)
{
ClientKill(pPlayer->edict());
pPlayer->pev->frags++;
if (pPlayer->Kill())
{
pPlayer->pev->frags++;
}
}

MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo);
Expand Down Expand Up @@ -520,6 +522,21 @@ EXT_FUNC bool CCSPlayer::HintMessageEx(const char *pMessage, float duration, boo
return BasePlayer()->HintMessageEx(pMessage, duration, bDisplayIfPlayerDead, bOverride);
}

EXT_FUNC void CCSPlayer::Reset()
{
BasePlayer()->Reset();
}

EXT_FUNC void CCSPlayer::OnSpawnEquip(bool addDefault, bool equipGame)
{
BasePlayer()->OnSpawnEquip(addDefault, equipGame);
}

EXT_FUNC void CCSPlayer::SetScoreboardAttributes(CBasePlayer *destination)
{
BasePlayer()->SetScoreboardAttributes(destination);
}

EXT_FUNC bool CCSPlayer::CheckActivityInGame()
{
const CBasePlayer* pPlayer = BasePlayer();
Expand All @@ -532,7 +549,7 @@ EXT_FUNC bool CCSPlayer::CheckActivityInGame()
return (fabs(deltaYaw) >= 0.1f && fabs(deltaPitch) >= 0.1f);
}

void CCSPlayer::Reset()
void CCSPlayer::ResetVars()
{
m_szModel[0] = '\0';

Expand All @@ -548,6 +565,7 @@ void CCSPlayer::Reset()
m_bAutoBunnyHopping = false;
m_bMegaBunnyJumping = false;
m_bPlantC4Anywhere = false;
m_bSpawnProtectionEffects = false;
}

void CCSPlayer::OnSpawn()
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/basemonster.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

enum
{
ITBD_PARALLYZE = 0,
ITBD_PARALYZE = 0,
ITBD_NERVE_GAS,
ITBD_POISON,
ITBD_RADIATION,
Expand Down
6 changes: 1 addition & 5 deletions regamedll/dlls/bot/cs_bot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,7 @@ void CCSBotManager::ServerCommand(const char *pcmd)
{
if (killThemAll || FStrEq(name, msg))
{
#ifdef REGAMEDLL_FIXES
ClientKill(pPlayer->edict());
#else
pPlayer->TakeDamage(pPlayer->pev, pPlayer->pev, 9999.9f, DMG_CRUSH);
#endif
pPlayer->Kill();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,9 @@ T *GetClassPtr(T *a)
a->pev = pev;

#ifdef REGAMEDLL_API
a->OnCreate();
a->m_pEntity = new W();
a->m_pEntity->m_pContainingEntity = a;
a->OnCreate();
#endif

}
Expand Down
33 changes: 9 additions & 24 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,29 +375,13 @@ void EXT_FUNC ClientKill(edict_t *pEntity)
entvars_t *pev = &pEntity->v;
CBasePlayer *pPlayer = CBasePlayer::Instance(pev);

if (pPlayer->GetObserverMode() != OBS_NONE)
return;

if (pPlayer->m_iJoiningState != JOINED)
return;

// prevent suiciding too often
if (pPlayer->m_fNextSuicideTime > gpGlobals->time)
return;

pPlayer->m_LastHitGroup = HITGROUP_GENERIC;

// don't let them suicide for 1 second after suiciding
pPlayer->m_fNextSuicideTime = gpGlobals->time + 1.0f;

// have the player kill themself
pEntity->v.health = 0;
pPlayer->Killed(pev, GIB_NEVER);

if (CSGameRules()->m_pVIP == pPlayer)
{
CSGameRules()->m_iConsecutiveVIP = 10;
}
pPlayer->Kill();
}

LINK_HOOK_VOID_CHAIN(ShowMenu, (CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText), pPlayer, bitsValidSlots, nDisplayTime, fNeedMore, pszText)
Expand Down Expand Up @@ -743,7 +727,7 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
}

#ifdef REGAMEDLL_API
pPlayer->CSPlayer()->Reset();
pPlayer->CSPlayer()->ResetVars();
#endif

UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", (sName[0] != '\0') ? sName : "<unconnected>");
Expand Down Expand Up @@ -1860,10 +1844,11 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *pPlayer, int slot)
{
if (pPlayer->m_iTeam != UNASSIGNED && pPlayer->pev->deadflag == DEAD_NO)
{
ClientKill(pPlayer->edict());

// add 1 to frags to balance out the 1 subtracted for killing yourself
pPlayer->pev->frags++;
if (pPlayer->Kill())
{
// add 1 to frags to balance out the 1 subtracted for killing yourself
pPlayer->pev->frags++;
}
}

pPlayer->RemoveAllItems(TRUE);
Expand Down Expand Up @@ -2091,10 +2076,10 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *pPlayer, int slot)
pPlayer->m_iMenu = Menu_ChooseAppearance;

// Show the appropriate Choose Appearance menu
// This must come before ClientKill() for CheckWinConditions() to function properly
// This must come before pPlayer->Kill() for CheckWinConditions() to function properly
if (pPlayer->pev->deadflag == DEAD_NO)
{
ClientKill(pPlayer->edict());
pPlayer->Kill();
}
}

Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f
cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr };
cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr };
cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr };
cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };
cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr };

// Note: Just for my plugins & cie.
cvar_t game_version_personnal = { "game_version_personnal", "1.3.0-public-AMXModDev", FCVAR_SERVER, 0.0f, nullptr };
Expand Down Expand Up @@ -410,6 +412,8 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&sv_enablebunnyhopping);
CVAR_REGISTER(&plant_c4_anywhere);
CVAR_REGISTER(&give_c4_frags);
CVAR_REGISTER(&hostages_rescued_ratio);
CVAR_REGISTER(&legacy_vehicle_block);

CVAR_REGISTER(&game_version_personnal);

Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ extern cvar_t sv_autobunnyhopping;
extern cvar_t sv_enablebunnyhopping;
extern cvar_t plant_c4_anywhere;
extern cvar_t give_c4_frags;
extern cvar_t hostages_rescued_ratio;
extern cvar_t legacy_vehicle_block;

extern cvar_t game_version_personnal;

Expand Down
10 changes: 10 additions & 0 deletions regamedll/dlls/gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,13 @@ CGameRules *EXT_FUNC __API_HOOK(InstallGameRules)()

return new CHalfLifeMultiplay;
}

LINK_HOOK_VOID_CHAIN(FreeGameRules, (CGameRules **pGameRules), pGameRules)

void EXT_FUNC __API_HOOK(FreeGameRules)(CGameRules **pGameRules)
{
if (!pGameRules || !(*pGameRules))
return;

delete (*pGameRules);
}
2 changes: 2 additions & 0 deletions regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,11 @@ extern CGameRules DLLEXPORT *g_pGameRules;

#ifdef REGAMEDLL_API
CGameRules *InstallGameRules_OrigFunc();
void FreeGameRules_OrigFunc(CGameRules **pGameRules);
#endif

CGameRules *InstallGameRules();
void FreeGameRules(CGameRules **pGameRules);

// Gets us at the CS game rules
inline CHalfLifeMultiplay *CSGameRules()
Expand Down
Loading

0 comments on commit 017a237

Please sign in to comment.