Merge branch 'master' of https://github.com/alliedmodders/sourcemod
This commit is contained in:
commit
b0e7bab980
@ -2050,18 +2050,18 @@ void CPlayer::UpdateAuthIds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
char szAuthBuffer[64];
|
char szAuthBuffer[64];
|
||||||
snprintf(szAuthBuffer, sizeof(szAuthBuffer), "STEAM_%u:%u:%u", steam2universe, m_SteamId.GetAccountID() & 1, m_SteamId.GetAccountID() >> 1);
|
ke::SafeSprintf(szAuthBuffer, sizeof(szAuthBuffer), "STEAM_%u:%u:%u", steam2universe, m_SteamId.GetAccountID() & 1, m_SteamId.GetAccountID() >> 1);
|
||||||
|
|
||||||
m_Steam2Id = szAuthBuffer;
|
m_Steam2Id = szAuthBuffer;
|
||||||
|
|
||||||
// TODO: make sure all hl2sdks' steamclientpublic.h have k_unSteamUserDesktopInstance.
|
// TODO: make sure all hl2sdks' steamclientpublic.h have k_unSteamUserDesktopInstance.
|
||||||
if (m_SteamId.GetUnAccountInstance() == 1 /* k_unSteamUserDesktopInstance */)
|
if (m_SteamId.GetUnAccountInstance() == 1 /* k_unSteamUserDesktopInstance */)
|
||||||
{
|
{
|
||||||
snprintf(szAuthBuffer, sizeof(szAuthBuffer), "[U:%u:%u]", m_SteamId.GetEUniverse(), m_SteamId.GetAccountID());
|
ke::SafeSprintf(szAuthBuffer, sizeof(szAuthBuffer), "[U:%u:%u]", m_SteamId.GetEUniverse(), m_SteamId.GetAccountID());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(szAuthBuffer, sizeof(szAuthBuffer), "[U:%u:%u:%u]", m_SteamId.GetEUniverse(), m_SteamId.GetAccountID(), m_SteamId.GetUnAccountInstance());
|
ke::SafeSprintf(szAuthBuffer, sizeof(szAuthBuffer), "[U:%u:%u:%u]", m_SteamId.GetEUniverse(), m_SteamId.GetAccountID(), m_SteamId.GetUnAccountInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Steam3Id = szAuthBuffer;
|
m_Steam3Id = szAuthBuffer;
|
||||||
|
@ -1090,14 +1090,14 @@ bool AdminCache::GetUnifiedSteamIdentity(const char *ident, char *out, size_t ma
|
|||||||
else if (len >= 11 && !strncmp(ident, "STEAM_", 6) && ident[8] != '_')
|
else if (len >= 11 && !strncmp(ident, "STEAM_", 6) && ident[8] != '_')
|
||||||
{
|
{
|
||||||
// non-bot/lan Steam2 Id, strip off the STEAM_* part
|
// non-bot/lan Steam2 Id, strip off the STEAM_* part
|
||||||
snprintf(out, maxlen, "%s", &ident[8]);
|
ke::SafeStrcpy(out, maxlen, &ident[8]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (len >= 7 && !strncmp(ident, "[U:", 3) && ident[len-1] == ']')
|
else if (len >= 7 && !strncmp(ident, "[U:", 3) && ident[len-1] == ']')
|
||||||
{
|
{
|
||||||
// Steam3 Id, replicate the Steam2 Post-"STEAM_" part
|
// Steam3 Id, replicate the Steam2 Post-"STEAM_" part
|
||||||
uint32_t accountId = strtoul(&ident[5], nullptr, 10);
|
uint32_t accountId = strtoul(&ident[5], nullptr, 10);
|
||||||
snprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
ke::SafeSprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1124,7 +1124,7 @@ bool AdminCache::GetUnifiedSteamIdentity(const char *ident, char *out, size_t ma
|
|||||||
&& accountType == k_EAccountTypeIndividual && accountInstance <= k_unSteamUserWebInstance
|
&& accountType == k_EAccountTypeIndividual && accountInstance <= k_unSteamUserWebInstance
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
snprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
ke::SafeSprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ bool CLocalExtension::Load(char *error, size_t maxlength)
|
|||||||
{
|
{
|
||||||
m_pLib->CloseLibrary();
|
m_pLib->CloseLibrary();
|
||||||
m_pLib = NULL;
|
m_pLib = NULL;
|
||||||
snprintf(error, maxlength, "Unable to find extension entry point");
|
ke::SafeStrcpy(error, maxlength, "Unable to find extension entry point");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ void CLocalExtension::Unload()
|
|||||||
|
|
||||||
bool CRemoteExtension::Reload(char *error, size_t maxlength)
|
bool CRemoteExtension::Reload(char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Remote extensions do not support reloading");
|
ke::SafeStrcpy(error, maxlength, "Remote extensions do not support reloading");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,13 +280,13 @@ bool CExtension::PerformAPICheck(char *error, size_t maxlength)
|
|||||||
{
|
{
|
||||||
if (!m_pAPI)
|
if (!m_pAPI)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "No IExtensionInterface instance provided");
|
ke::SafeStrcpy(error, maxlength, "No IExtensionInterface instance provided");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pAPI->GetExtensionVersion() > SMINTERFACE_EXTENSIONAPI_VERSION)
|
if (m_pAPI->GetExtensionVersion() > SMINTERFACE_EXTENSIONAPI_VERSION)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
|
ke::SafeSprintf(error, maxlength, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ bool CExtension::IsRunning(char *error, size_t maxlength)
|
|||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "%s", m_Error.c_str());
|
ke::SafeStrcpy(error, maxlength, m_Error.c_str());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1136,7 +1136,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
|||||||
if (pExt->unload_code == (unsigned)atoi(unload))
|
if (pExt->unload_code == (unsigned)atoi(unload))
|
||||||
{
|
{
|
||||||
char filename[PLATFORM_MAX_PATH];
|
char filename[PLATFORM_MAX_PATH];
|
||||||
snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
|
ke::SafeStrcpy(filename, PLATFORM_MAX_PATH, pExt->GetFilename());
|
||||||
UnloadExtension(pExt);
|
UnloadExtension(pExt);
|
||||||
rootmenu->ConsolePrint("[SM] Extension %s is now unloaded.", filename);
|
rootmenu->ConsolePrint("[SM] Extension %s is now unloaded.", filename);
|
||||||
}
|
}
|
||||||
@ -1151,7 +1151,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
|||||||
|| (!pExt->m_ChildDeps.size() && !pExt->m_Dependents.size()))
|
|| (!pExt->m_ChildDeps.size() && !pExt->m_Dependents.size()))
|
||||||
{
|
{
|
||||||
char filename[PLATFORM_MAX_PATH];
|
char filename[PLATFORM_MAX_PATH];
|
||||||
snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
|
ke::SafeStrcpy(filename, PLATFORM_MAX_PATH, pExt->GetFilename());
|
||||||
UnloadExtension(pExt);
|
UnloadExtension(pExt);
|
||||||
rootmenu->ConsolePrint("[SM] Extension %s is now unloaded.", filename);
|
rootmenu->ConsolePrint("[SM] Extension %s is now unloaded.", filename);
|
||||||
return;
|
return;
|
||||||
@ -1252,7 +1252,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
|||||||
char filename[PLATFORM_MAX_PATH];
|
char filename[PLATFORM_MAX_PATH];
|
||||||
char error[255];
|
char error[255];
|
||||||
|
|
||||||
snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
|
ke::SafeStrcpy(filename, PLATFORM_MAX_PATH, pExt->GetFilename());
|
||||||
|
|
||||||
if (pExt->Reload(error, sizeof(error)))
|
if (pExt->Reload(error, sizeof(error)))
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,7 @@ CDirectory::CDirectory(const char *path)
|
|||||||
{
|
{
|
||||||
#if defined PLATFORM_WINDOWS
|
#if defined PLATFORM_WINDOWS
|
||||||
char newpath[PLATFORM_MAX_PATH];
|
char newpath[PLATFORM_MAX_PATH];
|
||||||
snprintf(newpath, sizeof(newpath), "%s\\*.*", path);
|
ke::SafeSprintf(newpath, sizeof(newpath), "%s\\*.*", path);
|
||||||
m_dir = FindFirstFileA(newpath, &m_fd);
|
m_dir = FindFirstFileA(newpath, &m_fd);
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ CDirectory::CDirectory(const char *path)
|
|||||||
{
|
{
|
||||||
/* :TODO: we need to read past "." and ".."! */
|
/* :TODO: we need to read past "." and ".."! */
|
||||||
ep = readdir(m_dir);
|
ep = readdir(m_dir);
|
||||||
snprintf(m_origpath, PLATFORM_MAX_PATH, "%s", path);
|
ke::SafeStrcpy(m_origpath, PLATFORM_MAX_PATH, path);
|
||||||
} else {
|
} else {
|
||||||
ep = NULL;
|
ep = NULL;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ bool CDirectory::IsEntryDirectory()
|
|||||||
return ((m_fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
|
return ((m_fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
|
||||||
#elif defined PLATFORM_POSIX
|
#elif defined PLATFORM_POSIX
|
||||||
char temppath[PLATFORM_MAX_PATH];
|
char temppath[PLATFORM_MAX_PATH];
|
||||||
int ret = snprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
int ret = ke::SafeSprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
||||||
if (static_cast<size_t>(ret) >= sizeof(temppath))
|
if (static_cast<size_t>(ret) >= sizeof(temppath))
|
||||||
return false;
|
return false;
|
||||||
return ke::file::IsDirectory(temppath);
|
return ke::file::IsDirectory(temppath);
|
||||||
@ -138,7 +138,7 @@ bool CDirectory::IsEntryFile()
|
|||||||
return !(m_fd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE));
|
return !(m_fd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE));
|
||||||
#elif defined PLATFORM_POSIX
|
#elif defined PLATFORM_POSIX
|
||||||
char temppath[PLATFORM_MAX_PATH];
|
char temppath[PLATFORM_MAX_PATH];
|
||||||
int ret = snprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
int ret = ke::SafeSprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
||||||
if (static_cast<size_t>(ret) >= sizeof(temppath))
|
if (static_cast<size_t>(ret) >= sizeof(temppath))
|
||||||
return false;
|
return false;
|
||||||
return ke::file::IsFile(temppath);
|
return ke::file::IsFile(temppath);
|
||||||
|
@ -166,7 +166,7 @@ void RootConsoleMenu::DrawGenericOption(const char *cmd, const char *text)
|
|||||||
{
|
{
|
||||||
buffer[len++] = ' ';
|
buffer[len++] = ' ';
|
||||||
}
|
}
|
||||||
len += snprintf(&buffer[len], sizeof(buffer) - len, " - %s", text);
|
len += ke::SafeSprintf(&buffer[len], sizeof(buffer) - len, " - %s", text);
|
||||||
ConsolePrint("%s", buffer);
|
ConsolePrint("%s", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ static cell_t sm_OpenDirectory(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
size_t len = strlen(path);
|
size_t len = strlen(path);
|
||||||
char wildcardedPath[PLATFORM_MAX_PATH];
|
char wildcardedPath[PLATFORM_MAX_PATH];
|
||||||
snprintf(wildcardedPath, sizeof(wildcardedPath), "%s%s*", path, (path[len-1] != '/' && path[len-1] != '\\') ? "/" : "");
|
ke::SafeSprintf(wildcardedPath, sizeof(wildcardedPath), "%s%s*", path, (path[len-1] != '/' && path[len-1] != '\\') ? "/" : "");
|
||||||
|
|
||||||
char *pathID;
|
char *pathID;
|
||||||
if ((err=pContext->LocalToStringNULL(params[3], &pathID)) != SP_ERROR_NONE)
|
if ((err=pContext->LocalToStringNULL(params[3], &pathID)) != SP_ERROR_NONE)
|
||||||
|
@ -397,7 +397,7 @@ static cell_t SteamIdToLocal(IPluginContext *pCtx, int index, AuthIdType authTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
char szAuth[64];
|
char szAuth[64];
|
||||||
snprintf(szAuth, sizeof(szAuth), "%" PRIu64, steamId);
|
ke::SafeSprintf(szAuth, sizeof(szAuth), "%" PRIu64, steamId);
|
||||||
|
|
||||||
pCtx->StringToLocal(local_addr, bytes, szAuth);
|
pCtx->StringToLocal(local_addr, bytes, szAuth);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen
|
|||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
|
ke::SafeSprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
|
|
||||||
if (DBInfo == NULL)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
|
|
||||||
if (Driver == NULL)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
#if SOURCE_ENGINE != SE_CSGO
|
#if SOURCE_ENGINE != SE_CSGO
|
||||||
if (strcmp(g_pSM->GetGameFolderName(), "cstrike") != 0)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -76,7 +76,7 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
{
|
{
|
||||||
if (error)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
|
|||||||
{
|
{
|
||||||
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
|
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
|
||||||
|
|
||||||
Q_strncpy(tempWeapon, szWeapon, sizeof(tempWeapon));
|
ke::SafeStrcpy(tempWeapon, sizeof(tempWeapon), szWeapon);
|
||||||
Q_strlower(tempWeapon);
|
Q_strlower(tempWeapon);
|
||||||
|
|
||||||
if (strstr(tempWeapon, "weapon_") == NULL && strstr(tempWeapon, "item_") == NULL)
|
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++)
|
for (unsigned int i = 0; i < SM_ARRAYSIZE(szClassPrefixs); i++)
|
||||||
{
|
{
|
||||||
char classname[MAX_WEAPON_NAME_LENGTH];
|
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);
|
ClassnameMap::Result res = g_mapClassToDefIdx.find(classname);
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <sourcemod_version.h>
|
#include <sourcemod_version.h>
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "GeoIP.h"
|
#include "GeoIP.h"
|
||||||
|
#include "am-string.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file extension.cpp
|
* @file extension.cpp
|
||||||
@ -51,7 +52,7 @@ bool GeoIP_Extension::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
|
|
||||||
if (!gi)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "MyDriver.h"
|
#include "MyDriver.h"
|
||||||
#include "MyDatabase.h"
|
#include "MyDatabase.h"
|
||||||
#include "smsdk_ext.h"
|
#include "smsdk_ext.h"
|
||||||
|
#include "am-string.h"
|
||||||
|
|
||||||
MyDriver g_MyDriver;
|
MyDriver g_MyDriver;
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ MYSQL *Connect(const DatabaseInfo *info, char *error, size_t maxlength)
|
|||||||
M_CLIENT_MULTI_RESULTS))
|
M_CLIENT_MULTI_RESULTS))
|
||||||
{
|
{
|
||||||
/* :TODO: expose UTIL_Format from smutil! */
|
/* :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);
|
mysql_close(mysql);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
#include "clientnatives.h"
|
#include "clientnatives.h"
|
||||||
#include "teamnatives.h"
|
#include "teamnatives.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
#include "am-string.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file extension.cpp
|
* @file extension.cpp
|
||||||
* @brief Implements SDK Tools extension code.
|
* @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);
|
g_CallHandle = handlesys->CreateType("ValveCall", this, 0, NULL, NULL, myself->GetIdentity(), &err);
|
||||||
if (g_CallHandle == 0)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +144,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
{
|
{
|
||||||
handlesys->RemoveType(g_CallHandle, myself->GetIdentity());
|
handlesys->RemoveType(g_CallHandle, myself->GetIdentity());
|
||||||
g_CallHandle = 0;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +387,7 @@ bool SDKTools::LevelInit(char const *pMapName, char const *pMapEntities, char co
|
|||||||
|
|
||||||
while (n <= count)
|
while (n <= count)
|
||||||
{
|
{
|
||||||
snprintf(key, sizeof(key), "SlapSound%d", n);
|
ke::SafeSprintf(key, sizeof(key), "SlapSound%d", n);
|
||||||
if ((name=g_pGameConf->GetKeyValue(key)))
|
if ((name=g_pGameConf->GetKeyValue(key)))
|
||||||
{
|
{
|
||||||
engsound->PrecacheSound(name, true);
|
engsound->PrecacheSound(name, true);
|
||||||
@ -436,7 +438,7 @@ bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
|
|||||||
info->num_targets = 1;
|
info->num_targets = 1;
|
||||||
info->reason = COMMAND_TARGET_VALID;
|
info->reason = COMMAND_TARGET_VALID;
|
||||||
info->target_name_style = COMMAND_TARGETNAME_RAW;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else if (strcmp(info->pattern, "@spec") == 0)
|
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->reason = info->num_targets > 0 ? COMMAND_TARGET_VALID : COMMAND_TARGET_EMPTY_FILTER;
|
||||||
info->target_name_style = COMMAND_TARGETNAME_ML;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
#include "am-string.h"
|
||||||
|
|
||||||
ISourcePawnEngine *spengine = NULL;
|
ISourcePawnEngine *spengine = NULL;
|
||||||
EntityOutputManager g_OutputManager;
|
EntityOutputManager g_OutputManager;
|
||||||
@ -120,7 +121,7 @@ bool EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator
|
|||||||
}
|
}
|
||||||
|
|
||||||
char sOutput[20];
|
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
|
// attempt to directly lookup a hook using the pOutput pointer
|
||||||
OutputNameStruct *pOutputName = NULL;
|
OutputNameStruct *pOutputName = NULL;
|
||||||
|
@ -462,7 +462,7 @@ static cell_t smn_TESend(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||||
} else if (!pPlayer->IsInGame()) {
|
} else if (!pPlayer->IsInGame()) {
|
||||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <inetchannel.h>
|
#include <inetchannel.h>
|
||||||
#include <iclient.h>
|
#include <iclient.h>
|
||||||
#include "iserver.h"
|
#include "iserver.h"
|
||||||
|
#include "am-string.h"
|
||||||
|
|
||||||
SourceHook::List<ValveCall *> g_RegCalls;
|
SourceHook::List<ValveCall *> g_RegCalls;
|
||||||
SourceHook::List<ICallWrapper *> g_CallWraps;
|
SourceHook::List<ICallWrapper *> g_CallWraps;
|
||||||
@ -623,7 +624,7 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params)
|
|||||||
int maxClients = playerhelpers->GetMaxClients();
|
int maxClients = playerhelpers->GetMaxClients();
|
||||||
|
|
||||||
int r = (rand() % s_sound_count) + 1;
|
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)
|
if ((sound_name = g_pGameConf->GetKeyValue(name)) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -390,7 +390,7 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann
|
|||||||
{
|
{
|
||||||
pFunc->GetParentContext()->BlamePluginError(pFunc, "Callback-provided client index %d is invalid", client);
|
pFunc->GetParentContext()->BlamePluginError(pFunc, "Callback-provided client index %d is invalid", client);
|
||||||
} else if (!pPlayer->IsInGame()) {
|
} else if (!pPlayer->IsInGame()) {
|
||||||
pFunc->GetParentContext()->BlamePluginError(pFunc, "Client %d is not connected", client);
|
pFunc->GetParentContext()->BlamePluginError(pFunc, "Client %d is not in game", client);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan
|
|||||||
{
|
{
|
||||||
pFunc->GetParentContext()->BlamePluginError(pFunc, "Client index %d is invalid", client);
|
pFunc->GetParentContext()->BlamePluginError(pFunc, "Client index %d is invalid", client);
|
||||||
} else if (!pPlayer->IsInGame()) {
|
} else if (!pPlayer->IsInGame()) {
|
||||||
pFunc->GetParentContext()->BlamePluginError(pFunc, "Client %d is not connected", client);
|
pFunc->GetParentContext()->BlamePluginError(pFunc, "Client %d is not in game", client);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -780,7 +780,7 @@ static cell_t EmitSound(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||||
} else if (!pPlayer->IsInGame()) {
|
} else if (!pPlayer->IsInGame()) {
|
||||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1136,7 +1136,7 @@ static cell_t EmitSoundEntry(IPluginContext *pContext, const cell_t *params)
|
|||||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||||
}
|
}
|
||||||
else if (!pPlayer->IsInGame()) {
|
else if (!pPlayer->IsInGame()) {
|
||||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1273,7 +1273,7 @@ static cell_t EmitSentence(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||||
} else if (!pPlayer->IsInGame()) {
|
} else if (!pPlayer->IsInGame()) {
|
||||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ stock void PrintToConsoleAll(const char[] format, any ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reples to a message in a command.
|
* Replies to a message in a command.
|
||||||
*
|
*
|
||||||
* A client index of 0 will use PrintToServer().
|
* A client index of 0 will use PrintToServer().
|
||||||
* If the command was from the console, PrintToConsole() is used.
|
* If the command was from the console, PrintToConsole() is used.
|
||||||
|
@ -321,7 +321,6 @@ methodmap Menu < Handle
|
|||||||
|
|
||||||
// Returns the text of a menu's title.
|
// Returns the text of a menu's title.
|
||||||
//
|
//
|
||||||
// @param menu Menu Handle.
|
|
||||||
// @param buffer Buffer to store title.
|
// @param buffer Buffer to store title.
|
||||||
// @param maxlength Maximum length of the buffer.
|
// @param maxlength Maximum length of the buffer.
|
||||||
// @return Number of bytes written.
|
// @return Number of bytes written.
|
||||||
@ -330,7 +329,6 @@ methodmap Menu < Handle
|
|||||||
// Creates a raw MenuPanel based off the menu's style.
|
// Creates a raw MenuPanel based off the menu's style.
|
||||||
// The Handle must be freed with CloseHandle().
|
// The Handle must be freed with CloseHandle().
|
||||||
//
|
//
|
||||||
// @param menu Menu Handle.
|
|
||||||
// @return A new MenuPanel Handle.
|
// @return A new MenuPanel Handle.
|
||||||
public native Panel ToPanel();
|
public native Panel ToPanel();
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <IShareSys.h>
|
#include <IShareSys.h>
|
||||||
#include <ILibrarySys.h>
|
#include <ILibrarySys.h>
|
||||||
|
#include "am-string.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file IExtensionSys.h
|
* @file IExtensionSys.h
|
||||||
@ -443,7 +444,7 @@ namespace SourceMod
|
|||||||
{ \
|
{ \
|
||||||
if (errbuf) \
|
if (errbuf) \
|
||||||
{ \
|
{ \
|
||||||
size_t len = snprintf(errbuf, \
|
size_t len = ke::SafeSprintf(errbuf, \
|
||||||
errsize, \
|
errsize, \
|
||||||
"Could not find interface: %s (version: %d)", \
|
"Could not find interface: %s (version: %d)", \
|
||||||
SM_IFACEPAIR(prefix)); \
|
SM_IFACEPAIR(prefix)); \
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "smsdk_ext.h"
|
#include "smsdk_ext.h"
|
||||||
|
#include "am-string.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file smsdk_ext.cpp
|
* @file smsdk_ext.cpp
|
||||||
@ -128,7 +129,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error,
|
|||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Metamod attach failed");
|
ke::SafeStrcpy(error, maxlength, "Metamod attach failed");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -376,7 +377,7 @@ bool SDKExtension::Unload(char *error, size_t maxlen)
|
|||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
|
ke::SafeStrcpy(error, maxlen, "This extension must be unloaded by SourceMod.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -390,7 +391,7 @@ bool SDKExtension::Pause(char *error, size_t maxlen)
|
|||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlen, "This extension must be paused by SourceMod.");
|
ke::SafeStrcpy(error, maxlen, "This extension must be paused by SourceMod.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -406,7 +407,7 @@ bool SDKExtension::Unpause(char *error, size_t maxlen)
|
|||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
|
ke::SafeStrcpy(error, maxlen, "This extension must be unpaused by SourceMod.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <sp_vm_api.h>
|
#include <sp_vm_api.h>
|
||||||
#include <sm_platform.h>
|
#include <sm_platform.h>
|
||||||
#include <ISourceMod.h>
|
#include <ISourceMod.h>
|
||||||
|
#include "am-string.h"
|
||||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
#endif //SMEXT_ENABLE_FORWARDSYS
|
#endif //SMEXT_ENABLE_FORWARDSYS
|
||||||
@ -327,7 +328,7 @@ extern IServerGameDLL *gamedll;
|
|||||||
{ \
|
{ \
|
||||||
if (error != NULL && maxlength) \
|
if (error != NULL && maxlength) \
|
||||||
{ \
|
{ \
|
||||||
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
size_t len = ke::SafeSprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||||
if (len >= maxlength) \
|
if (len >= maxlength) \
|
||||||
{ \
|
{ \
|
||||||
error[maxlength - 1] = '\0'; \
|
error[maxlength - 1] = '\0'; \
|
||||||
@ -344,7 +345,7 @@ extern IServerGameDLL *gamedll;
|
|||||||
{ \
|
{ \
|
||||||
if (error != NULL && maxlength) \
|
if (error != NULL && maxlength) \
|
||||||
{ \
|
{ \
|
||||||
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
size_t len = ke::SafeSprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||||
if (len >= maxlength) \
|
if (len >= maxlength) \
|
||||||
{ \
|
{ \
|
||||||
error[maxlength - 1] = '\0'; \
|
error[maxlength - 1] = '\0'; \
|
||||||
|
Loading…
Reference in New Issue
Block a user