AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CS:GO] Uncache all particles for custom maps [NEW] (https://forums.alliedmods.net/showthread.php?t=313951)

gubka 01-29-2019 10:55

[CS:GO] Uncache all particles for custom maps [NEW]
 
Considerring topic: https://forums.alliedmods.net/showthread.php?t=247897

Onlu support lin, because Windows not have that issue, and clean the tables itself
PHP Code:

/**
 * Variables to store SDK calls handlers.
 **/
Handle hSDKCallDestructorParticleDictionary;
Handle hSDKCallContainerFindTable;
Handle hSDKCallTableDeleteAllStrings;

/**
 * Variables to store virtual SDK offsets.
 **/
Address particleSystemDictionary;
Address networkStringTable;
int ParticleSystem_Count;

/**
 * @brief Particles module init function.
 **/
void ParticlesOnInit(/*void*/)
{
    
// Starts the preparation of an SDK call
    
StartPrepSDKCall(SDKCall_Raw);
    
PrepSDKCall_SetFromConf(gServerData.ConfigSDKConf_Signature"CParticleSystemDictionary::~CParticleSystemDictionary");
    
    
// Validate call
    
if((hSDKCallDestructorParticleDictionary EndPrepSDKCall()) == null)
    {
        
// Log failure
        
LogEvent(falseLogType_FatalLOG_GAME_EVENTSLogModule_Effects"GameData Validation""Failed to load SDK call \"CParticleSystemDictionary::~CParticleSystemDictionary\". Update signature in \"%s\""PLUGIN_CONFIG);
        return;
    }
    
    
/*_________________________________________________________________________________________________________________________________________*/

    // Starts the preparation of an SDK call
    
StartPrepSDKCall(SDKCall_Raw);
    
PrepSDKCall_SetFromConf(gServerData.ConfigSDKConf_Virtual"CNetworkStringTableContainer::FindTable");
    
    
// Adds a parameter to the calling convention. This should be called in normal ascending order
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);
    
    
// Validate call
    
if((hSDKCallContainerFindTable EndPrepSDKCall()) == null)
    {
        
// Log failure
        
LogEvent(falseLogType_FatalLOG_GAME_EVENTSLogModule_Effects"GameData Validation""Failed to load SDK call \"CNetworkStringTableContainer::FindTable\". Update virtual offset in \"%s\""PLUGIN_CONFIG);
        return;
    }
    
    
/*_________________________________________________________________________________________________________________________________________*/

    // Starts the preparation of an SDK call
    
StartPrepSDKCall(SDKCall_Raw);
    
PrepSDKCall_SetFromConf(gServerData.ConfigSDKConf_Signature"CNetworkStringTable::DeleteAllStrings");
    
    
// Validate call
    
if((hSDKCallTableDeleteAllStrings EndPrepSDKCall()) == null)
    {
        
// Log failure
        
LogEvent(falseLogType_FatalLOG_GAME_EVENTSLogModule_Effects"GameData Validation""Failed to load SDK call \"CNetworkStringTable::DeleteAllStrings\". Update signature in \"%s\""PLUGIN_CONFIG);
        return;
    }
    
    
/*_________________________________________________________________________________________________________________________________________*/
    
    // Load other offsets
    
fnInitGameConfAddress(gServerData.ConfigparticleSystemDictionary"m_pParticleSystemDictionary");
    
fnInitGameConfAddress(gServerData.ConfignetworkStringTable"s_NetworkStringTable");
    
fnInitGameConfOffset(gServerData.ConfigParticleSystem_Count"CParticleSystemMgr::GetParticleSystemCount");
}

/**
 * @brief Particles module load function.
 **/
void ParticlesOnLoad(/*void*/)
{
    
// Initialize buffer char
    
static char sBuffer[PLATFORM_LINE_LENGTH];

    
// Validate that particles wasn't precache yet
    
bool bSave LockStringTables(false);
    
int iCount LoadFromAddress(particleSystemDictionary view_as<Address>(ParticleSystem_Count), NumberType_Int16);
    
int iTable SDKCall(hSDKCallContainerFindTablenetworkStringTable"ParticleEffectNames");
    if(!
iCount && iTable/// Validate that table is exist and it empty
    
{
        
// Opens the file
        
File hFile OpenFile("particles/particles_manifest.txt""rt"true);
        
        
// If doesn't exist stop
        
if(hFile == null)
        {
            
LogEvent(falseLogType_FatalLOG_CORE_EVENTSLogModule_Effects"Config Validation""Error opening file: \"particles/particles_manifest.txt\"");
            return;
        }

        
// Read lines in the file
        
while(hFile.ReadLine(sBuffersizeof(sBuffer)))
        {
            
// Checks if string has correct quotes
            
int iQuotes CountCharInString(sBuffer'"');
            if(
iQuotes == 4)
            {
                
// Trim string
                
TrimString(sBuffer);

                
// Copy value string
                
strcopy(sBuffersizeof(sBuffer), sBuffer[strlen("\"file\"")]);
                
                
// Trim string
                
TrimString(sBuffer);
                
                
// Strips a quote pair off a string 
                
StripQuotes(sBuffer);

                
// Precache model
                
int i; if(sBuffer[i] == '!'i++;
                
PrecacheGeneric(sBuffer[i], true);
                
SDKCall(hSDKCallTableDeleteAllStringsiTable); /// HACK~HACK
                /// Clear tables after each file because some of them contains
                /// huge amount of particles and we work around the limit
            
}
        }
    }
    
    
// Initialize the table index
    
static int tableIndex INVALID_STRING_TABLE;

    
// Validate table
    
if(tableIndex == INVALID_STRING_TABLE)
    {
        
// Searches for a string table
        
tableIndex FindStringTable("ParticleEffectNames");
    }
    
    
// If array hasn't been created, then create
    
if(gServerData.Particles == null)
    {
        
// Initialize a particle list array
        
gServerData.Particles CreateArray(NORMAL_LINE_LENGTH); 

        
// i = table string
        
iCount GetStringTableNumStrings(tableIndex);
        for(
int i 0iCounti++)
        {
            
// Gets the string at a given index
            
ReadStringTable(tableIndexisBuffersizeof(sBuffer));
            
            
// Push data into array 
            
gServerData.Particles.PushString(sBuffer);
        }
    }
    else
    {
        
// i = particle name
        
iCount gServerData.Particles.Length;
        for(
int i 0iCounti++)
        {
            
// Gets the string at a given index
            
gServerData.Particles.GetString(isBuffersizeof(sBuffer));
            
            
// Push data into table 
            
AddToStringTable(tableIndexsBuffer);
        }
    }   
    
LockStringTables(bSave);
}

/**
 * @brief Particles module purge function.
 **/
void ParticlesOnPurge(/*void*/)
{
    
// @link https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/src_main/particles/particles.cpp#L81
    
SDKCall(hSDKCallDestructorParticleDictionaryparticleSystemDictionary);

    
/*_________________________________________________________________________________________________________________________________________*/
    
    /// Clear all particles effect table
    
bool bSave LockStringTables(false);
    
int iTable SDKCall(hSDKCallContainerFindTablenetworkStringTable"ParticleEffectNames");
    if(
iTable)   SDKCall(hSDKCallTableDeleteAllStringsiTable);
    
LockStringTables(bSave);


PHP Code:

"Games"
{
    
"csgo"
    
{
        
"Offsets"
        
{
            
"CParticleSystemMgr::GetParticleSystemCount" // Str: "PrecacheStandardParticleSystems()"
            
{
                
"windows"   "38"
                "linux"     "38"
            
}
        }

        
// Sigs from the lib ( https://forums.alliedmods.net/showthread.php?t=309074 )
        // You can update them only by yourself using tutorial in the link
        
"Signatures"
        
{
            
/*
             * Info: Every custom particle precached during a map is not removed from precache table on the map end. 
             *       Then, if a lot of maps that uses custom particles are running in my server the precache table will be filled 
             *       and the custom particles used on the next maps will not show right but erros will appear in their place.
             */
            
"CParticleSystemDictionary::~CParticleSystemDictionary" // Str: "CParticleSystemMgr::InitAttributeTable has an out-of-date attribute list! (element %d not set up)\n" | "CParticleSystemMgr::InitAttributeTable" -> "CParticleSystemMgr::CParticleSystemMgr" -> "CParticleSystemMgr::~CParticleSystemMgr" 
            
{
                
"library"   "server"
                "windows"   "\x55\x8B\xEC\x51\x56\x57\x8B\xF9\x33\xF6\x8B\x47\x58"
                "linux"     "\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\x8B\x7D\x08\x8B\x47\x58\x85\xC0"
            
}
            
"CParticleSystemDefinition::ParseChildren" // Str: "DmeParticleSystemDefinition" and "children" and "preventNameBasedLookup"
            
{
                
"library"    "server"
                "windows"   "\x55\x8B\xEC\x83\xEC\x20\x53\x56\x57\x8B\xF9\x51"
                "linux"        "\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\x8B\x45\x0C\xC7\x44\x24\x04"
            
}
            
"SV_ActivateServer" // Str: "SV_ActivateServer"
            
{
                
"library"   "engine"
                "windows"   "\x55\x8B\xEC\x83\xE4\xF8\x83\xEC\x0C\x53\x8B\x1D\x2A\x2A\x2A\x2A"
                "linux"     "\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\xC7\x04\x24\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\xC7\x04\x24\x2A\x2A\x2A\x2A"
            
}
            
"CNetworkStringTable::DeleteAllStrings" // Str: "___clientsideitemsplaceholder0___"
            
{
                
"library"   "engine"
                "windows"   "\x56\x8B\xF1\x57\x8B\x4E\x40"
                "linux"     "\x55\x89\xE5\x53\x83\xEC\x14\x8B\x5D\x08\x8B\x43\x40"
            
}
        }
       
        
// Addr from the lib ( https://forums.alliedmods.net/showthread.php?t=309074 )
        // You can update them only by yourself using tutorial in the link
        
"Addresses"
        
{
            
"m_pParticleSystemDictionary"
            
{
                
"linux"
                
{
                    
"signature"     "CParticleSystemDefinition::ParseChildren"
                    "read"          "375"
                    "read"          "0"
                    "read"          "140"
                
}
                
"windows"
                
{
                    
"signature"     "CParticleSystemDefinition::ParseChildren"
                    "read"          "401"
                    "read"          "0"
                
}
            }
            
"s_NetworkStringTable"
            
{
                
"linux"
                
{
                    
"signature"     "SV_ActivateServer"
                    "read"          "34"
                    "read"          "0"
                
}
                
"windows"
                
{
                    
"signature"     "SV_ActivateServer"
                    "read"          "997"
                    "read"          "0"
                
}
            }
        }
    }



8guawong 01-29-2019 11:35

Re: [CS:GO] Uncache all particles for custom maps
 
wow thanks for sharing this

Dragokas 01-31-2019 04:42

Re: [CS:GO] Uncache all particles for custom maps
 
gubka, very nice. Thank you!

offtop.
Maybe, you could also found signature for registering particle system? (for custom games, instead manifest method)

gubka 01-31-2019 07:06

Re: [CS:GO] Uncache all particles for custom maps
 
Quote:

Originally Posted by Dragokas (Post 2637395)
gubka, very nice. Thank you!

offtop.
Maybe, you could also found signature for registering particle system? (for custom games, instead manifest method)

at first I tryied to store address of defaultquery which should contain the particle system which precache on the first start, using signature CParticleSystemMgr::Init(PQuery DefaultQuery), but it didn't help, and it more easier to precache throw those file, cause I developed that algo for my zp core, you can do whatever you want with it, but in my option that one of the simplest solution which you can find, because more sigs for me, make some updates for me a bit problematic, cause sometimes I just don't have time to open IDA and to update all sigs back. So good luck

simpson0141 02-12-2019 02:53

Re: [CS:GO] Uncache all particles for custom maps
 
Thank you for sharing. It is not use on Windows?

gubka 02-16-2019 09:57

Re: [CS:GO] Uncache all particles for custom maps
 
Quote:

Originally Posted by simpson0141 (Post 2639275)
Thank you for sharing. It is not use on Windows?

window dont use those signatures

Agent Wesker 02-27-2019 19:26

Re: [CS:GO] Uncache all particles for custom maps
 
If anyone knows how to get this working on Windows it would be very helpful.

SHUFEN 02-28-2019 02:42

Re: [CS:GO] Uncache all particles for custom maps
 
We fixed this problem for Windows, since 4 years ago.
Concretely, It is able via CParticleSystemDefinition::Uncache and CUtlSymbolTable::RemoveAll.

ClaudiaPastor 02-28-2019 05:17

Re: [CS:GO] Uncache all particles for custom maps
 
Quote:

Originally Posted by gubka (Post 2637408)
at first I tryied to store address of defaultquery which should contain the particle system which precache on the first start, using signature CParticleSystemMgr::Init(PQuery DefaultQuery), but it didn't help, and it more easier to precache throw those file, cause I developed that algo for my zp core, you can do whatever you want with it, but in my option that one of the simplest solution which you can find, because more sigs for me, make some updates for me a bit problematic, cause sometimes I just don't have time to open IDA and to update all sigs back. So good luck. descubre todos los sintomas de embarazo hay muchos.

Thx so much :)

gubka 03-14-2019 07:19

Re: [CS:GO] Uncache all particles for custom maps [NEW]
 
UPDATE*


All times are GMT -4. The time now is 14:54.

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