This commit is contained in:
Christoph Oelckers 2016-01-26 11:40:32 +01:00
commit 371225858d
12 changed files with 129 additions and 70 deletions

View file

@ -36,7 +36,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
if (self->player != NULL)
{
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO))
if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire))
return;
@ -73,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
if (self->player != NULL)
{
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return;
@ -148,7 +148,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
slope = P_AimLineAttack (self, angle, Range, &linetarget) + (pr_saw.Random2() * (Spread_Z / 255));
AWeapon *weapon = self->player->ReadyWeapon;
if ((weapon != NULL) && !(Flags & SF_NOUSEAMMO) && !(!linetarget && (Flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO))
if ((weapon != NULL) && !(Flags & SF_NOUSEAMMO) && !(!linetarget && (Flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire))
return;
@ -250,7 +250,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun)
S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM);
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return;
@ -281,7 +281,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2))
return;
@ -390,7 +390,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun)
}
AWeapon *weapon = player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return;
@ -431,7 +431,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile)
return;
}
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return;
@ -454,7 +454,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade)
return;
}
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire))
return;
@ -479,7 +479,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma)
return;
}
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return;
@ -497,7 +497,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma)
//
// [RH] A_FireRailgun
//
static void FireRailgun(AActor *self, int offset_xy)
static void FireRailgun(AActor *self, int offset_xy, bool fromweapon)
{
int damage;
player_t *player;
@ -508,7 +508,7 @@ static void FireRailgun(AActor *self, int offset_xy)
}
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && fromweapon)
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return;
@ -528,17 +528,17 @@ static void FireRailgun(AActor *self, int offset_xy)
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun)
{
FireRailgun(self, 0);
FireRailgun(self, 0, ACTION_CALL_FROM_WEAPON());
}
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight)
{
FireRailgun(self, 10);
FireRailgun(self, 10, ACTION_CALL_FROM_WEAPON());
}
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft)
{
FireRailgun(self, -10);
FireRailgun(self, -10, ACTION_CALL_FROM_WEAPON());
}
DEFINE_ACTION_FUNCTION(AActor, A_RailWait)
@ -560,7 +560,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG)
}
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, deh.BFGCells))
return;
@ -671,6 +671,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG)
AActor * mo = NULL;
player_t *player;
bool doesautoaim = false;
if (NULL == (player = self->player))
{
@ -678,18 +679,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG)
}
AWeapon *weapon = self->player->ReadyWeapon;
if (!ACTION_CALL_FROM_WEAPON()) weapon = NULL;
if (weapon != NULL)
{
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return;
doesautoaim = !(weapon->WeaponFlags & WIF_NOAUTOAIM);
weapon->WeaponFlags |= WIF_NOAUTOAIM; // No autoaiming that gun
}
self->player->extralight = 2;
// Save values temporarily
angle_t SavedPlayerAngle = self->angle;
fixed_t SavedPlayerPitch = self->pitch;
bool doesautoaim = !(self->player->ReadyWeapon->WeaponFlags & WIF_NOAUTOAIM);
self->player->ReadyWeapon->WeaponFlags |= WIF_NOAUTOAIM; // No autoaiming that gun
for (int i = 0; i < 2; i++) // Spawn two plasma balls in sequence
{
self->angle += ((pr_oldbfg()&127) - 64) * (ANG90/768);
@ -699,5 +702,5 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG)
self->angle = SavedPlayerAngle;
self->pitch = SavedPlayerPitch;
}
if (doesautoaim) self->player->ReadyWeapon->WeaponFlags &= ~WIF_NOAUTOAIM; // Restore autoaim setting
if (doesautoaim && weapon != NULL) weapon->WeaponFlags &= ~WIF_NOAUTOAIM; // Restore autoaim setting
}

View file

@ -109,10 +109,10 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast)
TThinkerIterator<AActor> iterator;
fixed_t dist;
if (self->player && (blastflags & BF_USEAMMO))
if (self->player && (blastflags & BF_USEAMMO) && ACTION_CALL_FROM_WEAPON())
{
AWeapon * weapon = self->player->ReadyWeapon;
if (!weapon->DepleteAmmo(weapon->bAltFire))
if (weapon != NULL && !weapon->DepleteAmmo(weapon->bAltFire))
return;
}

View file

@ -6009,10 +6009,10 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
int startalpha = argCount > 13 ? args[13] : 0xFF; // Byte trans
int fadestep = argCount > 14 ? args[14] : -1;
startalpha = clamp<int>(startalpha, 0, 0xFF); // Clamp to byte
lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte
fadestep = clamp<int>(fadestep, -1, 0xFF); // Clamp to byte inc. -1 (indicating automatic)
size = clamp<int>(size, 0, 127); // Clamp to byte
startalpha = clamp<int>(startalpha, 0, 255); // Clamp to byte
lifetime = clamp<int>(lifetime, 0, 255); // Clamp to byte
fadestep = clamp<int>(fadestep, -1, 255); // Clamp to byte inc. -1 (indicating automatic)
size = clamp<int>(size, 0, 65535); // Clamp to word
if (lifetime != 0)
P_SpawnParticle(x, y, z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz);

View file

@ -284,7 +284,7 @@ void P_ThinkParticles ()
}
}
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz)
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, WORD size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz)
{
particle_t *particle = NewParticle();

View file

@ -59,7 +59,7 @@ struct particle_t
fixed_t accx,accy,accz;
BYTE ttl;
BYTE trans;
BYTE size:7;
WORD size;
BYTE bright:1;
BYTE fade;
int color;
@ -83,7 +83,7 @@ particle_t *JitterParticle (int ttl);
particle_t *JitterParticle (int ttl, float drift);
void P_ThinkParticles (void);
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz);
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, WORD size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz);
void P_InitEffects (void);
void P_RunEffects (void);

View file

@ -36,6 +36,7 @@
#include "templates.h"
#include "doomdef.h"
#include "doomstat.h"
#include "d_event.h"
#include "gstrings.h"
#include "i_system.h"
@ -177,7 +178,7 @@ bool CheckIfExitIsGood (AActor *self, level_info_t *info)
{
return false;
}
if (deathmatch)
if (deathmatch && gameaction != ga_completed)
{
Printf ("%s exited the level.\n", self->player->userinfo.GetName());
}

View file

@ -46,7 +46,8 @@
//
//===========================================================================
template<class TSrc, class TDest, class TBlend>
void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf)
void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf,
BYTE tr, BYTE tg, BYTE tb)
{
int i;
int fac;
@ -59,7 +60,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
case BLEND_NONE:
for(i=0;i<count;i++)
{
a = TSrc::A(pin);
a = TSrc::A(pin, tr, tg, tb);
if (TBlend::ProcessAlpha0() || a)
{
TBlend::OpC(pout[TDest::RED], TSrc::R(pin), a, inf);
@ -77,7 +78,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
// Since this is done in True Color the purplish tint is fully preserved - even in Doom!
for(i=0;i<count;i++)
{
a = TSrc::A(pin);
a = TSrc::A(pin, tr, tg, tb);
if (TBlend::ProcessAlpha0() || a)
{
int gray = TSrc::Gray(pin)>>4;
@ -99,7 +100,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
FSpecialColormap *cm = &SpecialColormaps[inf->blend - BLEND_SPECIALCOLORMAP1];
for(i=0;i<count;i++)
{
a = TSrc::A(pin);
a = TSrc::A(pin, tr, tg, tb);
if (TBlend::ProcessAlpha0() || a)
{
gray = clamp<int>(TSrc::Gray(pin),0,255);
@ -120,7 +121,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
fac=inf->blend-BLEND_DESATURATE1+1;
for(i=0;i<count;i++)
{
a = TSrc::A(pin);
a = TSrc::A(pin, tr, tg, tb);
if (TBlend::ProcessAlpha0() || a)
{
gray = TSrc::Gray(pin);
@ -142,7 +143,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
case BLEND_MODULATE:
for(i=0;i<count;i++)
{
a = TSrc::A(pin);
a = TSrc::A(pin, tr, tg, tb);
if (TBlend::ProcessAlpha0() || a)
{
r = (TSrc::R(pin)*inf->blendcolor[0])>>FRACBITS;
@ -163,7 +164,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
for(i=0;i<count;i++)
{
// color blend
a = TSrc::A(pin);
a = TSrc::A(pin, tr, tg, tb);
if (TBlend::ProcessAlpha0() || a)
{
r = (TSrc::R(pin)*inf->blendcolor[3] + inf->blendcolor[0]) >> FRACBITS;
@ -183,11 +184,12 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in
}
}
typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf);
typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf, BYTE r, BYTE g, BYTE b);
#define COPY_FUNCS(op) \
{ \
iCopyColors<cRGB, cBGRA, op>, \
iCopyColors<cRGBT, cBGRA, op>, \
iCopyColors<cRGBA, cBGRA, op>, \
iCopyColors<cIA, cBGRA, op>, \
iCopyColors<cCMYK, cBGRA, op>, \
@ -197,7 +199,7 @@ typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopy
iCopyColors<cRGB555, cBGRA, op>, \
iCopyColors<cPalEntry, cBGRA, op> \
}
static const CopyFunc copyfuncs[][9]={
static const CopyFunc copyfuncs[][10]={
COPY_FUNCS(bCopy),
COPY_FUNCS(bBlend),
COPY_FUNCS(bAdd),
@ -370,7 +372,8 @@ bool FClipRect::Intersect(int ix, int iy, int iw, int ih)
//
//===========================================================================
void FBitmap::CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth,
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf)
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf,
int r, int g, int b)
{
if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
{
@ -378,7 +381,7 @@ void FBitmap::CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int
int op = inf==NULL? OP_COPY : inf->op;
for (int y=0;y<srcheight;y++)
{
copyfuncs[op][ct](&buffer[y*Pitch], &patch[y*step_y], srcwidth, step_x, inf);
copyfuncs[op][ct](&buffer[y*Pitch], &patch[y*step_y], srcwidth, step_x, inf, r, g, b);
}
}
}
@ -443,7 +446,7 @@ void FBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int sr
memset(penew, 0, sizeof(penew));
if (inf && inf->blend)
{
iCopyColors<cPalEntry, cBGRA, bCopy>((BYTE*)penew, (const BYTE*)palette, 256, 4, inf);
iCopyColors<cPalEntry, cBGRA, bCopy>((BYTE*)penew, (const BYTE*)palette, 256, 4, inf, 0, 0, 0);
palette = penew;
}

View file

@ -157,7 +157,8 @@ public:
virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth,
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL);
int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL,
/* for PNG tRNS */ int r=0, int g=0, int b=0);
virtual void CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight,
int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf = NULL);
@ -179,7 +180,16 @@ struct cRGB
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char A(const unsigned char * p) { return 255; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; }
};
struct cRGBT
{
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE r, BYTE g, BYTE b) { return (p[0] != r || p[1] != g || p[2] != b) ? 255 : 0; }
static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; }
};
@ -195,7 +205,7 @@ struct cRGBA
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char A(const unsigned char * p) { return p[3]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[3]; }
static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; }
};
@ -204,7 +214,7 @@ struct cIA
static __forceinline unsigned char R(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char A(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[1]; }
static __forceinline int Gray(const unsigned char * p) { return p[0]; }
};
@ -213,7 +223,7 @@ struct cCMYK
static __forceinline unsigned char R(const unsigned char * p) { return p[3] - (((256-p[0])*p[3]) >> 8); }
static __forceinline unsigned char G(const unsigned char * p) { return p[3] - (((256-p[1])*p[3]) >> 8); }
static __forceinline unsigned char B(const unsigned char * p) { return p[3] - (((256-p[2])*p[3]) >> 8); }
static __forceinline unsigned char A(const unsigned char * p) { return 255; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; }
};
@ -222,7 +232,7 @@ struct cBGR
static __forceinline unsigned char R(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char A(const unsigned char * p) { return 255; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; }
};
@ -238,7 +248,7 @@ struct cBGRA
static __forceinline unsigned char R(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char A(const unsigned char * p) { return p[3]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[3]; }
static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; }
};
@ -254,7 +264,7 @@ struct cARGB
static __forceinline unsigned char R(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[2]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[3]; }
static __forceinline unsigned char A(const unsigned char * p) { return p[0]; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[0]; }
static __forceinline int Gray(const unsigned char * p) { return (p[1]*77 + p[2]*143 + p[3]*36)>>8; }
};
@ -263,7 +273,7 @@ struct cI16
static __forceinline unsigned char R(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char G(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char B(const unsigned char * p) { return p[1]; }
static __forceinline unsigned char A(const unsigned char * p) { return 255; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return p[1]; }
};
@ -272,7 +282,7 @@ struct cRGB555
static __forceinline unsigned char R(const unsigned char * p) { return (((*(WORD*)p)&0x1f)<<3); }
static __forceinline unsigned char G(const unsigned char * p) { return (((*(WORD*)p)&0x3e0)>>2); }
static __forceinline unsigned char B(const unsigned char * p) { return (((*(WORD*)p)&0x7c00)>>7); }
static __forceinline unsigned char A(const unsigned char * p) { return 255; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; }
static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; }
};
@ -281,13 +291,14 @@ struct cPalEntry
static __forceinline unsigned char R(const unsigned char * p) { return ((PalEntry*)p)->r; }
static __forceinline unsigned char G(const unsigned char * p) { return ((PalEntry*)p)->g; }
static __forceinline unsigned char B(const unsigned char * p) { return ((PalEntry*)p)->b; }
static __forceinline unsigned char A(const unsigned char * p) { return ((PalEntry*)p)->a; }
static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return ((PalEntry*)p)->a; }
static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; }
};
enum ColorType
{
CF_RGB,
CF_RGBT,
CF_RGBA,
CF_IA,
CF_CMYK,

View file

@ -70,6 +70,8 @@ protected:
BYTE BitDepth;
BYTE ColorType;
BYTE Interlace;
bool HaveTrans;
WORD NonPaletteTrans[3];
BYTE *PaletteMap;
int PaletteSize;
@ -195,7 +197,7 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height,
BYTE depth, BYTE colortype, BYTE interlace)
: FTexture(NULL, lumpnum), SourceFile(filename), Pixels(0), Spans(0),
BitDepth(depth), ColorType(colortype), Interlace(interlace),
BitDepth(depth), ColorType(colortype), Interlace(interlace), HaveTrans(false),
PaletteMap(0), PaletteSize(0), StartOfIDAT(0)
{
union
@ -204,7 +206,6 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
BYTE pngpal[256][3];
} p;
BYTE trans[256];
bool havetRNS = false;
DWORD len, id;
int i;
@ -273,7 +274,11 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
case MAKE_ID('t','R','N','S'):
lump.Read (trans, len);
havetRNS = true;
HaveTrans = true;
// Save for colortype 2
NonPaletteTrans[0] = BigShort(((WORD *)trans)[0]);
NonPaletteTrans[1] = BigShort(((WORD *)trans)[1]);
NonPaletteTrans[2] = BigShort(((WORD *)trans)[2]);
break;
case MAKE_ID('a','l','P','h'):
@ -297,13 +302,13 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
case 0: // Grayscale
if (!bAlphaTexture)
{
if (colortype == 0 && havetRNS && trans[0] != 0)
if (colortype == 0 && HaveTrans && NonPaletteTrans[0] < 256)
{
bMasked = true;
PaletteSize = 256;
PaletteMap = new BYTE[256];
memcpy (PaletteMap, GrayMap, 256);
PaletteMap[trans[0]] = 0;
PaletteMap[NonPaletteTrans[0]] = 0;
}
else
{
@ -328,6 +333,10 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
case 6: // RGB + Alpha
bMasked = true;
break;
case 2: // RGB
bMasked = HaveTrans;
break;
}
}
@ -520,8 +529,24 @@ void FPNGTexture::MakeTexture ()
for (x = Width; x > 0; --x)
{
for (y = Height; y > 0; --y)
{
if (!HaveTrans)
{
*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
}
else
{
if (in[0] == NonPaletteTrans[0] &&
in[1] == NonPaletteTrans[1] &&
in[2] == NonPaletteTrans[2])
{
*out++ = 0;
}
else
{
*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
}
}
in += pitch;
}
in -= backstep;
@ -625,12 +650,15 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
break;
case MAKE_ID('t','R','N','S'):
if (ColorType == 3)
{
for(DWORD i = 0; i < len; i++)
{
(*lump) >> pe[i].a;
if (pe[i].a != 0 && pe[i].a != 255)
transpal = true;
}
}
break;
}
lump->Seek(4, SEEK_CUR); // Skip CRC
@ -639,6 +667,12 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
lump->Read(&id, 4);
}
if (ColorType == 0 && HaveTrans && NonPaletteTrans[0] < 256)
{
pe[NonPaletteTrans[0]].a = 0;
transpal = true;
}
BYTE * Pixels = new BYTE[pixwidth * Height];
lump->Seek (StartOfIDAT, SEEK_SET);
@ -655,7 +689,15 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
break;
case 2:
if (!HaveTrans)
{
bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, pixwidth, rotate, CF_RGB, inf);
}
else
{
bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, pixwidth, rotate, CF_RGBT, inf,
NonPaletteTrans[0], NonPaletteTrans[1], NonPaletteTrans[2]);
}
break;
case 4:

View file

@ -382,7 +382,7 @@ struct StateCallData
void AF_##name (AActor *self, AActor *stateowner, FState *, int, StateCallData *); \
static AFuncDesc info_##cls##_##name = { #name, AF_##name }; \
MSVC_ASEG AFuncDesc *infoptr_##cls##_##name GCC_ASEG = &info_##cls##_##name; \
void AF_##name (AActor *self, AActor *stateowner, FState *, int, StateCallData *statecall)
void AF_##name (AActor *self, AActor *stateowner, FState *CallingState, int, StateCallData *statecall)
#define DEFINE_ACTION_FUNCTION_PARAMS(cls, name) \
void AFP_##name (AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall); \

View file

@ -1261,7 +1261,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
int bslope = 0;
int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
if ((flags & FBF_USEAMMO) && weapon)
if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return; // out of ammo
@ -1450,7 +1450,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
pitch = P_AimLineAttack (self, angle, range, &linetarget);
// only use ammo when actually hitting something!
if ((flags & CPF_USEAMMO) && linetarget && weapon)
if ((flags & CPF_USEAMMO) && linetarget && weapon && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return; // out of ammo
@ -1548,7 +1548,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack)
AWeapon *weapon = self->player->ReadyWeapon;
// only use ammo when actually hitting something!
if (useammo)
if (useammo && weapon != NULL && ACTION_CALL_FROM_WEAPON())
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return; // out of ammo
@ -2644,7 +2644,6 @@ enum SPFflag
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
{
//(color color1, int flags = 0, int lifetime = 35, int size = 1, float angle = 0, float xoff = 0, float yoff = 0, float zoff = 0, float velx = 0, float vely = 0, float velz = 0, float accelx = 0, float accely = 0, float accelz = 0, float startalphaf = 1, float fadestepf = -1);
ACTION_PARAM_START(15);
ACTION_PARAM_COLOR(color, 0);
ACTION_PARAM_INT(flags, 1);
@ -2665,8 +2664,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
BYTE startalpha = (BYTE)Scale(clamp(startalphaf, 0, FRACUNIT), 255, FRACUNIT);
int fadestep = fadestepf < 0? -1 : Scale(clamp(fadestepf, 0, FRACUNIT), 255, FRACUNIT);
lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte
size = clamp<int>(size, 0, 0xFF); // Clamp to byte
lifetime = clamp<int>(lifetime, 0, 255); // Clamp to byte
size = clamp<int>(size, 0, 65535); // Clamp to word
if (lifetime != 0)
{

View file

@ -2455,7 +2455,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, GruntSpeed, F, PlayerPawn)
DEFINE_CLASS_PROPERTY_PREFIX(player, FallingScreamSpeed, FF, PlayerPawn)
{
PROP_FIXED_PARM(minz, 0);
PROP_FIXED_PARM(maxz, 0);
PROP_FIXED_PARM(maxz, 1);
defaults->FallingScreamMinSpeed = minz;
defaults->FallingScreamMaxSpeed = maxz;
}