Merge branch 'master' into gonesolong

Conflicts:
	src/CMakeLists.txt
	src/actor.h
	src/g_heretic/a_hereticmisc.cpp
	src/g_heretic/a_hereticweaps.cpp
	src/g_heretic/a_ironlich.cpp
	src/info.h
	src/namedef.h
	src/p_buildmap.cpp
	src/p_enemy.cpp
	src/p_map.cpp
	src/p_mobj.cpp
	src/thingdef/thingdef_codeptr.cpp
	zdoom.vcproj
This commit is contained in:
Randy Heit 2014-12-20 19:11:39 -06:00
commit 2d87eb0ba2
457 changed files with 13703 additions and 9290 deletions

View file

@ -41,28 +41,65 @@
// classes.
////////////////////////////////////////////////////////////////////////////////
class CommandDrawImage : public SBarInfoCommand
class CommandDrawImage : public SBarInfoCommandFlowControl
{
public:
CommandDrawImage(SBarInfo *script) : SBarInfoCommand(script),
translatable(false), type(NORMAL_IMAGE), image(-1), offset(static_cast<Offset> (TOP|LEFT)),
CommandDrawImage(SBarInfo *script) : SBarInfoCommandFlowControl(script),
translatable(false), type(NORMAL_IMAGE), image(-1), maxwidth(-1),
maxheight(-1), spawnScaleX(1.0f), spawnScaleY(1.0f), flags(0),
applyscale(false), offset(static_cast<Offset> (TOP|LEFT)),
texture(NULL), alpha(FRACUNIT)
{
}
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar)
{
if(flags & DI_ALTERNATEONFAIL)
SBarInfoCommandFlowControl::Draw(block, statusBar);
if(texture == NULL)
return;
int w = maxwidth, h = maxheight;
// We must calculate this per frame in order to prevent glitches with cl_capfps true.
fixed_t frameAlpha = block->Alpha();
if(alpha != FRACUNIT)
frameAlpha = fixed_t(((double) block->Alpha() / (double) FRACUNIT) * ((double) alpha / (double) OPAQUE) * FRACUNIT);
if(flags & DI_DRAWINBOX)
{
double scale1, scale2;
scale1 = scale2 = 1.0f;
double texwidth = (int) (texture->GetScaledWidthDouble()*spawnScaleX);
double texheight = (int) (texture->GetScaledHeightDouble()*spawnScaleY);
if (w != -1 && (w<texwidth || (flags & DI_FORCESCALE)))
{
scale1 = w/texwidth;
}
if (h != -1 && (h<texheight || (flags & DI_FORCESCALE)))
{
scale2 = h/texheight;
}
if (flags & DI_FORCESCALE)
{
if (w == -1 || (h != -1 && scale2<scale1))
scale1=scale2;
}
else if (scale2<scale1) scale1=scale2;
w=(int)(texwidth*scale1);
h=(int)(texheight*scale1);
}
else if (applyscale)
{
w=(int) (texture->GetScaledWidthDouble()*spawnScaleX);
h=(int) (texture->GetScaledHeightDouble()*spawnScaleY);
}
statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(),
translatable, false, offset);
translatable, false, offset, false, w, h);
}
void Parse(FScanner &sc, bool fullScreenOffsets)
{
@ -98,7 +135,7 @@ class CommandDrawImage : public SBarInfoCommand
type = HEXENARMOR_AMULET;
else
{
sc.ScriptMessage("Unkown armor type: '%s'", sc.String);
sc.ScriptMessage("Unknown armor type: '%s'", sc.String);
type = HEXENARMOR_ARMOR;
}
sc.MustGetToken(',');
@ -136,53 +173,100 @@ class CommandDrawImage : public SBarInfoCommand
GetCoordinates(sc, fullScreenOffsets, imgx, imgy);
if(sc.CheckToken(','))
{
sc.MustGetToken(TK_Identifier);
if(sc.Compare("center"))
offset = CENTER;
else if(sc.Compare("centerbottom"))
offset = static_cast<Offset> (HMIDDLE|BOTTOM);
else
sc.ScriptError("'%s' is not a valid alignment.", sc.String);
// Use none instead of topleft in case we decide we want to use
// alignments to remove the offset from images.
if(!sc.CheckToken(TK_None))
{
sc.MustGetToken(TK_Identifier);
if(sc.Compare("center"))
offset = CENTER;
else if(sc.Compare("centerbottom"))
offset = static_cast<Offset> (HMIDDLE|BOTTOM);
else
sc.ScriptError("'%s' is not a valid alignment.", sc.String);
}
}
sc.MustGetToken(';');
if(sc.CheckToken(','))
{
sc.MustGetToken(TK_IntConst);
if((maxwidth = sc.Number) > 0)
flags |= DI_DRAWINBOX;
else
maxwidth = -1;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
if ((maxheight = sc.Number) > 0)
flags |= DI_DRAWINBOX;
else
maxheight = -1;
}
if(sc.CheckToken(','))
{
while(sc.CheckToken(TK_Identifier))
{
if(sc.Compare("skipicon"))
flags |= DI_SKIPICON;
else if(sc.Compare("skipalticon"))
flags |= DI_SKIPALTICON;
else if(sc.Compare("skipspawn"))
flags |= DI_SKIPSPAWN;
else if(sc.Compare("skipready"))
flags |= DI_SKIPREADY;
else if(sc.Compare("alticonfirst"))
flags |= DI_ALTICONFIRST;
else if(sc.Compare("forcescale"))
{
if(flags & DI_DRAWINBOX)
flags |= DI_FORCESCALE;
}
else if(sc.Compare("alternateonfail"))
flags |= DI_ALTERNATEONFAIL;
else
sc.ScriptError("Unknown flag '%s'.", sc.String);
if(!sc.CheckToken('|') && !sc.CheckToken(',')) break;
}
}
if(flags & DI_ALTERNATEONFAIL)
SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets);
else
sc.MustGetToken(';');
}
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
{
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
texture = NULL;
alpha = FRACUNIT;
if (applyscale)
{
spawnScaleX = spawnScaleY = 1.0f;
applyscale = false;
}
if(type == PLAYERICON)
texture = TexMan[statusBar->CPlayer->mo->ScoreIcon];
else if(type == AMMO1)
{
if(statusBar->ammo1 != NULL)
texture = TexMan[statusBar->ammo1->Icon];
AAmmo *ammo = statusBar->ammo1;
if(ammo != NULL)
GetIcon(ammo);
}
else if(type == AMMO2)
{
if(statusBar->ammo2 != NULL)
texture = TexMan[statusBar->ammo2->Icon];
AAmmo *ammo = statusBar->ammo2;
if(ammo != NULL)
GetIcon(ammo);
}
else if(type == ARMOR)
{
if(statusBar->armor != NULL && statusBar->armor->Amount != 0)
texture = TexMan(statusBar->armor->Icon);
ABasicArmor *armor = statusBar->armor;
if(armor != NULL && armor->Amount != 0)
GetIcon(armor);
}
else if(type == WEAPONICON)
{
AWeapon *weapon = statusBar->CPlayer->ReadyWeapon;
if(weapon != NULL)
{
FTextureID icon;
if (weapon->Icon.isValid())
{
icon = weapon->Icon;
}
else
{
icon = GetWeaponIcon(weapon);
}
texture = TexMan[icon];
}
GetIcon(weapon);
}
else if(type == SIGIL)
{
@ -213,8 +297,26 @@ class CommandDrawImage : public SBarInfoCommand
texture = TexMan(statusBar->CPlayer->mo->InvSel->Icon);
else if(image >= 0)
texture = statusBar->Images[image];
if (flags & DI_ALTERNATEONFAIL)
{
SetTruth(texture == NULL || texture->UseType == FTexture::TEX_Null, block, statusBar);
}
}
protected:
void GetIcon(AInventory *item)
{
FTextureID icon = GetInventoryIcon(item, flags, &applyscale);
if (applyscale)
{
spawnScaleX = FIXED2FLOAT(item->scaleX);
spawnScaleY = FIXED2FLOAT(item->scaleY);
}
texture = TexMan[icon];
}
enum ImageType
{
PLAYERICON,
@ -238,6 +340,12 @@ class CommandDrawImage : public SBarInfoCommand
ImageType type;
int image;
FTextureID sprite;
int maxwidth;
int maxheight;
double spawnScaleX;
double spawnScaleY;
DWORD flags;
bool applyscale; //Set remotely from from GetInventoryIcon when selected sprite comes from Spawn state
// I'm using imgx/imgy here so that I can inherit drawimage with drawnumber for some commands.
SBarInfoCoordinate imgx;
SBarInfoCoordinate imgy;
@ -722,7 +830,7 @@ class CommandDrawString : public SBarInfoCommand
if(level.lumpnum != cache)
{
cache = level.lumpnum;
str = level.mapname;
str = level.MapName;
str.ToUpper();
RealignString();
}
@ -1479,11 +1587,11 @@ class CommandDrawMugShot : public SBarInfoCommand
////////////////////////////////////////////////////////////////////////////////
class CommandDrawSelectedInventory : public SBarInfoCommandFlowControl, private CommandDrawImage, private CommandDrawNumber
class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDrawNumber
{
public:
CommandDrawSelectedInventory(SBarInfo *script) : SBarInfoCommandFlowControl(script),
CommandDrawImage(script), CommandDrawNumber(script), alternateOnEmpty(false),
CommandDrawSelectedInventory(SBarInfo *script) : CommandDrawImage(script),
CommandDrawNumber(script), alternateOnEmpty(false),
artiflash(false), alwaysShowCounter(false)
{
length = INT_MAX; // Counter size
@ -1639,10 +1747,20 @@ class CommandGameMode : public SBarInfoCommandFlowControl
void Parse(FScanner &sc, bool fullScreenOffsets)
{
static bool warnUnknown = true;
do
{
sc.MustGetToken(TK_Identifier);
modes |= static_cast<GameModes> (1<<sc.MustMatchString(modeNames));
int mode = sc.MatchString(modeNames);
if(mode >= 0)
modes |= static_cast<GameModes> (1<<mode);
else if(warnUnknown)
{
// Only warn about unknowns for cross port compatibility
// Also only warn once to keep logs from getting messy.
warnUnknown = false;
FScriptPosition(sc).Message(MSG_WARNING, "Ignoring unknown gamemode %s (future cases will be silently ignored).", sc.String);
}
}
while(sc.CheckToken(','));
SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets);
@ -3011,7 +3129,7 @@ class CommandDrawGem : public SBarInfoCommand
else
sc.ScriptError("Unknown drawgem flag '%s'.", sc.String);
if(!sc.CheckToken('|'))
sc.MustGetToken(',');
sc.MustGetToken(',');
}
sc.MustGetToken(TK_StringConst); //chain
chain = script->newImage(sc.String);