Make sure map filenames always get slashes prepended to them, to make sure getlevelfromfilename() doesn't fail

git-svn-id: https://svn.eduke32.com/eduke32@412 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-12-12 07:25:01 +00:00
parent 75563afd01
commit 35ea2d7ad1
5 changed files with 29 additions and 12 deletions

View file

@ -859,6 +859,7 @@ void getpackets(void)
Bstrcpy(boardfilename,packbuf+1);
boardfilename[packbufleng-1] = 0;
Bcorrectfilename(boardfilename,0);
if (boardfilename[0] != 0)
{
if ((i = kopen4load(boardfilename,0)) < 0)
@ -9326,7 +9327,8 @@ static void Startup(long argc, char **argv)
{
char *dot, *slash;
Bstrcpy(boardfilename, CommandMap);
boardfilename[0] = '/';
Bstrcat(boardfilename, CommandMap);
dot = Bstrrchr(boardfilename,'.');
slash = Bstrrchr(boardfilename,'/');
@ -9335,6 +9337,8 @@ static void Startup(long argc, char **argv)
if ((!slash && !dot) || (slash && dot < slash))
Bstrcat(boardfilename,".map");
Bcorrectfilename(boardfilename,0);
i = kopen4load(boardfilename,0);
if (i!=-1)
{
@ -9492,6 +9496,8 @@ void sendboardname(void)
tempbuf[0] = 9;
tempbuf[1] = 0;
Bcorrectfilename(boardfilename,0);
j = Bstrlen(boardfilename);
boardfilename[j] = 0;
Bstrcat(tempbuf+1,boardfilename);

View file

@ -1868,12 +1868,15 @@ static char parsecommand(void)
if (*textptr == 0) break;
}
j = 0;
tempbuf[j] = '/';
while (isaltok(*(textptr+j)))
{
tempbuf[j] = textptr[j];
tempbuf[j+1] = textptr[j];
j++;
}
tempbuf[j] = '\0';
tempbuf[j+1] = '\0';
Bcorrectfilename(tempbuf,0);
if (music_fn[k][i] == NULL)
music_fn[k][i] = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char));
@ -4023,9 +4026,11 @@ repeatcase:
i = 0;
tempbuf[i] = '/';
while (*textptr != ' ' && *textptr != '\t' && *textptr != 0x0a)
{
tempbuf[i] = *textptr;
tempbuf[i+1] = *textptr;
textptr++,i++;
if (i >= BMAX_PATH)
{
@ -4035,7 +4040,9 @@ repeatcase:
break;
}
}
tempbuf[i] = '\0';
tempbuf[i+1] = '\0';
Bcorrectfilename(tempbuf,0);
if (level_file_names[j*MAXLEVELS+k] == NULL)
level_file_names[j*MAXLEVELS+k] = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char));

View file

@ -2002,10 +2002,8 @@ cheat_for_port_credits:
break;
case 101:
// everything seems to work fine without this...
// if (boardfilename[0] == 0) strcpy(boardfilename, "./");
// Bcorrectfilename(boardfilename,1);
if (boardfilename[0] == 0) strcpy(boardfilename, "./");
Bcorrectfilename(boardfilename,1);
getfilenames(boardfilename,"*.map");
cmenu(102);
KB_FlushKeyboardQueue();

View file

@ -138,8 +138,8 @@ int osdcmd_map(const osdfuncparm_t *parm)
OSD_Printf("Command not allowed in multiplayer\n");
return OSDCMD_OK;
}
strcpy(filename,parm->parms[0]);
filename[0] = '/';
strcat(filename,parm->parms[0]);
if (strchr(filename,'.') == 0)
strcat(filename,".map");
@ -152,6 +152,8 @@ int osdcmd_map(const osdfuncparm_t *parm)
strcpy(boardfilename, filename);
Bcorrectfilename(boardfilename,0);
if (ps[myconnectindex].gm & MODE_GAME)
{
// in-game behave like a cheat
@ -770,6 +772,8 @@ int osdcmd_mpmap(const osdfuncparm_t *parm)
strcpy(boardfilename, filename);
Bcorrectfilename(boardfilename,0);
sendboardname();
return OSDCMD_OK;

View file

@ -1535,7 +1535,7 @@ extern void adduserquote(char *daquote);
extern int gotvote[MAXPLAYERS], votes[MAXPLAYERS], voting, vote_map, vote_episode;
static void getlevelfromfilename(char *fn, char *volume, char *level)
static void getlevelfromfilename(const char *fn, char *volume, char *level)
{
for ((*volume)=0;(*volume)<MAXVOLUMES;(*volume)++)
{
@ -1588,6 +1588,8 @@ int enterlevel(char g)
{
char volume, level;
Bcorrectfilename(boardfilename,0);
getlevelfromfilename(boardfilename,&volume,&level);
if (level != MAXLEVELS)