Take over more correct G_AddGroup from game.c to astub.c.

The code in the editor was potentially doing a strcat on a strdup'd string.
Also, rename AddGamePath to G_AddPath in astub.c and add CODEDUP markers
because shared stuff like this ought to be factored out into a separate
source file some time.

git-svn-id: https://svn.eduke32.com/eduke32@2531 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-03-25 22:00:42 +00:00
parent 694acef9fe
commit c4efd9b1fa
2 changed files with 23 additions and 14 deletions

View file

@ -8380,10 +8380,11 @@ static void G_ShowParameterHelp(void)
wm_msgbox(tempbuf, "%s", s);
}
static void AddGamePath(const char *buffer)
// CODEDUP game.c
static void G_AddPath(const char *buffer)
{
struct strllist *s;
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
struct strllist *s = Bcalloc(1,sizeof(struct strllist));
s->str = Bstrdup(buffer);
if (CommandPaths)
@ -8393,16 +8394,23 @@ static void AddGamePath(const char *buffer)
t->next = s;
return;
}
CommandPaths = s;
}
// CODEDUP game.c
static void G_AddGroup(const char *buffer)
{
struct strllist *s;
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
s->str = Bstrdup(buffer);
if (Bstrchr(s->str,'.') == 0)
Bstrcat(s->str,".grp");
char buf[BMAX_PATH];
struct strllist *s = Bcalloc(1,sizeof(struct strllist));
Bstrcpy(buf, buffer);
if (Bstrchr(buf,'.') == 0)
Bstrcat(buf,".grp");
s->str = Bstrdup(buf);
if (CommandGrps)
{
@ -8498,7 +8506,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
#endif
Bstrncpy(g_modDir, argv[i+1], sizeof(g_modDir));
g_modDir[sizeof(g_modDir)-1] = 0;
AddGamePath(argv[i+1]);
G_AddPath(argv[i+1]);
COPYARG(i);
COPYARG(i+1);
@ -8685,7 +8693,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
case 'J':
c++;
if (!*c) break;
AddGamePath(c);
G_AddPath(c);
COPYARG(i);
break;
case 'g':

View file

@ -8567,12 +8567,13 @@ static int32_t loaddefinitions_game(const char *fn, int32_t preload)
return 0;
}
// CODEDUP astub.c
static void G_AddGroup(const char *buffer)
{
struct strllist *s;
char buf[BMAX_PATH];
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
struct strllist *s = Bcalloc(1,sizeof(struct strllist));
Bstrcpy(buf, buffer);
@ -8591,10 +8592,10 @@ static void G_AddGroup(const char *buffer)
CommandGrps = s;
}
// CODEDUP astub.c
static void G_AddPath(const char *buffer)
{
struct strllist *s;
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
struct strllist *s = Bcalloc(1,sizeof(struct strllist));
s->str = Bstrdup(buffer);
if (CommandPaths)