Skip to content

Commit

Permalink
Read local mod name from descript.ion file if present
Browse files Browse the repository at this point in the history
e.g. `alk1.2/descript.ion` would contain `Alkaline 1.2` on the first line

Note: only loose files are supported for now.
  • Loading branch information
andrei-drexler committed Mar 17, 2023
1 parent 66accd6 commit 52bbe28
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,14 +1073,44 @@ static void Modlist_Add (const char *name)
{
filelist_item_t *item;
modinfo_t *info;
size_t i;
int i;

memset (&info, 0, sizeof (info));
item = FileList_AddWithData (name, NULL, sizeof (*info), &modlist);

info = (modinfo_t *) (item + 1);
info->status.value = MODSTATUS_INSTALLED;

// look for descript.ion file in mod dir and use first non-empty line as full name
if (!info->full_name)
{
for (i = com_numbasedirs - 1; i >= 0; i--)
{
char path[MAX_OSPATH];
char *description, *end;

if (q_snprintf (path, sizeof (path), "%s/%s/descript.ion", com_basedirs[i], name) >= sizeof (path))
continue;

description = (char *) COM_LoadMallocFile_TextMode_OSPath (path, NULL);
if (!description)
continue;

while (q_isspace (*description))
++description;
end = strchr (description, '\n');
if (end)
*end = '\0';
if (*description)
info->full_name = strdup (description);
free (description);

This comment has been minimized.

Copy link
@sezero

sezero Mar 17, 2023

This is broken: you increment the pointer above to skip whitespace.

This comment has been minimized.

Copy link
@andrei-drexler

andrei-drexler Mar 17, 2023

Author Owner

Oh, good catch!

This comment has been minimized.

Copy link
@andrei-drexler

andrei-drexler Mar 17, 2023

Author Owner

Fixed in 5b130aa, thanks!


if (info->full_name)
break;
}
}

// look for mod in hard-coded list
if (!info->full_name)
{
for (i = 0; i < countof (knownmods); i++)
Expand Down

0 comments on commit 52bbe28

Please sign in to comment.