Fix PlayerStageStats::SetLifeRecordAt to broadcast correct message for the player. Also adds Message::Message(MessageID) constructor.

This commit is contained in:
Kyzentun
2014-08-06 04:41:05 -06:00
parent 84a8d3adfb
commit 6be879f06d
6 changed files with 51 additions and 4 deletions
+6
View File
@@ -8,6 +8,12 @@ ________________________________________________________________________________
StepMania current development
--------------------------------------------------------------------------------
2014/08/06
----------
* [ScreenGameplay] LifeMeterChangedP1 message is no longer broadcast for for
P2's lifemeter. Use LifeMeterChangedP2. "Life" and "StepsSecond" are passed
in the params table for the message.
2013/10/09
----------
* [CombinedLifeMeterTug] Added names and commands to Separator and Frame items.
+7
View File
@@ -102,6 +102,13 @@ Message::Message( const RString &s )
m_bBroadcast = false;
}
Message::Message(const MessageID id)
{
m_sName= MessageIDToString(id);
m_pParams = new LuaTable;
m_bBroadcast = false;
}
Message::Message( const RString &s, const LuaReference &params )
{
m_sName = s;
+1
View File
@@ -90,6 +90,7 @@ const RString& MessageIDToString( MessageID m );
struct Message
{
explicit Message( const RString &s );
explicit Message(const MessageID id);
Message( const RString &s, const LuaReference &params );
~Message();
+21 -2
View File
@@ -25,8 +25,12 @@ const float LESSON_PASS_THRESHOLD = 0.8f;
Grade GetGradeFromPercent( float fPercent );
void PlayerStageStats::Init()
void PlayerStageStats::InternalInit()
{
m_for_multiplayer= false;
m_player_number= PLAYER_1;
m_multiplayer_number= MultiPlayer_P1;
m_bPlayerCanAchieveFullCombo = true;
m_bJoined = false;
m_vpPossibleSteps.clear();
@@ -67,6 +71,18 @@ void PlayerStageStats::Init()
m_HighScore = HighScore();
}
void PlayerStageStats::Init(PlayerNumber pn)
{
m_for_multiplayer= false;
m_player_number= pn;
}
void PlayerStageStats::Init(MultiPlayer pn)
{
m_for_multiplayer= true;
m_multiplayer_number= pn;
}
void PlayerStageStats::AddStats( const PlayerStageStats& other )
{
m_bJoined = other.m_bJoined;
@@ -353,7 +369,10 @@ void PlayerStageStats::SetLifeRecordAt( float fLife, float fStepsSecond )
// fSecond will always be greater than any value already in the map.
m_fLifeRecord[fStepsSecond] = fLife;
MESSAGEMAN->Broadcast( Message_LifeMeterChangedP1 );
Message msg(static_cast<MessageID>(Message_LifeMeterChangedP1+m_player_number));
msg.SetParam("Life", fLife);
msg.SetParam("StepsSecond", fStepsSecond);
MESSAGEMAN->Broadcast(msg);
// Memory optimization:
// If we have three consecutive records A, B, and C all with the same fLife,
+8 -2
View File
@@ -13,8 +13,10 @@ class PlayerStageStats
{
public:
/** @brief Set up the PlayerStageStats with default values. */
PlayerStageStats() { Init(); }
void Init();
PlayerStageStats() { InternalInit(); }
void InternalInit();
void Init(PlayerNumber pn);
void Init(MultiPlayer pn);
/**
* @brief Add stats from one PlayerStageStats to another.
@@ -31,6 +33,10 @@ public:
int GetLessonScoreNeeded() const;
void ResetScoreForLesson();
bool m_for_multiplayer;
PlayerNumber m_player_number;
MultiPlayer m_multiplayer_number;
bool m_bJoined;
bool m_bPlayerCanAchieveFullCombo;
vector<Steps*> m_vpPossibleSteps;
+8
View File
@@ -29,6 +29,14 @@ StageStats::StageStats()
m_fGameplaySeconds = 0;
m_fStepsSeconds = 0;
m_fMusicRate = 1;
FOREACH_PlayerNumber(pn)
{
m_player[pn].Init(pn);
}
FOREACH_MultiPlayer(pn)
{
m_multiPlayer[pn].Init(pn);
}
}
void StageStats::Init()