Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletXF committed Sep 1, 2024
1 parent e5739a8 commit 4b0831f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SortIncludes: Never
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/Chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class ChartMeta {

[[nodiscard]] int GetKeyLaneCount() const { return KeyMode; }
[[nodiscard]] int GetScratchLaneCount() const { return IsDP ? 2 : 1; }
[[nodiscard]] int GetTotalLaneCount() const { return KeyMode + GetScratchLaneCount(); }
[[nodiscard]] int GetTotalLaneCount() const {
return KeyMode + GetScratchLaneCount();
}

[[nodiscard]] std::vector<int> GetKeyLaneIndices() const {
switch (KeyMode) {
Expand Down
27 changes: 15 additions & 12 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ inline bool Parser::MatchHeader(const std::string_view &str,
return true;
}

void Parser::Parse(const std::filesystem::path& fpath, Chart **chart,
void Parser::Parse(const std::filesystem::path &fpath, Chart **chart,
bool addReadyMeasure, bool metaOnly,
std::atomic_bool &bCancelled) {
#if BMS_PARSER_VERBOSE == 1
Expand Down Expand Up @@ -503,7 +503,9 @@ void Parser::Parse(const std::vector<unsigned char> &bytes, Chart **chart,
const auto g = Gcd(j, dataCount);
// ReSharper disable PossibleLossOfFraction

const auto position = static_cast<double>(j / g) / static_cast<double>(dataCount / g); // NOLINT(*-integer-division)
const auto position =
static_cast<double>(j / g) /
static_cast<double>(dataCount / g); // NOLINT(*-integer-division)

if (timelines.find(position) == timelines.end()) {
timelines[position] = new TimeLine(TempKey, metaOnly);
Expand Down Expand Up @@ -667,17 +669,17 @@ void Parser::Parse(const std::vector<unsigned char> &bytes, Chart **chart,

break;
case P1MineKeyBase: {
// landmine
++totalLandmineNotes;
if (metaOnly) {
break;
}
const auto damage = static_cast<float>(ParseInt(val, true)) / 2.0f;
timeline->SetNote(laneNumber, new LandmineNote{damage});
// landmine
++totalLandmineNotes;
if (metaOnly) {
break;
}
const auto damage = static_cast<float>(ParseInt(val, true)) / 2.0f;
timeline->SetNote(laneNumber, new LandmineNote{damage});
break;
}
default:
break;
break;
}
}
}
Expand Down Expand Up @@ -859,7 +861,7 @@ void Parser::ParseHeader(Chart *Chart, std::string_view cmd,
}
StopLengthTable[id] = std::strtod(Value.c_str(), nullptr);
} else if (MatchHeader(cmd, "MIDIFILE")) {
// TODO: handle this
// TODO: handle this
} else if (MatchHeader(cmd, "VIDEOFILE")) {
} else if (MatchHeader(cmd, "PLAYLEVEL")) {
Chart->Meta.PlayLevel =
Expand Down Expand Up @@ -923,7 +925,8 @@ void Parser::ParseHeader(Chart *Chart, std::string_view cmd,
}
}

inline unsigned long long Parser::Gcd(unsigned long long A, unsigned long long B) {
inline unsigned long long Parser::Gcd(unsigned long long A,
unsigned long long B) {
while (true) {
if (B == 0) {
return A;
Expand Down
9 changes: 5 additions & 4 deletions src/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Parser {
Parser();
void SetRandomSeed(unsigned int RandomSeed);

void Parse(const std::filesystem::path& path, Chart **Chart, bool addReadyMeasure,
bool metaOnly, std::atomic_bool &bCancelled);
void Parse(const std::filesystem::path &path, Chart **Chart,
bool addReadyMeasure, bool metaOnly, std::atomic_bool &bCancelled);
~Parser();
void Parse(const std::vector<unsigned char> &bytes, Chart **chart,
bool addReadyMeasure, bool metaOnly, std::atomic_bool &bCancelled);
Expand All @@ -54,8 +54,9 @@ class Parser {
void ParseHeader(Chart *Chart, std::string_view cmd, std::string_view Xx,
const std::string &Value);
static inline bool MatchHeader(const std::string_view &str,
const std::string_view &headerUpper);
static inline unsigned long long Gcd(unsigned long long A, unsigned long long B);
const std::string_view &headerUpper);
static inline unsigned long long Gcd(unsigned long long A,
unsigned long long B);
inline bool CheckResourceIdRange(int Id) const;
inline int ToWaveId(Chart *Chart, std::string_view Wav, bool metaOnly);
};
Expand Down
1 change: 0 additions & 1 deletion src/SHA256.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <string>
#include <vector>


// http://www.zedwood.com/article/cpp-sha256-function
namespace bms_parser {
class SHA256 {
Expand Down
2 changes: 1 addition & 1 deletion src/TimeLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TimeLine {
double Pos = 0;

explicit TimeLine(int lanes, bool metaOnly);

TimeLine *SetNote(int lane, Note *note);

TimeLine *SetInvisibleNote(int lane, Note *note);
Expand Down
2 changes: 1 addition & 1 deletion src/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MD5 {
void init();
typedef unsigned char uint1; // 8bit
typedef unsigned int uint4; // 32bit
enum { blocksize = 64 }; // VC6 won't eat a const static int here
enum { blocksize = 64 }; // VC6 won't eat a const static int here

void transform(const uint1 block[blocksize]);
static void decode(uint4 output[], const uint1 input[], size_type len);
Expand Down

0 comments on commit 4b0831f

Please sign in to comment.