diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 3589f01f4..952072d2a 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,8 +1,20 @@ -August 10, 2008 +August 10, 2008 (Changes by Graf Zahl) +- Removed DECORATE's ParseClass because it was only used to add data to fully + internal actor classes which no longer exist. +- Changed the state structure so that the Tics value doesn't need to be hacked + into misc1 with SF_BIGTIC anymore. +- Changed sprite processing so that sprite names are converted to indices + during parsing so that an additional postprocessing step is no longer needed. +- Fixed: Sprite names in DECORATE were case sensitive. +- Exported AActor's defaults to DECORATE and removed all code for the + internal property parser which is no longer needed. +- Converted the Heresiarch to DECORATE. - Added an Active and Inactive state for monsters. - Made the speed a parameter to A_RaiseMobj and A_SinkMobj and deleted GetRaiseSpeed and GetSinkSpeed. - Added some remaining DECORATE conversions for Hexen by Karate Chris. + +August 10, 2008 - Changed Windows to use the performance counter instead of rdtsc. - Changed Linux to use clock_gettime for profiling instead of rdtsc. This avoids potential erroneous results on multicore and variable speed diff --git a/src/actor.h b/src/actor.h index f6c7a7a87..c8e2286ec 100644 --- a/src/actor.h +++ b/src/actor.h @@ -774,10 +774,6 @@ public: FState *FindState (FName label) const; FState *FindState (FName label, FName sublabel, bool exact = false) const; bool HasSpecialDeathStates () const; - - static FState States[]; - - enum { S_NULL = 2, S_GENERICFREEZEDEATH = 3 }; }; class FActorIterator diff --git a/src/codepointers.h b/src/codepointers.h index 24817efdb..b583e3b99 100644 --- a/src/codepointers.h +++ b/src/codepointers.h @@ -251,7 +251,6 @@ WEAPON(MLightningAttack) ACTOR(LightningZap) ACTOR(LightningClip) ACTOR(LightningRemove) -ACTOR(FreeTargMobj) ACTOR(LastZap) ACTOR(ZapMimic) WEAPON(MStaffAttack) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 3f1217fd3..40ff7a742 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1177,7 +1177,7 @@ static int PatchFrame (int frameNum) { if (memcmp (OrgSprNames[val], sprites[i].name, 4) == 0) { - info->sprite.index = (int)i; + info->sprite = (int)i; break; } } @@ -1217,11 +1217,10 @@ static int PatchFrame (int frameNum) { Printf ("Frame %d: Subnumber must be in range [0,63]\n", frameNum); } - info->Tics = (tics+1) & 255; - info->Misc1 = ((tics+1)>>8) | misc1; + info->Tics = tics; + info->Misc1 = misc1; info->Frame = (frame & 0x3f) | - (frame & 0x8000 ? SF_FULLBRIGHT : 0) | - (tics > 254 ? SF_BIGTIC : 0); + (frame & 0x8000 ? SF_FULLBRIGHT : 0); } return result; diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index af5745c58..6f22a2716 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -727,8 +727,8 @@ void D_ReadUserInfoStrings (int i, BYTE **stream, bool update) if (players[i].mo != NULL) { if (players[i].cls != NULL && - players[i].mo->state->sprite.index == - GetDefaultByType (players[i].cls)->SpawnState->sprite.index) + players[i].mo->state->sprite == + GetDefaultByType (players[i].cls)->SpawnState->sprite) { // Only change the sprite if the player is using a standard one players[i].mo->sprite = skins[info->skin].sprite; players[i].mo->scaleX = skins[info->skin].ScaleX; diff --git a/src/f_finale.cpp b/src/f_finale.cpp index 3b022ef23..d1a932688 100644 --- a/src/f_finale.cpp +++ b/src/f_finale.cpp @@ -588,7 +588,7 @@ void F_StartCast (void) wipegamestate = GS_FORCEWIPE; castnum = 0; caststate = castorder[castnum].info->SeeState; - castsprite = caststate->sprite.index; + castsprite = caststate->sprite; casttranslation = NULL; casttics = caststate->GetTics (); castdeath = false; @@ -638,7 +638,7 @@ void F_CastTicker (void) } else { - castsprite = caststate->sprite.index; + castsprite = caststate->sprite; casttranslation = NULL; } castframes = 0; diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index a42bd3c9e..5780b05cb 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -337,7 +337,7 @@ void A_FireCGun (AActor *actor) int theflash = clamp (int(player->psprites[ps_weapon].state - atk), 0, 1); - if (flash[theflash].sprite.index != flash->sprite.index) + if (flash[theflash].sprite != flash->sprite) { theflash = 0; } diff --git a/src/g_doom/a_scriptedmarine.cpp b/src/g_doom/a_scriptedmarine.cpp index 180a8b55b..d92cca166 100644 --- a/src/g_doom/a_scriptedmarine.cpp +++ b/src/g_doom/a_scriptedmarine.cpp @@ -109,7 +109,7 @@ void AScriptedMarine::Tick () Super::Tick (); // Override the standard sprite, if desired - if (SpriteOverride != 0 && sprite == States[0].sprite.index) + if (SpriteOverride != 0 && sprite == GetClass()->ActorInfo->OwnedStates[0].sprite) { sprite = SpriteOverride; } @@ -593,7 +593,7 @@ void AScriptedMarine::SetSprite (const PClass *source) { if (source == NULL || source->ActorInfo == NULL) { // A valid actor class wasn't passed, so use the standard sprite - SpriteOverride = sprite = States[0].sprite.index; + SpriteOverride = sprite = GetClass()->ActorInfo->OwnedStates[0].sprite; // Copy the standard player's scaling AActor * playerdef = GetDefaultByName("DoomPlayer"); if (playerdef == NULL) playerdef = GetDefaultByType(RUNTIME_CLASS(AScriptedMarine)); @@ -602,7 +602,7 @@ void AScriptedMarine::SetSprite (const PClass *source) } else { // Use the same sprite the passed class spawns with - SpriteOverride = sprite = GetDefaultByType (source)->SpawnState->sprite.index; + SpriteOverride = sprite = GetDefaultByType (source)->SpawnState->sprite; scaleX = GetDefaultByType(source)->scaleX; scaleY = GetDefaultByType(source)->scaleY; } diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index af3ee1484..e2ea25e93 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -27,7 +27,6 @@ void A_LightningZap (AActor *); void A_ZapMimic (AActor *); void A_LastZap (AActor *); void A_LightningRemove (AActor *); -void A_FreeTargMobj (AActor *); // Lightning ---------------------------------------------------------------- diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 59f82b91f..3ea52cccb 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1243,15 +1243,20 @@ void APowerTargeter::DoEffect () PositionAccuracy (); if (EffectTics < 5*TICRATE) { - if (EffectTics & 32) + FState *state = FindState("Targeter"); + + if (state != NULL) { - P_SetPsprite (player, ps_targetright, NULL); - P_SetPsprite (player, ps_targetleft, &States[1]); - } - else if (EffectTics & 16) - { - P_SetPsprite (player, ps_targetright, &States[2]); - P_SetPsprite (player, ps_targetleft, NULL); + if (EffectTics & 32) + { + P_SetPsprite (player, ps_targetright, NULL); + P_SetPsprite (player, ps_targetleft, state+1); + } + else if (EffectTics & 16) + { + P_SetPsprite (player, ps_targetright, state+2); + P_SetPsprite (player, ps_targetleft, NULL); + } } } } diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 29bdf4ba6..dcf8f3838 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -634,7 +634,7 @@ AInventory *AInventory::CreateTossable () // If this actor lacks a SpawnState, don't drop it. (e.g. A base weapon // like the fist can't be dropped because you'll never see it.) - if (SpawnState == &AActor::States[AActor::S_NULL] || + if (SpawnState == ::GetDefault()->SpawnState || SpawnState == NULL) { return NULL; diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 747ea273a..d197ce083 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -61,7 +61,7 @@ bool AWeapon::TryPickup (AActor *toucher) { FState * ReadyState = FindState(NAME_Ready); if (ReadyState != NULL && - ReadyState->GetFrame() < sprites[ReadyState->sprite.index].numframes) + ReadyState->GetFrame() < sprites[ReadyState->sprite].numframes) { return Super::TryPickup (toucher); } diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 39496085e..e321797d9 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -397,12 +397,12 @@ static void DrawOneKey(int xo, int & x, int & y, int & c, AInventory * inv) { icon = AltIcon; } - else if (inv->SpawnState && inv->SpawnState->sprite.index!=0) + else if (inv->SpawnState && inv->SpawnState->sprite!=0) { FState * state = inv->SpawnState; - if (state && (unsigned)state->sprite.index < (unsigned)sprites.Size ()) + if (state && (unsigned)state->sprite < (unsigned)sprites.Size ()) { - spritedef_t * sprdef = &sprites[state->sprite.index]; + spritedef_t * sprdef = &sprites[state->sprite]; spriteframe_t * sprframe = &SpriteFrames[sprdef->spriteframes + state->GetFrame()]; icon = sprframe->Texture[0]; } @@ -592,18 +592,18 @@ static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon) if (picnum.isNull()) { - if (weapon->SpawnState && weapon->SpawnState->sprite.index!=0) + if (weapon->SpawnState && weapon->SpawnState->sprite!=0) { state = weapon->SpawnState; } // no spawn state - now try the ready state - else if ((ReadyState = weapon->FindState(NAME_Ready)) && ReadyState->sprite.index!=0) + else if ((ReadyState = weapon->FindState(NAME_Ready)) && ReadyState->sprite!=0) { state = ReadyState; } - if (state && (unsigned)state->sprite.index < (unsigned)sprites.Size ()) + if (state && (unsigned)state->sprite < (unsigned)sprites.Size ()) { - spritedef_t * sprdef = &sprites[state->sprite.index]; + spritedef_t * sprdef = &sprites[state->sprite]; spriteframe_t * sprframe = &SpriteFrames[sprdef->spriteframes + state->GetFrame()]; picnum = sprframe->Texture[0]; diff --git a/src/info.cpp b/src/info.cpp index 5f783130a..ec854f728 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -32,9 +32,6 @@ ** ** This is completely different from Doom's info.c. ** -** The primary advancement over Doom's system is that actors can be defined -** across multiple files without having to recompile most of the source -** whenever one changes. */ @@ -93,14 +90,16 @@ FArchive &operator<< (FArchive &arc, FState *&state) } else { + /* this was never working as intended. I_Error ("Cannot find owner for state %p:\n" "%s %c%c %3d [%p] -> %p", state, - sprites[state->sprite.index].name, + sprites[state->sprite].name, state->GetFrame() + 'A', state->GetFullbright() ? '*' : ' ', state->GetTics(), state->GetAction(), state->GetNextState()); + */ } } else @@ -134,27 +133,9 @@ FArchive &operator<< (FArchive &arc, FState *&state) const PClass *FState::StaticFindStateOwner (const FState *state) { - const FActorInfo *info = RUNTIME_CLASS(AActor)->ActorInfo; - - if (state >= info->OwnedStates && - state < info->OwnedStates + info->NumOwnedStates) - { - return RUNTIME_CLASS(AActor); - } - - TAutoSegIterator reg; - while (++reg != NULL) - { - if (state >= reg->OwnedStates && - state < reg->OwnedStates + reg->NumOwnedStates) - { - return reg->Class; - } - } - for (unsigned int i = 0; i < PClass::m_RuntimeActors.Size(); ++i) { - info = PClass::m_RuntimeActors[i]->ActorInfo; + FActorInfo *info = PClass::m_RuntimeActors[i]->ActorInfo; if (state >= info->OwnedStates && state < info->OwnedStates + info->NumOwnedStates) { @@ -209,30 +190,6 @@ int GetSpriteIndex(const char * spritename) } -//========================================================================== -// -// Change sprite names to indices -// -//========================================================================== - -void ProcessStates (FState *states, int numstates) -{ - int sprite = -1; - - if (states == NULL) - return; - while (--numstates >= 0) - { - if (sprite == -1 || strncmp (sprites[sprite].name, states->sprite.name, 4) != 0) - { - sprite = GetSpriteIndex(states->sprite.name); - } - states->sprite.index = sprite; - states++; - } -} - - //========================================================================== // // @@ -240,8 +197,6 @@ void ProcessStates (FState *states, int numstates) void FActorInfo::StaticInit () { - TAutoSegIterator reg; - if (sprites.Size() == 0) { spritedef_t temp; @@ -257,26 +212,6 @@ void FActorInfo::StaticInit () sprites.Push (temp); } - // Attach FActorInfo structures to every actor's PClass - while (++reg != NULL) - { - reg->Class->ActorInfo = reg; - if (reg->OwnedStates && - (unsigned)reg->OwnedStates->sprite.index < sprites.Size ()) - { - Printf ("\x1c+%s is stateless. Fix its default list.\n", - reg->Class->TypeName.GetChars()); - } - ProcessStates (reg->OwnedStates, reg->NumOwnedStates); - } - - // Now build default instances of every actor - reg.Reset (); - while (++reg != NULL) - { - reg->BuildDefaults (); - } - Printf ("LoadDecorations: Load external actors.\n"); LoadDecorations (); } @@ -292,14 +227,6 @@ void FActorInfo::StaticSetActorNums () memset (SpawnableThings, 0, sizeof(SpawnableThings)); DoomEdMap.Empty (); - // For every actor valid for this game, add it to the - // SpawnableThings array and DoomEdMap - TAutoSegIterator reg; - while (++reg != NULL) - { - reg->RegisterIDs (); - } - for (unsigned int i = 0; i < PClass::m_RuntimeActors.Size(); ++i) { PClass::m_RuntimeActors[i]->ActorInfo->RegisterIDs (); @@ -522,30 +449,6 @@ FState *FActorInfo::FindState (int numnames, FName *names, bool exact) const return best; } -//=========================================================================== -// -// Changes a single state -// -// If the given state does not exist it won't be changed -// This is only used for postprocessing of actors that use different -// spawn states for different games so more complex checks are not needed. -// -//=========================================================================== - -void FActorInfo::ChangeState (FName label, FState * newstate) const -{ - FStateLabel *slabel; - - if (StateList != NULL) - { - slabel = StateList->FindLabel (label); - if (slabel != NULL) - { - slabel->State = newstate; - } - } -} - //========================================================================== // // Creates a list of names from a string. Dots are used as separator diff --git a/src/info.h b/src/info.h index e745714e4..a783c0573 100644 --- a/src/info.h +++ b/src/info.h @@ -80,20 +80,11 @@ #include "tarray.h" const BYTE SF_FULLBRIGHT = 0x40; -const BYTE SF_BIGTIC = 0x80; struct FState { - union - { -#if _MSC_VER - char name[4]; -#else - char name[8]; // 4 for name, 1 for '\0', 3 for pad -#endif - int index; - } sprite; - BYTE Tics; + WORD sprite; + SWORD Tics; SBYTE Misc1; BYTE Misc2; BYTE Frame; @@ -103,7 +94,7 @@ struct FState inline int GetFrame() const { - return Frame & ~(SF_FULLBRIGHT|SF_BIGTIC); + return Frame & ~(SF_FULLBRIGHT); } inline int GetFullbright() const { @@ -111,23 +102,11 @@ struct FState } inline int GetTics() const { - int tics; -#ifdef WORDS_BIGENDIAN - tics = Frame & SF_BIGTIC ? (Tics|((BYTE)Misc1<<8))-1 : Tics-1; -#else - // Use some trickery to help the compiler create this without - // using any jumps. - tics = ((*(SDWORD *)&Tics) & ((*(SDWORD *)&Tics) < 0 ? 0xffff : 0xff)) - 1; -#endif -#if TICRATE == 35 - return tics; -#else - return tics > 0 ? tics * TICRATE / 35 : tics; -#endif + return Tics; } inline int GetMisc1() const { - return Frame & SF_BIGTIC ? 0 : Misc1; + return Misc1; } inline int GetMisc2() const { @@ -143,7 +122,7 @@ struct FState } inline void SetFrame(BYTE frame) { - Frame = (Frame & (SF_FULLBRIGHT|SF_BIGTIC)) | (frame-'A'); + Frame = (Frame & SF_FULLBRIGHT) | (frame-'A'); } static const PClass *StaticFindStateOwner (const FState *state); @@ -172,34 +151,6 @@ struct FStateLabels FArchive &operator<< (FArchive &arc, FState *&state); -#if _MSC_VER -#define _S__SPRITE_(spr) \ - { {{(char)(#@spr>>24),(char)((#@spr>>16)&255),(char)((#@spr>>8)&255),(char)(#@spr&255)}} -#else -#define _S__SPRITE_(spr) \ - { {{#spr}} -#endif - -#define _S__FR_TIC_(spr,frm,tic,m1,m2,cmd,next) \ - _S__SPRITE_(spr), (tic+1)&255, (m1)|((tic+1)>>8), m2, (tic>254)?(SF_BIGTIC|(frm)):(frm), cmd, next } - -#define S_NORMAL2(spr,frm,tic,cmd,next,m1,m2) \ - _S__FR_TIC_(spr, (frm) - 'A', tic, m1, m2, cmd, next) - -#define S_BRIGHT2(spr,frm,tic,cmd,next,m1,m2) \ - _S__FR_TIC_(spr, ((frm) - 'A') | SF_FULLBRIGHT, tic, m1, m2, cmd, next) - -/* #defines its own, completely unrelated S_NORMAL. - * Since winbase.h will only be included in Win32-specific files that - * don't define any actors, we can safely avoid defining it here. - */ - -#ifndef S_NORMAL -#define S_NORMAL(spr,frm,tic,cmd,next) S_NORMAL2(spr,frm,tic,cmd,next,0,0) -#endif -#define S_BRIGHT(spr,frm,tic,cmd,next) S_BRIGHT2(spr,frm,tic,cmd,next,0,0) - - #ifndef EGAMETYPE #define EGAMETYPE enum EGameType @@ -215,170 +166,6 @@ enum EGameType }; #endif -enum -{ - ADEFTYPE_Byte = 0x0000, - ADEFTYPE_FixedMul = 0x4000, // one byte, multiplied by FRACUNIT - ADEFTYPE_Word = 0x8000, - ADEFTYPE_Long = 0xC000, - ADEFTYPE_MASK = 0xC000, - - // These first properties are always strings - ADEF_SeeSound = 1, - ADEF_AttackSound, - ADEF_PainSound, - ADEF_DeathSound, - ADEF_ActiveSound, - ADEF_UseSound, - ADEF_Weapon_UpSound, - ADEF_Weapon_ReadySound, - ADEF_Inventory_PickupSound, - ADEF_Tag, // Used by Strife to name items - ADEF_Weapon_AmmoType1, - ADEF_Weapon_AmmoType2, - ADEF_Weapon_SisterType, - ADEF_Weapon_ProjectileType, - ADEF_PowerupGiver_Powerup, - ADEF_Inventory_Icon, - ADEF_Obituary, - ADEF_HitObituary, - ADEF_Inventory_PickupMsg, - // [GRB] Player class properties - ADEF_PlayerPawn_CrouchSprite, - ADEF_PlayerPawn_DisplayName, - ADEF_PlayerPawn_SoundClass, - ADEF_PlayerPawn_Face, - ADEF_PlayerPawn_ScoreIcon, - ADEF_PlayerPawn_MorphWeapon, - ADEF_LastString = ADEF_PlayerPawn_MorphWeapon, - - // The rest of the properties use their type field (upper 2 bits) - ADEF_XScale, - ADEF_YScale, - ADEF_SpawnHealth, - ADEF_ReactionTime, - ADEF_PainChance, - ADEF_Speed, - ADEF_Radius, - ADEF_Height, - ADEF_Mass, - ADEF_Damage, - ADEF_DamageType, - ADEF_Flags, // Use these flags exactly - ADEF_Flags2, // " - ADEF_Flags3, // " - ADEF_Flags4, // " - ADEF_Flags5, // " - ADEF_FlagsSet, // Or these flags with previous - ADEF_Flags2Set, // " - ADEF_Flags3Set, // " - ADEF_Flags4Set, // " - ADEF_Flags5Set, // " - ADEF_FlagsClear, // Clear these flags from previous - ADEF_Flags2Clear, // " - ADEF_Flags3Clear, // " - ADEF_Flags4Clear, // " - ADEF_Flags5Clear, // " - ADEF_Alpha, - ADEF_RenderStyle, - ADEF_RenderFlags, - ADEF_Translation, - ADEF_MinMissileChance, - ADEF_MeleeRange, - ADEF_MaxDropOffHeight, - ADEF_MaxStepHeight, - ADEF_BounceFactor, - ADEF_WallBounceFactor, - ADEF_BounceCount, - ADEF_FloatSpeed, - ADEF_RDFactor, - ADEF_FXFlags, - ADEF_Gravity, - - ADEF_SpawnState, - ADEF_SeeState, - ADEF_PainState, - ADEF_MeleeState, - ADEF_MissileState, - ADEF_CrashState, - ADEF_DeathState, - ADEF_XDeathState, - ADEF_BDeathState, - ADEF_IDeathState, - ADEF_EDeathState, - ADEF_RaiseState, - ADEF_WoundState, - - ADEF_StrifeType, // Not really a property. Used to init StrifeTypes[] in p_conversation.h. - ADEF_StrifeTeaserType, - ADEF_StrifeTeaserType2, - - ADEF_Inventory_Amount, - ADEF_Inventory_MaxAmount, - ADEF_Inventory_DefMaxAmount, - ADEF_Inventory_RespawnTics, - ADEF_Inventory_FlagsSet, - ADEF_Inventory_FlagsClear, - ADEF_Inventory_PickupFlash, - - ADEF_PuzzleItem_Number, // Identifies the puzzle item for UsePuzzleItem - - ADEF_BasicArmorPickup_SavePercent, - ADEF_BasicArmorPickup_SaveAmount, - ADEF_BasicArmorBonus_SavePercent, - ADEF_BasicArmorBonus_SaveAmount, - ADEF_BasicArmorBonus_MaxSaveAmount, - ADEF_HexenArmor_ArmorAmount, - - ADEF_Powerup_EffectTics, - ADEF_Powerup_Color, - ADEF_PowerupGiver_EffectTics, - - ADEF_Ammo_BackpackAmount, - ADEF_Ammo_BackpackMaxAmount, - ADEF_Ammo_DropAmount, - - ADEF_Weapon_Flags, - ADEF_Weapon_FlagsSet, - ADEF_Weapon_AmmoGive1, - ADEF_Weapon_AmmoGive2, - ADEF_Weapon_AmmoUse1, - ADEF_Weapon_AmmoUse2, - ADEF_Weapon_Kickback, - ADEF_Weapon_YAdjust, - ADEF_Weapon_SelectionOrder, - ADEF_Weapon_MoveCombatDist, - ADEF_Weapon_UpState, - ADEF_Weapon_DownState, - ADEF_Weapon_ReadyState, - ADEF_Weapon_AtkState, - ADEF_Weapon_HoldAtkState, - ADEF_Weapon_FlashState, - ADEF_Sigil_NumPieces, - - // [GRB] Player class properties - ADEF_PlayerPawn_JumpZ, - ADEF_PlayerPawn_ViewHeight, - ADEF_PlayerPawn_ForwardMove1, - ADEF_PlayerPawn_ForwardMove2, - ADEF_PlayerPawn_SideMove1, - ADEF_PlayerPawn_SideMove2, - ADEF_PlayerPawn_ColorRange, - ADEF_PlayerPawn_SpawnMask, - ADEF_PlayerPawn_AttackZOffset, - - // The following are not properties but affect how the list is parsed - ADEF_FirstCommand, - ADEF_SkipSuper = ADEF_FirstCommand, // Take defaults from AActor instead of superclass(es) - - ADEF_EOL = 0xED5E // End Of List -}; - -#if _MSC_VER -// nonstandard extension used : zero-sized array in struct/union -#pragma warning(disable:4200) -#endif - typedef TMap DmgFactors; typedef TMap PainChanceList; @@ -394,9 +181,6 @@ struct FActorInfo FState *FindState (FName name) const; FState *FindState (int numnames, FName *names, bool exact=false) const; - void ChangeState (FName label, FState * newstate) const; - - FActorInfo *GetReplacement (); FActorInfo *GetReplacee (); @@ -411,20 +195,8 @@ struct FActorInfo FStateLabels * StateList; DmgFactors *DamageFactors; PainChanceList * PainChances; - -#if _MSC_VER - // A 0-terminated list of default properties - BYTE DefaultList[]; -#else - // A function to initialize the defaults for this actor - void (*DefaultsConstructor)(); -#endif }; -#if _MSC_VER -#pragma warning(default:4200) -#endif - class FDoomEdMap { public: @@ -454,8 +226,5 @@ extern FDoomEdMap DoomEdMap; int GetSpriteIndex(const char * spritename); void MakeStateNameList(const char * fname, TArray * out); -void ProcessStates (FState *states, int numstates); - -#include "infomacros.h" #endif // __INFO_H__ diff --git a/src/infodefaults.cpp b/src/infodefaults.cpp deleted file mode 100644 index 215bf56c5..000000000 --- a/src/infodefaults.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/* -** infodefaults.cpp -** Parses default lists to create default copies of actors -** -**--------------------------------------------------------------------------- -** Copyright 1998-2007 Randy Heit -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#include -#include "actor.h" -#include "info.h" -#include "s_sound.h" -#include "p_conversation.h" -#include "a_pickups.h" -#include "gi.h" -#include "a_artifacts.h" -#include "a_keys.h" -#include "i_system.h" -#include "r_data.h" -#include "w_wad.h" -#include "a_strifeglobal.h" -#include "thingdef/thingdef.h" - -void FActorInfo::BuildDefaults () -{ - if (Class->Defaults == NULL) - { - Class->Defaults = new BYTE[Class->Size]; - if (Class == RUNTIME_CLASS(AActor)) - { - memset (Class->Defaults, 0, Class->Size); - } - else - { - PClass *parent; - - parent = Class->ParentClass; - parent->ActorInfo->BuildDefaults (); - Class->Meta = parent->Meta; - Class->Symbols.SetParentTable (&parent->Symbols); - assert (Class->Size >= parent->Size); - memcpy (Class->Defaults, parent->Defaults, parent->Size); - if (Class->Size > parent->Size) - { - memset (Class->Defaults + parent->Size, 0, Class->Size - parent->Size); - } - } - ApplyDefaults (Class->Defaults); - } -} - -static FState *DefaultStates (PClass *type) -{ - FState *states = type->ActorInfo->OwnedStates; - - if (states == NULL) - { - do - { - type = type->ParentClass; - states = type->ActorInfo->OwnedStates; - } while (states == NULL && type != RUNTIME_CLASS(AActor)); - } - return states; -} - -static PClass *sgClass; -static BYTE *sgDefaults; - - -static void ApplyActorDefault (int defnum, const char *datastr, int dataint) -{ - FSoundID datasound; - FState *datastate = NULL; - const PClass *datatype; - - if (defnum <= ADEF_LastString) - { - if (defnum <= ADEF_Inventory_PickupSound) - { - datasound = datastr; - } - } - else if (defnum > ADEF_LastString && dataint >= 0 && dataint < PROP_CLEAR_STATE) - { - datastate = DefaultStates (sgClass) + dataint; - } - - // Different casts for the same thing - AActor *const actor = (AActor *)sgDefaults; - APowerupGiver *const giver = (APowerupGiver *)sgDefaults; - AInventory *const item = (AInventory *)sgDefaults; - ABasicArmorBonus *const armorb = (ABasicArmorBonus *)sgDefaults; - ABasicArmorPickup *const armorp = (ABasicArmorPickup *)sgDefaults; - APuzzleItem *const puzzl = (APuzzleItem *)sgDefaults; - APowerup *const power = (APowerup *)sgDefaults; - AWeapon *const weapon = (AWeapon *)sgDefaults; - ASigil *const sigil = (ASigil *)sgDefaults; - AAmmo *const ammo = (AAmmo *)sgDefaults; - APlayerPawn *const player = (APlayerPawn *)sgDefaults; - - switch (defnum) - { - case ADEF_Weapon_ProjectileType: - case ADEF_PowerupGiver_Powerup: - datatype = PClass::FindClass (datastr); - if (datatype == NULL) - { - I_FatalError ("Unknown class %s in %s's default list", datastr, sgClass->TypeName.GetChars()); - } - break; - - default: - datatype = NULL; - } - - switch (defnum) - { - case ADEF_SeeSound: actor->SeeSound = datasound; break; - case ADEF_AttackSound: actor->AttackSound = datasound; break; - case ADEF_PainSound: actor->PainSound = datasound; break; - case ADEF_DeathSound: actor->DeathSound = datasound; break; - case ADEF_ActiveSound: actor->ActiveSound = datasound; break; - case ADEF_UseSound: actor->UseSound = datasound; break; - case ADEF_Tag: - { - char name[256]; - int i; - - // Replace underscores with spaces - i = 0; - do - { - name[i] = datastr[i] == '_' ? ' ' : datastr[i]; - } while (datastr[i++] != 0); - sgClass->Meta.SetMetaString (AMETA_StrifeName, name); - break; - } - - case ADEF_Obituary: - sgClass->Meta.SetMetaString (AMETA_Obituary, datastr); - break; - - case ADEF_HitObituary: - sgClass->Meta.SetMetaString (AMETA_HitObituary, datastr); - break; - - case ADEF_Inventory_PickupMsg: - sgClass->Meta.SetMetaString (AIMETA_PickupMessage, datastr); - break; - - case ADEF_PowerupGiver_Powerup: - giver->PowerupType = datatype; - break; - - case ADEF_Inventory_Icon: - item->Icon = TexMan.AddPatch (datastr); - if (!item->Icon.isValid()) - { - item->Icon = TexMan.AddPatch (datastr, ns_sprites); - } - break; - - case ADEF_XScale: actor->scaleX = dataint; break; - case ADEF_YScale: actor->scaleY = dataint; break; - case ADEF_SpawnHealth: actor->health = dataint; break; - case ADEF_ReactionTime: actor->reactiontime = dataint; break; - case ADEF_PainChance: actor->PainChance = dataint; break; - case ADEF_Speed: actor->Speed = dataint; break; - case ADEF_FloatSpeed: actor->FloatSpeed = dataint; break; - case ADEF_Radius: actor->radius = dataint; break; - case ADEF_Height: actor->height = dataint; break; - case ADEF_Mass: actor->Mass = dataint; break; - case ADEF_Damage: actor->Damage = dataint; break; - case ADEF_DamageType: actor->DamageType = (ENamedName)dataint; break; - case ADEF_Flags: actor->flags = dataint; break; - case ADEF_Flags2: actor->flags2 = dataint; break; - case ADEF_Flags3: actor->flags3 = dataint; break; - case ADEF_Flags4: actor->flags4 = dataint; break; - case ADEF_Flags5: actor->flags5 = dataint; break; - case ADEF_FlagsSet: actor->flags |= dataint; break; - case ADEF_Flags2Set: actor->flags2 |= dataint; break; - case ADEF_Flags3Set: actor->flags3 |= dataint; break; - case ADEF_Flags4Set: actor->flags4 |= dataint; break; - case ADEF_Flags5Set: actor->flags5 |= dataint; break; - case ADEF_FlagsClear: actor->flags &= ~dataint; break; - case ADEF_Flags2Clear: actor->flags2 &= ~dataint; break; - case ADEF_Flags3Clear: actor->flags3 &= ~dataint; break; - case ADEF_Flags4Clear: actor->flags4 &= ~dataint; break; - case ADEF_Flags5Clear: actor->flags5 &= ~dataint; break; - case ADEF_Alpha: actor->alpha = dataint; break; - case ADEF_RenderStyle: actor->RenderStyle = ERenderStyle(dataint); break; - case ADEF_RenderFlags: actor->renderflags = dataint; break; - case ADEF_Translation: actor->Translation = dataint; break; - case ADEF_MinMissileChance: actor->MinMissileChance = dataint; break; - case ADEF_MeleeRange: actor->meleerange = dataint; break; - case ADEF_MaxDropOffHeight: actor->MaxDropOffHeight = dataint; break; - case ADEF_MaxStepHeight: actor->MaxStepHeight = dataint; break; - case ADEF_BounceFactor: actor->bouncefactor = dataint; break; - case ADEF_WallBounceFactor: actor->wallbouncefactor = dataint; break; - case ADEF_BounceCount: actor->bouncecount = dataint; break; - case ADEF_RDFactor: sgClass->Meta.SetMetaFixed (AMETA_RDFactor, dataint); break; - case ADEF_FXFlags: actor->effects = dataint; break; - case ADEF_Gravity: actor->gravity = dataint; break; - - case ADEF_SpawnState: AddState("Spawn", datastate); break; - case ADEF_SeeState: AddState("See", datastate); break; - case ADEF_PainState: AddState("Pain", datastate); break; - case ADEF_MeleeState: AddState("Melee", datastate); break; - case ADEF_MissileState: AddState("Missile", datastate); break; - case ADEF_CrashState: AddState("Crash", datastate); break; - case ADEF_DeathState: AddState("Death", datastate); break; - case ADEF_XDeathState: AddState("XDeath", datastate); break; - case ADEF_BDeathState: AddState("Burn", datastate); break; - case ADEF_IDeathState: AddState("Ice", datastate); break; - case ADEF_EDeathState: AddState("Disintegrate", datastate);break; - case ADEF_RaiseState: AddState("Raise", datastate); break; - case ADEF_WoundState: AddState("Wound", datastate); break; - - case ADEF_StrifeType: if (!(gameinfo.flags & GI_SHAREWARE)) StrifeTypes[dataint] = sgClass; break; - case ADEF_StrifeTeaserType: - if ((gameinfo.flags & (GI_SHAREWARE|GI_TEASER2)) == (GI_SHAREWARE)) - StrifeTypes[dataint] = sgClass; - break; - case ADEF_StrifeTeaserType2: - if ((gameinfo.flags & (GI_SHAREWARE|GI_TEASER2)) == (GI_SHAREWARE|GI_TEASER2)) - StrifeTypes[dataint] = sgClass; - break; - - - case ADEF_Inventory_FlagsSet: item->ItemFlags |= dataint; break; - case ADEF_Inventory_FlagsClear: item->ItemFlags &= ~dataint; break; - case ADEF_Inventory_PickupFlash:if(dataint) { item->PickupFlash = fuglyname("PickupFlash"); } else { item->PickupFlash = NULL; } break; - case ADEF_Inventory_Amount: item->Amount = dataint; break; - case ADEF_Inventory_RespawnTics:item->RespawnTics = dataint; break; - case ADEF_Inventory_MaxAmount: item->MaxAmount = dataint; break; - case ADEF_Inventory_DefMaxAmount: - // In Heretic, the maximum number of artifacts of one kind you can carry is 16. - // In Hexen, it was upped to 25. - item->MaxAmount = gameinfo.gametype == GAME_Heretic ? 16 : 25; - break; - case ADEF_Inventory_PickupSound:item->PickupSound = datasound; break; - - case ADEF_BasicArmorPickup_SavePercent: armorp->SavePercent = dataint; break; - case ADEF_BasicArmorPickup_SaveAmount: armorp->SaveAmount = dataint; break; - case ADEF_BasicArmorBonus_SavePercent: armorb->SavePercent = dataint; break; - case ADEF_BasicArmorBonus_SaveAmount: armorb->SaveAmount = dataint; break; - case ADEF_BasicArmorBonus_MaxSaveAmount: armorb->MaxSaveAmount = dataint; break; - case ADEF_HexenArmor_ArmorAmount: item->Amount = dataint; break; - - case ADEF_PuzzleItem_Number: puzzl->PuzzleItemNumber = dataint; break; - - case ADEF_PowerupGiver_EffectTics:giver->EffectTics = dataint; break; - - case ADEF_Powerup_EffectTics: power->EffectTics = dataint; break; - case ADEF_Powerup_Color: power->BlendColor = dataint; break; - - case ADEF_Ammo_BackpackAmount: ammo->BackpackAmount = dataint; break; - case ADEF_Ammo_BackpackMaxAmount:ammo->BackpackMaxAmount = dataint; break; - case ADEF_Ammo_DropAmount: sgClass->Meta.SetMetaInt (AIMETA_DropAmount, dataint); break; - - case ADEF_Weapon_Flags: weapon->WeaponFlags = dataint; break; - case ADEF_Weapon_FlagsSet: weapon->WeaponFlags |= dataint; break; - case ADEF_Weapon_UpSound: weapon->UpSound = datasound; break; - case ADEF_Weapon_ReadySound: weapon->ReadySound = datasound; break; - case ADEF_Weapon_SisterType: weapon->SisterWeaponType = fuglyname(datastr); break; - case ADEF_Weapon_ProjectileType:weapon->ProjectileType = datatype; break; - case ADEF_Weapon_AmmoType1: weapon->AmmoType1 = fuglyname(datastr); break; - case ADEF_Weapon_AmmoType2: weapon->AmmoType2 = fuglyname(datastr); break; - case ADEF_Weapon_AmmoGive1: weapon->AmmoGive1 = dataint; break; - case ADEF_Weapon_AmmoGive2: weapon->AmmoGive2 = dataint; break; - case ADEF_Weapon_AmmoUse1: weapon->AmmoUse1 = dataint; break; - case ADEF_Weapon_AmmoUse2: weapon->AmmoUse2 = dataint; break; - case ADEF_Weapon_Kickback: weapon->Kickback = dataint; break; - case ADEF_Weapon_YAdjust: weapon->YAdjust = (dataint<<8)>>8; break; - case ADEF_Weapon_SelectionOrder:weapon->SelectionOrder = dataint; break; - case ADEF_Weapon_MoveCombatDist:weapon->MoveCombatDist = dataint; break; - - case ADEF_Weapon_UpState: AddState("Select", datastate); break; - case ADEF_Weapon_DownState: AddState("Deselect", datastate); break; - case ADEF_Weapon_ReadyState: AddState("Ready", datastate); break; - case ADEF_Weapon_AtkState: AddState("Fire", datastate); break; - case ADEF_Weapon_HoldAtkState: AddState("Hold", datastate); break; - case ADEF_Weapon_FlashState: AddState("Flash", datastate); break; - case ADEF_Sigil_NumPieces: sigil->NumPieces = dataint; break; - - // [GRB] Player class properties - case ADEF_PlayerPawn_JumpZ: player->JumpZ = dataint; break; - case ADEF_PlayerPawn_AttackZOffset: player->AttackZOffset = dataint; break; - case ADEF_PlayerPawn_ViewHeight: player->ViewHeight = dataint; break; - case ADEF_PlayerPawn_ForwardMove1: player->ForwardMove1 = dataint; break; - case ADEF_PlayerPawn_ForwardMove2: player->ForwardMove2 = dataint; break; - case ADEF_PlayerPawn_SideMove1: player->SideMove1 = dataint; break; - case ADEF_PlayerPawn_SideMove2: player->SideMove2 = dataint; break; - case ADEF_PlayerPawn_ColorRange: sgClass->Meta.SetMetaInt (APMETA_ColorRange, dataint); break; - case ADEF_PlayerPawn_CrouchSprite: player->crouchsprite = GetSpriteIndex(datastr); break; - case ADEF_PlayerPawn_SpawnMask: player->SpawnMask = dataint; break; - case ADEF_PlayerPawn_MorphWeapon: player->MorphWeapon = FName(datastr); break; - - case ADEF_PlayerPawn_DisplayName: - sgClass->Meta.SetMetaString (APMETA_DisplayName, datastr); - break; - case ADEF_PlayerPawn_SoundClass: - sgClass->Meta.SetMetaString (APMETA_SoundClass, datastr); - break; - case ADEF_PlayerPawn_Face: - sgClass->Meta.SetMetaString (APMETA_Face, datastr); - break; - case ADEF_PlayerPawn_ScoreIcon: - player->ScoreIcon = TexMan.AddPatch (datastr); - if (!player->ScoreIcon.isValid()) - { - player->ScoreIcon = TexMan.AddPatch (datastr, ns_sprites); - } - break; - } -} - -#ifndef _MSC_VER -void ApplyActorDefault (int defnum, const char *datastr) -{ - ApplyActorDefault (defnum, datastr, 0); -} -void ApplyActorDefault (int defnum, int dataint) -{ - ApplyActorDefault (defnum, 0, dataint); -} -#endif - -void FActorInfo::ApplyDefaults (BYTE *defaults) -{ - sgClass = Class; - sgDefaults = defaults; - - if (Class != RUNTIME_CLASS(AActor)) - { - MakeStateDefines(Class->ParentClass->ActorInfo->StateList); - } - else - { - ClearStateLabels(); - } -#if _MSC_VER - const BYTE *parser = DefaultList; - - const char *datastr = NULL; - int dataint = 0; - int defnum; - int deftype; - - while ((defnum = *(WORD *)parser) != ADEF_EOL) - { - deftype = defnum >> (16-2); - defnum &= 0x3FFF; - parser += 2; - if (defnum <= ADEF_LastString) - { - datastr = (const char *)parser; - parser = (const BYTE *)datastr + strlen (datastr) + 1; - } - else - { - switch (deftype) - { - case 0: // byte - dataint = *parser; - parser++; - break; - - case 1: // byte * FRACUNIT; - dataint = *parser << FRACBITS; - parser++; - break; - - case 2: // word - dataint = *(WORD *)parser; - parser += 2; - break; - - case 3: // long - dataint = *(DWORD *)parser; - parser += 4; - break; - } - defnum &= ~ADEFTYPE_MASK; - } - - ApplyActorDefault (defnum, datastr, dataint); - } -#else - DefaultsConstructor (); -#endif - InstallStates(this, ((AActor *)defaults)); - // Anything that is CountKill is also a monster, even if it doesn't specify it. - if (((AActor *)defaults)->flags & MF_COUNTKILL) - { - ((AActor *)defaults)->flags3 |= MF3_ISMONSTER; - ((AActor *)defaults)->flags4 |= MF4_CANUSEWALLS; // I won't bother changing all internal monster definitions so let's set this here. - } - // Any default projectile in Raven's games produces blood splatter - if (gameinfo.gametype & GAME_Raven && ((AActor *)defaults)->flags & MF_MISSILE) - { - ((AActor *)defaults)->flags5 |= MF5_BLOODSPLATTER; - } -} diff --git a/src/infomacros.h b/src/infomacros.h deleted file mode 100644 index e35bd2251..000000000 --- a/src/infomacros.h +++ /dev/null @@ -1,321 +0,0 @@ -/* -** infomacros.h -** -**--------------------------------------------------------------------------- -** Copyright 1998-2007 Randy Heit -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** This file contains macros for building Actor defaults lists -** Defaults lists are byte-packed arrays of keys and values. -** -** For Visual C++, a simple byte array will do, with one restriction: -** Any strings must be at the end of the array. -** -** For GCC, an initializer function is created instead, since GCC doesn't -** let you combine integers and strings in the same character array, and -** there's no way to guarantee that consecutive variables will be -** consecutive in the generated code. -*/ - -#ifndef __INFOMACROS_H__ -#define __INFOMACROS_H__ - -#ifndef __INFO_H__ -#error infomacros.h is meant to be included by info.h -#endif - -#ifdef WORDS_BIGENDIAN -#define BREAK_WORD(x) ((unsigned)(x)>>8), (x)&255 -#define BREAK_LONG(x) ((unsigned)(x)>>24), ((x)>>16)&255, ((x)>>8)&255, (x)&255 -#else -#define BREAK_WORD(x) (x)&255, ((unsigned)(x))>>8 -#define BREAK_LONG(x) (x)&255, ((x)>>8)&255, ((x)>>16)&255, ((unsigned)(x))>>24 -#endif - -typedef void (*voidfunc_)(); - - -#if defined(_MSC_VER) - -/************************************************ -************** Visual C++ macros **************** -************************************************/ - -#pragma warning(disable: 4207) // nonstandard extension used : extended initializer form - -#pragma data_seg(".areg$u") // ActorInfo initializer list -#pragma data_seg() - -#define DOOMEDNUMOF(actor) actor##ActorInfo.DoomEdNum - -#define BEGIN_DEFAULTS_PRE(actor) \ - extern FActorInfo actor##ActorInfo; \ - __declspec(allocate(".areg$u")) FActorInfo *actor##DefaultsReg = &actor##ActorInfo; \ - FActorInfo actor##ActorInfo = { - -#define BEGIN_DEFAULTS_POST(actor,game,ednum,id) \ - GAME_##game, id, ednum, NULL, NULL, NULL, - -#ifdef WORDS_BIGENDIAN -#define END_DEFAULTS "\xED\x5E" }; -#else -#define END_DEFAULTS "\x5E\xED" }; -#endif - -#define ADD_BYTE_PROP(prop,val) BREAK_WORD(prop|ADEFTYPE_Byte), val, -#define ADD_FIXD_PROP(prop,val) BREAK_WORD(prop|ADEFTYPE_FixedMul), (BYTE)(val), -#define ADD_WORD_PROP(prop,val) BREAK_WORD(prop|ADEFTYPE_Word), BREAK_WORD(val), -#define ADD_LONG_PROP(prop,val) BREAK_WORD(prop|ADEFTYPE_Long), BREAK_LONG(val), -#ifdef WORDS_BIGENDIAN -#define ADD_STRING_PROP(prop1,prop2,val) "\0" prop2 val "\0" -#else -#define ADD_STRING_PROP(prop1,prop2,val) prop2 "\0" val "\0" -#endif - -#else - -/*********************************************** -************* Non-Visual C++ macros ************ -************************************************/ - -#include "autosegs.h" - -#define DOOMEDNUMOF(actor) actor##ActorInfo.DoomEdNum - -extern void ApplyActorDefault (int defnum, const char *datastr); -extern void ApplyActorDefault (int defnum, int dataint); - -// All variables used for the default list must be declared extern to -// ensure that GCC actually generates them in the object file. -#define BEGIN_DEFAULTS_PRE(actor) \ - extern FActorInfo actor##ActorInfo; \ - extern FActorInfo *actor##DefaultsReg; \ - extern void actor##DefaultsConstructor(); \ - FActorInfo *actor##DefaultsReg __attribute__((section(AREG_SECTION))) = &actor##ActorInfo; \ - FActorInfo actor##ActorInfo = { - -#define BEGIN_DEFAULTS_POST(actor,game,ednum,id) \ - GAME_##game, id, ednum, NULL, NULL, NULL, actor##DefaultsConstructor }; \ - void actor##DefaultsConstructor() { \ - -#define END_DEFAULTS } - -#define ADD_BYTE_PROP(prop,val) ApplyActorDefault (prop, (val)); -#define ADD_FIXD_PROP(prop,val) ApplyActorDefault (prop, ((val)<sprite.index].spriteframes + PlayerState->GetFrame()]; + spriteframe_t *sprframe = &SpriteFrames[sprites[PlayerState->sprite].spriteframes + PlayerState->GetFrame()]; fixed_t scaleX = GetDefaultByType (PlayerClass->Type)->scaleX; fixed_t scaleY = GetDefaultByType (PlayerClass->Type)->scaleY; @@ -2133,9 +2133,9 @@ static void M_PlayerSetupDrawer () if (GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN || players[consoleplayer].userinfo.PlayerClass == -1 || - PlayerState->sprite.index != GetDefaultByType (PlayerClass->Type)->SpawnState->sprite.index) + PlayerState->sprite != GetDefaultByType (PlayerClass->Type)->SpawnState->sprite) { - sprframe = &SpriteFrames[sprites[PlayerState->sprite.index].spriteframes + PlayerState->GetFrame()]; + sprframe = &SpriteFrames[sprites[PlayerState->sprite].spriteframes + PlayerState->GetFrame()]; ScaleX = GetDefaultByType(PlayerClass->Type)->scaleX; ScaleY = GetDefaultByType(PlayerClass->Type)->scaleY; } diff --git a/src/namedef.h b/src/namedef.h index e4492b74b..c8b21280b 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -165,6 +165,7 @@ xx(Yes) xx(No) xx(Greetings) xx(Idle) +xx(GenericFreezeDeath) // Compatible death names for the decorate parser. xx(XDeath) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index f86ea31f1..02d224cec 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -656,7 +656,7 @@ void AActor::Die (AActor *source, AActor *inflictor) if (!deh.NoAutofreeze && !(flags4 & MF4_NOICEDEATH) && (player || (flags3 & MF3_ISMONSTER))) { - diestate = &AActor::States[S_GENERICFREEZEDEATH]; + diestate = FindState(NAME_GenericFreezeDeath); } } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 4caa47df8..5012fa5bd 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -360,8 +360,8 @@ void AActor::Serialize (FArchive &arc) { if (playeringame[player - players] && player->cls != NULL && - state->sprite.index == - GetDefaultByType (player->cls)->SpawnState->sprite.index) + state->sprite == + GetDefaultByType (player->cls)->SpawnState->sprite) { // Give player back the skin sprite = skins[player->userinfo.skin].sprite; scaleX = skins[player->userinfo.skin].ScaleX; @@ -477,7 +477,7 @@ bool AActor::SetState (FState *newstate) if (state != NULL) { - prevsprite = state->sprite.index; + prevsprite = state->sprite; } else { @@ -486,13 +486,13 @@ bool AActor::SetState (FState *newstate) state = newstate; tics = GetTics(newstate); renderflags = (renderflags & ~RF_FULLBRIGHT) | newstate->GetFullbright(); - newsprite = newstate->sprite.index; + newsprite = newstate->sprite; if (newsprite != 1) { // Sprite 1 is ----, which means "do not change the sprite" frame = newstate->GetFrame(); - if (!(flags4 & MF4_NOSKIN) && newsprite == SpawnState->sprite.index) + if (!(flags4 & MF4_NOSKIN) && newsprite == SpawnState->sprite) { // [RH] If the new sprite is the same as the original sprite, and // this actor is attached to a player, use the player's skin's // sprite. If a player is not attached, do not change the sprite @@ -560,7 +560,7 @@ bool AActor::SetStateNF (FState *newstate) if (state != NULL) { - prevsprite = state->sprite.index; + prevsprite = state->sprite; } else { @@ -569,13 +569,13 @@ bool AActor::SetStateNF (FState *newstate) state = newstate; tics = GetTics(newstate); renderflags = (renderflags & ~RF_FULLBRIGHT) | newstate->GetFullbright(); - newsprite = newstate->sprite.index; + newsprite = newstate->sprite; if (newsprite != 1) { // Sprite 1 is ----, which means "do not change the sprite" frame = newstate->GetFrame(); - if (!(flags4 & MF4_NOSKIN) && newsprite == SpawnState->sprite.index) + if (!(flags4 & MF4_NOSKIN) && newsprite == SpawnState->sprite) { if (player != NULL && gameinfo.gametype != GAME_Hexen) { @@ -3057,23 +3057,6 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) return false; // we did the splash ourselves! ;) } -//---------------------------------------------------------------------------- -// -// PROC A_FreeTargMobj -// -//---------------------------------------------------------------------------- - -void A_FreeTargMobj (AActor *mo) -{ - mo->momx = mo->momy = mo->momz = 0; - mo->z = mo->ceilingz + 4*FRACUNIT; - mo->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY|MF_SOLID); - mo->flags |= MF_CORPSE|MF_DROPOFF|MF_NOGRAVITY; - mo->flags2 &= ~MF2_PASSMOBJ; - mo->gravity = FRACUNIT; - mo->player = NULL; -} - //========================================================================== // // A_GenericFreezeDeath @@ -3086,45 +3069,6 @@ void A_GenericFreezeDeath (AActor *actor) A_FreezeDeath (actor); } -//========================================================================== -// -// AActor stuff -// -//========================================================================== - -FState AActor::States[] = -{ - S_NORMAL (TNT1, 'A', -1, NULL, NULL), - S_NORMAL (TNT1, 'E', 1050, A_FreeTargMobj, NULL), - S_NORMAL (TNT1, 'A', 1, NULL, NULL), // S_NULL - - // Generic freeze death frames. Woo! - S_NORMAL (----, 'A', 5, A_GenericFreezeDeath, &States[4]), - S_NORMAL (----, 'A', 1, A_FreezeDeathChunks, &States[4]) -}; - -BEGIN_DEFAULTS (AActor, Any, -1, 0) - PROP_XScale (FRACUNIT) - PROP_YScale (FRACUNIT) - PROP_SpawnState (2) - PROP_SpawnHealth (1000) - PROP_ReactionTime (8) - PROP_RadiusFixed (20) - PROP_HeightFixed (16) - PROP_Mass (100) - PROP_RenderStyle (STYLE_Normal) - PROP_Alpha (FRACUNIT) - PROP_MinMissileChance (200) - PROP_MeleeRange(44) // MELEERANGE(64) - 20 - PROP_MaxDropOffHeight(24) - PROP_MaxStepHeight(24) - PROP_BounceFactor(FRACUNIT*7/10) - PROP_WallBounceFactor(FRACUNIT*3/4) - PROP_BounceCount(-1) - PROP_FloatSpeed(4) - PROP_Gravity(FRACUNIT) -END_DEFAULTS - //========================================================================== // // P_SpawnMobj @@ -3174,7 +3118,7 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t actor->state = st; actor->tics = st->GetTics(); - actor->sprite = st->sprite.index; + actor->sprite = st->sprite; actor->frame = st->GetFrame(); actor->renderflags = (actor->renderflags & ~RF_FULLBRIGHT) | st->GetFullbright(); actor->touching_sectorlist = NULL; // NULL head of sector list // phares 3/13/98 @@ -3923,7 +3867,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) const AActor *defaults = GetDefaultByType (i); if (defaults->SpawnState == NULL || - sprites[defaults->SpawnState->sprite.index].numframes == 0) + sprites[defaults->SpawnState->sprite].numframes == 0) { Printf ("%s at (%i, %i) has no frames\n", i->TypeName.GetChars(), mthing->x>>FRACBITS, mthing->y>>FRACBITS); @@ -4917,7 +4861,7 @@ int AActor::TakeSpecialDamage (AActor *inflictor, AActor *source, int damage, FN if (death == NULL && !deh.NoAutofreeze && !(flags4 & MF4_NOICEDEATH) && (player || (flags3 & MF3_ISMONSTER))) { - death = &AActor::States[S_GENERICFREEZEDEATH]; + death = FindState(NAME_GenericFreezeDeath); } } else diff --git a/src/p_user.cpp b/src/p_user.cpp index ad7b870a4..40753af71 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -439,7 +439,7 @@ void APlayerPawn::BeginPlay () // This assumes that player sprites always exist in rotated form and // that the front view is always a separate sprite. So far this is // true for anything that exists. - FString normspritename = sprites[SpawnState->sprite.index].name; + FString normspritename = sprites[SpawnState->sprite].name; FString crouchspritename = sprites[crouchsprite].name; int spritenorm = Wads.CheckNumForName(normspritename + "A1", ns_sprites); @@ -1081,8 +1081,7 @@ void APlayerPawn::Die (AActor *source, AActor *inflictor) AInventory *item; if (weap->SpawnState != NULL && - weap->SpawnState != &AActor::States[0] && - weap->SpawnState != &AActor::States[AActor::S_NULL]) + weap->SpawnState != ::GetDefault()->SpawnState) { item = P_DropItem (this, weap->GetClass(), -1, 256); if (item != NULL) @@ -1322,7 +1321,7 @@ void P_CheckPlayerSprites() if (player->crouchfactor < FRACUNIT*3/4) { - if (mo->sprite == mo->SpawnState->sprite.index || mo->sprite == mo->crouchsprite) + if (mo->sprite == mo->SpawnState->sprite || mo->sprite == mo->crouchsprite) { crouchspriteno = mo->crouchsprite; } @@ -1351,7 +1350,7 @@ void P_CheckPlayerSprites() { if (mo->sprite == mo->crouchsprite) { - mo->sprite = mo->SpawnState->sprite.index; + mo->sprite = mo->SpawnState->sprite; } else if (mo->sprite == skins[player->userinfo.skin].crouchsprite) { diff --git a/src/r_things.cpp b/src/r_things.cpp index 41a8304bc..1783532b6 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -645,7 +645,7 @@ void R_InitSkins (void) const PClass *type = PlayerClasses[j].Type; if (type->IsDescendantOf (basetype) && - GetDefaultByType (type)->SpawnState->sprite.index == GetDefaultByType (basetype)->SpawnState->sprite.index && + GetDefaultByType (type)->SpawnState->sprite == GetDefaultByType (basetype)->SpawnState->sprite && type->Meta.GetMetaInt (APMETA_ColorRange) == basetype->Meta.GetMetaInt (APMETA_ColorRange)) { PlayerClasses[j].Skins.Push ((int)i); @@ -905,7 +905,7 @@ void R_InitSprites () skins[i].range0end = basetype->Meta.GetMetaInt (APMETA_ColorRange) >> 8; skins[i].ScaleX = GetDefaultByType (basetype)->scaleX; skins[i].ScaleY = GetDefaultByType (basetype)->scaleY; - skins[i].sprite = GetDefaultByType (basetype)->SpawnState->sprite.index; + skins[i].sprite = GetDefaultByType (basetype)->SpawnState->sprite; skins[i].namespc = ns_global; PlayerClasses[i].Skins.Push (i); @@ -1535,15 +1535,15 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ vissprite_t avis; // decide which patch to use - if ( (unsigned)psp->state->sprite.index >= (unsigned)sprites.Size ()) + if ( (unsigned)psp->state->sprite >= (unsigned)sprites.Size ()) { - DPrintf ("R_DrawPSprite: invalid sprite number %i\n", psp->state->sprite.index); + DPrintf ("R_DrawPSprite: invalid sprite number %i\n", psp->state->sprite); return; } - sprdef = &sprites[psp->state->sprite.index]; + sprdef = &sprites[psp->state->sprite]; if (psp->state->GetFrame() >= sprdef->numframes) { - DPrintf ("R_DrawPSprite: invalid sprite frame %i : %i\n", psp->state->sprite.index, psp->state->GetFrame()); + DPrintf ("R_DrawPSprite: invalid sprite frame %i : %i\n", psp->state->sprite, psp->state->GetFrame()); return; } sprframe = &SpriteFrames[sprdef->spriteframes + psp->state->GetFrame()]; diff --git a/src/thingdef/olddecorations.cpp b/src/thingdef/olddecorations.cpp index fac8cb39c..4c52e8b58 100644 --- a/src/thingdef/olddecorations.cpp +++ b/src/thingdef/olddecorations.cpp @@ -332,9 +332,8 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) memcpy (info->OwnedStates, &states[0], info->NumOwnedStates * sizeof(info->OwnedStates[0])); if (info->NumOwnedStates == 1) { - info->OwnedStates->Tics = 0; + info->OwnedStates->Tics = -1; info->OwnedStates->Misc1 = 0; - info->OwnedStates->Frame &= ~SF_BIGTIC; } else { @@ -360,9 +359,8 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) } else { - info->OwnedStates[i].Tics = 0; + info->OwnedStates[i].Tics = -1; info->OwnedStates[i].Misc1 = 0; - info->OwnedStates[i].Frame &= ~SF_BIGTIC; } if (def == DEF_Projectile) @@ -408,9 +406,8 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) } else { - info->OwnedStates[i].Tics = 0; + info->OwnedStates[i].Tics = -1; info->OwnedStates[i].Misc1 = 0; - info->OwnedStates[i].Frame &= ~SF_BIGTIC; } // The first frame plays the burn sound and @@ -443,20 +440,20 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) info->OwnedStates[i].NextState = &info->OwnedStates[i+1]; } info->OwnedStates[i].NextState = &info->OwnedStates[info->NumOwnedStates-1]; - info->OwnedStates[i].Tics = 6; + info->OwnedStates[i].Tics = 5; info->OwnedStates[i].Misc1 = 0; info->OwnedStates[i].Action = A_FreezeDeath; i = info->NumOwnedStates - 1; info->OwnedStates[i].NextState = &info->OwnedStates[i]; - info->OwnedStates[i].Tics = 2; + info->OwnedStates[i].Tics = 1; info->OwnedStates[i].Misc1 = 0; info->OwnedStates[i].Action = A_FreezeDeathChunks; AddState("Ice", &info->OwnedStates[extra.IceDeathStart]); } else if (extra.bGenericIceDeath) { - AddState("Ice", &AActor::States[AActor::S_GENERICFREEZEDEATH]); + AddState("Ice", RUNTIME_CLASS(AActor)->ActorInfo->FindState(NAME_GenericFreezeDeath)); } } if (def == DEF_BreakableDecoration) @@ -469,7 +466,6 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def) } AddState("Spawn", &info->OwnedStates[extra.SpawnStart]); InstallStates (info, ((AActor *)(type->Defaults))); - ProcessStates (info->OwnedStates, info->NumOwnedStates); } //========================================================================== @@ -749,16 +745,18 @@ static void ParseInsideDecoration (FActorInfo *info, AActor *defaults, } unsigned int i; + int spr = GetSpriteIndex(sprite); for (i = 0; i < states.Size(); ++i) { - memcpy (states[i].sprite.name, sprite, 4); + states[i].sprite = spr; } if (extra.DeathSprite[0] && extra.DeathEnd != 0) { + int spr = GetSpriteIndex(extra.DeathSprite); for (i = extra.DeathStart; i < extra.DeathEnd; ++i) { - memcpy (states[i].sprite.name, extra.DeathSprite, 4); + states[i].sprite = spr; } } } @@ -805,7 +803,7 @@ static void ParseSpriteFrames (FActorInfo *info, TArray &states, FScanne while (*token == ' ') token++; - int rate = 5; + int rate = 4; bool firstState = true; char *colon = strchr (token, ':'); @@ -820,11 +818,9 @@ static void ParseSpriteFrames (FActorInfo *info, TArray &states, FScanne sc.ScriptError ("Rates must be in the range [0,65534]"); } token = colon + 1; - rate += 1; } - state.Tics = rate & 0xff; - state.Misc1 = (rate >> 8); + state.Tics = rate; while (*token) { @@ -850,7 +846,7 @@ static void ParseSpriteFrames (FActorInfo *info, TArray &states, FScanne states.Push (state); } firstState = false; - state.Frame = (rate >= 256) ? (SF_BIGTIC | (*token-'A')) : (*token-'A'); + state.Frame = *token-'A'; } ++token; } diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index c88b4eef2..4fbbb228a 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -398,7 +398,7 @@ static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *b { sc.ScriptError("Unknown native class '%s'", typeName.GetChars()); } - else if (ti->ParentClass->NativeClass() != parent->NativeClass()) + else if (ti != RUNTIME_CLASS(AActor) && ti->ParentClass->NativeClass() != parent->NativeClass()) { sc.ScriptError("Native class '%s' does not inherit from '%s'", typeName.GetChars(),parent->TypeName.GetChars()); @@ -751,61 +751,3 @@ void FinishThingdef() } -//========================================================================== -// -// ParseClass -// -// A minimal placeholder so that I can assign properties to some native -// classes. Please, no end users use this until it's finalized. -// -//========================================================================== - -void ParseClass(FScanner &sc) -{ - Baggage bag; - PClass *cls; - FName classname; - FName supername; - - sc.MustGetToken(TK_Identifier); // class name - classname = sc.String; - sc.MustGetToken(TK_Extends); // because I'm not supporting Object - sc.MustGetToken(TK_Identifier); // superclass name - supername = sc.String; - sc.MustGetToken(TK_Native); // use actor definitions for your own stuff - sc.MustGetToken('{'); - - cls = const_cast(PClass::FindClass (classname)); - if (cls == NULL) - { - sc.ScriptError ("'%s' is not a native class", classname.GetChars()); - } - if (cls->ParentClass == NULL || cls->ParentClass->TypeName != supername) - { - sc.ScriptError ("'%s' does not extend '%s'", classname.GetChars(), supername.GetChars()); - } - bag.Info = cls->ActorInfo; - - sc.MustGetAnyToken(); - while (sc.TokenType != '}') - { - if (sc.TokenType == TK_Action) - { - ParseActionDef(sc, cls); - } - else if (sc.TokenType == TK_Const) - { - ParseConstant(sc, &cls->Symbols, cls); - } - else if (sc.TokenType == TK_Enum) - { - ParseEnum(sc, &cls->Symbols, cls); - } - else - { - FString tokname = sc.TokenName(sc.TokenType, sc.String); - sc.ScriptError ("Expected 'action', 'const' or 'enum' but got %s", tokname.GetChars()); - } - sc.MustGetAnyToken(); - } -} diff --git a/src/thingdef/thingdef_main.cpp b/src/thingdef/thingdef_main.cpp index 0b0106b27..3da7ad648 100644 --- a/src/thingdef/thingdef_main.cpp +++ b/src/thingdef/thingdef_main.cpp @@ -84,10 +84,6 @@ static void ParseDecorate (FScanner &sc) break; } - case TK_Class: - ParseClass (sc); - break; - case TK_Const: ParseConstant (sc, &RUNTIME_CLASS(AActor)->Symbols, RUNTIME_CLASS(AActor)); break; diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 84654180b..fe71a9ea1 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2898,7 +2898,6 @@ void FinishActor(FScanner &sc, FActorInfo *info, Baggage &bag) FinishStates (sc, info, defaults, bag); InstallStates (info, defaults); - ProcessStates (info->OwnedStates, info->NumOwnedStates); if (bag.DropItemSet) { if (bag.DropItemList == NULL) diff --git a/src/thingdef/thingdef_states.cpp b/src/thingdef/thingdef_states.cpp index b32da9102..84c64aa51 100644 --- a/src/thingdef/thingdef_states.cpp +++ b/src/thingdef/thingdef_states.cpp @@ -311,18 +311,10 @@ void InstallStates(FActorInfo *info, AActor *defaults) // First ensure we have a valid spawn state. FState * state = FindState(defaults, info->Class, "Spawn"); - // Stateless actors that are direct subclasses of AActor - // have their spawnstate default to something that won't - // immediately destroy them. - if (state == &AActor::States[2] && info->Class->ParentClass == RUNTIME_CLASS(AActor)) + if (state == NULL) { - AddState("Spawn", &AActor::States[0]); - } - else if (state == NULL) - { - // A NULL spawn state will crash the engine so set it to something that will make - // the actor disappear as quickly as possible. - AddState("Spawn", &AActor::States[2]); + // A NULL spawn state will crash the engine so set it to something valid. + AddState("Spawn", GetDefault()->SpawnState); } if (info->StateList != NULL) @@ -510,6 +502,8 @@ int ParseStates(FScanner &sc, FActorInfo * actor, AActor * defaults, Baggage &ba FState * laststate = NULL; intptr_t lastlabel = -1; int minrequiredstate = -1; + int spriteindex; + char lastsprite[5]=""; sc.MustGetStringName ("{"); sc.SetEscape(false); // disable escape sequences in the state parser @@ -609,7 +603,14 @@ do_stop: sc.ScriptError ("Sprite names must be exactly 4 characters\n"); } - memcpy(state.sprite.name, statestring, 4); + statestring.ToUpper(); + if (strcmp(statestring, lastsprite)) + { + strcpy(lastsprite, statestring); + spriteindex = GetSpriteIndex(lastsprite); + } + + state.sprite = spriteindex; state.Misc1 = state.Misc2 = 0; state.ParameterIndex = 0; sc.MustGetString(); @@ -623,13 +624,7 @@ do_stop: } sc.MustGetNumber(); - sc.Number++; - state.Tics = sc.Number & 255; - state.Misc1 = (sc.Number >> 8) & 255; - if (state.Misc1) - { - state.Frame |= SF_BIGTIC; - } + state.Tics = clamp(sc.Number, -1, 32767); while (sc.GetString() && !sc.Crossed) { @@ -640,10 +635,6 @@ do_stop: } if (sc.Compare("OFFSET")) { - if (state.Frame & SF_BIGTIC) - { - sc.ScriptError("You cannot use OFFSET with a state duration larger than 254!"); - } // specify a weapon offset sc.MustGetStringName("("); sc.MustGetNumber(); @@ -902,7 +893,7 @@ endofstate: frame=0; } - state.Frame=(state.Frame&(SF_FULLBRIGHT|SF_BIGTIC))|frame; + state.Frame=(state.Frame&(SF_FULLBRIGHT))|frame; StateArray.Push(state); count++; } diff --git a/wadsrc/static/actors/nativeclasses.txt b/wadsrc/static/actors/actor.txt similarity index 58% rename from wadsrc/static/actors/nativeclasses.txt rename to wadsrc/static/actors/actor.txt index a85d68c80..1a23595b4 100644 --- a/wadsrc/static/actors/nativeclasses.txt +++ b/wadsrc/static/actors/actor.txt @@ -1,6 +1,23 @@ -class Actor extends Thinker - native +ACTOR Actor native //: Thinker { + Scale 1 + Health 1000 + Reactiontime 8 + Radius 20 + Height 16 + Mass 100 + RenderStyle Normal + Alpha 1 + MinMissileChance 200 + MeleeRange 44 + MaxDropoffHeight 24 + MaxStepHeight 24 + BounceFactor 0.7 + WallBounceFactor 0.75 + BounceCount -1 + FloatSpeed 4 + Gravity 1 + action native A_MonsterRail(); action native A_BFGSpray(optional class spraytype, optional eval int numrays, optional eval int damagecount); action native A_Pain(); @@ -188,350 +205,23 @@ class Actor extends Thinker action native A_RemoveForcefield(); action native A_DropWeaponPieces(class p1, class p2, class p3); action native A_PigPain (); -} - - - -ACTOR Inventory native -{ - Inventory.Amount 1 - Inventory.MaxAmount 1 - Inventory.UseSound "misc/invuse" - Inventory.PickupSound "misc/i_pkup" - - action native A_JumpIfNoAmmo(state label); - action native A_CustomPunch(eval int damage, optional eval bool norandom, optional evalnot bool useammo, optional class pufftype, optional eval float range); - action native A_FireBullets(eval float spread_xy, eval float spread_z, eval int numbullets, eval int damageperbullet, optional class pufftype, optional evalnot bool useammo, optional eval float range); - action native A_FireCustomMissile(class missiletype, optional eval float angle, optional evalnot bool useammo, optional eval int spawnofs_xy, optional eval float spawnheight, optional eval bool aimatangle); - action native A_RailAttack(eval int damage, optional eval int spawnofs_xy, optional evalnot int useammo, optional color color1, optional color color2, optional eval bool silent, optional eval float maxdiff, optional class pufftype); - action native A_Light(eval int extralight); - action native A_Light0(); - action native A_Light1(); - action native A_Light2(); - action native A_LightInverse(); - action native A_WeaponReady(); - action native A_Lower(); - action native A_Raise(); - action native A_FirePistol(); - action native A_FireShotgun(); - action native A_FireShotgun2(); - action native A_OpenShotgun2(); - action native A_LoadShotgun2(); - action native A_CloseShotgun2(); - action native A_FireCGun(); - action native A_FireMissile(); - action native A_FirePlasma(); - action native A_FireRailgun(); - action native A_FireRailgunLeft(); - action native A_FireRailgunRight(); - action native A_RailWait(); - action native A_BFGsound(); - action native A_FireBFG(); - action native A_ReFire(); - action native A_ClearReFire(); - action native A_CheckReload(); - action native A_GunFlash(); - action native A_Saw(optional coerce sound fullsound, optional coerce sound hitsound, optional eval int damage, optional class pufftype); - action native A_CheckForReload(eval int counter, state label); - action native A_ResetReloadCounter(); - action native A_RestoreSpecialPosition(); - action native A_RestoreSpecialDoomThing(); - action native A_RestoreSpecialThing1(); - action native A_RestoreSpecialThing2(); - States { - HideDoomish: - TNT1 A 1050 - TNT1 A 0 A_RestoreSpecialPosition - TNT1 A 1 A_RestoreSpecialDoomThing - Stop - HideSpecial: - ACLO E 1400 - ACLO A 0 A_RestoreSpecialPosition - ACLO A 4 A_RestoreSpecialThing1 - ACLO BABCBCDC 4 - ACLO D 4 A_RestoreSpecialThing2 - Stop - Held: + Spawn: TNT1 A -1 Stop - HoldAndDestroy: + Null: TNT1 A 1 Stop + GenericFreezeDeath: + // Generic freeze death frames. Woo! + "----" A 5 A_GenericFreezeDeath + "----" A 1 A_FreezeDeathChunks + Wait } } -Actor Ammo : Inventory native -{ - +INVENTORY.KEEPDEPLETED - Inventory.PickupSound "misc/ammo_pkup" -} -Actor BackpackItem : Inventory native -{ -} -ACTOR Armor : Inventory native -{ - Inventory.PickupSound "misc/armor_pkup" -} - -ACTOR BasicArmor : Armor native -{ - +Inventory.KEEPDEPLETED -} - -ACTOR BasicArmorBonus : Armor native -{ - +Inventory.AUTOACTIVATE - +Inventory.ALWAYSPICKUP - Inventory.MaxAmount 0 - Armor.SavePercent 0.333333 - -} - -ACTOR BasicArmorPickup : Armor native -{ - +Inventory.AUTOACTIVATE - Inventory.MaxAmount 0 -} - -ACTOR HexenArmor : Armor native -{ - +Inventory.KEEPDEPLETED - +Inventory.UNDROPPABLE -} - -ACTOR DehackedPickup : Inventory native -{ -} - -ACTOR FakeInventory : Inventory native -{ -} - -ACTOR CustomInventory : Inventory native -{ -} - -Actor Health : Inventory native -{ - Inventory.Amount 1 - Inventory.MaxAmount 0 - Inventory.PickupSound "misc/health_pkup" -} - -Actor HealthPickup : Inventory native -{ - Inventory.DefMaxAmount - +INVENTORY.INVBAR -} - -Actor Key : Inventory native -{ - +INVENTORY.INTERHUBSTRIP - Inventory.PickupSound "misc/k_pkup" -} - -ACTOR PowerupGiver : Inventory native -{ - Inventory.DefMaxAmount - +INVENTORY.INVBAR - +INVENTORY.FANCYPICKUPSOUND - Inventory.PickupSound "misc/p_pkup" -} - -ACTOR Powerup : Inventory native -{ -} - -ACTOR PowerInvulnerable : Powerup native -{ - Powerup.Duration -30 - inventory.icon "SPSHLD0" -} - -ACTOR PowerStrength : Powerup native -{ - Powerup.Duration 1 - Powerup.Color 255,0,0,0.5 - +INVENTORY.HUBPOWER -} - -ACTOR PowerInvisibility : Powerup native -{ - Powerup.Duration -60 -} - -ACTOR PowerGhost : PowerInvisibility native -{ -} - -ACTOR PowerShadow : PowerInvisibility native -{ - Powerup.Duration -55 - +INVENTORY.HUBPOWER -} - -ACTOR PowerIronFeet : Powerup native -{ - Powerup.Duration -60 - Powerup.Color 0, 255, 0, 0.125 -} - -ACTOR PowerMask : PowerIronFeet native -{ - Powerup.Duration -80 - Powerup.Color 0,0,0,0 - +INVENTORY.HUBPOWER - Inventory.Icon "I_MASK" -} - -ACTOR PowerLightAmp : Powerup native -{ - Powerup.Duration -120 -} - -ACTOR PowerTorch : PowerLightAmp native -{ -} - -ACTOR PowerFlight : Powerup native -{ - Powerup.Duration -60 - +INVENTORY.HUBPOWER -} - -ACTOR PowerWeaponLevel2 : Powerup native -{ - Powerup.Duration -40 - Inventory.Icon "SPINBK0" -} - -ACTOR PowerSpeed: Powerup native -{ - Powerup.Duration -45 - Speed 1.5 - Inventory.Icon "SPBOOT0" -} - -// Player Speed Trail (used by the Speed Powerup) ---------------------------- - -ACTOR PlayerSpeedTrail native -{ - +NOBLOCKMAP - +NOGRAVITY - Alpha 0.6 - RenderStyle Translucent -} - -ACTOR PowerMinotaur : Powerup native -{ - Powerup.Duration -25 - Inventory.Icon "SPMINO0" -} - -ACTOR PowerTargeter : Powerup native -{ - Powerup.Duration -160 - +INVENTORY.HUBPOWER - States - { - Targeter: - TRGT A -1 - Stop - TRGT B -1 - Stop - TRGT C -1 - Stop - } -} - -ACTOR PowerFrightener : Powerup native -{ - Powerup.Duration -60 -} - -ACTOR PowerScanner : Powerup native -{ - Powerup.Duration -80 - +INVENTORY.HUBPOWER -} - -ACTOR PowerTimeFreezer : Powerup native -{ - Powerup.Duration -12 -} - -ACTOR PowerDamage : Powerup native -{ - Powerup.Duration -25 -} - -ACTOR PowerProtection : Powerup native -{ - Powerup.Duration -25 -} - -ACTOR PowerDrain : Powerup native -{ - Powerup.Duration -60 -} - -ACTOR PowerRegeneration : Powerup native -{ - Powerup.Duration -120 -} - -ACTOR PowerHighJump : Powerup native -{ -} - -ACTOR PowerMorph : Powerup native -{ - Powerup.Duration -40 -} - -ACTOR MapRevealer : Inventory native -{ -} - -ACTOR PuzzleItem : Inventory native -{ - +NOGRAVITY - +INVENTORY.INVBAR - Inventory.DefMaxAmount - Inventory.UseSound "PuzzleSuccess" - Inventory.PickupSound "misc/i_pkup" -} - -Actor Weapon : Inventory native -{ - - Inventory.PickupSound "misc/w_pkup" - Weapon.DefaultKickback - States - { - LightDone: - SHTG E 0 A_Light0 - Stop - } -} - -ACTOR WeaponGiver : Weapon native -{ -} - -Actor WeaponHolder : Inventory native -{ - +NOBLOCKMAP - +NOSECTOR - +INVENTORY.UNDROPPABLE -} - -Actor WeaponPiece : Inventory native -{ -} diff --git a/wadsrc/static/actors/hexen/magelightning.txt b/wadsrc/static/actors/hexen/magelightning.txt index 45567e924..d3412f38d 100644 --- a/wadsrc/static/actors/hexen/magelightning.txt +++ b/wadsrc/static/actors/hexen/magelightning.txt @@ -69,7 +69,6 @@ ACTOR LightningCeiling : Lightning action native A_LightningZap(); action native A_LightningClip(); action native A_LightningRemove(); - action native A_FreeTargMobj(); States { @@ -89,7 +88,7 @@ ACTOR LightningCeiling : Lightning MLF2 O 3 Bright MLF2 P 3 Bright MLF2 P 1 Bright A_HideThing - ACLO E 1050 A_FreeTargMobj + ACLO E 1050 Stop } } diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt new file mode 100644 index 000000000..93fcae59e --- /dev/null +++ b/wadsrc/static/actors/shared/inventory.txt @@ -0,0 +1,342 @@ +ACTOR Inventory native +{ + Inventory.Amount 1 + Inventory.MaxAmount 1 + Inventory.UseSound "misc/invuse" + Inventory.PickupSound "misc/i_pkup" + + action native A_JumpIfNoAmmo(state label); + action native A_CustomPunch(eval int damage, optional eval bool norandom, optional evalnot bool useammo, optional class pufftype, optional eval float range); + action native A_FireBullets(eval float spread_xy, eval float spread_z, eval int numbullets, eval int damageperbullet, optional class pufftype, optional evalnot bool useammo, optional eval float range); + action native A_FireCustomMissile(class missiletype, optional eval float angle, optional evalnot bool useammo, optional eval int spawnofs_xy, optional eval float spawnheight, optional eval bool aimatangle); + action native A_RailAttack(eval int damage, optional eval int spawnofs_xy, optional evalnot int useammo, optional color color1, optional color color2, optional eval bool silent, optional eval float maxdiff, optional class pufftype); + action native A_Light(eval int extralight); + action native A_Light0(); + action native A_Light1(); + action native A_Light2(); + action native A_LightInverse(); + action native A_WeaponReady(); + action native A_Lower(); + action native A_Raise(); + action native A_FirePistol(); + action native A_FireShotgun(); + action native A_FireShotgun2(); + action native A_OpenShotgun2(); + action native A_LoadShotgun2(); + action native A_CloseShotgun2(); + action native A_FireCGun(); + action native A_FireMissile(); + action native A_FirePlasma(); + action native A_FireRailgun(); + action native A_FireRailgunLeft(); + action native A_FireRailgunRight(); + action native A_RailWait(); + action native A_BFGsound(); + action native A_FireBFG(); + action native A_ReFire(); + action native A_ClearReFire(); + action native A_CheckReload(); + action native A_GunFlash(); + action native A_Saw(optional coerce sound fullsound, optional coerce sound hitsound, optional eval int damage, optional class pufftype); + action native A_CheckForReload(eval int counter, state label); + action native A_ResetReloadCounter(); + action native A_RestoreSpecialPosition(); + action native A_RestoreSpecialDoomThing(); + action native A_RestoreSpecialThing1(); + action native A_RestoreSpecialThing2(); + + States + { + HideDoomish: + TNT1 A 1050 + TNT1 A 0 A_RestoreSpecialPosition + TNT1 A 1 A_RestoreSpecialDoomThing + Stop + HideSpecial: + ACLO E 1400 + ACLO A 0 A_RestoreSpecialPosition + ACLO A 4 A_RestoreSpecialThing1 + ACLO BABCBCDC 4 + ACLO D 4 A_RestoreSpecialThing2 + Stop + Held: + TNT1 A -1 + Stop + HoldAndDestroy: + TNT1 A 1 + Stop + } +} + +Actor Ammo : Inventory native +{ + +INVENTORY.KEEPDEPLETED + Inventory.PickupSound "misc/ammo_pkup" +} + +Actor BackpackItem : Inventory native +{ +} + +ACTOR Armor : Inventory native +{ + Inventory.PickupSound "misc/armor_pkup" +} + +ACTOR BasicArmor : Armor native +{ + +Inventory.KEEPDEPLETED +} + +ACTOR BasicArmorBonus : Armor native +{ + +Inventory.AUTOACTIVATE + +Inventory.ALWAYSPICKUP + Inventory.MaxAmount 0 + Armor.SavePercent 0.333333 + +} + +ACTOR BasicArmorPickup : Armor native +{ + +Inventory.AUTOACTIVATE + Inventory.MaxAmount 0 +} + +ACTOR HexenArmor : Armor native +{ + +Inventory.KEEPDEPLETED + +Inventory.UNDROPPABLE +} + +ACTOR DehackedPickup : Inventory native +{ +} + +ACTOR FakeInventory : Inventory native +{ +} + +ACTOR CustomInventory : Inventory native +{ +} + +Actor Health : Inventory native +{ + Inventory.Amount 1 + Inventory.MaxAmount 0 + Inventory.PickupSound "misc/health_pkup" +} + +Actor HealthPickup : Inventory native +{ + Inventory.DefMaxAmount + +INVENTORY.INVBAR +} + +Actor Key : Inventory native +{ + +INVENTORY.INTERHUBSTRIP + Inventory.PickupSound "misc/k_pkup" +} + +ACTOR PowerupGiver : Inventory native +{ + Inventory.DefMaxAmount + +INVENTORY.INVBAR + +INVENTORY.FANCYPICKUPSOUND + Inventory.PickupSound "misc/p_pkup" +} + +ACTOR Powerup : Inventory native +{ +} + +ACTOR PowerInvulnerable : Powerup native +{ + Powerup.Duration -30 + inventory.icon "SPSHLD0" +} + +ACTOR PowerStrength : Powerup native +{ + Powerup.Duration 1 + Powerup.Color 255,0,0,0.5 + +INVENTORY.HUBPOWER +} + +ACTOR PowerInvisibility : Powerup native +{ + Powerup.Duration -60 +} + +ACTOR PowerGhost : PowerInvisibility native +{ +} + +ACTOR PowerShadow : PowerInvisibility native +{ + Powerup.Duration -55 + +INVENTORY.HUBPOWER +} + +ACTOR PowerIronFeet : Powerup native +{ + Powerup.Duration -60 + Powerup.Color 0, 255, 0, 0.125 +} + +ACTOR PowerMask : PowerIronFeet native +{ + Powerup.Duration -80 + Powerup.Color 0,0,0,0 + +INVENTORY.HUBPOWER + Inventory.Icon "I_MASK" +} + +ACTOR PowerLightAmp : Powerup native +{ + Powerup.Duration -120 +} + +ACTOR PowerTorch : PowerLightAmp native +{ +} + +ACTOR PowerFlight : Powerup native +{ + Powerup.Duration -60 + +INVENTORY.HUBPOWER +} + +ACTOR PowerWeaponLevel2 : Powerup native +{ + Powerup.Duration -40 + Inventory.Icon "SPINBK0" +} + +ACTOR PowerSpeed: Powerup native +{ + Powerup.Duration -45 + Speed 1.5 + Inventory.Icon "SPBOOT0" +} + +// Player Speed Trail (used by the Speed Powerup) ---------------------------- + +ACTOR PlayerSpeedTrail native +{ + +NOBLOCKMAP + +NOGRAVITY + Alpha 0.6 + RenderStyle Translucent +} + +ACTOR PowerMinotaur : Powerup native +{ + Powerup.Duration -25 + Inventory.Icon "SPMINO0" +} + +ACTOR PowerTargeter : Powerup native +{ + Powerup.Duration -160 + +INVENTORY.HUBPOWER + States + { + Targeter: + TRGT A -1 + Stop + TRGT B -1 + Stop + TRGT C -1 + Stop + } +} + +ACTOR PowerFrightener : Powerup native +{ + Powerup.Duration -60 +} + +ACTOR PowerScanner : Powerup native +{ + Powerup.Duration -80 + +INVENTORY.HUBPOWER +} + +ACTOR PowerTimeFreezer : Powerup native +{ + Powerup.Duration -12 +} + +ACTOR PowerDamage : Powerup native +{ + Powerup.Duration -25 +} + +ACTOR PowerProtection : Powerup native +{ + Powerup.Duration -25 +} + +ACTOR PowerDrain : Powerup native +{ + Powerup.Duration -60 +} + +ACTOR PowerRegeneration : Powerup native +{ + Powerup.Duration -120 +} + +ACTOR PowerHighJump : Powerup native +{ +} + +ACTOR PowerMorph : Powerup native +{ + Powerup.Duration -40 +} + +ACTOR MapRevealer : Inventory native +{ +} + +ACTOR PuzzleItem : Inventory native +{ + +NOGRAVITY + +INVENTORY.INVBAR + Inventory.DefMaxAmount + Inventory.UseSound "PuzzleSuccess" + Inventory.PickupSound "misc/i_pkup" +} + +Actor Weapon : Inventory native +{ + + Inventory.PickupSound "misc/w_pkup" + Weapon.DefaultKickback + States + { + LightDone: + SHTG E 0 A_Light0 + Stop + } +} + +ACTOR WeaponGiver : Weapon native +{ +} + +Actor WeaponHolder : Inventory native +{ + +NOBLOCKMAP + +NOSECTOR + +INVENTORY.UNDROPPABLE +} + +Actor WeaponPiece : Inventory native +{ +} + diff --git a/wadsrc/static/decorate.txt b/wadsrc/static/decorate.txt index ee33abba4..6df4f842a 100644 --- a/wadsrc/static/decorate.txt +++ b/wadsrc/static/decorate.txt @@ -1,6 +1,7 @@ -#include "actors/nativeclasses.txt" +#include "actors/actor.txt" #include "actors/constants.txt" +#include "actors/shared/inventory.txt" #include "actors/shared/player.txt" #include "actors/shared/morph.txt" #include "actors/shared/botstuff.txt" diff --git a/zdoom.vcproj b/zdoom.vcproj index ef546bf44..1ff2f091b 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -644,10 +644,6 @@ RelativePath=".\src\info.cpp" > - - @@ -1289,10 +1285,6 @@ RelativePath=".\src\Info.h" > - -