Skip to content

Commit

Permalink
Merge branch 'nostalgia' of https://github.com/Nostalgia-Gamers/ReGam…
Browse files Browse the repository at this point in the history
…eDLL_CS into nostalgia
  • Loading branch information
aleeperezz16 committed Mar 16, 2024
2 parents a4cd9a5 + 4cc9a09 commit 93ad535
Show file tree
Hide file tree
Showing 37 changed files with 201 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: C/C++ CI

on:
push:
branches: [master]
branches: [master, nostalgia]
paths-ignore:
- '**.md'

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| 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 |
| mp_max_alive_name_changes | -1 | -1 | - | Maximum amount of nickname changes when alive<br/>`-1` unlimited<br/>`0` Blocks name changes </br>`>0` Allow to change arbitrary amount of nicks |
| sv_legacy_restart_entities | 0 | 0 | 1 | Legacy restart of entities on new round<br/>`0` disabled<br/>`1` enabled |
| sv_block_vote_commands | 0 | 0 | 1 | When set, blocks `vote` and `votemap` commands.<br/>`0` disabled <br/>`1` enabled |
| mp_dying_time | 3.0 | 0.0 | - | Time for switch to free observing after death.<br/>`0` - disable spectating around death.<br/>`>0.00001` - time delay to start spectate.<br/>`NOTE`: The countdown starts when the player’s death animation is finished. |
| mp_deathmsg_flags | abc | 0 | - | Sets a flags for extra information in the player's death message.<br/>`0` disabled<br/>`a` position where the victim died<br/>`b` index of the assistant who helped the attacker kill the victim<br/>`c` rarity classification bits, e.g., `blinkill`, `noscope`, `penetrated`, etc. |
| mp_assist_damage_threshold | 40 | 0 | 100 | Sets the percentage of damage needed to score an assist. |
Expand Down
21 changes: 21 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,27 @@ mp_hostages_rescued_ratio "1.0"
//
// Default value: "1"
mp_legacy_vehicle_block "1"
// Maximum amount of nickname changes before next respawn.
// -1 - unlimited (default behaviour)
// 0 - Blocks name changes
// >0 - Allow to change arbitrary amount of nicks
//
// Default value: "-1"
mp_max_alive_name_changes -1
// Legacy restart of entities on new round.
// 0 - disabled (default behaviour)
// 1 - enabled
//
// Default value: "0"
sv_legacy_restart_entities 0
// When set, blocks "vote" and "votemap" commands.
// 0 - disabled (default behaviour)
// 1 - enabled
//
// Default value: "0"
sv_block_vote_commands 0
// Time for switch to free observing after death.
// NOTE: The countdown starts when the player’s death animation is finished.
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ ReGameFuncs_t g_ReGameApiFuncs = {
UTIL_Remove_api,

AddAmmoNameToAmmoRegistry_api,
RemoveAmmoNameFromAmmoRegistry,
TextureTypePlaySound_api,
CreateWeaponBox_api,
SpawnGrenade_api,
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ void CCSPlayer::ResetVars()
m_bGameForcingRespawn = false;
m_bAutoBunnyHopping = false;
m_bMegaBunnyJumping = false;
m_iAliveNameChanges = 0;
m_bSpawnProtectionEffects = false;
}

Expand All @@ -564,6 +565,7 @@ void CCSPlayer::OnSpawn()
{
m_bGameForcingRespawn = false;
m_flRespawnPending = 0.0f;
m_iAliveNameChanges = 0;
m_DamageList.Clear();
}

Expand Down
12 changes: 10 additions & 2 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
pPlayer->ForceClientDllUpdate();
}
}
else if (FStrEq(pcmd, "vote"))
else if (FStrEq(pcmd, "vote")
#ifdef REGAMEDLL_ADD
&& sv_block_vote_commands.value <= 0
#endif
)
{
if (gpGlobals->time >= pPlayer->m_flLastCommandTime[CMD_VOTE])
{
Expand Down Expand Up @@ -2671,7 +2675,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
CSGameRules()->DisplayMaps(pPlayer, 0);
}
}
else if (FStrEq(pcmd, "votemap"))
else if (FStrEq(pcmd, "votemap")
#ifdef REGAMEDLL_ADD
&& sv_block_vote_commands.value <= 0
#endif
)
{
if (gpGlobals->time >= pPlayer->m_flLastCommandTime[CMD_VOTEMAP])
{
Expand Down
7 changes: 7 additions & 0 deletions regamedll/dlls/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ enum BuyItemMenuSlot
MENU_SLOT_ITEM_SHIELD,
};

// custom enum
enum
{
BLOCK_VOTE = BIT(0),
BLOCK_VOTEMAP = BIT(1),
};

#define CS_NUM_SKIN 4
#define CZ_NUM_SKIN 5

Expand Down
11 changes: 8 additions & 3 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ cvar_t deathmsg_flags = { "mp_deathmsg_flags", "abc", 0, 0.0f
cvar_t assist_damage_threshold = { "mp_assist_damage_threshold", "40", 0, 40.0f, nullptr };
cvar_t freezetime_duck = { "mp_freezetime_duck", "1", 0, 1.0f, nullptr };
cvar_t freezetime_jump = { "mp_freezetime_jump", "1", 0, 1.0f, nullptr };
cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };

cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };
cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr };
cvar_t legacy_restart_entities = { "sv_legacy_restart_entities", "0", 0, 0.0f, nullptr };
cvar_t sv_block_vote_commands = { "sv_block_vote_commands", "0", 0, 0.0f, nullptr };

cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr };

Expand Down Expand Up @@ -429,9 +432,7 @@ 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(&dying_time);
Expand All @@ -442,6 +443,10 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&freezetime_jump);
CVAR_REGISTER(&defuser_allocation);

CVAR_REGISTER(&max_alive_name_changes);
CVAR_REGISTER(&legacy_restart_entities);
CVAR_REGISTER(&sv_block_vote_commands);

// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");

Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ extern cvar_t freezetime_duck;
extern cvar_t freezetime_jump;
extern cvar_t defuser_allocation;

extern cvar_t max_alive_name_changes;
extern cvar_t legacy_restart_entities;
extern cvar_t sv_block_vote_commands;

#endif

extern cvar_t scoreboard_showmoney;
Expand Down
51 changes: 33 additions & 18 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,16 @@ LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, CleanUpMap)
void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)()
{
#ifdef REGAMEDLL_FIXES
UTIL_RestartOther("multi_manager");
#ifdef REGAMEDLL_ADD
if (!(bool)legacy_restart_entities.value)
#endif
{
UTIL_RestartOther("multi_manager");

// Release or reset everything entities in depending of flags ObjectCaps
// (FCAP_MUST_RESET / FCAP_MUST_RELEASE)
UTIL_ResetEntities();
// Release or reset everything entities in depending of flags ObjectCaps
// (FCAP_MUST_RESET / FCAP_MUST_RELEASE)
UTIL_ResetEntities();
}
#endif

// Recreate all the map entities from the map data (preserving their indices),
Expand All @@ -622,11 +627,16 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)()
UTIL_RestartOther("func_door");

#ifdef REGAMEDLL_FIXES
UTIL_RestartOther("func_button");
UTIL_RestartOther("func_rot_button");
UTIL_RestartOther("env_render");
UTIL_RestartOther("env_spark");
UTIL_RestartOther("trigger_push");
#ifdef REGAMEDLL_ADD
if (!(bool)legacy_restart_entities.value)
#endif
{
UTIL_RestartOther("func_button");
UTIL_RestartOther("func_rot_button");
UTIL_RestartOther("env_render");
UTIL_RestartOther("env_spark");
UTIL_RestartOther("trigger_push");
}
#endif

UTIL_RestartOther("func_water");
Expand All @@ -639,15 +649,20 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)()
UTIL_RestartOther("env_sprite");

#ifdef REGAMEDLL_FIXES
UTIL_RestartOther("trigger_once");
UTIL_RestartOther("func_wall_toggle");
UTIL_RestartOther("func_healthcharger");
UTIL_RestartOther("func_recharge");
UTIL_RestartOther("trigger_hurt");
UTIL_RestartOther("multisource");
UTIL_RestartOther("env_beam");
UTIL_RestartOther("env_laser");
UTIL_RestartOther("trigger_auto");
#ifdef REGAMEDLL_ADD
if (!(bool)legacy_restart_entities.value)
#endif
{
UTIL_RestartOther("trigger_once");
UTIL_RestartOther("func_wall_toggle");
UTIL_RestartOther("func_healthcharger");
UTIL_RestartOther("func_recharge");
UTIL_RestartOther("trigger_hurt");
UTIL_RestartOther("multisource");
UTIL_RestartOther("env_beam");
UTIL_RestartOther("env_laser");
UTIL_RestartOther("trigger_auto");
}
#endif

// Remove grenades and C4
Expand Down
18 changes: 17 additions & 1 deletion regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,19 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c
}
#endif

if (pev->deadflag != DEAD_NO)
#ifdef REGAMEDLL_ADD
if (max_alive_name_changes.value <= 0)
{
ClientPrint(pev, HUD_PRINTCENTER, "#Command_Not_Available");
return false;
}
#endif

if (pev->deadflag != DEAD_NO
#if defined REGAMEDLL_API && REGAMEDLL_ADD
|| CSPlayer()->m_iAliveNameChanges >= max_alive_name_changes.value
#endif
)
{
m_bHasChangedName = true;
Q_snprintf(m_szNewName, sizeof(m_szNewName), "%s", szNewName);
Expand All @@ -189,6 +201,10 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c
WRITE_STRING(szNewName);
MESSAGE_END();

#ifdef REGAMEDLL_API
CSPlayer()->m_iAliveNameChanges++;
#endif

UTIL_LogPrintf("\"%s<%i><%s><%s>\" changed name to \"%s\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict()), GetTeam(m_iTeam), szNewName);
return true;
}
Expand Down
54 changes: 51 additions & 3 deletions regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,28 @@ struct {
{ AMMO_C4, "C4" },
};
#endif
#ifdef REGAMEDLL_API
BOOL EXT_FUNC RemoveAmmoNameFromAmmoRegistry(const char *szAmmoname)
{
if (!szAmmoname || !szAmmoname[0])
{
return FALSE;
}

for (int i = 1; i < MAX_AMMO_SLOTS; i++)
{
AmmoInfo& ammoinfo = CBasePlayerItem::m_AmmoInfoArray[i];

if (ammoinfo.iId && !Q_stricmp(ammoinfo.pszName, szAmmoname))
{
Q_memset(&CBasePlayerItem::m_AmmoInfoArray[i], 0, sizeof(CBasePlayerItem::m_AmmoInfoArray[i]));
return TRUE;
}
}

return FALSE;
}
#endif

// Precaches the ammo and queues the ammo info for sending to clients
int AddAmmoNameToAmmoRegistry(const char *szAmmoname)
Expand All @@ -222,6 +244,32 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname)
return -1;
}

#ifdef REGAMEDLL_ADD
int newIndex = -1;
for (int i = 1; i < MAX_AMMO_SLOTS; i++)
{
AmmoInfo& ammoinfo = CBasePlayerItem::m_AmmoInfoArray[i];

if (ammoinfo.iId && !Q_stricmp(ammoinfo.pszName, szAmmoname))
{
return i;
}

// New slot for the ammo it's the first one clear.
if (!ammoinfo.iId && newIndex == -1)
{
newIndex = i;
}
}

if (newIndex != -1)
{
CBasePlayerItem::m_AmmoInfoArray[newIndex].pszName = szAmmoname;
CBasePlayerItem::m_AmmoInfoArray[newIndex].iId = newIndex;
}

return newIndex;
#else
// make sure it's not already in the registry
for (int i = 1; i < MAX_AMMO_SLOTS; i++)
{
Expand Down Expand Up @@ -260,6 +308,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname)
CBasePlayerItem::m_AmmoInfoArray[giAmmoIndex].iId = giAmmoIndex;

return giAmmoIndex;
#endif
}

// Precaches the weapon and queues the weapon info for sending to clients
Expand Down Expand Up @@ -1228,10 +1277,9 @@ void CBasePlayerItem::AttachToPlayer(CBasePlayer *pPlayer)
void CBasePlayerWeapon::Spawn()
{
#ifdef REGAMEDLL_API
ItemInfo info;
Q_memset(&info, 0, sizeof(info));
ItemInfo &info = m_ItemInfoArray[m_iId];

if (GetItemInfo(&info)) {
if (info.iId) {
CSPlayerItem()->SetItemInfo(&info);
}
#endif
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -2181,4 +2181,5 @@ float GetBaseAccuracy(WeaponIdType id);
void ClearMultiDamage_OrigFunc();
void ApplyMultiDamage_OrigFunc(entvars_t *pevInflictor, entvars_t *pevAttacker);
void AddMultiDamage_OrigFunc(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
BOOL RemoveAmmoNameFromAmmoRegistry(const char* szAmmoname);
#endif
2 changes: 1 addition & 1 deletion regamedll/dlls/wpn_shared/wpn_ak47.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim)

void CAK47::Reload()
{
#ifdef REGAMEDLL_FIXES
#ifndef REGAMEDLL_FIXES
// to prevent reload if not enough ammo
if (m_pPlayer->ammo_762nato <= 0)
return;
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/wpn_shared/wpn_aug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)

void CAUG::Reload()
{
#ifndef REGAMEDLL_FIXES
if (m_pPlayer->ammo_556nato <= 0)
return;
#endif

if (DefaultReload(iMaxClip(), AUG_RELOAD, AUG_RELOAD_TIME))
{
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/wpn_shared/wpn_awp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)

void CAWP::Reload()
{
#ifndef REGAMEDLL_FIXES
if (m_pPlayer->ammo_338mag <= 0)
return;
#endif

if (DefaultReload(iMaxClip(), AWP_RELOAD, AWP_RELOAD_TIME))
{
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/wpn_shared/wpn_deagle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ void CDEAGLE::DEAGLEFire(float flSpread, float flCycleTime, BOOL fUseSemi)

void CDEAGLE::Reload()
{
#ifndef REGAMEDLL_FIXES
if (m_pPlayer->ammo_50ae <= 0)
return;
#endif

if (DefaultReload(iMaxClip(), DEAGLE_RELOAD, DEAGLE_RELOAD_TIME))
{
Expand Down
Loading

0 comments on commit 93ad535

Please sign in to comment.