Fix max length inconsistencies + typo

This commit is contained in:
Arkshine
2015-10-05 19:06:38 +02:00
parent 138b9e1510
commit c29eabec50
18 changed files with 54 additions and 58 deletions

View File

@ -179,7 +179,7 @@ void UpdateListBox(HWND hDlg) {
//if ((*b).getPosition() < 1) // umm... naaah!
//continue;
ke::SafeSprintf(tempbuffer, sizeof(tempbuffer)-1, "%s", (*b).getName());
ke::SafeSprintf(tempbuffer, sizeof(tempbuffer), "%s", (*b).getName());
SendMessage( // returns LRESULT in lResult
listbox, // handle to destination control
@ -326,7 +326,7 @@ void SaveChanges(HWND hDlg) {
UpdateListBox(hDlg);
char buffer[256];
ke::SafeSprintf(buffer, sizeof(buffer)-1, "New rank of %s: %d", name, newPosition);
ke::SafeSprintf(buffer, sizeof(buffer), "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.

View File

@ -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)
{
ke::SafeSprintf(g_buffer, sizeof(g_buffer)-1, "%s", STRING(params[1]));
ke::SafeSprintf(g_buffer, sizeof(g_buffer), "%s", STRING(params[1]));
return MF_SetAmxString(amx, params[2], g_buffer, params[3]);
}

View File

@ -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];
ke::SafeSprintf(temp, sizeof(temp)-1, "%d", rets.i);
ke::SafeSprintf(temp, sizeof(temp), "%d", rets.i);
return MF_SetAmxString(amx, params[3], temp, size);
} else if (ValType == Ret_Float) {
char temp[32];
ke::SafeSprintf(temp, sizeof(temp)-1, "%f", rets.f);
ke::SafeSprintf(temp, sizeof(temp), "%f", rets.f);
return MF_SetAmxString(amx, params[3], temp, size);
} else if (ValType == Ret_Vec) {
char temp[32];
ke::SafeSprintf(temp, sizeof(temp)-1, "%f %f %f", vr.x, vr.y, vr.z);
ke::SafeSprintf(temp, sizeof(temp), "%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];
ke::SafeSprintf(temp, sizeof(temp)-1, "%d %d", rets.ba[0], rets.ba[1]);
ke::SafeSprintf(temp, sizeof(temp), "%d %d", rets.ba[0], rets.ba[1]);
return MF_SetAmxString(amx, params[3], temp, size);
} else if (ValType == Ret_Bytes4) {
char temp[32];
ke::SafeSprintf(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), "%d %d %d %d", rets.ba[0], rets.ba[1], rets.ba[2], rets.ba[3]);
return MF_SetAmxString(amx, params[3], temp, size);
}

View File

@ -192,7 +192,7 @@ bool loadDatabase()
// MF_BuildPathname not used because backslash
// makes CreateFileMapping failing under windows.
ke::SafeSprintf(file, sizeof(file) - 1, "%s/%s/GeoLite2-%s.mmdb", modName, dataDir, databases[i]);
ke::SafeSprintf(file, sizeof(file), "%s/%s/GeoLite2-%s.mmdb", modName, dataDir, databases[i]);
status = MMDB_open(file, MMDB_MODE_MMAP, &HandleDB);

View File

@ -109,7 +109,7 @@ static void read_mirror(char *input)
*data='\0';
// mark down the source
ke::SafeSprintf(source, sizeof(source)-1, "%s", input);
ke::SafeSprintf(source, sizeof(source), "%s", input);
*data=old;
@ -129,13 +129,13 @@ static void read_mirror(char *input)
old=*data;
*data='\0';
ke::SafeSprintf(dest, sizeof(dest)-1, "%s", data2);
ke::SafeSprintf(dest, sizeof(dest), "%s", data2);
*data=old;
if (strcmp(dest, CurrentModName)==0)
{
ke::SafeSprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", source);
ke::SafeSprintf(CurrentModName, sizeof(CurrentModName), "%s", source);
}
}
@ -314,7 +314,7 @@ int ReadConfig(void)
FILE *fp=fopen(FileName,"r");
ke::SafeSprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname());
ke::SafeSprintf(CurrentModName, sizeof(CurrentModName), "%s", MF_GetModname());
if (!fp)
{

View File

@ -22,12 +22,12 @@
#define CHECK_FUNCTION(x) \
if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \
char msg[1024]; \
ke::SafeSprintf(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), "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]; \
ke::SafeSprintf(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.", hooklist[x].name); \
ke::SafeSprintf(msg, sizeof(msg), "Function %s is not configured in hamdata.ini.", hooklist[x].name); \
FailPlugin(amx, x, HAM_FUNC_NOT_CONFIGURED, msg); \
return 0; \
}

View File

@ -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)
ke::SafeSprintf(classname, sizeof(classname) - 1, "%s", STRING(Entity->v.classname));
ke::SafeSprintf(classname, sizeof(classname), "%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);

View File

@ -26,7 +26,7 @@ void ParticleManager::ReadFile(void)
char FileName[256];
ke::SafeSprintf(FileName, sizeof(FileName)-1, "%s/ns.ps", MF_GetModname());
ke::SafeSprintf(FileName, sizeof(FileName), "%s/ns.ps", MF_GetModname());
FILE *fp=fopen(FileName,"r");
if (!fp)

View File

@ -27,7 +27,7 @@ void TitleManager::LoadTitles(void)
char FileName[128];
ke::SafeSprintf(FileName, sizeof(FileName)-1, "%s/titles.txt", MF_GetModname());
ke::SafeSprintf(FileName, sizeof(FileName), "%s/titles.txt", MF_GetModname());
FILE *fp=fopen(FileName,"r");

View File

@ -48,7 +48,7 @@ cell PSKeyValueI(const char *name, AMX *amx, cell *params)
char StrData[1024];
ke::SafeSprintf(StrData, sizeof(StrData)-1, "%d", params[2]);
ke::SafeSprintf(StrData, sizeof(StrData), "%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];
ke::SafeSprintf(StrData, sizeof(StrData)-1, "%f", amx_ctof2(params[2]));
ke::SafeSprintf(StrData, sizeof(StrData), "%f", amx_ctof2(params[2]));
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
kvd.szKeyName=name;