Closed jensewe closed 2 years ago
https://github.com/ValveSoftware/Source-1-Games/issues/3388#issuecomment-830781131
I can only advise to change method of disabling intros, or to attempt to understand what's been missing in said plugin.
Came up with a thought that even though the camera is disabled, the Think function could still be running. So I tried a bit with SDKHook hooking, blocking Think and it seems I'm right as SDKHook Think was actually called and no crash.
Still I'm not confident to confirm a fix because I've been doing CTriggerCamera
cases only, while under no impression of what maps contain the other two. Would be appreciated if there's info.
Modified code below:
Action SDK_CTriggerCamera_OnThink(int entity)
{
SDKUnhook(entity, SDKHook_Think, SDK_CTriggerCamera_OnThink);
if (GetEntProp(entity, Prop_Data, "m_state") == 0) {
PrintToChatAll("\x04CTriggerCamera Think");
return Plugin_Handled;
}
return Plugin_Continue;
}
Action SDK_CMoveableCamera_OnThink(int entity)
{
SDKUnhook(entity, SDKHook_Think, SDK_CMoveableCamera_OnThink);
static int iOffs_m_bActive = -1;
if (iOffs_m_bActive == -1) {
iOffs_m_bActive = FindDataMapInfo(entity, "m_iszScriptId") + 72;
}
if (GetEntData(entity, iOffs_m_bActive, 1) == 0) {
PrintToChatAll("\x04CMoveableCamera Think");
return Plugin_Handled;
}
return Plugin_Continue;
}
public void OnClientDisconnect(int client)
{
if (!IsClientInGame(client)) {
return;
}
int viewEntity = GetEntPropEnt(client, Prop_Send, "m_hViewEntity");
if (!IsValidEdict(viewEntity)) {
return;
}
char cls[64];
GetEdictClassname(viewEntity, cls, sizeof(cls));
if (strncmp(cls, "point_viewcontrol", 17) == 0) {
// Matches CSurvivorCamera, CTriggerCamera
if (strcmp(cls[17], "_survivor") == 0 || cls[17] == '\0') {
// Disable entity to prevent CMoveableCamera::FollowTarget to cause a crash
// m_hTargetEnt EHANDLE is not checked for existence and can be NULL
// CBaseEntity::GetAbsAngles being called on causing a crash
AcceptEntityInput(viewEntity, "Disable");
if (cls[17] == '\0') {
SDKHook(viewEntity, SDKHook_Think, SDK_CTriggerCamera_OnThink);
} else {
SDKHook(viewEntity, SDKHook_Think, SDK_CMoveableCamera_OnThink);
}
}
// Matches CTriggerCameraMultiplayer
if (strcmp(cls[17], "_multiplayer") == 0) {
AcceptEntityInput(viewEntity, "RemovePlayer", client);
SDKHook(viewEntity, SDKHook_Think, SDK_CMoveableCamera_OnThink);
}
}
}
Why are you trying to enforce a fix to be placed into my plugin for a problem that's caused by a different plugin? 🤔
There's no convenient entry point to patch FollowCamera NULL dereference, and the only problematic case (known to me) that could happen on a clean sourcemod/game installation is taken care of by my plugin.
Thanks. looks like the skip intro actually raises this one:
// STOP SCENE
SetVariantString("!self");
AcceptEntityInput(entity, "StartMovement");
StartMovement
runs regardless of the active state handled by Enable/Disable
, guess I can prove it later and contact the author for a fix to it.
Thank you for your patience and helps!
Happens when joining Survivors from Spectators at start of Versus second half, with First Map - Skip Intro Cutscenes installed.
https://github.com/shqke/sp_public/blob/aadfd7c425e5a585a197160474551642b11d3115/disable_cameras/scripting/disable_cameras.sp#L21 It looks like changing to
IsClientConnected
would help, just weird and not guaranteed. I really doubt it's caused by a little gap between Connected and InGame for bots, still I'm not aware of how and when Connected and PutInServer are called for bots.Crash dumps QHQB-NAAW-M456 35K3-GYJ3-Z7H5