diff --git a/src/playsim/d_player.h b/src/playsim/d_player.h index 97460b427..a7c66b72c 100644 --- a/src/playsim/d_player.h +++ b/src/playsim/d_player.h @@ -391,11 +391,14 @@ public: float BlendB = 0; float BlendA = 0; - FString SoundClass = "Player"; + //FString SoundClass = "player"; + FString SoundClass = "player"; FString LogText; // [RH] Log for Strife FString SubtitleText; int SubtitleCounter; + //SoundClass != nullptr ? mo->StringVar(NAME_SoundClass) : "player"; + DAngle MinPitch = 0.; // Viewpitch limits (negative is up, positive is down) DAngle MaxPitch = 0.; diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index 80a3973da..5a9c4be9d 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -1611,21 +1611,24 @@ bool S_AreSoundsEquivalent (AActor *actor, int id1, int id2) static const char *GetSoundClass(AActor *pp) { auto player = pp->player; + + /*I couldn't just init SoundClass to NAME_SoundClass, GZDoom won't launch at all. Probably because that info is not parsed by the time the variable is initialized. + So I just SoundClass to NAME_SoundClass here if NAME_SoundClass is not null and the current SoundClass is player*/ + if (strcmp(pp->player->SoundClass.GetChars(), "player") == 0 && pp->NameVar(NAME_SoundClass) != NAME_None) + pp->player->SoundClass = pp->NameVar(NAME_SoundClass).GetChars(); + + FString sclass = player ? pp->player->SoundClass.GetChars() : "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()) + (unsigned)player->userinfo.GetSkin() < Skins.Size() && + strcmp(pp->player->SoundClass.GetChars(),sclass) == 0) { return Skins[player->userinfo.GetSkin()].Name.GetChars(); } - auto sclass = player? pp->NameVar(NAME_SoundClass) : NAME_None; - if (sclass != NAME_None) - pp->player->SoundClass = sclass.GetChars(); - else - pp->player->SoundClass = "Player"; - - return sclass != NAME_None ? sclass.GetChars() : "player"; + return sclass; } //========================================================================== @@ -1642,7 +1645,7 @@ int S_FindSkinnedSound (AActor *actor, FSoundID refid) if (actor != nullptr) { - if (actor->player != nullptr) pclass = actor->player->SoundClass; + if (actor->player != nullptr) pclass = GetSoundClass(actor); if (actor->player != nullptr) gender = actor->player->userinfo.GetGender(); } else