- started transitioning to a global mapinfo list.

This will make it a lot easier for cross-game parts of the engine to query game state.
So far the EDuke frontend has been ported over.
This commit is contained in:
Christoph Oelckers 2019-12-10 00:01:45 +01:00
parent 16818d2d71
commit 3b57f38e55
14 changed files with 137 additions and 104 deletions

View file

@ -26,10 +26,14 @@
#include "menu.h"
#include "gstrings.h"
#include "quotemgr.h"
#include "mapinfo.h"
#ifndef NETCODE_DISABLE
#include "enet.h"
#endif
MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts.
MapRecord *currentLevel;
void C_CON_SetAliases();
InputState inputState;
void SetClipshapes();

41
source/common/mapinfo.h Normal file
View file

@ -0,0 +1,41 @@
#pragma once
#include "gstrings.h"
// Localization capable replacement of the game specific solutions.
inline void MakeStringLocalizable(FString &quote)
{
// Only prepend a quote if the string is localizable.
if (quote.Len() > 0 && quote[0] != '$' && GStrings[quote]) quote.Insert(0, "$");
}
struct MapRecord
{
int parTime;
int designerTime;
FString fileName;
FString name;
FString music;
int cdSongId;
// The rest is only used by Blood
int nextLevel;
int nextSecret;
int messageStart; // messages are stored in the quote array to reduce clutter.
FString author;
// bool fog, weather; // Blood defines these but they aren't used.
const char *DisplayName()
{
return GStrings.localize(name);
}
void SetName(const char *n)
{
name = n;
MakeStringLocalizable(name);
}
};
extern MapRecord mapList[512];
extern MapRecord *currentLevel;

View file

@ -42,7 +42,8 @@
void Quotes::MakeStringLabel(FString &quote)
{
quote.Insert(0, "$");
// Only prepend a quote if the string is localizable.
if (quote.Len() > 0 && quote[0] != '$' && GStrings[quote]) quote.Insert(0, "$");
}
void Quotes::InitializeQuote(int num, const char *text, bool fromscript)

View file

@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "duke3d.h"
#include "osdcmds.h"
#include "mapinfo.h"
BEGIN_DUKE_NS
@ -555,7 +556,7 @@ void G_DoCheats(void)
int32_t const volnume = ud.m_volume_number, levnume = m_level_number;
if ((!VOLUMEONE || volnume == 0) && (unsigned)volnume < (unsigned)g_volumeCnt &&
(unsigned)levnume < MAXLEVELS && g_mapInfo[volnume*MAXLEVELS + levnume].filename != NULL)
(unsigned)levnume < MAXLEVELS && mapList[volnume*MAXLEVELS + levnume].fileName.IsNotEmpty())
{
ud.volume_number = volnume;
ud.level_number = levnume;

View file

@ -48,6 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "filesystem/filesystem.h"
#include "statistics.h"
#include "menu/menu.h"
#include "mapinfo.h"
// Uncomment to prevent anything except mirrors from drawing. It is sensible to
// also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
@ -4814,7 +4815,8 @@ static int32_t S_DefineMusic(const char *ID, const char *name)
return -1;
}
return S_DefineAudioIfSupported(&g_mapInfo[sel].musicfn, name);
mapList[sel].music = name;
return 0;
}
static int parsedefinitions_game(scriptfile *, int);
@ -5389,10 +5391,6 @@ static void G_Cleanup(void)
for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music
{
Xfree(g_mapInfo[i].name);
Xfree(g_mapInfo[i].filename);
Xfree(g_mapInfo[i].musicfn);
G_FreeMapState(i);
}

View file

@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "m_argv.h"
#include "menu/menu.h"
#include "stringtable.h"
#include "mapinfo.h"
void C_CON_SetButtonAlias(int num, const char* text);
void C_CON_ClearButtonAlias(int num);
@ -2029,10 +2030,7 @@ void C_DefineMusic(int volumeNum, int levelNum, const char *fileName)
if (strcmp(fileName, "/.") == 0)
return;
map_t *const pMapInfo = &g_mapInfo[(MAXLEVELS*volumeNum)+levelNum];
Xfree(pMapInfo->musicfn);
pMapInfo->musicfn = dup_filename(fileName);
mapList[(MAXLEVELS * volumeNum) + levelNum].music = fileName;
}
void C_DefineVolumeFlags(int32_t vol, int32_t flags)
@ -2084,12 +2082,12 @@ void C_UndefineLevel(int32_t vol, int32_t lev)
Bassert((unsigned)vol < MAXVOLUMES);
Bassert((unsigned)lev < MAXLEVELS);
map_t *const map = &g_mapInfo[(MAXLEVELS*vol)+lev];
auto& gmap = mapList[(MAXLEVELS * vol) + lev];
DO_FREE_AND_NULL(map->filename);
DO_FREE_AND_NULL(map->name);
map->partime = 0;
map->designertime = 0;
gmap.fileName = "";
gmap.name = "";
gmap.parTime = 0;
gmap.designerTime = 0;
}
LUNATIC_EXTERN int32_t C_SetDefName(const char *name)
@ -5174,16 +5172,11 @@ repeatcase:
Bcorrectfilename(tempbuf,0);
if (g_mapInfo[j *MAXLEVELS+k].filename == NULL)
g_mapInfo[j *MAXLEVELS+k].filename = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t));
else if ((Bstrlen(tempbuf)+1) > sizeof(g_mapInfo[j*MAXLEVELS+k].filename))
g_mapInfo[j *MAXLEVELS+k].filename = (char *)Xrealloc(g_mapInfo[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1));
Bstrcpy(g_mapInfo[j*MAXLEVELS+k].filename,tempbuf);
mapList[j * MAXLEVELS + k].fileName = tempbuf;
C_SkipComments();
g_mapInfo[j *MAXLEVELS+k].partime =
mapList[j *MAXLEVELS+k].parTime =
(((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*REALGAMETICSPERSEC*60)+
(((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*REALGAMETICSPERSEC);
@ -5193,7 +5186,7 @@ repeatcase:
// cheap hack, 0.99 doesn't have the 3D Realms time
if (*(textptr+2) == ':')
{
g_mapInfo[j *MAXLEVELS+k].designertime =
mapList[j *MAXLEVELS+k].designerTime =
(((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*REALGAMETICSPERSEC*60)+
(((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*REALGAMETICSPERSEC);
@ -5220,14 +5213,7 @@ repeatcase:
tempbuf[i] = '\0';
if (g_mapInfo[j*MAXLEVELS+k].name == NULL)
g_mapInfo[j*MAXLEVELS+k].name = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t));
else if ((Bstrlen(tempbuf)+1) > sizeof(g_mapInfo[j*MAXLEVELS+k].name))
g_mapInfo[j *MAXLEVELS+k].name = (char *)Xrealloc(g_mapInfo[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1));
/* initprintf("level name string len: %d\n",Bstrlen(tempbuf)); */
Bstrcpy(g_mapInfo[j*MAXLEVELS+k].name,tempbuf);
mapList[j * MAXLEVELS + k].SetName(tempbuf);
continue;

View file

@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "menu/menu.h"
#include "c_dispatch.h"
#include "quotemgr.h"
#include "mapinfo.h"
#include "debugbreak.h"
extern bool rotatesprite_2doverride;
@ -3752,13 +3753,13 @@ badindex:
int const levelNum = ud.volume_number * MAXLEVELS + ud.level_number;
const char *pName;
if (EDUKE32_PREDICT_FALSE((unsigned)levelNum >= ARRAY_SIZE(g_mapInfo)))
if (EDUKE32_PREDICT_FALSE((unsigned)levelNum >= ARRAY_SIZE(mapList)))
{
CON_ERRPRINTF("out of bounds map number (vol=%d, lev=%d)\n", ud.volume_number, ud.level_number);
abort_after_error();
}
pName = j == STR_MAPNAME ? g_mapInfo[levelNum].name : g_mapInfo[levelNum].filename;
pName = j == STR_MAPNAME ? mapList[levelNum].DisplayName() : mapList[levelNum].fileName.GetChars();
if (EDUKE32_PREDICT_FALSE(pName == NULL))
{
@ -3767,7 +3768,7 @@ badindex:
abort_after_error();
}
quoteMgr.InitializeQuote(q, j == STR_MAPNAME ? g_mapInfo[levelNum].name : g_mapInfo[levelNum].filename);
quoteMgr.InitializeQuote(q, j == STR_MAPNAME ? mapList[levelNum].DisplayName() : mapList[levelNum].fileName.GetChars());
break;
}
case STR_PLAYERNAME:

View file

@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "savegame.h"
#include "input.h"
#include "gamecvars.h"
#include "mapinfo.h"
#include "enet.h"
#include "m_crc32.h"
@ -2037,7 +2038,7 @@ static void Net_ReceiveMapVoteInitiate(uint8_t *pbuf)
vote_map = pendingnewgame.level_number;
Bsprintf(tempbuf, GStrings("votemap"), g_player[voting].user_name,
g_mapInfo[(uint8_t)(vote_episode * MAXLEVELS + vote_map)].name, vote_episode + 1, vote_map + 1);
mapList[(uint8_t)(vote_episode * MAXLEVELS + vote_map)].DisplayName(), vote_episode + 1, vote_map + 1);
G_AddUserQuote(tempbuf);
strcpy(tempbuf, GStrings("TXT_PRESSF1_F2"));

View file

@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "menus.h"
#include "savegame.h"
#include "sbar.h"
#include "mapinfo.h"
BEGIN_DUKE_NS
@ -59,7 +60,7 @@ static int osdcmd_changelevel(osdcmdptr_t parm)
if (volume < 0 || level < 0)
return OSDCMD_SHOWHELP;
if (level > MAXLEVELS || g_mapInfo[volume * MAXLEVELS + level].filename == NULL)
if (level > MAXLEVELS || mapList[volume * MAXLEVELS + level].fileName.IsEmpty())
{
OSD_Printf("changelevel: no map defined for episode %d level %d\n", volume + 1, level + 1);
return OSDCMD_SHOWHELP;

View file

@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "savegame.h"
#include "statistics.h"
#include "menu/menu.h"
#include "mapinfo.h"
#include "cmdlib.h"
BEGIN_DUKE_NS
static uint8_t precachehightile[2][(MAXTILES+7)>>3];
@ -379,9 +381,7 @@ static void G_DoLoadScreen(const char *statustext, int percent)
else
{
menutext_center(90, GStrings("TXT_LOADING"));
if (g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
menutext_center(90+16+8, g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name);
menutext_center(90+16+8, mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].DisplayName());
}
#ifndef EDUKE32_TOUCH_DEVICES
@ -1621,13 +1621,11 @@ int G_FindLevelByFile(const char *fileName)
{
int i = 0;
for (auto &levelNum : g_mapInfo)
for (auto &levelNum : mapList)
{
i++;
if (levelNum.filename == NULL)
continue;
else if (!Bstrcasecmp(fileName, levelNum.filename))
if (levelNum.fileName.CompareNoCase(fileName) == 0)
return i-1;
}
@ -1691,20 +1689,18 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName)
{
char *p;
char const *exts[] = {
#ifdef HAVE_FLAC
"flac",
#endif
#ifdef HAVE_VORBIS
"ogg",
#endif
#ifdef HAVE_XMP
"mp3",
"xm",
"mod",
"it",
"s3m",
"mtm",
#endif
"mid"
"mid",
"hmp",
"hmi",
"xmi"
};
Bstrncpy(nameBuf, fileName, BMAX_PATH);
@ -1717,31 +1713,32 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName)
p[0] = '.';
}
// Test if a real file with this name exists with all known extensions for music.
for (auto & ext : exts)
{
Bmemcpy(p+1, ext, Bstrlen(ext) + 1);
if (fileSystem.FileExists(nameBuf))
if (FileExists(nameBuf))
{
realloc_copy(&g_mapInfo[USERMAPMUSICFAKESLOT].musicfn, nameBuf);
mapList[USERMAPMUSICFAKESLOT].music = nameBuf;
return;
}
}
char const * usermapMusic = g_mapInfo[MUS_USERMAP].musicfn;
if (usermapMusic != nullptr)
auto &usermapMusic = mapList[MUS_USERMAP].music;
if (usermapMusic.IsNotEmpty())
{
realloc_copy(&g_mapInfo[USERMAPMUSICFAKESLOT].musicfn, usermapMusic);
mapList[USERMAPMUSICFAKESLOT].music = usermapMusic;
return;
}
#ifndef EDUKE32_STANDALONE
if (!FURY)
{
char const * e1l8 = g_mapInfo[7].musicfn;
if (e1l8 != nullptr)
auto &e1l8 = mapList[7].music;
if (e1l8.IsNotEmpty())
{
realloc_copy(&g_mapInfo[USERMAPMUSICFAKESLOT].musicfn, e1l8);
mapList[USERMAPMUSICFAKESLOT].music = e1l8;
return;
}
}
@ -1816,13 +1813,13 @@ int G_EnterLevel(int gameMode)
int const mapidx = (ud.volume_number * MAXLEVELS) + ud.level_number;
Bassert((unsigned)mapidx < ARRAY_SIZE(g_mapInfo));
Bassert((unsigned)mapidx < ARRAY_SIZE(mapList));
auto &m = g_mapInfo[mapidx];
auto& mm = mapList[mapidx];
if (VOLUMEONE || !Menu_HaveUserMap())
{
if (m.name == NULL || m.filename == NULL)
if (mm.name.IsEmpty() || mm.fileName.IsEmpty())
{
OSD_Printf(OSDTEXT_RED "Map E%dL%d not defined!\n", ud.volume_number+1, ud.level_number+1);
return 1;
@ -1856,15 +1853,15 @@ int G_EnterLevel(int gameMode)
G_LoadMapHack(levelName, boardfilename);
G_SetupFilenameBasedMusic(levelName, boardfilename);
}
else if (engineLoadBoard(m.filename, VOLUMEONE, &p0.pos, &playerAngle, &p0.cursectnum) < 0)
else if (engineLoadBoard(mm.fileName, VOLUMEONE, &p0.pos, &playerAngle, &p0.cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", m.filename);
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", mm.fileName.GetChars());
return 1;
}
else
{
STAT_NewLevel(m.filename);
G_LoadMapHack(levelName, m.filename);
STAT_NewLevel(mm.fileName);
G_LoadMapHack(levelName, mm.fileName);
}
p0.q16ang = fix16_from_int(playerAngle);
@ -1885,7 +1882,7 @@ int G_EnterLevel(int gameMode)
G_ResetAllPlayers();
G_CollectSpawnPoints(gameMode);
ud.playerbest = CONFIG_GetMapBestTime(Menu_HaveUserMap() ? boardfilename : m.filename, g_loadedMapHack.md4);
ud.playerbest = CONFIG_GetMapBestTime(Menu_HaveUserMap() ? boardfilename : mm.fileName.GetChars(), g_loadedMapHack.md4);
// G_FadeLoad(0,0,0, 252,0, -28, 4, -1);
G_CacheMapData();
@ -1897,8 +1894,8 @@ int G_EnterLevel(int gameMode)
{
S_PlayLevelMusicOrNothing(USERMAPMUSICFAKESLOT);
}
else if (g_mapInfo[g_musicIndex].musicfn == NULL || m.musicfn == NULL ||
strcmp(g_mapInfo[g_musicIndex].musicfn, m.musicfn) || g_musicSize == 0 || ud.last_level == -1)
else if (mapList[g_musicIndex].music.IsEmpty() || mm.music.IsEmpty() || mapList[g_musicIndex].music.CompareNoCase(mm.music) == 0 ||
g_musicSize == 0 || ud.last_level == -1)
{
S_PlayLevelMusicOrNothing(mapidx);
}
@ -1960,9 +1957,9 @@ int G_EnterLevel(int gameMode)
if (G_HaveUserMap())
OSD_Printf(OSDTEXT_YELLOW "%s: %s\n", GStrings("TXT_USERMAP"), boardfilename);
else if (FURY)
OSD_Printf(OSDTEXT_YELLOW "%s: %s\n", GStrings("TXT_ENTERING"), m.name);
OSD_Printf(OSDTEXT_YELLOW "%s: %s\n", GStrings("TXT_ENTERING"), mm.DisplayName());
else
OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n", ud.volume_number + 1, ud.level_number + 1, m.name);
OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n", ud.volume_number + 1, ud.level_number + 1, mm.DisplayName());
g_restorePalette = -1;

View file

@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "version.h"
#include "savegamehelp.h"
#include "menu/menu.h"
#include "mapinfo.h"
#include "z_music.h"
BEGIN_DUKE_NS
@ -317,9 +318,9 @@ int32_t G_LoadPlayer(FSaveGameNode *sv)
int const mapIdx = volume*MAXLEVELS + level;
if (boardfilename[0])
Bstrcpy(currentboardfilename, boardfilename);
else if (g_mapInfo[mapIdx].filename)
Bstrcpy(currentboardfilename, g_mapInfo[mapIdx].filename);
strcpy(currentboardfilename, boardfilename);
else if (mapList[mapIdx].fileName.IsNotEmpty())
strcpy(currentboardfilename, mapList[mapIdx].fileName);
if (currentboardfilename[0])
@ -519,9 +520,9 @@ int32_t G_LoadPlayer(FSaveGameNode *sv)
int const mapIdx = h.volnum*MAXLEVELS + h.levnum;
if (boardfilename[0])
Bstrcpy(currentboardfilename, boardfilename);
else if (g_mapInfo[mapIdx].filename)
Bstrcpy(currentboardfilename, g_mapInfo[mapIdx].filename);
strcpy(currentboardfilename, boardfilename);
else if (mapList[mapIdx].fileName.IsNotEmpty())
strcpy(currentboardfilename, mapList[mapIdx].fileName);
if (currentboardfilename[0])
{
@ -1469,8 +1470,8 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, i
auto fw = WriteSavegameChunk("header.dat");
fw->Write(&h, sizeof(savehead_t));
auto& mi = g_mapInfo[(MAXLEVELS * ud.volume_number) + ud.level_number];
G_WriteSaveHeader(name, mi.filename, mi.name);
auto& mii = mapList[(MAXLEVELS * ud.volume_number) + ud.level_number];
G_WriteSaveHeader(name, mii.fileName, mii.DisplayName());
}
else
{

View file

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screens.h"
#include "gamecvars.h"
#include "menu/menu.h"
#include "mapinfo.h"
BEGIN_DUKE_NS
@ -183,7 +184,7 @@ static void G_ShowScores(void)
if (g_mostConcurrentPlayers > 1 && (g_gametypeFlags[ud.coop]&GAMETYPE_SCORESHEET))
{
gametext_center(SCORESHEETOFFSET+58+2, GStrings("Multiplayer Totals"));
gametext_center(SCORESHEETOFFSET+58+10, g_mapInfo[G_LastMapInfoIndex()].name);
gametext_center(SCORESHEETOFFSET+58+10, mapList[G_LastMapInfoIndex()].DisplayName());
t = 0;
minitext(70, SCORESHEETOFFSET+80, GStrings("Name"), 8, 2+8+16+ROTATESPRITE_MAX);
@ -958,7 +959,7 @@ void G_DisplayRest(int32_t smoothratio)
if (textret == 0 && ud.overhead_on == 2)
{
const int32_t a = (ud.screen_size > 0) ? 147 : 179;
char const * levelname = g_mapInfo[ud.volume_number*MAXLEVELS + ud.level_number].name;
char const * levelname = mapList[ud.volume_number*MAXLEVELS + ud.level_number].DisplayName();
if (G_HaveUserMap())
levelname = boardfilename;
else if (!(G_GetLogoFlags() & LOGO_HIDEEPISODE))
@ -993,12 +994,13 @@ void G_DisplayRest(int32_t smoothratio)
else if (g_levelTextTime < 5)
o |= 1;
if (g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
auto dname = mapList[(ud.volume_number * MAXLEVELS) + ud.level_number].DisplayName();
if (dname != NULL && *dname != 0)
{
char const * const fn = currentboardfilename[0] != 0 &&
ud.volume_number == 0 && ud.level_number == 7
? currentboardfilename
: g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name;
: dname;
menutext_(160<<16, (90+16+8)<<16, -g_levelTextTime+22/*quotepulseshade*/, fn, o, TEXT_XCENTER);
}
@ -1102,7 +1104,7 @@ void G_DisplayRest(int32_t smoothratio)
{
Bsprintf(tempbuf, "%s^00 has called a vote for map", g_player[voting].user_name);
gametext_center(40, tempbuf);
Bsprintf(tempbuf, "%s (E%dL%d)", g_mapInfo[vote_episode*MAXLEVELS + vote_map].name, vote_episode+1, vote_map+1);
Bsprintf(tempbuf, "%s (E%dL%d)", mapList[vote_episode*MAXLEVELS + vote_map].DisplayName(), vote_episode+1, vote_map+1);
gametext_center(48, tempbuf);
gametext_center(70, "Press F1 to Accept, F2 to Decline");
}
@ -1883,7 +1885,7 @@ static void G_DisplayMPResultsScreen(void)
if (PLUTOPAK) // JBF 20030804
rotatesprite_fs((260)<<16, 36<<16, 65536L, 0, PLUTOPAKSPRITE+2, 0, 0, 2+8);
gametext_center(58+2, GStrings("Multiplayer Totals"));
gametext_center(58+10, g_mapInfo[G_LastMapInfoIndex()].name);
gametext_center(58+10, mapList[G_LastMapInfoIndex()].DisplayName());
gametext_center_shade(165, GStrings("Presskey"), quotepulseshade);
@ -1951,11 +1953,11 @@ static int32_t G_PrintTime_ClockPad(void)
clockpad = max(clockpad, ij);
if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0]))
{
for (ii=g_mapInfo[G_LastMapInfoIndex()].partime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
for (ii=mapList[G_LastMapInfoIndex()].parTime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
clockpad = max(clockpad, ij);
if (!NAM_WW2GI && g_mapInfo[G_LastMapInfoIndex()].designertime)
if (!NAM_WW2GI && mapList[G_LastMapInfoIndex()].designerTime)
{
for (ii=g_mapInfo[G_LastMapInfoIndex()].designertime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
for (ii= mapList[G_LastMapInfoIndex()].designerTime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
clockpad = max(clockpad, ij);
}
}
@ -1984,13 +1986,13 @@ const char* G_PrintParTime(void)
{
if (ud.last_level < 1)
return "<invalid>";
return G_PrintTime2(g_mapInfo[G_LastMapInfoIndex()].partime);
return G_PrintTime2(mapList[G_LastMapInfoIndex()].parTime);
}
const char* G_PrintDesignerTime(void)
{
if (ud.last_level < 1)
return "<invalid>";
return G_PrintTime2(g_mapInfo[G_LastMapInfoIndex()].designertime);
return G_PrintTime2(mapList[G_LastMapInfoIndex()].designerTime);
}
const char* G_PrintBestTime(void)
{
@ -2002,7 +2004,7 @@ void G_BonusScreen(int32_t bonusonly)
int32_t gfx_offset;
int32_t bonuscnt;
int32_t clockpad = 2;
char *lastmapname;
const char *lastmapname;
if (g_networkMode == NET_DEDICATED_SERVER)
return;
@ -2015,9 +2017,9 @@ void G_BonusScreen(int32_t bonusonly)
}
else
{
lastmapname = g_mapInfo[G_LastMapInfoIndex()].name;
if (!lastmapname) // this isn't right but it's better than no name at all
lastmapname = g_mapInfo[G_LastMapInfoIndex()].name;
lastmapname = mapList[G_LastMapInfoIndex()].name;
if (!lastmapname || !*lastmapname) // this isn't right but it's better than no name at all
lastmapname = mapList[G_LastMapInfoIndex()].fileName;
}
@ -2183,12 +2185,12 @@ void G_BonusScreen(int32_t bonusonly)
yy+=10;
if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0]))
{
if (g_mapInfo[G_LastMapInfoIndex()].partime)
if (mapList[G_LastMapInfoIndex()].parTime)
{
gametext(10, yy+9, GStrings("TXT_ParTime"));
yy+=10;
}
if (!NAM_WW2GI && !DUKEBETA && g_mapInfo[G_LastMapInfoIndex()].designertime)
if (!NAM_WW2GI && !DUKEBETA && mapList[G_LastMapInfoIndex()].designerTime)
{
// EDuke 2.0 / NAM source suggests "Green Beret's Time:"
gametext(10, yy+9, GStrings("TXT_3DRTIME"));
@ -2227,13 +2229,13 @@ void G_BonusScreen(int32_t bonusonly)
if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0]))
{
if (g_mapInfo[G_LastMapInfoIndex()].partime)
if (mapList[G_LastMapInfoIndex()].parTime)
{
G_PrintParTime();
gametext_number((320>>2)+71, yy+9, tempbuf);
yy+=10;
}
if (!NAM_WW2GI && !DUKEBETA && g_mapInfo[G_LastMapInfoIndex()].designertime)
if (!NAM_WW2GI && !DUKEBETA && mapList[G_LastMapInfoIndex()].designerTime)
{
G_PrintDesignerTime();
gametext_number((320>>2)+71, yy+9, tempbuf);

View file

@ -106,12 +106,10 @@ extern void G_SaveMapState();
extern void G_RestoreMapState();
typedef struct {
int32_t partime, designertime;
char *name, *filename, *musicfn;
mapstate_t *savedstate;
} map_t;
//extern map_t g_mapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music
void G_ActivateBySector(int sect,int spriteNum);
int S_FindMusicSFX(int sectNum, int *sndptr);

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "al_midi.h"
#include "openaudio.h"
#include "z_music.h"
#include "mapinfo.h"
#include <atomic>
BEGIN_DUKE_NS
@ -147,15 +148,15 @@ void S_PlayLevelMusicOrNothing(unsigned int m)
if (retval >= 0)
{
Mus_Play(g_mapInfo[m].filename, g_mapInfo[m].musicfn, true);
Mus_Play(mapList[m].fileName, mapList[m].music, true);
S_SetMusicIndex(m);
}
}
int S_TryPlaySpecialMusic(unsigned int m)
{
char const * musicfn = g_mapInfo[m].musicfn;
if (musicfn != NULL)
auto &musicfn = mapList[m].music;
if (musicfn.IsNotEmpty())
{
if (!Mus_Play(nullptr, musicfn, true))
{