- consolidated the 'music' parsing in Defs (pending a refactor of the MAPINFO system.)

- removed the remaining parts of the game Defs parser because we do not want anything EDuke in here.
This commit is contained in:
Christoph Oelckers 2020-06-24 00:40:22 +02:00
parent 4b743b4063
commit e146e73345
14 changed files with 207 additions and 629 deletions

View file

@ -115,7 +115,6 @@ enum gametokens
T_ALLOW = 2,
T_NOAUTOLOAD,
T_INCLUDEDEFAULT,
T_MUSIC,
T_SOUND,
T_FILE,
//T_CUTSCENE,
@ -1435,7 +1434,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
{ "loadgrp", T_LOADGRP },
{ "cachesize", T_CACHESIZE },
{ "noautoload", T_NOAUTOLOAD },
{ "music", T_MUSIC },
{ "sound", T_SOUND },
//{ "cutscene", T_CUTSCENE },
//{ "animsounds", T_ANIMSOUNDS },
@ -1512,43 +1510,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
if (firstPass)
gNoAutoLoad = true;
break;
case T_MUSIC:
{
char *tokenPtr = pScript->ltextptr;
char *musicID = NULL;
char *fileName = NULL;
char *musicEnd;
if (scriptfile_getbraces(pScript, &musicEnd))
break;
while (pScript->textptr < musicEnd)
{
switch (getatoken(pScript, soundTokens, ARRAY_SIZE(soundTokens)))
{
case T_ID: scriptfile_getstring(pScript, &musicID); break;
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
}
}
if (!firstPass)
{
if (musicID==NULL)
{
Printf("Error: missing ID for music definition near line %s:%d\n",
pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
break;
}
if (fileName == NULL || fileSystem.FileExists(fileName))
break;
if (S_DefineMusic(musicID, fileName) == -1)
Printf("Error: invalid music ID on line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
}
}
break;
case T_RFFDEFINEID:
{
char *resName = NULL;

View file

@ -18,6 +18,71 @@
#include "m_argv.h"
#include "gamecontrol.h"
#include "palettecontainer.h"
#include "mapinfo.h"
#if 0
// For later
{
if (sc.Compare("music"))
{
FString id, mus;
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
{
sc.MustGetToken(TK_Identifier);
if (sc.Compare("id"))
{
sc.MustGetString();
id = sc.String;
}
else if (sc.Compare("file"))
{
sc.MustGetString();
mus = sc.String;
}
}
if (!SetMusicForMap(id, mus, true))
{
sc.ScriptError("Map %s not found in music definition", id.GetChars());
}
char* tokenPtr = pScript->ltextptr;
char* musicID = NULL;
char* fileName = NULL;
char* musicEnd;
if (scriptfile_getbraces(pScript, &musicEnd))
break;
while (pScript->textptr < musicEnd)
{
switch (getatoken(pScript, soundTokens, ARRAY_SIZE(soundTokens)))
{
case T_ID: scriptfile_getstring(pScript, &musicID); break;
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
}
}
if (!firstPass)
{
if (musicID == NULL)
{
Printf("Error: missing ID for music definition near line %s:%d\n",
pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
break;
}
if (fileName == NULL || fileSystem.FileExists(fileName))
break;
if (S_DefineMusic(musicID, fileName) == -1)
Printf("Error: invalid music ID on line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
}
}
}
#endif
enum scripttoken_t
{
@ -477,6 +542,12 @@ static int32_t defsparser(scriptfile *script)
{
char *bs;
scriptfile_getstring(script,&bs);
#if 0
if (!scriptfile_getstring(pScript, &fileName) && firstPass)
{
fileSystem.AddAdditionalFile(fileName);
}
#endif
}
break;
case T_CACHESIZE:
@ -2361,6 +2432,7 @@ static int32_t defsparser(scriptfile *script)
break;
}
}
SetMusicForMap(dummy2, dummy, true);
}
break;

View file

@ -953,12 +953,22 @@ bool FScanner::ScanValue(bool allowfloat)
return false;
}
}
if (TokenType != TK_IntConst && (TokenType != TK_FloatConst || !allowfloat))
{
if (TokenType == TK_FloatConst && !allowfloat)
return false;
if (TokenType != TK_IntConst && TokenType != TK_FloatConst)
{
auto d = constants.CheckKey(String);
if (!d) return false;
if (!allowfloat && int64_t(*d) != *d) return false;
BigNumber = *d;
Number = *d;
Float = *d;
}
if (neg)
{
BigNumber = -BigNumber;
Number = -Number;
Float = -Float;
}

View file

@ -2,6 +2,7 @@
#define __SC_MAN_H__
#include "zstring.h"
#include "tarray.h"
#include "name.h"
#include "basics.h"
@ -97,6 +98,11 @@ public:
bool GetFloat();
void MustGetFloat();
bool CheckFloat();
double *LookupConstant(FName name)
{
return constants.CheckKey(name);
}
// Token based variant
bool CheckValue(bool allowfloat);
@ -137,6 +143,8 @@ protected:
// Strings longer than this minus one will be dynamically allocated.
static const int MAX_STRING_SIZE = 128;
TMap<FName, double> constants;
bool ScriptOpen;
FString ScriptBuffer;
const char *ScriptPtr;

View file

@ -61,11 +61,48 @@ struct MapRecord
};
extern MapRecord mapList[512];
extern MapRecord userMapRecord;
extern MapRecord *currentLevel;
extern MapRecord* lastLevel;
inline bool SetMusicForMap(const char* mapname, const char* music, bool namehack = false)
{
static const char* specials[] = { "intro", "briefing", "loading" };
for (int i = 0; i < 3; i++)
{
if (!stricmp(mapname, specials[i]))
{
// todo: store this properly.
return true;
}
}
int index = -1; // = FindMap(mapname);
// This is for the DEFS parser's MUSIC command which never bothered to check for the real map name.
if (index < 0 && namehack)
{
int lev, ep;
signed char b1, b2;
int numMatches = sscanf(mapname, "%c%d%c%d", &b1, &ep, &b2, &lev);
if (numMatches != 4 || toupper(b1) != 'E' || toupper(b2) != 'L')
return false;
index = -1; // = FindMapByIndex(ep, lev);
}
if (index >= 0)
{
mapList[index].music = music;
return true;
}
return false;
}
inline void InitRREndMap()
{

View file

@ -133,7 +133,6 @@ enum gametokens
T_ALLOW = 2,
T_NOAUTOLOAD,
T_INCLUDEDEFAULT,
T_MUSIC,
T_SOUND,
T_FILE,
T_CUTSCENE,
@ -4684,7 +4683,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
{ "loadgrp", T_LOADGRP },
{ "cachesize", T_CACHESIZE },
{ "noautoload", T_NOAUTOLOAD },
{ "music", T_MUSIC },
{ "sound", T_SOUND },
{ "cutscene", T_CUTSCENE },
{ "animsounds", T_ANIMSOUNDS },
@ -4777,42 +4775,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
if (firstPass)
gNoAutoLoad = 1;
break;
case T_MUSIC:
{
char *tokenPtr = pScript->ltextptr;
char *musicID = NULL;
char *fileName = NULL;
char *musicEnd;
if (scriptfile_getbraces(pScript, &musicEnd))
break;
while (pScript->textptr < musicEnd)
{
switch (getatoken(pScript, soundTokens, ARRAY_SIZE(soundTokens)))
{
case T_ID: scriptfile_getstring(pScript, &musicID); break;
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
}
}
if (!firstPass)
{
if (musicID==NULL)
{
Printf("Error: missing ID for music definition near line %s:%d\n",
pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
break;
}
if (fileName == NULL || fileSystem.FileExists(fileName))
break;
if (S_DefineMusic(musicID, fileName) == -1)
Printf("Error: invalid music ID on line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
}
}
break;
case T_CUTSCENE:
{

View file

@ -451,7 +451,6 @@ enum gametokens
T_ALLOW = 2,
T_NOAUTOLOAD,
T_INCLUDEDEFAULT,
T_MUSIC,
T_SOUND,
T_FILE,
T_CUTSCENE,

View file

@ -49,10 +49,6 @@ enum basepal_t {
#include "v_text.h"
extern int loaddefinitions_game(const char *fn, int32_t preload);
//////////
extern void G_InitMultiPsky(int CLOUDYOCEAN__DYN, int MOONSKY1__DYN, int BIGORBIT1__DYN, int LA__DYN);
extern void G_SetupGlobalPsky(void);

View file

@ -130,6 +130,9 @@ END_DUKE_NS
BEGIN_DUKE_NS
extern FFont* IndexFont;
extern FFont* DigiFont;
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{

View file

@ -451,22 +451,6 @@ static inline void G_NewGame_EnterLevel(void)
G_BackToMenu();
}
static inline int G_GetMusicIdx(const char *str)
{
int32_t lev, ep;
signed char b1, b2;
int numMatches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
if (numMatches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
return -1;
if ((unsigned)--lev >= MAXLEVELS || (unsigned)--ep >= MAXVOLUMES)
return -2;
return (ep * MAXLEVELS) + lev;
}
extern void G_PrintCurrentMusic(void);
void addspritetodelete(int spnum);

View file

@ -32,9 +32,14 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "screens.h"
#include "baselayer.h"
#include "m_argv.h"
#include "mapinfo.h"
#include "texturemanager.h"
BEGIN_DUKE_NS
FFont* IndexFont;
FFont* DigiFont;
//---------------------------------------------------------------------------
//
// game specific command line args go here.
@ -162,6 +167,76 @@ void genspriteremaps(void)
}
}
//==========================================================================
//
// Sets up the game fonts.
//
//==========================================================================
void InitFonts()
{
GlyphSet fontdata;
// Small font
for (int i = 0; i < 95; i++)
{
auto tile = tileGetTexture(TILE_STARTALPHANUM + i);
if (tile && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
fontdata.Insert('!' + i, tile);
}
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// Big font
// This font is VERY messy...
fontdata.Insert('_', tileGetTexture(TILE_BIGALPHANUM - 11));
fontdata.Insert('-', tileGetTexture(TILE_BIGALPHANUM - 11));
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_BIGALPHANUM - 10 + i));
for (int i = 0; i < 26; i++) fontdata.Insert('A' + i, tileGetTexture(TILE_BIGALPHANUM + i));
fontdata.Insert('.', tileGetTexture(TILE_BIGPERIOD));
fontdata.Insert(',', tileGetTexture(TILE_BIGCOMMA));
fontdata.Insert('!', tileGetTexture(TILE_BIGX_));
fontdata.Insert('?', tileGetTexture(TILE_BIGQ));
fontdata.Insert(';', tileGetTexture(TILE_BIGSEMI));
fontdata.Insert(':', tileGetTexture(TILE_BIGCOLIN));
fontdata.Insert('\\', tileGetTexture(TILE_BIGALPHANUM + 68));
fontdata.Insert('/', tileGetTexture(TILE_BIGALPHANUM + 68));
fontdata.Insert('%', tileGetTexture(TILE_BIGALPHANUM + 69));
fontdata.Insert('`', tileGetTexture(TILE_BIGAPPOS));
fontdata.Insert('"', tileGetTexture(TILE_BIGAPPOS));
fontdata.Insert('\'', tileGetTexture(TILE_BIGAPPOS));
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// Tiny font
for (int i = 0; i < 95; i++)
{
auto tile = tileGetTexture(TILE_MINIFONT + i);
if (tile && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
fontdata.Insert('!' + i, tile);
}
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// SBAR index font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_THREEBYFIVE + i));
fontdata.Insert(':', tileGetTexture(TILE_THREEBYFIVE + 10));
fontdata.Insert('/', tileGetTexture(TILE_THREEBYFIVE + 11));
fontdata.Insert('%', tileGetTexture(TILE_MINIFONT + '%' - '!'));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// digital font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_DIGITALNUM + i));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
}
END_DUKE_NS

View file

@ -1572,427 +1572,9 @@ void G_HandleLocalKeys(void)
}
}
// Returns:
// 0: all OK
// -1: ID declaration was invalid:
static int32_t S_DefineMusic(const char *ID, const char *name)
{
int32_t sel = MUS_FIRST_SPECIAL;
Bassert(ID != NULL);
if (!Bstrcmp(ID,"intro"))
{
// nothing
}
else if (!Bstrcmp(ID,"briefing"))
{
sel++;
}
else if (!Bstrcmp(ID,"loading"))
{
sel += 2;
}
else
{
sel = G_GetMusicIdx(ID);
if (sel < 0)
return -1;
}
mapList[sel].music = name;
return 0;
}
static int parsedefinitions_game(scriptfile *, int);
static void parsedefinitions_game_include(const char *fileName, scriptfile *pScript, const char *cmdtokptr, int const firstPass)
{
scriptfile *included = scriptfile_fromfile(fileName);
if (included)
{
parsedefinitions_game(included, firstPass);
scriptfile_close(included);
}
}
static void parsedefinitions_game_animsounds(scriptfile *pScript, const char * blockEnd, char const * fileName, dukeanim_t * animPtr)
{
size_t numPairs = 0, allocSize = 4;
animPtr->Sounds.Clear();
int defError = 1;
uint16_t lastFrameNum = 1;
while (pScript->textptr < blockEnd)
{
int32_t frameNum;
int32_t soundNum;
// HACK: we've reached the end of the list
// (hack because it relies on knowledge of
// how scriptfile_* preprocesses the text)
if (blockEnd - pScript->textptr == 1)
break;
// would produce error when it encounters the closing '}'
// without the above hack
if (scriptfile_getnumber(pScript, &frameNum))
break;
defError = 1;
if (scriptfile_getsymbol(pScript, &soundNum))
break;
// frame numbers start at 1 for us
if (frameNum <= 0)
{
Printf("Error: frame number must be greater zero on line %s:%d\n", pScript->filename,
scriptfile_getlinum(pScript, pScript->ltextptr));
break;
}
if (frameNum < lastFrameNum)
{
Printf("Error: frame numbers must be in (not necessarily strictly)"
" ascending order (line %s:%d)\n",
pScript->filename, scriptfile_getlinum(pScript, pScript->ltextptr));
break;
}
lastFrameNum = frameNum;
if ((unsigned)soundNum >= MAXSOUNDS && soundNum != -1)
{
Printf("Error: sound number #%d invalid on line %s:%d\n", soundNum, pScript->filename,
scriptfile_getlinum(pScript, pScript->ltextptr));
break;
}
defError = 0;
animsound_t sound;
sound.frame = frameNum;
sound.sound = soundNum;
animPtr->Sounds.Push(sound);
++numPairs;
}
if (!defError)
{
// Printf("Defined sound sequence for hi-anim \"%s\" with %d frame/sound pairs\n",
// hardcoded_anim_tokens[animnum].text, numpairs);
}
else
{
Printf("Failed defining sound sequence for anim \"%s\".\n", fileName);
}
animPtr->Sounds.ShrinkToFit();
}
static int parsedefinitions_game(scriptfile *pScript, int firstPass)
{
int token;
char *pToken;
static const tokenlist tokens[] =
{
{ "include", T_INCLUDE },
{ "#include", T_INCLUDE },
{ "includedefault", T_INCLUDEDEFAULT },
{ "#includedefault", T_INCLUDEDEFAULT },
{ "loadgrp", T_LOADGRP },
{ "cachesize", T_CACHESIZE },
{ "noautoload", T_NOAUTOLOAD },
{ "music", T_MUSIC },
{ "sound", T_SOUND },
{ "cutscene", T_CUTSCENE },
{ "animsounds", T_ANIMSOUNDS },
{ "renamefile", T_RENAMEFILE },
{ "globalgameflags", T_GLOBALGAMEFLAGS },
};
static const tokenlist soundTokens[] =
{
{ "id", T_ID },
{ "file", T_FILE },
{ "minpitch", T_MINPITCH },
{ "maxpitch", T_MAXPITCH },
{ "priority", T_PRIORITY },
{ "type", T_TYPE },
{ "distance", T_DISTANCE },
{ "volume", T_VOLUME },
};
static const tokenlist animTokens [] =
{
{ "delay", T_DELAY },
{ "aspect", T_ASPECT },
{ "sounds", T_SOUND },
{ "forcefilter", T_FORCEFILTER },
{ "forcenofilter", T_FORCENOFILTER },
{ "texturefilter", T_TEXTUREFILTER },
};
do
{
token = getatoken(pScript, tokens, ARRAY_SIZE(tokens));
pToken = pScript->ltextptr;
switch (token)
{
case T_LOADGRP:
{
char *fileName;
if (!scriptfile_getstring(pScript,&fileName) && firstPass)
{
fileSystem.AddAdditionalFile(fileName);
}
}
break;
case T_CACHESIZE:
{
int32_t cacheSize;
if (scriptfile_getnumber(pScript, &cacheSize) || !firstPass)
break;
}
break;
case T_INCLUDE:
{
char *fileName;
if (!scriptfile_getstring(pScript, &fileName))
parsedefinitions_game_include(fileName, pScript, pToken, firstPass);
break;
}
case T_INCLUDEDEFAULT:
{
parsedefinitions_game_include(G_DefaultDefFile(), pScript, pToken, firstPass);
break;
}
case T_NOAUTOLOAD:
if (firstPass)
gNoAutoLoad = 1;
break;
case T_MUSIC:
{
char *tokenPtr = pScript->ltextptr;
char *musicID = NULL;
char *fileName = NULL;
char *musicEnd;
if (scriptfile_getbraces(pScript, &musicEnd))
break;
while (pScript->textptr < musicEnd)
{
switch (getatoken(pScript, soundTokens, ARRAY_SIZE(soundTokens)))
{
case T_ID: scriptfile_getstring(pScript, &musicID); break;
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
}
}
if (!firstPass)
{
if (musicID==NULL)
{
Printf("Error: missing ID for music definition near line %s:%d\n",
pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
break;
}
if (fileName == NULL || fileSystem.FileExists(fileName))
break;
if (S_DefineMusic(musicID, fileName) == -1)
Printf("Error: invalid music ID on line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
}
}
break;
case T_CUTSCENE:
{
char *fileName = NULL;
scriptfile_getstring(pScript, &fileName);
char *animEnd;
if (scriptfile_getbraces(pScript, &animEnd))
break;
if (!firstPass)
{
dukeanim_t *animPtr = Anim_Find(fileName);
if (!animPtr)
{
animPtr = Anim_Create(fileName);
animPtr->framedelay = 10;
animPtr->frameflags = 0;
}
int32_t temp;
while (pScript->textptr < animEnd)
{
switch (getatoken(pScript, animTokens, ARRAY_SIZE(animTokens)))
{
case T_DELAY:
scriptfile_getnumber(pScript, &temp);
animPtr->framedelay = temp;
break;
case T_ASPECT:
{
double dtemp, dtemp2;
scriptfile_getdouble(pScript, &dtemp);
scriptfile_getdouble(pScript, &dtemp2);
animPtr->frameaspect1 = dtemp;
animPtr->frameaspect2 = dtemp2;
break;
}
case T_SOUND:
{
char *animSoundsEnd = NULL;
if (scriptfile_getbraces(pScript, &animSoundsEnd))
break;
parsedefinitions_game_animsounds(pScript, animSoundsEnd, fileName, animPtr);
break;
}
case T_FORCEFILTER:
animPtr->frameflags |= CUTSCENE_FORCEFILTER;
break;
case T_FORCENOFILTER:
animPtr->frameflags |= CUTSCENE_FORCENOFILTER;
break;
case T_TEXTUREFILTER:
animPtr->frameflags |= CUTSCENE_TEXTUREFILTER;
break;
}
}
}
else
pScript->textptr = animEnd;
}
break;
case T_ANIMSOUNDS:
{
char *tokenPtr = pScript->ltextptr;
char *fileName = NULL;
scriptfile_getstring(pScript, &fileName);
if (!fileName)
break;
char *animSoundsEnd = NULL;
if (scriptfile_getbraces(pScript, &animSoundsEnd))
break;
if (firstPass)
{
pScript->textptr = animSoundsEnd;
break;
}
dukeanim_t *animPtr = Anim_Find(fileName);
if (!animPtr)
{
Printf("Error: expected animation filename on line %s:%d\n",
pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
break;
}
parsedefinitions_game_animsounds(pScript, animSoundsEnd, fileName, animPtr);
}
break;
case T_SOUND:
{
char *tokenPtr = pScript->ltextptr;
char *fileName = NULL;
char *musicEnd;
double volume = 1.0;
int32_t soundNum = -1;
int32_t maxpitch = 0;
int32_t minpitch = 0;
int32_t priority = 0;
int32_t type = 0;
int32_t distance = 0;
if (scriptfile_getbraces(pScript, &musicEnd))
break;
while (pScript->textptr < musicEnd)
{
switch (getatoken(pScript, soundTokens, ARRAY_SIZE(soundTokens)))
{
case T_ID: scriptfile_getsymbol(pScript, &soundNum); break;
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
case T_MINPITCH: scriptfile_getsymbol(pScript, &minpitch); break;
case T_MAXPITCH: scriptfile_getsymbol(pScript, &maxpitch); break;
case T_PRIORITY: scriptfile_getsymbol(pScript, &priority); break;
case T_TYPE: scriptfile_getsymbol(pScript, &type); break;
case T_DISTANCE: scriptfile_getsymbol(pScript, &distance); break;
case T_VOLUME: scriptfile_getdouble(pScript, &volume); break;
}
}
if (!firstPass)
{
if (soundNum==-1)
{
Printf("Error: missing ID for sound definition near line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
break;
}
if (fileName == NULL || fileSystem.FileExists(fileName))
break;
// maybe I should have just packed this into a sound_t and passed a reference...
if (S_DefineSound(soundNum, fileName, minpitch, maxpitch, priority, type, distance, volume) == -1)
Printf("Error: invalid sound ID on line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
}
}
break;
case T_GLOBALGAMEFLAGS: scriptfile_getnumber(pScript, &duke3d_globalflags); break;
case T_EOF: return 0;
default: break;
}
}
while (1);
return 0;
}
int loaddefinitions_game(const char *fileName, int32_t firstPass)
{
scriptfile *pScript = scriptfile_fromfile(fileName);
if (pScript)
parsedefinitions_game(pScript, firstPass);
if (userConfig.AddDefs) for (auto& m : *userConfig.AddDefs)
parsedefinitions_game_include(m, NULL, "null", firstPass);
if (pScript)
scriptfile_close(pScript);
scriptfile_clearsymbols();
return 0;
}
static void G_Cleanup(void)
{
@ -2449,7 +2031,6 @@ int GameInterface::app_main()
uint32_t etime = timerGetTicks();
Printf("Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime-stime);
}
loaddefinitions_game(defsfile, FALSE);
userConfig.AddDefs.reset();

View file

@ -31,78 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "texturemanager.h"
BEGIN_DUKE_NS
static FFont* IndexFont;
static FFont* DigiFont;
//==========================================================================
//
// Font init should go elsewhere later.
//
//==========================================================================
void InitFonts()
{
GlyphSet fontdata;
// Small font
for (int i = 0; i < 95; i++)
{
auto tile = tileGetTexture(TILE_STARTALPHANUM + i);
if (tile && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
fontdata.Insert('!' + i, tile);
}
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// Big font
// This font is VERY messy...
fontdata.Insert('_', tileGetTexture(TILE_BIGALPHANUM - 11));
fontdata.Insert('-', tileGetTexture(TILE_BIGALPHANUM - 11));
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_BIGALPHANUM - 10 + i));
for (int i = 0; i < 26; i++) fontdata.Insert('A' + i, tileGetTexture(TILE_BIGALPHANUM + i));
fontdata.Insert('.', tileGetTexture(TILE_BIGPERIOD));
fontdata.Insert(',', tileGetTexture(TILE_BIGCOMMA));
fontdata.Insert('!', tileGetTexture(TILE_BIGX_));
fontdata.Insert('?', tileGetTexture(TILE_BIGQ));
fontdata.Insert(';', tileGetTexture(TILE_BIGSEMI));
fontdata.Insert(':', tileGetTexture(TILE_BIGCOLIN));
fontdata.Insert('\\', tileGetTexture(TILE_BIGALPHANUM + 68));
fontdata.Insert('/', tileGetTexture(TILE_BIGALPHANUM + 68));
fontdata.Insert('%', tileGetTexture(TILE_BIGALPHANUM + 69));
fontdata.Insert('`', tileGetTexture(TILE_BIGAPPOS));
fontdata.Insert('"', tileGetTexture(TILE_BIGAPPOS));
fontdata.Insert('\'', tileGetTexture(TILE_BIGAPPOS));
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// Tiny font
for (int i = 0; i < 95; i++)
{
auto tile = tileGetTexture(TILE_MINIFONT + i);
if (tile && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
fontdata.Insert('!' + i, tile);
}
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// SBAR index font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_THREEBYFIVE + i));
fontdata.Insert(':', tileGetTexture(TILE_THREEBYFIVE + 10));
fontdata.Insert('/', tileGetTexture(TILE_THREEBYFIVE + 11));
fontdata.Insert('%', tileGetTexture(TILE_MINIFONT + '%' - '!'));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
fontdata.Clear();
// digital font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_DIGITALNUM + i));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
}
//==========================================================================
//
// Helpers

View file

@ -105,7 +105,6 @@ enum gametokens
T_ALLOW = 2,
T_NOAUTOLOAD,
T_INCLUDEDEFAULT,
T_MUSIC,
T_SOUND,
T_FILE,
T_CUTSCENE,
@ -6199,7 +6198,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
{ "loadgrp", T_LOADGRP },
{ "cachesize", T_CACHESIZE },
{ "noautoload", T_NOAUTOLOAD },
{ "music", T_MUSIC },
{ "sound", T_SOUND },
{ "cutscene", T_CUTSCENE },
{ "animsounds", T_ANIMSOUNDS },
@ -6272,42 +6270,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
if (firstPass)
gNoAutoLoad = 1;
break;
case T_MUSIC:
{
char *tokenPtr = pScript->ltextptr;
char *musicID = NULL;
char *fileName = NULL;
char *musicEnd;
if (scriptfile_getbraces(pScript, &musicEnd))
break;
while (pScript->textptr < musicEnd)
{
switch (getatoken(pScript, soundTokens, ARRAY_SIZE(soundTokens)))
{
case T_ID: scriptfile_getstring(pScript, &musicID); break;
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
}
}
if (!firstPass)
{
if (musicID==NULL)
{
Printf("Error: missing ID for music definition near line %s:%d\n",
pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
break;
}
if (fileName == NULL || fileSystem.FileExists(fileName))
break;
if (S_DefineMusic(musicID, fileName) == -1)
Printf("Error: invalid music ID on line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
}
}
break;
case T_CUTSCENE:
{