diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 46b67eff5..399268d1c 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -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; diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 172467ed7..b2d68547e 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -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; diff --git a/source/common/engine/sc_man.cpp b/source/common/engine/sc_man.cpp index 96c79538c..b9f3cc882 100644 --- a/source/common/engine/sc_man.cpp +++ b/source/common/engine/sc_man.cpp @@ -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; } diff --git a/source/common/engine/sc_man.h b/source/common/engine/sc_man.h index 684482e6c..18504569d 100644 --- a/source/common/engine/sc_man.h +++ b/source/common/engine/sc_man.h @@ -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 constants; + bool ScriptOpen; FString ScriptBuffer; const char *ScriptPtr; diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index bfd990353..7b2dea3ff 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -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() { diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index a458de2d6..363183d05 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -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: { diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 5d571313a..c8eade2e1 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -451,7 +451,6 @@ enum gametokens T_ALLOW = 2, T_NOAUTOLOAD, T_INCLUDEDEFAULT, - T_MUSIC, T_SOUND, T_FILE, T_CUTSCENE, diff --git a/source/games/duke/src/common_game.h b/source/games/duke/src/common_game.h index 23e551fbf..2db6b8b31 100644 --- a/source/games/duke/src/common_game.h +++ b/source/games/duke/src/common_game.h @@ -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); diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 69365dee6..3a4c66394 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -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 { diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index bcb590a5f..306810881 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -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); diff --git a/source/games/duke/src/game_main.cpp b/source/games/duke/src/game_main.cpp index 9c99d5ed3..f162f545d 100644 --- a/source/games/duke/src/game_main.cpp +++ b/source/games/duke/src/game_main.cpp @@ -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 diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index c8437a187..213bc87c5 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -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(); diff --git a/source/games/duke/src/zz_sbar.cpp b/source/games/duke/src/zz_sbar.cpp index fef93fabb..54dd40cb2 100644 --- a/source/games/duke/src/zz_sbar.cpp +++ b/source/games/duke/src/zz_sbar.cpp @@ -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 diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index c33ffe202..d051bb639 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -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: {