Skip to content

Commit

Permalink
Restore extra player slots (255) functionality and fix reported issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rafradek committed May 29, 2024
1 parent 52e58d3 commit 7124697
Show file tree
Hide file tree
Showing 27 changed files with 636 additions and 167 deletions.
14 changes: 8 additions & 6 deletions cfg/sigsegv_convars.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ sig_demo_stringtable_limit "0" // Mod: override 512KB string table limit in dem
sig_etc_allow_civilian_class "0" // Mod: allow civilian class to be picked
sig_etc_crayairblast_convar_nocheat "1" // Mod: remove the FCVAR_CHEAT flag from the Cray Airblast enable and tuning convars
sig_etc_deflect_rocket_spew "0" // Mod: intentionally cause multiple rocket breakmodels to spew forth when projectile deflection occurs
sig_etc_fix_misc_crash "1" // Mod: Fixes crashes:
// When firing too many arrows
// When trying to detonate non grenades on pipebomb launcher
// After removing sky_camera
sig_etc_heat_seeking_rockets "1" // Etc: enable heat-seeking rockets
sig_etc_hltv_client_interact "1" // Mod: allow HLTV clients to interact with server players
sig_etc_hltv_notify_clients "1" // Mod: Notify players about connecting Source TV spectators
Expand All @@ -95,12 +99,9 @@ sig_etc_misc "1" // Mod:
// Automatically destroy oldest disposable sentry when building new one
// Fixes:
// Snap unreachable dropped mvm bomb to last nav area
// Fix unowned sentry's rockets not dealing damage
// Fix penetration arrows colliding with bounding boxes of various entities
// Fix specific CFuncIllusionary crash
// Fix stun disappearing weapons
// Fix crash with firing too many arrows
// Fix crash when trying to detonate non grenades on pipebomb launcher
// Unowned sentry's rockets not dealing damage
// Penetration arrows colliding with bounding boxes of various entities
// Stun disappearing weapons
sig_etc_max_total_script_files_count "100000" // Mod: Max total count of files created by vscript
sig_etc_mm_spoof_mode "-1" // Mod: spoof mode
sig_etc_mm_spoof "0" // Mod: spoof a server into using Valve's matchmaking gamemodes
Expand Down Expand Up @@ -265,6 +266,7 @@ sig_custom_popfile "" // Force load specified popfile on map start in PvP (use
sig_pop_tank_extensions "1" // Mod: enable extended KV in CTankSpawner::Parse
sig_bot_improved_airblast "0" // Bots can reflect grenades stickies and arrows, makes them aware of new JI airblast
sig_no_bot_partner_taunt "1" // Disable bots answering to partner taunts
sig_pop_extra_bots_reserved_slots "8" // Reserve this many regual slots for giants/preferred bots when extra player slots is enabled
sig_pop_tfbot_extensions "1" // Mod: enable extended KV in CTFBotSpawner::Parse
sig_text_print_speed "4"
sig_pop_wave_extensions "1" // Mod: enable extended KV in CWave::Parse
Expand Down
7 changes: 4 additions & 3 deletions cfg/sigsegv_convars_no_mvm.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ sig_demo_stringtable_limit "0" // Mod: override 512KB string table limit in dem
sig_etc_allow_civilian_class "0" // Mod: allow civilian class to be picked
sig_etc_crayairblast_convar_nocheat "1" // Mod: remove the FCVAR_CHEAT flag from the Cray Airblast enable and tuning convars
sig_etc_deflect_rocket_spew "0" // Mod: intentionally cause multiple rocket breakmodels to spew forth when projectile deflection occurs
sig_etc_fix_misc_crash "1" // Mod: Fixes crashes:
// When firing too many arrows
// When trying to detonate non grenades on pipebomb launcher
// After removing sky_camera
sig_etc_heat_seeking_rockets "1" // Etc: enable heat-seeking rockets
sig_etc_hltv_notify_clients "0" // Mod: Notify players about connecting Source TV spectators
sig_etc_hltv_client_interact "0" // Mod: allow HLTV clients to interact with server players
Expand All @@ -70,10 +74,7 @@ sig_etc_misc "1" // Mod:
// Snap unreachable dropped mvm bomb to last nav area
// Fix unowned sentry's rockets not dealing damage
// Fix penetration arrows colliding with bounding boxes of various entities
// Fix specific CFuncIllusionary crash
// Fix stun disappearing weapons
// Fix crash with firing too many arrows
// Fix crash when trying to detonate non grenades on pipebomb launcher
sig_etc_max_total_script_files_count "100000" // Mod: Max total count of files created by vscript
sig_etc_mm_spoof_mode "-1" // Mod: spoof mode
sig_etc_mm_spoof "0" // Mod: spoof a server into using Valve's matchmaking gamemodes
Expand Down
14 changes: 14 additions & 0 deletions gamedata/sigsegv/misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5930,6 +5930,8 @@

"CEconWearable::RemoveFrom" "_ZN13CEconWearable10RemoveFromEP11CBaseEntity"
"CEconWearable::UnEquip" "_ZN13CEconWearable7UnEquipEP11CBasePlayer"
"CEconWearable::GetSkin" "_ZN13CEconWearable7GetSkinEv"


"CPlayerInventory::DumpInventoryToConsole" "_ZN16CPlayerInventory22DumpInventoryToConsoleEb"
"CPlayerInventory::GetMaxItemCount" "_ZNK16CPlayerInventory15GetMaxItemCountEv"
Expand Down Expand Up @@ -6031,6 +6033,8 @@
"CTFWeaponBase::GetViewModelWeaponRole" "_ZN13CTFWeaponBase22GetViewModelWeaponRoleEv"
"CTFWeaponBase::OnActiveStateChanged" "_ZN13CTFWeaponBase20OnActiveStateChangedEi"
"CTFWeaponBase::CanHolster" "_ZNK13CTFWeaponBase10CanHolsterEv"
"CTFWeaponBase::GetSkin" "_ZN13CTFWeaponBase7GetSkinEv"


"CTFWeaponBaseGun::DoFireEffects" "_ZN16CTFWeaponBaseGun13DoFireEffectsEv"
"CTFWeaponBaseGun::FireProjectile" "_ZN16CTFWeaponBaseGun14FireProjectileEP9CTFPlayer"
Expand Down Expand Up @@ -6063,6 +6067,7 @@
"CWeaponMedigun::SecondaryAttack" "_ZN14CWeaponMedigun15SecondaryAttackEv"
"CWeaponMedigun::CycleResistType" "_ZN14CWeaponMedigun15CycleResistTypeEv"
"CWeaponMedigun::FindAndHealTargets" "_ZN14CWeaponMedigun18FindAndHealTargetsEv"
"CWeaponMedigun::Deploy" "_ZN14CWeaponMedigun6DeployEv"

"CTFWeaponFlameBall::FireProjectile" "_ZN18CTFWeaponFlameBall14FireProjectileEP9CTFPlayer"

Expand Down Expand Up @@ -6124,6 +6129,11 @@
"CTFBaseBoss::GetCurrencyValue" "_ZN11CTFBaseBoss16GetCurrencyValueEv"

"CTFTankBoss::GetCurrencyValue" "_ZN11CTFTankBoss16GetCurrencyValueEv"

"CBeam::BeamCreate" "_ZN5CBeam10BeamCreateEPKcf"
"CBeam::EntsInit" "_ZN5CBeam8EntsInitEP11CBaseEntityS1_"

"CSprite::SpriteCreate" "_ZN7CSprite12SpriteCreateEPKcRK6Vectorb"

"CLagCompensationManager::BacktrackPlayer" "_ZN23CLagCompensationManager15BacktrackPlayerEP11CBasePlayerf"

Expand Down Expand Up @@ -6160,6 +6170,10 @@
"CServerNetworkProperty::IsInPVS" "_ZN22CServerNetworkProperty7IsInPVSEPK18CCheckTransmitInfo"

"CServerGameDLL::Shutdown" "_ZN14CServerGameDLL11DLLShutdownEv"

"ClientData_Update" "_Z17ClientData_UpdateP11CBasePlayer"

"GetCurrentSkyCamera" "_Z19GetCurrentSkyCamerav"
}

"addrs_group"
Expand Down
2 changes: 1 addition & 1 deletion gamedata/sigsegv/tfplayer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@
"CTFPlayerShared::OnAddTeleported" "_ZN15CTFPlayerShared15OnAddTeleportedEv"
"CTFPlayerShared::OnRemoveTeleported" "_ZN15CTFPlayerShared18OnRemoveTeleportedEv"
"CTFPlayerShared::RemoveAllCond" "_ZN15CTFPlayerShared13RemoveAllCondEv"

"CTFPlayerShared::RecalculatePlayerBodygroups" "_ZN15CTFPlayerShared27RecalculatePlayerBodygroupsEv"
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions scripts/mvm_bigrock_sigdemo.pop
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ WaveSchedule
SniperHideLasers 1 [$SIGSEGV] //If set, snipers will not display lasers when aiming
SentryBusterFriendlyFire 0 [$SIGSEGV] //If set to 0, buster will not damage robots (default: 1)
BotPushaway 0 [$SIGSEGV] //Should bots push each other away (default: 1)
AllowBotExtraSlots 1 [$SIGSEGV] // Allows you to set RobotLimit up to 94 bots instead of 26. Must be placed before RobotLimit. Bots will prefer normal slots by default unless the TFBot has the PreferExtraSlots 1 key (default: 0)
AllowBotExtraSlots 1 [$SIGSEGV] // Increases maximum RobotLimit to a total player slot limit (On most servers with -unrestricted_maxplayers this is 94 after excluding defenders, on some this is 250). Must be placed before RobotLimit. Bots will prefer normal slots by default unless the TFBot has the PreferExtraSlots 1 key (default: 0)
ExtraBotSlotsNoDeathcam 1 [$SIGSEGV] // If bots in extra slots kill a player, the bot name in deathcam with display as ERRORNAME. If you don't like that you can turn deathcam off (default: 1)
RobotLimit 18 [$SIGSEGV] //Sets a robot limit. You can increase or decrease it, but increasing it will reduce max spectator and player count (you need to set MaxSpectators below 5). 26 is maximum value to keep 6 players active (default: 22)
ExtraBotSlotsReservedNormalSlotCount 8 [$SIGSEGV] // If the Robot and human limit combined is above 100, reserve this many normal slots for giants and preferred bots. You can add PreferNormalSlots 1 to TFBot to make the robot use the reserved slot (default: 8)
RobotLimit 18 [$SIGSEGV] //Sets a robot limit. You can increase or decrease it, but increasing it will reduce max spectator and player count (you need to set MaxSpectators below 5). Without AllowBotsExtraSlots, 26 is maximum value to keep 6 players active (default: 22)
EnableDominations 1 [$SIGSEGV] //Should enable player to bot dominations
MedigunShieldDamage 1 [$SIGSEGV] //If set to 1, bot medigun shields will damage players. Use "dmg penalty vs players" attribute to control damage dealt (default: 0)
SendBotsToSpectatorImmediately 1 [$SIGSEGV] //Should the bots be transferred to spectator team immediately after dying. Use this if your mission consists of lots of easy to kill enemies (default: 0)
Expand Down
3 changes: 3 additions & 0 deletions src/convar_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ namespace ConVar_Restore
// Warning("ConVar_Restore::Save: ConVar \"%s\" is a duplicate\n", var->GetName());
// continue;
// }
if (var->IsFlagSet(FCVAR_DEVELOPMENTONLY)) {
continue;
}
if (var->IsFlagSet(FCVAR_NEVER_AS_STRING)) {
Warning("ConVar_Restore::Save: ConVar \"%s\" has unsupported flag FCVAR_NEVER_AS_STRING\n", var->GetName());
continue;
Expand Down
14 changes: 13 additions & 1 deletion src/mod/attr/custom_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8804,8 +8804,17 @@ namespace Mod::Attr::Custom_Attributes
return;
}
}
float multIncrease = additive ? player->GetMaxAmmo(ammoType) / (player->GetMaxAmmo(ammoType) - (new_value.m_Float - old_value.m_Float)) : new_value.m_Float / old_value.m_Float;
float newAmmoRatio = additive ? player->GetMaxAmmo(ammoType) : new_value.m_Float;
float oldAmmoRatio = additive ? (player->GetMaxAmmo(ammoType) - (new_value.m_Float - old_value.m_Float)) : old_value.m_Float;

float multIncrease = newAmmoRatio / oldAmmoRatio;
auto mod = player->GetOrCreateEntityModule<AmmoFractionModule>("amraction");
// Old max ammo count was 0, restrore ammo to full
if (oldAmmoRatio == 0) {
mod->ammoFraction[ammoType] = 0;
player->SetAmmoCount(ammoType, player->GetMaxAmmo(ammoType));
return;
}
if (mod->ammoFraction[ammoType] != 0 && player->GetAmmoCount(ammoType) * multIncrease >= player->GetMaxAmmo(ammoType)) {
mod->ammoFraction[ammoType] = 0;
}
Expand All @@ -8819,6 +8828,9 @@ namespace Mod::Attr::Custom_Attributes
{
auto player = GetPlayerOwnerOfAttributeList(list);
if (player != nullptr) {
int maxAmmoPre = player->GetMaxAmmo(TF_AMMO_PRIMARY);
int ammoPre = player->GetAmmoCount(TF_AMMO_PRIMARY);

AdjustAmmo(player, TF_AMMO_PRIMARY, old_value, new_value, !pAttrDef->IsMultiplicative());
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/mod/common/weapon_shoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ namespace Mod::Common::Weapon_Shoot

int customDamageTypeBullet = 0;
RefCount rc_FireWeaponDoTrace;
bool isCritTrace = false;
DETOUR_DECL_MEMBER(void, CTFPlayer_FireBullet, CTFWeaponBase *weapon, FireBulletsInfo_t& info, bool bDoEffects, int nDamageType, int nCustomDamageType)
{
bool doTrace = false;
Expand All @@ -369,6 +370,7 @@ namespace Mod::Common::Weapon_Shoot
int ePenetrateType = weapon ? weapon->GetPenetrateType() : TF_DMG_CUSTOM_NONE;
if (ePenetrateType == TF_DMG_CUSTOM_NONE)
ePenetrateType = customDamageTypeBullet;
isCritTrace = nDamageType & DMG_CRITICAL;
doTrace = ( ( info.m_iTracerFreq != 0 ) && ( tracerCount++ % info.m_iTracerFreq ) == 0 ) || (ePenetrateType == TF_DMG_CUSTOM_PENETRATE_ALL_PLAYERS);
}

Expand All @@ -384,7 +386,8 @@ namespace Mod::Common::Weapon_Shoot
te_tf_particle_effects_control_point_t cp;
cp.m_eParticleAttachment = PATTACH_ABSORIGIN;
cp.m_vecOffset = vEndPos;
DispatchParticleEffect(reinterpret_cast<CTFPlayer *>(this)->GetTracerType(), PATTACH_ABSORIGIN, nullptr, nullptr, vStartPos, true, vec3_origin, vec3_origin, false, false, &cp, nullptr);
auto tracerName = reinterpret_cast<CTFPlayer *>(this)->GetTracerType();
DispatchParticleEffect(isCritTrace ? CFmtStr("%s_crit", tracerName).Get() : tracerName, PATTACH_ABSORIGIN, nullptr, nullptr, vStartPos, true, vec3_origin, vec3_origin, false, false, &cp, nullptr);
}
DETOUR_MEMBER_CALL(CTFPlayer_MaybeDrawRailgunBeam)(filter, weapon, vStartPos, vEndPos);
}
Expand Down
74 changes: 74 additions & 0 deletions src/mod/etc/crash_fixes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include "mod.h"
#include "stub/baseentity.h"
#include "stub/tfweaponbase.h"
#include "stub/projectiles.h"
#include "stub/objects.h"
#include "stub/tfentities.h"
#include "stub/nextbot_cc.h"
#include "stub/gamerules.h"
#include "stub/nav.h"
#include "stub/misc.h"
#include "link/link.h"
#include "util/backtrace.h"
#include "util/clientmsg.h"
#include "util/misc.h"
#include "util/iterate.h"
#include "tier1/CommandBuffer.h"

namespace Mod::Etc::Crash_Fixes
{

DETOUR_DECL_MEMBER(CBaseEntity *, CTFPipebombLauncher_FireProjectile, CTFPlayer *player)
{
auto proj = DETOUR_MEMBER_CALL(CTFPipebombLauncher_FireProjectile)(player);
auto weapon = reinterpret_cast<CTFPipebombLauncher *>(this);
if (rtti_cast<CTFGrenadePipebombProjectile *>(proj) == nullptr) {
weapon->m_Pipebombs->RemoveAll();
weapon->m_iPipebombCount = 0;
}
return proj;
}

DETOUR_DECL_MEMBER(void, CFuncIllusionary_Spawn)
{
auto entity = reinterpret_cast<CBaseEntity *>(this);
CBaseEntity::PrecacheModel(STRING(entity->GetModelName()));
DETOUR_MEMBER_CALL(CFuncIllusionary_Spawn)();
}
StaticFuncThunk<CBaseEntity*> ft_GetCurrentSkyCamera("GetCurrentSkyCamera");

DETOUR_DECL_STATIC(void, ClientData_Update, CBasePlayer *pl)
{
if (ft_GetCurrentSkyCamera() == nullptr) {
pl->m_Local->m_skybox3darea = 255;
return;
}
DETOUR_STATIC_CALL(ClientData_Update)(pl);
}

class CMod : public IMod
{
public:
CMod() : IMod("Etc:Crash_Fixes")
{
// Fix cfuncillusionary crash
MOD_ADD_DETOUR_MEMBER(CFuncIllusionary_Spawn, "CFuncIllusionary::Spawn");

// Fix arrow crash when firing too fast
MOD_ADD_DETOUR_MEMBER(CTFPipebombLauncher_FireProjectile, "CTFPipebombLauncher::FireProjectile");

// Fix crash after sky_camera being removed
MOD_ADD_DETOUR_STATIC(ClientData_Update, "ClientData_Update");
}
};
CMod s_Mod;

ConVar cvar_enable("sig_etc_fix_misc_crash", "0", FCVAR_NOTIFY,
"Mod:\nFixes crashes:"
"\nWhen firing too many arrows"
"\nWhen trying to detonate non grenades on pipebomb launcher"
"\nAfter removing sky_camera",
[](IConVar *pConVar, const char *pOldValue, float flOldValue){
s_Mod.Toggle(static_cast<ConVar *>(pConVar)->GetBool());
});
}
Loading

0 comments on commit 7124697

Please sign in to comment.