Remove UTIL_Format() and UTIL_VarArgs()
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#include "CstrikeHLTypeConversion.h"
|
||||
#include <CDetour/detours.h>
|
||||
#include <amtl/am-vector.h>
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
bool NoKifesMode = false;
|
||||
|
||||
@ -898,7 +899,7 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params)
|
||||
GET_OFFSET("CBasePlayer", m_modelIndexPlayer);
|
||||
|
||||
char model[260];
|
||||
UTIL_Format(model, sizeof(model), "models/player/%s/%s.mdl", newModel, newModel);
|
||||
ke::SafeSprintf(model, sizeof(model), "models/player/%s/%s.mdl", newModel, newModel);
|
||||
|
||||
for (size_t i = 0; i < HL_MODEL_MAX; ++i)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ binary = AMXX.Program(builder, 'WinCSX')
|
||||
binary.compiler.includes += [
|
||||
os.path.join(builder.currentSourcePath, 'resources'),
|
||||
]
|
||||
binary.compiler.defines += ['_MBCS']
|
||||
binary.compiler.defines += ['_MBCS', 'HAVE_STDINT_H']
|
||||
binary.compiler.linkflags += [
|
||||
'comctl32.lib',
|
||||
]
|
||||
|
@ -11,24 +11,7 @@
|
||||
#include "WinCSX.h"
|
||||
#include <stdio.h>
|
||||
#include "commctrl.h"
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
buffer[maxlength - 1] = '\0';
|
||||
return (maxlength - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return len;
|
||||
}
|
||||
}
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
@ -196,7 +179,7 @@ void UpdateListBox(HWND hDlg) {
|
||||
//if ((*b).getPosition() < 1) // umm... naaah!
|
||||
//continue;
|
||||
|
||||
UTIL_Format(tempbuffer, sizeof(tempbuffer)-1, "%s", (*b).getName());
|
||||
ke::SafeSprintf(tempbuffer, sizeof(tempbuffer)-1, "%s", (*b).getName());
|
||||
|
||||
SendMessage( // returns LRESULT in lResult
|
||||
listbox, // handle to destination control
|
||||
@ -343,7 +326,7 @@ void SaveChanges(HWND hDlg) {
|
||||
UpdateListBox(hDlg);
|
||||
|
||||
char buffer[256];
|
||||
UTIL_Format(buffer, sizeof(buffer)-1, "New rank of %s: %d", name, newPosition);
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "New rank of %s: %d", name, newPosition);
|
||||
MessageBox(hDlg, buffer, "Update succeeded", MB_OK);
|
||||
|
||||
// In the listbox, we need to reselect the item we just updated. Use the new name.
|
||||
|
@ -945,7 +945,7 @@ static cell AMX_NATIVE_CALL traceresult(AMX *amx, cell *params)
|
||||
// (jghg)
|
||||
static cell AMX_NATIVE_CALL get_string(AMX *amx, cell *params) // (string, returnstring[], length)
|
||||
{
|
||||
UTIL_Format(g_buffer, sizeof(g_buffer)-1, "%s", STRING(params[1]));
|
||||
ke::SafeSprintf(g_buffer, sizeof(g_buffer)-1, "%s", STRING(params[1]));
|
||||
return MF_SetAmxString(amx, params[2], g_buffer, params[3]);
|
||||
}
|
||||
|
||||
|
@ -299,23 +299,23 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
|
||||
return num;
|
||||
} else if (ValType & Ret_Int) {
|
||||
char temp[32];
|
||||
UTIL_Format(temp, sizeof(temp)-1, "%d", rets.i);
|
||||
ke::SafeSprintf(temp, sizeof(temp)-1, "%d", rets.i);
|
||||
return MF_SetAmxString(amx, params[3], temp, size);
|
||||
} else if (ValType == Ret_Float) {
|
||||
char temp[32];
|
||||
UTIL_Format(temp, sizeof(temp)-1, "%f", rets.f);
|
||||
ke::SafeSprintf(temp, sizeof(temp)-1, "%f", rets.f);
|
||||
return MF_SetAmxString(amx, params[3], temp, size);
|
||||
} else if (ValType == Ret_Vec) {
|
||||
char temp[32];
|
||||
UTIL_Format(temp, sizeof(temp)-1, "%f %f %f", vr.x, vr.y, vr.z);
|
||||
ke::SafeSprintf(temp, sizeof(temp)-1, "%f %f %f", vr.x, vr.y, vr.z);
|
||||
return MF_SetAmxString(amx, params[3], temp, size);
|
||||
} else if (ValType == Ret_Bytes2) {
|
||||
char temp[32];
|
||||
UTIL_Format(temp, sizeof(temp)-1, "%d %d", rets.ba[0], rets.ba[1]);
|
||||
ke::SafeSprintf(temp, sizeof(temp)-1, "%d %d", rets.ba[0], rets.ba[1]);
|
||||
return MF_SetAmxString(amx, params[3], temp, size);
|
||||
} else if (ValType == Ret_Bytes4) {
|
||||
char temp[32];
|
||||
UTIL_Format(temp, sizeof(temp)-1, "%d %d %d %d", rets.ba[0], rets.ba[1], rets.ba[2], rets.ba[3]);
|
||||
ke::SafeSprintf(temp, sizeof(temp)-1, "%d %d %d %d", rets.ba[0], rets.ba[1], rets.ba[2], rets.ba[3]);
|
||||
return MF_SetAmxString(amx, params[3], temp, size);
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ bool loadDatabase()
|
||||
// MF_BuildPathname not used because backslash
|
||||
// makes CreateFileMapping failing under windows.
|
||||
|
||||
UTIL_Format(file, sizeof(file) - 1, "%s/%s/GeoLite2-%s.mmdb", modName, dataDir, databases[i]);
|
||||
ke::SafeSprintf(file, sizeof(file) - 1, "%s/%s/GeoLite2-%s.mmdb", modName, dataDir, databases[i]);
|
||||
|
||||
status = MMDB_open(file, MMDB_MODE_MMAP, &HandleDB);
|
||||
|
||||
|
@ -157,7 +157,7 @@ static cell AMX_NATIVE_CALL amx_geoip_region_code(AMX *amx, cell *params)
|
||||
if (countryCode)
|
||||
{
|
||||
finalLength = length + 1; // + 1 for dash.
|
||||
UTIL_Format(code, finalLength + 1, "%s-", countryCode); // + EOS.
|
||||
ke::SafeSprintf(code, finalLength + 1, "%s-", countryCode); // + EOS.
|
||||
|
||||
const char *pathRegion[] = { "subdivisions", "0", "iso_code", NULL }; // First result.
|
||||
const char *regionCode = lookupString(ip, pathRegion, &length);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "ham_const.h"
|
||||
#include "hooklist.h"
|
||||
#include "offsets.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
extern hook_t hooklist[];
|
||||
|
||||
@ -108,7 +109,7 @@ static void read_mirror(char *input)
|
||||
*data='\0';
|
||||
|
||||
// mark down the source
|
||||
UTIL_Format(source, sizeof(source)-1, "%s", input);
|
||||
ke::SafeSprintf(source, sizeof(source)-1, "%s", input);
|
||||
|
||||
*data=old;
|
||||
|
||||
@ -128,13 +129,13 @@ static void read_mirror(char *input)
|
||||
old=*data;
|
||||
*data='\0';
|
||||
|
||||
UTIL_Format(dest, sizeof(dest)-1, "%s", data2);
|
||||
ke::SafeSprintf(dest, sizeof(dest)-1, "%s", data2);
|
||||
|
||||
*data=old;
|
||||
|
||||
if (strcmp(dest, CurrentModName)==0)
|
||||
{
|
||||
UTIL_Format(CurrentModName, sizeof(CurrentModName)-1, "%s", source);
|
||||
ke::SafeSprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", source);
|
||||
}
|
||||
|
||||
}
|
||||
@ -313,7 +314,7 @@ int ReadConfig(void)
|
||||
FILE *fp=fopen(FileName,"r");
|
||||
|
||||
|
||||
UTIL_Format(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname());
|
||||
ke::SafeSprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname());
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
|
@ -17,16 +17,17 @@
|
||||
#include "amxxmodule.h"
|
||||
#include "offsets.h"
|
||||
#include "NEW_Util.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
#define CHECK_FUNCTION(x) \
|
||||
if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \
|
||||
char msg[1024]; \
|
||||
UTIL_Format(msg, sizeof(msg)-1, "Function out of bounds. Got: %d Max: %d", x, HAM_LAST_ENTRY_DONT_USE_ME_LOL - 1); \
|
||||
ke::SafeSprintf(msg, sizeof(msg)-1, "Function out of bounds. Got: %d Max: %d", x, HAM_LAST_ENTRY_DONT_USE_ME_LOL - 1); \
|
||||
FailPlugin(amx, x, HAM_INVALID_FUNC, msg); \
|
||||
return 0; \
|
||||
} else if (hooklist[x].isset == 0) { \
|
||||
char msg[1024]; \
|
||||
UTIL_Format(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.", hooklist[x].name); \
|
||||
ke::SafeSprintf(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.", hooklist[x].name); \
|
||||
FailPlugin(amx, x, HAM_FUNC_NOT_CONFIGURED, msg); \
|
||||
return 0; \
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "forward.h"
|
||||
#include "Trampolines.h"
|
||||
#include <amtl/am-vector.h>
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
#define ALIGN(ar) ((intptr_t)ar & ~(sysconf(_SC_PAGESIZE)-1))
|
||||
|
||||
@ -62,7 +63,7 @@ public:
|
||||
size_t len=strlen(name);
|
||||
ent=new char[len+1];
|
||||
|
||||
UTIL_Format(ent, len + 1, "%s", name);
|
||||
ke::SafeSprintf(ent, len + 1, "%s", name);
|
||||
};
|
||||
|
||||
~Hook()
|
||||
|
@ -707,7 +707,7 @@ static cell AMX_NATIVE_CALL RegisterHamFromEntity(AMX *amx, cell *params)
|
||||
// It may very well be wrong (such as lots of TS weapons have the same classname)
|
||||
// but it's the best we can do, and better than nothing.
|
||||
// (only used for display)
|
||||
UTIL_Format(classname, sizeof(classname) - 1, "%s", STRING(Entity->v.classname));
|
||||
ke::SafeSprintf(classname, sizeof(classname) - 1, "%s", STRING(Entity->v.classname));
|
||||
|
||||
// If we got here, the function is not hooked
|
||||
Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "amxxmodule.h"
|
||||
#include "MysqlDriver.h"
|
||||
#include "MysqlDatabase.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
@ -47,7 +48,7 @@ IDatabase *MysqlDriver::_Connect(DatabaseInfo *info, int *errcode, char *error,
|
||||
*errcode = -1;
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "Initialization failed");
|
||||
ke::SafeSprintf(error, maxlength, "Initialization failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -89,7 +90,7 @@ IDatabase *MysqlDriver::_Connect(DatabaseInfo *info, int *errcode, char *error,
|
||||
}
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "%s", mysql_error(mysql));
|
||||
ke::SafeSprintf(error, maxlength, "%s", mysql_error(mysql));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "MysqlQuery.h"
|
||||
#include "MysqlDatabase.h"
|
||||
#include "MysqlResultSet.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
@ -90,7 +91,7 @@ bool MysqlQuery::ExecuteR(QueryInfo *info, char *error, size_t maxlength)
|
||||
info->rs = NULL;
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "%s", mysql_error(m_pDatabase->m_pMysql));
|
||||
ke::SafeSprintf(error, maxlength, "%s", mysql_error(m_pDatabase->m_pMysql));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -26,7 +26,7 @@ void ParticleManager::ReadFile(void)
|
||||
|
||||
char FileName[256];
|
||||
|
||||
UTIL_Format(FileName, sizeof(FileName)-1, "%s/ns.ps", MF_GetModname());
|
||||
ke::SafeSprintf(FileName, sizeof(FileName)-1, "%s/ns.ps", MF_GetModname());
|
||||
FILE *fp=fopen(FileName,"r");
|
||||
|
||||
if (!fp)
|
||||
|
@ -27,7 +27,7 @@ void TitleManager::LoadTitles(void)
|
||||
|
||||
char FileName[128];
|
||||
|
||||
UTIL_Format(FileName, sizeof(FileName)-1, "%s/titles.txt", MF_GetModname());
|
||||
ke::SafeSprintf(FileName, sizeof(FileName)-1, "%s/titles.txt", MF_GetModname());
|
||||
|
||||
FILE *fp=fopen(FileName,"r");
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "ParticleManager.h"
|
||||
|
||||
#include "AllocString.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
extern int gmsgHudText2;
|
||||
extern BOOL iscombat;
|
||||
@ -91,9 +92,9 @@ void OnAmxxAttach()
|
||||
char FileName[256];
|
||||
DLHANDLE DLLBase;
|
||||
#ifdef __linux__
|
||||
UTIL_Format(FileName, sizeof(FileName), "%s/dlls/ns_i386.so", MF_GetModname());
|
||||
ke::SafeSprintf(FileName, sizeof(FileName), "%s/dlls/ns_i386.so", MF_GetModname());
|
||||
#else
|
||||
UTIL_Format(FileName, sizeof(FileName), "%s\\dlls\\ns.dll", MF_GetModname());
|
||||
ke::SafeSprintf(FileName, sizeof(FileName), "%s\\dlls\\ns.dll", MF_GetModname());
|
||||
#endif
|
||||
|
||||
DLLBase = DLOPEN(FileName);
|
||||
|
@ -48,7 +48,7 @@ cell PSKeyValueI(const char *name, AMX *amx, cell *params)
|
||||
|
||||
char StrData[1024];
|
||||
|
||||
UTIL_Format(StrData, sizeof(StrData)-1, "%d", params[2]);
|
||||
ke::SafeSprintf(StrData, sizeof(StrData)-1, "%d", params[2]);
|
||||
|
||||
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
|
||||
kvd.szKeyName=name;
|
||||
@ -71,7 +71,7 @@ cell PSKeyValueF(const char *name, AMX *amx, cell *params)
|
||||
|
||||
char StrData[1024];
|
||||
|
||||
UTIL_Format(StrData, sizeof(StrData)-1, "%f", amx_ctof2(params[2]));
|
||||
ke::SafeSprintf(StrData, sizeof(StrData)-1, "%f", amx_ctof2(params[2]));
|
||||
|
||||
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
|
||||
kvd.szKeyName=name;
|
||||
|
@ -367,7 +367,7 @@ bool NVault::GetValue(const char *key, time_t &stamp, char buffer[], size_t len)
|
||||
}
|
||||
|
||||
stamp = result.stamp;
|
||||
UTIL_Format(buffer, len, "%s", result.value.chars());
|
||||
ke::SafeSprintf(buffer, len, "%s", result.value.chars());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "SqliteHeaders.h"
|
||||
#include "SqliteDriver.h"
|
||||
#include "SqliteDatabase.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
#if defined WIN32
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
@ -62,7 +63,7 @@ IDatabase *SqliteDriver::Connect(DatabaseInfo *info, int *errcode, char *error,
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "%s", sqlite3_errmsg(pSql));
|
||||
ke::SafeSprintf(error, maxlength, "%s", sqlite3_errmsg(pSql));
|
||||
}
|
||||
sqlite3_close(pSql);
|
||||
return NULL;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "SqliteQuery.h"
|
||||
#include "SqliteDatabase.h"
|
||||
#include "SqliteResultSet.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
@ -92,7 +93,7 @@ bool SqliteQuery::ExecuteR(QueryInfo *info, char *error, size_t maxlength)
|
||||
{
|
||||
if (error && maxlength && errmsg)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "%s", errmsg);
|
||||
ke::SafeSprintf(error, maxlength, "%s", errmsg);
|
||||
}
|
||||
info->affected_rows = 0;
|
||||
info->errorcode = err;
|
||||
|
Reference in New Issue
Block a user