AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [l4d2] Need help with cl_fullupdate (https://forums.alliedmods.net/showthread.php?t=339594)

JLmelenchon 09-19-2022 16:12

[l4d2] Need help with cl_fullupdate
 
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 09-19-2022 16:14

Re: [l4d2] Need help with cl_fullupdate
 
I just noticed that some signatures for linux are missing, where can i find them? Can't load the adress of BaseServer too.

Spirit_12 09-19-2022 17:00

Re: [l4d2] Need help with cl_fullupdate
 
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.

Marttt 09-19-2022 17:06

Re: [l4d2] Need help with cl_fullupdate
 
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.

JLmelenchon 09-19-2022 17:19

Re: [l4d2] Need help with cl_fullupdate
 
https://github.com/SirPlease/L4D2-Co...ork/issues/319

Unless valve fix their ****, this is so needed at least each round start.

backwards 09-19-2022 17:42

Re: [l4d2] Need help with cl_fullupdate
 
The offset for l4d2 linux CBaseClient::UpdateAcknowledgedFramecount should be 50, however I could of miss counted and it could be 49 or 51.

Marttt 09-19-2022 21:28

Re: [l4d2] Need help with cl_fullupdate
 
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

JLmelenchon 09-20-2022 06:11

Re: [l4d2] Need help with cl_fullupdate
 
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.

Zynda 09-20-2022 11:59

Re: [l4d2] Need help with cl_fullupdate
 
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"
                        }
                }
        }
}


JLmelenchon 09-20-2022 13:20

Re: [l4d2] Need help with cl_fullupdate
 
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.


All times are GMT -4. The time now is 15:26.

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