Add CTuningParams::PossibleTunings to find tune params by name

This commit is contained in:
Robert Müller 2022-08-09 17:41:28 +02:00
parent 047c88d797
commit 6af8f46526
2 changed files with 16 additions and 0 deletions

View file

@ -48,6 +48,20 @@ bool CTuningParams::Get(const char *pName, float *pValue) const
return false;
}
int CTuningParams::PossibleTunings(const char *pStr, IConsole::FPossibleCallback pfnCallback, void *pUser)
{
int Index = 0;
for(int i = 0; i < Num(); i++)
{
if(str_find_nocase(Name(i), pStr))
{
pfnCallback(Index, Name(i), pUser);
Index++;
}
}
return Index;
}
float VelocityRamp(float Value, float Start, float Range, float Curvature)
{
if(Value < Start)

View file

@ -10,6 +10,7 @@
#include <set>
#include <vector>
#include <engine/console.h>
#include <engine/shared/protocol.h>
#include <game/generated/protocol.h>
@ -64,6 +65,7 @@ public:
bool Get(int Index, float *pValue) const;
bool Get(const char *pName, float *pValue) const;
static const char *Name(int Index) { return ms_apNames[Index]; }
int PossibleTunings(const char *pStr, IConsole::FPossibleCallback pfnCallback = IConsole::EmptyPossibleCommandCallback, void *pUser = nullptr);
};
inline void StrToInts(int *pInts, int Num, const char *pStr)