-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HeldNote, MultiplayerAnalyzer and Scoring
- Loading branch information
1 parent
f6dadb1
commit 1aef75f
Showing
7 changed files
with
311 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#include "HeldNote.h" | ||
#include "Scoring.h" | ||
|
||
HeldNote::HeldNote() | ||
: mGameGem(0), unk_0x4(-1), mTrackType((TrackType)(kTrackBass | kTrackRealBass)), | ||
unk_0xc(0.0f), unk_0x10(0), unk_0x14(0.0f), unk_0x18(0), unk_0x1c(0), | ||
unk_0x20(false) {} | ||
|
||
HeldNote::HeldNote( | ||
TrackType trackType, int param2, const GameGem ¶m3, unsigned int param4 | ||
) | ||
: mGameGem(¶m3), unk_0x4(param2), mTrackType(trackType), unk_0xc(0), unk_0x14(0), | ||
unk_0x1c(param4), unk_0x20(true) { | ||
unsigned int ticks = param3.mDurationTicks; | ||
|
||
int bits = param3.CountBitsInSlotType(trackType); | ||
int slots = param3.NumSlots(); | ||
|
||
unk_0x20 = true; | ||
|
||
int tailPoints = TheScoring.GetTailPoints(trackType, ticks); | ||
|
||
unk_0x10 = tailPoints * bits; | ||
unk_0x18 = tailPoints * slots; | ||
|
||
if (param4 != slots) { | ||
unk_0x20 = false; | ||
} | ||
} | ||
|
||
const GameGem *HeldNote::GetGem() { | ||
MILO_ASSERT(mGameGem != 0, 0x44); | ||
|
||
return mGameGem; | ||
} | ||
|
||
unsigned int HeldNote::GetGemSlots() const { | ||
if (mGameGem == 0) { | ||
return 0; | ||
} | ||
|
||
return mGameGem->mSlots; | ||
} | ||
|
||
bool HeldNote::IsDone() const { | ||
return unk_0xc == unk_0x10; | ||
} | ||
|
||
bool HeldNote::HeldCompletely() const { | ||
bool complete = false; | ||
|
||
if (unk_0xc == unk_0x10 && unk_0x20) { | ||
complete = true; | ||
} | ||
|
||
return complete; | ||
} | ||
|
||
double HeldNote::SetHoldTime(float time) { | ||
MILO_ASSERT(mGameGem != 0, 0x66); | ||
|
||
double x = 0; | ||
double y = x - mGameGem->mMs; | ||
|
||
if (0.0 < y) { | ||
x = y; | ||
} | ||
|
||
y = mGameGem->mDurationMs - 4503599627370496.0; | ||
|
||
MILO_ASSERT(y <= 0, 0x6a); | ||
|
||
y = x / y; | ||
|
||
if (1 < y) { | ||
y = 1; | ||
} | ||
|
||
bool range = false; | ||
if (0 <= y && y < 1) { | ||
range = true; | ||
} | ||
|
||
MILO_ASSERT(!range, 0x6e); | ||
|
||
x = 0; | ||
|
||
float z = y * unk_0x10; | ||
|
||
y = z - unk_0xc; | ||
if (0 < y) { | ||
unk_0xc = z; | ||
unk_0x14 += y; | ||
x = y; | ||
} | ||
|
||
return x; | ||
} | ||
|
||
float HeldNote::GetPointFraction() { | ||
int headPoints = TheScoring.GetHeadPoints(mTrackType); | ||
int pointsPlus = headPoints + unk_0x18; | ||
|
||
if (pointsPlus) { | ||
return 0.0f; | ||
} | ||
|
||
float x = headPoints + unk_0x14 / pointsPlus; | ||
|
||
if (x < 0 || 1 < x) { | ||
MILO_WARN( | ||
"HeldNote::GetPointFraction: (%d + %f) / %d = %f is out of range [0, 1]", | ||
headPoints, | ||
unk_0x14, | ||
pointsPlus, | ||
x | ||
); | ||
x = 1; | ||
} | ||
|
||
return x; | ||
} | ||
|
||
float HeldNote::GetAwardedPercent() const { | ||
if (unk_0x18 == 0) { | ||
return 0.0f; | ||
} | ||
|
||
float x = unk_0x14 / unk_0x18; | ||
|
||
return x; | ||
} | ||
|
||
float HeldNote::GetAwardedPoints() const { | ||
return unk_0x14; | ||
} | ||
|
||
void HeldNote::ReleaseSlot(int slot) { | ||
unsigned int mask = 1 << slot; | ||
|
||
if ((unk_0x1c & mask) != 0) { | ||
GameGem *gem = (GameGem *)(unk_0x1c & ~mask); | ||
unk_0x1c = (unsigned int)gem; | ||
|
||
int bits = gem->CountBitsInSlotType(mask); | ||
int tailPoints = TheScoring.GetTailPoints(mTrackType, mGameGem->mDurationTicks); | ||
unk_0x10 = tailPoints * bits; | ||
unk_0x20 = false; | ||
unk_0xc *= bits / (bits + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef GAME_HELDNOTE_H | ||
#define GAME_HELDNOTE_H | ||
|
||
#include "beatmatch/GameGem.h" | ||
#include "beatmatch/TrackType.h" | ||
|
||
class HeldNote { | ||
public: | ||
HeldNote(); | ||
HeldNote(TrackType, int, const GameGem &, unsigned int); | ||
|
||
const GameGem *GetGem(); | ||
unsigned int GetGemSlots() const; | ||
bool IsDone() const; | ||
bool HeldCompletely() const; | ||
double SetHoldTime(float); | ||
|
||
float GetPointFraction(); | ||
|
||
float GetAwardedPercent() const; | ||
float GetAwardedPoints() const; | ||
|
||
void ReleaseSlot(int); | ||
|
||
const GameGem *mGameGem; | ||
int unk_0x4; | ||
TrackType mTrackType; | ||
float unk_0xc; | ||
int unk_0x10; | ||
float unk_0x14; | ||
int unk_0x18; | ||
unsigned int unk_0x1c; | ||
bool unk_0x20; | ||
}; | ||
|
||
#endif // GAME_HELDNOTE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "MultiplayerAnalyzer.h" | ||
|
||
MultiplayerAnalyzer::MultiplayerAnalyzer(SongData *songData) | ||
: mUnk_0x0(""), mSongData(songData), mUnk_0x10(), mUnk_0x18() {} | ||
|
||
float MultiplayerAnalyzer::GetMaxPoints(const UserGuid &userGuid) const { | ||
const MysteryType *data = GetData(userGuid); | ||
|
||
if (data == 0) { | ||
return 0; | ||
} | ||
|
||
return data->m_maxPoints; | ||
} | ||
|
||
float MultiplayerAnalyzer::GetMaxStreakPoints(const UserGuid &userGuid) const { | ||
const MysteryType *data = GetData(userGuid); | ||
|
||
if (data == 0) { | ||
return 0; | ||
} | ||
|
||
return data->m_maxStreakPoints; | ||
} | ||
|
||
float MultiplayerAnalyzer::GetBonusPoints(const UserGuid &userGuid) const { | ||
const MysteryType *data = GetData(userGuid); | ||
|
||
if (data == 0) { | ||
return 0.0f; | ||
} | ||
|
||
return data->unk_0x20 + data->unk_0x24; | ||
} | ||
|
||
const MysteryType *MultiplayerAnalyzer::GetData(const UserGuid &userGuid) const { | ||
for (int i = 0; i < mUnk_0x8.size(); i++) { | ||
if (mUnk_0x8[i].mGuid == userGuid) { | ||
return &mUnk_0x8[i]; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
MysteryType *MultiplayerAnalyzer::GetData(const UserGuid &userGuid) { | ||
for (int i = 0; i < mUnk_0x8.size(); i++) { | ||
if (mUnk_0x8[i].mGuid == userGuid) { | ||
return &mUnk_0x8[i]; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef GAME_MULTIPLAYERANALYZER_H | ||
#define GAME_MULTIPLAYERANALYZER_H | ||
|
||
#include "beatmatch/SongData.h" | ||
#include "system/utl/HxGuid.h" | ||
|
||
class MysteryType { | ||
public: | ||
HxGuid mGuid; | ||
char unk_pre[8]; | ||
float m_maxStreakPoints; | ||
float m_maxPoints; | ||
float unk_0x20; | ||
float unk_0x24; | ||
char unk_Stuff[24]; | ||
}; | ||
|
||
class PlayerScoreInfo {}; | ||
|
||
class MultiplayerAnalyzer { | ||
public: | ||
MultiplayerAnalyzer(SongData *); | ||
|
||
void PostLoad(); | ||
int TotalBasePoints() const; | ||
void AddUser(const UserGuid &); | ||
float GetMaxPoints(const UserGuid &) const; | ||
float GetMaxStreakPoints(const UserGuid &) const; | ||
float GetBonusPoints(const UserGuid &) const; | ||
|
||
void AddTrack(int, TrackType); | ||
void AddGem(int, const GameGem &); | ||
void AddSolo(const UserGuid &, int); | ||
void AddSolos(); | ||
void GetCodaExtents(const UserGuid &, int &, int &); | ||
void AddGems(); | ||
void AddCodas(); | ||
|
||
const MysteryType *GetData(const UserGuid &) const; | ||
MysteryType *GetData(const UserGuid &); | ||
|
||
char *mUnk_0x0; | ||
SongData *mSongData; | ||
|
||
// Whatever type is here is 0x40 size | ||
std::vector<MysteryType> mUnk_0x8; | ||
std::vector<PlayerScoreInfo *> mUnk_0x10; | ||
int mUnk_0x18; | ||
}; | ||
|
||
#endif // GAME_MULTIPLAYERANALYZER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "Scoring.h" | ||
|
||
Scoring TheScoring; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef GAME_SCORING_H | ||
#define GAME_SCORING_H | ||
|
||
#include "beatmatch/TrackType.h" | ||
|
||
class Scoring { | ||
public: | ||
int GetHeadPoints(TrackType) const; | ||
int GetTailPoints(TrackType, int) const; | ||
}; | ||
|
||
extern Scoring TheScoring; | ||
|
||
#endif // GAME_SCORING_H |