mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 06:34:11 +00:00
rework the maplist code to use Con_DisplayList. this results in both
prettier code and prettier output.
This commit is contained in:
parent
e0dfa2b453
commit
460b53e9ee
1 changed files with 12 additions and 18 deletions
|
@ -67,6 +67,7 @@ static const char rcsid[] =
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "QF/cmd.h"
|
#include "QF/cmd.h"
|
||||||
|
#include "QF/console.h" //FIXME maplist really shouldn't be in here
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
#include "QF/hash.h"
|
#include "QF/hash.h"
|
||||||
#include "QF/qargs.h"
|
#include "QF/qargs.h"
|
||||||
|
@ -279,7 +280,9 @@ maplist_add_map (struct maplist *maplist, char *fname)
|
||||||
}
|
}
|
||||||
maplist->list = new_list;
|
maplist->list = new_list;
|
||||||
}
|
}
|
||||||
maplist->list[maplist->count++] = strdup (fname);
|
fname = strdup (fname);
|
||||||
|
*strstr (fname, ".bsp") = 0;
|
||||||
|
maplist->list[maplist->count++] = fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -287,34 +290,25 @@ maplist_cmp (const void *_a, const void *_b)
|
||||||
{
|
{
|
||||||
char *a = *(char **) _a;
|
char *a = *(char **) _a;
|
||||||
char *b = *(char **) _b;
|
char *b = *(char **) _b;
|
||||||
int al = strstr (a, ".bsp") - a;
|
|
||||||
int bl = strstr (b, ".bsp") - b;
|
|
||||||
int cmp = strncmp (a, b, min (al, bl));
|
|
||||||
|
|
||||||
if (cmp == 0)
|
return strcmp (a, b);
|
||||||
return al - bl;
|
|
||||||
return cmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maplist_print (struct maplist *maplist)
|
maplist_print (struct maplist *maplist)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *end;
|
const char **list;
|
||||||
char *name;
|
|
||||||
|
|
||||||
if (maplist->count) {
|
if (maplist->count) {
|
||||||
qsort (maplist->list, maplist->count, sizeof (char *), maplist_cmp);
|
qsort (maplist->list, maplist->count, sizeof (char *), maplist_cmp);
|
||||||
|
|
||||||
for (i = 0; i < maplist->count - 1; i++) {
|
list = (const char **)malloc (maplist->count + 1);
|
||||||
name = maplist->list[i];
|
list[maplist->count] = 0;
|
||||||
end = strstr (name, ".bsp");
|
for (i = 0; i < maplist->count; i++)
|
||||||
Sys_Printf ("%-8.*s%c", end - name, name,
|
list[i] = maplist->list[i];
|
||||||
((i + 1) % 4) ? ' ' : '\n');
|
Con_DisplayList (list, con_linewidth);
|
||||||
}
|
free (list);
|
||||||
name = maplist->list[i];
|
|
||||||
end = strstr (name, ".bsp");
|
|
||||||
Sys_Printf ("%-9.*s\n", end - name, name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue