Use a constant for file path stuff

This commit is contained in:
NepDisk 2025-10-17 12:21:54 -04:00
parent b9a2878c11
commit bf93fafa27
4 changed files with 10 additions and 8 deletions

View file

@ -44,7 +44,7 @@ consvar_t cv_addons_search_case = CVAR_INIT ("addons_search_case", "No", CV_SAVE
static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}};
consvar_t cv_addons_search_type = CVAR_INIT ("addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL);
char menupath[1024];
char menupath[MAXFILEPATH];
size_t menupathindex[menudepth];
size_t menudepthleft = menudepth;
@ -68,7 +68,7 @@ filestatus_t filesearch(char *filename, const char *startpath, UINT64 wantedhash
int found = 0;
char *searchname = strdup(filename);
int depthleft = maxsearchdepth;
char searchpath[1024];
char searchpath[MAXFILEPATH];
size_t *searchpathindex;
dirhandle = (DIR**) malloc(maxsearchdepth * sizeof (DIR*));

View file

@ -35,7 +35,8 @@ filestatus_t filesearch(char *filename, const char *startpath, UINT64 wantedhash
#define menudepth 20
extern char menupath[1024];
#define MAXFILEPATH 1024
extern char menupath[MAXFILEPATH];
extern size_t menupathindex[menudepth];
extern size_t menudepthleft;

View file

@ -18,6 +18,7 @@
#include "doomstat.h"
#include "d_event.h"
#include "m_textinput.h"
#include "filesrch.h"
#ifdef __cplusplus
extern "C" {
@ -91,7 +92,7 @@ typedef enum {
} menudemotype_e;
struct menudemo_t {
char filepath[1024];
char filepath[MAXFILEPATH];
menudemotype_e type;
char title[65]; // Null-terminated for string prints

View file

@ -3327,7 +3327,7 @@ INT32 MR_Addons(INT32 choice)
if (cv_addons_option.value == 3 && *cv_addons_folder.string != '\0')
pathname = cv_addons_folder.string;
strlcpy(menupath, pathname, 1024);
strlcpy(menupath, pathname, MAXFILEPATH);
menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath) + 1;
if (menupath[menupathindex[menudepthleft]-2] != PATHSEP[0])
@ -3425,9 +3425,9 @@ static void M_DrawTemperature(INT32 x, fixed_t t)
static char *M_AddonsHeaderPath(void)
{
UINT32 len;
static char header[1024];
static char header[MAXFILEPATH];
strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), 1024);
strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), MAXFILEPATH);
len = strlen(header);
if (len > 34)
{
@ -3830,7 +3830,7 @@ static void PrepReplayList(void)
else
{
demolist[i].type = MD_NOTLOADED;
snprintf(demolist[i].filepath, 1024, "%s%s", menupath, dirmenu[i] + DIR_STRING);
snprintf(demolist[i].filepath, MAXFILEPATH, "%s%s", menupath, dirmenu[i] + DIR_STRING);
sprintf(demolist[i].title, ".....");
}
}