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
+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)
{