mirror of
https://github.com/rehlds/rechecker.git
synced 2025-04-09 09:50:00 +03:00
Added: delay before execute the cmd.
This commit is contained in:
parent
cfb3b69378
commit
edcb803bf2
@ -168,6 +168,7 @@
|
|||||||
<ClInclude Include="..\src\engine_rehlds.h" />
|
<ClInclude Include="..\src\engine_rehlds.h" />
|
||||||
<ClInclude Include="..\src\main.h" />
|
<ClInclude Include="..\src\main.h" />
|
||||||
<ClInclude Include="..\src\precompiled.h" />
|
<ClInclude Include="..\src\precompiled.h" />
|
||||||
|
<ClInclude Include="..\src\task.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\common\parsemsg.cpp">
|
<ClCompile Include="..\common\parsemsg.cpp">
|
||||||
@ -191,6 +192,7 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\sdk_util.cpp" />
|
<ClCompile Include="..\src\sdk_util.cpp" />
|
||||||
|
<ClCompile Include="..\src\task.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\dist\config.ini" />
|
<None Include="..\dist\config.ini" />
|
||||||
|
@ -462,6 +462,7 @@
|
|||||||
<ClInclude Include="..\src\engine_rehlds.h" />
|
<ClInclude Include="..\src\engine_rehlds.h" />
|
||||||
<ClInclude Include="..\src\cmdexec.h" />
|
<ClInclude Include="..\src\cmdexec.h" />
|
||||||
<ClInclude Include="..\src\resource.h" />
|
<ClInclude Include="..\src\resource.h" />
|
||||||
|
<ClInclude Include="..\src\task.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\common\parsemsg.cpp">
|
<ClCompile Include="..\common\parsemsg.cpp">
|
||||||
@ -480,6 +481,7 @@
|
|||||||
<ClCompile Include="..\src\sdk_util.cpp" />
|
<ClCompile Include="..\src\sdk_util.cpp" />
|
||||||
<ClCompile Include="..\src\cmdexec.cpp" />
|
<ClCompile Include="..\src\cmdexec.cpp" />
|
||||||
<ClCompile Include="..\src\resource.cpp" />
|
<ClCompile Include="..\src\resource.cpp" />
|
||||||
|
<ClCompile Include="..\src\task.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="sdk">
|
<Filter Include="sdk">
|
||||||
|
@ -4,7 +4,6 @@ DLL_FUNCTIONS *g_pFunctionTable;
|
|||||||
|
|
||||||
extern void ServerDeactivate_Post();
|
extern void ServerDeactivate_Post();
|
||||||
extern void ClientPutInServer_Post(edict_t *pEntity);
|
extern void ClientPutInServer_Post(edict_t *pEntity);
|
||||||
extern void StartFrame();
|
|
||||||
|
|
||||||
static DLL_FUNCTIONS gFunctionTable =
|
static DLL_FUNCTIONS gFunctionTable =
|
||||||
{
|
{
|
||||||
|
39
src/main.cpp
39
src/main.cpp
@ -99,6 +99,7 @@ void OnMetaDetach()
|
|||||||
|
|
||||||
// clear
|
// clear
|
||||||
Exec.Clear();
|
Exec.Clear();
|
||||||
|
Task.Clear();
|
||||||
Resource.Clear();
|
Resource.Clear();
|
||||||
|
|
||||||
g_RehldsApi->GetHookchains()->SV_DropClient()->unregisterHook(&SV_DropClient);
|
g_RehldsApi->GetHookchains()->SV_DropClient()->unregisterHook(&SV_DropClient);
|
||||||
@ -110,6 +111,7 @@ void ServerDeactivate_Post()
|
|||||||
{
|
{
|
||||||
// clear
|
// clear
|
||||||
Exec.Clear();
|
Exec.Clear();
|
||||||
|
Task.Clear();
|
||||||
Resource.Clear();
|
Resource.Clear();
|
||||||
|
|
||||||
SET_META_RESULT(MRES_IGNORED);
|
SET_META_RESULT(MRES_IGNORED);
|
||||||
@ -120,6 +122,9 @@ void SV_DropClient(IRehldsHook_SV_DropClient *chain, IGameClient *pClient, bool
|
|||||||
// clear buffer cmdexec the client when was disconnected up to perform cmdexec
|
// clear buffer cmdexec the client when was disconnected up to perform cmdexec
|
||||||
Exec.Clear(pClient);
|
Exec.Clear(pClient);
|
||||||
|
|
||||||
|
// to clear the current tasks
|
||||||
|
Task.Clear(pClient);
|
||||||
|
|
||||||
// clear temporary files of response
|
// clear temporary files of response
|
||||||
Resource.Clear(pClient);
|
Resource.Clear(pClient);
|
||||||
|
|
||||||
@ -138,6 +143,18 @@ int SV_TransferConsistencyInfo(IRehldsHook_SV_TransferConsistencyInfo *chain)
|
|||||||
return chain->callNext() + nConsistency;
|
return chain->callNext() + nConsistency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskCommandExecute_Handler(IGameClient *pClient)
|
||||||
|
{
|
||||||
|
if (!pClient->IsConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// client is connected to putinserver, go execute cmd out buffer
|
||||||
|
Exec.CommandExecute(pClient);
|
||||||
|
|
||||||
|
// clear temporary files of response
|
||||||
|
Resource.Clear(pClient);
|
||||||
|
}
|
||||||
|
|
||||||
void ClientPutInServer_Post(edict_t *pEntity)
|
void ClientPutInServer_Post(edict_t *pEntity)
|
||||||
{
|
{
|
||||||
int nIndex = ENTINDEX(pEntity) - 1;
|
int nIndex = ENTINDEX(pEntity) - 1;
|
||||||
@ -147,11 +164,19 @@ void ClientPutInServer_Post(edict_t *pEntity)
|
|||||||
|
|
||||||
IGameClient *pClient = g_RehldsApi->GetServerStatic()->GetClient(nIndex);
|
IGameClient *pClient = g_RehldsApi->GetServerStatic()->GetClient(nIndex);
|
||||||
|
|
||||||
// client is connected to putinserver, go execute cmd out buffer
|
if (pcv_rch_delay->value == 0.0f)
|
||||||
Exec.CommandExecute(pClient);
|
{
|
||||||
|
// client is connected to putinserver, go execute cmd out buffer
|
||||||
|
Exec.CommandExecute(pClient);
|
||||||
|
|
||||||
// clear temporary files of response
|
// clear temporary files of response
|
||||||
Resource.Clear(pClient);
|
Resource.Clear(pClient);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// hold to execute cmd
|
||||||
|
Task.AddTask(pClient, pcv_rch_delay->value, (xtask_t)TaskCommandExecute_Handler);
|
||||||
|
}
|
||||||
|
|
||||||
SET_META_RESULT(MRES_IGNORED);
|
SET_META_RESULT(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
@ -164,3 +189,9 @@ bool SV_CheckConsistencyResponse(IRehldsHook_SV_CheckConsistencyResponse *chain,
|
|||||||
// call next hook and take return of values from original func
|
// call next hook and take return of values from original func
|
||||||
return chain->callNext(pSenderClient, resource, hash);
|
return chain->callNext(pSenderClient, resource, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StartFrame()
|
||||||
|
{
|
||||||
|
Task.StartFrame();
|
||||||
|
SET_META_RESULT(MRES_IGNORED);
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ plugin_info_t Plugin_info =
|
|||||||
{
|
{
|
||||||
META_INTERFACE_VERSION,
|
META_INTERFACE_VERSION,
|
||||||
"Rechecker",
|
"Rechecker",
|
||||||
"1.3",
|
"1.6",
|
||||||
__DATE__,
|
__DATE__,
|
||||||
"s1lent",
|
"s1lent",
|
||||||
"http://www.dedicated-server.ru/",
|
"http://www.dedicated-server.ru/",
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "consistency.h"
|
#include "consistency.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
//#include "task.h"
|
#include "task.h"
|
||||||
//#include "config.h"
|
//#include "config.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "cmdexec.h"
|
#include "cmdexec.h"
|
||||||
|
@ -4,7 +4,10 @@ CResourceFile Resource;
|
|||||||
std::vector<const char *> StringsCache;
|
std::vector<const char *> StringsCache;
|
||||||
|
|
||||||
cvar_t cv_rch_log = { "rch_log", "0", 0, 0.0f, NULL };
|
cvar_t cv_rch_log = { "rch_log", "0", 0, 0.0f, NULL };
|
||||||
|
cvar_t cv_rch_delay = { "rch_delay", "0", 0, 0.0f, NULL };
|
||||||
|
|
||||||
cvar_t *pcv_rch_log = NULL;
|
cvar_t *pcv_rch_log = NULL;
|
||||||
|
cvar_t *pcv_rch_delay = NULL;
|
||||||
|
|
||||||
int CResourceFile::CreateResourceList()
|
int CResourceFile::CreateResourceList()
|
||||||
{
|
{
|
||||||
@ -17,7 +20,7 @@ int CResourceFile::CreateResourceList()
|
|||||||
|
|
||||||
// prevent duplicate of filenames
|
// prevent duplicate of filenames
|
||||||
// check if filename is been marked so do not add the resource again
|
// check if filename is been marked so do not add the resource again
|
||||||
if (!pRes->IsDuplicate())
|
if (!pRes->IsDuplicate() && !SV_FileInConsistencyList(pRes->GetFileName(), NULL))
|
||||||
{
|
{
|
||||||
// check limit resource
|
// check limit resource
|
||||||
if (g_RehldsServerData->GetResourcesNum() >= MAX_RESOURCE_LIST)
|
if (g_RehldsServerData->GetResourcesNum() >= MAX_RESOURCE_LIST)
|
||||||
@ -213,7 +216,10 @@ void CResourceFile::Init()
|
|||||||
snprintf(m_PathDir, sizeof(m_PathDir), "%s" FILE_INI_RESOURCES, path);
|
snprintf(m_PathDir, sizeof(m_PathDir), "%s" FILE_INI_RESOURCES, path);
|
||||||
|
|
||||||
g_engfuncs.pfnCvar_RegisterVariable(&cv_rch_log);
|
g_engfuncs.pfnCvar_RegisterVariable(&cv_rch_log);
|
||||||
|
g_engfuncs.pfnCvar_RegisterVariable(&cv_rch_delay);
|
||||||
|
|
||||||
pcv_rch_log = g_engfuncs.pfnCVarGetPointer(cv_rch_log.name);
|
pcv_rch_log = g_engfuncs.pfnCVarGetPointer(cv_rch_log.name);
|
||||||
|
pcv_rch_delay = g_engfuncs.pfnCVarGetPointer(cv_rch_delay.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8 hexbyte(uint8 *hex)
|
inline uint8 hexbyte(uint8 *hex)
|
||||||
@ -408,8 +414,8 @@ void CResourceFile::LoadResources()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOG_PRINT_FAILED(str, argv)\
|
#define LOG_PRINT_FAILED(str, ...)\
|
||||||
UTIL_Printf(__FUNCTION__ ": Failed to load \"" FILE_INI_RESOURCES "\"; " str, argv);\
|
UTIL_Printf(__FUNCTION__ ": Failed to load \"" FILE_INI_RESOURCES "\"; " str, __VA_ARGS__);\
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (argc >= MAX_PARSE_ARGUMENT)
|
if (argc >= MAX_PARSE_ARGUMENT)
|
||||||
@ -425,7 +431,7 @@ void CResourceFile::LoadResources()
|
|||||||
}
|
}
|
||||||
else if (!IsValidFilename(filename, pchar))
|
else if (!IsValidFilename(filename, pchar))
|
||||||
{
|
{
|
||||||
LOG_PRINT_FAILED("filename has invalid character '%c' on line %d\n", (pchar, cline));
|
LOG_PRINT_FAILED("filename has invalid character '%c' on line %d\n", pchar, cline);
|
||||||
}
|
}
|
||||||
else if (flag == FLAG_TYPE_NONE)
|
else if (flag == FLAG_TYPE_NONE)
|
||||||
{
|
{
|
||||||
@ -440,7 +446,7 @@ void CResourceFile::LoadResources()
|
|||||||
}
|
}
|
||||||
else if (pToken != NULL || argc > ARG_TYPE_FILE_NAME)
|
else if (pToken != NULL || argc > ARG_TYPE_FILE_NAME)
|
||||||
{
|
{
|
||||||
LOG_PRINT_FAILED("parsing not enough arguments on line %d (got '%d', expected '%d')\n", (cline, argc, MAX_PARSE_ARGUMENT));
|
LOG_PRINT_FAILED("parsing not enough arguments on line %d (got '%d', expected '%d')\n", cline, argc, MAX_PARSE_ARGUMENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,8 +619,9 @@ bool CResourceFile::FileConsistencyResponse(IGameClient *pSenderClient, resource
|
|||||||
// push exec cmd
|
// push exec cmd
|
||||||
Exec.AddElement(pSenderClient, pRes, hash);
|
Exec.AddElement(pSenderClient, pRes, hash);
|
||||||
|
|
||||||
Log(" -> file: (%s), exphash: (%x), got: (%x), typeFind: (%d), prevhash: (%x), (%s), prevfile: (%s), findathash: (%s), md5hex: (%x)",
|
static const char *szTypeNames[] = { "none", "exists", "missing", "ignore", "hash_any" };
|
||||||
pRes->GetFileName(), pRes->GetFileHash(), hash, typeFind, m_PrevHash, pSenderClient->GetName(),
|
Log(" -> file: (%s), exphash: (%x), got: (%x), typeFind: (%s), prevhash: (%x), (%s), prevfile: (%s), findathash: (%s), md5hex: (%x)",
|
||||||
|
pRes->GetFileName(), pRes->GetFileHash(), hash, szTypeNames[typeFind], m_PrevHash, pSenderClient->GetName(),
|
||||||
FindFilenameOfHash(m_PrevHash), FindFilenameOfHash(hash), _byteswap_ulong(hash));
|
FindFilenameOfHash(m_PrevHash), FindFilenameOfHash(hash), _byteswap_ulong(hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,4 +110,7 @@ private:
|
|||||||
|
|
||||||
extern CResourceFile Resource;
|
extern CResourceFile Resource;
|
||||||
|
|
||||||
|
extern cvar_t *pcv_rch_log;
|
||||||
|
extern cvar_t *pcv_rch_delay;
|
||||||
|
|
||||||
void ClearStringsCache();
|
void ClearStringsCache();
|
||||||
|
@ -53,7 +53,7 @@ void CTaskMngr::Clear(IGameClient *pClient)
|
|||||||
{
|
{
|
||||||
if (pClient == NULL)
|
if (pClient == NULL)
|
||||||
{
|
{
|
||||||
// reset next frame
|
// reset next frame on level change
|
||||||
m_nextFrame = 0;
|
m_nextFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define TASK_FREQUENCY_TIME 1.0f // check frequency current tasks
|
#define TASK_FREQUENCY_TIME 0.1f // check frequency current tasks
|
||||||
|
|
||||||
typedef void (*xtask_t)(IGameClient *);
|
typedef void (*xtask_t)(IGameClient *);
|
||||||
|
|
||||||
@ -34,3 +34,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern CTaskMngr Task;
|
extern CTaskMngr Task;
|
||||||
|
extern DLL_FUNCTIONS *g_pFunctionTable;
|
||||||
|
|
||||||
|
extern void StartFrame();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user