2006-04-23 06:44:19 +00:00
|
|
|
/*
|
|
|
|
* Definitions file parser for Build
|
2012-03-12 04:47:04 +00:00
|
|
|
* by Jonathon Fowler (jf@jonof.id.au)
|
2006-04-23 06:44:19 +00:00
|
|
|
* Remixed substantially by Ken Silverman
|
|
|
|
* See the included license file "BUILDLIC.TXT" for license info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
#include "compat.h"
|
2011-01-27 07:05:12 +00:00
|
|
|
#include "engine_priv.h"
|
2006-04-23 06:44:19 +00:00
|
|
|
#include "scriptfile.h"
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2013-02-07 21:01:24 +00:00
|
|
|
#include "mdsprite.h" // md3model_t
|
2020-05-24 05:58:56 +00:00
|
|
|
#include "buildtiles.h"
|
2019-10-05 21:44:28 +00:00
|
|
|
#include "bitmap.h"
|
2019-11-01 18:25:42 +00:00
|
|
|
#include "m_argv.h"
|
|
|
|
#include "gamecontrol.h"
|
2020-04-12 05:50:24 +00:00
|
|
|
#include "palettecontainer.h"
|
2020-06-23 22:40:22 +00:00
|
|
|
#include "mapinfo.h"
|
|
|
|
|
2020-11-10 19:12:46 +00:00
|
|
|
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags);
|
|
|
|
int tileSetSkybox(int picnum, int palnum, const char** facenames, int flags);
|
|
|
|
void tileRemoveReplacement(int num);
|
|
|
|
|
2020-09-14 22:11:08 +00:00
|
|
|
|
|
|
|
int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
if (!sf) return T_ERROR;
|
|
|
|
if (!sf->GetString()) return T_EOF;
|
|
|
|
|
|
|
|
for (i=ntokens-1; i>=0; i--)
|
|
|
|
{
|
|
|
|
if (sf->Compare(tl[i].text))
|
|
|
|
return tl[i].tokenid;
|
|
|
|
}
|
|
|
|
return T_ERROR;
|
|
|
|
}
|
|
|
|
|
2020-09-13 11:01:44 +00:00
|
|
|
void AddUserMapHack(usermaphack_t&);
|
2020-06-23 22:40:22 +00:00
|
|
|
#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)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(pScript, soundTokens, countof(soundTokens)))
|
2020-06-23 22:40:22 +00:00
|
|
|
{
|
|
|
|
case T_ID: scriptfile_getstring(pScript, &musicID); break;
|
|
|
|
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!firstPass)
|
|
|
|
{
|
|
|
|
if (musicID == NULL)
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "missing ID for music definition\n");
|
2020-06-23 22:40:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fileName == NULL || fileSystem.FileExists(fileName))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (S_DefineMusic(musicID, fileName) == -1)
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "invalid music ID");
|
2020-06-23 22:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
enum scripttoken_t
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
T_INCLUDE = 0,
|
|
|
|
T_DEFINE,
|
|
|
|
T_DEFINETEXTURE,
|
|
|
|
T_DEFINESKYBOX,
|
|
|
|
T_DEFINETINT,
|
|
|
|
T_DEFINEMODEL,
|
|
|
|
T_DEFINEMODELFRAME,
|
|
|
|
T_DEFINEMODELANIM,
|
|
|
|
T_DEFINEMODELSKIN,
|
|
|
|
T_SELECTMODELSKIN,
|
|
|
|
T_DEFINEVOXEL,
|
|
|
|
T_DEFINEVOXELTILES,
|
|
|
|
T_MODEL,
|
|
|
|
T_FILE,
|
|
|
|
T_SCALE,
|
|
|
|
T_SHADE,
|
|
|
|
T_FRAME,
|
2007-04-12 03:09:41 +00:00
|
|
|
T_SMOOTHDURATION,
|
2006-04-24 19:04:22 +00:00
|
|
|
T_ANIM,
|
|
|
|
T_SKIN,
|
|
|
|
T_SURF,
|
|
|
|
T_TILE,
|
|
|
|
T_TILE0,
|
|
|
|
T_TILE1,
|
|
|
|
T_FRAME0,
|
|
|
|
T_FRAME1,
|
|
|
|
T_FPS,
|
|
|
|
T_FLAGS,
|
|
|
|
T_PAL,
|
2011-01-27 07:05:12 +00:00
|
|
|
T_BASEPAL,
|
2007-01-15 09:08:57 +00:00
|
|
|
T_DETAIL,
|
2007-02-15 01:35:34 +00:00
|
|
|
T_GLOW,
|
2009-04-28 22:56:43 +00:00
|
|
|
T_SPECULAR,
|
|
|
|
T_NORMAL,
|
2007-02-16 01:34:41 +00:00
|
|
|
T_PARAM,
|
2006-04-24 19:04:22 +00:00
|
|
|
T_HUD,
|
|
|
|
T_XADD,
|
|
|
|
T_YADD,
|
|
|
|
T_ZADD,
|
|
|
|
T_ANGADD,
|
2011-03-01 05:52:33 +00:00
|
|
|
T_FOV,
|
2006-04-24 19:04:22 +00:00
|
|
|
T_FLIPPED,
|
|
|
|
T_HIDE,
|
|
|
|
T_NOBOB,
|
|
|
|
T_NODEPTH,
|
|
|
|
T_VOXEL,
|
|
|
|
T_SKYBOX,
|
|
|
|
T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM,
|
2010-12-30 08:13:37 +00:00
|
|
|
T_HIGHPALOOKUP,
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
T_TINT,
|
|
|
|
T_MAKEPALOOKUP, T_REMAPPAL, T_REMAPSELF,
|
2015-09-23 17:55:19 +00:00
|
|
|
T_NOFLOORPAL, T_FLOORPAL,
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
T_RED,T_GREEN,T_BLUE,
|
2009-03-28 12:14:37 +00:00
|
|
|
T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_SPECPOWER,T_SPECFACTOR,T_NOCOMPRESS,T_NODOWNSIZE,
|
2015-03-28 09:49:37 +00:00
|
|
|
T_FORCEFILTER,
|
2016-05-02 18:29:35 +00:00
|
|
|
T_ARTQUALITY,
|
2013-09-14 17:58:46 +00:00
|
|
|
T_ORIGSIZEX,T_ORIGSIZEY,
|
2006-04-24 19:04:22 +00:00
|
|
|
T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE,
|
|
|
|
T_ALPHAHACK,T_ALPHAHACKRANGE,
|
2015-11-14 23:40:57 +00:00
|
|
|
T_SPRITECOL,T_2DCOL,T_2DCOLIDXRANGE,
|
2006-04-24 19:04:22 +00:00
|
|
|
T_FOGPAL,
|
|
|
|
T_LOADGRP,
|
2006-07-20 01:50:56 +00:00
|
|
|
T_DUMMYTILE,T_DUMMYTILERANGE,
|
2008-03-27 21:32:23 +00:00
|
|
|
T_SETUPTILE,T_SETUPTILERANGE,
|
2015-04-09 07:52:28 +00:00
|
|
|
T_UNDEFINETILE,T_UNDEFINETILERANGE,
|
2008-08-02 13:00:41 +00:00
|
|
|
T_ANIMTILERANGE,
|
2007-12-20 19:14:38 +00:00
|
|
|
T_CACHESIZE,
|
2008-11-24 09:22:07 +00:00
|
|
|
T_IMPORTTILE,
|
2007-12-20 19:14:38 +00:00
|
|
|
T_MUSIC,T_ID,T_SOUND,
|
2012-11-25 13:19:06 +00:00
|
|
|
T_TILEFROMTEXTURE, T_XOFFSET, T_YOFFSET, T_TEXHITSCAN, T_NOFULLBRIGHT,
|
2015-05-03 07:05:35 +00:00
|
|
|
T_ARTFILE,
|
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
|
|
|
T_INCLUDEDEFAULT,
|
|
|
|
T_ANIMSOUNDS,
|
2015-02-11 05:22:07 +00:00
|
|
|
T_CUTSCENE,
|
2012-04-04 18:57:58 +00:00
|
|
|
T_NOFLOORPALRANGE,
|
2012-10-14 20:41:34 +00:00
|
|
|
T_TEXHITSCANRANGE,
|
2012-11-25 13:19:06 +00:00
|
|
|
T_NOFULLBRIGHTRANGE,
|
2012-12-23 03:12:50 +00:00
|
|
|
T_MAPINFO, T_MAPFILE, T_MAPTITLE, T_MAPMD4, T_MHKFILE,
|
2012-03-10 09:44:17 +00:00
|
|
|
T_ECHO,
|
2015-03-09 20:32:36 +00:00
|
|
|
T_GLOBALFLAGS,
|
2015-04-12 08:07:30 +00:00
|
|
|
T_COPYTILE,
|
2015-04-24 00:08:46 +00:00
|
|
|
T_GLOBALGAMEFLAGS,
|
2015-05-27 08:47:50 +00:00
|
|
|
T_MULTIPSKY, T_HORIZFRAC, T_LOGNUMTILES,
|
2015-09-23 17:55:19 +00:00
|
|
|
T_BASEPALETTE, T_PALOOKUP, T_BLENDTABLE,
|
|
|
|
T_RAW, T_OFFSET, T_SHIFTLEFT, T_NOSHADES, T_COPY,
|
2015-09-27 21:18:24 +00:00
|
|
|
T_NUMALPHATABS,
|
2015-10-03 11:52:51 +00:00
|
|
|
T_UNDEF,
|
|
|
|
T_UNDEFBASEPALETTERANGE, T_UNDEFPALOOKUPRANGE, T_UNDEFBLENDTABLERANGE,
|
2016-10-09 07:55:23 +00:00
|
|
|
T_GLBLEND, T_FORWARD, T_REVERSE, T_BOTH, T_SRC, T_DST, T_ALPHA,
|
|
|
|
T_ZERO, T_ONE,
|
|
|
|
T_SRC_COLOR, T_ONE_MINUS_SRC_COLOR,
|
|
|
|
T_SRC_ALPHA, T_ONE_MINUS_SRC_ALPHA,
|
|
|
|
T_DST_ALPHA, T_ONE_MINUS_DST_ALPHA,
|
|
|
|
T_DST_COLOR, T_ONE_MINUS_DST_COLOR,
|
2017-12-12 05:13:58 +00:00
|
|
|
T_SHADERED, T_SHADEGREEN, T_SHADEBLUE,
|
2018-01-26 04:35:15 +00:00
|
|
|
T_SHADEFACTOR,
|
2019-12-22 10:19:59 +00:00
|
|
|
T_IFCRC,T_IFMATCH,T_CRC32,
|
|
|
|
T_SIZE,
|
2019-08-09 08:21:19 +00:00
|
|
|
T_NEWGAMECHOICES,
|
2019-09-17 05:07:28 +00:00
|
|
|
T_RFFDEFINEID,
|
|
|
|
T_EXTRA,
|
|
|
|
T_ROTATE,
|
2020-08-19 18:29:37 +00:00
|
|
|
T_SURFACE, T_VIEW,
|
2006-04-23 06:44:19 +00:00
|
|
|
};
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0;
|
2014-09-30 04:17:53 +00:00
|
|
|
static char *faketilebuffer = NULL;
|
|
|
|
static int32_t faketilebuffersiz = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
static const char *skyfaces[6] =
|
|
|
|
{
|
|
|
|
"front face", "right face", "back face",
|
|
|
|
"left face", "top face", "bottom face"
|
|
|
|
};
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2011-07-21 22:39:29 +00:00
|
|
|
static int32_t defsparser(scriptfile *script);
|
|
|
|
|
2020-09-14 22:11:08 +00:00
|
|
|
static void defsparser_include(const char *fn, scriptfile *script, FScriptPosition *pos)
|
2011-07-21 22:39:29 +00:00
|
|
|
{
|
|
|
|
scriptfile *included;
|
|
|
|
|
|
|
|
included = scriptfile_fromfile(fn);
|
2020-09-04 19:24:48 +00:00
|
|
|
if (!included)
|
2011-07-21 22:39:29 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
if (!pos)
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Warning: Failed including %s as module\n", fn);
|
2011-07-21 22:39:29 +00:00
|
|
|
else
|
2020-09-14 20:55:21 +00:00
|
|
|
pos->Message(MSG_ERROR, "Failed including %s", fn);
|
2011-07-21 22:39:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-14 22:11:08 +00:00
|
|
|
if (script) included->symbols = std::move(script->symbols);
|
2011-07-21 22:39:29 +00:00
|
|
|
defsparser(included);
|
2020-09-14 22:11:08 +00:00
|
|
|
if (script) script->symbols = std::move(included->symbols);
|
2011-07-21 22:39:29 +00:00
|
|
|
scriptfile_close(included);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-04 18:58:19 +00:00
|
|
|
|
|
|
|
static int32_t check_tile_range(const char *defcmd, int32_t *tilebeg, int32_t *tileend,
|
2020-09-14 20:55:21 +00:00
|
|
|
const scriptfile *script, FScriptPosition pos)
|
2012-04-04 18:58:19 +00:00
|
|
|
{
|
2020-09-04 19:24:48 +00:00
|
|
|
if (*tileend < *tilebeg)
|
2012-04-04 18:58:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_WARNING, "%s: backwards tile range", defcmd);
|
2020-09-10 14:36:31 +00:00
|
|
|
std::swap(*tilebeg, *tileend);
|
2012-04-04 18:58:19 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)*tilebeg >= MAXUSERTILES || (unsigned)*tileend >= MAXUSERTILES)
|
2012-04-04 18:58:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "%s: Invalid tile range", defcmd);
|
2012-04-04 18:58:19 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
static int32_t check_tile(const char *defcmd, int32_t tile, const scriptfile *script, FScriptPosition pos)
|
2012-04-04 18:58:19 +00:00
|
|
|
{
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)tile >= MAXUSERTILES)
|
2012-04-04 18:58:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "%s: Invalid tile number", defcmd);
|
2012-04-04 18:58:19 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-30 18:10:50 +00:00
|
|
|
#undef USE_DEF_PROGRESS
|
|
|
|
#if defined _WIN32 || defined HAVE_GTK2
|
|
|
|
# define USE_DEF_PROGRESS
|
|
|
|
#endif
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t defsparser(scriptfile *script)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t tokn;
|
2013-05-30 18:10:50 +00:00
|
|
|
#ifdef USE_DEF_PROGRESS
|
2013-05-23 18:27:24 +00:00
|
|
|
static uint32_t iter = 0;
|
2013-05-30 18:10:50 +00:00
|
|
|
#endif
|
2010-08-02 08:13:51 +00:00
|
|
|
|
|
|
|
static const tokenlist basetokens[] =
|
|
|
|
{
|
|
|
|
{ "include", T_INCLUDE },
|
|
|
|
{ "#include", T_INCLUDE },
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
{ "includedefault", T_INCLUDEDEFAULT },
|
|
|
|
{ "#includedefault", T_INCLUDEDEFAULT },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "define", T_DEFINE },
|
|
|
|
{ "#define", T_DEFINE },
|
|
|
|
|
|
|
|
// deprecated style
|
|
|
|
{ "definetexture", T_DEFINETEXTURE },
|
|
|
|
{ "defineskybox", T_DEFINESKYBOX },
|
|
|
|
{ "definetint", T_DEFINETINT },
|
|
|
|
{ "definemodel", T_DEFINEMODEL },
|
|
|
|
{ "definemodelframe",T_DEFINEMODELFRAME },
|
|
|
|
{ "definemodelanim", T_DEFINEMODELANIM },
|
|
|
|
{ "definemodelskin", T_DEFINEMODELSKIN },
|
|
|
|
{ "selectmodelskin", T_SELECTMODELSKIN },
|
|
|
|
{ "definevoxel", T_DEFINEVOXEL },
|
|
|
|
{ "definevoxeltiles",T_DEFINEVOXELTILES },
|
|
|
|
|
|
|
|
// new style
|
|
|
|
{ "model", T_MODEL },
|
|
|
|
{ "voxel", T_VOXEL },
|
|
|
|
{ "skybox", T_SKYBOX },
|
2010-12-30 08:13:37 +00:00
|
|
|
{ "highpalookup", T_HIGHPALOOKUP },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "tint", T_TINT },
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
{ "makepalookup", T_MAKEPALOOKUP },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "texture", T_TEXTURE },
|
|
|
|
{ "tile", T_TEXTURE },
|
|
|
|
{ "music", T_MUSIC },
|
|
|
|
{ "sound", T_SOUND },
|
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
|
|
|
{ "animsounds", T_ANIMSOUNDS }, // dummy
|
2015-02-11 05:22:07 +00:00
|
|
|
{ "cutscene", T_CUTSCENE },
|
2014-12-13 22:33:04 +00:00
|
|
|
{ "nofloorpalrange", T_NOFLOORPALRANGE },
|
2012-10-14 20:41:34 +00:00
|
|
|
{ "texhitscanrange", T_TEXHITSCANRANGE },
|
2012-11-25 13:19:06 +00:00
|
|
|
{ "nofullbrightrange", T_NOFULLBRIGHTRANGE },
|
2010-08-02 08:13:51 +00:00
|
|
|
// other stuff
|
|
|
|
{ "undefmodel", T_UNDEFMODEL },
|
|
|
|
{ "undefmodelrange", T_UNDEFMODELRANGE },
|
|
|
|
{ "undefmodelof", T_UNDEFMODELOF },
|
|
|
|
{ "undeftexture", T_UNDEFTEXTURE },
|
|
|
|
{ "undeftexturerange", T_UNDEFTEXTURERANGE },
|
|
|
|
{ "alphahack", T_ALPHAHACK },
|
|
|
|
{ "alphahackrange", T_ALPHAHACKRANGE },
|
|
|
|
{ "spritecol", T_SPRITECOL },
|
|
|
|
{ "2dcol", T_2DCOL },
|
2015-11-14 23:40:57 +00:00
|
|
|
{ "2dcolidxrange", T_2DCOLIDXRANGE },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "fogpal", T_FOGPAL },
|
|
|
|
{ "loadgrp", T_LOADGRP },
|
|
|
|
{ "dummytile", T_DUMMYTILE },
|
|
|
|
{ "dummytilerange", T_DUMMYTILERANGE },
|
|
|
|
{ "setuptile", T_SETUPTILE },
|
|
|
|
{ "setuptilerange", T_SETUPTILERANGE },
|
2015-04-09 07:52:28 +00:00
|
|
|
{ "undefinetile", T_UNDEFINETILE },
|
2015-04-09 07:56:36 +00:00
|
|
|
{ "undefinetilerange", T_UNDEFINETILERANGE },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "animtilerange", T_ANIMTILERANGE },
|
|
|
|
{ "cachesize", T_CACHESIZE },
|
|
|
|
{ "dummytilefrompic",T_IMPORTTILE },
|
|
|
|
{ "tilefromtexture", T_TILEFROMTEXTURE },
|
2015-05-03 07:05:35 +00:00
|
|
|
{ "artfile", T_ARTFILE },
|
2015-01-08 15:14:00 +00:00
|
|
|
{ "mapinfo", T_MAPINFO },
|
2012-03-10 09:44:17 +00:00
|
|
|
{ "echo", T_ECHO },
|
2015-03-09 20:32:36 +00:00
|
|
|
{ "globalflags", T_GLOBALFLAGS },
|
2015-04-12 08:07:30 +00:00
|
|
|
{ "copytile", T_COPYTILE },
|
2015-04-24 00:08:46 +00:00
|
|
|
{ "globalgameflags", T_GLOBALGAMEFLAGS }, // dummy
|
2015-05-27 08:47:50 +00:00
|
|
|
{ "multipsky", T_MULTIPSKY },
|
2015-09-23 17:55:19 +00:00
|
|
|
{ "basepalette", T_BASEPALETTE },
|
|
|
|
{ "palookup", T_PALOOKUP },
|
|
|
|
{ "blendtable", T_BLENDTABLE },
|
2015-09-27 21:18:24 +00:00
|
|
|
{ "numalphatables", T_NUMALPHATABS },
|
2015-10-03 11:52:51 +00:00
|
|
|
{ "undefbasepaletterange", T_UNDEFBASEPALETTERANGE },
|
|
|
|
{ "undefpalookuprange", T_UNDEFPALOOKUPRANGE },
|
|
|
|
{ "undefblendtablerange", T_UNDEFBLENDTABLERANGE },
|
2018-01-26 04:35:15 +00:00
|
|
|
{ "shadefactor", T_SHADEFACTOR },
|
2019-08-09 08:21:19 +00:00
|
|
|
{ "newgamechoices", T_NEWGAMECHOICES },
|
2019-09-19 20:02:45 +00:00
|
|
|
{ "rffdefineid", T_RFFDEFINEID }, // dummy
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2013-05-30 18:10:50 +00:00
|
|
|
#ifdef USE_DEF_PROGRESS
|
2013-05-23 18:27:24 +00:00
|
|
|
if (++iter >= 50)
|
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf(".");
|
2013-05-23 18:27:24 +00:00
|
|
|
iter = 0;
|
|
|
|
}
|
2013-05-30 18:10:50 +00:00
|
|
|
#endif
|
2020-09-08 16:48:18 +00:00
|
|
|
tokn = getatoken(script,basetokens,countof(basetokens));
|
2020-09-14 20:55:21 +00:00
|
|
|
auto pos = scriptfile_getposition(script);
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (tokn)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_ERROR:
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "Unknown error");
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
case T_EOF:
|
2016-06-21 00:34:41 +00:00
|
|
|
return 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_INCLUDE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!scriptfile_getstring(script,&fn))
|
2020-09-14 20:55:21 +00:00
|
|
|
defsparser_include(fn, script, &pos);
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
case T_INCLUDEDEFAULT:
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
defsparser_include(G_DefaultDefFile(), script, &pos);
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString name;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t number;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getstring(script,&name)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&number)) break;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2020-09-14 22:11:08 +00:00
|
|
|
if (scriptfile_addsymbolvalue(script, name,number) < 0)
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_WARNING, "Warning: Symbol %s was NOT redefined to %d", name.GetChars(),number);
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
// OLD (DEPRECATED) DEFINITION SYNTAX
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINETEXTURE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2012-03-28 19:41:39 +00:00
|
|
|
int32_t tile,pal,fnoo;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&pal)) break;
|
|
|
|
if (scriptfile_getnumber(script,&fnoo)) break; //x-center
|
|
|
|
if (scriptfile_getnumber(script,&fnoo)) break; //y-center
|
|
|
|
if (scriptfile_getnumber(script,&fnoo)) break; //x-size
|
|
|
|
if (scriptfile_getnumber(script,&fnoo)) break; //y-size
|
|
|
|
if (scriptfile_getstring(script,&fn)) break;
|
|
|
|
|
2020-09-12 10:39:18 +00:00
|
|
|
if (!fileSystem.FileExists(fn))
|
2012-03-28 19:41:39 +00:00
|
|
|
break;
|
2006-10-31 18:32:29 +00:00
|
|
|
|
2019-10-17 10:45:25 +00:00
|
|
|
tileSetHightileReplacement(tile,pal,fn,-1.0,1.0,1.0,1.0,1.0,0);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINESKYBOX:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2012-03-28 19:41:39 +00:00
|
|
|
int32_t tile,pal,i;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn[6];
|
|
|
|
int happy = 1;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&pal)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&i)) break; //future expansion
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<6; i++)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getstring(script,&fn[i])) break; //grab the 6 faces
|
2007-05-01 04:35:27 +00:00
|
|
|
|
2020-09-12 10:39:18 +00:00
|
|
|
if (!fileSystem.FileExists(fn[i]))
|
2012-03-28 19:41:39 +00:00
|
|
|
happy = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
if (i < 6 || !happy) break;
|
2019-10-17 10:45:25 +00:00
|
|
|
tileSetSkybox(tile, pal, (const char **)fn, 0);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINETINT:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2018-02-18 00:24:54 +00:00
|
|
|
int32_t pal, r,g,b,f;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&pal)) break;
|
|
|
|
if (scriptfile_getnumber(script,&r)) break;
|
|
|
|
if (scriptfile_getnumber(script,&g)) break;
|
|
|
|
if (scriptfile_getnumber(script,&b)) break;
|
|
|
|
if (scriptfile_getnumber(script,&f)) break; //effects
|
2020-05-29 18:15:42 +00:00
|
|
|
lookups.setPaletteTint(pal,r,g,b,0,0,0,f);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_ALPHAHACK:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t tile;
|
2006-11-13 23:12:47 +00:00
|
|
|
double alpha;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (scriptfile_getdouble(script,&alpha)) break;
|
2012-03-28 19:41:15 +00:00
|
|
|
if ((uint32_t)tile < MAXTILES)
|
2020-09-12 10:39:18 +00:00
|
|
|
TileFiles.tiledata[tile].texture->alphaThreshold = (float)alpha;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_ALPHAHACKRANGE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2013-01-08 06:17:10 +00:00
|
|
|
int32_t tilenume1,tilenume2;
|
2006-11-13 23:12:47 +00:00
|
|
|
double alpha;
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tilenume1)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&tilenume2)) break;
|
|
|
|
if (scriptfile_getdouble(script,&alpha)) break;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("alphahackrange", &tilenume1, &tilenume2, script, pos))
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
|
|
|
|
2020-05-29 21:33:26 +00:00
|
|
|
for (int i=tilenume1; i<=tilenume2; i++)
|
2020-09-12 10:39:18 +00:00
|
|
|
TileFiles.tiledata[i].texture->alphaThreshold = (float)alpha;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_SPRITECOL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t tile,col,col2;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (scriptfile_getnumber(script,&col)) break;
|
|
|
|
if (scriptfile_getnumber(script,&col2)) break;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_2DCOL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t col,b,g,r;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
|
|
|
if (scriptfile_getnumber(script,&col)) break;
|
|
|
|
if (scriptfile_getnumber(script,&r)) break;
|
|
|
|
if (scriptfile_getnumber(script,&g)) break;
|
|
|
|
if (scriptfile_getnumber(script,&b)) break;
|
|
|
|
|
2012-03-18 23:17:51 +00:00
|
|
|
if ((unsigned)col < 256)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-11-14 23:40:57 +00:00
|
|
|
case T_2DCOLIDXRANGE: // NOTE: takes precedence over 2dcol, see InitCustomColors()
|
|
|
|
{
|
|
|
|
int32_t col, idx, idxend;
|
|
|
|
|
|
|
|
if (scriptfile_getnumber(script,&col)) break;
|
|
|
|
if (scriptfile_getnumber(script,&idx)) break;
|
|
|
|
if (scriptfile_getnumber(script,&idxend)) break;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_FOGPAL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2012-03-29 21:17:03 +00:00
|
|
|
int32_t p,r,g,b;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
Ensure that anywhere the def parser takes a tilenum or palnum accepts defined tokens in addition to integer literals, if it doesn't already.
Affects fogpal, nofloorpalrange, setuptilerange, dummytilerange, undefinetilerange, definemodelframe, definevoxeltiles, texhitscanrange, nofullbrightrange, and light.
git-svn-id: https://svn.eduke32.com/eduke32@6896 1a8010ca-5511-0410-912e-c29ae57300e0
2018-05-23 05:43:35 +00:00
|
|
|
if (scriptfile_getsymbol(script,&p)) break;
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getnumber(script,&r)) break;
|
|
|
|
if (scriptfile_getnumber(script,&g)) break;
|
|
|
|
if (scriptfile_getnumber(script,&b)) break;
|
|
|
|
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
r = clamp(r, 0, 63);
|
|
|
|
g = clamp(g, 0, 63);
|
|
|
|
b = clamp(b, 0, 63);
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.makeTable(p, NULL, r<<2, g<<2, b<<2, 1);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-12-13 22:33:04 +00:00
|
|
|
case T_NOFLOORPALRANGE:
|
|
|
|
{
|
|
|
|
int32_t b,e,i;
|
|
|
|
|
Ensure that anywhere the def parser takes a tilenum or palnum accepts defined tokens in addition to integer literals, if it doesn't already.
Affects fogpal, nofloorpalrange, setuptilerange, dummytilerange, undefinetilerange, definemodelframe, definevoxeltiles, texhitscanrange, nofullbrightrange, and light.
git-svn-id: https://svn.eduke32.com/eduke32@6896 1a8010ca-5511-0410-912e-c29ae57300e0
2018-05-23 05:43:35 +00:00
|
|
|
if (scriptfile_getsymbol(script,&b)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&e)) break;
|
2014-12-13 22:33:04 +00:00
|
|
|
|
|
|
|
b = max(b, 1);
|
|
|
|
e = min(e, MAXPALOOKUPS-1);
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
for (i = b; i <= e; i++)
|
|
|
|
lookups.tables[i].noFloorPal = true;
|
2014-12-13 22:33:04 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_LOADGRP:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
scriptfile_getstring(script,nullptr);
|
2020-06-23 22:40:22 +00:00
|
|
|
#if 0
|
|
|
|
if (!scriptfile_getstring(pScript, &fileName) && firstPass)
|
|
|
|
{
|
|
|
|
fileSystem.AddAdditionalFile(fileName);
|
|
|
|
}
|
|
|
|
#endif
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-01-02 02:27:31 +00:00
|
|
|
case T_CACHESIZE:
|
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t j;
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2007-01-02 02:27:31 +00:00
|
|
|
if (scriptfile_getnumber(script,&j)) break;
|
|
|
|
}
|
|
|
|
break;
|
2018-01-26 04:35:15 +00:00
|
|
|
case T_SHADEFACTOR:
|
2020-04-12 05:51:11 +00:00
|
|
|
//scriptfile_getnumber(script, &realmaxshade);
|
|
|
|
//frealmaxshade = (float)realmaxshade;
|
2018-01-26 04:35:15 +00:00
|
|
|
break;
|
2015-05-03 07:05:35 +00:00
|
|
|
case T_ARTFILE:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos blockend;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2015-05-03 07:05:35 +00:00
|
|
|
int32_t tile = -1, havetile = 0;
|
|
|
|
|
|
|
|
static const tokenlist artfiletokens[] =
|
|
|
|
{
|
|
|
|
{ "file", T_FILE },
|
|
|
|
{ "tile", T_TILE },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&blockend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, blockend))
|
2015-05-03 07:05:35 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,artfiletokens,countof(artfiletokens));
|
2015-05-03 07:05:35 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_FILE:
|
|
|
|
scriptfile_getstring(script,&fn);
|
|
|
|
break;
|
|
|
|
case T_TILE:
|
|
|
|
havetile = 1;
|
|
|
|
scriptfile_getsymbol(script,&tile);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (fn.IsEmpty())
|
2015-05-03 07:05:35 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "missing 'file name' for artfile definition");
|
2015-05-03 07:05:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-14 20:55:21 +00:00
|
|
|
if (!check_tile("artfile", tile, script, pos))
|
2020-05-24 20:37:50 +00:00
|
|
|
TileFiles.LoadArtFile(fn, nullptr, tile);
|
2015-05-03 07:05:35 +00:00
|
|
|
}
|
|
|
|
break;
|
2020-09-23 14:54:52 +00:00
|
|
|
case T_SETUPTILE:
|
|
|
|
{
|
|
|
|
int tile, tmp;
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (check_tile("setuptile", tile, script, pos))
|
|
|
|
break;
|
|
|
|
auto& tiled = TileFiles.tiledata[tile];
|
|
|
|
if (scriptfile_getsymbol(script,&tmp)) break; // XXX
|
|
|
|
tiled.h_xsize = tmp;
|
|
|
|
if (scriptfile_getsymbol(script,&tmp)) break;
|
|
|
|
tiled.h_ysize = tmp;
|
|
|
|
if (scriptfile_getsymbol(script,&tmp)) break;
|
|
|
|
tiled.h_xoffs = tmp;
|
|
|
|
if (scriptfile_getsymbol(script,&tmp)) break;
|
|
|
|
tiled.h_yoffs = tmp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_SETUPTILERANGE:
|
|
|
|
{
|
|
|
|
int tile1,tile2,xsiz,ysiz,xoffs,yoffs,i;
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile1)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&tile2)) break;
|
|
|
|
if (scriptfile_getnumber(script,&xsiz)) break;
|
|
|
|
if (scriptfile_getnumber(script,&ysiz)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&xoffs)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&yoffs)) break;
|
|
|
|
|
|
|
|
if (check_tile_range("setuptilerange", &tile1, &tile2, script, pos))
|
|
|
|
break;
|
|
|
|
|
|
|
|
for (i=tile1; i<=tile2; i++)
|
|
|
|
{
|
|
|
|
auto& tiled = TileFiles.tiledata[i];
|
|
|
|
|
|
|
|
tiled.h_xsize = xsiz;
|
|
|
|
tiled.h_ysize = ysiz;
|
|
|
|
tiled.h_xoffs = xoffs;
|
|
|
|
tiled.h_yoffs = yoffs;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2008-08-02 13:00:41 +00:00
|
|
|
case T_ANIMTILERANGE:
|
|
|
|
{
|
2020-09-15 22:21:17 +00:00
|
|
|
SetAnim set;
|
|
|
|
if (scriptfile_getsymbol(script,&set.tile1)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&set.tile2)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&set.speed)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&set.type)) break;
|
|
|
|
processSetAnim("animtilerange", pos, set);
|
2008-08-02 13:00:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-24 11:31:05 +00:00
|
|
|
case T_TILEFROMTEXTURE:
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto texturepos = scriptfile_getposition(script);
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos textureend;
|
2020-09-14 23:21:17 +00:00
|
|
|
TileImport imp;
|
2008-11-24 11:31:05 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist tilefromtexturetokens[] =
|
|
|
|
{
|
|
|
|
{ "file", T_FILE },
|
|
|
|
{ "name", T_FILE },
|
|
|
|
{ "alphacut", T_ALPHACUT },
|
|
|
|
{ "xoffset", T_XOFFSET },
|
|
|
|
{ "xoff", T_XOFFSET },
|
|
|
|
{ "yoffset", T_YOFFSET },
|
|
|
|
{ "yoff", T_YOFFSET },
|
2012-10-14 20:41:34 +00:00
|
|
|
{ "texhitscan", T_TEXHITSCAN },
|
2012-11-25 13:19:06 +00:00
|
|
|
{ "nofullbright", T_NOFULLBRIGHT },
|
2015-05-27 08:45:13 +00:00
|
|
|
{ "texture", T_TEXTURE },
|
2019-03-02 23:21:37 +00:00
|
|
|
{ "ifcrc", T_IFCRC },
|
2019-12-22 10:19:59 +00:00
|
|
|
{ "ifmatch", T_IFMATCH },
|
2019-07-23 15:56:39 +00:00
|
|
|
{ "extra", T_EXTRA },
|
2020-08-19 18:29:37 +00:00
|
|
|
// Blood also defines these.
|
|
|
|
{ "surface", T_SURFACE },
|
|
|
|
{ "voxel", T_VOXEL },
|
|
|
|
{ "view", T_VIEW },
|
|
|
|
{ "shade", T_SHADE },
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2020-09-14 23:21:17 +00:00
|
|
|
if (scriptfile_getsymbol(script,&imp.tile)) break;
|
2008-11-24 11:31:05 +00:00
|
|
|
if (scriptfile_getbraces(script,&textureend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, textureend))
|
2008-11-24 11:31:05 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,tilefromtexturetokens,countof(tilefromtexturetokens));
|
2008-11-24 11:31:05 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_FILE:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getstring(script,&imp.fn);
|
2015-05-03 07:05:04 +00:00
|
|
|
break;
|
2008-11-24 11:31:05 +00:00
|
|
|
case T_ALPHACUT:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script,&imp.alphacut);
|
|
|
|
imp.alphacut = clamp(imp.alphacut, 0, 255);
|
2015-05-03 07:05:04 +00:00
|
|
|
break;
|
2008-12-19 00:53:54 +00:00
|
|
|
case T_XOFFSET:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script,&imp.xoffset);
|
|
|
|
imp.xoffset = clamp(imp.xoffset, -128, 127);
|
2015-05-03 07:05:04 +00:00
|
|
|
break;
|
2008-12-19 00:53:54 +00:00
|
|
|
case T_YOFFSET:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script,&imp.yoffset);
|
|
|
|
imp.yoffset = clamp(imp.yoffset, -128, 127);
|
2015-05-03 07:05:04 +00:00
|
|
|
break;
|
2019-03-02 23:21:37 +00:00
|
|
|
case T_IFCRC:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.crc32);
|
2019-03-02 23:21:37 +00:00
|
|
|
break;
|
2019-12-22 10:19:59 +00:00
|
|
|
case T_IFMATCH:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos ifmatchend;
|
2019-12-22 10:19:59 +00:00
|
|
|
|
|
|
|
static const tokenlist ifmatchtokens[] =
|
|
|
|
{
|
|
|
|
{ "crc32", T_CRC32 },
|
|
|
|
{ "size", T_SIZE },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&ifmatchend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, ifmatchend))
|
2019-12-22 10:19:59 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,ifmatchtokens,countof(ifmatchtokens));
|
2019-12-22 10:19:59 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_CRC32:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.crc32);
|
2019-12-22 10:19:59 +00:00
|
|
|
break;
|
|
|
|
case T_SIZE:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.sizex);
|
|
|
|
scriptfile_getsymbol(script, &imp.sizey);
|
2019-12-22 10:19:59 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-10-14 20:41:34 +00:00
|
|
|
case T_TEXHITSCAN:
|
2020-09-14 23:21:17 +00:00
|
|
|
imp.flags |= PICANM_TEXHITSCAN_BIT;
|
2013-07-20 03:37:10 +00:00
|
|
|
break;
|
|
|
|
case T_NOFULLBRIGHT:
|
2020-09-14 23:21:17 +00:00
|
|
|
imp.flags |= PICANM_NOFULLBRIGHT_BIT;
|
2008-11-24 11:31:05 +00:00
|
|
|
break;
|
2015-05-27 08:45:13 +00:00
|
|
|
case T_TEXTURE:
|
2020-09-14 23:21:17 +00:00
|
|
|
imp.istexture = 1;
|
2015-05-27 08:45:13 +00:00
|
|
|
break;
|
2019-07-23 15:56:39 +00:00
|
|
|
case T_EXTRA:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.extra);
|
2019-07-23 15:56:39 +00:00
|
|
|
break;
|
2020-08-19 18:29:37 +00:00
|
|
|
case T_SURFACE:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.surface);
|
2020-08-19 18:29:37 +00:00
|
|
|
break;
|
|
|
|
case T_VOXEL:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.vox);
|
2020-08-19 18:29:37 +00:00
|
|
|
break;
|
|
|
|
case T_VIEW:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.extra);
|
|
|
|
imp.extra &= 7;
|
2020-08-19 18:29:37 +00:00
|
|
|
break;
|
|
|
|
case T_SHADE:
|
2020-09-14 23:21:17 +00:00
|
|
|
scriptfile_getsymbol(script, &imp.shade);
|
2020-08-19 18:29:37 +00:00
|
|
|
break;
|
|
|
|
|
2012-10-14 20:41:34 +00:00
|
|
|
default:
|
2008-11-24 11:31:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-15 22:10:12 +00:00
|
|
|
processTileImport("tileimporttexture", pos, imp);
|
2008-11-24 11:31:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-04-12 08:07:30 +00:00
|
|
|
case T_COPYTILE:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos blockend;
|
2015-04-12 08:07:30 +00:00
|
|
|
int32_t tile = -1, source;
|
|
|
|
int32_t havetile = 0, havexoffset = 0, haveyoffset = 0;
|
2019-10-15 21:38:01 +00:00
|
|
|
int32_t xoffset = -1024, yoffset = -1024;
|
2015-04-12 08:07:30 +00:00
|
|
|
int32_t flags = 0;
|
|
|
|
int32_t tsiz = 0;
|
2019-10-15 21:38:01 +00:00
|
|
|
int32_t temppal = -1;
|
|
|
|
int32_t tempsource = -1;
|
2015-04-12 08:07:30 +00:00
|
|
|
|
|
|
|
static const tokenlist copytiletokens[] =
|
|
|
|
{
|
|
|
|
{ "tile", T_TILE },
|
|
|
|
{ "pal", T_PAL },
|
|
|
|
{ "xoffset", T_XOFFSET },
|
|
|
|
{ "xoff", T_XOFFSET },
|
|
|
|
{ "yoffset", T_YOFFSET },
|
|
|
|
{ "yoff", T_YOFFSET },
|
|
|
|
{ "texhitscan", T_TEXHITSCAN },
|
|
|
|
{ "nofullbright", T_NOFULLBRIGHT },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
source = tile; // without a "tile" token, we still palettize self by default
|
|
|
|
if (scriptfile_getbraces(script,&blockend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, blockend))
|
2015-04-12 08:07:30 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,copytiletokens,countof(copytiletokens));
|
2015-04-12 08:07:30 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_TILE:
|
|
|
|
{
|
|
|
|
scriptfile_getsymbol(script,&tempsource);
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("copytile", tempsource, script, pos))
|
2015-04-12 08:07:30 +00:00
|
|
|
break;
|
|
|
|
source = tempsource;
|
|
|
|
|
|
|
|
havetile = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_PAL:
|
|
|
|
{
|
|
|
|
scriptfile_getsymbol(script,&temppal);
|
|
|
|
|
|
|
|
// palettize self case
|
|
|
|
if (!havetile)
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("copytile", source, script, pos))
|
2015-04-12 08:07:30 +00:00
|
|
|
break;
|
|
|
|
havetile = 1;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)temppal >= MAXPALOOKUPS-RESERVEDPALS)
|
2015-04-12 08:07:30 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "copytile 'palette number' out of range (max=%d)\n",
|
2015-04-12 08:07:30 +00:00
|
|
|
MAXPALOOKUPS-RESERVEDPALS-1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_XOFFSET:
|
|
|
|
havexoffset = 1;
|
|
|
|
scriptfile_getsymbol(script,&xoffset); break;
|
|
|
|
case T_YOFFSET:
|
|
|
|
haveyoffset = 1;
|
|
|
|
scriptfile_getsymbol(script,&yoffset); break;
|
|
|
|
case T_TEXHITSCAN:
|
|
|
|
flags |= PICANM_TEXHITSCAN_BIT;
|
|
|
|
break;
|
|
|
|
case T_NOFULLBRIGHT:
|
|
|
|
flags |= PICANM_NOFULLBRIGHT_BIT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("copytile", tile, script, pos))
|
2015-04-12 08:07:30 +00:00
|
|
|
break;
|
|
|
|
|
2019-10-15 21:38:01 +00:00
|
|
|
if (!havetile)
|
2015-04-12 08:07:30 +00:00
|
|
|
{
|
2019-10-15 21:38:01 +00:00
|
|
|
// if !havetile, we have never confirmed a valid source
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("copytile", source, script, pos))
|
2015-04-12 08:07:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:38:01 +00:00
|
|
|
tileCopy(tile, tempsource, temppal, xoffset, yoffset, flags);
|
2015-04-12 08:07:30 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-11-24 09:22:07 +00:00
|
|
|
case T_IMPORTTILE:
|
|
|
|
{
|
2015-05-03 07:05:04 +00:00
|
|
|
int32_t tile;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2008-11-24 09:22:07 +00:00
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (scriptfile_getstring(script,&fn)) break;
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("importtile", tile, script, pos))
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
2008-11-24 09:22:07 +00:00
|
|
|
|
2019-10-15 21:38:01 +00:00
|
|
|
int32_t const texstatus = tileImportFromTexture(fn, tile, 255, 0);
|
2015-05-03 07:05:04 +00:00
|
|
|
if (texstatus < 0)
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
|
|
|
|
2019-10-08 20:23:48 +00:00
|
|
|
picanm[tile] = {};
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2008-11-24 09:22:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-26 01:25:18 +00:00
|
|
|
case T_DUMMYTILE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2012-04-04 18:58:19 +00:00
|
|
|
int32_t tile, xsiz, ysiz;
|
2006-04-26 01:25:18 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&xsiz)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&ysiz)) break;
|
2006-08-04 04:01:17 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("dummytile", tile, script, pos))
|
2015-04-12 08:06:51 +00:00
|
|
|
break;
|
2015-04-09 07:52:28 +00:00
|
|
|
|
2019-10-15 21:29:47 +00:00
|
|
|
tileSetDummy(tile, xsiz, ysiz);
|
2006-11-13 23:12:47 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2006-04-26 01:25:18 +00:00
|
|
|
case T_DUMMYTILERANGE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2012-04-04 18:58:19 +00:00
|
|
|
int32_t tile1,tile2,xsiz,ysiz,i;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
Ensure that anywhere the def parser takes a tilenum or palnum accepts defined tokens in addition to integer literals, if it doesn't already.
Affects fogpal, nofloorpalrange, setuptilerange, dummytilerange, undefinetilerange, definemodelframe, definevoxeltiles, texhitscanrange, nofullbrightrange, and light.
git-svn-id: https://svn.eduke32.com/eduke32@6896 1a8010ca-5511-0410-912e-c29ae57300e0
2018-05-23 05:43:35 +00:00
|
|
|
if (scriptfile_getsymbol(script,&tile1)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&tile2)) break;
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getnumber(script,&xsiz)) break;
|
|
|
|
if (scriptfile_getnumber(script,&ysiz)) break;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("dummytilerange", &tile1, &tile2, script, pos))
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
|
|
|
|
2015-04-09 07:52:28 +00:00
|
|
|
if (xsiz < 0 || ysiz < 0)
|
2012-04-04 18:58:19 +00:00
|
|
|
break; // TODO: message
|
|
|
|
|
|
|
|
for (i=tile1; i<=tile2; i++)
|
2006-04-26 01:25:18 +00:00
|
|
|
{
|
2019-10-15 21:29:47 +00:00
|
|
|
tileSetDummy(i, xsiz, ysiz);
|
2006-04-26 01:25:18 +00:00
|
|
|
}
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-26 01:25:18 +00:00
|
|
|
|
2015-04-09 07:52:28 +00:00
|
|
|
case T_UNDEFINETILE:
|
|
|
|
{
|
|
|
|
int32_t tile;
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("undefinetile", tile, script, pos))
|
2015-04-12 08:06:51 +00:00
|
|
|
break;
|
2015-04-09 07:52:28 +00:00
|
|
|
|
2018-04-12 21:03:30 +00:00
|
|
|
tileDelete(tile);
|
2015-04-09 07:52:28 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_UNDEFINETILERANGE:
|
|
|
|
{
|
|
|
|
int32_t tile1, tile2;
|
|
|
|
|
Ensure that anywhere the def parser takes a tilenum or palnum accepts defined tokens in addition to integer literals, if it doesn't already.
Affects fogpal, nofloorpalrange, setuptilerange, dummytilerange, undefinetilerange, definemodelframe, definevoxeltiles, texhitscanrange, nofullbrightrange, and light.
git-svn-id: https://svn.eduke32.com/eduke32@6896 1a8010ca-5511-0410-912e-c29ae57300e0
2018-05-23 05:43:35 +00:00
|
|
|
if (scriptfile_getsymbol(script,&tile1)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&tile2)) break;
|
2015-04-09 07:52:28 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("undefinetilerange", &tile1, &tile2, script, pos))
|
2015-04-09 07:52:28 +00:00
|
|
|
break;
|
|
|
|
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i = tile1; i <= tile2; i++)
|
2018-04-12 21:03:30 +00:00
|
|
|
tileDelete(i);
|
2015-04-09 07:52:28 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINEMODEL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString modelfn;
|
2006-11-13 23:12:47 +00:00
|
|
|
double scale;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t shadeoffs;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getstring(script,&modelfn)) break;
|
|
|
|
if (scriptfile_getdouble(script,&scale)) break;
|
|
|
|
if (scriptfile_getnumber(script,&shadeoffs)) break;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
lastmodelid = md_loadmodel(modelfn);
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastmodelid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
Printf("Warning: Failed loading MD2/MD3 model \"%s\"\n", modelfn.GetChars());
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2012-01-17 04:31:59 +00:00
|
|
|
md_setmisc(lastmodelid,(float)scale, shadeoffs,0.0,0.0,0);
|
2020-08-16 07:36:32 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
modelskin = lastmodelskin = 0;
|
|
|
|
seenframe = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case T_DEFINEMODELFRAME:
|
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString framename;
|
2008-07-24 11:16:20 +00:00
|
|
|
char happy=1;
|
2013-01-08 06:17:10 +00:00
|
|
|
int32_t tilex;
|
|
|
|
int32_t ftilenume, ltilenume;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
|
|
|
if (scriptfile_getstring(script,&framename)) break;
|
Ensure that anywhere the def parser takes a tilenum or palnum accepts defined tokens in addition to integer literals, if it doesn't already.
Affects fogpal, nofloorpalrange, setuptilerange, dummytilerange, undefinetilerange, definemodelframe, definevoxeltiles, texhitscanrange, nofullbrightrange, and light.
git-svn-id: https://svn.eduke32.com/eduke32@6896 1a8010ca-5511-0410-912e-c29ae57300e0
2018-05-23 05:43:35 +00:00
|
|
|
if (scriptfile_getsymbol(script,&ftilenume)) break; //first tile number
|
|
|
|
if (scriptfile_getsymbol(script,<ilenume)) break; //last tile number (inclusive)
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("definemodelframe", &ftilenume, <ilenume, script, pos))
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastmodelid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_WARNING, "Ignoring frame definition.\n");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++)
|
|
|
|
{
|
2007-12-20 19:14:38 +00:00
|
|
|
switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), 0.0f,0))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case -1:
|
|
|
|
happy = 0; break; // invalid model id!?
|
|
|
|
case -2:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Invalid tile number");
|
2006-11-13 23:12:47 +00:00
|
|
|
happy = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case -3:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Invalid frame name");
|
2006-11-13 23:12:47 +00:00
|
|
|
happy = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
2011-06-19 18:30:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
seenframe = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case T_DEFINEMODELANIM:
|
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString startframe, endframe;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t flags;
|
2006-11-13 23:12:47 +00:00
|
|
|
double dfps;
|
|
|
|
|
|
|
|
if (scriptfile_getstring(script,&startframe)) break;
|
|
|
|
if (scriptfile_getstring(script,&endframe)) break;
|
|
|
|
if (scriptfile_getdouble(script,&dfps)) break; //animation frame rate
|
|
|
|
if (scriptfile_getnumber(script,&flags)) break;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastmodelid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Warning: Ignoring animation definition.\n");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2009-01-09 09:29:17 +00:00
|
|
|
switch (md_defineanimation(lastmodelid, startframe, endframe, (int32_t)(dfps*(65536.0*.001)), flags))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
break; // invalid model id!?
|
|
|
|
case -2:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Invalid starting frame name");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -3:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Invalid ending frame name");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -4:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Out of memory");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINEMODELSKIN:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2012-03-28 19:41:39 +00:00
|
|
|
int32_t palnum;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString skinfn;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&palnum)) break;
|
|
|
|
if (scriptfile_getstring(script,&skinfn)) break; //skin filename
|
|
|
|
|
|
|
|
// if we see a sequence of definemodelskin, then a sequence of definemodelframe,
|
|
|
|
// and then a definemodelskin, we need to increment the skin counter.
|
|
|
|
//
|
|
|
|
// definemodel "mymodel.md2" 1 1
|
|
|
|
// definemodelskin 0 "normal.png" // skin 0
|
|
|
|
// definemodelskin 21 "normal21.png"
|
|
|
|
// definemodelframe "foo" 1000 1002 // these use skin 0
|
|
|
|
// definemodelskin 0 "wounded.png" // skin 1
|
|
|
|
// definemodelskin 21 "wounded21.png"
|
|
|
|
// definemodelframe "foo2" 1003 1004 // these use skin 1
|
|
|
|
// selectmodelskin 0 // resets to skin 0
|
|
|
|
// definemodelframe "foo3" 1005 1006 // these use skin 0
|
2007-12-12 17:42:14 +00:00
|
|
|
if (seenframe) { modelskin = ++lastmodelskin; }
|
2006-11-13 23:12:47 +00:00
|
|
|
seenframe = 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2020-09-12 10:39:18 +00:00
|
|
|
if (!fileSystem.FileExists(skinfn))
|
2012-03-28 19:41:39 +00:00
|
|
|
break;
|
2012-03-10 09:44:54 +00:00
|
|
|
|
2015-03-28 09:49:11 +00:00
|
|
|
switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0, 0.0f, 1.0f, 1.0f, 0))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
break; // invalid model id!?
|
|
|
|
case -2:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Invalid skin filename");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -3:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Invalid palette number");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -4:
|
2020-09-14 20:55:21 +00:00
|
|
|
Printf("Out of memory");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_SELECTMODELSKIN:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
|
|
|
if (scriptfile_getsymbol(script,&modelskin)) break;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINEVOXEL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getstring(script,&fn))
|
2014-12-26 17:29:48 +00:00
|
|
|
break; //voxel filename
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
while (nextvoxid < MAXVOXELS && (voxreserve[nextvoxid>>3]&(1<<(nextvoxid&7))))
|
|
|
|
nextvoxid++;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (nextvoxid == MAXVOXELS)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Maximum number of voxels (%d) already defined.\n", MAXVOXELS);
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (qloadkvx(nextvoxid, fn))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
Printf("Failure loading voxel file \"%s\"\n",fn.GetChars());
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
lastvoxid = nextvoxid++;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_DEFINEVOXELTILES:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t ftilenume, ltilenume, tilex;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
Ensure that anywhere the def parser takes a tilenum or palnum accepts defined tokens in addition to integer literals, if it doesn't already.
Affects fogpal, nofloorpalrange, setuptilerange, dummytilerange, undefinetilerange, definemodelframe, definevoxeltiles, texhitscanrange, nofullbrightrange, and light.
git-svn-id: https://svn.eduke32.com/eduke32@6896 1a8010ca-5511-0410-912e-c29ae57300e0
2018-05-23 05:43:35 +00:00
|
|
|
if (scriptfile_getsymbol(script,&ftilenume)) break; //1st tile #
|
|
|
|
if (scriptfile_getsymbol(script,<ilenume)) break; //last tile #
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("definevoxeltiles", &ftilenume, <ilenume, script, pos))
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastvoxid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Warning: Ignoring voxel tiles definition.\n");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-03-04 08:50:58 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
for (tilex = ftilenume; tilex <= ltilenume; tilex++)
|
2006-11-13 23:12:47 +00:00
|
|
|
tiletovox[tilex] = lastvoxid;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
// NEW (ENCOURAGED) DEFINITION SYNTAX
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_MODEL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos modelend;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString modelfn;
|
2012-01-17 04:31:59 +00:00
|
|
|
double scale=1.0, mzadd=0.0, myoffset=0.0;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t shadeoffs=0, pal=0, flags=0;
|
2019-07-19 01:49:19 +00:00
|
|
|
uint8_t usedframebitmap[(1024+7)>>3];
|
2011-06-19 18:30:32 +00:00
|
|
|
|
2012-01-07 17:48:55 +00:00
|
|
|
int32_t model_ok = 1;
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist modeltokens[] =
|
|
|
|
{
|
|
|
|
{ "scale", T_SCALE },
|
|
|
|
{ "shade", T_SHADE },
|
|
|
|
{ "zadd", T_ZADD },
|
2012-01-17 04:31:59 +00:00
|
|
|
{ "yoffset", T_YOFFSET },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "frame", T_FRAME },
|
|
|
|
{ "anim", T_ANIM },
|
|
|
|
{ "skin", T_SKIN },
|
|
|
|
{ "detail", T_DETAIL },
|
|
|
|
{ "glow", T_GLOW },
|
|
|
|
{ "specular", T_SPECULAR },
|
|
|
|
{ "normal", T_NORMAL },
|
|
|
|
{ "hud", T_HUD },
|
|
|
|
{ "flags", T_FLAGS },
|
|
|
|
};
|
|
|
|
|
2020-09-08 16:48:18 +00:00
|
|
|
memset(usedframebitmap, 0, sizeof(usedframebitmap));
|
2011-07-01 12:22:12 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
modelskin = lastmodelskin = 0;
|
|
|
|
seenframe = 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getstring(script,&modelfn)) break;
|
2008-07-20 04:12:52 +00:00
|
|
|
if (scriptfile_getbraces(script,&modelend)) break;
|
2020-09-22 21:07:11 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
lastmodelid = md_loadmodel(modelfn);
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastmodelid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
Printf("Warning: Failed loading MD2/MD3 model \"%s\"\n", modelfn.GetChars());
|
2020-09-13 09:28:32 +00:00
|
|
|
scriptfile_setposition(script, modelend);
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, modelend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,modeltokens,countof(modeltokens));
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
//case T_ERROR: Printf("Error on line %s:%d in model tokens\n", script->filename,script->linenum); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_SCALE:
|
|
|
|
scriptfile_getdouble(script,&scale); break;
|
|
|
|
case T_SHADE:
|
|
|
|
scriptfile_getnumber(script,&shadeoffs); break;
|
|
|
|
case T_ZADD:
|
|
|
|
scriptfile_getdouble(script,&mzadd); break;
|
2012-01-17 04:31:59 +00:00
|
|
|
case T_YOFFSET:
|
|
|
|
scriptfile_getdouble(script,&myoffset); break;
|
2007-12-20 19:14:38 +00:00
|
|
|
case T_FLAGS:
|
|
|
|
scriptfile_getnumber(script,&flags); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FRAME:
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto framepos = scriptfile_getposition(script);
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos frameend;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString framename;
|
2013-01-08 06:17:10 +00:00
|
|
|
char happy=1;
|
|
|
|
int32_t tilex = 0, framei;
|
|
|
|
int32_t ftilenume = -1, ltilenume = -1;
|
2008-12-10 11:36:53 +00:00
|
|
|
double smoothduration = 0.1f;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist modelframetokens[] =
|
|
|
|
{
|
|
|
|
{ "pal", T_PAL },
|
|
|
|
{ "frame", T_FRAME },
|
|
|
|
{ "name", T_FRAME },
|
|
|
|
{ "tile", T_TILE },
|
|
|
|
{ "tile0", T_TILE0 },
|
|
|
|
{ "tile1", T_TILE1 },
|
|
|
|
{ "smoothduration", T_SMOOTHDURATION },
|
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getbraces(script,&frameend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, frameend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,modelframetokens,countof(modelframetokens)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2007-12-20 19:14:38 +00:00
|
|
|
case T_PAL:
|
Ensure that anywhere the def parser takes a tilenum or palnum accepts defined tokens in addition to integer literals, if it doesn't already.
Affects fogpal, nofloorpalrange, setuptilerange, dummytilerange, undefinetilerange, definemodelframe, definevoxeltiles, texhitscanrange, nofullbrightrange, and light.
git-svn-id: https://svn.eduke32.com/eduke32@6896 1a8010ca-5511-0410-912e-c29ae57300e0
2018-05-23 05:43:35 +00:00
|
|
|
scriptfile_getsymbol(script,&pal); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FRAME:
|
|
|
|
scriptfile_getstring(script,&framename); break;
|
|
|
|
case T_TILE:
|
|
|
|
scriptfile_getsymbol(script,&ftilenume); ltilenume = ftilenume; break;
|
|
|
|
case T_TILE0:
|
|
|
|
scriptfile_getsymbol(script,&ftilenume); break; //first tile number
|
|
|
|
case T_TILE1:
|
|
|
|
scriptfile_getsymbol(script,<ilenume); break; //last tile number (inclusive)
|
2007-04-12 03:09:41 +00:00
|
|
|
case T_SMOOTHDURATION:
|
|
|
|
scriptfile_getdouble(script,&smoothduration); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("model: frame", &ftilenume, <ilenume, script, pos))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2012-04-04 18:58:19 +00:00
|
|
|
model_ok = 0;
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastmodelid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
framepos.Message(MSG_WARNING, "ignoring frame definition");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-03-24 00:40:48 +00:00
|
|
|
|
|
|
|
if (smoothduration > 1.0)
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
framepos.Message(MSG_WARNING, "smoothduration out of range");
|
2015-03-24 00:40:48 +00:00
|
|
|
smoothduration = 1.0;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++)
|
|
|
|
{
|
2011-06-19 18:30:32 +00:00
|
|
|
framei = md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), smoothduration,pal);
|
|
|
|
switch (framei)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case -1:
|
|
|
|
happy = 0; break; // invalid model id!?
|
|
|
|
case -2:
|
2020-09-14 20:55:21 +00:00
|
|
|
framepos.Message(MSG_WARNING, "Invalid tile number");
|
2006-11-13 23:12:47 +00:00
|
|
|
happy = 0;
|
|
|
|
break;
|
|
|
|
case -3:
|
2020-09-14 20:55:21 +00:00
|
|
|
framepos.Message(MSG_WARNING, "%s: Invalid frame name", framename.GetChars());
|
2006-11-13 23:12:47 +00:00
|
|
|
happy = 0;
|
|
|
|
break;
|
2011-06-19 18:30:32 +00:00
|
|
|
default:
|
|
|
|
if (framei >= 0 && framei<1024)
|
2019-08-04 02:51:50 +00:00
|
|
|
usedframebitmap[framei>>3] |= pow2char[framei&7];
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok &= happy;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
seenframe = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case T_ANIM:
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto animpos = scriptfile_getposition(script);
|
|
|
|
FScanner::SavedPos animend;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString startframe, endframe;
|
|
|
|
int happy=1;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t flags = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
double dfps = 1.0;
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist modelanimtokens[] =
|
|
|
|
{
|
|
|
|
{ "frame0", T_FRAME0 },
|
|
|
|
{ "frame1", T_FRAME1 },
|
|
|
|
{ "fps", T_FPS },
|
|
|
|
{ "flags", T_FLAGS },
|
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getbraces(script,&animend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, animend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,modelanimtokens,countof(modelanimtokens)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FRAME0:
|
|
|
|
scriptfile_getstring(script,&startframe); break;
|
|
|
|
case T_FRAME1:
|
|
|
|
scriptfile_getstring(script,&endframe); break;
|
|
|
|
case T_FPS:
|
|
|
|
scriptfile_getdouble(script,&dfps); break; //animation frame rate
|
|
|
|
case T_FLAGS:
|
|
|
|
scriptfile_getsymbol(script,&flags); break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (startframe.IsEmpty()) animpos.Message(MSG_ERROR, "missing 'start frame' for anim definition"), happy = 0;
|
|
|
|
if (endframe.IsEmpty()) animpos.Message(MSG_ERROR, "missing 'end frame' for anim definition"), happy = 0;
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok &= happy;
|
2020-09-04 19:24:48 +00:00
|
|
|
if (!happy) break;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastmodelid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Warning: Ignoring animation definition.\n");
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
2009-01-09 09:29:17 +00:00
|
|
|
switch (md_defineanimation(lastmodelid, startframe, endframe, (int32_t)(dfps*(65536.0*.001)), flags))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
break; // invalid model id!?
|
|
|
|
case -2:
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "Invalid starting frame name");
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -3:
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "Invalid ending frame name");
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -4:
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "Out of memory");
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-04-28 22:56:43 +00:00
|
|
|
case T_SKIN: case T_DETAIL: case T_GLOW: case T_SPECULAR: case T_NORMAL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto skinpos = scriptfile_getposition(script);
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos skinend;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString skinfn;
|
2012-03-28 19:41:39 +00:00
|
|
|
int32_t palnum = 0, surfnum = 0;
|
2009-03-28 15:19:44 +00:00
|
|
|
double param = 1.0, specpower = 1.0, specfactor = 1.0;
|
2015-03-28 09:49:11 +00:00
|
|
|
int32_t flags = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist modelskintokens[] =
|
|
|
|
{
|
|
|
|
{ "pal", T_PAL },
|
|
|
|
{ "file", T_FILE },
|
|
|
|
{ "surf", T_SURF },
|
|
|
|
{ "surface", T_SURF },
|
|
|
|
{ "intensity", T_PARAM },
|
|
|
|
{ "scale", T_PARAM },
|
|
|
|
{ "detailscale", T_PARAM },
|
2012-03-26 05:06:31 +00:00
|
|
|
{ "specpower", T_SPECPOWER }, { "specularpower", T_SPECPOWER }, { "parallaxscale", T_SPECPOWER },
|
|
|
|
{ "specfactor", T_SPECFACTOR }, { "specularfactor", T_SPECFACTOR }, { "parallaxbias", T_SPECFACTOR },
|
2015-03-28 09:49:11 +00:00
|
|
|
{ "nocompress", T_NOCOMPRESS },
|
|
|
|
{ "nodownsize", T_NODOWNSIZE },
|
2015-03-28 09:49:37 +00:00
|
|
|
{ "forcefilter", T_FORCEFILTER },
|
2016-05-02 18:29:35 +00:00
|
|
|
{ "artquality", T_ARTQUALITY },
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getbraces(script,&skinend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, skinend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,modelskintokens,countof(modelskintokens)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_PAL:
|
|
|
|
scriptfile_getsymbol(script,&palnum); break;
|
2007-02-16 01:34:41 +00:00
|
|
|
case T_PARAM:
|
|
|
|
scriptfile_getdouble(script,¶m); break;
|
2009-03-28 15:19:44 +00:00
|
|
|
case T_SPECPOWER:
|
|
|
|
scriptfile_getdouble(script,&specpower); break;
|
|
|
|
case T_SPECFACTOR:
|
|
|
|
scriptfile_getdouble(script,&specfactor); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FILE:
|
|
|
|
scriptfile_getstring(script,&skinfn); break; //skin filename
|
|
|
|
case T_SURF:
|
|
|
|
scriptfile_getnumber(script,&surfnum); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (skinfn.IsEmpty())
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
skinpos.Message(MSG_ERROR, "missing 'skin filename' for skin definition");
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seenframe) { modelskin = ++lastmodelskin; }
|
|
|
|
seenframe = 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2007-12-20 19:14:38 +00:00
|
|
|
switch (token)
|
2007-02-16 01:34:41 +00:00
|
|
|
{
|
2007-12-20 19:14:38 +00:00
|
|
|
case T_DETAIL:
|
2007-02-16 01:34:41 +00:00
|
|
|
palnum = DETAILPAL;
|
|
|
|
param = 1.0f / param;
|
2007-12-20 19:14:38 +00:00
|
|
|
break;
|
|
|
|
case T_GLOW:
|
2007-02-16 01:34:41 +00:00
|
|
|
palnum = GLOWPAL;
|
2007-12-20 19:14:38 +00:00
|
|
|
break;
|
2009-04-28 22:56:43 +00:00
|
|
|
case T_SPECULAR:
|
|
|
|
palnum = SPECULARPAL;
|
|
|
|
break;
|
|
|
|
case T_NORMAL:
|
|
|
|
palnum = NORMALPAL;
|
|
|
|
break;
|
2007-12-20 19:14:38 +00:00
|
|
|
}
|
2007-02-16 01:34:41 +00:00
|
|
|
|
2020-09-12 10:39:18 +00:00
|
|
|
if (!fileSystem.FileExists(skinfn))
|
2012-03-28 19:41:39 +00:00
|
|
|
break;
|
2012-03-10 09:44:54 +00:00
|
|
|
|
2015-03-28 09:49:11 +00:00
|
|
|
switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum, param, specpower, specfactor, flags))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
break; // invalid model id!?
|
|
|
|
case -2:
|
2020-09-14 20:55:21 +00:00
|
|
|
skinpos.Message(MSG_ERROR, "Invalid skin filename");
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -3:
|
2020-09-14 20:55:21 +00:00
|
|
|
skinpos.Message(MSG_ERROR, "Invalid palette number");
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
case -4:
|
2020-09-14 20:55:21 +00:00
|
|
|
skinpos.Message(MSG_ERROR, "Out of memory");
|
2012-01-07 17:48:55 +00:00
|
|
|
model_ok = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_HUD:
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto hudpos = scriptfile_getposition(script);
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos frameend;
|
2013-01-08 06:17:10 +00:00
|
|
|
char happy=1;
|
|
|
|
int32_t tilex = 0;
|
2014-09-30 04:06:57 +00:00
|
|
|
int32_t ftilenume = -1, ltilenume = -1, flags = 0, fov = -1, angadd = 0;
|
|
|
|
double xadd = 0.0, yadd = 0.0, zadd = 0.0;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist modelhudtokens[] =
|
|
|
|
{
|
|
|
|
{ "tile", T_TILE },
|
|
|
|
{ "tile0", T_TILE0 },
|
|
|
|
{ "tile1", T_TILE1 },
|
|
|
|
{ "xadd", T_XADD },
|
|
|
|
{ "yadd", T_YADD },
|
|
|
|
{ "zadd", T_ZADD },
|
|
|
|
{ "angadd", T_ANGADD },
|
2011-03-01 05:52:33 +00:00
|
|
|
{ "fov", T_FOV },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "hide", T_HIDE },
|
|
|
|
{ "nobob", T_NOBOB },
|
|
|
|
{ "flipped",T_FLIPPED},
|
|
|
|
{ "nodepth",T_NODEPTH},
|
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getbraces(script,&frameend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, frameend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,modelhudtokens,countof(modelhudtokens)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_TILE:
|
|
|
|
scriptfile_getsymbol(script,&ftilenume); ltilenume = ftilenume; break;
|
|
|
|
case T_TILE0:
|
|
|
|
scriptfile_getsymbol(script,&ftilenume); break; //first tile number
|
|
|
|
case T_TILE1:
|
|
|
|
scriptfile_getsymbol(script,<ilenume); break; //last tile number (inclusive)
|
|
|
|
case T_XADD:
|
|
|
|
scriptfile_getdouble(script,&xadd); break;
|
|
|
|
case T_YADD:
|
|
|
|
scriptfile_getdouble(script,&yadd); break;
|
|
|
|
case T_ZADD:
|
|
|
|
scriptfile_getdouble(script,&zadd); break;
|
|
|
|
case T_ANGADD:
|
2014-09-30 04:06:57 +00:00
|
|
|
scriptfile_getsymbol(script,&angadd); break;
|
2011-03-01 05:52:33 +00:00
|
|
|
case T_FOV:
|
|
|
|
scriptfile_getsymbol(script,&fov); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_HIDE:
|
2013-11-22 19:26:50 +00:00
|
|
|
flags |= HUDFLAG_HIDE; break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_NOBOB:
|
2013-11-22 19:26:50 +00:00
|
|
|
flags |= HUDFLAG_NOBOB; break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FLIPPED:
|
2013-11-22 19:26:50 +00:00
|
|
|
flags |= HUDFLAG_FLIPPED; break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_NODEPTH:
|
2013-11-22 19:26:50 +00:00
|
|
|
flags |= HUDFLAG_NODEPTH; break;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("hud", &ftilenume, <ilenume, script, hudpos))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2012-04-04 18:58:19 +00:00
|
|
|
model_ok = 0;
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (lastmodelid < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
hudpos.Message(MSG_WARNING, "Ignoring frame definition.");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++)
|
|
|
|
{
|
2015-03-24 00:40:48 +00:00
|
|
|
vec3f_t const add = { (float)xadd, (float)yadd, (float)zadd };
|
|
|
|
switch (md_definehud(lastmodelid, tilex, add, angadd, flags, fov))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
happy = 0; break; // invalid model id!?
|
|
|
|
case -2:
|
2020-09-14 20:55:21 +00:00
|
|
|
hudpos.Message(MSG_ERROR, "Invalid tile number");
|
2006-11-13 23:12:47 +00:00
|
|
|
happy = 0;
|
|
|
|
break;
|
|
|
|
case -3:
|
2020-09-14 20:55:21 +00:00
|
|
|
hudpos.Message(MSG_ERROR, "Invalid frame name");
|
2006-11-13 23:12:47 +00:00
|
|
|
happy = 0;
|
|
|
|
break;
|
|
|
|
}
|
2012-01-07 17:48:55 +00:00
|
|
|
|
|
|
|
model_ok &= happy;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (!model_ok)
|
2012-01-07 17:48:55 +00:00
|
|
|
{
|
|
|
|
if (lastmodelid >= 0)
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "Removing model %d due to errors.", lastmodelid);
|
2012-01-07 17:48:55 +00:00
|
|
|
md_undefinemodel(lastmodelid);
|
|
|
|
nextmodelid--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-17 04:31:59 +00:00
|
|
|
md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd,(float)myoffset,flags);
|
2006-11-13 23:12:47 +00:00
|
|
|
modelskin = lastmodelskin = 0;
|
|
|
|
seenframe = 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_VOXEL:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto voxelpos = scriptfile_getposition(script);
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos modelend;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t tile0 = MAXTILES, tile1 = -1, tilex = -1;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist voxeltokens[] =
|
|
|
|
{
|
|
|
|
{ "tile", T_TILE },
|
|
|
|
{ "tile0", T_TILE0 },
|
|
|
|
{ "tile1", T_TILE1 },
|
|
|
|
{ "scale", T_SCALE },
|
2019-09-17 05:07:28 +00:00
|
|
|
{ "rotate", T_ROTATE },
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getstring(script,&fn))
|
2014-12-26 17:29:52 +00:00
|
|
|
break; //voxel filename
|
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
while (nextvoxid < MAXVOXELS && (voxreserve[nextvoxid>>3]&(1<<(nextvoxid&7))))
|
|
|
|
nextvoxid++;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (nextvoxid == MAXVOXELS)
|
2014-12-26 17:29:52 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
voxelpos.Message(MSG_ERROR, "Maximum number of voxels (%d) already defined.", MAXVOXELS);
|
2014-12-26 17:29:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (qloadkvx(nextvoxid, fn))
|
2014-12-26 17:29:52 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
voxelpos.Message(MSG_ERROR, "Failure loading voxel file \"%s\"",fn.GetChars());
|
2014-12-26 17:29:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
lastvoxid = nextvoxid++;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getbraces(script,&modelend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, modelend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script, voxeltokens, countof(voxeltokens)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
//case T_ERROR: Printf("Error on line %s:%d in voxel tokens\n", script->filename,linenum); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_TILE:
|
|
|
|
scriptfile_getsymbol(script,&tilex);
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("voxel", tilex, script, voxelpos))
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
tiletovox[tilex] = lastvoxid;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_TILE0:
|
2012-04-04 18:58:19 +00:00
|
|
|
scriptfile_getsymbol(script,&tile0);
|
|
|
|
break; //1st tile #
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_TILE1:
|
|
|
|
scriptfile_getsymbol(script,&tile1);
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("voxel", &tile0, &tile1, script, voxelpos))
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
for (tilex=tile0; tilex<=tile1; tilex++)
|
|
|
|
tiletovox[tilex] = lastvoxid;
|
2006-11-13 23:12:47 +00:00
|
|
|
break; //last tile number (inclusive)
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
case T_SCALE:
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
double scale=1.0;
|
|
|
|
scriptfile_getdouble(script,&scale);
|
2009-01-09 09:29:17 +00:00
|
|
|
voxscale[lastvoxid] = (int32_t)(65536*scale);
|
2011-06-18 13:02:08 +00:00
|
|
|
if (voxmodels[lastvoxid])
|
|
|
|
voxmodels[lastvoxid]->scale = scale;
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-09-17 05:07:28 +00:00
|
|
|
|
|
|
|
case T_ROTATE:
|
|
|
|
voxrotate[lastvoxid>>3] |= pow2char[lastvoxid&7];
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
lastvoxid = -1;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_SKYBOX:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto skyboxpos = scriptfile_getposition(script);
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn[6];
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos modelend;
|
2015-03-08 07:56:29 +00:00
|
|
|
int32_t i, tile = -1, pal = 0, happy = 1;
|
2019-10-17 10:45:25 +00:00
|
|
|
int flags = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist skyboxtokens[] =
|
|
|
|
{
|
|
|
|
{ "tile" ,T_TILE },
|
|
|
|
{ "pal" ,T_PAL },
|
|
|
|
{ "ft" ,T_FRONT },{ "front" ,T_FRONT },{ "forward",T_FRONT },
|
|
|
|
{ "rt" ,T_RIGHT },{ "right" ,T_RIGHT },
|
|
|
|
{ "bk" ,T_BACK },{ "back" ,T_BACK },
|
|
|
|
{ "lf" ,T_LEFT },{ "left" ,T_LEFT },{ "lt" ,T_LEFT },
|
|
|
|
{ "up" ,T_TOP },{ "top" ,T_TOP },{ "ceiling",T_TOP },{ "ceil" ,T_TOP },
|
2015-02-18 01:47:00 +00:00
|
|
|
{ "dn" ,T_BOTTOM },{ "bottom" ,T_BOTTOM },{ "floor" ,T_BOTTOM },{ "down" ,T_BOTTOM },
|
|
|
|
{ "nocompress", T_NOCOMPRESS },
|
|
|
|
{ "nodownsize", T_NODOWNSIZE },
|
2015-03-28 09:49:37 +00:00
|
|
|
{ "forcefilter", T_FORCEFILTER },
|
2016-05-02 18:29:35 +00:00
|
|
|
{ "artquality", T_ARTQUALITY },
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getbraces(script,&modelend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, modelend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,skyboxtokens,countof(skyboxtokens)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
//case T_ERROR: Printf("Error on line %s:%d in skybox tokens\n",script->filename,linenum); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_TILE:
|
2007-12-12 17:42:14 +00:00
|
|
|
scriptfile_getsymbol(script,&tile); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_PAL:
|
2007-12-12 17:42:14 +00:00
|
|
|
scriptfile_getsymbol(script,&pal); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FRONT:
|
|
|
|
scriptfile_getstring(script,&fn[0]); break;
|
|
|
|
case T_RIGHT:
|
|
|
|
scriptfile_getstring(script,&fn[1]); break;
|
|
|
|
case T_BACK:
|
|
|
|
scriptfile_getstring(script,&fn[2]); break;
|
|
|
|
case T_LEFT:
|
|
|
|
scriptfile_getstring(script,&fn[3]); break;
|
|
|
|
case T_TOP:
|
|
|
|
scriptfile_getstring(script,&fn[4]); break;
|
|
|
|
case T_BOTTOM:
|
|
|
|
scriptfile_getstring(script,&fn[5]); break;
|
2019-10-17 10:45:25 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (tile < 0) skyboxpos.Message(MSG_ERROR, "skybox: missing 'tile number'"), happy=0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<6; i++)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
if (fn[i].IsEmpty()) skyboxpos.Message(MSG_ERROR, "skybox: missing '%s filename'", skyfaces[i]), happy = 0;
|
2010-12-17 14:22:15 +00:00
|
|
|
// FIXME?
|
2020-09-12 10:39:18 +00:00
|
|
|
if (!fileSystem.FileExists(fn[i]))
|
2012-03-28 19:41:39 +00:00
|
|
|
happy = 0;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
if (!happy) break;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
const char* fns[] = { fn[0].GetChars(), fn[1].GetChars(), fn[2].GetChars(), fn[3].GetChars(), fn[4].GetChars(), fn[5].GetChars() };
|
|
|
|
tileSetSkybox(tile, pal, fns, flags);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-12-30 08:13:37 +00:00
|
|
|
case T_HIGHPALOOKUP:
|
|
|
|
{
|
2012-03-28 19:41:39 +00:00
|
|
|
int32_t basepal=-1, pal=-1;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos highpalend;
|
2010-12-30 08:13:37 +00:00
|
|
|
static const tokenlist highpaltokens[] =
|
|
|
|
{
|
2011-01-27 07:05:12 +00:00
|
|
|
{ "basepal", T_BASEPAL },
|
2010-12-30 08:13:37 +00:00
|
|
|
{ "pal", T_PAL },
|
|
|
|
{ "file", T_FILE }
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&highpalend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, highpalend))
|
2010-12-30 08:13:37 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,highpaltokens,countof(highpaltokens)))
|
2010-12-30 08:13:37 +00:00
|
|
|
{
|
2011-01-27 07:05:12 +00:00
|
|
|
case T_BASEPAL:
|
|
|
|
scriptfile_getsymbol(script,&basepal); break;
|
2010-12-30 08:13:37 +00:00
|
|
|
case T_PAL:
|
|
|
|
scriptfile_getsymbol(script,&pal); break;
|
|
|
|
case T_FILE:
|
|
|
|
scriptfile_getstring(script,&fn); break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)basepal >= MAXBASEPALS)
|
2011-01-27 07:05:12 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "missing or invalid 'base palette number' for highpalookup definition ");
|
2011-01-27 07:05:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-12-30 08:13:37 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)pal >= MAXPALOOKUPS - RESERVEDPALS)
|
2010-12-30 08:13:37 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "missing or invalid 'palette number' for highpalookup definition");
|
2010-12-30 08:13:37 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-01-27 07:05:12 +00:00
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (fn.IsEmpty())
|
2010-12-30 08:13:37 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "missing 'file name' for highpalookup definition");
|
2010-12-30 08:13:37 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-01-16 02:50:27 +00:00
|
|
|
|
2020-09-12 10:39:18 +00:00
|
|
|
if (!fileSystem.FileExists(fn))
|
2012-03-28 19:41:39 +00:00
|
|
|
break;
|
2010-12-31 01:35:00 +00:00
|
|
|
|
2010-12-30 08:13:37 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_TINT:
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto tintpos = scriptfile_getposition(script);
|
2017-12-12 05:13:58 +00:00
|
|
|
int32_t red=255, green=255, blue=255, shadered=0, shadegreen=0, shadeblue=0, pal=-1, flags=0;
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos tintend;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist tinttokens[] =
|
|
|
|
{
|
2017-12-12 05:13:58 +00:00
|
|
|
{ "pal", T_PAL },
|
|
|
|
{ "red", T_RED },{ "r", T_RED },
|
|
|
|
{ "green", T_GREEN },{ "g", T_GREEN },
|
|
|
|
{ "blue", T_BLUE },{ "b", T_BLUE },
|
|
|
|
{ "shadered", T_SHADERED },{ "sr", T_SHADERED },
|
|
|
|
{ "shadegreen", T_SHADEGREEN },{ "sg", T_SHADEGREEN },
|
|
|
|
{ "shadeblue", T_SHADEBLUE },{ "sb", T_SHADEBLUE },
|
|
|
|
{ "flags", T_FLAGS }
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getbraces(script,&tintend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, tintend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,tinttokens,countof(tinttokens)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_PAL:
|
2017-12-12 05:13:58 +00:00
|
|
|
scriptfile_getsymbol(script,&pal); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_RED:
|
2017-12-12 05:13:58 +00:00
|
|
|
scriptfile_getnumber(script,&red); red = min(255,max(0,red)); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_GREEN:
|
2017-12-12 05:13:58 +00:00
|
|
|
scriptfile_getnumber(script,&green); green = min(255,max(0,green)); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_BLUE:
|
2017-12-12 05:13:58 +00:00
|
|
|
scriptfile_getnumber(script,&blue); blue = min(255,max(0,blue)); break;
|
|
|
|
case T_SHADERED:
|
|
|
|
scriptfile_getnumber(script,&shadered); shadered = min(255,max(0,shadered)); break;
|
|
|
|
case T_SHADEGREEN:
|
|
|
|
scriptfile_getnumber(script,&shadegreen); shadegreen = min(255,max(0,shadegreen)); break;
|
|
|
|
case T_SHADEBLUE:
|
|
|
|
scriptfile_getnumber(script,&shadeblue); shadeblue = min(255,max(0,shadeblue)); break;
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FLAGS:
|
2017-12-12 05:13:58 +00:00
|
|
|
scriptfile_getsymbol(script,&flags); break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (pal < 0)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
tintpos.Message(MSG_ERROR, "tint: missing 'palette number'");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2020-05-29 18:15:42 +00:00
|
|
|
lookups.setPaletteTint(pal,red,green,blue,shadered,shadegreen,shadeblue,flags);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
case T_MAKEPALOOKUP:
|
|
|
|
{
|
|
|
|
int32_t red=0, green=0, blue=0, pal=-1;
|
|
|
|
int32_t havepal=0, remappal=0;
|
2015-03-27 12:29:52 +00:00
|
|
|
int32_t nofloorpal=-1;
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos endtextptr;
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
|
|
|
|
static const tokenlist palookuptokens[] =
|
|
|
|
{
|
|
|
|
{ "pal", T_PAL },
|
|
|
|
{ "red", T_RED }, { "r", T_RED },
|
|
|
|
{ "green", T_GREEN }, { "g", T_GREEN },
|
|
|
|
{ "blue", T_BLUE }, { "b", T_BLUE },
|
|
|
|
{ "remappal", T_REMAPPAL },
|
|
|
|
{ "remapself", T_REMAPSELF },
|
2015-03-27 12:29:52 +00:00
|
|
|
{ "nofloorpal", T_NOFLOORPAL },
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
};
|
|
|
|
|
2014-12-13 22:33:06 +00:00
|
|
|
enum {
|
|
|
|
HAVE_PAL = 1,
|
|
|
|
HAVE_REMAPPAL = 2,
|
|
|
|
HAVE_REMAPSELF = 4,
|
|
|
|
|
|
|
|
HAVEPAL_SPECIAL = HAVE_REMAPPAL | HAVE_REMAPSELF,
|
|
|
|
HAVEPAL_ERROR = 8,
|
|
|
|
};
|
|
|
|
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
if (scriptfile_getbraces(script,&endtextptr)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, endtextptr))
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script, palookuptokens, countof(palookuptokens)))
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
{
|
|
|
|
case T_PAL:
|
|
|
|
scriptfile_getsymbol(script, &pal);
|
2014-12-13 22:33:06 +00:00
|
|
|
havepal |= HAVE_PAL;
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
break;
|
|
|
|
case T_RED:
|
|
|
|
scriptfile_getnumber(script,&red);
|
|
|
|
red = clamp(red, 0, 63);
|
|
|
|
break;
|
|
|
|
case T_GREEN:
|
|
|
|
scriptfile_getnumber(script,&green);
|
|
|
|
green = clamp(green, 0, 63);
|
|
|
|
break;
|
|
|
|
case T_BLUE:
|
|
|
|
scriptfile_getnumber(script,&blue);
|
|
|
|
blue = clamp(blue, 0, 63);
|
|
|
|
break;
|
|
|
|
case T_REMAPPAL:
|
|
|
|
scriptfile_getsymbol(script,&remappal);
|
2014-12-13 22:33:06 +00:00
|
|
|
if (havepal & HAVEPAL_SPECIAL)
|
|
|
|
havepal |= HAVEPAL_ERROR;
|
|
|
|
havepal |= HAVE_REMAPPAL;
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
break;
|
|
|
|
case T_REMAPSELF:
|
2014-12-13 22:33:06 +00:00
|
|
|
if (havepal & HAVEPAL_SPECIAL)
|
|
|
|
havepal |= HAVEPAL_ERROR;
|
|
|
|
havepal |= HAVE_REMAPSELF;
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
break;
|
2015-03-27 12:29:52 +00:00
|
|
|
case T_NOFLOORPAL:
|
|
|
|
scriptfile_getsymbol(script, &nofloorpal);
|
|
|
|
nofloorpal = clamp(nofloorpal, 0, 1);
|
|
|
|
break;
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
char msgend[BMAX_PATH+64];
|
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
sprintf(msgend, "for palookup definition");
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((havepal & HAVE_PAL)==0)
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "missing 'palette number' %s\n", msgend);
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-04 19:24:48 +00:00
|
|
|
else if (pal==0 || (unsigned)pal >= MAXPALOOKUPS-RESERVEDPALS)
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "'palette number' out of range (1 .. %d) %s\n",
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
MAXPALOOKUPS-RESERVEDPALS-1, msgend);
|
|
|
|
break;
|
|
|
|
}
|
2014-12-13 22:33:06 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (havepal & HAVEPAL_ERROR)
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
{
|
|
|
|
// will also disallow multiple remappals or remapselfs
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "must have exactly one of either 'remappal' or 'remapself' %s\n", msgend);
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-04 19:24:48 +00:00
|
|
|
else if ((havepal & HAVE_REMAPPAL
|
2014-12-13 22:33:06 +00:00
|
|
|
&& (unsigned)remappal >= MAXPALOOKUPS-RESERVEDPALS))
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "'remap palette number' out of range (max=%d) %s\n",
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
MAXPALOOKUPS-RESERVEDPALS-1, msgend);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-12-13 22:33:06 +00:00
|
|
|
if (havepal & HAVE_REMAPSELF)
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
remappal = pal;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: all palookups are initialized, i.e. non-NULL!
|
|
|
|
// NOTE2: aliasing (pal==remappal) is OK
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.makeTable(pal, lookups.getTable(remappal), red<<2, green<<2, blue<<2,
|
|
|
|
remappal==0 ? 1 : (nofloorpal == -1 ? lookups.tables[remappal].noFloorPal : nofloorpal));
|
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows:
makepalookup { <token-list...> }
where valid tokens are
* pal <palnum>: the palette number, 1 .. 250
* red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale.
Components that are not present are assumed to be 0.
* remappal <palnum>: the palette number to take the index remapping from, i.e. 21
for blue -> red. When absent, defaults to 0.
* remapself: when present, specifies that the remappal is the same as the 'pal'.
This is to prevent textual redundancy when overwriting existing palookups.
Examples (best tested with tile #251):
1) makepalookup { pal 200 red 30 remappal 23 }
This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping
(assuming it has not been changed before)
2) makepalookup { pal 21 red 30 remapself }
This 'fogifies' palookup 21 with a red fog.
3) makepalookup { pal 21 red 30 }
This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping.
The fog aspect of this command affects the GL modes just like 'fogpal', but the
remapping has no effect for hightiles.
- Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63.
git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-29 21:16:41 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_TEXTURE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos textureend;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t tile=-1, token;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist texturetokens[] =
|
|
|
|
{
|
|
|
|
{ "pal", T_PAL },
|
|
|
|
{ "detail", T_DETAIL },
|
|
|
|
{ "glow", T_GLOW },
|
|
|
|
{ "specular",T_SPECULAR },
|
|
|
|
{ "normal", T_NORMAL },
|
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getsymbol(script,&tile)) break;
|
|
|
|
if (scriptfile_getbraces(script,&textureend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, textureend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
token = getatoken(script,texturetokens,countof(texturetokens));
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_PAL:
|
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto palpos = scriptfile_getposition(script);
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos palend;
|
2013-09-14 17:58:46 +00:00
|
|
|
int32_t pal=-1, xsiz = 0, ysiz = 0;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2009-10-04 15:41:40 +00:00
|
|
|
double alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
|
2019-10-17 10:45:25 +00:00
|
|
|
uint8_t flags = 0;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist texturetokens_pal[] =
|
|
|
|
{
|
|
|
|
{ "file", T_FILE },{ "name", T_FILE },
|
|
|
|
{ "alphacut", T_ALPHACUT },
|
|
|
|
{ "detailscale", T_XSCALE }, { "scale", T_XSCALE }, { "xscale", T_XSCALE }, { "intensity", T_XSCALE },
|
|
|
|
{ "yscale", T_YSCALE },
|
2012-03-26 05:06:31 +00:00
|
|
|
{ "specpower", T_SPECPOWER }, { "specularpower", T_SPECPOWER }, { "parallaxscale", T_SPECPOWER },
|
|
|
|
{ "specfactor", T_SPECFACTOR }, { "specularfactor", T_SPECFACTOR }, { "parallaxbias", T_SPECFACTOR },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "nocompress", T_NOCOMPRESS },
|
|
|
|
{ "nodownsize", T_NODOWNSIZE },
|
2015-03-28 09:49:37 +00:00
|
|
|
{ "forcefilter", T_FORCEFILTER },
|
2016-05-02 18:29:35 +00:00
|
|
|
{ "artquality", T_ARTQUALITY },
|
2013-09-14 17:58:46 +00:00
|
|
|
{ "orig_sizex", T_ORIGSIZEX }, { "orig_sizey", T_ORIGSIZEY }
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getsymbol(script,&pal)) break;
|
|
|
|
if (scriptfile_getbraces(script,&palend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, palend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,texturetokens_pal,countof(texturetokens_pal)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case T_FILE:
|
|
|
|
scriptfile_getstring(script,&fn); break;
|
|
|
|
case T_ALPHACUT:
|
|
|
|
scriptfile_getdouble(script,&alphacut); break;
|
2007-02-17 02:23:50 +00:00
|
|
|
case T_XSCALE:
|
|
|
|
scriptfile_getdouble(script,&xscale); break;
|
|
|
|
case T_YSCALE:
|
|
|
|
scriptfile_getdouble(script,&yscale); break;
|
2009-10-04 15:41:40 +00:00
|
|
|
case T_SPECPOWER:
|
|
|
|
scriptfile_getdouble(script,&specpower); break;
|
|
|
|
case T_SPECFACTOR:
|
|
|
|
scriptfile_getdouble(script,&specfactor); break;
|
2013-09-14 17:58:46 +00:00
|
|
|
case T_ORIGSIZEX:
|
|
|
|
scriptfile_getnumber(script, &xsiz);
|
|
|
|
break;
|
|
|
|
case T_ORIGSIZEY:
|
|
|
|
scriptfile_getnumber(script, &ysiz);
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)tile >= MAXUSERTILES) break; // message is printed later
|
|
|
|
if ((unsigned)pal >= MAXPALOOKUPS - RESERVEDPALS)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
palpos.Message(MSG_ERROR, "missing or invalid 'palette number' for texture definition");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-13 08:29:57 +00:00
|
|
|
if (fn.IsEmpty())
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
palpos.Message(MSG_ERROR, "missing 'file name' for texture definition");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-04-30 19:41:19 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (!fileSystem.FileExists(fn))
|
2020-01-28 20:35:46 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
palpos.Message(MSG_ERROR, "%s not found in replacement for tile %d", fn.GetChars(), tile);
|
2012-03-28 19:41:39 +00:00
|
|
|
break;
|
2020-01-28 20:35:46 +00:00
|
|
|
}
|
2007-05-01 04:35:27 +00:00
|
|
|
|
2013-09-14 17:58:46 +00:00
|
|
|
if (xsiz > 0 && ysiz > 0)
|
|
|
|
{
|
2019-10-15 21:29:47 +00:00
|
|
|
tileSetDummy(tile, xsiz, ysiz);
|
2013-09-14 17:58:46 +00:00
|
|
|
}
|
2007-02-17 02:23:50 +00:00
|
|
|
xscale = 1.0f / xscale;
|
|
|
|
yscale = 1.0f / yscale;
|
|
|
|
|
2019-10-17 10:45:25 +00:00
|
|
|
tileSetHightileReplacement(tile,pal,fn,alphacut,xscale,yscale, specpower, specfactor,flags);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-04-28 22:56:43 +00:00
|
|
|
case T_DETAIL: case T_GLOW: case T_SPECULAR: case T_NORMAL:
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
auto detailpos = scriptfile_getposition(script);
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos detailend;
|
2012-03-28 19:41:39 +00:00
|
|
|
int32_t pal = 0;
|
2013-01-08 06:17:10 +00:00
|
|
|
char flags = 0;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2009-04-28 22:56:43 +00:00
|
|
|
double xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
|
2007-01-15 09:08:57 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist texturetokens_pal[] =
|
|
|
|
{
|
|
|
|
{ "file", T_FILE },{ "name", T_FILE },
|
|
|
|
{ "alphacut", T_ALPHACUT },
|
|
|
|
{ "detailscale", T_XSCALE }, { "scale", T_XSCALE }, { "xscale", T_XSCALE }, { "intensity", T_XSCALE },
|
|
|
|
{ "yscale", T_YSCALE },
|
2012-03-26 05:06:31 +00:00
|
|
|
{ "specpower", T_SPECPOWER }, { "specularpower", T_SPECPOWER }, { "parallaxscale", T_SPECPOWER },
|
|
|
|
{ "specfactor", T_SPECFACTOR }, { "specularfactor", T_SPECFACTOR }, { "parallaxbias", T_SPECFACTOR },
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "nocompress", T_NOCOMPRESS },
|
|
|
|
{ "nodownsize", T_NODOWNSIZE },
|
2015-03-28 09:49:37 +00:00
|
|
|
{ "forcefilter", T_FORCEFILTER },
|
2016-05-02 18:29:35 +00:00
|
|
|
{ "artquality", T_ARTQUALITY },
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getbraces(script,&detailend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, detailend))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,texturetokens_pal,countof(texturetokens_pal)))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2007-01-15 09:08:57 +00:00
|
|
|
case T_FILE:
|
|
|
|
scriptfile_getstring(script,&fn); break;
|
2007-02-17 02:23:50 +00:00
|
|
|
case T_XSCALE:
|
2007-03-01 18:19:11 +00:00
|
|
|
scriptfile_getdouble(script,&xscale); break;
|
|
|
|
case T_YSCALE:
|
|
|
|
scriptfile_getdouble(script,&yscale); break;
|
2009-04-28 22:56:43 +00:00
|
|
|
case T_SPECPOWER:
|
|
|
|
scriptfile_getdouble(script,&specpower); break;
|
|
|
|
case T_SPECFACTOR:
|
|
|
|
scriptfile_getdouble(script,&specfactor); break;
|
2007-01-15 09:08:57 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)tile >= MAXUSERTILES) break; // message is printed later
|
2020-09-13 08:29:57 +00:00
|
|
|
if (fn.IsEmpty())
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
detailpos.Message(MSG_ERROR, "missing 'file name' for texture definition");
|
2007-01-15 09:08:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-04-30 19:41:19 +00:00
|
|
|
|
2020-09-12 10:39:18 +00:00
|
|
|
if (!fileSystem.FileExists(fn))
|
2012-03-28 19:41:39 +00:00
|
|
|
break;
|
2007-01-15 09:08:57 +00:00
|
|
|
|
2007-12-20 19:14:38 +00:00
|
|
|
switch (token)
|
2007-02-16 01:34:41 +00:00
|
|
|
{
|
2007-12-20 19:14:38 +00:00
|
|
|
case T_DETAIL:
|
2007-02-16 01:34:41 +00:00
|
|
|
pal = DETAILPAL;
|
2007-03-01 18:19:11 +00:00
|
|
|
xscale = 1.0f / xscale;
|
2007-03-03 23:09:40 +00:00
|
|
|
yscale = 1.0f / yscale;
|
2007-12-20 19:14:38 +00:00
|
|
|
break;
|
|
|
|
case T_GLOW:
|
2007-02-16 01:34:41 +00:00
|
|
|
pal = GLOWPAL;
|
2007-12-20 19:14:38 +00:00
|
|
|
break;
|
2009-04-28 22:56:43 +00:00
|
|
|
case T_SPECULAR:
|
|
|
|
pal = SPECULARPAL;
|
|
|
|
break;
|
|
|
|
case T_NORMAL:
|
|
|
|
pal = NORMALPAL;
|
|
|
|
break;
|
2007-12-20 19:14:38 +00:00
|
|
|
}
|
2019-10-17 10:45:25 +00:00
|
|
|
tileSetHightileReplacement(tile,pal,fn,-1.0f,xscale,yscale, specpower, specfactor,flags);
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
default:
|
2006-04-24 19:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)tile >= MAXUSERTILES)
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "missing or invalid 'tile number' for texture definition");
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
case T_UNDEFMODEL:
|
|
|
|
case T_UNDEFMODELRANGE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t r0,r1;
|
2006-11-13 23:12:47 +00:00
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getsymbol(script,&r0)) break;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (tokn == T_UNDEFMODELRANGE)
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (scriptfile_getsymbol(script,&r1)) break;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("undefmodelrange", &r0, &r1, script, pos))
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
r1 = r0;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("undefmodel", r0, script, pos))
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-04-04 18:58:19 +00:00
|
|
|
for (; r0 <= r1; r0++)
|
|
|
|
md_undefinetile(r0);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
case T_UNDEFMODELOF:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t r0;
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getsymbol(script,&r0)) break;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("undefmodelof", r0, script, pos))
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
|
|
|
// XXX: See comment of md_undefinemodel()
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_WARNING, "undefmodelof: currently non-functional.");
|
2012-04-04 18:58:19 +00:00
|
|
|
break;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2016-12-26 06:02:06 +00:00
|
|
|
#if defined USE_OPENGL && 0
|
2007-12-20 19:14:38 +00:00
|
|
|
mid = md_tilehasmodel(r0,0);
|
2006-11-13 23:12:47 +00:00
|
|
|
if (mid < 0) break;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
md_undefinemodel(mid);
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
case T_UNDEFTEXTURE:
|
|
|
|
case T_UNDEFTEXTURERANGE:
|
2006-11-13 23:12:47 +00:00
|
|
|
{
|
2013-01-08 06:17:10 +00:00
|
|
|
int32_t r0,r1;
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getsymbol(script,&r0)) break;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (tokn == T_UNDEFTEXTURERANGE)
|
|
|
|
{
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getsymbol(script,&r1)) break;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile_range("undeftexturerange", &r0, &r1, script, pos))
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
r1 = r0;
|
2012-04-04 18:58:19 +00:00
|
|
|
|
2020-09-14 20:55:21 +00:00
|
|
|
if (check_tile("undeftexture", r0, script, pos))
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2019-10-17 10:45:25 +00:00
|
|
|
for (; r0 <= r1; r0++) tileRemoveReplacement(r0);
|
2006-11-13 23:12:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-02-11 05:22:07 +00:00
|
|
|
case T_CUTSCENE:
|
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
|
|
|
case T_ANIMSOUNDS:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos dummy;
|
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
|
|
|
|
|
|
|
static const tokenlist dummytokens[] = { { "id", T_ID }, };
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (scriptfile_getstring(script, nullptr)) break;
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getbraces(script,&dummy)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, dummy))
|
Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
animsounds <anim> { frame1 sound1 frame2 sound2 ... }
<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.
The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).
Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:
// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244 64 14 }
git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
|
|
|
{
|
|
|
|
// XXX?
|
|
|
|
getatoken(script,dummytokens,sizeof(dummytokens)/sizeof(dummytokens));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-10-14 20:41:34 +00:00
|
|
|
case T_TEXHITSCANRANGE:
|
2012-11-25 13:19:06 +00:00
|
|
|
case T_NOFULLBRIGHTRANGE:
|
2012-10-14 20:41:34 +00:00
|
|
|
{
|
|
|
|
int32_t b,e, i;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getsymbol(script,&b)) break;
|
|
|
|
if (scriptfile_getsymbol(script,&e))break;
|
2012-10-14 20:41:34 +00:00
|
|
|
|
|
|
|
b = max(b, 0);
|
2013-12-28 17:04:22 +00:00
|
|
|
e = min(e, MAXUSERTILES-1);
|
2012-10-14 20:41:34 +00:00
|
|
|
|
|
|
|
for (i=b; i<=e; i++)
|
2012-11-25 13:19:06 +00:00
|
|
|
picanm[i].sf |= (tokn==T_TEXHITSCANRANGE) ?
|
|
|
|
PICANM_TEXHITSCAN_BIT : PICANM_NOFULLBRIGHT_BIT;
|
2012-10-14 20:41:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
case T_SOUND:
|
2007-12-20 19:14:38 +00:00
|
|
|
case T_MUSIC:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos p;
|
2020-09-13 08:29:57 +00:00
|
|
|
FString dummy, dummy2;
|
2010-08-02 08:13:51 +00:00
|
|
|
static const tokenlist sound_musictokens[] =
|
2007-12-20 19:14:38 +00:00
|
|
|
{
|
2010-08-02 08:13:51 +00:00
|
|
|
{ "id", T_ID },
|
|
|
|
{ "file", T_FILE },
|
|
|
|
};
|
2007-12-20 19:14:38 +00:00
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (scriptfile_getbraces(script,&p)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, p))
|
2007-12-20 19:14:38 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,sound_musictokens,countof(sound_musictokens)))
|
2007-12-20 19:14:38 +00:00
|
|
|
{
|
|
|
|
case T_ID:
|
2010-08-02 08:13:51 +00:00
|
|
|
scriptfile_getstring(script,&dummy2);
|
2008-03-08 05:23:15 +00:00
|
|
|
break;
|
2007-12-20 19:14:38 +00:00
|
|
|
case T_FILE:
|
2020-09-12 10:39:18 +00:00
|
|
|
scriptfile_getstring(script,&dummy);
|
2008-03-08 05:23:15 +00:00
|
|
|
break;
|
2007-12-20 19:14:38 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-23 22:40:22 +00:00
|
|
|
SetMusicForMap(dummy2, dummy, true);
|
2007-12-20 19:14:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-23 03:12:50 +00:00
|
|
|
case T_MAPINFO:
|
|
|
|
{
|
2020-09-13 11:01:44 +00:00
|
|
|
FString mapmd4string;
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos mapinfoend;
|
2020-09-13 11:01:44 +00:00
|
|
|
usermaphack_t mhk;
|
2012-12-23 03:12:50 +00:00
|
|
|
static const tokenlist mapinfotokens[] =
|
|
|
|
{
|
|
|
|
{ "mapfile", T_MAPFILE },
|
|
|
|
{ "maptitle", T_MAPTITLE },
|
|
|
|
{ "mapmd4", T_MAPMD4 },
|
|
|
|
{ "mhkfile", T_MHKFILE },
|
|
|
|
};
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (scriptfile_getbraces(script,&mapinfoend)) break;
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, mapinfoend))
|
2012-12-23 03:12:50 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script,mapinfotokens,countof(mapinfotokens)))
|
2012-12-23 03:12:50 +00:00
|
|
|
{
|
|
|
|
case T_MAPFILE:
|
2020-09-13 11:01:44 +00:00
|
|
|
scriptfile_getstring(script,nullptr);
|
2012-12-23 03:12:50 +00:00
|
|
|
break;
|
|
|
|
case T_MAPTITLE:
|
2020-09-13 11:01:44 +00:00
|
|
|
scriptfile_getstring(script,&mhk.title);
|
2012-12-23 03:12:50 +00:00
|
|
|
break;
|
|
|
|
case T_MAPMD4:
|
2015-01-08 15:14:00 +00:00
|
|
|
{
|
|
|
|
scriptfile_getstring(script,&mapmd4string);
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
for (int i = 0; i < 16; i++)
|
2015-01-08 15:14:00 +00:00
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
char smallbuf[3] = { mapmd4string[2 * i], mapmd4string[2 * i + 1], 0 };
|
2020-09-13 11:01:44 +00:00
|
|
|
mhk.md4[i] = strtol(smallbuf, NULL, 16);
|
2015-01-08 15:14:00 +00:00
|
|
|
}
|
|
|
|
|
2012-12-23 03:12:50 +00:00
|
|
|
break;
|
2015-01-08 15:14:00 +00:00
|
|
|
}
|
2012-12-23 03:12:50 +00:00
|
|
|
case T_MHKFILE:
|
2020-09-13 11:01:44 +00:00
|
|
|
scriptfile_getstring(script,&mhk.mhkfile);
|
2012-12-23 03:12:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-13 11:01:44 +00:00
|
|
|
AddUserMapHack(mhk);
|
2012-12-23 03:12:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-03-10 09:44:17 +00:00
|
|
|
case T_ECHO:
|
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString string;
|
2012-03-10 09:44:17 +00:00
|
|
|
scriptfile_getstring(script,&string);
|
2020-09-13 08:29:57 +00:00
|
|
|
Printf("%s\n",string.GetChars());
|
2012-03-10 09:44:17 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-03-09 20:32:36 +00:00
|
|
|
case T_GLOBALFLAGS:
|
|
|
|
{
|
|
|
|
if (scriptfile_getnumber(script,&globalflags)) break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-04-24 00:08:46 +00:00
|
|
|
case T_GLOBALGAMEFLAGS:
|
|
|
|
{
|
|
|
|
int32_t dummy;
|
|
|
|
if (scriptfile_getnumber(script,&dummy)) break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-05-27 08:47:50 +00:00
|
|
|
case T_MULTIPSKY:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos blockend;
|
2015-05-27 08:47:50 +00:00
|
|
|
int32_t tile;
|
|
|
|
|
|
|
|
static const tokenlist subtokens[] =
|
|
|
|
{
|
|
|
|
{ "horizfrac", T_HORIZFRAC },
|
2016-10-14 07:40:53 +00:00
|
|
|
{ "yoffset", T_YOFFSET },
|
2015-05-27 08:47:50 +00:00
|
|
|
{ "lognumtiles", T_LOGNUMTILES },
|
|
|
|
{ "tile", T_TILE },
|
|
|
|
{ "panel", T_TILE },
|
2017-11-29 07:29:48 +00:00
|
|
|
{ "yscale", T_YSCALE },
|
2015-05-27 08:47:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&tile))
|
|
|
|
break;
|
|
|
|
if (scriptfile_getbraces(script,&blockend))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (tile != DEFAULTPSKY && (unsigned)tile >= MAXUSERTILES)
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
scriptfile_setposition(script, blockend);
|
2015-05-27 08:47:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
psky_t * const newpsky = tileSetupSky(tile);
|
2015-05-27 08:47:50 +00:00
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, blockend))
|
2015-05-27 08:47:50 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,subtokens,countof(subtokens));
|
2015-05-27 08:47:50 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_HORIZFRAC:
|
|
|
|
{
|
|
|
|
int32_t horizfrac;
|
|
|
|
scriptfile_getsymbol(script,&horizfrac);
|
|
|
|
|
|
|
|
newpsky->horizfrac = horizfrac;
|
|
|
|
break;
|
|
|
|
}
|
2016-10-14 07:40:53 +00:00
|
|
|
case T_YOFFSET:
|
|
|
|
{
|
|
|
|
int32_t yoffset;
|
|
|
|
scriptfile_getsymbol(script,&yoffset);
|
|
|
|
|
|
|
|
newpsky->yoffs = yoffset;
|
|
|
|
break;
|
|
|
|
}
|
2015-05-27 08:47:50 +00:00
|
|
|
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;
|
|
|
|
}
|
2017-11-29 07:29:48 +00:00
|
|
|
case T_YSCALE:
|
|
|
|
{
|
|
|
|
int32_t yscale;
|
|
|
|
scriptfile_getsymbol(script,&yscale);
|
|
|
|
|
|
|
|
newpsky->yscale = yscale;
|
|
|
|
break;
|
|
|
|
}
|
2015-05-27 08:47:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-09-23 17:55:19 +00:00
|
|
|
case T_BASEPALETTE:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos blockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
int32_t id;
|
|
|
|
|
|
|
|
static const tokenlist subtokens[] =
|
|
|
|
{
|
|
|
|
{ "raw", T_RAW },
|
|
|
|
{ "copy", T_COPY },
|
2015-10-03 11:52:51 +00:00
|
|
|
{ "undef", T_UNDEF },
|
2015-09-23 17:55:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&id))
|
|
|
|
break;
|
|
|
|
if (scriptfile_getbraces(script,&blockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)id >= MAXBASEPALS)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Invalid basepal number");
|
2020-09-13 09:28:32 +00:00
|
|
|
scriptfile_setposition(script, blockend);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int didLoadPal = 0;
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, blockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,subtokens,countof(subtokens));
|
2015-09-23 17:55:19 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_RAW:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos rawblockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
|
|
|
|
static const tokenlist rawsubtokens[] =
|
|
|
|
{
|
|
|
|
{ "file", T_FILE },
|
|
|
|
{ "offset", T_OFFSET },
|
|
|
|
{ "shiftleft", T_SHIFTLEFT },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&rawblockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2015-09-23 17:55:19 +00:00
|
|
|
int32_t offset = 0;
|
|
|
|
int32_t shiftleft = 0;
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, rawblockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,rawsubtokens,countof(rawsubtokens));
|
2015-09-23 17:55:19 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_FILE:
|
|
|
|
{
|
|
|
|
scriptfile_getstring(script,&fn);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_OFFSET:
|
|
|
|
{
|
|
|
|
scriptfile_getnumber(script,&offset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_SHIFTLEFT:
|
|
|
|
{
|
|
|
|
scriptfile_getnumber(script,&shiftleft);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (fn.IsEmpty())
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: No filename provided");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (offset < 0)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Invalid file offset");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)shiftleft >= 8)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Invalid left shift provided");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-11 21:54:33 +00:00
|
|
|
FileReader fil = fileSystem.OpenFileReader(fn);
|
2019-10-21 15:16:08 +00:00
|
|
|
if (!fil.isOpen())
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Failed opening \"%s\"", fn.GetChars());
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:16:08 +00:00
|
|
|
if (fil.Seek(offset, FileReader::SeekSet) < 0)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Seek failed");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:16:08 +00:00
|
|
|
auto palbuf = fil.Read();
|
|
|
|
if (palbuf.Size() < 768)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Read failed");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shiftleft != 0)
|
|
|
|
{
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t k = 0; k < 768; k++)
|
2015-09-23 17:55:19 +00:00
|
|
|
palbuf[k] <<= shiftleft;
|
|
|
|
}
|
|
|
|
|
2020-05-23 12:40:54 +00:00
|
|
|
paletteSetColorTable(id, palbuf.Data(), false, false);
|
2015-09-23 17:55:19 +00:00
|
|
|
didLoadPal = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_COPY:
|
|
|
|
{
|
|
|
|
int32_t source;
|
|
|
|
scriptfile_getsymbol(script,&source);
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)source >= MAXBASEPALS || source == id)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Invalid source basepal number");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-12 05:50:24 +00:00
|
|
|
auto sourcepal = GPalette.GetTranslation(Translation_BasePalettes, source);
|
|
|
|
if (sourcepal == NULL)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "basepalette: Source basepal does not exist");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-12 05:50:24 +00:00
|
|
|
GPalette.CopyTranslation(TRANSLATION(Translation_BasePalettes, id), TRANSLATION(Translation_BasePalettes, source));
|
2015-09-23 17:55:19 +00:00
|
|
|
didLoadPal = 1;
|
|
|
|
break;
|
|
|
|
}
|
2015-10-03 11:52:51 +00:00
|
|
|
case T_UNDEF:
|
|
|
|
{
|
2020-04-12 05:50:24 +00:00
|
|
|
GPalette.ClearTranslationSlot(TRANSLATION(Translation_BasePalettes, id));
|
2015-10-03 11:52:51 +00:00
|
|
|
|
|
|
|
didLoadPal = 0;
|
|
|
|
if (id == 0)
|
|
|
|
paletteloaded &= ~PALETTE_MAIN;
|
|
|
|
break;
|
|
|
|
}
|
2015-09-23 17:55:19 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (didLoadPal && id == 0)
|
|
|
|
{
|
|
|
|
paletteloaded |= PALETTE_MAIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case T_PALOOKUP:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos blockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
int32_t id;
|
|
|
|
|
|
|
|
static const tokenlist subtokens[] =
|
|
|
|
{
|
|
|
|
{ "raw", T_RAW },
|
|
|
|
{ "copy", T_COPY },
|
2015-10-03 11:52:51 +00:00
|
|
|
{ "undef", T_UNDEF },
|
2015-09-23 17:55:19 +00:00
|
|
|
|
|
|
|
{ "fogpal", T_FOGPAL },
|
|
|
|
{ "makepalookup", T_MAKEPALOOKUP },
|
|
|
|
|
|
|
|
{ "floorpal", T_FLOORPAL },
|
|
|
|
{ "nofloorpal", T_NOFLOORPAL },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&id))
|
|
|
|
break;
|
|
|
|
if (scriptfile_getbraces(script,&blockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)id >= MAXPALOOKUPS)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Invalid pal number");
|
2020-09-13 09:28:32 +00:00
|
|
|
scriptfile_setposition(script, blockend);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int didLoadShade = 0;
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, blockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,subtokens,countof(subtokens));
|
2015-09-23 17:55:19 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_RAW:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos subblockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
|
|
|
|
static const tokenlist rawsubtokens[] =
|
|
|
|
{
|
|
|
|
{ "file", T_FILE },
|
|
|
|
{ "offset", T_OFFSET },
|
|
|
|
{ "noshades", T_NOSHADES },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&subblockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2015-09-23 17:55:19 +00:00
|
|
|
int32_t offset = 0;
|
|
|
|
int32_t length = 256*32; // hardcoding 32 instead of numshades
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, subblockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,rawsubtokens,countof(rawsubtokens));
|
2015-09-23 17:55:19 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_FILE:
|
|
|
|
{
|
|
|
|
scriptfile_getstring(script,&fn);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_OFFSET:
|
|
|
|
{
|
|
|
|
scriptfile_getnumber(script,&offset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_NOSHADES:
|
|
|
|
{
|
|
|
|
length = 256;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (fn.IsEmpty())
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: No filename provided");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (offset < 0)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Invalid file offset");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-11 21:54:33 +00:00
|
|
|
FileReader fil = fileSystem.OpenFileReader(fn);
|
2019-10-21 15:16:08 +00:00
|
|
|
if (!fil.isOpen())
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Failed opening \"%s\"", fn.GetChars());
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:16:08 +00:00
|
|
|
if (fil.Seek(offset, FileReader::SeekSet) < 0)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Seek failed");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:16:08 +00:00
|
|
|
auto palookupbuf = fil.Read();
|
|
|
|
if (palookupbuf.Size() < 256)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Read failed");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-21 17:36:54 +00:00
|
|
|
if (palookupbuf.Size() >= 256*32)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
|
|
|
didLoadShade = 1;
|
|
|
|
numshades = 32;
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.setTable(id, palookupbuf.Data());
|
2015-09-23 17:55:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-04 19:24:48 +00:00
|
|
|
if (!(paletteloaded & PALETTE_SHADE))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Shade tables not loaded");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.makeTable(id, palookupbuf.Data(), 0,0,0, lookups.tables[id].noFloorPal);
|
2015-09-23 17:55:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_COPY:
|
|
|
|
{
|
|
|
|
int32_t source;
|
|
|
|
scriptfile_getsymbol(script,&source);
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)source >= MAXPALOOKUPS || source == id)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Invalid source pal number");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (source == 0 && !(paletteloaded & PALETTE_SHADE))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Shade tables not loaded");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
if (lookups.checkTable(source) || id > 0) // do not overwrite the base with an empty table.
|
|
|
|
lookups.copyTable(id, source);
|
2015-09-23 17:55:19 +00:00
|
|
|
didLoadShade = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_FOGPAL:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos subblockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
|
|
|
|
static const tokenlist fogpaltokens[] =
|
|
|
|
{
|
|
|
|
{ "red", T_RED }, { "r", T_RED },
|
|
|
|
{ "green", T_GREEN }, { "g", T_GREEN },
|
|
|
|
{ "blue", T_BLUE }, { "b", T_BLUE },
|
|
|
|
};
|
|
|
|
|
|
|
|
int32_t red = 0, green = 0, blue = 0;
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&subblockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, subblockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script, fogpaltokens, countof(fogpaltokens)))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
|
|
|
case T_RED:
|
|
|
|
scriptfile_getnumber(script,&red);
|
2015-10-10 06:57:36 +00:00
|
|
|
red = clamp(red, 0, 255);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
case T_GREEN:
|
|
|
|
scriptfile_getnumber(script,&green);
|
2015-10-10 06:57:36 +00:00
|
|
|
green = clamp(green, 0, 255);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
case T_BLUE:
|
|
|
|
scriptfile_getnumber(script,&blue);
|
2015-10-10 06:57:36 +00:00
|
|
|
blue = clamp(blue, 0, 255);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (!(paletteloaded & PALETTE_SHADE))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Shade tables not loaded");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.makeTable(id, NULL, red, green, blue, 1);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_MAKEPALOOKUP:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos subblockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
|
|
|
|
static const tokenlist makepalookuptokens[] =
|
|
|
|
{
|
|
|
|
{ "red", T_RED }, { "r", T_RED },
|
|
|
|
{ "green", T_GREEN }, { "g", T_GREEN },
|
|
|
|
{ "blue", T_BLUE }, { "b", T_BLUE },
|
|
|
|
{ "remappal", T_REMAPPAL },
|
|
|
|
{ "remapself", T_REMAPSELF },
|
|
|
|
};
|
|
|
|
|
|
|
|
int32_t red = 0, green = 0, blue = 0;
|
|
|
|
int32_t remappal = -1;
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&subblockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, subblockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
switch (getatoken(script, makepalookuptokens, countof(makepalookuptokens)))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
|
|
|
case T_RED:
|
|
|
|
scriptfile_getnumber(script,&red);
|
2015-10-10 06:57:36 +00:00
|
|
|
red = clamp(red, 0, 255);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
case T_GREEN:
|
|
|
|
scriptfile_getnumber(script,&green);
|
2015-10-10 06:57:36 +00:00
|
|
|
green = clamp(green, 0, 255);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
case T_BLUE:
|
|
|
|
scriptfile_getnumber(script,&blue);
|
2015-10-10 06:57:36 +00:00
|
|
|
blue = clamp(blue, 0, 255);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
case T_REMAPPAL:
|
|
|
|
scriptfile_getsymbol(script,&remappal);
|
|
|
|
break;
|
|
|
|
case T_REMAPSELF:
|
|
|
|
remappal = id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)remappal >= MAXPALOOKUPS)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Invalid remappal");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (!(paletteloaded & PALETTE_SHADE))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "palookup: Shade tables not loaded");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.makeTable(id, NULL, red, green, blue, lookups.tables[id].noFloorPal);
|
2015-09-23 17:55:19 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_NOFLOORPAL:
|
|
|
|
{
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.tables[id].noFloorPal = 1;
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_FLOORPAL:
|
|
|
|
{
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.tables[id].noFloorPal = 0;
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-10-03 11:52:51 +00:00
|
|
|
case T_UNDEF:
|
|
|
|
{
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.clearTable(id);
|
2015-10-03 11:52:51 +00:00
|
|
|
didLoadShade = 0;
|
|
|
|
if (id == 0)
|
|
|
|
paletteloaded &= ~PALETTE_SHADE;
|
|
|
|
break;
|
|
|
|
}
|
2015-09-23 17:55:19 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (didLoadShade && id == 0)
|
|
|
|
{
|
|
|
|
paletteloaded |= PALETTE_SHADE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case T_BLENDTABLE:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos blockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
int32_t id;
|
|
|
|
|
|
|
|
static const tokenlist subtokens[] =
|
|
|
|
{
|
|
|
|
{ "raw", T_RAW },
|
2016-10-09 07:55:23 +00:00
|
|
|
{ "glblend", T_GLBLEND },
|
2015-09-23 17:55:19 +00:00
|
|
|
{ "copy", T_COPY },
|
2015-10-03 11:52:51 +00:00
|
|
|
{ "undef", T_UNDEF },
|
2015-09-23 17:55:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&id))
|
|
|
|
break;
|
|
|
|
if (scriptfile_getbraces(script,&blockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)id >= MAXBLENDTABS)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "blendtable: Invalid blendtable number");
|
2020-09-13 09:28:32 +00:00
|
|
|
scriptfile_setposition(script, blockend);
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, blockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,subtokens,countof(subtokens));
|
2015-09-23 17:55:19 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_RAW:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos rawblockend;
|
2015-09-23 17:55:19 +00:00
|
|
|
|
|
|
|
static const tokenlist rawsubtokens[] =
|
|
|
|
{
|
|
|
|
{ "file", T_FILE },
|
|
|
|
{ "offset", T_OFFSET },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&rawblockend))
|
|
|
|
break;
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
FString fn;
|
2015-09-23 17:55:19 +00:00
|
|
|
int32_t offset = 0;
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, rawblockend))
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t token = getatoken(script,rawsubtokens,countof(rawsubtokens));
|
2015-09-23 17:55:19 +00:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case T_FILE:
|
|
|
|
{
|
|
|
|
scriptfile_getstring(script,&fn);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_OFFSET:
|
|
|
|
{
|
|
|
|
scriptfile_getnumber(script,&offset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
if (fn.IsEmpty())
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "blendtable: No filename provided");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (offset < 0)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "blendtable: Invalid file offset");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-11 21:54:33 +00:00
|
|
|
FileReader fil = fileSystem.OpenFileReader(fn);
|
2019-10-21 15:16:08 +00:00
|
|
|
if (!fil.isOpen())
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "blendtable: Failed opening \"%s\"", fn.GetChars());
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:16:08 +00:00
|
|
|
if (fil.Seek(offset, FileReader::SeekSet) < 0)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "blendtable: Seek failed");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:16:08 +00:00
|
|
|
auto blendbuf = fil.Read();
|
|
|
|
if (blendbuf.Size() < 256*256)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "blendtable: Read failed");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_COPY:
|
|
|
|
{
|
|
|
|
int32_t source;
|
|
|
|
scriptfile_getsymbol(script,&source);
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if ((unsigned)source >= MAXBLENDTABS || source == id)
|
2015-09-23 17:55:19 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "blendtable: Invalid source blendtable number");
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-10-09 07:55:23 +00:00
|
|
|
glblend[id] = glblend[source];
|
2015-09-23 17:55:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-10-03 11:52:51 +00:00
|
|
|
case T_UNDEF:
|
|
|
|
{
|
2016-10-09 07:55:23 +00:00
|
|
|
glblend[id] = defaultglblend;
|
2015-10-03 11:52:51 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-10-09 07:55:23 +00:00
|
|
|
case T_GLBLEND:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos glblendblockend;
|
2016-10-09 07:55:23 +00:00
|
|
|
|
|
|
|
static const tokenlist glblendtokens[] =
|
|
|
|
{
|
|
|
|
{ "forward", T_FORWARD },
|
|
|
|
{ "reverse", T_REVERSE },
|
|
|
|
{ "both", T_BOTH },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&glblendblockend))
|
|
|
|
break;
|
|
|
|
|
|
|
|
glblend_t * const glb = glblend + id;
|
|
|
|
*glb = nullglblend;
|
|
|
|
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, glblendblockend))
|
2016-10-09 07:55:23 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t glblendtoken = getatoken(script,glblendtokens,countof(glblendtokens));
|
2016-10-09 07:55:23 +00:00
|
|
|
switch (glblendtoken)
|
|
|
|
{
|
|
|
|
case T_FORWARD:
|
|
|
|
case T_REVERSE:
|
|
|
|
case T_BOTH:
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos glblenddefblockend;
|
2016-10-09 07:55:23 +00:00
|
|
|
|
|
|
|
static const tokenlist glblenddeftokens[] =
|
|
|
|
{
|
|
|
|
{ "src", T_SRC },
|
|
|
|
{ "sfactor", T_SRC },
|
|
|
|
{ "top", T_SRC },
|
|
|
|
|
|
|
|
{ "dst", T_DST },
|
|
|
|
{ "dfactor", T_DST },
|
|
|
|
{ "bottom", T_DST },
|
|
|
|
|
|
|
|
{ "alpha", T_ALPHA },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scriptfile_getbraces(script,&glblenddefblockend))
|
|
|
|
break;
|
|
|
|
|
|
|
|
glblenddef_t * const glbdef = glb->def + (glblendtoken == T_REVERSE);
|
2020-09-13 22:19:20 +00:00
|
|
|
while (!scriptfile_endofblock(script, glblenddefblockend))
|
2016-10-09 07:55:23 +00:00
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
int32_t glblenddeftoken = getatoken(script,glblenddeftokens,countof(glblenddeftokens));
|
2016-10-09 07:55:23 +00:00
|
|
|
switch (glblenddeftoken)
|
|
|
|
{
|
|
|
|
case T_SRC:
|
|
|
|
case T_DST:
|
|
|
|
{
|
|
|
|
uint8_t * const factor = glblenddeftoken == T_SRC ? &glbdef->src : &glbdef->dst;
|
2020-09-22 21:05:43 +00:00
|
|
|
if (script->Compare("ZERO")) *factor = STYLEALPHA_Zero;
|
|
|
|
else if (script->Compare("ONE")) *factor = STYLEALPHA_One;
|
|
|
|
else if (script->Compare("SRC_COLOR")) *factor = STYLEALPHA_SrcCol;
|
|
|
|
else if (script->Compare("ONE_MINUS_SRC_COLOR")) *factor = STYLEALPHA_InvSrcCol;
|
|
|
|
else if (script->Compare("SRC_ALPHA")) *factor = STYLEALPHA_Src;
|
|
|
|
else if (script->Compare("ONE_MINUS_SRC_ALPHA")) *factor = STYLEALPHA_InvSrc;
|
|
|
|
else if (script->Compare("DST_ALPHA")) *factor = STYLEALPHA_Dst;
|
|
|
|
else if (script->Compare("ONE_MINUS_DST_ALPHA")) *factor = STYLEALPHA_InvDst;
|
|
|
|
else if (script->Compare("DST_COLOR")) *factor = STYLEALPHA_DstCol;
|
|
|
|
else if (script->Compare("ONE_MINUS_DST_COLOR")) *factor = STYLEALPHA_InvDstCol;
|
|
|
|
else script->ScriptMessage("Unknown blend operation %s", script->String);
|
2016-10-09 07:55:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case T_ALPHA:
|
|
|
|
{
|
|
|
|
double tempalpha;
|
|
|
|
scriptfile_getdouble(script,&tempalpha);
|
|
|
|
glbdef->alpha = (float)tempalpha;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (glblendtoken == T_BOTH)
|
|
|
|
glb->def[1] = *glbdef;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-23 17:55:19 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-09-27 21:18:24 +00:00
|
|
|
case T_NUMALPHATABS:
|
|
|
|
{
|
|
|
|
int32_t value;
|
|
|
|
if (scriptfile_getnumber(script,&value)) break;
|
|
|
|
|
|
|
|
switch (value)
|
|
|
|
{
|
2016-10-14 07:40:32 +00:00
|
|
|
case 1: case 3: case 7: case 15: case 31: case 63: case 127:
|
|
|
|
case 2: case 4: case 8: case 16: case 32: case 64: case 128:
|
2016-10-09 07:55:23 +00:00
|
|
|
#ifdef USE_OPENGL
|
2016-10-14 07:40:32 +00:00
|
|
|
for (int32_t a = 1, value2 = value*2 + (value&1); a <= value; ++a)
|
2016-10-09 07:55:23 +00:00
|
|
|
{
|
2016-10-14 07:40:32 +00:00
|
|
|
float finv2value = 1.f/(float)value2;
|
2016-10-09 07:55:23 +00:00
|
|
|
|
|
|
|
glblend_t * const glb = glblend + a;
|
|
|
|
*glb = defaultglblend;
|
|
|
|
glb->def[0].alpha = (float)(value2-a) * finv2value;
|
|
|
|
glb->def[1].alpha = (float)a * finv2value;
|
|
|
|
}
|
2017-07-18 20:53:41 +00:00
|
|
|
fallthrough__;
|
2016-10-09 07:55:23 +00:00
|
|
|
#endif
|
2016-10-14 07:40:32 +00:00
|
|
|
case 0:
|
2015-09-27 21:18:24 +00:00
|
|
|
numalphatabs = value;
|
|
|
|
break;
|
|
|
|
default:
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "numalphatables: Invalid value");
|
2015-09-27 21:18:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-10-03 11:52:51 +00:00
|
|
|
case T_UNDEFBASEPALETTERANGE:
|
|
|
|
{
|
|
|
|
int32_t id0, id1;
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&id0))
|
|
|
|
break;
|
|
|
|
if (scriptfile_getsymbol(script,&id1))
|
|
|
|
break;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (id0 > id1 || (unsigned)id0 >= MAXBASEPALS || (unsigned)id1 >= MAXBASEPALS)
|
2015-10-03 11:52:51 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "undefbasepaletterange: Invalid range");
|
2015-10-03 11:52:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i = id0; i <= id1; i++)
|
2020-04-12 05:50:24 +00:00
|
|
|
GPalette.ClearTranslationSlot(TRANSLATION(Translation_BasePalettes, i));
|
2015-10-03 11:52:51 +00:00
|
|
|
|
|
|
|
if (id0 == 0)
|
|
|
|
paletteloaded &= ~PALETTE_MAIN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case T_UNDEFPALOOKUPRANGE:
|
|
|
|
{
|
|
|
|
int32_t id0, id1;
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&id0))
|
|
|
|
break;
|
|
|
|
if (scriptfile_getsymbol(script,&id1))
|
|
|
|
break;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (id0 > id1 || (unsigned)id0 >= MAXPALOOKUPS || (unsigned)id1 >= MAXPALOOKUPS)
|
2015-10-03 11:52:51 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "undefpalookuprange: Invalid range");
|
2015-10-03 11:52:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i = id0; i <= id1; i++)
|
2020-05-27 20:19:02 +00:00
|
|
|
lookups.clearTable(i);
|
2015-10-03 11:52:51 +00:00
|
|
|
|
|
|
|
if (id0 == 0)
|
|
|
|
paletteloaded &= ~PALETTE_SHADE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case T_UNDEFBLENDTABLERANGE:
|
|
|
|
{
|
|
|
|
int32_t id0, id1;
|
|
|
|
|
|
|
|
if (scriptfile_getsymbol(script,&id0))
|
|
|
|
break;
|
|
|
|
if (scriptfile_getsymbol(script,&id1))
|
|
|
|
break;
|
|
|
|
|
2020-09-04 19:24:48 +00:00
|
|
|
if (id0 > id1 || (unsigned)id0 >= MAXBLENDTABS || (unsigned)id1 >= MAXBLENDTABS)
|
2015-10-03 11:52:51 +00:00
|
|
|
{
|
2020-09-14 20:55:21 +00:00
|
|
|
pos.Message(MSG_ERROR, "undefblendtablerange: Invalid range");
|
2015-10-03 11:52:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-08-09 08:21:19 +00:00
|
|
|
case T_NEWGAMECHOICES: // stub
|
|
|
|
{
|
2020-09-13 09:28:32 +00:00
|
|
|
FScanner::SavedPos blockend;
|
2019-08-09 08:21:19 +00:00
|
|
|
if (scriptfile_getbraces(script,&blockend))
|
|
|
|
break;
|
2020-09-13 09:28:32 +00:00
|
|
|
scriptfile_setposition(script, blockend);
|
|
|
|
break;
|
2019-08-09 08:21:19 +00:00
|
|
|
}
|
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
case T_RFFDEFINEID:
|
|
|
|
{
|
2020-09-13 08:29:57 +00:00
|
|
|
FString resName;
|
|
|
|
FString resType;
|
|
|
|
FString rffName;
|
2020-08-19 18:29:37 +00:00
|
|
|
int resID;
|
2019-09-19 20:02:45 +00:00
|
|
|
|
2020-08-19 18:29:37 +00:00
|
|
|
if (scriptfile_getstring(script, &resName))
|
2019-09-19 20:02:45 +00:00
|
|
|
break;
|
2020-08-19 18:29:37 +00:00
|
|
|
|
|
|
|
if (scriptfile_getstring(script, &resType))
|
2019-09-19 20:02:45 +00:00
|
|
|
break;
|
2020-08-19 18:29:37 +00:00
|
|
|
|
|
|
|
if (scriptfile_getnumber(script, &resID))
|
2019-09-19 20:02:45 +00:00
|
|
|
break;
|
2020-08-19 18:29:37 +00:00
|
|
|
|
|
|
|
if (scriptfile_getstring(script, &rffName))
|
2019-09-19 20:02:45 +00:00
|
|
|
break;
|
2020-08-19 18:29:37 +00:00
|
|
|
|
2020-09-13 08:29:57 +00:00
|
|
|
FStringf name("%s.%s", resName.GetChars(), resType.GetChars());
|
2020-08-19 18:29:37 +00:00
|
|
|
fileSystem.CreatePathlessCopy(resName, resID, 0);
|
2019-09-19 20:02:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-05-27 08:47:50 +00:00
|
|
|
|
2020-08-19 18:29:37 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
default:
|
2020-09-22 06:49:03 +00:00
|
|
|
pos.Message(MSG_ERROR, "%s: Unknown token.", script->String); break;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-23 18:27:24 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-16 14:42:44 +00:00
|
|
|
int32_t loaddefinitionsfile(const char *fn, bool loadadds)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
scriptfile *script;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
script = scriptfile_fromfile(fn);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2013-03-28 09:06:14 +00:00
|
|
|
if (script)
|
|
|
|
{
|
2020-08-26 18:19:54 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Loading \"%s\"\n",fn);
|
2013-03-28 09:06:14 +00:00
|
|
|
|
|
|
|
defsparser(script);
|
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2020-09-16 14:42:44 +00:00
|
|
|
if (userConfig.AddDefs && loadadds) for (auto& m : *userConfig.AddDefs)
|
2020-09-14 22:11:08 +00:00
|
|
|
{
|
|
|
|
Printf("Loading module \"%s\"\n",m.GetChars());
|
|
|
|
defsparser_include(m, NULL, NULL); // Q: should we let the external script see our symbol table?
|
|
|
|
}
|
2011-07-21 22:39:29 +00:00
|
|
|
|
2013-03-28 09:06:14 +00:00
|
|
|
if (script)
|
|
|
|
scriptfile_close(script);
|
|
|
|
|
2014-09-30 04:17:53 +00:00
|
|
|
DO_FREE_AND_NULL(faketilebuffer);
|
|
|
|
faketilebuffersiz = 0;
|
|
|
|
|
2013-03-28 09:06:14 +00:00
|
|
|
if (!script) return -1;
|
|
|
|
|
2020-08-26 18:19:54 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "\n");
|
2013-09-13 20:23:59 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// vim:ts=4:
|