Migrate extensions to common AMTL string funcs (#785)

This commit is contained in:
Michael Flaherty
2018-03-25 13:00:53 -07:00
committed by Kyle Sanderson
parent 6c7e29cbdb
commit 5611ec54a2
19 changed files with 53 additions and 44 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
if (DBInfo == NULL)
{
snprintf(error, maxlength, "Could not find any suitable database configs");
ke::SafeStrcpy(error, maxlength, "Could not find any suitable database configs");
return false;
}
@@ -81,7 +81,7 @@ bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
if (Driver == NULL)
{
snprintf(error, maxlength, "Could not load DB Driver \"%s\"", DBInfo->driver);
ke::SafeSprintf(error, maxlength, "Could not load DB Driver \"%s\"", DBInfo->driver);
return false;
}
+2 -2
View File
@@ -63,7 +63,7 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
#if SOURCE_ENGINE != SE_CSGO
if (strcmp(g_pSM->GetGameFolderName(), "cstrike") != 0)
{
snprintf(error, maxlength, "Cannot Load Cstrike Extension on mods other than CS:S and CS:GO");
ke::SafeStrcpy(error, maxlength, "Cannot Load Cstrike Extension on mods other than CS:S and CS:GO");
return false;
}
#endif
@@ -76,7 +76,7 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
if (error)
{
snprintf(error, maxlength, "Could not read sm-cstrike.games: %s", conf_error);
ke::SafeSprintf(error, maxlength, "Could not read sm-cstrike.games: %s", conf_error);
}
return false;
}
+2 -2
View File
@@ -357,7 +357,7 @@ ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
{
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
Q_strncpy(tempWeapon, szWeapon, sizeof(tempWeapon));
ke::SafeStrcpy(tempWeapon, sizeof(tempWeapon), szWeapon);
Q_strlower(tempWeapon);
if (strstr(tempWeapon, "weapon_") == NULL && strstr(tempWeapon, "item_") == NULL)
@@ -367,7 +367,7 @@ ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
for (unsigned int i = 0; i < SM_ARRAYSIZE(szClassPrefixs); i++)
{
char classname[MAX_WEAPON_NAME_LENGTH];
Q_snprintf(classname, sizeof(classname), "%s%s", szClassPrefixs[i], tempWeapon);
ke::SafeSprintf(classname, sizeof(classname), "%s%s", szClassPrefixs[i], tempWeapon);
ClassnameMap::Result res = g_mapClassToDefIdx.find(classname);
+2 -1
View File
@@ -32,6 +32,7 @@
#include <sourcemod_version.h>
#include "extension.h"
#include "GeoIP.h"
#include "am-string.h"
/**
* @file extension.cpp
@@ -51,7 +52,7 @@ bool GeoIP_Extension::SDK_OnLoad(char *error, size_t maxlength, bool late)
if (!gi)
{
snprintf(error, maxlength, "Could not load configs/geoip/GeoIP.dat");
ke::SafeStrcpy(error, maxlength, "Could not load configs/geoip/GeoIP.dat");
return false;
}
+2 -1
View File
@@ -32,6 +32,7 @@
#include "MyDriver.h"
#include "MyDatabase.h"
#include "smsdk_ext.h"
#include "am-string.h"
MyDriver g_MyDriver;
@@ -133,7 +134,7 @@ MYSQL *Connect(const DatabaseInfo *info, char *error, size_t maxlength)
M_CLIENT_MULTI_RESULTS))
{
/* :TODO: expose UTIL_Format from smutil! */
snprintf(error, maxlength, "[%d]: %s", mysql_errno(mysql), mysql_error(mysql));
ke::SafeSprintf(error, maxlength, "[%d]: %s", mysql_errno(mysql), mysql_error(mysql));
mysql_close(mysql);
return NULL;
}
+7 -5
View File
@@ -46,6 +46,8 @@
#include "clientnatives.h"
#include "teamnatives.h"
#include "filesystem.h"
#include "am-string.h"
/**
* @file extension.cpp
* @brief Implements SDK Tools extension code.
@@ -128,7 +130,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
g_CallHandle = handlesys->CreateType("ValveCall", this, 0, NULL, NULL, myself->GetIdentity(), &err);
if (g_CallHandle == 0)
{
snprintf(error, maxlength, "Could not create call handle type (err: %d)", err);
ke::SafeSprintf(error, maxlength, "Could not create call handle type (err: %d)", err);
return false;
}
@@ -142,7 +144,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
handlesys->RemoveType(g_CallHandle, myself->GetIdentity());
g_CallHandle = 0;
snprintf(error, maxlength, "Could not create traceray handle type (err: %d)", err);
ke::SafeSprintf(error, maxlength, "Could not create traceray handle type (err: %d)", err);
return false;
}
@@ -385,7 +387,7 @@ bool SDKTools::LevelInit(char const *pMapName, char const *pMapEntities, char co
while (n <= count)
{
snprintf(key, sizeof(key), "SlapSound%d", n);
ke::SafeSprintf(key, sizeof(key), "SlapSound%d", n);
if ((name=g_pGameConf->GetKeyValue(key)))
{
engsound->PrecacheSound(name, true);
@@ -436,7 +438,7 @@ bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
info->num_targets = 1;
info->reason = COMMAND_TARGET_VALID;
info->target_name_style = COMMAND_TARGETNAME_RAW;
snprintf(info->target_name, info->target_name_maxlength, "%s", pTarget->GetName());
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, pTarget->GetName());
return true;
}
else if (strcmp(info->pattern, "@spec") == 0)
@@ -462,7 +464,7 @@ bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
}
info->reason = info->num_targets > 0 ? COMMAND_TARGET_VALID : COMMAND_TARGET_EMPTY_FILTER;
info->target_name_style = COMMAND_TARGETNAME_ML;
snprintf(info->target_name, info->target_name_maxlength, "all spectators");
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, "all spectators");
return true;
}
+2 -1
View File
@@ -31,6 +31,7 @@
#include "extension.h"
#include "output.h"
#include "am-string.h"
ISourcePawnEngine *spengine = NULL;
EntityOutputManager g_OutputManager;
@@ -120,7 +121,7 @@ bool EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator
}
char sOutput[20];
Q_snprintf(sOutput, sizeof(sOutput), "%p", pOutput);
ke::SafeSprintf(sOutput, sizeof(sOutput), "%p", pOutput);
// attempt to directly lookup a hook using the pOutput pointer
OutputNameStruct *pOutputName = NULL;
+2 -1
View File
@@ -40,6 +40,7 @@
#include <inetchannel.h>
#include <iclient.h>
#include "iserver.h"
#include "am-string.h"
SourceHook::List<ValveCall *> g_RegCalls;
SourceHook::List<ICallWrapper *> g_CallWraps;
@@ -623,7 +624,7 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params)
int maxClients = playerhelpers->GetMaxClients();
int r = (rand() % s_sound_count) + 1;
snprintf(name, sizeof(name), "SlapSound%d", r);
ke::SafeSprintf(name, sizeof(name), "SlapSound%d", r);
if ((sound_name = g_pGameConf->GetKeyValue(name)) != NULL)
{