From acb4d89f52c7021e5a993771724848b93749af63 Mon Sep 17 00:00:00 2001 From: Zandrewnum Date: Tue, 20 Apr 2021 09:28:15 -0700 Subject: [PATCH] APROP_Soundclass update again - Just set init for SoundClass to empty. - Removed code block from SetActorProperty for APROP_Soundclass that does nothing - Lower-cased soundclass in FSerializer - Created a new const char to read the player's soundclass. If the playerpawn returns NAME_None for it's default, then it will set defaultsoundclass to "player". After running the skin code, the function now returns defaultsoundclass or soundclass, depending if soundclass is empty or not. - Renamed GetSoundClass to S_GetSoundClass --- src/playsim/d_player.h | 2 +- src/playsim/p_acs.cpp | 13 ++++--------- src/playsim/p_user.cpp | 2 +- src/sound/s_advsound.cpp | 13 ++++++------- src/sound/s_sound.h | 2 +- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/playsim/d_player.h b/src/playsim/d_player.h index 44f72d002..3dc3acc16 100644 --- a/src/playsim/d_player.h +++ b/src/playsim/d_player.h @@ -391,7 +391,7 @@ public: float BlendB = 0; float BlendA = 0; - FString SoundClass = ""; + FString SoundClass; FString LogText; // [RH] Log for Strife FString SubtitleText; int SubtitleCounter; diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index fe7eba54f..674aad0f4 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -4311,16 +4311,11 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) case APROP_SoundClass: if (actor->IsKindOf(NAME_PlayerPawn)) { - if (actor->player != NULL) + if (actor->player != nullptr) { - if(!strcmp(Level->Behaviors.LookupString(value), "")) - { - actor->player->SoundClass = ""; - } actor->player->SoundClass = Level->Behaviors.LookupString(value); } - } - + } break; default: @@ -4420,7 +4415,7 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_MaxStepHeight: return DoubleToACS(actor->MaxStepHeight); case APROP_MaxDropOffHeight: return DoubleToACS(actor->MaxDropOffHeight); case APROP_DamageType: return GlobalACSStrings.AddString(actor->DamageType.GetChars()); - case APROP_SoundClass: return GlobalACSStrings.AddString(GetSoundClass(actor)); + case APROP_SoundClass: return GlobalACSStrings.AddString(S_GetSoundClass(actor)); default: return 0; } @@ -4494,7 +4489,7 @@ int DLevelScript::CheckActorProperty (int tid, int property, int value) case APROP_Species: string = actor->GetSpecies().GetChars(); break; case APROP_NameTag: string = actor->GetTag(); break; case APROP_DamageType: string = actor->DamageType.GetChars(); break; - case APROP_SoundClass: string = GetSoundClass(actor); break; + case APROP_SoundClass: string = S_GetSoundClass(actor); break; } if (string == NULL) string = ""; return (!stricmp(string, Level->Behaviors.LookupString(value))); diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index b92cebb33..9d976431b 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -1698,7 +1698,7 @@ void player_t::Serialize(FSerializer &arc) ("onground", onground) ("musinfoactor", MUSINFOactor) ("musinfotics", MUSINFOtics) - ("SoundClass", SoundClass); + ("soundclass", SoundClass); if (arc.isWriting ()) { diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index 5699b327b..b29b8f121 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -1608,10 +1608,10 @@ bool S_AreSoundsEquivalent (AActor *actor, int id1, int id2) // //=========================================================================== -const char *GetSoundClass(AActor *pp) +const char *S_GetSoundClass(AActor *pp) { auto player = pp->player; - + const char *defaultsoundclass = pp->NameVar(NAME_SoundClass) == NAME_None ? "player" : pp->NameVar(NAME_SoundClass).GetChars(); if (player != nullptr && (player->mo == nullptr || !(player->mo->flags4 &MF4_NOSKIN)) && (unsigned int)player->userinfo.GetSkin() >= PlayerClasses.Size() && @@ -1620,9 +1620,8 @@ const char *GetSoundClass(AActor *pp) { return Skins[player->userinfo.GetSkin()].Name.GetChars(); } - auto sclass = player->SoundClass.IsEmpty() ? pp->NameVar(NAME_SoundClass).GetChars() : player->SoundClass.GetChars(); - - return sclass ? sclass : "player"; + + return player->SoundClass.IsEmpty() ? defaultsoundclass : player->SoundClass.GetChars(); } //========================================================================== @@ -1639,7 +1638,7 @@ int S_FindSkinnedSound (AActor *actor, FSoundID refid) if (actor != nullptr) { - if (actor->player != nullptr) pclass = GetSoundClass(actor); + if (actor->player != nullptr) pclass = S_GetSoundClass(actor); if (actor->player != nullptr) gender = actor->player->userinfo.GetGender(); } else @@ -1684,7 +1683,7 @@ int S_FindSkinnedSoundEx (AActor *actor, const char *name, const char *extendedn void S_MarkPlayerSounds (AActor *player) { - const char *playerclass = GetSoundClass(player); + const char *playerclass = S_GetSoundClass(player); int classidx = S_FindPlayerClass(playerclass); if (classidx < 0) { diff --git a/src/sound/s_sound.h b/src/sound/s_sound.h index 29b2f7b2b..c4c0655cf 100644 --- a/src/sound/s_sound.h +++ b/src/sound/s_sound.h @@ -70,7 +70,7 @@ bool S_AreSoundsEquivalent (AActor *actor, int id1, int id2); bool S_AreSoundsEquivalent (AActor *actor, const char *name1, const char *name2); int S_LookupPlayerSound (const char *playerclass, int gender, const char *logicalname); int S_LookupPlayerSound (const char *playerclass, int gender, FSoundID refid); -const char *GetSoundClass(AActor *pp); +const char *S_GetSoundClass(AActor *pp); int S_FindSkinnedSound (AActor *actor, FSoundID refid); int S_FindSkinnedSoundEx (AActor *actor, const char *logicalname, const char *extendedname); int S_AddSound (const char *logicalname, const char *lumpname, FScanner *sc=NULL); // Add sound by lumpname