mirror of
https://github.com/yquake2/yquake2
synced 2026-08-20 00:26:04 -04:00
ARRLEN macro used where appropriate
Some consts are actually static
This commit is contained in:
parent
07b21602fd
commit
3d2df1a40a
7 changed files with 15 additions and 17 deletions
|
|
@ -108,7 +108,7 @@ static void SetExecutablePath(char* exePath)
|
|||
int name[4] = {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME};
|
||||
#endif
|
||||
size_t len = PATH_MAX-1;
|
||||
int ret = sysctl(name, sizeof(name)/sizeof(name[0]), exePath, &len, NULL, 0);
|
||||
int ret = sysctl(name, ARRLEN(name), exePath, &len, NULL, 0);
|
||||
if(ret != 0)
|
||||
{
|
||||
// an error occured, clear exe path
|
||||
|
|
|
|||
|
|
@ -622,7 +622,7 @@ Sys_Realpath(const char *in, char *out, size_t size)
|
|||
WCHAR win[MAX_OSPATH] = {0};
|
||||
WCHAR wconverted[MAX_OSPATH] = {0};
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, in, -1, win, sizeof(win)/sizeof(win[0]));
|
||||
MultiByteToWideChar(CP_UTF8, 0, in, -1, win, ARRLEN(win));
|
||||
|
||||
if (_wfullpath(wconverted, win, size) == NULL)
|
||||
{
|
||||
|
|
@ -706,7 +706,7 @@ Sys_GetWorkDir(char *buffer, size_t len)
|
|||
{
|
||||
WCHAR wbuffer[MAX_OSPATH];
|
||||
|
||||
if (GetCurrentDirectoryW(sizeof(wbuffer)/sizeof(wbuffer[0]), wbuffer) != 0)
|
||||
if (GetCurrentDirectoryW(ARRLEN(wbuffer), wbuffer) != 0)
|
||||
{
|
||||
WideCharToMultiByte(CP_UTF8, 0, wbuffer, -1, buffer, len, NULL, NULL);
|
||||
return;
|
||||
|
|
@ -720,7 +720,7 @@ Sys_SetWorkDir(char *path)
|
|||
{
|
||||
WCHAR wpath[MAX_OSPATH];
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, sizeof(wpath)/sizeof(wpath[0]));
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, ARRLEN(wpath));
|
||||
|
||||
if (SetCurrentDirectoryW(wpath) != 0)
|
||||
{
|
||||
|
|
@ -760,8 +760,8 @@ Sys_RedirectStdout(void)
|
|||
snprintf(path_stdout, sizeof(path_stdout), "%s/%s", dir, "stdout.txt");
|
||||
snprintf(path_stderr, sizeof(path_stderr), "%s/%s", dir, "stderr.txt");
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, path_stdout, -1, wpath_stdout, sizeof(wpath_stdout)/sizeof(wpath_stdout[0]));
|
||||
MultiByteToWideChar(CP_UTF8, 0, path_stderr, -1, wpath_stderr, sizeof(wpath_stderr)/sizeof( wpath_stderr[0] ) );
|
||||
MultiByteToWideChar(CP_UTF8, 0, path_stdout, -1, wpath_stdout, ARRLEN(wpath_stdout));
|
||||
MultiByteToWideChar(CP_UTF8, 0, path_stderr, -1, wpath_stderr, ARRLEN(wpath_stderr));
|
||||
|
||||
_wfreopen(wpath_stdout, L"w", stdout);
|
||||
_wfreopen(wpath_stderr, L"w", stderr);
|
||||
|
|
|
|||
|
|
@ -275,8 +275,6 @@ static char *gamepadbtns[] =
|
|||
"TRIG_RIGHT_ALT"
|
||||
};
|
||||
|
||||
#define NUM_GAMEPAD_BTNS (sizeof gamepadbtns / sizeof gamepadbtns[0])
|
||||
|
||||
static char *gpbtns_face[] =
|
||||
{
|
||||
// Xbox
|
||||
|
|
@ -822,6 +820,7 @@ Key_Message(int key)
|
|||
static int
|
||||
Key_StringToKeynum(char *str)
|
||||
{
|
||||
static const int num_gamepad_btns = ARRLEN(gamepadbtns);
|
||||
keyname_t *kn;
|
||||
int i;
|
||||
|
||||
|
|
@ -843,7 +842,7 @@ Key_StringToKeynum(char *str)
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_GAMEPAD_BTNS; i++)
|
||||
for (i = 0; i < num_gamepad_btns; i++)
|
||||
{
|
||||
if (!Q_stricmp(str, gamepadbtns[i]))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2804,7 +2804,7 @@ static const joy_preset_t joy_presets[] = {
|
|||
void
|
||||
IN_ApplyJoyPreset(void)
|
||||
{
|
||||
const int final_preset = ARRLEN(joy_presets) - 1;
|
||||
static const int final_preset = ARRLEN(joy_presets) - 1;
|
||||
const int i = lroundf(Q_clamp(joy_sensitivity->value, 0, final_preset));
|
||||
|
||||
joy_sensitivity->modified = false;
|
||||
|
|
@ -2822,7 +2822,7 @@ IN_ApplyJoyPreset(void)
|
|||
qboolean
|
||||
IN_MatchJoyPreset(void)
|
||||
{
|
||||
const int num_presets = ARRLEN(joy_presets);
|
||||
static const int num_presets = ARRLEN(joy_presets);
|
||||
|
||||
for (int i = 0; i < num_presets; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2773,7 +2773,7 @@ static const joy_preset_t joy_presets[] = {
|
|||
void
|
||||
IN_ApplyJoyPreset(void)
|
||||
{
|
||||
const int final_preset = ARRLEN(joy_presets) - 1;
|
||||
static const int final_preset = ARRLEN(joy_presets) - 1;
|
||||
const int i = lroundf(Q_clamp(joy_sensitivity->value, 0, final_preset));
|
||||
|
||||
joy_sensitivity->modified = false;
|
||||
|
|
@ -2791,7 +2791,7 @@ IN_ApplyJoyPreset(void)
|
|||
qboolean
|
||||
IN_MatchJoyPreset(void)
|
||||
{
|
||||
const int num_presets = ARRLEN(joy_presets);
|
||||
static const int num_presets = ARRLEN(joy_presets);
|
||||
|
||||
for (int i = 0; i < num_presets; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -167,8 +167,7 @@ static voidpf ZCALLBACK fopen_file_func_utf(voidpf opaque, const char *filename,
|
|||
|
||||
if (!((filename == NULL) || (mode_fopen == NULL)))
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename,
|
||||
sizeof(wfilename) / sizeof(*wfilename));
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, ARRLEN(wfilename));
|
||||
file = _wfopen((const wchar_t *) wfilename, mode_fopen);
|
||||
}
|
||||
|
||||
|
|
@ -1492,7 +1491,7 @@ static int
|
|||
Q_sort_modcmp(const void *p1, const void *p2)
|
||||
{
|
||||
static const char *first_mods[] = {BASEDIRNAME, "xatrix", "rogue", "ctf"};
|
||||
static const unsigned short int first_mods_qty = 4;
|
||||
static const unsigned short int first_mods_qty = ARRLEN(first_mods);
|
||||
|
||||
const char * s1 = * (char * const *)p1;
|
||||
const char * s2 = * (char * const *)p2;
|
||||
|
|
|
|||
|
|
@ -1104,7 +1104,7 @@ flooded(edict_t *ent)
|
|||
}
|
||||
|
||||
cl = ent->client;
|
||||
mx = sizeof(cl->flood_when) / sizeof(cl->flood_when[0]);
|
||||
mx = ARRLEN(cl->flood_when);
|
||||
|
||||
if (num_msgs > mx)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue