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 d5e8a1b85..5d87b4c37 100644 --- a/src/g_inventory/a_weapons.cpp +++ b/src/g_inventory/a_weapons.cpp @@ -491,7 +491,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 d6201418e..d46523b4b 100644 --- a/src/g_statusbar/sbar_mugshot.cpp +++ b/src/g_statusbar/sbar_mugshot.cpp @@ -477,7 +477,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 4eb36e30c..37e14c5d5 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -1036,6 +1036,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 8c3f01b11..3d8a66e55 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -819,18 +819,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 @@ -954,30 +942,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() @@ -2088,7 +2056,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 686aa1349..8c5af7464 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -1013,14 +1013,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 b8cd869d6..51ec33f3f 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -45,6 +45,7 @@ #include "serializer.h" #include "v_text.h" #include "g_levellocals.h" +#include "r_data/sprites.h" #include "vm.h" // MACROS ------------------------------------------------------------------ @@ -1888,6 +1889,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 @@ -1900,10 +1922,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 { @@ -2053,8 +2075,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 05f3c61a9..426197e6a 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -1358,7 +1358,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; } //========================================================================== @@ -1369,7 +1369,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(); @@ -1384,7 +1384,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; } } @@ -1691,7 +1691,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;