diff --git a/src/d_player.h b/src/d_player.h index 2b67ead99..2c96de927 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -101,7 +101,6 @@ public: // These are virtual on the script side only. void PlayIdle(); - const char *GetSoundClass () const; int hasBuddha(); // returns 0 for no buddha, 1 for regular buddha and 2 for strong buddha enum EInvulState @@ -141,18 +140,17 @@ public: double ViewBob; double curBob; - // Former class properties that were moved into the object to get rid of the meta class. - FName SoundClass; // Sound class - FName Face; // Doom status bar face (when used) - FName Portrait; - FName Slot[10]; - - // Everything below this point is only used by scripted code. + // Everything below this point is only used by scripted code or through the scripted variable interface. int RunHealth; TObjPtr InvFirst; // first inventory item displayed on inventory bar double ForwardMove1, ForwardMove2; double SideMove1, SideMove2; double HexenArmor[5]; + + // Former class properties that were moved into the object to get rid of the meta class. + FName SoundClass; // Sound class + FName Portrait; + FName Slot[10]; PClassActor *FlechetteType; }; diff --git a/src/g_inventory/a_weapons.cpp b/src/g_inventory/a_weapons.cpp index 33f1d256c..4e4eb5ec7 100644 --- a/src/g_inventory/a_weapons.cpp +++ b/src/g_inventory/a_weapons.cpp @@ -498,7 +498,7 @@ void FWeaponSlots::SendDifferences(int playernum, const FWeaponSlots &other) void FWeaponSlots::SetFromPlayer(PClassActor *type) { Clear(); - auto Slot = ((APlayerPawn*)GetDefaultByType(type))->Slot; + auto Slot = &GetDefaultByType(type)->NameVar(NAME_Slot); for (int i = 0; i < NUM_WEAPON_SLOTS; ++i) { if (Slot[i] != NAME_None) diff --git a/src/g_statusbar/sbar_mugshot.cpp b/src/g_statusbar/sbar_mugshot.cpp index 4bec24f1b..000e16073 100644 --- a/src/g_statusbar/sbar_mugshot.cpp +++ b/src/g_statusbar/sbar_mugshot.cpp @@ -490,7 +490,7 @@ FTexture *FMugShot::GetFace(player_t *player, const char *default_face, int accu if (CurrentState != NULL) { int skin = player->userinfo.GetSkin(); - const char *skin_face = (stateflags & FMugShot::CUSTOM) ? nullptr : (player->morphTics ? ((APlayerPawn*)GetDefaultByType(player->MorphedPlayerClass))->Face.GetChars() : Skins[skin].Face.GetChars()); + const char *skin_face = (stateflags & FMugShot::CUSTOM) ? nullptr : (player->morphTics ? ((APlayerPawn*)GetDefaultByType(player->MorphedPlayerClass))->NameVar(NAME_Face).GetChars() : Skins[skin].Face.GetChars()); return CurrentState->GetCurrentFrameTexture(default_face, skin_face, level, angle); } return NULL; diff --git a/src/namedef.h b/src/namedef.h index f302a2127..93eeb0fd7 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -1027,6 +1027,9 @@ xx(ForwardMove1) xx(ForwardMove2) xx(SideMove1) xx(SideMove2) +xx(Face) +xx(Slot) +xx(SoundClass) xx(BlueCard) xx(YellowCard) diff --git a/src/p_user.cpp b/src/p_user.cpp index abf5eb058..d004ef42e 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -806,18 +806,6 @@ void APlayerPawn::Serialize(FSerializer &arc) ("fullheight", FullHeight, def->FullHeight); } -//=========================================================================== -// -// APlayerPawn :: MarkPlayerSounds -// -//=========================================================================== - -DEFINE_ACTION_FUNCTION(APlayerPawn, MarkPlayerSounds) -{ - PARAM_SELF_PROLOGUE(APlayerPawn); - S_MarkPlayerSounds(self->GetSoundClass()); - return 0; -} //=========================================================================== // // APlayerPawn :: BeginPlay @@ -941,30 +929,10 @@ void APlayerPawn::GiveDeathmatchInventory() } } -//=========================================================================== -// -// APlayerPawn :: GetSoundClass -// -//=========================================================================== - -const char *APlayerPawn::GetSoundClass() const -{ - if (player != NULL && - (player->mo == NULL || !(player->mo->flags4 &MF4_NOSKIN)) && - (unsigned int)player->userinfo.GetSkin() >= PlayerClasses.Size () && - (unsigned)player->userinfo.GetSkin() < Skins.Size()) - { - return Skins[player->userinfo.GetSkin()].Name.GetChars(); - } - - return SoundClass != NAME_None? SoundClass.GetChars() : "player"; -} - //=========================================================================== // // APlayerPawn :: hasBuddha // - //=========================================================================== int APlayerPawn::hasBuddha() @@ -2075,7 +2043,6 @@ DEFINE_FIELD(APlayerPawn, ViewBob) DEFINE_FIELD(APlayerPawn, curBob) DEFINE_FIELD(APlayerPawn, FullHeight) DEFINE_FIELD(APlayerPawn, SoundClass) -DEFINE_FIELD(APlayerPawn, Face) DEFINE_FIELD(APlayerPawn, Portrait) DEFINE_FIELD(APlayerPawn, Slot) DEFINE_FIELD(APlayerPawn, HexenArmor) diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 594a07fb1..762489025 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -1017,14 +1017,8 @@ void R_InitSprites () auto basetype = ((APlayerPawn*)GetDefaultByType(PlayerClasses[i].Type)); Skins[i].Name = "Base"; - if (basetype->Face == NAME_None) - { - Skins[i].Face = "STF"; - } - else - { - Skins[i].Face = basetype->Face; - } + auto face = basetype->NameVar(NAME_Face); + Skins[i].Face = face == NAME_None? FName("STF") : face; Skins[i].range0start = basetype->IntVar(NAME_ColorRangeStart); Skins[i].range0end = basetype->IntVar(NAME_ColorRangeEnd); Skins[i].Scale = basetype->Scale; diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index dc12a4edd..c92ac6c26 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -53,6 +53,7 @@ #include "serializer.h" #include "v_text.h" #include "g_levellocals.h" +#include "r_data/sprites.h" #include "vm.h" // MACROS ------------------------------------------------------------------ @@ -1897,6 +1898,27 @@ bool S_AreSoundsEquivalent (AActor *actor, int id1, int id2) return id1 == id2; } +//=========================================================================== +// +// APlayerPawn :: GetSoundClass +// +//=========================================================================== + +static const char *GetSoundClass(AActor *pp) +{ + auto player = pp->player; + if (player != nullptr && + (player->mo == nullptr || !(player->mo->flags4 &MF4_NOSKIN)) && + (unsigned int)player->userinfo.GetSkin() >= PlayerClasses.Size() && + (unsigned)player->userinfo.GetSkin() < Skins.Size()) + { + return Skins[player->userinfo.GetSkin()].Name.GetChars(); + } + auto sclass = pp->NameVar(NAME_SoundClass); + + return sclass != NAME_None ? sclass.GetChars() : "player"; +} + //========================================================================== // // S_FindSkinnedSound @@ -1909,10 +1931,10 @@ int S_FindSkinnedSound (AActor *actor, FSoundID refid) const char *pclass; int gender = 0; - if (actor != NULL && actor->IsKindOf(RUNTIME_CLASS(APlayerPawn))) + if (actor != nullptr) { - pclass = static_cast(actor)->GetSoundClass (); - if (actor->player != NULL) gender = actor->player->userinfo.GetGender(); + pclass = GetSoundClass (actor); + if (actor->player != nullptr) gender = actor->player->userinfo.GetGender(); } else { @@ -2062,8 +2084,9 @@ void sfxinfo_t::MarkUsed() // //========================================================================== -void S_MarkPlayerSounds (const char *playerclass) +void S_MarkPlayerSounds (AActor *player) { + const char *playerclass = GetSoundClass(player); int classidx = S_FindPlayerClass(playerclass); if (classidx < 0) { diff --git a/src/s_sound.h b/src/s_sound.h index c6ee76236..7b971c046 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -364,7 +364,7 @@ int S_AddSoundLump (const char *logicalname, int lump); // Add sound by lump ind int S_AddPlayerSound (const char *playerclass, const int gender, int refid, const char *lumpname); int S_AddPlayerSound (const char *playerclass, const int gender, int refid, int lumpnum, bool fromskin=false); int S_AddPlayerSoundExisting (const char *playerclass, const int gender, int refid, int aliasto, bool fromskin=false); -void S_MarkPlayerSounds (const char *playerclass); +void S_MarkPlayerSounds (AActor *player); void S_ShrinkPlayerSoundLists (); void S_UnloadSound (sfxinfo_t *sfx); sfxinfo_t *S_LoadSound(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer = nullptr); diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index bb45eebfd..201e5e0a9 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -1375,7 +1375,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, soundclass, S, PlayerPawn) FString tmp = str; tmp.ReplaceChars (' ', '_'); - defaults->SoundClass = tmp.IsNotEmpty()? FName(tmp) : NAME_None; + defaults->NameVar(NAME_SoundClass) = tmp.IsNotEmpty()? FName(tmp) : NAME_None; } //========================================================================== @@ -1386,7 +1386,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, face, S, PlayerPawn) PROP_STRING_PARM(str, 0); FString tmp = str; - if (tmp.Len() == 0) defaults->Face = NAME_None; + if (tmp.Len() == 0) defaults->NameVar(NAME_Face) = NAME_None; else { tmp.ToUpper(); @@ -1401,7 +1401,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, face, S, PlayerPawn) "Invalid face '%s' for '%s';\nSTF replacement codes must be 3 alphanumeric characters.\n", tmp.GetChars(), info->TypeName.GetChars()); } - defaults->Face = tmp; + defaults->NameVar(NAME_Face) = tmp; } } @@ -1708,7 +1708,8 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, weaponslot, ISsssssssssssssssssssssssssssss PROP_STRING_PARM(str, i); weapons << ' ' << str; } - defaults->Slot[slot] = weapons.IsEmpty()? NAME_None : FName(weapons); + FName *slots = &defaults->NameVar(NAME_Slot); + slots[slot] = weapons.IsEmpty()? NAME_None : FName(weapons); } } diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 74a2c5d3b..603ac9773 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -1649,6 +1649,20 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckFor3DCeilingHit, CheckFor3DCeilingHit +//=========================================================================== +// +// APlayerPawn :: MarkPlayerSounds +// +//=========================================================================== + +DEFINE_ACTION_FUNCTION_NATIVE(APlayerPawn, MarkPlayerSounds, S_MarkPlayerSounds) +{ + PARAM_SELF_PROLOGUE(APlayerPawn); + S_MarkPlayerSounds(self); + return 0; +} + + DEFINE_FIELD(AActor, snext) DEFINE_FIELD(AActor, player) DEFINE_FIELD_NAMED(AActor, __Pos, pos) diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 6c0fe0473..461fc8686 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -25,7 +25,6 @@ class PlayerPawn : Actor native native clearscope Inventory InvFirst; // first inventory item displayed on inventory bar native clearscope Inventory InvSel; // selected inventory item native Name SoundClass; // Sound class - native Name Face; // Doom status bar face (when used) native Name Portrait; native Name Slot[10]; native double HexenArmor[5]; @@ -51,6 +50,7 @@ class PlayerPawn : Actor native meta Name HealingRadiusType; meta Name InvulMode; + meta Name Face; meta int TeleportFreezeTime; meta int ColorRangeStart; // Skin color range meta int ColorRangeEnd;