diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3baba1c4b..f0a0d20eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1208,9 +1208,7 @@ set (PCH_SOURCES g_inventory/a_weapons.cpp g_strife/strife_sbar.cpp g_shared/a_action.cpp - g_shared/a_bridge.cpp g_shared/a_decals.cpp - g_shared/a_fastprojectile.cpp g_shared/a_flashfader.cpp g_shared/a_fountain.cpp g_shared/a_lightning.cpp diff --git a/src/actor.h b/src/actor.h index d4f5f27c5..562984577 100644 --- a/src/actor.h +++ b/src/actor.h @@ -44,7 +44,6 @@ #include "portal.h" struct subsector_t; -class PClassAmmo; struct FBlockNode; struct FPortalGroupArray; @@ -596,7 +595,7 @@ public: AActor &operator= (const AActor &other); ~AActor (); - virtual void Destroy() override; + virtual void OnDestroy() override; virtual void Serialize(FSerializer &arc) override; virtual void PostSerialize() override; virtual void PostBeginPlay() override; // Called immediately before the actor's first tick @@ -733,7 +732,7 @@ public: AInventory *FirstInv (); // Tries to give the actor some ammo. - bool GiveAmmo (PClassAmmo *type, int amount); + bool GiveAmmo (PClassInventory *type, int amount); // Destroys all the inventory the actor is holding. void DestroyAllInventory (); diff --git a/src/b_bot.h b/src/b_bot.h index 5dfbb7e63..58a9b7640 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -110,8 +110,8 @@ public: bool IsDangerous (sector_t *sec); TArray getspawned; //Array of bots (their names) which should be spawned when starting a game. - BYTE freeze:1; //Game in freeze mode. - BYTE changefreeze:1; //Game wants to change freeze mode. + BYTE freeze; //Game in freeze mode. + BYTE changefreeze; //Game wants to change freeze mode. int botnum; botinfo_t *botinfo; int spawn_tries; diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index f4663f4bf..41b89f7c4 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -147,7 +147,7 @@ struct StyleName static TArray StyleNames; -static TArray AmmoNames; +static TArray AmmoNames; static TArray WeaponNames; // DeHackEd trickery to support MBF-style parameters @@ -1535,7 +1535,7 @@ static int PatchSprite (int sprNum) static int PatchAmmo (int ammoNum) { - PClassAmmo *ammoType = NULL; + PClassActor *ammoType = NULL; AAmmo *defaultAmmo = NULL; int result; int oldclip; @@ -1670,7 +1670,7 @@ static int PatchWeapon (int weapNum) { val = 5; } - info->AmmoType1 = AmmoNames[val]; + info->AmmoType1 = (PClassInventory*)AmmoNames[val]; if (info->AmmoType1 != NULL) { info->AmmoGive1 = ((AAmmo*)GetDefaultByType (info->AmmoType1))->Amount * 2; @@ -2929,8 +2929,8 @@ static bool LoadDehSupp () } else { - PClassAmmo *cls = dyn_cast(PClass::FindClass(sc.String)); - if (cls == NULL) + auto cls = PClass::FindActor(sc.String); + if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(AAmmo))) { sc.ScriptError("Unknown ammo type '%s'", sc.String); } @@ -3199,14 +3199,14 @@ void ADehackedPickup::DoPickupSpecial (AActor *toucher) RealPickup = nullptr; } -void ADehackedPickup::Destroy () +void ADehackedPickup::OnDestroy () { if (RealPickup != nullptr) { RealPickup->Destroy (); RealPickup = nullptr; } - Super::Destroy (); + Super::OnDestroy(); } PClassActor *ADehackedPickup::DetermineType () diff --git a/src/d_dehacked.h b/src/d_dehacked.h index 434853bf2..7b21e8694 100644 --- a/src/d_dehacked.h +++ b/src/d_dehacked.h @@ -41,7 +41,7 @@ class ADehackedPickup : public AInventory DECLARE_CLASS (ADehackedPickup, AInventory) HAS_OBJECT_POINTERS public: - void Destroy() override; + void OnDestroy() override; FString PickupMessage (); bool ShouldRespawn (); bool ShouldStay (); diff --git a/src/d_main.cpp b/src/d_main.cpp index 2c6b1c9e9..1fd89c6bf 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2715,7 +2715,6 @@ void D_DoomMain (void) *(afunc->VMPointer) = NULL; } - ReleaseGlobalSymbols(); PClass::StaticShutdown(); GC::FullGC(); // perform one final garbage collection after shutdown @@ -2727,6 +2726,7 @@ void D_DoomMain (void) restart++; PClass::bShutdown = false; + PClass::bShuttingDown = false; } while (1); } diff --git a/src/d_player.h b/src/d_player.h index 81a1c43a6..16bcb1805 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -120,9 +120,9 @@ public: void TweakSpeeds (double &forwardmove, double &sidemove); void MorphPlayerThink (); void ActivateMorphWeapon (); - AWeapon *PickNewWeapon (PClassAmmo *ammotype); - AWeapon *BestWeapon (PClassAmmo *ammotype); - void CheckWeaponSwitch(PClassAmmo *ammotype); + AWeapon *PickNewWeapon (PClassInventory *ammotype); + AWeapon *BestWeapon (PClassInventory *ammotype); + void CheckWeaponSwitch(PClassInventory *ammotype); void GiveDeathmatchInventory (); void FilterCoopRespawnInventory (APlayerPawn *oldplayer); diff --git a/src/dobject.cpp b/src/dobject.cpp index b96cc5ff9..ead9848be 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -351,8 +351,18 @@ DObject::~DObject () // //========================================================================== -void DObject::Destroy () +void DObject:: Destroy () { + // We cannot call the VM during shutdown because all the needed data has been or is in the process of being deleted. + if (!PClass::bShuttingDown) + { + IFVIRTUAL(DObject, OnDestroy) + { + VMValue params[1] = { (DObject*)this }; + GlobalVMStack.Call(func, params, 1, nullptr, 0); + } + } + OnDestroy(); ObjectFlags = (ObjectFlags & ~OF_Fixed) | OF_EuthanizeMe; } @@ -555,4 +565,4 @@ DEFINE_ACTION_FUNCTION(DObject, GetClassName) { PARAM_SELF_PROLOGUE(DObject); ACTION_RETURN_INT(self->GetClass()->TypeName); -} \ No newline at end of file +} diff --git a/src/dobject.h b/src/dobject.h index ed9c0fffa..0f99361ef 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -94,15 +94,12 @@ enum CLASSREG_PClass, CLASSREG_PClassActor, CLASSREG_PClassInventory, - CLASSREG_PClassAmmo, CLASSREG_PClassHealth, CLASSREG_PClassPuzzleItem, CLASSREG_PClassWeapon, CLASSREG_PClassPlayerPawn, CLASSREG_PClassType, CLASSREG_PClassClass, - CLASSREG_PClassWeaponPiece, - CLASSREG_PClassPowerupGiver }; struct ClassReg @@ -476,7 +473,8 @@ public: // that don't call their base class. void CheckIfSerialized () const; - virtual void Destroy(); + virtual void OnDestroy() {} + void Destroy(); // If you need to replace one object with another and want to // change any pointers from the old object to the new object, diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 3abdd5800..cc5dfdb4e 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -72,6 +72,7 @@ FTypeTable TypeTable; PSymbolTable GlobalSymbols; TArray PClass::AllClasses; bool PClass::bShutdown; +bool PClass::bShuttingDown; PErrorType *TypeError; PErrorType *TypeAuto; @@ -534,16 +535,9 @@ const char *PType::DescriptiveName() const // //========================================================================== -void ReleaseGlobalSymbols() -{ - TypeTable.Clear(); - GlobalSymbols.ReleaseSymbols(); -} - void PType::StaticInit() { // Add types to the global symbol table. - atterm(ReleaseGlobalSymbols); // Set up TypeTable hash keys. RUNTIME_CLASS(PErrorType)->TypeTableType = RUNTIME_CLASS(PErrorType); @@ -2962,7 +2956,18 @@ void PClass::StaticShutdown () TArray uniqueFPs(64); unsigned int i, j; - FS_Close(); // this must be done before the classes get deleted. + + // Make a full garbage collection here so that all destroyed but uncollected higher level objects that still exist can be properly taken down. + GC::FullGC(); + + // From this point onward no scripts may be called anymore because the data needed by the VM is getting deleted now. + // This flags DObject::Destroy not to call any scripted OnDestroy methods anymore. + bShuttingDown = true; + + // Unless something went wrong, anything left here should be class and type objects only, which do not own any scripts. + TypeTable.Clear(); + GlobalSymbols.ReleaseSymbols(); + for (i = 0; i < PClass::AllClasses.Size(); ++i) { PClass *type = PClass::AllClasses[i]; @@ -2989,7 +2994,6 @@ void PClass::StaticShutdown () { delete[] uniqueFPs[i]; } - TypeTable.Clear(); bShutdown = true; AllClasses.Clear(); @@ -3002,7 +3006,7 @@ void PClass::StaticShutdown () auto cr = ((ClassReg *)*probe); cr->MyClass = nullptr; } - + } //========================================================================== @@ -3090,7 +3094,6 @@ PClass *ClassReg::RegisterClass() &PClass::RegistrationInfo, &PClassActor::RegistrationInfo, &PClassInventory::RegistrationInfo, - &PClassAmmo::RegistrationInfo, &PClassHealth::RegistrationInfo, &PClassPuzzleItem::RegistrationInfo, &PClassWeapon::RegistrationInfo, diff --git a/src/dobjtype.h b/src/dobjtype.h index 952f4d627..3035a6eb2 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -883,6 +883,7 @@ public: static TArray AllClasses; static bool bShutdown; + static bool bShuttingDown; }; class PClassType : public PClass @@ -1015,8 +1016,6 @@ public: PSymbolConstString() {} }; -void ReleaseGlobalSymbols(); - // Enumerations for serializing types in an archive ------------------------- enum ETypeVal : BYTE diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp index e934c5b9d..22acf74bc 100644 --- a/src/dsectoreffect.cpp +++ b/src/dsectoreffect.cpp @@ -39,7 +39,7 @@ DSectorEffect::DSectorEffect () m_Sector = NULL; } -void DSectorEffect::Destroy() +void DSectorEffect::OnDestroy() { if (m_Sector) { @@ -56,7 +56,7 @@ void DSectorEffect::Destroy() m_Sector->lightingdata = NULL; } } - Super::Destroy(); + Super::OnDestroy(); } DSectorEffect::DSectorEffect (sector_t *sector) @@ -87,10 +87,10 @@ DMover::DMover (sector_t *sector) interpolation = NULL; } -void DMover::Destroy() +void DMover::OnDestroy() { StopInterpolation(); - Super::Destroy(); + Super::OnDestroy(); } void DMover::Serialize(FSerializer &arc) diff --git a/src/dsectoreffect.h b/src/dsectoreffect.h index e9327ce70..5139aaabd 100644 --- a/src/dsectoreffect.h +++ b/src/dsectoreffect.h @@ -12,7 +12,7 @@ public: void Serialize(FSerializer &arc); - void Destroy() override; + void OnDestroy() override; sector_t *GetSector() const { return m_Sector; } @@ -35,7 +35,7 @@ protected: DMover (); void Serialize(FSerializer &arc); - void Destroy() override; + void OnDestroy() override; }; class DMovingFloor : public DMover diff --git a/src/dthinker.cpp b/src/dthinker.cpp index 11ba54dbc..ac0abf3c5 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -253,7 +253,7 @@ DThinker::~DThinker () assert(NextThinker == NULL && PrevThinker == NULL); } -void DThinker::Destroy () +void DThinker::OnDestroy () { assert((NextThinker != NULL && PrevThinker != NULL) || (NextThinker == NULL && PrevThinker == NULL)); @@ -261,7 +261,7 @@ void DThinker::Destroy () { Remove(); } - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== diff --git a/src/dthinker.h b/src/dthinker.h index 3d580c3c2..fce3e4f7a 100644 --- a/src/dthinker.h +++ b/src/dthinker.h @@ -66,7 +66,7 @@ class DThinker : public DObject DECLARE_CLASS (DThinker, DObject) public: DThinker (int statnum = STAT_DEFAULT) throw(); - void Destroy () override; + void OnDestroy () override; virtual ~DThinker (); virtual void Tick (); void CallTick(); diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 514d9aaea..ce46daeb3 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -341,7 +341,7 @@ inline int T_FindFirstSectorFromTag(int tagnum) // Doom index is only supported for the 4 original ammo types // //========================================================================== -static PClassAmmo * T_GetAmmo(const svalue_t &t) +static PClassInventory * T_GetAmmo(const svalue_t &t) { const char * p; @@ -362,7 +362,7 @@ static PClassAmmo * T_GetAmmo(const svalue_t &t) } p=DefAmmo[ammonum]; } - PClassAmmo * am=dyn_cast(PClass::FindActor(p)); + PClassInventory * am=dyn_cast(PClass::FindActor(p)); if (am == NULL) { script_error("unknown ammo type : %s", p); @@ -1786,7 +1786,7 @@ public: DLightLevel(sector_t * s,int destlevel,int speed); void Serialize(FSerializer &arc); void Tick (); - void Destroy() { Super::Destroy(); m_Sector->lightingdata=NULL; } + void OnDestroy() { Super::OnDestroy(); m_Sector->lightingdata = nullptr; } }; IMPLEMENT_CLASS(DLightLevel, false, false) @@ -2572,7 +2572,7 @@ void FParser::SF_PlayerKeys(void) void FParser::SF_PlayerAmmo(void) { int playernum, amount; - PClassAmmo * ammotype; + PClassInventory * ammotype; if (CheckArgs(2)) { @@ -2608,7 +2608,7 @@ void FParser::SF_PlayerAmmo(void) void FParser::SF_MaxPlayerAmmo() { int playernum, amount; - PClassAmmo * ammotype; + PClassInventory * ammotype; if (CheckArgs(2)) { diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index b5c21632b..1ff4321fa 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -184,7 +184,7 @@ DFsScript::~DFsScript() // //========================================================================== -void DFsScript::Destroy() +void DFsScript::OnDestroy() { ClearVariables(true); ClearSections(); @@ -194,7 +194,7 @@ void DFsScript::Destroy() data = NULL; parent = NULL; trigger = NULL; - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== @@ -334,7 +334,7 @@ DRunningScript::DRunningScript(AActor *trigger, DFsScript *owner, int index) // //========================================================================== -void DRunningScript::Destroy() +void DRunningScript::OnDestroy() { int i; DFsVariable *current, *next; @@ -352,7 +352,7 @@ void DRunningScript::Destroy() } variables[i] = NULL; } - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== @@ -421,7 +421,7 @@ DFraggleThinker::DFraggleThinker() // //========================================================================== -void DFraggleThinker::Destroy() +void DFraggleThinker::OnDestroy() { DRunningScript *p = RunningScripts; while (p) @@ -438,7 +438,7 @@ void DFraggleThinker::Destroy() SpawnedThings.Clear(); ActiveThinker = NULL; - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h index 43f34acd4..7a5c21a10 100644 --- a/src/fragglescript/t_script.h +++ b/src/fragglescript/t_script.h @@ -347,7 +347,7 @@ public: DFsScript(); ~DFsScript(); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &ar); DFsVariable *NewVariable(const char *name, int vtype); @@ -662,7 +662,7 @@ class DRunningScript : public DObject public: DRunningScript(AActor *trigger=NULL, DFsScript *owner = NULL, int index = 0) ; - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); TObjPtr script; @@ -697,7 +697,7 @@ public: bool nocheckposition; DFraggleThinker(); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer & arc); diff --git a/src/g_game.cpp b/src/g_game.cpp index 6565d5324..77e675b8a 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2128,8 +2128,6 @@ CUSTOM_CVAR (Int, autosavecount, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { if (self < 0) self = 0; - if (self > 20) - self = 20; } extern void P_CalcHeight (player_t *); diff --git a/src/g_inventory/a_ammo.cpp b/src/g_inventory/a_ammo.cpp index 23a922187..6ef2c64d4 100644 --- a/src/g_inventory/a_ammo.cpp +++ b/src/g_inventory/a_ammo.cpp @@ -37,22 +37,6 @@ #include "d_player.h" #include "serializer.h" -IMPLEMENT_CLASS(PClassAmmo, false, false) - -PClassAmmo::PClassAmmo() -{ - DropAmount = 0; -} - -void PClassAmmo::DeriveData(PClass *newclass) -{ - assert(newclass->IsKindOf(RUNTIME_CLASS(PClassAmmo))); - Super::DeriveData(newclass); - PClassAmmo *newc = static_cast(newclass); - - newc->DropAmount = DropAmount; -} - IMPLEMENT_CLASS(AAmmo, false, false) DEFINE_FIELD(AAmmo, BackpackAmount) diff --git a/src/g_inventory/a_ammo.h b/src/g_inventory/a_ammo.h index 643d4b924..fbe96e4bc 100644 --- a/src/g_inventory/a_ammo.h +++ b/src/g_inventory/a_ammo.h @@ -1,21 +1,9 @@ #pragma once #include "a_pickups.h" -// Ammo: Something a weapon needs to operate -class PClassAmmo : public PClassInventory -{ - DECLARE_CLASS(PClassAmmo, PClassInventory) -protected: - virtual void DeriveData(PClass *newclass); -public: - PClassAmmo(); - - int DropAmount; // Specifies the amount for a dropped ammo item. -}; - class AAmmo : public AInventory { - DECLARE_CLASS_WITH_META(AAmmo, AInventory, PClassAmmo) + DECLARE_CLASS (AAmmo, AInventory) public: virtual void Serialize(FSerializer &arc) override; @@ -24,7 +12,7 @@ public: virtual AInventory *CreateTossable () override; PClassActor *GetParentAmmo () const; - int BackpackAmount, BackpackMaxAmount; + int BackpackAmount, BackpackMaxAmount, DropAmount; }; diff --git a/src/g_inventory/a_artifacts.cpp b/src/g_inventory/a_artifacts.cpp index 26ef3e288..afe676ccf 100644 --- a/src/g_inventory/a_artifacts.cpp +++ b/src/g_inventory/a_artifacts.cpp @@ -292,10 +292,10 @@ void APowerup::CallEndEffect() // //=========================================================================== -void APowerup::Destroy () +void APowerup::OnDestroy () { CallEndEffect (); - Super::Destroy (); + Super::OnDestroy(); } //=========================================================================== diff --git a/src/g_inventory/a_artifacts.h b/src/g_inventory/a_artifacts.h index 95182ce43..6cd10f637 100644 --- a/src/g_inventory/a_artifacts.h +++ b/src/g_inventory/a_artifacts.h @@ -12,7 +12,7 @@ class APowerup : public AInventory DECLARE_CLASS (APowerup, AInventory) public: virtual void Tick () override; - virtual void Destroy () override; + virtual void OnDestroy() override; virtual bool HandlePickup (AInventory *item) override; virtual AInventory *CreateCopy (AActor *other) override; virtual AInventory *CreateTossable () override; diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index aa00ba8b0..1b26a2db4 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -1137,14 +1137,14 @@ bool AInventory::CallShouldStay() // //=========================================================================== -void AInventory::Destroy () +void AInventory::OnDestroy () { if (Owner != NULL) { Owner->RemoveInventory (this); } Inventory = NULL; - Super::Destroy (); + Super::OnDestroy(); // Although contrived it can theoretically happen that these variables still got a pointer to this item if (SendItemUse == this) SendItemUse = NULL; diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index eedadbdff..894849ef2 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -76,7 +76,7 @@ public: virtual void Serialize(FSerializer &arc) override; virtual void MarkPrecacheSounds() const override; virtual void BeginPlay () override; - virtual void Destroy () override; + virtual void OnDestroy() override; virtual void Tick() override; virtual bool Grind(bool items) override; @@ -182,7 +182,7 @@ private: class AStateProvider : public AInventory { - DECLARE_CLASS(AStateProvider, AInventory) + DECLARE_CLASS (AStateProvider, AInventory) }; // CustomInventory: Supports the Use, Pickup, and Drop states from 96x diff --git a/src/g_inventory/a_weaponpiece.h b/src/g_inventory/a_weaponpiece.h index a8c6a2e76..ca5ed6a06 100644 --- a/src/g_inventory/a_weaponpiece.h +++ b/src/g_inventory/a_weaponpiece.h @@ -4,7 +4,7 @@ class AWeaponPiece : public AInventory { - DECLARE_CLASS(AWeaponPiece, AInventory) + DECLARE_CLASS (AWeaponPiece, AInventory) HAS_OBJECT_POINTERS protected: bool PrivateShouldStay (); @@ -26,7 +26,7 @@ public: // [BL] Needs to be available for SBarInfo to check weaponpieces class AWeaponHolder : public AInventory { - DECLARE_CLASS(AWeaponHolder, AInventory) + DECLARE_CLASS (AWeaponHolder, AInventory) public: int PieceMask; diff --git a/src/g_inventory/a_weapons.cpp b/src/g_inventory/a_weapons.cpp index 3b3b765d6..750aad952 100644 --- a/src/g_inventory/a_weapons.cpp +++ b/src/g_inventory/a_weapons.cpp @@ -329,7 +329,7 @@ bool AWeapon::Use (bool pickup) // //=========================================================================== -void AWeapon::Destroy() +void AWeapon::OnDestroy() { AWeapon *sister = SisterWeapon; @@ -342,7 +342,7 @@ void AWeapon::Destroy() sister->Destroy(); } } - Super::Destroy(); + Super::OnDestroy(); } //=========================================================================== diff --git a/src/g_inventory/a_weapons.h b/src/g_inventory/a_weapons.h index 1b1258401..564c0df02 100644 --- a/src/g_inventory/a_weapons.h +++ b/src/g_inventory/a_weapons.h @@ -107,7 +107,7 @@ class AWeapon : public AStateProvider HAS_OBJECT_POINTERS public: DWORD WeaponFlags; - PClassAmmo *AmmoType1, *AmmoType2; // Types of ammo used by this weapon + PClassInventory *AmmoType1, *AmmoType2; // Types of ammo used by this weapon int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon int AmmoUse1, AmmoUse2; // How much ammo to use with each shot @@ -145,7 +145,7 @@ public: virtual bool TryPickup (AActor *&toucher) override; virtual bool TryPickupRestricted (AActor *&toucher) override; virtual bool Use (bool pickup) override; - virtual void Destroy() override; + virtual void OnDestroy() override; bool PickupForAmmo(AWeapon *ownedWeapon); void PostMorphWeapon(); @@ -221,7 +221,7 @@ enum class AWeaponGiver : public AWeapon { - DECLARE_CLASS(AWeaponGiver, AWeapon) + DECLARE_CLASS (AWeaponGiver, AWeapon) public: virtual bool TryPickup(AActor *&toucher) override; diff --git a/src/g_level.h b/src/g_level.h index 6274c22b0..1fadcee3a 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -148,7 +148,7 @@ enum ELevelFlags : unsigned int LEVEL_MONSTERSTELEFRAG = 0x00000400, LEVEL_ACTOWNSPECIAL = 0x00000800, LEVEL_SNDSEQTOTALCTRL = 0x00001000, - LEVEL_FORCENOSKYSTRETCH = 0x00002000, + LEVEL_FORCETILEDSKY = 0x00002000, LEVEL_CROUCH_NO = 0x00004000, LEVEL_JUMP_NO = 0x00008000, diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 3fab0bd0d..bb641b23b 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1228,8 +1228,8 @@ MapFlagHandlers[] = { "smoothlighting", MITYPE_SETFLAG2, LEVEL2_SMOOTHLIGHTING, 0 }, { "noautosequences", MITYPE_SETFLAG, LEVEL_SNDSEQTOTALCTRL, 0 }, { "autosequences", MITYPE_CLRFLAG, LEVEL_SNDSEQTOTALCTRL, 0 }, - { "forcenoskystretch", MITYPE_SETFLAG, LEVEL_FORCENOSKYSTRETCH, 0 }, - { "skystretch", MITYPE_CLRFLAG, LEVEL_FORCENOSKYSTRETCH, 0 }, + { "forcenoskystretch", MITYPE_SETFLAG, LEVEL_FORCETILEDSKY, 0 }, + { "skystretch", MITYPE_CLRFLAG, LEVEL_FORCETILEDSKY, 0 }, { "allowfreelook", MITYPE_SCFLAGS, LEVEL_FREELOOK_YES, ~LEVEL_FREELOOK_NO }, { "nofreelook", MITYPE_SCFLAGS, LEVEL_FREELOOK_NO, ~LEVEL_FREELOOK_YES }, { "allowjump", MITYPE_CLRFLAG, LEVEL_JUMP_NO, 0 }, diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 187b215b8..ca92e731f 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -219,7 +219,7 @@ class DCorpsePointer : public DThinker HAS_OBJECT_POINTERS public: DCorpsePointer (AActor *ptr); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); TObjPtr Corpse; DWORD Count; // Only the first corpse pointer's count is valid. @@ -271,7 +271,7 @@ DCorpsePointer::DCorpsePointer (AActor *ptr) ++first->Count; } -void DCorpsePointer::Destroy () +void DCorpsePointer::OnDestroy () { // Store the count of corpses in the first thinker in the list TThinkerIterator iterator (STAT_CORPSEPOINTER); @@ -293,7 +293,7 @@ void DCorpsePointer::Destroy () { Corpse->Destroy (); } - Super::Destroy (); + Super::OnDestroy(); } void DCorpsePointer::Serialize(FSerializer &arc) diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp deleted file mode 100644 index cb6657796..000000000 --- a/src/g_shared/a_bridge.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include "actor.h" -#include "info.h" -#include "gi.h" -#include "m_random.h" - -static FRandom pr_orbit ("Orbit"); - - -// Custom bridge -------------------------------------------------------- -/* - args[0]: Bridge radius, in mapunits - args[1]: Bridge height, in mapunits - args[2]: Amount of bridge balls (if 0: Doom bridge) - args[3]: Rotation speed of bridge balls, in byte angle per seconds, sorta: - Since an arg is only a byte, it can only go from 0 to 255, while ZDoom's - BAM go from 0 to 65535. Plus, it needs to be able to go either way. So, - up to 128, it goes counterclockwise; 129-255 is clockwise, substracting - 256 from it to get the angle. A few example values: - 0: Hexen default - 11: 15° / seconds - 21: 30° / seconds - 32: 45° / seconds - 64: 90° / seconds - 128: 180° / seconds - 192: -90° / seconds - 223: -45° / seconds - 233: -30° / seconds - 244: -15° / seconds - This value only matters if args[2] is not zero. - args[4]: Rotation radius of bridge balls, in bridge radius %. - If 0, use Hexen default: ORBIT_RADIUS, regardless of bridge radius. - This value only matters if args[2] is not zero. -*/ - -class ACustomBridge : public AActor -{ - DECLARE_CLASS (ACustomBridge, AActor) -public: - void BeginPlay (); - void Destroy() override; -}; - -IMPLEMENT_CLASS(ACustomBridge, false, false) - -void ACustomBridge::BeginPlay () -{ - if (args[2]) // Hexen bridge if there are balls - { - SetState(SeeState); - radius = args[0] ? args[0] : 32; - Height = args[1] ? args[1] : 2; - } - else // No balls? Then a Doom bridge. - { - radius = args[0] ? args[0] : 36; - Height = args[1] ? args[1] : 4; - RenderStyle = STYLE_Normal; - } -} - -void ACustomBridge::Destroy() -{ - // Hexen originally just set a flag to make the bridge balls remove themselves in A_BridgeOrbit. - // But this is not safe with custom bridge balls that do not necessarily call that function. - // So the best course of action is to look for all bridge balls here and destroy them ourselves. - - TThinkerIterator it; - AActor *thing; - - while ((thing = it.Next())) - { - if (thing->target == this) - { - thing->Destroy(); - } - } - Super::Destroy(); -} - -// Action functions for the non-Doom bridge -------------------------------- - -#define ORBIT_RADIUS 15 - -// New bridge stuff -// Parent -// special1 true == removing from world -// -// Child -// target pointer to center mobj -// angle angle of ball - -static void BridgeOrbit(AActor *self) -{ - if (self->target == NULL) - { // Don't crash if somebody spawned this into the world - // independantly of a Bridge actor. - return; - } - // Set default values - // Every five tics, Hexen moved the ball 3/256th of a revolution. - DAngle rotationspeed = 45. / 32 * 3 / 5; - double rotationradius = ORBIT_RADIUS; - // If the bridge is custom, set non-default values if any. - - // Set angular speed; 1--128: counterclockwise rotation ~=1--180°; 129--255: clockwise rotation ~= 180--1° - if (self->target->args[3] > 128) rotationspeed = 45. / 32 * (self->target->args[3] - 256) / TICRATE; - else if (self->target->args[3] > 0) rotationspeed = 45. / 32 * (self->target->args[3]) / TICRATE; - // Set rotation radius - if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / 100); - - self->Angles.Yaw += rotationspeed; - self->SetOrigin(self->target->Vec3Angle(rotationradius, self->Angles.Yaw, 0), true); - self->floorz = self->target->floorz; - self->ceilingz = self->target->ceilingz; -} - -DEFINE_ACTION_FUNCTION(ABridgeBall, A_BridgeOrbit) -{ - PARAM_SELF_PROLOGUE(AActor); - BridgeOrbit(self); - return 0; -} - - -DEFINE_ACTION_FUNCTION(ACustomBridge, A_BridgeInit) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_CLASS_DEF(balltype, AActor); - - AActor *ball; - - if (balltype == NULL) - { - balltype = PClass::FindActor("BridgeBall"); - } - - DAngle startangle = pr_orbit() * (360./256.); - - // Spawn triad into world -- may be more than a triad now. - int ballcount = self->args[2]==0 ? 3 : self->args[2]; - - for (int i = 0; i < ballcount; i++) - { - ball = Spawn(balltype, self->Pos(), ALLOW_REPLACE); - ball->Angles.Yaw = startangle + (45./32) * (256/ballcount) * i; - ball->target = self; - BridgeOrbit(ball); - } - return 0; -} - - -// Invisible bridge -------------------------------------------------------- - -class AInvisibleBridge : public AActor -{ - DECLARE_CLASS (AInvisibleBridge, AActor) -public: - void BeginPlay (); -}; - -IMPLEMENT_CLASS(AInvisibleBridge, false, false) - -void AInvisibleBridge::BeginPlay () -{ - Super::BeginPlay (); - if (args[0]) - radius = args[0]; - if (args[1]) - Height = args[1]; -} - diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 5ac3cb452..dfa66795c 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -111,10 +111,10 @@ DBaseDecal::DBaseDecal (const DBaseDecal *basis) { } -void DBaseDecal::Destroy () +void DBaseDecal::OnDestroy () { Remove (); - Super::Destroy (); + Super::OnDestroy(); } void DBaseDecal::Remove () @@ -670,10 +670,10 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl return decal; } -void DImpactDecal::Destroy () +void DImpactDecal::OnDestroy () { ImpactCount--; - Super::Destroy (); + Super::OnDestroy(); } CCMD (countdecals) diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp deleted file mode 100644 index 3bfaf8d94..000000000 --- a/src/g_shared/a_fastprojectile.cpp +++ /dev/null @@ -1,164 +0,0 @@ - -#include "a_sharedglobal.h" -#include "p_local.h" -#include "g_level.h" -#include "r_sky.h" -#include "p_lnspec.h" -#include "b_bot.h" -#include "p_checkposition.h" -#include "virtual.h" -#include "g_levellocals.h" - -IMPLEMENT_CLASS(AFastProjectile, false, false) - - -//---------------------------------------------------------------------------- -// -// AFastProjectile :: Tick -// -// Thinker for the ultra-fast projectiles used by Heretic and Hexen -// -//---------------------------------------------------------------------------- - -void AFastProjectile::Tick () -{ - int i; - DVector3 frac; - int changexy; - - ClearInterpolation(); - double oldz = Z(); - - if (!(flags5 & MF5_NOTIMEFREEZE)) - { - //Added by MC: Freeze mode. - if (bglobal.freeze || level.flags2 & LEVEL2_FROZEN) - { - return; - } - } - - - // [RH] Ripping is a little different than it was in Hexen - FCheckPosition tm(!!(flags2 & MF2_RIP)); - - int count = 8; - if (radius > 0) - { - while ( fabs(Vel.X) > radius * count || fabs(Vel.Y) > radius * count) - { - // we need to take smaller steps. - count += count; - } - } - - // Handle movement - if (!Vel.isZero() || (Z() != floorz)) - { - // force some lateral movement so that collision detection works as intended. - if ((flags & MF_MISSILE) && Vel.X == 0 && Vel.Y == 0 && !IsZeroDamage()) - { - Vel.X = MinVel; - } - - frac = Vel / count; - changexy = frac.X != 0 || frac.Y != 0; - int ripcount = count / 8; - for (i = 0; i < count; i++) - { - if (changexy) - { - if (--ripcount <= 0) - { - tm.LastRipped.Clear(); // [RH] Do rip damage each step, like Hexen - } - - if (!P_TryMove (this, Pos() + frac, true, NULL, tm)) - { // Blocked move - if (!(flags3 & MF3_SKYEXPLODE)) - { - if (tm.ceilingline && - tm.ceilingline->backsector && - tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))) - { - // Hack to prevent missiles exploding against the sky. - // Does not handle sky floors. - Destroy (); - return; - } - // [RH] Don't explode on horizon lines. - if (BlockingLine != NULL && BlockingLine->special == Line_Horizon) - { - Destroy (); - return; - } - } - - P_ExplodeMissile (this, BlockingLine, BlockingMobj); - return; - } - } - AddZ(frac.Z); - UpdateWaterLevel (); - oldz = Z(); - if (oldz <= floorz) - { // Hit the floor - - if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) - { - // [RH] Just remove the missile without exploding it - // if this is a sky floor. - Destroy (); - return; - } - - SetZ(floorz); - P_HitFloor (this); - P_ExplodeMissile (this, NULL, NULL); - return; - } - if (Top() > ceilingz) - { // Hit the ceiling - - if (ceilingpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) - { - Destroy (); - return; - } - - SetZ(ceilingz - Height); - P_ExplodeMissile (this, NULL, NULL); - return; - } - if (!frac.isZero() && ripcount <= 0) - { - ripcount = count >> 3; - - // call the scripted 'Effect' method. - IFVIRTUAL(AFastProjectile, Effect) - { - // Without the type cast this picks the 'void *' assignment... - VMValue params[1] = { (DObject*)this }; - GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr); - } - } - } - } - if (!CheckNoDelay()) - return; // freed itself - // Advance the state - if (tics != -1) - { - if (tics > 0) tics--; - while (!tics) - { - if (!SetState (state->GetNextState ())) - { // mobj was removed - return; - } - } - } -} - - diff --git a/src/g_shared/a_flashfader.cpp b/src/g_shared/a_flashfader.cpp index 006b7ef84..504eb7308 100644 --- a/src/g_shared/a_flashfader.cpp +++ b/src/g_shared/a_flashfader.cpp @@ -23,10 +23,10 @@ DFlashFader::DFlashFader (float r1, float g1, float b1, float a1, Blends[1][0]=r2; Blends[1][1]=g2; Blends[1][2]=b2; Blends[1][3]=a2; } -void DFlashFader::Destroy () +void DFlashFader::OnDestroy () { SetBlend (1.f); - Super::Destroy(); + Super::OnDestroy(); } void DFlashFader::Serialize(FSerializer &arc) diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index b48a126cd..0ca8e3945 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -690,13 +690,13 @@ void AMorphedMonster::Serialize(FSerializer &arc) ("flagsave", FlagsSave); } -void AMorphedMonster::Destroy () +void AMorphedMonster::OnDestroy () { if (UnmorphedMe != NULL) { UnmorphedMe->Destroy (); } - Super::Destroy (); + Super::OnDestroy(); } void AMorphedMonster::Die (AActor *source, AActor *inflictor, int dmgflags) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 96a932d4f..6835cefeb 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -124,7 +124,7 @@ void DEarthquake::Tick () { if (pr_quake() < 50) { - P_DamageMobj (victim, NULL, NULL, pr_quake.HitDice (1), NAME_None); + P_DamageMobj (victim, NULL, NULL, pr_quake.HitDice (1), NAME_Quake); } // Thrust player around DAngle an = victim->Angles.Yaw + pr_quake(); diff --git a/src/g_shared/a_sectoraction.cpp b/src/g_shared/a_sectoraction.cpp index 2d7037551..6cc285afa 100644 --- a/src/g_shared/a_sectoraction.cpp +++ b/src/g_shared/a_sectoraction.cpp @@ -39,15 +39,12 @@ IMPLEMENT_CLASS(ASectorAction, false, false) -ASectorAction::ASectorAction (bool activatedByUse) : - ActivatedByUse (activatedByUse) {} - bool ASectorAction::IsActivatedByUse() const { - return ActivatedByUse; + return !!(health & (SECSPAC_Use|SECSPAC_UseWall)); } -void ASectorAction::Destroy () +void ASectorAction::OnDestroy () { if (Sector != nullptr) { @@ -72,7 +69,7 @@ void ASectorAction::Destroy () Sector = nullptr; } - Super::Destroy (); + Super::OnDestroy(); } void ASectorAction::BeginPlay () @@ -94,24 +91,9 @@ void ASectorAction::Deactivate (AActor *source) flags2 |= MF2_DORMANT; // Projectiles can trigger } -bool ASectorAction::TriggerAction(AActor *triggerer, int activationType) -{ - if (DoTriggerAction(triggerer, activationType)) - { - if (flags4 & MF4_STANDSTILL) - { - Destroy(); - } - } - return false; -} - bool ASectorAction::DoTriggerAction (AActor *triggerer, int activationType) { - if (tracer != NULL) - return barrier_cast(tracer)->DoTriggerAction (triggerer, activationType); - else - return false; + return (activationType & health) ? CheckTrigger(triggerer) : false; } bool ASectorAction::CanTrigger (AActor *triggerer) const @@ -133,205 +115,3 @@ bool ASectorAction::CheckTrigger (AActor *triggerer) const return false; } -// Triggered when entering sector ------------------------------------------- - -class ASecActEnter : public ASectorAction -{ - DECLARE_CLASS (ASecActEnter, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActEnter, false, false) - - -bool ASecActEnter::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_Enter) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when leaving sector -------------------------------------------- - -class ASecActExit : public ASectorAction -{ - DECLARE_CLASS (ASecActExit, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActExit, false, false) - - -bool ASecActExit::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_Exit) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when hitting sector's floor ------------------------------------ - -class ASecActHitFloor : public ASectorAction -{ - DECLARE_CLASS (ASecActHitFloor, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -// Skull Tag uses 9999 for a special that is triggered whenever -// the player is on the sector's floor. I think this is more useful. - -IMPLEMENT_CLASS(ASecActHitFloor, false, false) - - -bool ASecActHitFloor::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_HitFloor) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when hitting sector's ceiling ---------------------------------- - -class ASecActHitCeil : public ASectorAction -{ - DECLARE_CLASS (ASecActHitCeil, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActHitCeil, false, false) - - -bool ASecActHitCeil::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_HitCeiling) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when using inside sector --------------------------------------- - -class ASecActUse : public ASectorAction -{ - DECLARE_CLASS (ASecActUse, ASectorAction) -public: - ASecActUse() : ASectorAction (true) {} - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActUse, false, false) - - -bool ASecActUse::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_Use) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when using a sector's wall ------------------------------------- - -class ASecActUseWall : public ASectorAction -{ - DECLARE_CLASS (ASecActUseWall, ASectorAction) -public: - ASecActUseWall() : ASectorAction (true) {} - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActUseWall, false, false) - - -bool ASecActUseWall::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_UseWall) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when eyes go below fake floor ---------------------------------- - -class ASecActEyesDive : public ASectorAction -{ - DECLARE_CLASS (ASecActEyesDive, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActEyesDive, false, false) - - -bool ASecActEyesDive::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_EyesDive) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when eyes go above fake floor ---------------------------------- - -class ASecActEyesSurface : public ASectorAction -{ - DECLARE_CLASS (ASecActEyesSurface, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActEyesSurface, false, false) - - -bool ASecActEyesSurface::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_EyesSurface) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when eyes go below fake floor ---------------------------------- - -class ASecActEyesBelowC : public ASectorAction -{ - DECLARE_CLASS (ASecActEyesBelowC, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActEyesBelowC, false, false) - - -bool ASecActEyesBelowC::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_EyesBelowC) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when eyes go above fake floor ---------------------------------- - -class ASecActEyesAboveC : public ASectorAction -{ - DECLARE_CLASS (ASecActEyesAboveC, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActEyesAboveC, false, false) - - -bool ASecActEyesAboveC::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_EyesAboveC) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} - -// Triggered when eyes go below fake floor ---------------------------------- - -class ASecActHitFakeFloor : public ASectorAction -{ - DECLARE_CLASS (ASecActHitFakeFloor, ASectorAction) -public: - bool DoTriggerAction (AActor *triggerer, int activationType); -}; - -IMPLEMENT_CLASS(ASecActHitFakeFloor, false, false) - - -bool ASecActHitFakeFloor::DoTriggerAction (AActor *triggerer, int activationType) -{ - bool didit = (activationType & SECSPAC_HitFakeFloor) ? CheckTrigger (triggerer) : false; - return didit | Super::DoTriggerAction (triggerer, activationType); -} diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 001df5488..93e0c7e0e 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -24,7 +24,7 @@ public: DBaseDecal (const DBaseDecal *basis); void Serialize(FSerializer &arc); - void Destroy() override; + void OnDestroy() override; FTextureID StickToWall(side_t *wall, double x, double y, F3DFloor * ffloor); double GetRealZ (const side_t *wall) const; void SetShade (DWORD rgb); @@ -66,7 +66,7 @@ public: static DImpactDecal *StaticCreate(const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0); void BeginPlay (); - void Destroy() override; + void OnDestroy() override; protected: DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const; @@ -88,7 +88,7 @@ class ASkyViewpoint : public AActor DECLARE_CLASS (ASkyViewpoint, AActor) public: void BeginPlay (); - void Destroy() override; + void OnDestroy() override; }; // For an EE compatible linedef based definition. @@ -116,7 +116,7 @@ public: DFlashFader (float r1, float g1, float b1, float a1, float r2, float g2, float b2, float a2, float time, AActor *who); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); void Tick (); AActor *WhoFor() { return ForWho; } @@ -207,7 +207,7 @@ public: void Serialize(FSerializer &arc); void Die (AActor *source, AActor *inflictor, int dmgflags); - void Destroy() override; + void OnDestroy() override; TObjPtr UnmorphedMe; int UnmorphTime, MorphStyle; @@ -215,12 +215,4 @@ public: ActorFlags FlagsSave; }; -class AFastProjectile : public AActor -{ - DECLARE_CLASS(AFastProjectile, AActor) -public: - void Tick (); -}; - - #endif //__A_SHAREDGLOBAL_H__ diff --git a/src/g_shared/a_skies.cpp b/src/g_shared/a_skies.cpp index b2098f206..497e4014a 100644 --- a/src/g_shared/a_skies.cpp +++ b/src/g_shared/a_skies.cpp @@ -56,7 +56,7 @@ void ASkyViewpoint::BeginPlay () } } -void ASkyViewpoint::Destroy () +void ASkyViewpoint::OnDestroy () { // remove all sector references to ourselves. for (auto &s : sectorPortals) @@ -70,7 +70,7 @@ void ASkyViewpoint::Destroy () } } - Super::Destroy(); + Super::OnDestroy(); } IMPLEMENT_CLASS(ASkyCamCompat, false, false) @@ -150,30 +150,3 @@ void AStackPoint::BeginPlay () AActor::BeginPlay (); } -//--------------------------------------------------------------------------- - -class ASectorSilencer : public AActor -{ - DECLARE_CLASS (ASectorSilencer, AActor) -public: - void BeginPlay (); - void Destroy() override; -}; - -IMPLEMENT_CLASS(ASectorSilencer, false, false) - -void ASectorSilencer::BeginPlay () -{ - Super::BeginPlay (); - Sector->Flags |= SECF_SILENT; -} - -void ASectorSilencer::Destroy () -{ - if (Sector != nullptr) - { - Sector->Flags &= ~SECF_SILENT; - } - Super::Destroy (); -} - diff --git a/src/g_shared/a_soundsequence.cpp b/src/g_shared/a_soundsequence.cpp index 304017fba..1352e72de 100644 --- a/src/g_shared/a_soundsequence.cpp +++ b/src/g_shared/a_soundsequence.cpp @@ -104,7 +104,7 @@ class ASoundSequence : public AActor { DECLARE_CLASS (ASoundSequence, AActor) public: - void Destroy() override; + void OnDestroy() override; void PostBeginPlay (); void Activate (AActor *activator); void Deactivate (AActor *activator); @@ -119,10 +119,10 @@ IMPLEMENT_CLASS(ASoundSequence, false, false) // //========================================================================== -void ASoundSequence::Destroy () +void ASoundSequence::OnDestroy () { SN_StopSequence (this); - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index 335f10ace..46a9ccc41 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -220,13 +220,13 @@ DSpotState::DSpotState () // //---------------------------------------------------------------------------- -void DSpotState::Destroy () +void DSpotState::OnDestroy () { SpotLists.Clear(); SpotLists.ShrinkToFit(); SpotState = NULL; - Super::Destroy(); + Super::OnDestroy(); } //---------------------------------------------------------------------------- @@ -389,11 +389,11 @@ void ASpecialSpot::BeginPlay() // //---------------------------------------------------------------------------- -void ASpecialSpot::Destroy() +void ASpecialSpot::OnDestroy() { DSpotState *state = DSpotState::GetSpotState(false); if (state != NULL) state->RemoveSpot(this); - Super::Destroy(); + Super::OnDestroy(); } // Mace spawn spot ---------------------------------------------------------- diff --git a/src/g_shared/a_specialspot.h b/src/g_shared/a_specialspot.h index 57a643bdd..3b1e772d1 100644 --- a/src/g_shared/a_specialspot.h +++ b/src/g_shared/a_specialspot.h @@ -11,7 +11,7 @@ class ASpecialSpot : public AActor public: void BeginPlay(); - void Destroy() override; + void OnDestroy() override; }; @@ -28,7 +28,7 @@ public: DSpotState (); - void Destroy() override; + void OnDestroy() override; void Tick (); static DSpotState *GetSpotState(bool create = true); FSpotList *FindSpotList(PClassActor *type); diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index 7b7a2849a..d681eebad 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -341,7 +341,7 @@ public: }; DBaseStatusBar (int reltop, int hres=320, int vres=200); - void Destroy() override; + void OnDestroy() override; void SetScaled (bool scale, bool force=false); diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 0c9b74255..b645ac511 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -517,14 +517,14 @@ static int DrawKeys(player_t * CPlayer, int x, int y) // Drawing Ammo // //--------------------------------------------------------------------------- -static TArray orderedammos; +static TArray orderedammos; static void AddAmmoToList(AWeapon * weapdef) { for(int i=0; i<2;i++) { - PClassAmmo * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2; + PClassInventory * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2; if (ti) { AAmmo * ammodef=(AAmmo*)GetDefaultByType(ti); @@ -647,7 +647,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y) for(i=orderedammos.Size()-1;i>=0;i--) { - PClassAmmo * type = orderedammos[i]; + PClassInventory * type = orderedammos[i]; AAmmo * ammoitem = (AAmmo*)CPlayer->mo->FindInventory(type); AAmmo * inv = ammoitem? ammoitem : (AAmmo*)GetDefaultByType(orderedammos[i]); diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index cb3ada8e9..009b480b7 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -258,7 +258,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres) // //--------------------------------------------------------------------------- -void DBaseStatusBar::Destroy () +void DBaseStatusBar::OnDestroy () { for (size_t i = 0; i < countof(Messages); ++i) { @@ -271,7 +271,7 @@ void DBaseStatusBar::Destroy () } Messages[i] = NULL; } - Super::Destroy(); + Super::OnDestroy(); } //--------------------------------------------------------------------------- diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 1283cc972..4b1b5cc8b 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -800,10 +800,10 @@ void ADynamicLight::UnlinkLight () while (touching_sector) touching_sector = DeleteLightNode(touching_sector); } -void ADynamicLight::Destroy() +void ADynamicLight::OnDestroy() { UnlinkLight(); - Super::Destroy(); + Super::OnDestroy(); } diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h index f71f0dfdf..25d091150 100644 --- a/src/gl/dynlights/gl_dynlight.h +++ b/src/gl/dynlights/gl_dynlight.h @@ -108,7 +108,7 @@ public: void BeginPlay(); void SetOrigin (double x, double y, double z, bool moving = false); void PostBeginPlay(); - void Destroy(); + void OnDestroy() override; void Activate(AActor *activator); void Deactivate(AActor *activator); void SetOffset(const DVector3 &pos); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 015b42016..1d9cf9b3b 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -60,7 +60,7 @@ #include "w_wad.h" #include "r_state.h" #include "r_utility.h" -//#include "gl/gl_intern.h" +#include "g_levellocals.h" #include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" @@ -381,7 +381,13 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f; float yscale = 1.f; - if (texh < 128) + if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY)) + { + gl_RenderState.mModelMatrix.translate(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, 1.2f * 1.17f, 1.f); + yscale = 240.f / texh; + } + else if (texh < 128) { // smaller sky textures must be tiled. We restrict it to 128 sky pixels, though gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); diff --git a/src/gl/system/gl_extlist.txt b/src/gl/system/gl_extlist.txt index efa51ad01..b67d21f10 100644 --- a/src/gl/system/gl_extlist.txt +++ b/src/gl/system/gl_extlist.txt @@ -14,3 +14,4 @@ EXT_texture_filter_anisotropic EXT_texture_sRGB KHR_debug ARB_invalidate_subdata +EXT_abgr diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index a32eb226f..f390b5cc9 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -98,6 +98,7 @@ int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; int ogl_ext_KHR_debug = ogl_LOAD_FAILED; int ogl_ext_ARB_invalidate_subdata = ogl_LOAD_FAILED; +int ogl_ext_EXT_abgr = ogl_LOAD_FAILED; void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags) = NULL; @@ -2377,7 +2378,7 @@ typedef struct ogl_StrToExtMap_s PFN_LOADFUNCPOINTERS LoadExtension; } ogl_StrToExtMap; -static ogl_StrToExtMap ExtensionMap[11] = { +static ogl_StrToExtMap ExtensionMap[12] = { {"GL_APPLE_client_storage", &ogl_ext_APPLE_client_storage, NULL}, {"GL_ARB_buffer_storage", &ogl_ext_ARB_buffer_storage, Load_ARB_buffer_storage}, {"GL_ARB_shader_storage_buffer_object", &ogl_ext_ARB_shader_storage_buffer_object, Load_ARB_shader_storage_buffer_object}, @@ -2389,9 +2390,10 @@ static ogl_StrToExtMap ExtensionMap[11] = { {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, {"GL_KHR_debug", &ogl_ext_KHR_debug, Load_KHR_debug}, {"GL_ARB_invalidate_subdata", &ogl_ext_ARB_invalidate_subdata, Load_ARB_invalidate_subdata}, + {"GL_EXT_abgr", &ogl_ext_EXT_abgr, NULL}, }; -static int g_extensionMapSize = 11; +static int g_extensionMapSize = 12; static ogl_StrToExtMap *FindExtEntry(const char *extensionName) { @@ -2419,6 +2421,7 @@ static void ClearExtensionVars(void) ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; ogl_ext_KHR_debug = ogl_LOAD_FAILED; ogl_ext_ARB_invalidate_subdata = ogl_LOAD_FAILED; + ogl_ext_EXT_abgr = ogl_LOAD_FAILED; } diff --git a/src/gl/system/gl_load.h b/src/gl/system/gl_load.h index 892709ccd..dea1611f7 100644 --- a/src/gl/system/gl_load.h +++ b/src/gl/system/gl_load.h @@ -164,6 +164,7 @@ extern int ogl_ext_EXT_texture_filter_anisotropic; extern int ogl_ext_EXT_texture_sRGB; extern int ogl_ext_KHR_debug; extern int ogl_ext_ARB_invalidate_subdata; +extern int ogl_ext_EXT_abgr; #define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 @@ -331,6 +332,8 @@ extern int ogl_ext_ARB_invalidate_subdata; #define GL_STACK_UNDERFLOW 0x0504 #define GL_VERTEX_ARRAY 0x8074 +#define GL_ABGR_EXT 0x8000 + #define GL_2D 0x0600 #define GL_2_BYTES 0x1407 #define GL_3D 0x0601 @@ -1703,6 +1706,7 @@ extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexSubImage)(GLuint texture, GLi #define glInvalidateTexSubImage _ptrc_glInvalidateTexSubImage #endif /*GL_ARB_invalidate_subdata*/ + extern void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum op, GLfloat value); #define glAccum _ptrc_glAccum extern void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum func, GLfloat ref); diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 2416f01c4..2612bdd63 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -204,7 +204,7 @@ void DIntermissionScreen::Drawer () if (!mFlatfill) screen->FillBorder (NULL); } -void DIntermissionScreen::Destroy() +void DIntermissionScreen::OnDestroy() { if (mPaletteChanged) { @@ -222,7 +222,7 @@ void DIntermissionScreen::Destroy() M_EnableMenu(true); } S_StopSound(CHAN_VOICE); - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== @@ -874,9 +874,9 @@ void DIntermissionController::Drawer () } } -void DIntermissionController::Destroy () +void DIntermissionController::OnDestroy () { - Super::Destroy(); + Super::OnDestroy(); if (mScreen != NULL) mScreen->Destroy(); if (mDeleteDesc) delete mDesc; mDesc = NULL; diff --git a/src/intermission/intermission.h b/src/intermission/intermission.h index 25b369a3a..0f2c38dde 100644 --- a/src/intermission/intermission.h +++ b/src/intermission/intermission.h @@ -176,7 +176,7 @@ public: virtual int Responder (event_t *ev); virtual int Ticker (); virtual void Drawer (); - void Destroy() override; + void OnDestroy() override; FTextureID GetBackground(bool *fill) { *fill = mFlatfill; @@ -301,7 +301,7 @@ public: bool Responder (event_t *ev); void Ticker (); void Drawer (); - void Destroy() override; + void OnDestroy() override; friend void F_AdvanceIntermission(); }; diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 414fafba9..36c6249cd 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -646,7 +646,7 @@ void cht_Give (player_t *player, const char *name, int amount) if (type->ParentClass == RUNTIME_CLASS(AAmmo)) { - PClassAmmo *atype = static_cast(type); + PClassInventory *atype = static_cast(type); AInventory *ammo = player->mo->FindInventory(atype); if (ammo == NULL) { diff --git a/src/menu/colorpickermenu.cpp b/src/menu/colorpickermenu.cpp index e1ee3566d..0d92e1e45 100644 --- a/src/menu/colorpickermenu.cpp +++ b/src/menu/colorpickermenu.cpp @@ -95,7 +95,7 @@ public: desc->CalcIndent(); } - void Destroy() override + void OnDestroy() override { if (mStartItem >= 0) { diff --git a/src/menu/loadsavemenu.cpp b/src/menu/loadsavemenu.cpp index 73183ca22..457b020b4 100644 --- a/src/menu/loadsavemenu.cpp +++ b/src/menu/loadsavemenu.cpp @@ -103,7 +103,7 @@ protected: char savegamestring[SAVESTRINGSIZE]; DLoadSaveMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL); - void Destroy() override; + void OnDestroy() override; int RemoveSaveSlot (int index); void UnloadSaveData (); @@ -461,12 +461,12 @@ DLoadSaveMenu::DLoadSaveMenu(DMenu *parent, FListMenuDescriptor *desc) commentBottom = commentTop + commentHeight; } -void DLoadSaveMenu::Destroy() +void DLoadSaveMenu::OnDestroy() { if (currentSavePic != nullptr) delete currentSavePic; currentSavePic = nullptr; ClearSaveStuff (); - Super::Destroy(); + Super::OnDestroy(); } //============================================================================= @@ -928,7 +928,7 @@ class DSaveMenu : public DLoadSaveMenu public: DSaveMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL); - void Destroy() override; + void OnDestroy() override; void DoSave (FSaveGameNode *node); bool Responder (event_t *ev); bool MenuEvent (int mkey, bool fromcontroller); @@ -968,7 +968,7 @@ DSaveMenu::DSaveMenu(DMenu *parent, FListMenuDescriptor *desc) // //============================================================================= -void DSaveMenu::Destroy() +void DSaveMenu::OnDestroy() { if (SaveGames[0] == &NewSaveNode) { @@ -976,7 +976,7 @@ void DSaveMenu::Destroy() if (Selected == 0) Selected = -1; else Selected--; } - Super::Destroy(); + Super::OnDestroy(); } //============================================================================= diff --git a/src/menu/messagebox.cpp b/src/menu/messagebox.cpp index c406fc701..86b7c3bfe 100644 --- a/src/menu/messagebox.cpp +++ b/src/menu/messagebox.cpp @@ -63,7 +63,7 @@ class DMessageBoxMenu : public DMenu public: DMessageBoxMenu(DMenu *parent = NULL, const char *message = NULL, int messagemode = 0, bool playsound = false, FName action = NAME_None); - void Destroy() override; + void OnDestroy() override; void Init(DMenu *parent, const char *message, int messagemode, bool playsound = false); void Drawer(); bool Responder(event_t *ev); @@ -124,11 +124,11 @@ void DMessageBoxMenu::Init(DMenu *parent, const char *message, int messagemode, // //============================================================================= -void DMessageBoxMenu::Destroy() +void DMessageBoxMenu::OnDestroy() { if (mMessage != NULL) V_FreeBrokenLines(mMessage); mMessage = NULL; - Super::Destroy(); + Super::OnDestroy(); } //============================================================================= diff --git a/src/namedef.h b/src/namedef.h index 13ebf78ca..48f1a1943 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -277,6 +277,7 @@ xx(Massacre) // For death by a cheater! xx(InstantDeath) // Strife "instant death" xx(PoisonCloud) // makes monsters howl. xx(Hitscan) // for normal guns and the like +xx(Quake) // Special death name for getting killed excessively. Could be used as // a damage type if you wanted to force an extreme death. diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index 11332f049..bdb343449 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -123,7 +123,8 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, if (segs[i].Partner != DWORD_MAX) { - outSegs[i].PartnerSeg = &outSegs[Segs[segs[i].Partner].storedseg]; + const DWORD storedseg = Segs[segs[i].Partner].storedseg; + outSegs[i].PartnerSeg = DWORD_MAX == storedseg ? nullptr : &outSegs[storedseg]; } else { diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index c25d4a532..102ed57b0 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -369,7 +369,7 @@ bool P_CheckFor3DFloorHit(AActor * mo, double z) { if (fabs(z - rover->top.plane->ZatPoint(mo)) < EQUAL_EPSILON) { - rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor); + rover->model->TriggerSectorActions (mo, SECSPAC_HitFloor); return true; } } @@ -395,7 +395,7 @@ bool P_CheckFor3DCeilingHit(AActor * mo, double z) { if(fabs(z - rover->bottom.plane->ZatPoint(mo)) < EQUAL_EPSILON) { - rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling); + rover->model->TriggerSectorActions (mo, SECSPAC_HitCeiling); return true; } } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 3fb7ea314..5355b10a0 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8720,19 +8720,19 @@ scriptwait: case PCD_SETAMMOCAPACITY: if (activator != NULL) { - PClass *type = PClass::FindClass (FBehavior::StaticLookupString (STACK(2))); + PClassActor *type = PClass::FindActor (FBehavior::StaticLookupString (STACK(2))); AInventory *item; if (type != NULL && type->ParentClass == RUNTIME_CLASS(AAmmo)) { - item = activator->FindInventory (static_cast(type)); + item = activator->FindInventory (type); if (item != NULL) { item->MaxAmount = STACK(1); } else { - item = activator->GiveInventoryType (static_cast(type)); + item = activator->GiveInventoryType (type); if (item != NULL) { item->MaxAmount = STACK(1); diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 32161ed07..b47788212 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -3210,6 +3210,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Log) { PARAM_SELF_PROLOGUE(AActor); PARAM_STRING(text); + PARAM_BOOL_DEF(local); + + if (local && !self->CheckLocalView(consoleplayer)) return 0; if (text[0] == '$') text = GStrings(&text[1]); FString formatted = strbin1(text); @@ -3227,6 +3230,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_LogInt) { PARAM_SELF_PROLOGUE(AActor); PARAM_INT(num); + PARAM_BOOL_DEF(local); + + if (local && !self->CheckLocalView(consoleplayer)) return 0; Printf("%d\n", num); return 0; } @@ -3241,6 +3247,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_LogFloat) { PARAM_SELF_PROLOGUE(AActor); PARAM_FLOAT(num); + PARAM_BOOL_DEF(local); + + if (local && !self->CheckLocalView(consoleplayer)) return 0; IGNORE_FORMAT_PRE Printf("%H\n", num); IGNORE_FORMAT_POST diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 4f7f2fea7..0de02656d 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -829,12 +829,12 @@ public: // //============================================================================= - void Destroy() + void OnDestroy() override { V_FreeBrokenLines(mDialogueLines); mDialogueLines = NULL; I_SetMusicVolume (1.f); - Super::Destroy(); + Super::OnDestroy(); } bool DimAllowed() diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index ac4e0f04b..83b96af39 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -713,7 +713,7 @@ bool P_Move (AActor *actor) if (actor->floorsector->SecActTarget != NULL && actor->floorz == actor->floorsector->floorplane.ZatPoint(actor->PosRelative(actor->floorsector))) { - actor->floorsector->SecActTarget->TriggerAction(actor, SECSPAC_HitFloor); + actor->floorsector->TriggerSectorActions(actor, SECSPAC_HitFloor); } P_CheckFor3DFloorHit(actor, actor->Z()); } @@ -3241,7 +3241,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount) else if (inv->IsKindOf (RUNTIME_CLASS(AAmmo))) { // Half ammo when dropped by bad guys. - int amount = static_cast(inv->GetClass())->DropAmount; + int amount = static_cast(inv)->DropAmount; if (amount <= 0) { amount = MAX(1, int(inv->Amount * dropammofactor)); diff --git a/src/p_floor.cpp b/src/p_floor.cpp index d81ec8bf4..2fd205a9d 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -869,7 +869,7 @@ void DElevator::Serialize(FSerializer &arc) // //========================================================================== -void DElevator::Destroy() +void DElevator::OnDestroy() { if (m_Interp_Ceiling != NULL) { @@ -881,7 +881,7 @@ void DElevator::Destroy() m_Interp_Floor->DelRef(); m_Interp_Floor = NULL; } - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 0860c98b8..51e59ec08 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -1290,7 +1290,7 @@ CCMD(clearnodecache) } catch (CRecoverableError &err) { - Printf("%s", err.GetMessage()); + Printf("%s\n", err.GetMessage()); return; } @@ -1443,7 +1443,7 @@ void P_SetRenderSector() { int partner = (int)(p - segs); - if (partner < 0 || partner >= numsegs) + if (partner < 0 || partner >= numsegs || &segs[partner] != p) { segs[i].PartnerSeg = nullptr; } diff --git a/src/p_map.cpp b/src/p_map.cpp index 4e873c99a..c3fd2dc88 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2616,11 +2616,11 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, if (!oldAboveFakeFloor && eyez > fakez) { // View went above fake floor - newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesSurface); + newsec->TriggerSectorActions(thing, SECSPAC_EyesSurface); } else if (oldAboveFakeFloor && eyez <= fakez) { // View went below fake floor - newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesDive); + newsec->TriggerSectorActions(thing, SECSPAC_EyesDive); } if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) @@ -2628,11 +2628,11 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, fakez = hs->ceilingplane.ZatPoint(pos); if (!oldAboveFakeCeiling && eyez > fakez) { // View went above fake ceiling - newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesAboveC); + newsec->TriggerSectorActions(thing, SECSPAC_EyesAboveC); } else if (oldAboveFakeCeiling && eyez <= fakez) { // View went below fake ceiling - newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesBelowC); + newsec->TriggerSectorActions(thing, SECSPAC_EyesBelowC); } } } @@ -5304,7 +5304,7 @@ bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, sec = usething->Sector; - if (sec->SecActTarget && sec->SecActTarget->TriggerAction(usething, SECSPAC_Use)) + if (sec->SecActTarget && sec->TriggerSectorActions(usething, SECSPAC_Use)) { return true; } @@ -5313,7 +5313,7 @@ bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, in->d.line->frontsector : in->d.line->backsector; if (sec != NULL && sec->SecActTarget && - sec->SecActTarget->TriggerAction(usething, SECSPAC_UseWall)) + sec->TriggerSectorActions(usething, SECSPAC_UseWall)) { return true; } @@ -5434,7 +5434,7 @@ void P_UseLines(player_t *player) sector_t *sec = player->mo->Sector; int spac = SECSPAC_Use; if (foundline) spac |= SECSPAC_UseWall; - if ((!sec->SecActTarget || !sec->SecActTarget->TriggerAction(player->mo, spac)) && + if ((!sec->SecActTarget || !sec->TriggerSectorActions(player->mo, spac)) && P_NoWayTraverse(player->mo, start, end)) { S_Sound(player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index d5ec020a0..c3a7ac424 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1134,7 +1134,7 @@ DEFINE_ACTION_FUNCTION(AActor, GiveInventoryType) // //============================================================================ -bool AActor::GiveAmmo (PClassAmmo *type, int amount) +bool AActor::GiveAmmo (PClassInventory *type, int amount) { if (type != NULL) { @@ -1770,7 +1770,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) } } - // play the sound before changing the state, so that AActor::Destroy can call S_RelinkSounds on it and the death state can override it. + // play the sound before changing the state, so that AActor::OnDestroy can call S_RelinkSounds on it and the death state can override it. if (mo->DeathSound) { S_Sound (mo, CHAN_VOICE, mo->DeathSound, 1, @@ -2810,7 +2810,7 @@ void P_ZMovement (AActor *mo, double oldfloorz) mo->Sector->SecActTarget != NULL && mo->Sector->floorplane.ZatPoint(mo) == mo->floorz) { // [RH] Let the sector do something to the actor - mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor); + mo->Sector->TriggerSectorActions (mo, SECSPAC_HitFloor); } P_CheckFor3DFloorHit(mo, mo->floorz); // [RH] Need to recheck this because the sector action might have @@ -2913,7 +2913,7 @@ void P_ZMovement (AActor *mo, double oldfloorz) mo->Sector->SecActTarget != NULL && mo->Sector->ceilingplane.ZatPoint(mo) == mo->ceilingz) { // [RH] Let the sector do something to the actor - mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling); + mo->Sector->TriggerSectorActions (mo, SECSPAC_HitCeiling); } P_CheckFor3DCeilingHit(mo, mo->ceilingz); // [RH] Need to recheck this because the sector action might have @@ -2981,7 +2981,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight if (oldz > waterz && mo->Z() <= waterz) { // Feet hit fake floor - sec->SecActTarget->TriggerAction (mo, SECSPAC_HitFakeFloor); + sec->TriggerSectorActions (mo, SECSPAC_HitFakeFloor); } newz = mo->Z() + viewheight; @@ -2992,11 +2992,11 @@ void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight if (oldz <= waterz && newz > waterz) { // View went above fake floor - sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesSurface); + sec->TriggerSectorActions (mo, SECSPAC_EyesSurface); } else if (oldz > waterz && newz <= waterz) { // View went below fake floor - sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesDive); + sec->TriggerSectorActions (mo, SECSPAC_EyesDive); } if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) @@ -3004,11 +3004,11 @@ void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight waterz = hs->ceilingplane.ZatPoint(mo); if (oldz <= waterz && newz > waterz) { // View went above fake ceiling - sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesAboveC); + sec->TriggerSectorActions (mo, SECSPAC_EyesAboveC); } else if (oldz > waterz && newz <= waterz) { // View went below fake ceiling - sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesBelowC); + sec->TriggerSectorActions (mo, SECSPAC_EyesBelowC); } } } @@ -4333,6 +4333,12 @@ bool AActor::CheckNoDelay() return true; } +DEFINE_ACTION_FUNCTION(AActor, CheckNoDelay) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(self->CheckNoDelay()); +} + //========================================================================== // // AActor :: CheckSectorTransition @@ -4347,7 +4353,7 @@ void AActor::CheckSectorTransition(sector_t *oldsec) { if (oldsec->SecActTarget != NULL) { - oldsec->SecActTarget->TriggerAction(this, SECSPAC_Exit); + oldsec->TriggerSectorActions(this, SECSPAC_Exit); } if (Sector->SecActTarget != NULL) { @@ -4364,7 +4370,7 @@ void AActor::CheckSectorTransition(sector_t *oldsec) { act |= SECSPAC_HitFakeFloor; } - Sector->SecActTarget->TriggerAction(this, act); + Sector->TriggerSectorActions(this, act); } if (Z() == floorz) { @@ -4486,6 +4492,12 @@ bool AActor::UpdateWaterLevel (bool dosplash) return false; // we did the splash ourselves } +DEFINE_ACTION_FUNCTION(AActor, UpdateWaterLevel) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_BOOL_DEF(splash); + ACTION_RETURN_BOOL(self->UpdateWaterLevel(splash)); +} //========================================================================== // @@ -4920,7 +4932,7 @@ void AActor::CallDeactivate(AActor *activator) // //=========================================================================== -void AActor::Destroy () +void AActor::OnDestroy () { ClearRenderSectorList(); ClearRenderLineList(); @@ -4938,7 +4950,7 @@ void AActor::Destroy () // Transform any playing sound into positioned, non-actor sounds. S_RelinkSound (this, NULL); - Super::Destroy (); + Super::OnDestroy(); } //=========================================================================== @@ -7821,6 +7833,13 @@ DEFINE_ACTION_FUNCTION(AActor, Vec3Offset) ACTION_RETURN_VEC3(self->Vec3Offset(x, y, z, absolute)); } +DEFINE_ACTION_FUNCTION(AActor, PosRelative) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(sec, sector_t); + ACTION_RETURN_VEC3(self->PosRelative(sec)); +} + DEFINE_ACTION_FUNCTION(AActor, RestoreDamage) { PARAM_SELF_PROLOGUE(AActor); @@ -7861,6 +7880,19 @@ DEFINE_ACTION_FUNCTION(AActor, CountsAsKill) ACTION_RETURN_FLOAT(self->CountsAsKill()); } +DEFINE_ACTION_FUNCTION(AActor, IsZeroDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + ACTION_RETURN_BOOL(self->IsZeroDamage()); +} + +DEFINE_ACTION_FUNCTION(AActor, ClearInterpolation) +{ + PARAM_SELF_PROLOGUE(AActor); + self->ClearInterpolation(); + return 0; +} + DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactors) { PARAM_PROLOGUE; @@ -7880,6 +7912,7 @@ DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactors) } } + //---------------------------------------------------------------------------- // // DropItem handling diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index d603edc8a..77316ad2c 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -52,7 +52,7 @@ DPillar::DPillar () { } -void DPillar::Destroy() +void DPillar::OnDestroy() { if (m_Interp_Ceiling != NULL) { @@ -64,7 +64,7 @@ void DPillar::Destroy() m_Interp_Floor->DelRef(); m_Interp_Floor = NULL; } - Super::Destroy(); + Super::OnDestroy(); } void DPillar::Serialize(FSerializer &arc) diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 4d77bb645..7662f3240 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -1733,7 +1733,7 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetSafeFlash) // //------------------------------------------------------------------------ -void DPSprite::Destroy() +void DPSprite::OnDestroy() { // Do not crash if this gets called on partially initialized objects. if (Owner != nullptr && Owner->psprites != nullptr) @@ -1756,7 +1756,7 @@ void DPSprite::Destroy() GC::WriteBarrier(Next); } } - Super::Destroy(); + Super::OnDestroy(); } //------------------------------------------------------------------------ diff --git a/src/p_pspr.h b/src/p_pspr.h index 2b84f7949..5a8152591 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -79,6 +79,7 @@ public: AActor* GetCaller() { return Caller; } void SetCaller(AActor *newcaller) { Caller = newcaller; } void ResetInterpolation() { oldx = x; oldy = y; } + void OnDestroy() override; double x, y, alpha; double oldx, oldy; @@ -92,7 +93,6 @@ private: void Serialize(FSerializer &arc); void Tick(); - void Destroy() override; public: // must be public to be able to generate the field export tables. Grrr... TObjPtr Caller; diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index 403eb3087..11de6023f 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -45,7 +45,7 @@ public: DScroller (EScroll type, double dx, double dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all); DScroller (double dx, double dy, const line_t *l, int control, int accel, EScrollPos scrollpos = EScrollPos::scw_all); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); void Tick (); @@ -306,7 +306,7 @@ DScroller::DScroller (EScroll type, double dx, double dy, } } -void DScroller::Destroy () +void DScroller::OnDestroy () { for(int i=0;i<3;i++) { @@ -316,7 +316,7 @@ void DScroller::Destroy () m_Interpolations[i] = NULL; } } - Super::Destroy(); + Super::OnDestroy(); } //----------------------------------------------------------------------------- diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index c95f48d15..b8b2fdfa0 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1446,6 +1446,49 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt) } + //=========================================================================== + // + // + // + //=========================================================================== + + bool sector_t::TriggerSectorActions(AActor *thing, int activation) + { + auto act = SecActTarget; + bool res = false; + + while (act != nullptr) + { + AActor *next = act->tracer; + + bool didit = act->DoTriggerAction(thing, activation); + if (didit) + { + if (act->flags4 & MF4_STANDSTILL) + { + act->Destroy(); + } + } + act = static_cast(next); + res |= didit; + } + return res; + } + + DEFINE_ACTION_FUNCTION(_Sector, TriggerSectorActions) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_OBJECT(thing, AActor); + PARAM_INT(activation); + ACTION_RETURN_BOOL(self->TriggerSectorActions(thing, activation)); + } + + //=========================================================================== + // + // + // + //=========================================================================== + DEFINE_ACTION_FUNCTION(_Sector, PointInSector) { PARAM_PROLOGUE; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 614ed92bd..c7c59aaa9 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -4188,6 +4188,11 @@ static void P_Shutdown () P_FreeLevelData (); P_FreeExtraLevelData (); ST_Clear(); + FS_Close(); + for (auto &p : players) + { + if (p.psprites != nullptr) p.psprites->Destroy(); + } } #if 0 diff --git a/src/p_spec.h b/src/p_spec.h index a2fd0727a..c5e7b2f5c 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -243,7 +243,7 @@ public: void Serialize(FSerializer &arc); void Tick (); - void Destroy() override; + void OnDestroy() override; protected: EPillar m_Type; @@ -574,7 +574,7 @@ public: DElevator (sector_t *sec); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); void Tick (); diff --git a/src/p_user.cpp b/src/p_user.cpp index 936fdf4ad..b68cad604 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -942,7 +942,7 @@ bool APlayerPawn::UseInventory (AInventory *item) // //=========================================================================== -AWeapon *APlayerPawn::BestWeapon(PClassAmmo *ammotype) +AWeapon *APlayerPawn::BestWeapon(PClassInventory *ammotype) { AWeapon *bestMatch = NULL; int bestOrder = INT_MAX; @@ -1004,7 +1004,7 @@ AWeapon *APlayerPawn::BestWeapon(PClassAmmo *ammotype) // //=========================================================================== -AWeapon *APlayerPawn::PickNewWeapon(PClassAmmo *ammotype) +AWeapon *APlayerPawn::PickNewWeapon(PClassInventory *ammotype) { AWeapon *best = BestWeapon (ammotype); @@ -1032,7 +1032,7 @@ AWeapon *APlayerPawn::PickNewWeapon(PClassAmmo *ammotype) // //=========================================================================== -void APlayerPawn::CheckWeaponSwitch(PClassAmmo *ammotype) +void APlayerPawn::CheckWeaponSwitch(PClassInventory *ammotype) { if (!player->userinfo.GetNeverSwitch() && player->PendingWeapon == WP_NOCHANGE && diff --git a/src/po_man.cpp b/src/po_man.cpp index e8c1cbbb8..c2c8f5a7d 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -187,7 +187,7 @@ DPolyAction::DPolyAction (int polyNum) SetInterpolation (); } -void DPolyAction::Destroy() +void DPolyAction::OnDestroy() { FPolyObj *poly = PO_GetPolyobj (m_PolyObj); @@ -197,7 +197,7 @@ void DPolyAction::Destroy() } StopInterpolation(); - Super::Destroy(); + Super::OnDestroy(); } void DPolyAction::Stop() diff --git a/src/po_man.h b/src/po_man.h index 4d78fa179..34a735f05 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -12,7 +12,7 @@ class DPolyAction : public DThinker public: DPolyAction(int polyNum); void Serialize(FSerializer &arc); - void Destroy() override; + void OnDestroy() override; void Stop(); double GetSpeed() const { return m_Speed; } diff --git a/src/posix/cocoa/i_common.h b/src/posix/cocoa/i_common.h index 9cedb0262..0fc46e377 100644 --- a/src/posix/cocoa/i_common.h +++ b/src/posix/cocoa/i_common.h @@ -184,14 +184,19 @@ typedef NSInteger NSApplicationActivationPolicy; - (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; @end +@interface NSView(Compatibility) +- (NSRect)convertRectToBacking:(NSRect)aRect; +@end + @interface NSScreen(HiDPIStubs) - (NSRect)convertRectToBacking:(NSRect)aRect; @end static const NSWindowCollectionBehavior NSWindowCollectionBehaviorFullScreenAuxiliary = NSWindowCollectionBehavior(1 << 8); -static const NSOpenGLPixelFormatAttribute NSOpenGLPFAOpenGLProfile(96); -static const NSOpenGLPixelFormatAttribute NSOpenGLProfileVersion3_2Core(0x3200); +static const auto NSOpenGLPFAOpenGLProfile = NSOpenGLPixelFormatAttribute(96); +static const auto NSOpenGLProfileVersionLegacy = NSOpenGLPixelFormatAttribute(0x1000); +static const auto NSOpenGLProfileVersion3_2Core = NSOpenGLPixelFormatAttribute(0x3200); #endif // prior to 10.7 diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index f056b3876..7b5bdec8e 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -69,6 +69,19 @@ #undef Class +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 + +@implementation NSView(Compatibility) + +- (NSRect)convertRectToBacking:(NSRect)aRect +{ + return [self convertRect:aRect toView:[self superview]]; +} + +@end + +#endif // prior to 10.7 + @implementation NSWindow(ExitAppOnClose) - (void)exitAppOnClose diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 92dc683a8..2c7197a44 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -62,7 +62,7 @@ public: DSectorPlaneInterpolation() {} DSectorPlaneInterpolation(sector_t *sector, bool plane, bool attach); - void Destroy() override; + void OnDestroy() override; void UpdateInterpolation(); void Restore(); void Interpolate(double smoothratio); @@ -91,7 +91,7 @@ public: DSectorScrollInterpolation() {} DSectorScrollInterpolation(sector_t *sector, bool plane); - void Destroy() override; + void OnDestroy() override; void UpdateInterpolation(); void Restore(); void Interpolate(double smoothratio); @@ -119,7 +119,7 @@ public: DWallScrollInterpolation() {} DWallScrollInterpolation(side_t *side, int part); - void Destroy() override; + void OnDestroy() override; void UpdateInterpolation(); void Restore(); void Interpolate(double smoothratio); @@ -146,7 +146,7 @@ public: DPolyobjInterpolation() {} DPolyobjInterpolation(FPolyObj *poly); - void Destroy() override; + void OnDestroy() override; void UpdateInterpolation(); void Restore(); void Interpolate(double smoothratio); @@ -364,11 +364,11 @@ int DInterpolation::DelRef(bool force) // //========================================================================== -void DInterpolation::Destroy() +void DInterpolation::OnDestroy() { interpolator.RemoveInterpolation(this); refcount = 0; - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== @@ -419,7 +419,7 @@ DSectorPlaneInterpolation::DSectorPlaneInterpolation(sector_t *_sector, bool _pl // //========================================================================== -void DSectorPlaneInterpolation::Destroy() +void DSectorPlaneInterpolation::OnDestroy() { if (sector != nullptr) { @@ -437,7 +437,7 @@ void DSectorPlaneInterpolation::Destroy() { attached[i]->DelRef(); } - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== @@ -597,7 +597,7 @@ DSectorScrollInterpolation::DSectorScrollInterpolation(sector_t *_sector, bool _ // //========================================================================== -void DSectorScrollInterpolation::Destroy() +void DSectorScrollInterpolation::OnDestroy() { if (sector != nullptr) { @@ -611,7 +611,7 @@ void DSectorScrollInterpolation::Destroy() } sector = nullptr; } - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== @@ -702,14 +702,14 @@ DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part) // //========================================================================== -void DWallScrollInterpolation::Destroy() +void DWallScrollInterpolation::OnDestroy() { if (side != nullptr) { side->textures[part].interpolation = nullptr; side = nullptr; } - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== @@ -800,13 +800,13 @@ DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po) // //========================================================================== -void DPolyobjInterpolation::Destroy() +void DPolyobjInterpolation::OnDestroy() { if (poly != nullptr) { poly->interpolation = nullptr; } - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== diff --git a/src/r_data/r_interpolate.h b/src/r_data/r_interpolate.h index 44ff9bed0..bcb584d02 100644 --- a/src/r_data/r_interpolate.h +++ b/src/r_data/r_interpolate.h @@ -27,7 +27,7 @@ public: int AddRef(); int DelRef(bool force = false); - void Destroy() override; + void OnDestroy() override; virtual void UpdateInterpolation() = 0; virtual void Restore() = 0; virtual void Interpolate(double smoothratio) = 0; diff --git a/src/r_defs.h b/src/r_defs.h index ee32e6c8b..968d6829f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -281,19 +281,15 @@ class ASectorAction : public AActor { DECLARE_CLASS (ASectorAction, AActor) public: - ASectorAction (bool activatedByUse = false); - void Destroy () override; + void OnDestroy() override; void BeginPlay (); void Activate (AActor *source); void Deactivate (AActor *source); - bool TriggerAction(AActor *triggerer, int activationType); bool CanTrigger (AActor *triggerer) const; bool IsActivatedByUse() const; -protected: virtual bool DoTriggerAction(AActor *triggerer, int activationType); +protected: bool CheckTrigger(AActor *triggerer) const; -private: - bool ActivatedByUse; }; class ASkyViewpoint; @@ -673,6 +669,7 @@ public: int GetCeilingLight () const; sector_t *GetHeightSec() const; double GetFriction(int plane = sector_t::floor, double *movefac = NULL) const; + bool TriggerSectorActions(AActor *thing, int activation); DInterpolation *SetInterpolation(int position, bool attach); diff --git a/src/r_sky.cpp b/src/r_sky.cpp index 89a2bc44c..f2804bad7 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -120,12 +120,12 @@ void R_InitSkyMap () skystretch = (r_skymode == 1 && skyheight >= 128 && level.IsFreelookAllowed() - && !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0; + && !(level.flags & LEVEL_FORCETILEDSKY)) ? 1 : 0; skytexturemid = -28; } else if (skyheight > 200) { - skytexturemid = (200 - skyheight) * skytex1->Scale.Y +(r_skymode == 2 ? skytex1->SkyOffset + testskyoffset : 0); + skytexturemid = (200 - skyheight) * skytex1->Scale.Y +((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->SkyOffset + testskyoffset : 0); } if (viewwidth != 0 && viewheight != 0) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index d2c40109a..052abf04e 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -2483,7 +2483,7 @@ bool AMusicChanger::DoTriggerAction (AActor *triggerer, int activationType) triggerer->player->MUSINFOtics = 30; } } - return Super::DoTriggerAction (triggerer, activationType); + return false; } void AMusicChanger::PostBeginPlay() @@ -2495,7 +2495,7 @@ void AMusicChanger::PostBeginPlay() { if (playeringame[i] && players[i].mo && players[i].mo->Sector == this->Sector) { - TriggerAction(players[i].mo, SECSPAC_Enter); + DoTriggerAction(players[i].mo, SECSPAC_Enter); } } } diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index 31ed314b7..a8d2dc7d7 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -106,7 +106,7 @@ class DSeqActorNode : public DSeqNode HAS_OBJECT_POINTERS public: DSeqActorNode(AActor *actor, int sequence, int modenum); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); void MakeSound(int loop, FSoundID id) { @@ -134,7 +134,7 @@ class DSeqPolyNode : public DSeqNode DECLARE_CLASS(DSeqPolyNode, DSeqNode) public: DSeqPolyNode(FPolyObj *poly, int sequence, int modenum); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); void MakeSound(int loop, FSoundID id) { @@ -162,7 +162,7 @@ class DSeqSectorNode : public DSeqNode DECLARE_CLASS(DSeqSectorNode, DSeqNode) public: DSeqSectorNode(sector_t *sec, int chan, int sequence, int modenum); - void Destroy() override; + void OnDestroy() override; void Serialize(FSerializer &arc); void MakeSound(int loop, FSoundID id) { @@ -379,7 +379,7 @@ void DSeqNode::Serialize(FSerializer &arc) } } -void DSeqNode::Destroy() +void DSeqNode::OnDestroy() { // If this sequence was launched by a parent sequence, advance that // sequence now. @@ -405,7 +405,7 @@ void DSeqNode::Destroy() GC::WriteBarrier(m_Next, m_Prev); } ActiveSequences--; - Super::Destroy(); + Super::OnDestroy(); } void DSeqNode::StopAndDestroy () @@ -1041,31 +1041,31 @@ void SN_DoStop (void *source) } } -void DSeqActorNode::Destroy () +void DSeqActorNode::OnDestroy () { if (m_StopSound >= 0) S_StopSound (m_Actor, CHAN_BODY); if (m_StopSound >= 1) MakeSound (0, m_StopSound); - Super::Destroy(); + Super::OnDestroy(); } -void DSeqSectorNode::Destroy () +void DSeqSectorNode::OnDestroy () { if (m_StopSound >= 0) S_StopSound (m_Sector, Channel & 7); if (m_StopSound >= 1) MakeSound (0, m_StopSound); - Super::Destroy(); + Super::OnDestroy(); } -void DSeqPolyNode::Destroy () +void DSeqPolyNode::OnDestroy () { if (m_StopSound >= 0) S_StopSound (m_Poly, CHAN_BODY); if (m_StopSound >= 1) MakeSound (0, m_StopSound); - Super::Destroy(); + Super::OnDestroy(); } //========================================================================== diff --git a/src/s_sndseq.h b/src/s_sndseq.h index 13444f862..57e21caa1 100644 --- a/src/s_sndseq.h +++ b/src/s_sndseq.h @@ -22,7 +22,7 @@ class DSeqNode : public DObject public: void Serialize(FSerializer &arc); void StopAndDestroy (); - void Destroy() override; + void OnDestroy() override; void Tick (); void ChangeData (int seqOffset, int delayTics, float volume, FSoundID currentSoundID); void AddChoice (int seqnum, seqtype_t type); diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 407fd6307..9c9659356 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -52,6 +52,7 @@ #include "g_levellocals.h" #include "vm.h" #include "p_checkposition.h" +#include "r_sky.h" static TArray properties; static TArray AFTable; @@ -742,9 +743,8 @@ void InitThingdef() // As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up. sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(linestruct, false)), false), myoffsetof(sector_t, Lines), VARF_Native); - // add the sector planes. These are value items of native structs so they have to be done here. Write access should be through functions only to allow later optimization inside the renderer. - sectorstruct->AddNativeField("ceilingplane", secplanestruct, myoffsetof(sector_t, ceilingplane), VARF_Native|VARF_ReadOnly); - sectorstruct->AddNativeField("floorplane", secplanestruct, myoffsetof(sector_t, floorplane), VARF_Native|VARF_ReadOnly); + sectorstruct->AddNativeField("ceilingplane", secplanestruct, myoffsetof(sector_t, ceilingplane), VARF_Native); + sectorstruct->AddNativeField("floorplane", secplanestruct, myoffsetof(sector_t, floorplane), VARF_Native); @@ -788,6 +788,12 @@ void InitThingdef() playerf = new PField("gameaction", TypeUInt8, VARF_Native | VARF_Static, (intptr_t)&gameaction); GlobalSymbols.AddSymbol(playerf); + playerf = new PField("skyflatnum", TypeTextureID, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&skyflatnum); + GlobalSymbols.AddSymbol(playerf); + + playerf = new PField("globalfreeze", TypeUInt8, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&bglobal.freeze); + GlobalSymbols.AddSymbol(playerf); + playerf = new PField("consoleplayer", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&consoleplayer); GlobalSymbols.AddSymbol(playerf); diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index c4c44a709..32f7dd622 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -1723,8 +1723,7 @@ DEFINE_CLASS_PROPERTY(backpackmaxamount, I, Ammo) DEFINE_CLASS_PROPERTY(dropamount, I, Ammo) { PROP_INT_PARM(i, 0); - assert(info->IsKindOf(RUNTIME_CLASS(PClassAmmo))); - static_cast(info)->DropAmount = i; + defaults->DropAmount = i; } //========================================================================== diff --git a/src/scripting/vm/vmframe.cpp b/src/scripting/vm/vmframe.cpp index 08559445e..09192cbfe 100644 --- a/src/scripting/vm/vmframe.cpp +++ b/src/scripting/vm/vmframe.cpp @@ -272,6 +272,7 @@ VMFrameStack::~VMFrameStack() next = block->NextBlock; delete[] (VM_UBYTE *)block; } + Blocks = NULL; } if (UnusedBlocks != NULL) { @@ -281,9 +282,8 @@ VMFrameStack::~VMFrameStack() next = block->NextBlock; delete[] (VM_UBYTE *)block; } + UnusedBlocks = NULL; } - Blocks = NULL; - UnusedBlocks = NULL; } //=========================================================================== @@ -608,4 +608,4 @@ ADD_STAT(VM) VMCycles[0].Reset(); VMCalls[0] = 0; return FStringf("VM time in last 10 tics: %f ms, %d calls", added, addedc); -} \ No newline at end of file +} diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 99422e4ad..50f85d853 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -9,7 +9,7 @@ // #include "afxres.h" #include "../version.h" -#include "../gitinfo.h" +#include "../gitinfo.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -74,7 +74,7 @@ BEGIN " VALUE ""CompanyName"", "" ""\r\n" " VALUE ""FileDescription"", ""QZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" - " VALUE ""InternalName"", ""QZDoom""\r\n" + " VALUE ""InternalName"", "QZDoom""\r\n" " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" " VALUE ""OriginalFilename"", ""qzdoom.exe""\r\n" @@ -220,46 +220,31 @@ END // Dialog // -/* -IDD_IWADDIALOG DIALOGEX 0, 0, 212, 186 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Select an IWAD to use" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - LISTBOX IDC_IWADLIST,5,25,200,124,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,61,153,89,10 - DEFPUSHBUTTON "OK",IDOK,5,165,50,14 - PUSHBUTTON "Cancel",IDCANCEL,155,165,50,14 - LTEXT "ZDoom found more than one IWAD present.",IDC_STATIC,5,5,140,8 - LTEXT "Select from the list below to determine which one to use:",IDC_STATIC,5,15,200,8 -END -*/ -// [SP] Upstreamed from Zandronum -IDD_IWADDIALOG DIALOGEX 0, 0, 224, 246 +IDD_IWADDIALOG DIALOGEX 0, 0, 224, 249 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "Welcome" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - ICON IDI_ICON1,IDC_STATIC,7,7,21,20 - LTEXT "Welcome to QZDoom!",IDC_STATIC,42,8,180,8 - LTEXT "",IDC_WELCOME_VERSION,42,18,180,8 - GROUPBOX "IWAD selection",IDC_STATIC,8,32,208,102 - LTEXT "Select which game file (IWAD) to run.",IDC_STATIC,12,44,190,8 - LISTBOX IDC_IWADLIST,12,56,200,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Video settings",IDC_STATIC,8,138,208,48 - LTEXT "Choose how QZDoom will render the game.",IDC_STATIC,12,148,190,8 - CONTROL "Hardware (OpenGL)",IDC_WELCOME_OPENGL,"Button",BS_AUTORADIOBUTTON,12,170,93,10 - CONTROL "Software (Doom)",IDC_WELCOME_SOFTWARE,"Button",BS_AUTORADIOBUTTON,12,160,93,10 - CONTROL "Fullscreen",IDC_WELCOME_FULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,124,160,48,10 - CONTROL "Disable autoload",IDC_WELCOME_NOAUTOLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,39,65,10 - CONTROL "Lights.pk3",IDC_WELCOME_LIGHTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,46,192,51,10 - CONTROL "Brightmaps.pk3",IDC_WELCOME_BRIGHTMAPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,111,192,65,10 - CONTROL "Don't ask me this again",IDC_DONTASKIWAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,73,211,87,10 - DEFPUSHBUTTON "Play QZDoom",IDOK,8,228,90,14 - PUSHBUTTON "Exit",IDCANCEL,166,228,50,14 -END +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +FONT 8, "MS Shell Dlg" +{ + CONTROL 101, IDC_STATIC, STATIC, SS_ICON | WS_CHILD | WS_VISIBLE, 7, 7, 21, 20 + CONTROL "Welcome to QZDoom!", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 8, 180, 8 + CONTROL "", IDC_WELCOME_VERSION, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 18, 180, 8 + CONTROL "IWAD selection", IDC_STATIC, BUTTON, BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 8, 32, 208, 117 + CONTROL "Select which game file (IWAD) to run.", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 12, 44, 190, 8 + CONTROL "", IDC_IWADLIST, LISTBOX, LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 12, 56, 200, 87 + CONTROL "Video settings", IDC_STATIC, BUTTON, BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 8, 155, 109, 52 + CONTROL "Hardware (OpenGL)", IDC_WELCOME_OPENGL, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 12, 170, 93, 10 + CONTROL "Software (Doom)", IDC_WELCOME_SOFTWARE, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 12, 180, 93, 10 + CONTROL "Fullscreen", IDC_WELCOME_FULLSCREEN, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 12, 190, 48, 10 + CONTROL "Resource settings", IDC_STATIC, BUTTON, BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 123, 155, 95, 52 + CONTROL "Disable autoload", IDC_WELCOME_NOAUTOLOAD, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 170, 65, 10 + CONTROL "Load lights", IDC_WELCOME_LIGHTS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 180, 51, 10 + CONTROL "Load brightmaps", IDC_WELCOME_BRIGHTMAPS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 190, 65, 10 + CONTROL "Don't ask me this again", IDC_DONTASKIWAD, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 73, 211, 87, 10 + CONTROL "Play QZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 + CONTROL "Exit", IDCANCEL, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 228, 50, 14 +} IDD_EAXPROPERTYLIST DIALOGEX 0, 0, 265, 404 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VSCROLL diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 6a5be172e..6f9c2ac19 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -145,6 +145,7 @@ class Actor : Thinker native native int lastbump; native int DesignatedTeam; native Actor BlockingMobj; + native Line BlockingLine; native int PoisonDamage; native name PoisonDamageType; native int PoisonDuration; @@ -207,7 +208,6 @@ class Actor : Thinker native // need some definition work first //FRenderStyle RenderStyle; - //line_t *BlockingLine; // Line that blocked the last move //int ConversationRoot; // THe root of the current dialogue // deprecated things. @@ -345,7 +345,12 @@ class Actor : Thinker native native void ClearBounce(); native TerrainDef GetFloorTerrain(); native bool CheckLocalView(int consoleplayer); - + native bool CheckNoDelay(); + native bool UpdateWaterLevel (bool splash = true); + native bool IsZeroDamage(); + native void ClearInterpolation(); + native Vector3 PosRelative(sector sec); + native void ExplodeMissile(line lin = null, Actor target = null); native void RestoreDamage(); native int SpawnHealth(); @@ -742,9 +747,9 @@ class Actor : Thinker native native bool A_SpawnItemEx(class itemtype, double xofs = 0, double yofs = 0, double zofs = 0, double xvel = 0, double yvel = 0, double zvel = 0, double angle = 0, int flags = 0, int failchance = 0, int tid=0); native void A_Print(string whattoprint, double time = 0, name fontname = "none"); native void A_PrintBold(string whattoprint, double time = 0, name fontname = "none"); - native void A_Log(string whattoprint); - native void A_LogInt(int whattoprint); - native void A_LogFloat(double whattoprint); + native void A_Log(string whattoprint, bool local = false); + native void A_LogInt(int whattoprint, bool local = false); + native void A_LogFloat(double whattoprint, bool local = false); native void A_SetTranslucent(double alpha, int style = 0); native void A_SetRenderStyle(double alpha, int style); native void A_FadeIn(double reduce = 0.1, int flags = 0); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 232becccc..f0e280623 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -17,8 +17,10 @@ class Object native native static void SetMusicVolume(float vol); native Name GetClassName(); + native void Destroy(); - /*virtual*/ native void Destroy(); + // This does not call into the native method of the same name to avoid problems with objects that get garbage collected late on shutdown. + virtual void OnDestroy() {} } class Thinker : Object native @@ -506,6 +508,7 @@ struct Sector native native int GetOppositePortalGroup(int plane); native double CenterFloor(); native double CenterCeiling(); + native bool TriggerSectorActions(Actor thing, int activation); native int MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant = false); native int MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush); diff --git a/wadsrc/static/zscript/shared/bridge.txt b/wadsrc/static/zscript/shared/bridge.txt index 6fb0a99d5..9446ac12c 100644 --- a/wadsrc/static/zscript/shared/bridge.txt +++ b/wadsrc/static/zscript/shared/bridge.txt @@ -1,3 +1,28 @@ +/* + args[0]: Bridge radius, in mapunits + args[1]: Bridge height, in mapunits + args[2]: Amount of bridge balls (if 0: Doom bridge) + args[3]: Rotation speed of bridge balls, in byte angle per seconds, sorta: + Since an arg is only a byte, it can only go from 0 to 255, while ZDoom's + BAM go from 0 to 65535. Plus, it needs to be able to go either way. So, + up to 128, it goes counterclockwise; 129-255 is clockwise, substracting + 256 from it to get the angle. A few example values: + 0: Hexen default + 11: 15° / seconds + 21: 30° / seconds + 32: 45° / seconds + 64: 90° / seconds + 128: 180° / seconds + 192: -90° / seconds + 223: -45° / seconds + 233: -30° / seconds + 244: -15° / seconds + This value only matters if args[2] is not zero. + args[4]: Rotation radius of bridge balls, in bridge radius %. + If 0, use Hexen default: ORBIT_RADIUS, regardless of bridge radius. + This value only matters if args[2] is not zero. +*/ + // Bridge ball ------------------------------------------------------------- class BridgeBall : Actor @@ -9,8 +34,6 @@ class BridgeBall : Actor +NOGRAVITY } - native void A_BridgeOrbit(); - States { Spawn: @@ -19,12 +42,38 @@ class BridgeBall : Actor Wait; } + void A_BridgeOrbit() + { + if (target == NULL) + { // Don't crash if somebody spawned this into the world + // independantly of a Bridge actor. + return; + } + // Set default values + // Every five tics, Hexen moved the ball 3/256th of a revolution. + double rotationspeed = 45. / 32 * 3 / 5; + double rotationradius = CustomBridge.ORBIT_RADIUS; + // If the bridge is custom, set non-default values if any. + + // Set angular speed; 1--128: counterclockwise rotation ~=1--180°; 129--255: clockwise rotation ~= 180--1° + if (target.args[3] > 128) rotationspeed = 45. / 32 * (target.args[3] - 256) / TICRATE; + else if (target.args[3] > 0) rotationspeed = 45. / 32 * (target.args[3]) / TICRATE; + // Set rotation radius + if (target.args[4]) rotationradius = ((target.args[4] * target.radius) / 100); + + Angle += rotationspeed; + SetOrigin(target.Vec3Angle(rotationradius, Angle, 0), true); + floorz = target.floorz; + ceilingz = target.ceilingz; + } } // The bridge itself ------------------------------------------------------- -class CustomBridge : Actor native +class CustomBridge : Actor { + const ORBIT_RADIUS = 15; + default { +SOLID @@ -36,8 +85,6 @@ class CustomBridge : Actor native RenderStyle "None"; } - native void A_BridgeInit(class balltype = "BridgeBall"); - states { Spawn: @@ -53,6 +100,67 @@ class CustomBridge : Actor native TLGL A 300; Stop; } + + override void BeginPlay () + { + if (args[2]) // Hexen bridge if there are balls + { + SetState(SeeState); + A_SetSize(args[0] ? args[0] : 32, args[1] ? args[1] : 2); + } + else // No balls? Then a Doom bridge. + { + A_SetSize(args[0] ? args[0] : 36, args[1] ? args[1] : 4); + A_SetRenderStyle(1., STYLE_Normal); + } + } + + override void OnDestroy() + { + // Hexen originally just set a flag to make the bridge balls remove themselves in A_BridgeOrbit. + // But this is not safe with custom bridge balls that do not necessarily call that function. + // So the best course of action is to look for all bridge balls here and destroy them ourselves. + + let it = ThinkerIterator.Create("Actor"); + Actor thing; + + while ((thing = Actor(it.Next()))) + { + if (thing.target == self) + { + thing.Destroy(); + } + } + Super.OnDestroy(); + } + + + void A_BridgeInit(class balltype = "BridgeBall") + { + if (balltype == NULL) + { + balltype = "BridgeBall"; + } + + double startangle = random[orbit]() * (360./256.); + + // Spawn triad into world -- may be more than a triad now. + int ballcount = args[2]==0 ? 3 : args[2]; + + for (int i = 0; i < ballcount; i++) + { + Actor ball = Spawn(balltype, Pos, ALLOW_REPLACE); + ball.Angle = startangle + (45./32) * (256/ballcount) * i; + ball.target = self; + + double rotationradius = ORBIT_RADIUS; + if (args[4]) rotationradius = (args[4] * radius) / 100; + + ball.SetOrigin(Vec3Angle(rotationradius, ball.Angle, 0), true); + ball.floorz = floorz; + ball.ceilingz = ceilingz; + } + } } // The Hexen bridge ------------------------------------------------------- @@ -79,7 +187,7 @@ class ZBridge : CustomBridge // Invisible bridge -------------------------------------------------------- -class InvisibleBridge : Actor native +class InvisibleBridge : Actor { default { @@ -98,6 +206,16 @@ class InvisibleBridge : Actor native TNT1 A -1; Stop; } + + override void BeginPlay () + { + Super.BeginPlay (); + if (args[0] || args[1]) + { + A_SetSize(args[0]? args[0] : radius, args[1]? args[1] : height); + } + } + } // And some invisible bridges from Skull Tag ------------------------------- diff --git a/wadsrc/static/zscript/shared/fastprojectile.txt b/wadsrc/static/zscript/shared/fastprojectile.txt index b1d509073..fd877bd83 100644 --- a/wadsrc/static/zscript/shared/fastprojectile.txt +++ b/wadsrc/static/zscript/shared/fastprojectile.txt @@ -1,6 +1,6 @@ // Fast projectiles -------------------------------------------------------- -class FastProjectile : Actor native +class FastProjectile : Actor { Default { @@ -37,5 +37,148 @@ class FastProjectile : Actor native } } + //---------------------------------------------------------------------------- + // + // AFastProjectile :: Tick + // + // Thinker for the ultra-fast projectiles used by Heretic and Hexen + // + //---------------------------------------------------------------------------- + + override void Tick () + { + ClearInterpolation(); + double oldz = pos.Z; + + if (!bNoTimeFreeze) + { + //Added by MC: Freeze mode. + if (globalfreeze || level.Frozen) + { + return; + } + } + + // [RH] Ripping is a little different than it was in Hexen + FCheckPosition tm; + tm.DoRipping = bRipper; + + int count = 8; + if (radius > 0) + { + while ( abs(Vel.X) > radius * count || abs(Vel.Y) > radius * count) + { + // we need to take smaller steps. + count += count; + } + } + + // Handle movement + if (Vel != (0, 0, 0) || (pos.Z != floorz)) + { + // force some lateral movement so that collision detection works as intended. + if (bMissile && Vel.X == 0 && Vel.Y == 0 && !IsZeroDamage()) + { + Vel.X = MinVel; + } + + Vector3 frac = Vel / count; + int changexy = frac.X != 0 || frac.Y != 0; + int ripcount = count / 8; + for (int i = 0; i < count; i++) + { + if (changexy) + { + if (--ripcount <= 0) + { + tm.ClearLastRipped(); // [RH] Do rip damage each step, like Hexen + } + + if (!TryMove (Pos.XY + frac.XY, true, NULL, tm)) + { // Blocked move + if (!bSkyExplode) + { + let l = tm.ceilingline; + if (l && + l.backsector && + l.backsector.GetTexture(sector.ceiling) == skyflatnum) + { + let posr = PosRelative(l.backsector); + if (pos.Z >= l.backsector.ceilingplane.ZatPoint(posr.XY)) + { + // Hack to prevent missiles exploding against the sky. + // Does not handle sky floors. + Destroy (); + return; + } + } + // [RH] Don't explode on horizon lines. + if (BlockingLine != NULL && BlockingLine.special == Line_Horizon) + { + Destroy (); + return; + } + } + + ExplodeMissile (BlockingLine, BlockingMobj); + return; + } + } + AddZ(frac.Z); + UpdateWaterLevel (); + oldz = pos.Z; + if (oldz <= floorz) + { // Hit the floor + + if (floorpic == skyflatnum && !bSkyExplode) + { + // [RH] Just remove the missile without exploding it + // if this is a sky floor. + Destroy (); + return; + } + + SetZ(floorz); + HitFloor (); + ExplodeMissile (NULL, NULL); + return; + } + if (pos.Z + height > ceilingz) + { // Hit the ceiling + + if (ceilingpic == skyflatnum && !bSkyExplode) + { + Destroy (); + return; + } + + SetZ(ceilingz - Height); + ExplodeMissile (NULL, NULL); + return; + } + if (frac != (0, 0, 0) && ripcount <= 0) + { + ripcount = count >> 3; + + // call the 'Effect' method. + Effect(); + } + } + } + if (!CheckNoDelay()) + return; // freed itself + // Advance the state + if (tics != -1) + { + if (tics > 0) tics--; + while (!tics) + { + if (!SetState (CurState.NextState)) + { // mobj was removed + return; + } + } + } + } } diff --git a/wadsrc/static/zscript/shared/sectoraction.txt b/wadsrc/static/zscript/shared/sectoraction.txt index 03278f2d3..b1d41a69f 100644 --- a/wadsrc/static/zscript/shared/sectoraction.txt +++ b/wadsrc/static/zscript/shared/sectoraction.txt @@ -1,6 +1,22 @@ class SectorAction : Actor native { + // this class uses health to define the activation type. + enum EActivation + { + SECSPAC_Enter = 1, + SECSPAC_Exit = 2, + SECSPAC_HitFloor = 4, + SECSPAC_HitCeiling = 8, + SECSPAC_Use = 16, + SECSPAC_UseWall = 32, + SECSPAC_EyesDive = 64, + SECSPAC_EyesSurface = 128, + SECSPAC_EyesBelowC = 256, + SECSPAC_EyesAboveC = 512, + SECSPAC_HitFakeFloor= 1024, + }; + default { +NOBLOCKMAP @@ -12,68 +28,112 @@ class SectorAction : Actor native // Triggered when entering sector ------------------------------------------- -class SecActEnter : SectorAction native +class SecActEnter : SectorAction { + Default + { + Health SECSPAC_Enter; + } } // Triggered when leaving sector -------------------------------------------- -class SecActExit : SectorAction native +class SecActExit : SectorAction { + Default + { + Health SECSPAC_Exit; + } } // Triggered when hitting sector's floor ------------------------------------ -class SecActHitFloor : SectorAction native +class SecActHitFloor : SectorAction { + Default + { + Health SECSPAC_HitFloor; + } } // Triggered when hitting sector's ceiling ---------------------------------- -class SecActHitCeil : SectorAction native +class SecActHitCeil : SectorAction { + Default + { + Health SECSPAC_HitCeiling; + } } // Triggered when using inside sector --------------------------------------- -class SecActUse : SectorAction native +class SecActUse : SectorAction { + Default + { + Health SECSPAC_Use; + } } // Triggered when using a sector's wall ------------------------------------- -class SecActUseWall : SectorAction native +class SecActUseWall : SectorAction { + Default + { + Health SECSPAC_UseWall; + } } // Triggered when eyes go below fake floor ---------------------------------- -class SecActEyesDive : SectorAction native +class SecActEyesDive : SectorAction { + Default + { + Health SECSPAC_EyesDive; + } } // Triggered when eyes go above fake floor ---------------------------------- -class SecActEyesSurface : SectorAction native +class SecActEyesSurface : SectorAction { + Default + { + Health SECSPAC_EyesSurface; + } } -// Triggered when eyes go below fake floor ---------------------------------- +// Triggered when eyes go below fake ceiling ---------------------------------- -class SecActEyesBelowC : SectorAction native +class SecActEyesBelowC : SectorAction { + Default + { + Health SECSPAC_EyesBelowC; + } } -// Triggered when eyes go above fake floor ---------------------------------- +// Triggered when eyes go above fake ceiling ---------------------------------- -class SecActEyesAboveC : SectorAction native +class SecActEyesAboveC : SectorAction { + Default + { + Health SECSPAC_EyesAboveC; + } } -// Triggered when eyes go below fake floor ---------------------------------- +// Triggered when hitting fake floor ---------------------------------- -class SecActHitFakeFloor : SectorAction native +class SecActHitFakeFloor : SectorAction { + Default + { + Health SECSPAC_HitFakeFloor; + } } // Music changer ---------------------------------- diff --git a/wadsrc/static/zscript/shared/skies.txt b/wadsrc/static/zscript/shared/skies.txt index 35077ee5c..72b86b14f 100644 --- a/wadsrc/static/zscript/shared/skies.txt +++ b/wadsrc/static/zscript/shared/skies.txt @@ -37,7 +37,7 @@ class LowerStackLookOnly : StackPoint } -class SectorSilencer native +class SectorSilencer : Actor { default { @@ -46,4 +46,19 @@ class SectorSilencer native +DONTSPLASH RenderStyle "None"; } + + override void BeginPlay () + { + Super.BeginPlay (); + CurSector.Flags |= Sector.SECF_SILENT; + } + + override void OnDestroy () + { + if (CurSector != null) + { + CurSector.Flags &= ~Sector.SECF_SILENT; + } + Super.OnDestroy(); + } }