Skip to content

Commit 7859184

Browse files
committed
Move Hold drop code into PlayerReplay & reduce PC_REPLAY checks
also fix some oop stuff
1 parent e8cd51c commit 7859184

File tree

6 files changed

+102
-86
lines changed

6 files changed

+102
-86
lines changed

Themes/_fallback/metrics.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ Class="ScreenSplash"
15521552
Fallback="ScreenSplash"
15531553
NextScreen=ToGameplay()
15541554
PrevScreen=Branch.BackOutOfStageInformation()
1555-
PrepareScreen="ScreenGameplay"
1555+
PrepareScreen=ToGameplay()
15561556
#
15571557
ForceTimer=true
15581558
TimerStealth=true

src/Etterna/Actor/Base/Actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ Actor::BeginTweening(float time, ITween* pTween)
959959

960960
// If the number of tweens to ever gets this large, there's probably an
961961
// infinitely recursing ActorCommand.
962-
if (m_Tweens.size() > 50 && !(GamePreferences::m_AutoPlay == PC_REPLAY)) {
962+
if (m_Tweens.size() > 50) {
963963
LuaHelpers::ReportScriptErrorFmt(
964964
"Tween overflow: \"%s\"; infinitely recursing ActorCommand?",
965965
GetLineage().c_str());

src/Etterna/Actor/Gameplay/Player.cpp

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ ThemeMetric<bool> CHECKPOINTS_FLASH_ON_HOLD(
151151
"Player",
152152
"CheckpointsFlashOnHold"); // sm-ssc addition
153153
ThemeMetric<bool> IMMEDIATE_HOLD_LET_GO("Player", "ImmediateHoldLetGo");
154-
ThemeMetric<bool> COMBO_BREAK_ON_IMMEDIATE_HOLD_LET_GO(
155-
"Player",
156-
"ComboBreakOnImmediateHoldLetGo");
157154
/**
158155
* @brief Must a Player step on a hold head for a hold to activate?
159156
*
@@ -292,6 +289,8 @@ Player::Init(const std::string& sType,
292289
DRAW_DISTANCE_BEFORE_TARGET_PIXELS.Load(sType,
293290
"DrawDistanceBeforeTargetsPixels");
294291
ROLL_BODY_INCREMENTS_COMBO.Load("Player", "RollBodyIncrementsCombo");
292+
COMBO_BREAK_ON_IMMEDIATE_HOLD_LET_GO.Load("Player",
293+
"ComboBreakOnImmediateHoldLetGo");
295294

296295
{
297296
// Init judgment positions
@@ -564,13 +563,7 @@ Player::Load()
564563
m_iFirstUncrossedRow = iNoteRow - 1;
565564
m_pJudgedRows->Reset(iNoteRow);
566565

567-
// TODO: Remove use of PlayerNumber.
568-
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
569-
570-
/* The editor reuses Players ... so we really need to make sure everything
571-
* is reset and not tweening. Perhaps ActorFrame should recurse to
572-
* subactors; then we could just this->StopTweening()? -glenn */
573-
// hurr why don't you just set m_bPropagateCommands on it then -aj
566+
// Make sure c++ bound actor's tweens are reset if they exist
574567
if (m_sprJudgment)
575568
m_sprJudgment->PlayCommand("Reset");
576569
if (m_pPlayerStageStats != nullptr) {
@@ -580,11 +573,6 @@ Player::Load()
580573
->m_iCurMissCombo); // combo can persist between songs and games
581574
}
582575

583-
/* Don't re-init this; that'll reload graphics. Add a separate Reset() call
584-
* if some ScoreDisplays need it. */
585-
// if( m_pScore )
586-
// m_pScore->Init( pn );
587-
588576
// Mina garbage - Mina
589577
m_Timing = GAMESTATE->m_pCurSteps->GetTimingData();
590578
m_Timing->NegStopAndBPMCheck();
@@ -636,8 +624,6 @@ Player::Load()
636624
GAMESTATE->GetCurrentStyle(GetPlayerState()->m_PlayerNumber)
637625
->m_StepsType);
638626

639-
const Song* pSong = GAMESTATE->m_pCurSong;
640-
641627
// Generate some cache data structure.
642628
GenerateCacheDataStructure(m_pPlayerState, m_NoteData);
643629

@@ -654,13 +640,6 @@ Player::Load()
654640
iDrawDistanceBeforeTargetsPixels);
655641
}
656642

657-
// set this in Update
658-
// m_pJudgment->SetX( JUDGMENT_X.GetValue(pn,bPlayerUsingBothSides) );
659-
// m_pJudgment->SetY( bReverse ? JUDGMENT_Y_REVERSE : JUDGMENT_Y );
660-
661-
// Need to set Y positions of all these elements in Update since
662-
// they change depending on PlayerOptions.
663-
664643
// Load keysounds. If sounds are already loaded (as in the editor), don't
665644
// reload them.
666645
// XXX: the editor will load several duplicate copies (in each NoteField),
@@ -669,14 +648,15 @@ Player::Load()
669648
// ScreenGameplay::m_pSoundMusic and ScreenEdit::m_pSoundMusic?) We don't
670649
// have to load separate copies to set player fade: always make a copy, and
671650
// set the fade on the copy.
651+
const Song* pSong = GAMESTATE->m_pCurSong;
672652
std::string sSongDir = pSong->GetSongDir();
673653
m_vKeysounds.resize(pSong->m_vsKeysoundFile.size());
674654

675655
// parameters are invalid somehow... -aj
676656
RageSoundLoadParams SoundParams;
677657
SoundParams.m_bSupportPan = true;
678658

679-
float fBalance = GameSoundManager::GetPlayerBalance(pn);
659+
float fBalance = GameSoundManager::GetPlayerBalance(PLAYER_1);
680660
for (unsigned i = 0; i < m_vKeysounds.size(); i++) {
681661
std::string sKeysoundFilePath = sSongDir + pSong->m_vsKeysoundFile[i];
682662
RageSound& sound = m_vKeysounds[i];
@@ -690,11 +670,6 @@ Player::Load()
690670
SendComboMessages(m_pPlayerStageStats->m_iCurCombo,
691671
m_pPlayerStageStats->m_iCurMissCombo);
692672

693-
// If we are in a replay, attempt to load the real tapper stuff
694-
if (GamePreferences::m_AutoPlay == PC_REPLAY) {
695-
PlayerAI::SetUpExactTapMap(m_Timing);
696-
}
697-
698673
SAFE_DELETE(m_pIterNeedsTapJudging);
699674
m_pIterNeedsTapJudging = new NoteData::all_tracks_iterator(
700675
m_NoteData.GetTapNoteRangeAllTracks(iNoteRow, MAX_NOTE_ROW));
@@ -1107,39 +1082,6 @@ Player::UpdateHoldNotes(int iSongRow,
11071082
return; // we don't need to update the logic for this group
11081083
}
11091084

1110-
if (GamePreferences::m_AutoPlay == PC_REPLAY) {
1111-
FOREACH(TrackRowTapNote, vTN, trtn)
1112-
{
1113-
TapNote& tn = *trtn->pTN;
1114-
1115-
// check from now until the head of the hold to see if it should die
1116-
// possibly really bad, but we dont REALLY care that much about fps
1117-
// in replays, right?
1118-
bool holdDropped = false;
1119-
for (int yeet = vTN[0].iRow; yeet <= iSongRow && !holdDropped;
1120-
yeet++) {
1121-
if (PlayerAI::DetermineIfHoldDropped(yeet, trtn->iTrack)) {
1122-
holdDropped = true;
1123-
}
1124-
}
1125-
1126-
if (holdDropped) // it should be dead
1127-
{
1128-
tn.HoldResult.bHeld = false;
1129-
tn.HoldResult.bActive = false;
1130-
tn.HoldResult.fLife = 0.f;
1131-
tn.HoldResult.hns = HNS_LetGo;
1132-
1133-
// score the dead hold
1134-
if (COMBO_BREAK_ON_IMMEDIATE_HOLD_LET_GO)
1135-
IncrementMissCombo();
1136-
SetHoldJudgment(tn, iFirstTrackWithMaxEndRow, iSongRow);
1137-
HandleHoldScore(tn);
1138-
return;
1139-
}
1140-
}
1141-
}
1142-
11431085
// LOG->Trace("hold note doesn't already have result, let's check.");
11441086

11451087
// LOG->Trace( ssprintf("[C++] hold note score:
@@ -1202,9 +1144,6 @@ Player::UpdateHoldNotes(int iSongRow,
12021144
(iStartRow + trtn->pTN->iDuration) > iSongRow) {
12031145
int iTrack = trtn->iTrack;
12041146

1205-
// TODO: Remove use of PlayerNumber.
1206-
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
1207-
12081147
if (m_pPlayerState->m_PlayerController != PC_HUMAN) {
12091148
// TODO: Make the CPU miss sometimes.
12101149
if (m_pPlayerState->m_PlayerController == PC_AUTOPLAY) {
@@ -1217,7 +1156,7 @@ Player::UpdateHoldNotes(int iSongRow,
12171156
} else {
12181157
vector<GameInput> GameI;
12191158
GAMESTATE->GetCurrentStyle(GetPlayerState()->m_PlayerNumber)
1220-
->StyleInputToGameInput(iTrack, pn, GameI);
1159+
->StyleInputToGameInput(iTrack, PLAYER_1, GameI);
12211160

12221161
bIsHoldingButton &=
12231162
INPUTMAPPER->IsBeingPressed(GameI, m_pPlayerState->m_mp);
@@ -2529,9 +2468,7 @@ Player::CrossedRows(int iLastRowCrossed,
25292468
tn.type != TapNoteType_AutoKeysound &&
25302469
tn.result.tns == TNS_None &&
25312470
this->m_Timing->IsJudgableAtRow(iRow)) {
2532-
if ((m_pPlayerState->m_PlayerController == PC_REPLAY &&
2533-
PlayerAI::GetReplayType() != 2) ||
2534-
m_pPlayerState->m_PlayerController == PC_AUTOPLAY ||
2471+
if (m_pPlayerState->m_PlayerController == PC_AUTOPLAY ||
25352472
m_pPlayerState->m_PlayerController == PC_CPU) {
25362473
Step(iTrack, iRow, now, false, false);
25372474
if (m_pPlayerState->m_PlayerController == PC_AUTOPLAY ||
@@ -2562,8 +2499,7 @@ Player::CrossedRows(int iLastRowCrossed,
25622499
/* Update hold checkpoints
25632500
*
25642501
* TODO: Move this to a separate function. */
2565-
if (m_bTickHolds && m_pPlayerState->m_PlayerController != PC_AUTOPLAY &&
2566-
m_pPlayerState->m_PlayerController != PC_REPLAY) {
2502+
if (m_bTickHolds && m_pPlayerState->m_PlayerController == PC_HUMAN) {
25672503
// Few rows typically cross per update. Easier to check all crossed rows
25682504
// than to calculate from timing segments.
25692505
for (int r = m_iFirstUncrossedRow; r <= iLastRowCrossed; ++r) {
@@ -3255,7 +3191,8 @@ Player::SetHoldJudgment(TapNote& tn, int iTrack, int iRow)
32553191
m_pPlayerStageStats->m_fWifeScore = curwifescore / totalwifescore;
32563192
ChangeWifeRecord();
32573193
#else
3258-
if (m_pPlayerState->m_PlayerController == PC_HUMAN) {
3194+
if (m_pPlayerState->m_PlayerController == PC_HUMAN ||
3195+
m_pPlayerState->m_PlayerController == PC_REPLAY) {
32593196
m_pPlayerStageStats->m_fWifeScore =
32603197
curwifescore / totalwifescore;
32613198
m_pPlayerStageStats->CurWifeScore = curwifescore;

src/Etterna/Actor/Gameplay/Player.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ class Player : public ActorFrame
7878
int iRow;
7979
TapNote* pTN;
8080
};
81-
void UpdateHoldNotes(int iSongRow,
82-
float fDeltaTime,
83-
vector<TrackRowTapNote>& vTN);
84-
85-
void Init(const std::string& sType,
86-
PlayerState* pPlayerState,
87-
PlayerStageStats* pPlayerStageStats,
88-
LifeMeter* pLM,
89-
ScoreKeeper* pPrimaryScoreKeeper);
90-
void Load();
81+
virtual void UpdateHoldNotes(int iSongRow,
82+
float fDeltaTime,
83+
vector<TrackRowTapNote>& vTN);
84+
85+
virtual void Init(const std::string& sType,
86+
PlayerState* pPlayerState,
87+
PlayerStageStats* pPlayerStageStats,
88+
LifeMeter* pLM,
89+
ScoreKeeper* pPrimaryScoreKeeper);
90+
virtual void Load();
9191
virtual void CrossedRows(int iLastRowCrossed,
9292
const std::chrono::steady_clock::time_point& now);
9393
/**
@@ -302,6 +302,7 @@ class Player : public ActorFrame
302302
PLAYER INIT MUST LOAD THIS OR YOU CRASH
303303
*/
304304
ThemeMetric<bool> ROLL_BODY_INCREMENTS_COMBO;
305+
ThemeMetric<bool> COMBO_BREAK_ON_IMMEDIATE_HOLD_LET_GO;
305306

306307
#define NUM_REVERSE 2
307308
#define NUM_CENTERED 2

src/Etterna/Actor/Gameplay/PlayerReplay.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,80 @@ PlayerReplay::Init(const std::string& sType,
4040
m_pPlayerStageStats->m_bDisqualified = true;
4141
}
4242

43+
void
44+
PlayerReplay::Load()
45+
{
46+
Player::Load();
47+
48+
// Set the exact tap map when loading replay
49+
PlayerAI::SetUpExactTapMap(m_Timing);
50+
}
51+
52+
void
53+
PlayerReplay::UpdateHoldNotes(int iSongRow,
54+
float fDeltaTime,
55+
vector<TrackRowTapNote>& vTN)
56+
{
57+
Player::UpdateHoldNotes(iSongRow, fDeltaTime, vTN);
58+
ASSERT(!vTN.empty());
59+
60+
int iStartRow = vTN[0].iRow;
61+
int iMaxEndRow = INT_MIN;
62+
int iFirstTrackWithMaxEndRow = -1;
63+
64+
TapNoteSubType subType = TapNoteSubType_Invalid;
65+
FOREACH(TrackRowTapNote, vTN, trtn)
66+
{
67+
int iTrack = trtn->iTrack;
68+
ASSERT(iStartRow == trtn->iRow);
69+
TapNote& tn = *trtn->pTN;
70+
int iEndRow = iStartRow + tn.iDuration;
71+
if (subType == TapNoteSubType_Invalid)
72+
subType = tn.subType;
73+
74+
/* All holds must be of the same subType because fLife is handled
75+
* in different ways depending on the SubType. */
76+
ASSERT(tn.subType == subType);
77+
78+
if (iEndRow > iMaxEndRow) {
79+
iMaxEndRow = iEndRow;
80+
iFirstTrackWithMaxEndRow = iTrack;
81+
}
82+
}
83+
84+
ASSERT(iFirstTrackWithMaxEndRow != -1);
85+
86+
FOREACH(TrackRowTapNote, vTN, trtn)
87+
{
88+
TapNote& tn = *trtn->pTN;
89+
90+
// check from now until the head of the hold to see if it should die
91+
// possibly really bad, but we dont REALLY care that much about fps
92+
// in replays, right?
93+
bool holdDropped = false;
94+
for (int yeet = vTN[0].iRow; yeet <= iSongRow && !holdDropped; yeet++) {
95+
if (PlayerAI::DetermineIfHoldDropped(yeet, trtn->iTrack)) {
96+
holdDropped = true;
97+
}
98+
}
99+
100+
if (holdDropped) // it should be dead
101+
{
102+
tn.HoldResult.bHeld = false;
103+
tn.HoldResult.bActive = false;
104+
tn.HoldResult.fLife = 0.f;
105+
tn.HoldResult.hns = HNS_LetGo;
106+
107+
// score the dead hold
108+
if (COMBO_BREAK_ON_IMMEDIATE_HOLD_LET_GO)
109+
IncrementMissCombo();
110+
SetHoldJudgment(tn, iFirstTrackWithMaxEndRow, iSongRow);
111+
HandleHoldScore(tn);
112+
return;
113+
}
114+
}
115+
}
116+
43117
void
44118
PlayerReplay::UpdateHoldsAndRolls(
45119
float fDeltaTime,

src/Etterna/Actor/Gameplay/PlayerReplay.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ class PlayerReplay : public Player
1010
PlayerReplay(NoteData& nd, bool bVisibleParts = true);
1111
~PlayerReplay() override;
1212

13+
void UpdateHoldNotes(int iSongRow,
14+
float fDeltaTime,
15+
vector<TrackRowTapNote>& vTN) override;
1316
void Init(const std::string& sType,
1417
PlayerState* pPlayerState,
1518
PlayerStageStats* pPlayerStageStats,
1619
LifeMeter* pLM,
17-
ScoreKeeper* pPrimaryScoreKeeper);
20+
ScoreKeeper* pPrimaryScoreKeeper) override;
21+
void Load() override;
1822
void Update(float fDeltaTime) override;
1923
void CrossedRows(int iLastrowCrossed,
2024
const std::chrono::steady_clock::time_point& now) override;

0 commit comments

Comments
 (0)