mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
config.c: fix an overlapping strcpy() in CONFIG_SetMapBestTime().
git-svn-id: https://svn.eduke32.com/eduke32@5193 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
dd2f06b869
commit
c3b3b376fa
2 changed files with 19 additions and 22 deletions
|
@ -983,46 +983,43 @@ void CONFIG_WriteSetup(uint32_t flags)
|
|||
Bfflush(NULL);
|
||||
}
|
||||
|
||||
|
||||
int32_t CONFIG_GetMapBestTime(char *mapname)
|
||||
static const char *CONFIG_GetMapEntryName(char m[], const char *mapname)
|
||||
{
|
||||
int32_t t = -1;
|
||||
char m[BMAX_PATH], *p;
|
||||
|
||||
strcpy(m, mapname);
|
||||
p = strrchr(m, '/');
|
||||
|
||||
char *p = strrchr(m, '/');
|
||||
if (!p) p = strrchr(m, '\\');
|
||||
if (p) Bmemmove(m, p, Bstrlen(p)+1);//strcpy(m, p);
|
||||
if (p) Bmemmove(m, p, Bstrlen(p)+1);
|
||||
for (p=m; *p; p++) *p = tolower(*p);
|
||||
|
||||
// cheap hack because SCRIPT_GetNumber doesn't like the slashes
|
||||
p = m;
|
||||
while (*p == '/') p++;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
int32_t CONFIG_GetMapBestTime(const char *mapname)
|
||||
{
|
||||
if (!ud.config.setupread) return -1;
|
||||
if (ud.config.scripthandle < 0) return -1;
|
||||
|
||||
char m[BMAX_PATH];
|
||||
const char *p = CONFIG_GetMapEntryName(m, mapname);
|
||||
|
||||
int32_t t = -1;
|
||||
SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", p, &t);
|
||||
return t;
|
||||
}
|
||||
|
||||
int32_t CONFIG_SetMapBestTime(char *mapname, int32_t tm)
|
||||
int32_t CONFIG_SetMapBestTime(const char *mapname, int32_t tm)
|
||||
{
|
||||
char m[BMAX_PATH], *p;
|
||||
|
||||
strcpy(m, mapname);
|
||||
p = strrchr(m, '/');
|
||||
if (!p) p = strrchr(m, '\\');
|
||||
if (p) strcpy(m, p);
|
||||
for (p=m; *p; p++) *p = tolower(*p);
|
||||
|
||||
// cheap hack because SCRIPT_GetNumber doesn't like the slashes
|
||||
p = m;
|
||||
while (*p == '/') p++;
|
||||
|
||||
if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(setupfilename);
|
||||
if (ud.config.scripthandle < 0) return -1;
|
||||
|
||||
char m[BMAX_PATH];
|
||||
const char *p = CONFIG_GetMapEntryName(m, mapname);
|
||||
|
||||
SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", p, tm, FALSE, FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ void CONFIG_SetupMouse( void );
|
|||
void CONFIG_SetupJoystick( void );
|
||||
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN]);
|
||||
|
||||
int32_t CONFIG_GetMapBestTime(char *mapname);
|
||||
int32_t CONFIG_SetMapBestTime(char *mapname, int32_t tm);
|
||||
int32_t CONFIG_GetMapBestTime(const char *mapname);
|
||||
int32_t CONFIG_SetMapBestTime(const char *mapname, int32_t tm);
|
||||
|
||||
void CONFIG_MapKey(int32_t which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2);
|
||||
|
||||
|
|
Loading…
Reference in a new issue