Remove UTIL_Format() and UTIL_VarArgs()
This commit is contained in:
@@ -24,7 +24,7 @@ CDirectory::CDirectory(const char *path)
|
||||
#if defined PLATFORM_WINDOWS
|
||||
|
||||
char newpath[PLATFORM_MAX_PATH];
|
||||
UTIL_Format(newpath, sizeof(newpath) - 1, "%s\\*.*", path);
|
||||
ke::SafeSprintf(newpath, sizeof(newpath) - 1, "%s\\*.*", path);
|
||||
|
||||
m_dir = FindFirstFile(newpath, &m_fd);
|
||||
|
||||
@@ -40,7 +40,7 @@ CDirectory::CDirectory(const char *path)
|
||||
if (IsValid())
|
||||
{
|
||||
m_ep = readdir(m_dir); // TODO: we need to read past "." and ".."!
|
||||
UTIL_Format(m_origpath, sizeof(m_origpath) - 1, "%s", path);
|
||||
ke::SafeSprintf(m_origpath, sizeof(m_origpath) - 1, "%s", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -103,7 +103,7 @@ bool CDirectory::IsEntryDirectory()
|
||||
#elif defined PLATFORM_POSIX
|
||||
|
||||
char temppath[PLATFORM_MAX_PATH];
|
||||
UTIL_Format(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
||||
ke::SafeSprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
||||
|
||||
return ke::file::IsDirectory(temppath);
|
||||
|
||||
@@ -119,7 +119,7 @@ bool CDirectory::IsEntryFile()
|
||||
#elif defined PLATFORM_POSIX
|
||||
|
||||
char temppath[PLATFORM_MAX_PATH];
|
||||
UTIL_Format(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
||||
ke::SafeSprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
||||
|
||||
return ke::file::IsDirectory(temppath);
|
||||
|
||||
@@ -318,12 +318,12 @@ size_t LibrarySystem::GetFileFromPath(char* buffer, size_t maxlength, const char
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return UTIL_Format(buffer, maxlength, "%s", &path[i + 1]);
|
||||
return ke::SafeSprintf(buffer, maxlength, "%s", &path[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/* We scanned and found no path separator */
|
||||
return UTIL_Format(buffer, maxlength, "%s", path);
|
||||
return ke::SafeSprintf(buffer, maxlength, "%s", path);
|
||||
}
|
||||
|
||||
bool LibrarySystem::FileTime(const char* path, FileTimeType type, time_t* pTime)
|
||||
|
@@ -67,15 +67,9 @@
|
||||
#define PLATFORM_MAX_PATH 260
|
||||
|
||||
#if defined PLATFORM_WINDOWS
|
||||
|
||||
typedef HMODULE LibraryHandle;
|
||||
typedef HANDLE DirHandle;
|
||||
|
||||
#elif defined PLATFORM_POSIX
|
||||
|
||||
typedef void* LibraryHandle;
|
||||
typedef DIR* DirHandle;
|
||||
|
||||
#endif
|
||||
|
||||
enum FileTimeType
|
||||
|
@@ -137,7 +137,7 @@ SMCError TextParsers::ParseSMCFile(const char *file,
|
||||
states->col = 0;
|
||||
}
|
||||
/*libsys->GetPlatformError(error, sizeof(error));*/
|
||||
UTIL_Format(buffer, maxsize, "File could not be opened: %s", error);
|
||||
ke::SafeSprintf(buffer, maxsize, "File could not be opened: %s", error);
|
||||
return SMCError_StreamOpen;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ SMCError TextParsers::ParseSMCFile(const char *file,
|
||||
fclose(fp);
|
||||
|
||||
errstr = GetSMCErrorString(result);
|
||||
UTIL_Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
ke::SafeSprintf(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ SMCError TextParsers::ParseSMCStream(const char *stream,
|
||||
result = ParseStream_SMC(&rs, RawStreamReader, smc_listener, states);
|
||||
|
||||
const char *errstr = GetSMCErrorString(result);
|
||||
UTIL_Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
ke::SafeSprintf(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -53,8 +53,8 @@ void CoreConfig::ExecuteMainConfig()
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
char command[PLATFORM_MAX_PATH + sizeof(CommandFormat)];
|
||||
|
||||
UTIL_Format(path, sizeof(path), "%s/%s/%s", g_mod_name.chars(), get_localinfo("amx_configdir", "addons/amxmodx/configs"), MainConfigFile);
|
||||
UTIL_Format(command, sizeof(command), CommandFormat, path);
|
||||
ke::SafeSprintf(path, sizeof(path), "%s/%s/%s", g_mod_name.chars(), get_localinfo("amx_configdir", "addons/amxmodx/configs"), MainConfigFile);
|
||||
ke::SafeSprintf(command, sizeof(command), CommandFormat, path);
|
||||
|
||||
SERVER_COMMAND(command);
|
||||
}
|
||||
@@ -140,11 +140,11 @@ bool CoreConfig::ExecuteAutoConfig(CPluginMngr::CPlugin *plugin, AutoConfig *con
|
||||
|
||||
if (config->folder.length())
|
||||
{
|
||||
UTIL_Format(file, sizeof(file), "%s/%s%s/%s/%s.cfg", g_mod_name.chars(), configsDir, AutoConfigDir, config->folder.chars(), config->autocfg.chars());
|
||||
ke::SafeSprintf(file, sizeof(file), "%s/%s%s/%s/%s.cfg", g_mod_name.chars(), configsDir, AutoConfigDir, config->folder.chars(), config->autocfg.chars());
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_Format(file, sizeof(file), "%s/%s%s/%s.cfg", g_mod_name.chars(), configsDir, AutoConfigDir, config->autocfg.chars());
|
||||
ke::SafeSprintf(file, sizeof(file), "%s/%s%s/%s.cfg", g_mod_name.chars(), configsDir, AutoConfigDir, config->autocfg.chars());
|
||||
}
|
||||
|
||||
bool file_exists = g_LibSys.IsPathFile(file);
|
||||
@@ -244,7 +244,7 @@ bool CoreConfig::ExecuteAutoConfig(CPluginMngr::CPlugin *plugin, AutoConfig *con
|
||||
if (file_exists)
|
||||
{
|
||||
char command[PLATFORM_MAX_PATH + sizeof(CommandFormat)];
|
||||
UTIL_Format(command, sizeof(command), CommandFormat, file);
|
||||
ke::SafeSprintf(command, sizeof(command), CommandFormat, file);
|
||||
|
||||
SERVER_COMMAND(command);
|
||||
}
|
||||
@@ -266,21 +266,21 @@ void CoreConfig::ExecuteMapConfig()
|
||||
|
||||
if ((mapPrefix = strtok(mapName, "_")))
|
||||
{
|
||||
UTIL_Format(cfgPath, sizeof(cfgPath), "%s/%s%s/prefix_%s.cfg", g_mod_name.chars(), configsDir, MapConfigDir, mapPrefix);
|
||||
ke::SafeSprintf(cfgPath, sizeof(cfgPath), "%s/%s%s/prefix_%s.cfg", g_mod_name.chars(), configsDir, MapConfigDir, mapPrefix);
|
||||
|
||||
if (g_LibSys.IsPathFile(cfgPath))
|
||||
{
|
||||
UTIL_Format(command, sizeof(command), CommandFormat, cfgPath);
|
||||
ke::SafeSprintf(command, sizeof(command), CommandFormat, cfgPath);
|
||||
SERVER_COMMAND(command);
|
||||
}
|
||||
}
|
||||
|
||||
strncopy(mapName, STRING(gpGlobals->mapname), sizeof(mapName));
|
||||
UTIL_Format(cfgPath, sizeof(cfgPath), "%s/%s%s/%s.cfg", g_mod_name.chars(), configsDir, MapConfigDir, mapName);
|
||||
ke::SafeSprintf(cfgPath, sizeof(cfgPath), "%s/%s%s/%s.cfg", g_mod_name.chars(), configsDir, MapConfigDir, mapName);
|
||||
|
||||
if (g_LibSys.IsPathFile(cfgPath))
|
||||
{
|
||||
UTIL_Format(command, sizeof(command), CommandFormat, cfgPath);
|
||||
ke::SafeSprintf(command, sizeof(command), CommandFormat, cfgPath);
|
||||
SERVER_COMMAND(command);
|
||||
}
|
||||
|
||||
|
@@ -4506,7 +4506,7 @@ static cell AMX_NATIVE_CALL AutoExecConfig(AMX *amx, cell *params)
|
||||
}
|
||||
|
||||
static char newName[PLATFORM_MAX_PATH];
|
||||
UTIL_Format(newName, sizeof(newName), "plugin-%s", pluginName);
|
||||
ke::SafeSprintf(newName, sizeof(newName), "plugin-%s", pluginName);
|
||||
|
||||
name = newName;
|
||||
}
|
||||
|
@@ -139,8 +139,6 @@ template <typename D, typename S> unsigned int strncopy(D *dest, const S *src, s
|
||||
unsigned int UTIL_GetUTF8CharBytes(const char *stream);
|
||||
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive);
|
||||
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen, bool caseSensitive);
|
||||
char *UTIL_VarArgs(const char *fmt, ...);
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
void UTIL_TrimLeft(char *buffer);
|
||||
void UTIL_TrimRight(char *buffer);
|
||||
|
||||
|
@@ -81,7 +81,7 @@ void CLog::CreateNewFile()
|
||||
|
||||
while (true)
|
||||
{
|
||||
UTIL_Format(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.chars(), curTime->tm_mon + 1, curTime->tm_mday, i);
|
||||
ke::SafeSprintf(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.chars(), curTime->tm_mon + 1, curTime->tm_mday, i);
|
||||
build_pathname_r(file, sizeof(file)-1, "%s", name);
|
||||
FILE *pTmpFile = fopen(file, "r"); // open for reading to check whether the file exists
|
||||
|
||||
@@ -243,7 +243,7 @@ void CLog::LogError(const char *fmt, ...)
|
||||
va_end(arglst);
|
||||
|
||||
FILE *pF = NULL;
|
||||
UTIL_Format(name, sizeof(name), "%s/error_%04d%02d%02d.log", g_log_dir.chars(), curTime->tm_year + 1900, curTime->tm_mon + 1, curTime->tm_mday);
|
||||
ke::SafeSprintf(name, sizeof(name), "%s/error_%04d%02d%02d.log", g_log_dir.chars(), curTime->tm_year + 1900, curTime->tm_mon + 1, curTime->tm_mday);
|
||||
build_pathname_r(file, sizeof(file)-1, "%s", name);
|
||||
pF = fopen(file, "a+");
|
||||
|
||||
|
@@ -240,7 +240,7 @@ static cell AMX_NATIVE_CALL set_cvar_float(AMX *amx, cell *params)
|
||||
|
||||
if (info)
|
||||
{
|
||||
UTIL_Format(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%f", amx_ctof(params[2]));
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%f", amx_ctof(params[2]));
|
||||
CVAR_DIRECTSET(info->var, &CVarTempBuffer[0]);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ static cell AMX_NATIVE_CALL set_cvar_num(AMX *amx, cell *params)
|
||||
|
||||
if (info)
|
||||
{
|
||||
UTIL_Format(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%d", value);
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%d", value);
|
||||
CVAR_DIRECTSET(info->var, &CVarTempBuffer[0]);
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ static cell AMX_NATIVE_CALL set_pcvar_float(AMX *amx, cell *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UTIL_Format(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%f", amx_ctof(params[2]));
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%f", amx_ctof(params[2]));
|
||||
CVAR_DIRECTSET(ptr, &CVarTempBuffer[0]);
|
||||
|
||||
return 1;
|
||||
@@ -460,7 +460,7 @@ static cell AMX_NATIVE_CALL set_pcvar_num(AMX *amx, cell *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UTIL_Format(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%d", params[2]);
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%d", params[2]);
|
||||
CVAR_DIRECTSET(ptr, &CVarTempBuffer[0]);
|
||||
|
||||
return 1;
|
||||
|
@@ -367,7 +367,7 @@ int Debugger::FormatError(char *buffer, size_t maxLength)
|
||||
//cell *p_cip = NULL;
|
||||
//int amx_err = AMX_ERR_NONE;
|
||||
|
||||
size += UTIL_Format(buffer, maxLength, "Run time error %d: %s ", error, gen_err);
|
||||
size += ke::SafeSprintf(buffer, maxLength, "Run time error %d: %s ", error, gen_err);
|
||||
buffer += size;
|
||||
maxLength -= size;
|
||||
|
||||
@@ -390,7 +390,7 @@ int Debugger::FormatError(char *buffer, size_t maxLength)
|
||||
else
|
||||
amx_err = AMX_ERR_NOTFOUND;*/
|
||||
//if (!amx_err)
|
||||
size += UTIL_Format(buffer, maxLength, "(native \"%s\")", native_name);
|
||||
size += ke::SafeSprintf(buffer, maxLength, "(native \"%s\")", native_name);
|
||||
}
|
||||
|
||||
return size;
|
||||
@@ -623,12 +623,12 @@ void Debugger::FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLengt
|
||||
|
||||
if (error == AMX_ERR_EXIT)
|
||||
{
|
||||
UTIL_Format(buffer, maxLength, "Run time error %d (plugin \"%s\") - %s", error, filename, GenericError(AMX_ERR_EXIT));
|
||||
ke::SafeSprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - %s", error, filename, GenericError(AMX_ERR_EXIT));
|
||||
} else if (error == AMX_ERR_NATIVE) {
|
||||
amx_GetNative(amx, reinterpret_cast<long>(amx->usertags[UT_NATIVE]), native);
|
||||
UTIL_Format(buffer, maxLength, "Run time error %d (plugin \"%s\") (native \"%s\") - debug not enabled!", error, filename, native);
|
||||
ke::SafeSprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") (native \"%s\") - debug not enabled!", error, filename, native);
|
||||
} else {
|
||||
UTIL_Format(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename);
|
||||
ke::SafeSprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -673,7 +673,7 @@ reswitch:
|
||||
if (!def)
|
||||
{
|
||||
static char buf[255];
|
||||
UTIL_Format(buf, sizeof(buf) - 1, "ML_NOTFOUND: %s", key);
|
||||
ke::SafeSprintf(buf, sizeof(buf) - 1, "ML_NOTFOUND: %s", key);
|
||||
def = buf;
|
||||
}
|
||||
size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
|
||||
@@ -708,11 +708,11 @@ reswitch:
|
||||
}
|
||||
|
||||
int userid = GETPLAYERUSERID(player->pEdict);
|
||||
UTIL_Format(buffer, sizeof(buffer), "%s<%d><%s><%s>", player->name.chars(), userid, auth, player->team.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%s<%d><%s><%s>", player->name.chars(), userid, auth, player->team.chars());
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_Format(buffer, sizeof(buffer), "Console<0><Console><Console>");
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "Console<0><Console><Console>");
|
||||
}
|
||||
|
||||
AddString(&buf_p, llen, buffer, width, prec);
|
||||
|
@@ -97,7 +97,7 @@ size_t AddLibrariesFromString(const char *name, LibType type, LibSource src, voi
|
||||
char *ptr, *p, s;
|
||||
size_t count = 0;
|
||||
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "%s", name);
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s", name);
|
||||
|
||||
ptr = buffer;
|
||||
p = buffer;
|
||||
|
@@ -226,7 +226,7 @@ void LoadExtraPluginsToPCALM(const char *initialdir)
|
||||
while (!files.empty())
|
||||
{
|
||||
ke::AString *pString = files.front();
|
||||
UTIL_Format(path, sizeof(path)-1, "%s/%s",
|
||||
ke::SafeSprintf(path, sizeof(path)-1, "%s/%s",
|
||||
initialdir,
|
||||
pString->chars());
|
||||
g_plugins.CALMFromFile(path);
|
||||
@@ -243,7 +243,7 @@ void LoadExtraPluginsFromDir(const char *initialdir)
|
||||
while (!files.empty())
|
||||
{
|
||||
ke::AString *pString = files.front();
|
||||
UTIL_Format(path, sizeof(path)-1, "%s/%s",
|
||||
ke::SafeSprintf(path, sizeof(path)-1, "%s/%s",
|
||||
initialdir,
|
||||
pString->chars());
|
||||
g_plugins.loadPluginsFromFile(path);
|
||||
@@ -332,7 +332,7 @@ const char* get_localinfo_r(const char *name, const char *def, char buffer[], si
|
||||
SET_LOCALINFO((char*)name, (char*)(b = def));
|
||||
}
|
||||
|
||||
UTIL_Format(buffer, maxlength, "%s", b);
|
||||
ke::SafeSprintf(buffer, maxlength, "%s", b);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@@ -425,7 +425,7 @@ int C_Spawn(edict_t *pent)
|
||||
LoadExtraPluginsToPCALM(configs_dir);
|
||||
char temporaryMap[64], *tmap_ptr;
|
||||
|
||||
UTIL_Format(temporaryMap, sizeof(temporaryMap), "%s", STRING(gpGlobals->mapname));
|
||||
ke::SafeSprintf(temporaryMap, sizeof(temporaryMap), "%s", STRING(gpGlobals->mapname));
|
||||
|
||||
prefixed_map_pluginsfile[0] = '\0';
|
||||
if ((tmap_ptr = strchr(temporaryMap, '_')) != NULL)
|
||||
@@ -433,7 +433,7 @@ int C_Spawn(edict_t *pent)
|
||||
// this map has a prefix
|
||||
|
||||
*tmap_ptr = '\0';
|
||||
UTIL_Format(prefixed_map_pluginsfile,
|
||||
ke::SafeSprintf(prefixed_map_pluginsfile,
|
||||
sizeof(prefixed_map_pluginsfile),
|
||||
"%s/maps/plugins-%s.ini",
|
||||
configs_dir,
|
||||
@@ -441,7 +441,7 @@ int C_Spawn(edict_t *pent)
|
||||
g_plugins.CALMFromFile(prefixed_map_pluginsfile);
|
||||
}
|
||||
|
||||
UTIL_Format(map_pluginsfile_path,
|
||||
ke::SafeSprintf(map_pluginsfile_path,
|
||||
sizeof(map_pluginsfile_path),
|
||||
"%s/maps/plugins-%s.ini",
|
||||
configs_dir,
|
||||
|
@@ -670,7 +670,7 @@ char* build_pathname(const char *fmt, ...)
|
||||
{
|
||||
static char string[256];
|
||||
int b;
|
||||
int a = b = UTIL_Format(string, 255, "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
||||
int a = b = ke::SafeSprintf(string, 255, "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, fmt);
|
||||
@@ -694,7 +694,7 @@ char* build_pathname(const char *fmt, ...)
|
||||
|
||||
char *build_pathname_r(char *buffer, size_t maxlen, const char *fmt, ...)
|
||||
{
|
||||
UTIL_Format(buffer, maxlen, "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
||||
ke::SafeSprintf(buffer, maxlen, "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
||||
|
||||
size_t len = strlen(buffer);
|
||||
char *ptr = buffer + len;
|
||||
@@ -817,16 +817,16 @@ bool ConvertModuleName(const char *pathString, char *path)
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
size_t length = UTIL_Format(path, PLATFORM_MAX_PATH, "%s%c%s_amxx", orig_path, PATH_SEP_CHAR, tmpname);
|
||||
size_t length = ke::SafeSprintf(path, PLATFORM_MAX_PATH, "%s%c%s_amxx", orig_path, PATH_SEP_CHAR, tmpname);
|
||||
|
||||
#if defined PLATFORM_LINUX
|
||||
# if defined AMD64 || PAWN_CELL_SIZE == 64
|
||||
length += strncopy(path + length, "_amd64", PLATFORM_MAX_PATH - length);
|
||||
# else
|
||||
length += UTIL_Format(path + length, PLATFORM_MAX_PATH - length, "_i%c86", iDigit);
|
||||
length += ke::SafeSprintf(path + length, PLATFORM_MAX_PATH - length, "_i%c86", iDigit);
|
||||
# endif
|
||||
#endif
|
||||
UTIL_Format(path + length, PLATFORM_MAX_PATH - length, ".%s", PLATFORM_LIB_EXT);
|
||||
ke::SafeSprintf(path + length, PLATFORM_MAX_PATH - length, ".%s", PLATFORM_LIB_EXT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
BIN
amxmodx/msvc12/ipch/WINCSX-7d4a1d4a/WINCSX-e0702fa2.ipch
Normal file
BIN
amxmodx/msvc12/ipch/WINCSX-7d4a1d4a/WINCSX-e0702fa2.ipch
Normal file
Binary file not shown.
@@ -180,7 +180,7 @@ static cell AMX_NATIVE_CALL log_error(AMX *amx, cell *params)
|
||||
int len;
|
||||
char *err = format_amxstring(amx, params, 2, len);
|
||||
|
||||
UTIL_Format(g_errorStr, sizeof(g_errorStr), "%s", err);
|
||||
ke::SafeSprintf(g_errorStr, sizeof(g_errorStr), "%s", err);
|
||||
g_CurError = params[1];
|
||||
|
||||
return 1;
|
||||
|
@@ -289,7 +289,7 @@ bool Menu::Display(int player, page_t page)
|
||||
return false;
|
||||
|
||||
static char buffer[2048];
|
||||
int len = UTIL_Format(buffer, sizeof(buffer)-1, "%s", str);
|
||||
int len = ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s", str);
|
||||
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(player);
|
||||
|
||||
@@ -342,14 +342,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
if (items_per_page && (pages != 1))
|
||||
{
|
||||
if (m_AutoColors)
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages);
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages);
|
||||
else
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.chars(), page + 1, pages);
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.chars(), page + 1, pages);
|
||||
} else {
|
||||
if (m_AutoColors)
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "\\y%s\n\\w\n", m_Title.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "\\y%s\n\\w\n", m_Title.chars());
|
||||
else
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "%s\n\n", m_Title.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s\n\n", m_Title.chars());
|
||||
}
|
||||
|
||||
m_Text = m_Text + buffer;
|
||||
@@ -446,22 +446,22 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
|
||||
if (pItem->isBlank)
|
||||
{
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "%s\n", pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s\n", pItem->name.chars());
|
||||
}
|
||||
else if (enabled)
|
||||
{
|
||||
if (m_AutoColors)
|
||||
{
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "%s%d.\\w %s\n", m_ItemColor.chars(),option_display, pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s%d.\\w %s\n", m_ItemColor.chars(),option_display, pItem->name.chars());
|
||||
} else {
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "%d. %s\n", option_display, pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option_display, pItem->name.chars());
|
||||
}
|
||||
} else {
|
||||
if (m_AutoColors)
|
||||
{
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "\\d%d. %s\n\\w", option_display, pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "\\d%d. %s\n\\w", option_display, pItem->name.chars());
|
||||
} else {
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "#. %s\n", pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "#. %s\n", pItem->name.chars());
|
||||
}
|
||||
}
|
||||
slots++;
|
||||
@@ -503,14 +503,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
keys |= (1<<option++);
|
||||
if (m_AutoColors)
|
||||
{
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"%s%d. \\w%s\n",
|
||||
m_ItemColor.chars(),
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_BACK)].chars());
|
||||
} else {
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"%d. %s\n",
|
||||
option == 10 ? 0 : option,
|
||||
@@ -520,13 +520,13 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
option++;
|
||||
if (m_AutoColors)
|
||||
{
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"\\d%d. %s\n\\w",
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_BACK)].chars());
|
||||
} else {
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "#. %s\n", m_OptNames[abs(MENU_BACK)].chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "#. %s\n", m_OptNames[abs(MENU_BACK)].chars());
|
||||
}
|
||||
}
|
||||
m_Text = m_Text + buffer;
|
||||
@@ -536,14 +536,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
keys |= (1<<option++);
|
||||
if (m_AutoColors)
|
||||
{
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"%s%d. \\w%s\n",
|
||||
m_ItemColor.chars(),
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_MORE)].chars());
|
||||
} else {
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"%d. %s\n",
|
||||
option == 10 ? 0 : option,
|
||||
@@ -553,13 +553,13 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
option++;
|
||||
if (m_AutoColors)
|
||||
{
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"\\d%d. %s\n\\w",
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_MORE)].chars());
|
||||
} else {
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "#. %s\n", m_OptNames[abs(MENU_MORE)].chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "#. %s\n", m_OptNames[abs(MENU_MORE)].chars());
|
||||
}
|
||||
}
|
||||
m_Text = m_Text + buffer;
|
||||
@@ -578,14 +578,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
keys |= (1<<option++);
|
||||
if (m_AutoColors)
|
||||
{
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"%s%d. \\w%s\n",
|
||||
m_ItemColor.chars(),
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_EXIT)].chars());
|
||||
} else {
|
||||
UTIL_Format(buffer,
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
"%d. %s\n",
|
||||
option == 10 ? 0 : option,
|
||||
|
@@ -10,22 +10,6 @@
|
||||
#include <time.h>
|
||||
#include "amxmodx.h"
|
||||
|
||||
#if ( defined(__linux__) || defined(__APPLE__) ) && !defined _vsnprintf
|
||||
#define _vsnprintf vsnprintf
|
||||
#endif
|
||||
|
||||
char *UTIL_VarArgs(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
static char string[4096];
|
||||
|
||||
va_start(ap, fmt);
|
||||
ke::SafeVsprintf(string, sizeof(string), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
int UTIL_ReadFlags(const char* c)
|
||||
{
|
||||
int flags = 0;
|
||||
@@ -351,8 +335,8 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
|
||||
g_fakecmd.argv[1] = arg1;
|
||||
g_fakecmd.argv[2] = arg2;
|
||||
// build argument line
|
||||
UTIL_Format(g_fakecmd.args, 255, "%s %s", arg1, arg2);
|
||||
// if UTIL_Format reached 255 chars limit, this will make sure there will be no access violation
|
||||
ke::SafeSprintf(g_fakecmd.args, 255, "%s %s", arg1, arg2);
|
||||
// if ke::SafeSprintf reached 255 chars limit, this will make sure there will be no access violation
|
||||
g_fakecmd.args[255] = 0;
|
||||
}
|
||||
else if (arg1)
|
||||
@@ -361,8 +345,8 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
|
||||
// store argument
|
||||
g_fakecmd.argv[1] = arg1;
|
||||
// build argument line
|
||||
UTIL_Format(g_fakecmd.args, 255, "%s", arg1);
|
||||
// if UTIL_Format reached 255 chars limit, this will make sure there will be no access violation
|
||||
ke::SafeSprintf(g_fakecmd.args, 255, "%s", arg1);
|
||||
// if ke::SafeSprintf reached 255 chars limit, this will make sure there will be no access violation
|
||||
g_fakecmd.args[255] = 0;
|
||||
}
|
||||
else
|
||||
@@ -694,16 +678,6 @@ char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t se
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
size_t len = ke::SafeVsprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
// From Metamod:Source
|
||||
void UTIL_TrimLeft(char *buffer)
|
||||
{
|
||||
|
Reference in New Issue
Block a user