fix mapname autocompletion
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4067 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ alias editent [
|
||||
]
|
||||
|
||||
// Auto-completions
|
||||
alias mapcomplete [complete $arg1 "packages/maps" cgz]
|
||||
alias mapcomplete [complete $arg1 "packages/maps/official packages/maps" cgz]
|
||||
mapcommands = "map tdm coop dm lms ts ctf pf lss osok tosok htf vip tktf ktf"
|
||||
loop i (listlen $mapcommands) [
|
||||
mapcomplete (at $mapcommands $i)
|
||||
|
||||
+14
-2
@@ -518,10 +518,11 @@ struct completeval
|
||||
{
|
||||
int type;
|
||||
char *dir, *ext;
|
||||
vector<char *> dirlist;
|
||||
vector<char *> list;
|
||||
|
||||
completeval(int type, const char *dir, const char *ext) : type(type), dir(dir && dir[0] ? newstring(dir) : NULL), ext(ext && ext[0] ? newstring(ext) : NULL) {}
|
||||
~completeval() { DELETEA(dir); DELETEA(ext); list.deletecontentsa(); }
|
||||
~completeval() { DELETEA(dir); DELETEA(ext); dirlist.deletecontentsa(); list.deletecontentsa(); }
|
||||
};
|
||||
|
||||
static inline bool htcmp(const completekey &x, const completekey &y)
|
||||
@@ -556,6 +557,17 @@ void addcomplete(char *command, int type, char *dir, char *ext)
|
||||
{
|
||||
completeval *f = new completeval(type, dir, ext);
|
||||
if(type==COMPLETE_LIST) explodelist(dir, f->list);
|
||||
if(type==COMPLETE_FILE)
|
||||
{
|
||||
explodelist(dir, f->dirlist);
|
||||
loopv(f->dirlist)
|
||||
{
|
||||
char *dir = f->dirlist[i];
|
||||
int dirlen = (int)strlen(dir);
|
||||
while(dirlen > 0 && (dir[dirlen-1] == '/' || dir[dirlen-1] == '\\'))
|
||||
dir[--dirlen] = '\0';
|
||||
}
|
||||
}
|
||||
val = &completedata[completekey(type, f->dir, f->ext)];
|
||||
*val = f;
|
||||
}
|
||||
@@ -616,7 +628,7 @@ void commandcomplete(char *s)
|
||||
if(init && cdata && cdata->type==COMPLETE_FILE)
|
||||
{
|
||||
cdata->list.deletecontentsa();
|
||||
listfiles(cdata->dir, cdata->ext, cdata->list);
|
||||
loopv(cdata->dirlist) listfiles(cdata->dirlist[i], cdata->ext, cdata->list);
|
||||
}
|
||||
|
||||
if(*cp == '/' || *cp == ';')
|
||||
|
||||
@@ -268,16 +268,15 @@ int numspawn[3], maploaded = 0, numflagspawn[2];
|
||||
bool load_world(char *mname) // still supports all map formats that have existed since the earliest cube betas!
|
||||
{
|
||||
int loadmillis = SDL_GetTicks();
|
||||
bool isofficial = true;
|
||||
setnames(mname);
|
||||
maploaded = getfilesize(ocgzname);
|
||||
gzFile f = opengzfile(ocgzname, "rb9");
|
||||
if(!f)
|
||||
if(maploaded > 0)
|
||||
{
|
||||
maploaded = getfilesize(cgzname);
|
||||
f = opengzfile(cgzname, "rb9");
|
||||
isofficial = false;
|
||||
s_strcpy(cgzname, ocgzname);
|
||||
s_strcpy(mcfname, omcfname);
|
||||
}
|
||||
else maploaded = getfilesize(cgzname);
|
||||
gzFile f = opengzfile(cgzname, "rb9");
|
||||
if(!f) { conoutf("\f3could not read map %s", cgzname); return false; }
|
||||
header tmp;
|
||||
memset(&tmp, 0, sizeof(header));
|
||||
@@ -411,14 +410,14 @@ bool load_world(char *mname) // still supports all map formats that have
|
||||
if(f) gzclose(f);
|
||||
c2skeepalive();
|
||||
calclight();
|
||||
conoutf("read map %s (%d milliseconds)", isofficial ? ocgzname : cgzname, SDL_GetTicks()-loadmillis);
|
||||
conoutf("read map %s (%d milliseconds)", cgzname, SDL_GetTicks()-loadmillis);
|
||||
conoutf("%s", hdr.maptitle);
|
||||
|
||||
pushscontext(IEXC_MAPCFG); // untrusted altogether
|
||||
persistidents = false;
|
||||
execfile("config/default_map_settings.cfg");
|
||||
execfile(pcfname);
|
||||
execfile(isofficial ? omcfname : mcfname);
|
||||
execfile(mcfname);
|
||||
persistidents = true;
|
||||
popscontext();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user