From 35ea2d7ad1d3c99246311161399600667d6c1f67 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 12 Dec 2006 07:25:01 +0000 Subject: [PATCH] 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 --- polymer/eduke32/source/game.c | 8 +++++++- polymer/eduke32/source/gamedef.c | 15 +++++++++++---- polymer/eduke32/source/menus.c | 6 ++---- polymer/eduke32/source/osdcmds.c | 8 ++++++-- polymer/eduke32/source/premap.c | 4 +++- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 0bb03f0cf..d860be280 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -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); diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 3455b829e..9ecd0ed5d 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -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)); diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 7aff1d068..5b3970df0 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -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(); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 65e91f8e3..a67be6b41 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -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; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index f09774dc2..4a18662e8 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -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)