Name map best time entries in the cfg by MD4 checksum instead of filename.

Existing filename-demarcated personal bests are still read as a fallback if an MD4 is not found, but only MD4 entries are written.

Fans of both Lunar Apocalypse and Nuclear Winter should sort out the MapTimes section of their cfg file manually.

git-svn-id: https://svn.eduke32.com/eduke32@5470 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-12-20 05:18:59 +00:00
parent a5367ed600
commit 1ea0796b43
4 changed files with 26 additions and 13 deletions

View file

@ -967,7 +967,7 @@ void CONFIG_WriteSetup(uint32_t flags)
Bfflush(NULL);
}
static const char *CONFIG_GetMapEntryName(char m[], const char *mapname)
static const char *CONFIG_GetMapEntryName(char m[], char const * const mapname)
{
strcpy(m, mapname);
@ -983,28 +983,41 @@ static const char *CONFIG_GetMapEntryName(char m[], const char *mapname)
return p;
}
int32_t CONFIG_GetMapBestTime(const char *mapname)
static void CONFIG_GetMD4EntryName(char m[], uint8_t const * const md4)
{
sprintf(m, "MD4_%08x%08x%08x%08x",
B_BIG32(B_UNBUF32(&md4[0])), B_BIG32(B_UNBUF32(&md4[4])),
B_BIG32(B_UNBUF32(&md4[8])), B_BIG32(B_UNBUF32(&md4[12])));
}
int32_t CONFIG_GetMapBestTime(char const * const mapname, uint8_t const * const mapmd4)
{
if (!ud.config.setupread) return -1;
if (ud.config.scripthandle < 0) return -1;
char m[BMAX_PATH];
const char *p = CONFIG_GetMapEntryName(m, mapname);
char m[37];
CONFIG_GetMD4EntryName(m, mapmd4);
int32_t t = -1;
if (SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", m, &t))
{
// fall back to map filenames
char m2[BMAX_PATH];
char const * const p = CONFIG_GetMapEntryName(m2, mapname);
SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", p, &t);
}
return t;
}
int32_t CONFIG_SetMapBestTime(const char *mapname, int32_t tm)
int32_t CONFIG_SetMapBestTime(uint8_t const * const mapmd4, int32_t const tm)
{
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);
char m[37];
CONFIG_GetMD4EntryName(m, mapmd4);
SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", p, tm, FALSE, FALSE);
SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", m, tm, FALSE, FALSE);
return 0;
}

View file

@ -32,8 +32,8 @@ void CONFIG_SetupMouse( void );
void CONFIG_SetupJoystick( void );
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN]);
int32_t CONFIG_GetMapBestTime(const char *mapname);
int32_t CONFIG_SetMapBestTime(const char *mapname, int32_t tm);
int32_t CONFIG_GetMapBestTime(char const * mapname, uint8_t const * mapmd4);
int32_t CONFIG_SetMapBestTime(uint8_t const * mapmd4, int32_t tm);
void CONFIG_MapKey(int32_t which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2);

View file

@ -12944,7 +12944,7 @@ void G_BonusScreen(int32_t bonusonly)
totalclock = 0;
if (g_player[myconnectindex].ps->player_par > 0 && (g_player[myconnectindex].ps->player_par < ud.playerbest || ud.playerbest < 0))
CONFIG_SetMapBestTime(MapInfo[G_LastMapInfoIndex()].filename, g_player[myconnectindex].ps->player_par);
CONFIG_SetMapBestTime(g_loadedMapHack.md4, g_player[myconnectindex].ps->player_par);
do
{

View file

@ -1929,7 +1929,7 @@ int32_t G_EnterLevel(int32_t g)
G_AlignWarpElevators();
resetpspritevars(g);
ud.playerbest = CONFIG_GetMapBestTime(MapInfo[mii].filename);
ud.playerbest = CONFIG_GetMapBestTime(G_HaveUserMap() ? boardfilename : MapInfo[mii].filename, g_loadedMapHack.md4);
G_FadeLoad(0,0,0, 252,0, -28, 4, -1);
G_CacheMapData();