Skip to content

Commit

Permalink
Remove array-ness of NoteField m_pDisplays
Browse files Browse the repository at this point in the history
this was for managing Player NoteDisplays
but we only have 1 player ...
theres possibly reason for us to repurpose this in the future but I'm not fully sure when and where
so im leaving it as a kind of reminder i guess
  • Loading branch information
poco0317 committed Jan 28, 2021
1 parent 5017323 commit cd27903
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
18 changes: 5 additions & 13 deletions src/Etterna/Actor/Gameplay/NoteField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ NoteField::Unload()
delete m_NoteDisplay.second;
m_NoteDisplays.clear();
m_pCurDisplay = nullptr;
memset(m_pDisplays, 0, sizeof(m_pDisplays));
m_pDisplays = nullptr;
}

void
Expand Down Expand Up @@ -174,15 +174,8 @@ NoteField::CacheAllUsedNoteSkins()
auto it = m_NoteDisplays.find(sCurrentNoteSkinLower);
ASSERT_M(it != m_NoteDisplays.end(), sCurrentNoteSkinLower);
m_pCurDisplay = it->second;
memset(m_pDisplays, 0, sizeof(m_pDisplays));

auto sNoteSkinLower =
GAMESTATE->m_pPlayerState->m_PlayerOptions.GetCurrent().m_sNoteSkin;
NOTESKIN->ValidateNoteSkinName(sNoteSkinLower);
sNoteSkinLower = make_lower(sNoteSkinLower);
it = m_NoteDisplays.find(sNoteSkinLower);
ASSERT_M(it != m_NoteDisplays.end(), sNoteSkinLower);
m_pDisplays[PLAYER_1] = it->second;

m_pDisplays = it->second;

// I don't think this is needed?
// It's done in Load -- Nick12
Expand Down Expand Up @@ -277,8 +270,7 @@ NoteField::ensure_note_displays_have_skin()
ssprintf("iterator != m_NoteDisplays.end() [sNoteSkinLower = %s]",
sNoteSkinLower.c_str()));
}
memset(m_pDisplays, 0, sizeof(m_pDisplays));
m_pDisplays[PLAYER_1] = it->second;
m_pDisplays = it->second;
}

void
Expand All @@ -294,7 +286,7 @@ NoteField::InitColumnRenderers()
->m_iColsPerPlayer);
for (size_t ncr = 0; ncr < m_ColumnRenderers.size(); ++ncr) {
m_ColumnRenderers[ncr].m_displays[PLAYER_1] =
&(m_pDisplays[PLAYER_1]->display[ncr]);
&(m_pDisplays->display[ncr]);
m_ColumnRenderers[ncr].m_displays[PLAYER_INVALID] =
&(m_pCurDisplay->display[ncr]);
m_ColumnRenderers[ncr].m_column = ncr;
Expand Down
7 changes: 6 additions & 1 deletion src/Etterna/Actor/Gameplay/NoteField.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ class NoteField : public ActorFrame
/* All loaded note displays, mapped by their name. */
std::map<std::string, NoteDisplayCols*> m_NoteDisplays;
NoteDisplayCols* m_pCurDisplay;
NoteDisplayCols* m_pDisplays[NUM_PlayerNumber];
// leaving this here in case we want to vectorize this in the future
// the purpose is to have a display for each player
// this pointer does not get deleted
// why: it points to a member of m_NoteDisplays which is managed
// (same for m_pCurDisplay)
NoteDisplayCols* m_pDisplays;

// decorations, mostly used in MODE_EDIT
AutoActor m_sprBoard;
Expand Down

0 comments on commit cd27903

Please sign in to comment.