Skip to content

Commit

Permalink
Widely remove the dependency on NUM_PLAYERS
Browse files Browse the repository at this point in the history
This breaks some stuff. Experimental change.
  • Loading branch information
poco0317 committed Dec 22, 2018
1 parent 2299afc commit 1abc266
Show file tree
Hide file tree
Showing 71 changed files with 1,283 additions and 1,348 deletions.
24 changes: 12 additions & 12 deletions src/ArrowEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct PerPlayerData
float m_fBeatFactor;
float m_fExpandSeconds;
};
PerPlayerData g_EffectData[NUM_PLAYERS];
PerPlayerData g_EffectData;
} // namespace;

void
Expand All @@ -140,17 +140,17 @@ ArrowEffects::Update()
FOREACH_EnabledPlayer(pn)
{
const Style* pStyle = GAMESTATE->GetCurrentStyle(pn);
const Style::ColumnInfo* pCols = pStyle->m_ColumnInfo[pn];
const Style::ColumnInfo* pCols = pStyle->m_ColumnInfo;
const SongPosition& position =
GAMESTATE->m_bIsUsingStepTiming
? GAMESTATE->m_pPlayerState[pn]->m_Position
? GAMESTATE->m_pPlayerState->m_Position
: GAMESTATE->m_Position;
const float field_zoom = GAMESTATE->m_pPlayerState[pn]->m_NotefieldZoom;
const float* effects = GAMESTATE->m_pPlayerState[pn]
const float field_zoom = GAMESTATE->m_pPlayerState->m_NotefieldZoom;
const float* effects = GAMESTATE->m_pPlayerState
->m_PlayerOptions.GetCurrent()
.m_fEffects;

PerPlayerData& data = g_EffectData[pn];
PerPlayerData& data = g_EffectData;

if (!position.m_bFreeze || !position.m_bDelay) {
data.m_fExpandSeconds += fTime - fLastTime;
Expand Down Expand Up @@ -350,7 +350,7 @@ ArrowEffects::GetYOffset(const PlayerState* pPlayerState,

float fSongBeat = position.m_fSongBeatVisible;
PlayerNumber pn = pPlayerState->m_PlayerNumber;
Steps* pCurSteps = GAMESTATE->m_pCurSteps[pn];
Steps* pCurSteps = GAMESTATE->m_pCurSteps;

/* Usually, fTimeSpacing is 0 or 1, in which case we use entirely beat
* spacing or entirely time spacing (respectively). Occasionally, we tween
Expand Down Expand Up @@ -455,7 +455,7 @@ ArrowEffects::GetYOffset(const PlayerState* pPlayerState,

if (fAccels[PlayerOptions::ACCEL_EXPAND] != 0) {
// TODO: Don't index by PlayerNumber.
PerPlayerData& data = g_EffectData[pPlayerState->m_PlayerNumber];
PerPlayerData& data = g_EffectData;

float fExpandMultiplier = SCALE(
RageFastCos(data.m_fExpandSeconds * EXPAND_MULTIPLIER_FREQUENCY),
Expand Down Expand Up @@ -524,7 +524,7 @@ ArrowEffects::GetYPos(int iCol,
// Doing the math with a precalculated result of 0 should be faster than
// checking whether tipsy is on. -Kyz
// TODO: Don't index by PlayerNumber.
PerPlayerData& data = g_EffectData[curr_options->m_pn];
PerPlayerData& data = g_EffectData;
f += fEffects[PlayerOptions::EFFECT_TIPSY] * data.m_tipsy_result[iCol];

// In beware's DDR Extreme-focused fork of StepMania 3.9, this value is
Expand All @@ -545,7 +545,7 @@ ArrowEffects::GetYOffsetFromYPos(int iCol,
// Doing the math with a precalculated result of 0 should be faster than
// checking whether tipsy is on. -Kyz
// TODO: Don't index by PlayerNumber.
PerPlayerData& data = g_EffectData[curr_options->m_pn];
PerPlayerData& data = g_EffectData;
f +=
fEffects[PlayerOptions::EFFECT_TIPSY] * data.m_tipsy_offset_result[iCol];

Expand All @@ -572,8 +572,8 @@ ArrowEffects::GetXPos(const PlayerState* pPlayerState,

// TODO: Don't index by PlayerNumber.
const Style::ColumnInfo* pCols =
pStyle->m_ColumnInfo[pPlayerState->m_PlayerNumber];
PerPlayerData& data = g_EffectData[pPlayerState->m_PlayerNumber];
pStyle->m_ColumnInfo;
PerPlayerData& data = g_EffectData;

if (fEffects[PlayerOptions::EFFECT_TORNADO] != 0) {
const float fRealPixelOffset =
Expand Down
41 changes: 20 additions & 21 deletions src/AutoKeysounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
void
AutoKeysounds::Load(PlayerNumber pn, const NoteData& ndAutoKeysoundsOnly)
{
m_ndAutoKeysoundsOnly[pn] = ndAutoKeysoundsOnly;
m_ndAutoKeysoundsOnly = ndAutoKeysoundsOnly;
}

void
Expand All @@ -53,7 +53,7 @@ AutoKeysounds::LoadAutoplaySoundsInto(RageSoundReader_Chain* pChain)
* Add all current autoplay sounds in both players to the chain.
*/
int iNumTracks =
m_ndAutoKeysoundsOnly[GAMESTATE->GetMasterPlayerNumber()].GetNumTracks();
m_ndAutoKeysoundsOnly.GetNumTracks();
for (int t = 0; t < iNumTracks; t++) {
int iRow = -1;
for (;;) {
Expand All @@ -62,14 +62,14 @@ AutoKeysounds::LoadAutoplaySoundsInto(RageSoundReader_Chain* pChain)
FOREACH_EnabledPlayer(pn)
{
// XXX Hack. Enabled players need not have their own note data.
if (t >= m_ndAutoKeysoundsOnly[pn].GetNumTracks())
if (t >= m_ndAutoKeysoundsOnly.GetNumTracks())
continue;
int iNextRowForPlayer = iRow;
/* XXX: If a BMS file only has one tap note per track,
* this will prevent any keysounds from loading.
* This leads to failure later on.
* We need a better way to prevent this. */
if (m_ndAutoKeysoundsOnly[pn].GetNextTapNoteRowForTrack(
if (m_ndAutoKeysoundsOnly.GetNextTapNoteRowForTrack(
t, iNextRowForPlayer))
iNextRow = min(iNextRow, iNextRowForPlayer);
}
Expand All @@ -78,21 +78,20 @@ AutoKeysounds::LoadAutoplaySoundsInto(RageSoundReader_Chain* pChain)
break;
iRow = iNextRow;

TapNote tn[NUM_PLAYERS];
FOREACH_EnabledPlayer(pn) tn[pn] =
m_ndAutoKeysoundsOnly[pn].GetTapNote(t, iRow);
TapNote tn;
tn = m_ndAutoKeysoundsOnly.GetTapNote(t, iRow);

FOREACH_EnabledPlayer(pn)
{
if (tn[pn] == TAP_EMPTY)
if (tn == TAP_EMPTY)
continue;

ASSERT(tn[pn].type == TapNoteType_AutoKeysound);
if (tn[pn].iKeysoundIndex >= 0) {
ASSERT(tn.type == TapNoteType_AutoKeysound);
if (tn.iKeysoundIndex >= 0) {
RString sKeysoundFilePath =
sSongDir + pSong->m_vsKeysoundFile[tn[pn].iKeysoundIndex];
sSongDir + pSong->m_vsKeysoundFile[tn.iKeysoundIndex];
float fSeconds =
GAMESTATE->m_pCurSteps[pn]
GAMESTATE->m_pCurSteps
->GetTimingData()
->WhereUAtBroNoOffset(NoteRowToBeat(iRow)) +
SOUNDMAN->GetPlayLatency();
Expand Down Expand Up @@ -124,7 +123,7 @@ AutoKeysounds::LoadTracks(const Song* pSong,

vector<RString> vsMusicFile;
const RString sMusicPath =
GAMESTATE->m_pCurSteps[GAMESTATE->GetMasterPlayerNumber()]
GAMESTATE->m_pCurSteps
->GetMusicPath();

if (!sMusicPath.empty())
Expand Down Expand Up @@ -195,7 +194,7 @@ AutoKeysounds::FinishLoading()
Song* pSong = GAMESTATE->m_pCurSong;

vector<RageSoundReader*> apSounds;
LoadTracks(pSong, m_pSharedSound, m_pPlayerSounds[0]);
LoadTracks(pSong, m_pSharedSound, m_pPlayerSounds);

// Load autoplay sounds, if any.
{
Expand Down Expand Up @@ -223,13 +222,13 @@ AutoKeysounds::FinishLoading()
m_pSharedSound = new RageSoundReader_Pan(m_pSharedSound);
apSounds.push_back(m_pSharedSound);

if (m_pPlayerSounds[0] != nullptr) {
m_pPlayerSounds[0] =
new RageSoundReader_PitchChange(m_pPlayerSounds[0]);
m_pPlayerSounds[0] =
new RageSoundReader_PostBuffering(m_pPlayerSounds[0]);
m_pPlayerSounds[0] = new RageSoundReader_Pan(m_pPlayerSounds[0]);
apSounds.push_back(m_pPlayerSounds[0]);
if (m_pPlayerSounds != nullptr) {
m_pPlayerSounds =
new RageSoundReader_PitchChange(m_pPlayerSounds);
m_pPlayerSounds =
new RageSoundReader_PostBuffering(m_pPlayerSounds);
m_pPlayerSounds = new RageSoundReader_Pan(m_pPlayerSounds);
apSounds.push_back(m_pPlayerSounds);
}

if (apSounds.size() > 1) {
Expand Down
6 changes: 3 additions & 3 deletions src/AutoKeysounds.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AutoKeysounds
{
if (pn == PLAYER_INVALID)
return NULL;
return m_pPlayerSounds[pn];
return m_pPlayerSounds;
}

protected:
Expand All @@ -32,11 +32,11 @@ class AutoKeysounds
RageSoundReader*& pGlobal,
RageSoundReader*& pPlayer1);

NoteData m_ndAutoKeysoundsOnly[NUM_PLAYERS];
NoteData m_ndAutoKeysoundsOnly;
vector<RageSound> m_vKeysounds;
RageSound m_sSound;
RageSoundReader* m_pChain; // owned by m_sSound
RageSoundReader* m_pPlayerSounds[NUM_PLAYERS]; // owned by m_sSound
RageSoundReader* m_pPlayerSounds; // owned by m_sSound
RageSoundReader* m_pSharedSound; // owned by m_sSound
};

Expand Down
27 changes: 11 additions & 16 deletions src/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class BrightnessOverlay : public ActorFrame
void Set(float fBrightness);

private:
Quad m_quadBGBrightness[NUM_PLAYERS];
Quad m_quadBGBrightness;
Quad m_quadBGBrightnessFade;
};

Expand Down Expand Up @@ -938,7 +938,7 @@ bool
BackgroundImpl::IsDangerAllVisible()
{
// The players are never in danger in FAIL_OFF.
if (GAMESTATE->GetPlayerFailType(GAMESTATE->m_pPlayerState[PLAYER_1]) ==
if (GAMESTATE->GetPlayerFailType(GAMESTATE->m_pPlayerState) ==
FailType_Off) return false;
if (!g_bShowDanger)
return false;
Expand All @@ -956,17 +956,12 @@ BrightnessOverlay::BrightnessOverlay()
float fQuadWidth = (RIGHT_EDGE - LEFT_EDGE) / 2;
fQuadWidth -= g_fBackgroundCenterWidth / 2;

m_quadBGBrightness[0].StretchTo( RectF(LEFT_EDGE,TOP_EDGE,LEFT_EDGE+fQuadWidth,BOTTOM_EDGE) );
m_quadBGBrightness.StretchTo( RectF(LEFT_EDGE,TOP_EDGE,LEFT_EDGE+fQuadWidth,BOTTOM_EDGE) );
m_quadBGBrightnessFade.StretchTo( RectF(LEFT_EDGE+fQuadWidth,TOP_EDGE,RIGHT_EDGE-fQuadWidth,BOTTOM_EDGE) );
//m_quadBGBrightness[1].StretchTo( RectF(RIGHT_EDGE-fQuadWidth,TOP_EDGE,RIGHT_EDGE,BOTTOM_EDGE) );

m_quadBGBrightness[0].SetName("BrightnessOverlay");
ActorUtil::LoadAllCommands(m_quadBGBrightness[0], "Background");
this->AddChild(&m_quadBGBrightness[0]);

//m_quadBGBrightness[1].SetName( "BrightnessOverlay" );
//ActorUtil::LoadAllCommands( m_quadBGBrightness[1], "Background" );
//this->AddChild( &m_quadBGBrightness[1] );

m_quadBGBrightness.SetName("BrightnessOverlay");
ActorUtil::LoadAllCommands(m_quadBGBrightness, "Background");
this->AddChild(&m_quadBGBrightness);

m_quadBGBrightnessFade.SetName("BrightnessOverlay");
ActorUtil::LoadAllCommands(m_quadBGBrightnessFade, "Background");
Expand All @@ -988,8 +983,8 @@ BrightnessOverlay::Update(float fDeltaTime)
void
BrightnessOverlay::SetActualBrightness()
{
float fLeftBrightness = 1-GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().m_fCover;
float fRightBrightness = 1-GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().m_fCover;
float fLeftBrightness = 1-GAMESTATE->m_pPlayerState->m_PlayerOptions.GetCurrent().m_fCover;
float fRightBrightness = 1-GAMESTATE->m_pPlayerState->m_PlayerOptions.GetCurrent().m_fCover;

float fBaseBGBrightness = g_fBGBrightness;

Expand All @@ -1011,7 +1006,7 @@ BrightnessOverlay::SetActualBrightness()
RageColor LeftColor = GetBrightnessColor(fLeftBrightness);
RageColor RightColor = GetBrightnessColor(fRightBrightness);

m_quadBGBrightness[PLAYER_1].SetDiffuse( LeftColor );
m_quadBGBrightness.SetDiffuse( LeftColor );
m_quadBGBrightnessFade.SetDiffuseLeftEdge( LeftColor );
m_quadBGBrightnessFade.SetDiffuseRightEdge( RightColor );
}
Expand All @@ -1021,7 +1016,7 @@ BrightnessOverlay::Set(float fBrightness)
{
RageColor c = GetBrightnessColor(fBrightness);

m_quadBGBrightness[PLAYER_1].SetDiffuse(c);
m_quadBGBrightness.SetDiffuse(c);
m_quadBGBrightnessFade.SetDiffuse(c);
}

Expand Down
6 changes: 3 additions & 3 deletions src/CodeDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ CodeDetector::ChangeScrollSpeed(GameController controller, bool bIncrement)
// opt = PlayerOptions
// setup
PlayerNumber pn = INPUTMAPPER->ControllerToPlayerNumber( controller );
PlayerOptions po = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetPreferred();
PlayerOptions po = GAMESTATE->m_pPlayerState->m_PlayerOptions.GetPreferred();

/* what this code seems to be doing is:
* 1) getting the Speed line from the theme
Expand Down Expand Up @@ -235,7 +235,7 @@ CodeDetector::DetectAndAdjustMusicOptions(GameController controller)
auto code = static_cast<Code>(c);

PlayerOptions po =
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetPreferred();
GAMESTATE->m_pPlayerState->m_PlayerOptions.GetPreferred();

if (EnteredCode(controller, code)) {
switch (code) {
Expand Down Expand Up @@ -282,7 +282,7 @@ CodeDetector::DetectAndAdjustMusicOptions(GameController controller)
break;
}

GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.Assign(
GAMESTATE->m_pPlayerState->m_PlayerOptions.Assign(
ModsLevel_Preferred, po);

return true; // don't check any more
Expand Down
Loading

0 comments on commit 1abc266

Please sign in to comment.