From 1b13e6be983c4befbdb2d78d050eb2da4753f03e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 15 Sep 2014 11:24:48 +0200 Subject: [PATCH 01/13] -. fixed:S_LoadSound passed the wrong value for the lump size parameter to LoadSoundVoc. --- src/s_sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 32a245675..035b71c74 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1321,7 +1321,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx) // If the sound is voc, use the custom loader. if (strncmp ((const char *)sfxstart, "Creative Voice File", 19) == 0) { - sfx->data = GSnd->LoadSoundVoc(sfxstart, len); + sfx->data = GSnd->LoadSoundVoc(sfxstart, size); } // If the sound is raw, just load it as such. // Otherwise, try the sound as DMX format. From 4be9a716361c119c4d81eb1571f58420ca333b75 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 15 Sep 2014 11:32:40 +0200 Subject: [PATCH 02/13] - fixed: The VOC reader didn't advance the read index correctly. --- src/sound/i_sound.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index c95b0221f..07cd43a4b 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -494,6 +494,7 @@ SoundHandle SoundRenderer::LoadSoundVoc(BYTE *sfxdata, int length) break; default: break; } + i += blocksize; } } From 94123d5ef40e6843beb27a653f5e01dd3181a375 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 15 Sep 2014 12:59:07 -0400 Subject: [PATCH 03/13] - Applied anonymous patch to fix uncapped stuttering in SDL backend. --- src/sdl/i_system.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 9b3027a7d..8fea36c37 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -123,14 +123,13 @@ void I_EndRead(void) static DWORD TicStart; -static DWORD TicNext; static DWORD BaseTime; static int TicFrozen; // Signal based timer. static Semaphore timerWait; static int tics; -static DWORD sig_start, sig_next; +static DWORD sig_start; void I_SelectTimer(); @@ -169,7 +168,6 @@ int I_GetTimePolled (bool saveMS) if (saveMS) { TicStart = tm; - TicNext = Scale((Scale (tm, TICRATE, 1000) + 1), 1000, TICRATE); } return Scale(tm - BaseTime, TICRATE, 1000); } @@ -179,7 +177,6 @@ int I_GetTimeSignaled (bool saveMS) if (saveMS) { TicStart = sig_start; - TicNext = sig_next; } return tics; } @@ -250,7 +247,6 @@ void I_HandleAlarm (int sig) if(!TicFrozen) tics++; sig_start = SDL_GetTicks(); - sig_next = Scale((Scale (sig_start, TICRATE, 1000) + 1), 1000, TICRATE); SEMAPHORE_SIGNAL(timerWait) } @@ -293,15 +289,14 @@ void I_SelectTimer() fixed_t I_GetTimeFrac (uint32 *ms) { DWORD now = SDL_GetTicks (); - if (ms) *ms = TicNext; - DWORD step = TicNext - TicStart; - if (step == 0) + if (ms) *ms = TicStart + (1000 / TICRATE); + if (TicStart == 0) { return FRACUNIT; } else { - fixed_t frac = clamp ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); + fixed_t frac = clamp ((now - TicStart)*FRACUNIT*TICRATE/1000, 0, FRACUNIT); return frac; } } From 1c96039d7a1146a50b52335e0af8623f97f98415 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Mon, 15 Sep 2014 19:46:43 +0200 Subject: [PATCH 04/13] - Fixed miscompilation with Clang 3.5.0. The optimizer miscompiles the function FBehavior::LoadScriptsDirectory and causes random crashes when zdoom is run with wads containing scripts. As said in the comment, I just hope that the Clang devs fix it for the next patching release, ie 3.5.1. --- src/p_acs.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 235a47933..405d60320 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2306,6 +2306,12 @@ void FBehavior::LoadScriptsDirectory () default: break; } + +// [EP] Clang 3.5.0 optimizer miscompiles this function and causes random +// crashes in the program. I hope that Clang 3.5.x will fix this. +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ >= 5 + asm("" : "+g" (NumScripts)); +#endif for (i = 0; i < NumScripts; ++i) { Scripts[i].Flags = 0; From 864adde92ef98245551d2ab01ac222f332b36b0b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 16 Sep 2014 08:42:27 +0200 Subject: [PATCH 05/13] - typo for savegame versioning of AActor::weaponspecial: it was introduced in savegame version 4512, not 4511. --- src/p_mobj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 50461c43a..d035e0117 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -206,7 +206,7 @@ void AActor::Serialize (FArchive &arc) { arc << flags7; } - if (SaveVersion >= 4511) + if (SaveVersion >= 4512) { arc << weaponspecial; } From 7a62459c00c6ffe8ff500ba20a5c55321b52f93b Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 18 Sep 2014 17:58:06 -0500 Subject: [PATCH 06/13] Allow SXF_SETMASTER to work on non-monsters. --- src/thingdef/thingdef_codeptr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index b1c9e9065..c443c57d9 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1843,6 +1843,10 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) // If this is a missile or something else set the target to the originator mo->target = originator ? originator : self; } + if (flags & SIXF_SETMASTER) + { + mo->master = originator; + } if (flags & SIXF_TRANSFERSCALE) { mo->scaleX = self->scaleX; From 5c4ad9be68a09a08a1c328f346faebb5fc169e12 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 19 Sep 2014 14:15:31 -0500 Subject: [PATCH 07/13] Added Blue Shadow's A_SpawnItemEx changes: (1/2) SXF_TRANSFERALPHA and SXF_TRANSFERRENDERSTYLE --- src/thingdef/thingdef_codeptr.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index c443c57d9..f25a0818e 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1755,6 +1755,8 @@ enum SIX_Flags SIXF_TRANSFERSPECIAL = 1 << 15, SIXF_CLEARCALLERSPECIAL = 1 << 16, SIXF_TRANSFERSTENCILCOL = 1 << 17, + SIXF_TRANSFERALPHA = 1 << 18, + SIXF_TRANSFERRENDERSTYLE = 1 << 19, }; static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) @@ -1875,6 +1877,14 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) { mo->fillcolor = self->fillcolor; } + if (flags & SIXF_TRANSFERALPHA) + { + mo->alpha = self->alpha; + } + if (flags & SIXF_TRANSFERRENDERSTYLE) + { + mo->RenderStyle = self->RenderStyle; + } return true; } From 33f83cc7f92b9b814f1bdc8e166da01d9386f453 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 19 Sep 2014 14:17:24 -0500 Subject: [PATCH 08/13] Added Blue Shadow's A_SpawnItemEx changes: (2/2) SXF_TRANSFERALPHA and SXF_TRANSFERRENDERSTYLE --- wadsrc/static/actors/constants.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index d5358e5af..bf998e6b0 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -65,6 +65,8 @@ const int SXF_TRANSFERSCALE = 16384; const int SXF_TRANSFERSPECIAL = 32768; const int SXF_CLEARCALLERSPECIAL = 65536; const int SXF_TRANSFERSTENCILCOL = 131072; +const int SXF_TRANSFERALPHA = 262144; +const int SXF_TRANSFERRENDERSTYLE = 524288; // Flags for A_Chase const int CHF_FASTCHASE = 1; From 16a380f82ad5ded598640f12ac498e3b7cac9d04 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 19 Sep 2014 17:27:18 -0500 Subject: [PATCH 09/13] - Added Blue Shadow's DropInventory ACS function. --- src/p_acs.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 405d60320..c5ea7031d 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4367,6 +4367,7 @@ enum EACSFunctions ACSF_ChangeActorAngle, ACSF_ChangeActorPitch, // 80 ACSF_GetArmorInfo, + ACSF_DropInventory, /* Zandronum's - these must be skipped when we reach 99! -100:ResetMap(0), @@ -5491,6 +5492,42 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) break; } + case ACSF_DropInventory: + { + const char *type = FBehavior::StaticLookupString(args[1]); + AInventory *inv; + + if (type != NULL) + { + if (args[0] == 0) + { + if (activator != NULL) + { + inv = activator->FindInventory(type); + if (inv) + { + activator->DropInventory(inv); + } + } + } + else + { + FActorIterator it(args[0]); + AActor *actor; + + while ((actor = it.Next()) != NULL) + { + inv = actor->FindInventory(type); + if (inv) + { + actor->DropInventory(inv); + } + } + } + } + break; + } + case ACSF_CheckFlag: { AActor *actor = SingleActorFromTID(args[0], activator); From 44683657f22e29330f302cd80f82e71e7012e617 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sat, 20 Sep 2014 17:34:57 -0500 Subject: [PATCH 10/13] - Added jpalomo's A_SetSpeed patch. --- src/thingdef/thingdef_codeptr.cpp | 14 ++++++++++++++ src/thingdef/thingdef_expression.cpp | 1 + wadsrc/static/actors/actor.txt | 2 ++ 3 files changed, 17 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index f25a0818e..f80e89aad 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4980,3 +4980,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropItem) P_DropItem(self, spawntype, amount, chance); } + +//========================================================================== +// +// A_SetSpeed +// +//========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpeed) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_FIXED(speed, 0); + + self->Speed = speed; +} diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index c578ddb2b..7dbf5ec36 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -88,6 +88,7 @@ DEFINE_MEMBER_VARIABLE(height, AActor) DEFINE_MEMBER_VARIABLE(radius, AActor) DEFINE_MEMBER_VARIABLE(reactiontime, AActor) DEFINE_MEMBER_VARIABLE(meleerange, AActor) +DEFINE_MEMBER_VARIABLE(Speed, AActor) //========================================================================== diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 501933f04..e66226c1e 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -62,6 +62,7 @@ ACTOR Actor native //: Thinker native fixed_t radius; native int reactiontime; native fixed_t meleerange; + native fixed_t speed; // Meh, MBF redundant functions. Only for DeHackEd support. action native A_Turn(float angle = 0); @@ -302,6 +303,7 @@ ACTOR Actor native //: Thinker action native A_SetTics(int tics); action native A_SetDamageType(name damagetype); action native A_DropItem(class item, int dropamount = -1, int chance = 256); + action native A_SetSpeed(float speed); action native A_CheckSightOrRange(float distance, state label); action native A_CheckRange(float distance, state label); From cbf72fe9922e221ab441f7579c229382af72ab27 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 08:32:39 +0200 Subject: [PATCH 11/13] - fixed: Since the serializing code cannot distinguish between user variables of the same name coming from different actors in an inheritance chain, this kind of name duplication must be prohibited. --- src/thingdef/thingdef_parse.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 498003b4e..88e6084b6 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -374,6 +374,8 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClass *cls) FScriptPosition::ErrorCounter++; } + + FName symname = sc.String; if (sc.CheckToken('[')) { @@ -391,6 +393,15 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClass *cls) } sc.MustGetToken(';'); + // We must ensure that we do not define duplicates, even when they come from a parent table. + if (symt->FindSymbol(symname, true) != NULL) + { + sc.ScriptMessage ("'%s' is already defined in '%s' or one of its ancestors.", + symname.GetChars(), cls ? cls->TypeName.GetChars() : "Global"); + FScriptPosition::ErrorCounter++; + return; + } + PSymbolVariable *sym = new PSymbolVariable(symname); sym->offset = cls->Extend(sizeof(int) * (valuetype.Type == VAL_Array ? valuetype.size : 1)); sym->ValueType = valuetype; From f92cdb0ce799901e54795dbc70fe383f62b2ad27 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Sep 2014 09:11:33 +0200 Subject: [PATCH 12/13] - fixed: When the SectorAction's TriggerAction method was renamed, the inherited one in the MusicChanger was overlooked. (Bit thanks to the C++ specs for allowing to override a non-virtual method with a virtual one without even showing a warning...) --- src/s_advsound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 5b2e4e7c1..f7a40da9b 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -2347,14 +2347,14 @@ class AMusicChanger : public ASectorAction { DECLARE_CLASS (AMusicChanger, ASectorAction) public: - virtual bool TriggerAction (AActor *triggerer, int activationType); + virtual bool DoTriggerAction (AActor *triggerer, int activationType); virtual void Tick(); virtual void PostBeginPlay(); }; IMPLEMENT_CLASS(AMusicChanger) -bool AMusicChanger::TriggerAction (AActor *triggerer, int activationType) +bool AMusicChanger::DoTriggerAction (AActor *triggerer, int activationType) { if (activationType & SECSPAC_Enter) { @@ -2364,7 +2364,7 @@ bool AMusicChanger::TriggerAction (AActor *triggerer, int activationType) reactiontime = 30; } } - return Super::TriggerAction (triggerer, activationType); + return Super::DoTriggerAction (triggerer, activationType); } void AMusicChanger::Tick() From 313b2293193a7ba1d55cd85ffe52797f0e07d093 Mon Sep 17 00:00:00 2001 From: GitExl Date: Sun, 21 Sep 2014 16:43:17 +0200 Subject: [PATCH 13/13] Add PickActor ACS function. --- src/p_acs.cpp | 33 +++++++++++++++++++++++++++++++++ src/p_local.h | 1 + src/p_map.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index c5ea7031d..fd41d6e51 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4368,6 +4368,7 @@ enum EACSFunctions ACSF_ChangeActorPitch, // 80 ACSF_GetArmorInfo, ACSF_DropInventory, + ACSF_PickActor, /* Zandronum's - these must be skipped when we reach 99! -100:ResetMap(0), @@ -5593,6 +5594,38 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) } break; + case ACSF_PickActor: + if (argCount >= 5) + { + actor = SingleActorFromTID(args[0], activator); + if (actor == NULL) + { + return 0; + } + + DWORD actorMask = MF_SHOOTABLE; + if (argCount >= 6) { + actorMask = args[5]; + } + + DWORD wallMask = ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN; + if (argCount >= 7) { + wallMask = args[6]; + } + + AActor* pickedActor = P_LinePickActor(actor, args[1] << 16, args[3], args[2] << 16, actorMask, wallMask); + if (pickedActor == NULL) { + return 0; + } + + pickedActor->RemoveFromHash(); + pickedActor->tid = args[4]; + pickedActor->AddToHash(); + + return 1; + } + break; + default: break; } diff --git a/src/p_local.h b/src/p_local.h index 58d9d02e5..939018734 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -462,6 +462,7 @@ enum // P_LineAttack flags AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, int flags = 0, AActor **victim = NULL, int *actualdamage = NULL); AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, int flags = 0, AActor **victim = NULL, int *actualdamage = NULL); +AActor *P_LinePickActor (AActor *t1, angle_t angle, fixed_t distance, int pitch, DWORD actorMask, DWORD wallMask); void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version diff --git a/src/p_map.cpp b/src/p_map.cpp index 4ea8762ec..2274e7571 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3783,6 +3783,52 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, return NULL; } +//========================================================================== +// +// P_LinePickActor +// +//========================================================================== + +AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, + DWORD actorMask, DWORD wallMask) +{ + fixed_t vx, vy, vz, shootz; + + angle >>= ANGLETOFINESHIFT; + pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT; + + vx = FixedMul(finecosine[pitch], finecosine[angle]); + vy = FixedMul(finecosine[pitch], finesine[angle]); + vz = -finesine[pitch]; + + shootz = t1->z - t1->floorclip + (t1->height >> 1); + if (t1->player != NULL) + { + shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); + } + else + { + shootz += 8 * FRACUNIT; + } + + FTraceResults trace; + Origin TData; + + TData.Caller = t1; + TData.hitGhosts = true; + + if (Trace(t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance, + actorMask, wallMask, t1, trace, TRACE_NoSky, CheckForActor, &TData)) + { + if (trace.HitType == TRACE_HitActor) + { + return trace.Actor; + } + } + + return NULL; +} + //========================================================================== // //