mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 15:31:39 +00:00
console.c (BuildMapList, Con_TabComplete): fix sporadic erratic behaviour
with map name completion. from Steven. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@93 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
73b3628feb
commit
38cc82bde7
1 changed files with 7 additions and 4 deletions
|
@ -831,21 +831,22 @@ BuildMap -- stevenaaus
|
||||||
*/
|
*/
|
||||||
char *BuildMapList (char *partial)
|
char *BuildMapList (char *partial)
|
||||||
{
|
{
|
||||||
int i , match, plen;
|
|
||||||
static char matched[80];
|
static char matched[80];
|
||||||
char *i_matched, *i_name;
|
char *i_matched, *i_name;
|
||||||
extralevel_t *level;
|
extralevel_t *level;
|
||||||
|
int init, match, plen;
|
||||||
|
|
||||||
memset(matched, 0, 80);
|
memset(matched, 0, 80);
|
||||||
plen = strlen(partial);
|
plen = strlen(partial);
|
||||||
match = 0;
|
match = 0;
|
||||||
|
|
||||||
for (level = extralevels, i = 0; level; level = level->next, i++)
|
for (level = extralevels, init = 0; level; level = level->next)
|
||||||
{
|
{
|
||||||
if (!strncmp(level->name, partial, plen))
|
if (!strncmp(level->name, partial, plen))
|
||||||
{
|
{
|
||||||
if (!*matched)
|
if (init == 0)
|
||||||
{
|
{
|
||||||
|
init = 1;
|
||||||
strncpy (matched, level->name, 79);
|
strncpy (matched, level->name, 79);
|
||||||
matched[79] = '\0';
|
matched[79] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -868,7 +869,7 @@ char *BuildMapList (char *partial)
|
||||||
|
|
||||||
if (match > 1)
|
if (match > 1)
|
||||||
{
|
{
|
||||||
for (level = extralevels, i = 0; level; level = level->next, i++)
|
for (level = extralevels; level; level = level->next)
|
||||||
{
|
{
|
||||||
if (!strncmp(level->name, partial, plen))
|
if (!strncmp(level->name, partial, plen))
|
||||||
Con_SafePrintf (" %s\n", level->name);
|
Con_SafePrintf (" %s\n", level->name);
|
||||||
|
@ -951,12 +952,14 @@ void Con_TabComplete (void)
|
||||||
Q_strcpy (partial, matched_map);
|
Q_strcpy (partial, matched_map);
|
||||||
Q_strcpy (c, partial);
|
Q_strcpy (c, partial);
|
||||||
key_linepos = c - key_lines[edit_line] + Q_strlen(matched_map); //set new cursor position
|
key_linepos = c - key_lines[edit_line] + Q_strlen(matched_map); //set new cursor position
|
||||||
|
// if only one match, append a space
|
||||||
if ((key_lines[edit_line][key_linepos] == 0) && map_singlematch)
|
if ((key_lines[edit_line][key_linepos] == 0) && map_singlematch)
|
||||||
{
|
{
|
||||||
key_lines[edit_line][key_linepos] = ' ';
|
key_lines[edit_line][key_linepos] = ' ';
|
||||||
key_linepos++;
|
key_linepos++;
|
||||||
key_lines[edit_line][key_linepos] = 0;
|
key_lines[edit_line][key_linepos] = 0;
|
||||||
}
|
}
|
||||||
|
c = key_lines[edit_line] + key_linepos;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue