Raised This Month: $12 Target: $400
 3% 

[l4d2] Need help with cl_fullupdate


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 09-19-2022 , 16:12   [l4d2] Need help with cl_fullupdate
Reply With Quote #1

Code:
L 09/19/2022 - 19:44:16: [SM] Exception reported: PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "CBaseClient::UpdateAcknowledgedFramecount" failed!
L 09/19/2022 - 19:44:16: [SM] Blaming: FullUpdate.smx
L 09/19/2022 - 19:44:16: [SM] Call stack trace:
L 09/19/2022 - 19:44:16: [SM]   [0] SetFailState
L 09/19/2022 - 19:44:16: [SM]   [1] Line 34, plugin.sp::OnPluginStart
L 09/19/2022 - 19:44:16: [SM] Unable to load plugin "FullUpdate.smx": Error detected in plugin startup (see error logs)
Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>
#include <FullUpdate>
#include <readyup>

Handle g_hCBaseClient_UpdateAcknowledgedFramecount;

public Plugin myinfo = 
{
	name = "FullUpdate", 
	author = "BotoX", 
	description = "Serverside cl_fullupdate", 
	version = "1.0"
}

public void OnPluginStart()
{
	Handle hGameConf = LoadGameConfigFile("FullUpdate.games");
	if (hGameConf == INVALID_HANDLE)
	{
		SetFailState("Couldn't load FullUpdate.games game config!");
		return;
	}
	
	// void CBaseClient::UpdateAcknowledgedFramecount()
	StartPrepSDKCall(SDKCall_Raw);
	
	if (!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "CBaseClient::UpdateAcknowledgedFramecount"))
	{
		CloseHandle(hGameConf);
		SetFailState("PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, \"CBaseClient::UpdateAcknowledgedFramecount\" failed!");
		return;
	}
	CloseHandle(hGameConf);
	
	PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
	
	g_hCBaseClient_UpdateAcknowledgedFramecount = EndPrepSDKCall();
	
	RegConsoleCmd("sm_fullupdate", Command_FullUpdate);
	RegConsoleCmd("cl_fullupdate", Command_FullUpdate);
	RegConsoleCmd("fullupdate", Command_FullUpdate);
}

public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
	CreateNative("ClientFullUpdate", Native_FullUpdate);
	RegPluginLibrary("FullUpdate");
	
	return APLRes_Success;
}

bool FullUpdate(int client)
{
	if(IsFakeClient(client) || IsClientSourceTV(client) || IsClientReplay(client)) {
		return false;
	}
	
	// The IClient vtable is +4 from the IGameEventListener2 (CBaseClient) vtable due to multiple inheritance.
	Address pIClient = GetClientIClient(client) - view_as<Address>(4);
	
	if (!pIClient)
		return false;
		
	SDKCall(g_hCBaseClient_UpdateAcknowledgedFramecount, pIClient, -1);
	
	return true;
}

public int Native_FullUpdate(Handle plugin, int numParams)
{
	int client = GetNativeCell(1);
	
	if (client > MaxClients || client <= 0)
	{
		ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid.");
		return 0;
	}
	
	if (!IsClientInGame(client))
	{
		ThrowNativeError(SP_ERROR_NATIVE, "Client is not in-game.");
		return 0;
	}
	
	if (IsFakeClient(client))
	{
		ThrowNativeError(SP_ERROR_NATIVE, "Client is fake-client.");
		return 0;
	}
	
	return FullUpdate(client);
}

public Action Command_FullUpdate(int client, int args)
{
	AdminId aId = GetUserAdmin(client);
	bool bOwner = GetAdminFlag(aId, Admin_Custom6);
	
	if(!bOwner) {
		return Plugin_Handled;
	}
	
	FullUpdate(client);
	return Plugin_Handled;
}

public void OnRoundIsLive()
{
    for(int i = 1; i <= MaxClients; i++) {
        if(!IsClientInGame(i)) {
            continue;
        }
        
        ClientFullUpdate(i);
    }
}

stock Handle GetConfig()
{
	static Handle hGameConf = INVALID_HANDLE;
	
	if (hGameConf == INVALID_HANDLE)
	{
		hGameConf = LoadGameConfigFile("FullUpdate.games");
	}
	
	return hGameConf;
}

stock Address GetBaseServer()
{
	static Address pBaseServer = Address_Null;
	
	if (pBaseServer == Address_Null)
	{
		pBaseServer = GameConfGetAddress(GetConfig(), "CBaseServer");
	}
	
	return pBaseServer;
}

stock Address GetIClient(int slot)
{
	static Handle hGetClient = INVALID_HANDLE;
	
	if (hGetClient == INVALID_HANDLE)
	{
		StartPrepSDKCall(SDKCall_Raw);
		PrepSDKCall_SetFromConf(GetConfig(), SDKConf_Virtual, "CBaseServer::GetClient");
		PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
		PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
		hGetClient = EndPrepSDKCall();
	}
	
	return view_as<Address>(SDKCall(hGetClient, GetBaseServer(), slot));
}

stock int GetPlayerSlot(Address pIClient)
{
	static Handle hPlayerSlot = INVALID_HANDLE;
	
	if (hPlayerSlot == INVALID_HANDLE)
	{
		StartPrepSDKCall(SDKCall_Raw);
		PrepSDKCall_SetFromConf(GetConfig(), SDKConf_Virtual, "CBaseClient::GetPlayerSlot");
		PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
		hPlayerSlot = EndPrepSDKCall();
	}
	
	return SDKCall(hPlayerSlot, pIClient);
}

stock Address GetClientIClient(int client)
{
	if(IsFakeClient(client) || IsClientSourceTV(client) || IsClientReplay(client)) {
		return view_as<Address>(-1);
	}
	
	//Engine client index is entity index minus one
	return GetIClient(client - 1);
}
Code:
"Games"
{
	"#default"
	{
		"#supported"
		{
			"engine"	"orangebox_valve"
			"engine"	"css"
			"engine"	"csgo"
		}
		
		"Addresses"
		{
			"CBaseServer"
			{
				"windows"
				{
					"signature"	"CVEngineServer::CreateFakeClient"				
					"read"		"8"
				}
				"linux"
				{
					"signature"	"sv"
				}
				"mac"
				{
					"signature"	"sv"
				}
			}
		}
		
		"Signatures"
		{
			"CVEngineServer::CreateFakeClient"
			{
				"library"	"engine"
				"windows"	"\x55\x8B\xEC\x56\xFF\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x8B"
			}
			
			"sv"
			{
				"library"	"engine"
				"linux"		"@sv"
				"mac"		"@sv"
			}
		}
	}

  "#default"
	{
		"#supported"
		{
			"engine"	"left4dead"
			"engine"	"left4dead2"
			"engine"	"csgo"
		}
    
    "Signatures"
		{
			"CBaseClient::OnRequestFullUpdate"
			{
				"library"	"engine"
				"windows"	"\x55\x8B\xEC\x56\x8B\xF1\x8B\x8E\x30\x02\x00\x00"
			}
    }
		
		"Offsets"
		{
			"CBaseServer::GetClient"
			{
				"windows"	"6"
				"linux"		"7"
				"mac"		"7"
			}
			
			"CBaseClient::GetPlayerSlot"
			{
				"windows"	"14"
				"linux"		"15"
				"mac"		"15"
			}
      
      "CBaseClient::UpdateAcknowledgedFramecount"
			{
				"windows"		"17"
			}
      
      "CBaseClient::Test"
      {
        "windows"		"32"
      }
		}
	}
}
JLmelenchon is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 09-19-2022 , 16:14   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #2

I just noticed that some signatures for linux are missing, where can i find them? Can't load the adress of BaseServer too.

Last edited by JLmelenchon; 09-19-2022 at 16:57.
JLmelenchon is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 09-19-2022 , 17:00   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #3

You need to decompile the libraries and find them.

Curious to know what this plugin actually does? I see it provides a native, but what exactly is this function for.
__________________
Spirit_12 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 09-19-2022 , 17:06   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #4

I believe is the cl_fullupdate command. It forces the client to sync all entities, something like that.
e.g. Fixes clients glow desync when ALT+TAB (not in windowed mode)

Anyway, it is harmful (lag) to the server if not used wisely.
__________________

Last edited by Marttt; 09-19-2022 at 17:07.
Marttt is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 09-19-2022 , 17:19   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #5

https://github.com/SirPlease/L4D2-Co...ork/issues/319

Unless valve fix their ****, this is so needed at least each round start.
JLmelenchon is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 09-19-2022 , 17:42   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #6

The offset for l4d2 linux CBaseClient::UpdateAcknowledgedFramecount should be 50, however I could of miss counted and it could be 49 or 51.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 09-19-2022 , 21:28   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #7

Probably you will need create a command that allow clients to trigger this call, cause the bug is under control and is not always on round_start
__________________

Last edited by Marttt; 09-19-2022 at 22:14.
Marttt is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 09-20-2022 , 06:11   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #8

It needs to be automatic, people will not do that manually. I know that it does not cover all situations but it will fix half of them if you do that every round start and it will not affect the server if you only do that at this moment.

I honestly wonder if sv_consistency have not a responsability in this problem, it check files every map and could desync clients with the load.

Last edited by JLmelenchon; 09-20-2022 at 06:14.
JLmelenchon is offline
Zynda
Member
Join Date: Jul 2011
Old 09-20-2022 , 11:59   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #9

Your gamedata is a mess.
I've added the missing linux data and made it functional but you should clean it of unused entries, and remove entries for other games (unless you mean to support them).

Code:
"Games"
{
        "#default"
        {
                "#supported"
                {
                        "engine"        "orangebox_valve"
                        "engine"        "css"
                        "engine"        "csgo"
                        "engine"        "left4dead2"
                }
                
                "Addresses"
                {
                        "CBaseServer"
                        {
                                "windows"
                                {
                                        "signature"     "CVEngineServer::CreateFakeClient"                              
                                        "read"          "8"
                                }
                                "linux"
                                {
                                        "signature"     "sv"
                                }
                                "mac"
                                {
                                        "signature"     "sv"
                                }
                        }
                }
                
                "Signatures"
                {
                        "CVEngineServer::CreateFakeClient"
                        {
                                "library"       "engine"
                                "windows"       "\x55\x8B\xEC\x56\xFF\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x8B"
                        }
                        
                        "sv"
                        {
                                "library"       "engine"
                                "linux"         "@sv"
                                "mac"           "@sv"
                        }
                }
        }

        "left4dead2"
        {
                "Signatures"
                {
                        "CBaseClient::OnRequestFullUpdate"
                        {
                                "library"       "engine"
                                "windows"       "\x55\x8B\xEC\x56\x8B\xF1\x8B\x8E\x30\x02\x00\x00"
                                "linux"         "@_ZN11CBaseClient19OnRequestFullUpdateEPKc"
                        }
                }
                
                "Offsets"
                {
                        "CBaseServer::GetClient"
                        {
                                "windows"       "6"
                                "linux"         "7"
                                "mac"           "7"
                        }
                        
                        "CBaseClient::GetPlayerSlot"
                        {
                                // Windows not in l4d2 vtable
                                "linux"         "4"
                                "mac"           "4"
                        }
      
                        "CBaseClient::UpdateAcknowledgedFramecount"
                        {
                                "windows"       "4"
                                "linux"         "50"
                        }
                }
        }
}
Zynda is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 09-20-2022 , 13:20   Re: [l4d2] Need help with cl_fullupdate
Reply With Quote #10

You are my hero thank you. It works but just to be sure is it fine and not going to hurt server this way?

Code:
public void OnRoundIsLive()
{
    for(int i = 1; i <= MaxClients; i++) 
    {
        if(IsClientInGame(i) && !IsFakeClient(i)) 
        {
            ClientFullUpdate(i);
        }
        
    }
}
The code for roundislive i put in my first post was not working and throwed an error that the client was fake.

Last edited by JLmelenchon; 09-20-2022 at 13:23.
JLmelenchon is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode