diff --git a/src/d_player.h b/src/d_player.h index e5644e8cb..e27bf1087 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -443,10 +443,15 @@ public: FName LastDamageType; // [RH] For damage-specific pain and death sounds - //Added by MC: - TObjPtr Bot; + TObjPtr MUSINFOactor; // For MUSINFO purposes + SBYTE MUSINFOtics; bool settings_controller; // Player can control game settings. + SBYTE crouching; + SBYTE crouchdir; + + //Added by MC: + TObjPtr Bot; float BlendR; // [RH] Final blending values float BlendG; @@ -458,8 +463,6 @@ public: int MinPitch; // Viewpitch limits (negative is up, positive is down) int MaxPitch; - SBYTE crouching; - SBYTE crouchdir; fixed_t crouchfactor; fixed_t crouchoffset; fixed_t crouchviewdelta; diff --git a/src/g_level.cpp b/src/g_level.cpp index 60609050a..fd6d8049a 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1457,7 +1457,9 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) if (SaveVersion >= 3313) { - arc << level.nextmusic; + // This is a player property now + int nextmusic; + arc << nextmusic; } // Hub transitions must keep the current total time diff --git a/src/g_level.h b/src/g_level.h index 6e07b0c74..8a4702639 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -412,7 +412,6 @@ struct FLevelLocals int musicorder; int cdtrack; unsigned int cdid; - int nextmusic; // For MUSINFO purposes FTextureID skytexture1; FTextureID skytexture2; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 608ecb407..9102c0472 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4480,7 +4480,8 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) p->mo->ResetAirSupply(false); p->Uncrouch(); p->MinPitch = p->MaxPitch = 0; // will be filled in by PostBeginPlay()/netcode - + p->MUSINFOactor = NULL; + p->MUSINFOtics = -1; p->velx = p->vely = 0; // killough 10/98: initialize bobbing to 0. diff --git a/src/p_user.cpp b/src/p_user.cpp index 4d05d2660..6042d5662 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -309,7 +309,9 @@ player_t::player_t() ConversationNPC(0), ConversationPC(0), ConversationNPCAngle(0), - ConversationFaceTalker(0) + ConversationFaceTalker(0), + MUSINFOactor(0), + MUSINFOtics(-1) { memset (&cmd, 0, sizeof(cmd)); memset (frags, 0, sizeof(frags)); @@ -400,6 +402,8 @@ player_t &player_t::operator=(const player_t &p) ConversationPC = p.ConversationPC; ConversationNPCAngle = p.ConversationNPCAngle; ConversationFaceTalker = p.ConversationFaceTalker; + MUSINFOactor = p.MUSINFOactor; + MUSINFOtics = p.MUSINFOtics; return *this; } @@ -430,6 +434,7 @@ size_t player_t::FixPointers (const DObject *old, DObject *rep) if (*&PremorphWeapon == old) PremorphWeapon = static_cast(rep), changed++; if (*&ConversationNPC == old) ConversationNPC = replacement, changed++; if (*&ConversationPC == old) ConversationPC = replacement, changed++; + if (*&MUSINFOactor == old) MUSINFOactor = replacement, changed++; return changed; } @@ -443,6 +448,7 @@ size_t player_t::PropagateMark() GC::Mark(ReadyWeapon); GC::Mark(ConversationNPC); GC::Mark(ConversationPC); + GC::Mark(MUSINFOactor); GC::Mark(PremorphWeapon); if (PendingWeapon != WP_NOCHANGE) { @@ -2331,6 +2337,30 @@ void P_PlayerThink (player_t *player) player->crouchoffset = -FixedMul(player->mo->ViewHeight, (FRACUNIT - player->crouchfactor)); + // MUSINFO stuff + if (player->MUSINFOtics >= 0 && player->MUSINFOactor != NULL) + { + if (--player->MUSINFOtics < 0) + { + if (player - players == consoleplayer) + { + if (player->MUSINFOactor->args[0] != 0) + { + FName *music = level.info->MusicMap.CheckKey(player->MUSINFOactor->args[0]); + + if (music != NULL) + { + S_ChangeMusic(music->GetChars(), player->MUSINFOactor->args[1]); + } + } + else + { + S_ChangeMusic("*"); + } + } + DPrintf("MUSINFO change for player %d to %d\n", (int)(player - players), player->MUSINFOactor->args[0]); + } + } if (player->playerstate == PST_DEAD) { @@ -3105,6 +3135,10 @@ void player_t::Serialize (FArchive &arc) { userinfo.SkinChanged(skinname, CurrentPlayerClass); } + if (SaveVersion >= 4522) + { + arc << MUSINFOactor << MUSINFOtics; + } } diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index f7a40da9b..60a6730f6 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -2348,7 +2348,6 @@ class AMusicChanger : public ASectorAction DECLARE_CLASS (AMusicChanger, ASectorAction) public: virtual bool DoTriggerAction (AActor *triggerer, int activationType); - virtual void Tick(); virtual void PostBeginPlay(); }; @@ -2356,49 +2355,27 @@ IMPLEMENT_CLASS(AMusicChanger) bool AMusicChanger::DoTriggerAction (AActor *triggerer, int activationType) { - if (activationType & SECSPAC_Enter) + if (activationType & SECSPAC_Enter && triggerer->player != NULL) { - if (args[0] == 0 || level.info->MusicMap.CheckKey(args[0])) - { - level.nextmusic = args[0]; - reactiontime = 30; + if (triggerer->player->MUSINFOactor != this) + { + triggerer->player->MUSINFOactor = this; + triggerer->player->MUSINFOtics = 30; } } return Super::DoTriggerAction (triggerer, activationType); } -void AMusicChanger::Tick() -{ - Super::Tick(); - if (reactiontime > -1 && --reactiontime == 0) - { - // Is it our music that's queued for being played? - if (level.nextmusic == args[0]) - { - if (args[0] != 0) - { - FName *music = level.info->MusicMap.CheckKey(args[0]); - - if (music != NULL) - { - S_ChangeMusic(music->GetChars(), args[1]); - } - } - else - { - S_ChangeMusic("*"); - } - } - } - } - void AMusicChanger::PostBeginPlay() { // The music changer should consider itself activated if the player // spawns in its sector as well as if it enters the sector during a P_TryMove. Super::PostBeginPlay(); - if (players[consoleplayer].mo && players[consoleplayer].mo->Sector == this->Sector) + for (int i = 0; i < MAXPLAYERS; ++i) { - TriggerAction(players[consoleplayer].mo, SECSPAC_Enter); + if (playeringame[i] && players[i].mo && players[i].mo->Sector == this->Sector) + { + TriggerAction(players[i].mo, SECSPAC_Enter); + } } } diff --git a/src/version.h b/src/version.h index de33e93a7..7f6d9cedd 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4521 +#define SAVEVER 4522 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)