Skip to content

Commit

Permalink
Fixed crash issues on startup
Browse files Browse the repository at this point in the history
Fixed crash issues on startup
  • Loading branch information
SmileYzn committed Sep 17, 2024
1 parent 9572b4d commit f332c8d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
8 changes: 4 additions & 4 deletions AccuracyFix/AccuracyFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
CAccuracyFix gAccuracyFix;

void CAccuracyFix::ServerActivate()
{
{
this->m_af_accuracy_all = gAccuracyUtil.CvarRegister("af_accuracy_all", "-1.0");

this->m_af_distance_all = gAccuracyUtil.CvarRegister("af_distance_all", "-1.0");

this->m_af_jump_fix = gAccuracyUtil.CvarRegister("af_jump_fix", "0");
this->m_af_jump_fix = gAccuracyUtil.CvarRegister("af_jump_fix", "0.0");

/*if (g_ReGameApi)
if (g_ReGameApi)
{
char cvarName[32] = { 0 };

Expand Down Expand Up @@ -48,7 +48,7 @@ void CAccuracyFix::ServerActivate()
{
gAccuracyUtil.ServerCommand("exec %s/accuracyfix.cfg", Path);
}
}*/
}
}

void CAccuracyFix::TraceLine(const float* vStart, const float* vEnd, int fNoMonsters, edict_t* pentToSkip, TraceResult* ptr)
Expand Down
1 change: 0 additions & 1 deletion AccuracyFix/AccuracyFix.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class CAccuracyFix
void ServerActivate();
void TraceLine(const float* vStart, const float* vEnd, int fNoMonsters, edict_t* pentToSkip, TraceResult* ptr);

private:
cvar_t* m_af_distance_all;
cvar_t* m_af_distance[MAX_WEAPONS + 1];
cvar_t* m_af_accuracy_all;
Expand Down
27 changes: 13 additions & 14 deletions AccuracyFix/AccuracyUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,28 @@ CAccuracyUtil gAccuracyUtil;

cvar_t* CAccuracyUtil::CvarRegister(const char* Name, const char* Value)
{
cvar_t* pCvar = g_engfuncs.pfnCVarGetPointer(Name);
cvar_t* Pointer = g_engfuncs.pfnCVarGetPointer(Name);

if (!pCvar)
if (!Pointer)
{
this->m_CvarData[Name].name = Name;
static cvar_t CvarData;

CvarData = { Name, (char*)(Value), FCVAR_SERVER | FCVAR_SPONLY, 0.0f, NULL };

this->m_CvarData[Name].string = (char*)(Value);
g_engfuncs.pfnCVarRegister(&CvarData);

Pointer = g_engfuncs.pfnCVarGetPointer(Name);

this->m_CvarData[Name].flags = (FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED);

g_engfuncs.pfnCVarRegister(&this->m_CvarData[Name]);

pCvar = g_engfuncs.pfnCVarGetPointer(this->m_CvarData[Name].name);

if (pCvar)
if(Pointer)
{
g_engfuncs.pfnCvar_DirectSet(pCvar, Value);
g_engfuncs.pfnCvar_DirectSet(Pointer, Value);
}
}

return pCvar;
return Pointer;
}


const char* CAccuracyUtil::GetPath()
{
if (this->m_Path.empty())
Expand Down Expand Up @@ -68,7 +67,7 @@ void CAccuracyUtil::ServerCommand(const char* Format, ...)

va_end(argptr);

Q_strncat(Command, "\n", 1);
Q_strncat(Command, "\n", sizeof(Command) - 1);

g_engfuncs.pfnServerCommand(Command);
}
Expand Down
6 changes: 2 additions & 4 deletions AccuracyFix/AccuracyUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ class CAccuracyUtil
void ServerCommand(const char* Format, ...);
const char* GetPath();
TraceResult GetUserAiming(edict_t* pEntity, float DistanceLimit);

private:
std::map<std::string, cvar_t> m_CvarData;

std::string m_Path;
};

extern CAccuracyUtil gAccuracyUtil;
extern CAccuracyUtil gAccuracyUtil;
2 changes: 1 addition & 1 deletion AccuracyFix/precompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// If is not MSVC build
#ifndef _WIN32
#define _GLIBCXX_USE_CXX11_ABI 0
#define _GLIBCXX_USE_CXX11_ABI 0
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
#define _strdup strdup
Expand Down

0 comments on commit f332c8d

Please sign in to comment.