This commit is contained in:
Christoph Oelckers 2018-03-24 19:40:52 +01:00
commit 49ab99a383
5 changed files with 56 additions and 12 deletions

View File

@ -413,6 +413,12 @@ void E_WorldThingDestroyed(AActor* actor)
handler->WorldThingDestroyed(actor);
}
void E_WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
handler->WorldLinePreActivated(line, actor, shouldactivate);
}
void E_WorldLineActivated(line_t* line, AActor* actor)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
@ -548,6 +554,7 @@ DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageType);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageFlags);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageAngle);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, ActivatedLine);
DEFINE_FIELD_X(WorldEvent, FWorldEvent, ShouldActivate);
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, PlayerNumber);
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, IsReturn);
@ -634,6 +641,7 @@ DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDied)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingRevived)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDamaged)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldThingDestroyed)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldLinePreActivated)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldLineActivated)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldLightning)
DEFINE_EMPTY_HANDLER(DStaticEventHandler, WorldTick)
@ -796,6 +804,23 @@ void DStaticEventHandler::WorldThingDestroyed(AActor* actor)
}
}
void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate)
{
IFVIRTUAL(DStaticEventHandler, WorldLinePreActivated)
{
// don't create excessive DObjects if not going to be processed anyway
if (func == DStaticEventHandler_WorldLinePreActivated_VMPtr)
return;
FWorldEvent e = E_SetupWorldEvent();
e.Thing = actor;
e.ActivatedLine = line;
e.ShouldActivate = *shouldactivate;
VMValue params[2] = { (DStaticEventHandler*)this, &e };
VMCall(func, params, 2, nullptr, 0);
*shouldactivate = e.ShouldActivate;
}
}
void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor)
{
IFVIRTUAL(DStaticEventHandler, WorldLineActivated)

View File

@ -40,6 +40,8 @@ void E_WorldThingRevived(AActor* actor);
void E_WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle);
// called before AActor::Destroy of each actor.
void E_WorldThingDestroyed(AActor* actor);
// called in P_ActivateLine before executing special, set shouldactivate to false to prevent activation.
void E_WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate);
// called in P_ActivateLine after successful special execution.
void E_WorldLineActivated(line_t* line, AActor* actor);
// same as ACS SCRIPT_Lightning
@ -141,6 +143,7 @@ public:
void WorldThingRevived(AActor*);
void WorldThingDamaged(AActor*, AActor*, AActor*, int, FName, int, DAngle);
void WorldThingDestroyed(AActor*);
void WorldLinePreActivated(line_t*, AActor*, bool*);
void WorldLineActivated(line_t*, AActor*);
void WorldLightning();
void WorldTick();
@ -198,8 +201,9 @@ struct FWorldEvent
FName DamageType;
int DamageFlags = 0;
DAngle DamageAngle;
// for lineactivated
// for line(pre)activated
line_t* ActivatedLine = nullptr;
bool ShouldActivate = true;
};
struct FPlayerEvent

View File

@ -189,6 +189,11 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
return false;
}
// [MK] Use WorldLinePreActivated to decide if activation should continue
bool shouldactivate = true;
E_WorldLinePreActivated(line, mo, &shouldactivate);
if ( !shouldactivate ) return false;
bool remote = (line->special != 7 && line->special != 8 && (line->special < 11 || line->special > 14));
if (line->locknumber > 0 && !P_CheckKeys (mo, line->locknumber, remote)) return false;

View File

@ -768,8 +768,8 @@ OpenALSoundRenderer::OpenALSoundRenderer()
ALCint major=0, minor=0;
alcGetIntegerv(Device, ALC_MAJOR_VERSION, 1, &major);
alcGetIntegerv(Device, ALC_MINOR_VERSION, 1, &minor);
DPrintf(DMSG_SPAMMY, " ALC Version: " TEXTCOLOR_BLUE"%d.%d\n", major, minor);
DPrintf(DMSG_SPAMMY, " ALC Extensions: " TEXTCOLOR_ORANGE"%s\n", alcGetString(Device, ALC_EXTENSIONS));
DPrintf(DMSG_SPAMMY, " ALC Version: " TEXTCOLOR_BLUE"%d.%d\n", major, minor);
DPrintf(DMSG_SPAMMY, " ALC Extensions: " TEXTCOLOR_ORANGE"%s\n", alcGetString(Device, ALC_EXTENSIONS));
TArray<ALCint> attribs;
if(*snd_samplerate > 0)
@ -809,10 +809,18 @@ OpenALSoundRenderer::OpenALSoundRenderer()
}
attribs.Clear();
DPrintf(DMSG_SPAMMY, " Vendor: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VENDOR));
DPrintf(DMSG_SPAMMY, " Renderer: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_RENDERER));
DPrintf(DMSG_SPAMMY, " Version: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VERSION));
DPrintf(DMSG_SPAMMY, " Extensions: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_EXTENSIONS));
const ALchar *const version = alGetString(AL_VERSION);
if (strstr(version, "ALSOFT") == nullptr)
{
Printf(TEXTCOLOR_RED " You are using an unsupported OpenAL implementation\n"
" Install OpenAL Soft library for a better experience\n");
}
DPrintf(DMSG_SPAMMY, " Vendor: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VENDOR));
DPrintf(DMSG_SPAMMY, " Renderer: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_RENDERER));
DPrintf(DMSG_SPAMMY, " Version: " TEXTCOLOR_ORANGE"%s\n", version);
DPrintf(DMSG_SPAMMY, " Extensions: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_EXTENSIONS));
AL.EXT_source_distance_model = !!alIsExtensionPresent("AL_EXT_source_distance_model");
AL.EXT_SOURCE_RADIUS = !!alIsExtensionPresent("AL_EXT_SOURCE_RADIUS");
@ -912,7 +920,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
return;
}
FreeSfx = Sources;
DPrintf(DMSG_NOTIFY, " Allocated " TEXTCOLOR_BLUE"%u" TEXTCOLOR_NORMAL" sources\n", Sources.Size());
DPrintf(DMSG_NOTIFY, " Allocated " TEXTCOLOR_BLUE"%u" TEXTCOLOR_NORMAL" sources\n", Sources.Size());
WasInWater = false;
if(*snd_efx && ALC.EXT_EFX)
@ -961,10 +969,10 @@ OpenALSoundRenderer::OpenALSoundRenderer()
{
alEffecti(envReverb, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
if(alGetError() == AL_NO_ERROR)
DPrintf(DMSG_SPAMMY, " EAX Reverb found\n");
DPrintf(DMSG_SPAMMY, " EAX Reverb found\n");
alEffecti(envReverb, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
if(alGetError() == AL_NO_ERROR)
DPrintf(DMSG_SPAMMY, " Standard Reverb found\n");
DPrintf(DMSG_SPAMMY, " Standard Reverb found\n");
alDeleteEffects(1, &envReverb);
getALError();
@ -977,7 +985,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
alFilteri(EnvFilters[0], AL_FILTER_TYPE, AL_FILTER_LOWPASS);
alFilteri(EnvFilters[1], AL_FILTER_TYPE, AL_FILTER_LOWPASS);
if(getALError() == AL_NO_ERROR)
DPrintf(DMSG_SPAMMY, " Lowpass found\n");
DPrintf(DMSG_SPAMMY, " Lowpass found\n");
else
{
alDeleteFilters(2, EnvFilters);

View File

@ -25,8 +25,9 @@ struct WorldEvent native play version("2.4")
native readonly Name DamageType;
native readonly EDmgFlags DamageFlags;
native readonly double DamageAngle;
// for lineactivated
// for line(pre)activated
native readonly Line ActivatedLine;
native bool ShouldActivate;
}
struct PlayerEvent native play version("2.4")
@ -302,6 +303,7 @@ class StaticEventHandler : Object native play version("2.4")
virtual native void WorldThingRevived(WorldEvent e);
virtual native void WorldThingDamaged(WorldEvent e);
virtual native void WorldThingDestroyed(WorldEvent e);
virtual native void WorldLinePreActivated(WorldEvent e);
virtual native void WorldLineActivated(WorldEvent e);
virtual native void WorldLightning(WorldEvent e); // for the sake of completeness.
virtual native void WorldTick();