* Add support for .kart files.

* Wrap behind-the-scenes `addfile/exec` contents in quotation marks to allow for files with spaces in them.
This commit is contained in:
toaster 2018-08-29 14:19:08 +01:00
parent 0776460643
commit 7a758708c6
3 changed files with 10 additions and 7 deletions

View file

@ -550,9 +550,9 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
return retval;
}
char exttable[NUM_EXT_TABLE][5] = {
".txt", ".cfg", // exec
".wad", /*".pk3",*/ ".soc", ".lua"}; // addfile
char exttable[NUM_EXT_TABLE][7] = { // maximum extension length (currently 4) plus 3 (null terminator, stop, and length including previous two)
"\5.txt", "\5.cfg", // exec
"\5.wad", "\6.kart", /*"\5.pk3",*/ "\5.soc", "\5.lua"}; // addfile
char filenamebuf[MAX_WADFILES][MAX_WADPATH];
@ -760,7 +760,7 @@ boolean preparefilemenu(boolean samedepth)
size_t len = strlen(dent->d_name)+1;
UINT8 ext;
for (ext = 0; ext < NUM_EXT_TABLE; ext++)
if (!strcasecmp(exttable[ext], dent->d_name+len-5)) break; // extension comparison
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) break; // extension comparison
if (ext == NUM_EXT_TABLE) continue; // not an addfile-able (or exec-able) file
}
}
@ -826,7 +826,7 @@ boolean preparefilemenu(boolean samedepth)
{
if (!((numfolders+pos) < sizecoredirmenu)) continue; // crash prevention
for (; ext < NUM_EXT_TABLE; ext++)
if (!strcasecmp(exttable[ext], dent->d_name+len-5)) break; // extension comparison
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) break; // extension comparison
if (ext == NUM_EXT_TABLE && !cv_addons_showall.value) continue; // not an addfile-able (or exec-able) file
ext += EXT_START; // moving to be appropriate position

View file

@ -55,6 +55,7 @@ typedef enum
EXT_CFG,
EXT_LOADSTART,
EXT_WAD = EXT_LOADSTART,
EXT_KART,
//EXT_PK3,
EXT_SOC,
EXT_LUA, // allowed even if not HAVE_BLUA so that we can yell on load attempt

View file

@ -4341,6 +4341,7 @@ static void M_Addons(INT32 choice)
addonsp[EXT_TXT] = W_CachePatchName("M_FTXT", PU_STATIC);
addonsp[EXT_CFG] = W_CachePatchName("M_FCFG", PU_STATIC);
addonsp[EXT_WAD] = W_CachePatchName("M_FWAD", PU_STATIC);
addonsp[EXT_KART] = W_CachePatchName("M_FKART", PU_STATIC);
//addonsp[EXT_PK3] = W_CachePatchName("M_FPK3", PU_STATIC);
addonsp[EXT_SOC] = W_CachePatchName("M_FSOC", PU_STATIC);
addonsp[EXT_LUA] = W_CachePatchName("M_FLUA", PU_STATIC);
@ -4610,7 +4611,7 @@ static void M_AddonExec(INT32 ch)
return;
S_StartSound(NULL, sfx_zoom);
COM_BufAddText(va("exec %s%s", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
COM_BufAddText(va("exec \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
}
#define len menusearch[0]
@ -4762,8 +4763,9 @@ static void M_HandleAddons(INT32 choice)
// else intentional fallthrough
case EXT_SOC:
case EXT_WAD:
case EXT_KART:
//case EXT_PK3:
COM_BufAddText(va("addfile %s%s", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
COM_BufAddText(va("addfile \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
break;
default:
S_StartSound(NULL, sfx_lose);