- 4 more .def commands ported

This commit is contained in:
Christoph Oelckers 2021-04-13 00:28:51 +02:00
parent 798cf2f973
commit f4ec9a1921
4 changed files with 115 additions and 176 deletions

View file

@ -215,13 +215,13 @@ typedef struct {
// The proportion at which looking up/down affects the apparent 'horiz' of // The proportion at which looking up/down affects the apparent 'horiz' of
// a parallaxed sky, scaled by 65536 (so, a value of 65536 makes it align // a parallaxed sky, scaled by 65536 (so, a value of 65536 makes it align
// with the drawn surrounding scene): // with the drawn surrounding scene):
int32_t horizfrac; int horizfrac;
// The texel index offset in the y direction of a parallaxed sky: // The texel index offset in the y direction of a parallaxed sky:
// XXX: currently always 0. // XXX: currently always 0.
int32_t yoffs; int yoffs;
int8_t lognumtiles; // 1<<lognumtiles: number of tiles in multi-sky int lognumtiles; // 1<<lognumtiles: number of tiles in multi-sky
int16_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<<lognumtiles): tile offset relative to basetile int16_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<<lognumtiles): tile offset relative to basetile
int32_t yscale; int32_t yscale;
@ -275,8 +275,6 @@ enum {
GLOBAL_NO_GL_FOGSHADE = 1<<2, GLOBAL_NO_GL_FOGSHADE = 1<<2,
}; };
extern int32_t globalflags;
extern const char *engineerrstr; extern const char *engineerrstr;
EXTERN int32_t editorzrange[2]; EXTERN int32_t editorzrange[2];

View file

@ -35,8 +35,6 @@ int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens)
return T_ERROR; return T_ERROR;
} }
void AddUserMapHack(usermaphack_t&);
enum scripttoken_t enum scripttoken_t
{ {
T_INCLUDE = 0, T_INCLUDE = 0,
@ -329,6 +327,7 @@ static int32_t defsparser(scriptfile *script)
case T_CACHESIZE: case T_CACHESIZE:
case T_SHADEFACTOR: case T_SHADEFACTOR:
case T_GLOBALGAMEFLAGS: case T_GLOBALGAMEFLAGS:
case T_GLOBALFLAGS:
parseSkip<1>(*script, pos); parseSkip<1>(*script, pos);
break; break;
case T_SPRITECOL: case T_SPRITECOL:
@ -1545,179 +1544,19 @@ static int32_t defsparser(scriptfile *script)
case T_SOUND: case T_SOUND:
case T_MUSIC: case T_MUSIC:
{ parseMusic(*script, pos);
FScanner::SavedPos p;
FString dummy, dummy2;
static const tokenlist sound_musictokens[] =
{
{ "id", T_ID },
{ "file", T_FILE },
};
if (scriptfile_getbraces(script,&p)) break;
while (!scriptfile_endofblock(script, p))
{
switch (getatoken(script,sound_musictokens,countof(sound_musictokens)))
{
case T_ID:
scriptfile_getstring(script,&dummy2);
break;
case T_FILE:
scriptfile_getstring(script,&dummy);
break;
}
}
SetMusicForMap(dummy2, dummy, true);
}
break; break;
case T_MAPINFO: case T_MAPINFO:
{ parseMapinfo(*script, pos);
FString mapmd4string;
FScanner::SavedPos mapinfoend;
usermaphack_t mhk;
static const tokenlist mapinfotokens[] =
{
{ "mapfile", T_MAPFILE },
{ "maptitle", T_MAPTITLE },
{ "mapmd4", T_MAPMD4 },
{ "mhkfile", T_MHKFILE },
};
if (scriptfile_getbraces(script,&mapinfoend)) break;
while (!scriptfile_endofblock(script, mapinfoend))
{
switch (getatoken(script,mapinfotokens,countof(mapinfotokens)))
{
case T_MAPFILE:
scriptfile_getstring(script,nullptr);
break;
case T_MAPTITLE:
scriptfile_getstring(script,&mhk.title);
break;
case T_MAPMD4:
{
scriptfile_getstring(script,&mapmd4string);
for (int i = 0; i < 16; i++)
{
char smallbuf[3] = { mapmd4string[2 * i], mapmd4string[2 * i + 1], 0 };
mhk.md4[i] = strtol(smallbuf, NULL, 16);
}
break;
}
case T_MHKFILE:
scriptfile_getstring(script,&mhk.mhkfile);
break;
}
}
AddUserMapHack(mhk);
}
break; break;
case T_ECHO: case T_ECHO:
{ parseEcho(*script, pos);
FString string;
scriptfile_getstring(script,&string);
Printf("%s\n",string.GetChars());
}
break;
case T_GLOBALFLAGS:
{
if (scriptfile_getnumber(script,&globalflags)) break;
}
break; break;
case T_MULTIPSKY: case T_MULTIPSKY:
{ parseMultiPsky(*script, pos);
FScanner::SavedPos blockend;
int32_t tile;
static const tokenlist subtokens[] =
{
{ "horizfrac", T_HORIZFRAC },
{ "yoffset", T_YOFFSET },
{ "lognumtiles", T_LOGNUMTILES },
{ "tile", T_TILE },
{ "panel", T_TILE },
{ "yscale", T_YSCALE },
};
if (scriptfile_getsymbol(script,&tile))
break;
if (scriptfile_getbraces(script,&blockend))
break;
if (tile != DEFAULTPSKY && (unsigned)tile >= MAXUSERTILES)
{
scriptfile_setposition(script, blockend);
break;
}
psky_t * const newpsky = tileSetupSky(tile);
while (!scriptfile_endofblock(script, blockend))
{
int32_t token = getatoken(script,subtokens,countof(subtokens));
switch (token)
{
case T_HORIZFRAC:
{
int32_t horizfrac;
scriptfile_getsymbol(script,&horizfrac);
newpsky->horizfrac = horizfrac;
break;
}
case T_YOFFSET:
{
int32_t yoffset;
scriptfile_getsymbol(script,&yoffset);
newpsky->yoffs = yoffset;
break;
}
case T_LOGNUMTILES:
{
int32_t lognumtiles;
scriptfile_getsymbol(script,&lognumtiles);
if ((1<<lognumtiles) > MAXPSKYTILES)
break;
newpsky->lognumtiles = lognumtiles;
break;
}
case T_TILE:
{
int32_t panel, offset;
scriptfile_getsymbol(script,&panel);
scriptfile_getsymbol(script,&offset);
if ((unsigned) panel >= MAXPSKYTILES)
break;
if ((unsigned) offset > PSKYOFF_MAX)
break;
newpsky->tileofs[panel] = offset;
break;
}
case T_YSCALE:
{
int32_t yscale;
scriptfile_getsymbol(script,&yscale);
newpsky->yscale = yscale;
break;
}
default:
break;
}
}
}
break; break;
case T_BASEPALETTE: case T_BASEPALETTE:
{ {

View file

@ -56,8 +56,6 @@ int16_t pskybits_override = -1;
static int32_t beforedrawrooms = 1; static int32_t beforedrawrooms = 1;
int32_t globalflags;
static int8_t tempbuf[MAXWALLS]; static int8_t tempbuf[MAXWALLS];
static int32_t no_radarang2 = 0; static int32_t no_radarang2 = 0;

View file

@ -38,6 +38,7 @@
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor); int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor);
int tileSetSkybox(int picnum, int palnum, FString* facenames); int tileSetSkybox(int picnum, int palnum, FString* facenames);
void tileRemoveReplacement(int num); void tileRemoveReplacement(int num);
void AddUserMapHack(usermaphack_t&);
//=========================================================================== //===========================================================================
// //
@ -539,3 +540,106 @@ void parseTint(FScanner& sc, FScriptPosition& pos)
lookups.setPaletteTint(pal, clamp(red, 0, 255), clamp(green, 0, 255), clamp(blue, 0, 255), lookups.setPaletteTint(pal, clamp(red, 0, 255), clamp(green, 0, 255), clamp(blue, 0, 255),
clamp(shadered, 0, 255), clamp(shadegreen, 0, 255), clamp(shadeblue, 0, 255), flags); clamp(shadered, 0, 255), clamp(shadegreen, 0, 255), clamp(shadeblue, 0, 255), flags);
} }
//===========================================================================
//
//
//
//===========================================================================
void parseMusic(FScanner& sc, FScriptPosition& pos)
{
FString id, file;
FScanner::SavedPos blockend;
if (sc.StartBraces(&blockend)) return;
while (!sc.FoundEndBrace(blockend))
{
sc.MustGetString();
if (sc.Compare("id")) sc.GetString(id);
else if (sc.Compare("file")) sc.GetString(file);
}
SetMusicForMap(id, file, true);
}
//===========================================================================
//
//
//
//===========================================================================
void parseMapinfo(FScanner& sc, FScriptPosition& pos)
{
usermaphack_t mhk;
FScanner::SavedPos blockend;
if (sc.StartBraces(&blockend)) return;
while (!sc.FoundEndBrace(blockend))
{
sc.MustGetString();
if (sc.Compare("mapfile")) sc.GetString();
else if (sc.Compare("maptitle")) sc.GetString(mhk.title);
else if (sc.Compare("mhkfile")) sc.GetString(mhk.mhkfile);
else if (sc.Compare("mapmd4"))
{
sc.GetString();
for (int i = 0; i < 16; i++)
{
char smallbuf[3] = { sc.String[2 * i], sc.String[2 * i + 1], 0 };
mhk.md4[i] = strtol(smallbuf, nullptr, 16);
}
}
}
AddUserMapHack(mhk);
}
//===========================================================================
//
//
//
//===========================================================================
void parseEcho(FScanner& sc, FScriptPosition& pos)
{
sc.MustGetString();
Printf("%s\n", sc.String);
}
//===========================================================================
//
//
//
//===========================================================================
void parseMultiPsky(FScanner& sc, FScriptPosition& pos)
{
usermaphack_t mhk;
FScanner::SavedPos blockend;
psky_t sky{};
sky.yscale = 65536;
if (!sc.GetNumber(sky.tilenum, true)) return;
if (sc.StartBraces(&blockend)) return;
while (!sc.FoundEndBrace(blockend))
{
sc.MustGetString();
if (sc.Compare("horizfrac")) sc.GetNumber(sky.horizfrac, true);
else if (sc.Compare("yoffset")) sc.GetNumber(sky.yoffs, true);
else if (sc.Compare("lognumtiles")) sc.GetNumber(sky.lognumtiles, true);
else if (sc.Compare("yscale")) sc.GetNumber(sky.yscale, true);
else if (sc.Compare({ "tile", "panel" }))
{
int panel, offset;
sc.GetNumber(panel, true);
sc.GetNumber(offset, true);
if ((unsigned)panel < MAXPSKYTILES && (unsigned)offset <= PSKYOFF_MAX) sky.tileofs[panel] = offset;
}
}
if (sky.tilenum != DEFAULTPSKY && (unsigned)sky.tilenum >= MAXUSERTILES) return;
if ((1 << sky.lognumtiles) > MAXPSKYTILES) return;
auto psky = tileSetupSky(sky.tilenum);
*psky = sky;
}