mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
* All libraries have been isolated from each other, and build into separate artifacts. * Project has been restructured to support isolating libraries. * CCrashHandler now calls a callback on crash (setup from core/dllmain.cpp, this can be setup in any way for any project. This callback is getting called when the apllication crashes. Useful for flushing buffers before closing handles to logging files for example). * Tier0 'CoreMsgV' function now calls a callback sink, which could be set by the user (currently setup to the SDK's internal logger in core/dllmain.cpp). TODO: * Add a batch file to autogenerate all projects. * Add support for dedicated server. * Add support for client dll. Bugs: * Game crashes on the title screen after the UI script compiler has finished (root cause unknown). * Curl error messages are getting logged twice for the dedicated server due to the removal of all "DEDICATED" preprocessor directives to support isolating projects. This has to be fixed properly!
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
#include "core/stdafx.h"
|
|
#include "tier1/cmd.h"
|
|
#include "tier1/cvar.h"
|
|
#include "engine/cmd.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Returns current player calling this function
|
|
// Output : ECommandTarget_t -
|
|
//-----------------------------------------------------------------------------
|
|
ECommandTarget_t Cbuf_GetCurrentPlayer(void)
|
|
{
|
|
// Always returns 'CBUF_FIRST_PLAYER' in Respawn's code.
|
|
return ECommandTarget_t::CBUF_FIRST_PLAYER;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Sends the entire command line over to the server
|
|
// Input : *args -
|
|
// Output : true on success, false otherwise
|
|
//-----------------------------------------------------------------------------
|
|
bool Cmd_ForwardToServer(const CCommand* args)
|
|
{
|
|
#ifndef DEDICATED
|
|
// Client -> Server command throttling.
|
|
static double flForwardedCommandQuotaStartTime = -1;
|
|
static int nForwardedCommandQuotaCount = 0;
|
|
|
|
// No command to forward.
|
|
if (args->ArgC() == 0)
|
|
return false;
|
|
|
|
double flStartTime = Plat_FloatTime();
|
|
int nCmdQuotaLimit = cl_quota_stringCmdsPerSecond->GetInt();
|
|
const char* pszCmdString = nullptr;
|
|
|
|
// Special case: "cmd whatever args..." is forwarded as "whatever args...";
|
|
// in this case we strip "cmd" from the input.
|
|
if (Q_strcasecmp(args->Arg(0), "cmd") == 0)
|
|
pszCmdString = args->ArgS();
|
|
else
|
|
pszCmdString = args->GetCommandString();
|
|
|
|
if (nCmdQuotaLimit)
|
|
{
|
|
if (flStartTime - flForwardedCommandQuotaStartTime >= 1.0)
|
|
{
|
|
flForwardedCommandQuotaStartTime = flStartTime;
|
|
nForwardedCommandQuotaCount = 0;
|
|
}
|
|
++nForwardedCommandQuotaCount;
|
|
|
|
if (nForwardedCommandQuotaCount > nCmdQuotaLimit)
|
|
{
|
|
// If we are over quota commands per second, dump this on the floor.
|
|
// If we spam the server with too many commands, it will kick us.
|
|
Warning(eDLL_T::CLIENT, "Command '%s' ignored (submission quota of '%d' per second exceeded!)\n", pszCmdString, nCmdQuotaLimit);
|
|
return false;
|
|
}
|
|
}
|
|
return v_Cmd_ForwardToServer(args);
|
|
#else // !DEDICATED
|
|
return false; // Client only.
|
|
#endif // DEDICATED
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void VCmd::Attach() const
|
|
{
|
|
DetourAttach((LPVOID*)&v_Cmd_ForwardToServer, &Cmd_ForwardToServer);
|
|
}
|
|
void VCmd::Detach() const
|
|
{
|
|
DetourDetach((LPVOID*)&v_Cmd_ForwardToServer, &Cmd_ForwardToServer);
|
|
}
|