Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletXF committed May 1, 2024
1 parent ebe0483 commit 19d71b3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/Chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace bms_parser
int TotalLongNotes = 0;
int TotalScratchNotes = 0;
int TotalBackSpinNotes = 0;
int TotalLandmineNotes = 0;
int LnMode = 0; // 0: user decides, 1: LN, 2: CN, 3: HCN

int GetKeyLaneCount() const { return KeyMode; }
Expand Down
37 changes: 19 additions & 18 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ namespace bms_parser
{
const int measure = static_cast<int>(std::wcstol(line.substr(1, 3).c_str(), nullptr, 10));
lastMeasure = std::max(lastMeasure, measure);
const std::wstring_view ch = line.substr(4, 2);
const std::wstring ch = line.substr(4, 2);
const int channel = ParseInt(ch);
const std::wstring value = line.substr(7);
if (measures.find(measure) == measures.end())
Expand Down Expand Up @@ -549,8 +549,8 @@ namespace bms_parser
{
break;
}
std::wstring_view val_view = data.substr(j * 2, 2);
if (val_view == L"00")
std::wstring val = data.substr(j * 2, 2);
if (val == L"00")
{
if (timelines.size() == 0 && j == 0)
{
Expand Down Expand Up @@ -585,39 +585,39 @@ namespace bms_parser
{
break;
}
if (val_view == L"**")
if (val == L"**")
{
timeline->AddBackgroundNote(new Note{MetronomeWav});
break;
}
if (ParseInt(val_view) != 0)
if (ParseInt(val) != 0)
{
auto bgNote = new Note{ToWaveId(new_chart, val_view, metaOnly)};
auto bgNote = new Note{ToWaveId(new_chart, val, metaOnly)};
timeline->AddBackgroundNote(bgNote);
}

break;
case BpmChange:
{
int bpm = ParseHex(val_view);
int bpm = ParseHex(val);
timeline->Bpm = static_cast<double>(bpm);
// std::cout << "BPM_CHANGE: " << timeline->Bpm << ", on measure " << i << std::endl;
// Debug.Log($"BPM_CHANGE: {timeline.Bpm}, on measure {i}");
timeline->BpmChange = true;
break;
}
case BgaPlay:
timeline->BgaBase = ParseInt(val_view);
timeline->BgaBase = ParseInt(val);
break;
case PoorPlay:
timeline->BgaPoor = ParseInt(val_view);
timeline->BgaPoor = ParseInt(val);
break;
case LayerPlay:
timeline->BgaLayer = ParseInt(val_view);
timeline->BgaLayer = ParseInt(val);
break;
case BpmChangeExtend:
{
const auto id = ParseInt(val_view);
const auto id = ParseInt(val);
// std::cout << "BPM_CHANGE_EXTEND: " << id << ", on measure " << i << std::endl;
if (!CheckResourceIdRange(id))
{
Expand All @@ -639,7 +639,7 @@ namespace bms_parser
}
case Scroll:
{
const auto id = ParseInt(val_view);
const auto id = ParseInt(val);
if (!CheckResourceIdRange(id))
{
// UE_LOG(LogTemp, Warning, TEXT("Invalid Scroll id: %s"), *val);
Expand All @@ -658,7 +658,7 @@ namespace bms_parser
}
case Stop:
{
const auto id = ParseInt(val_view);
const auto id = ParseInt(val);
if (!CheckResourceIdRange(id))
{
// UE_LOG(LogTemp, Warning, TEXT("Invalid StopLength id: %s"), *val);
Expand All @@ -677,7 +677,7 @@ namespace bms_parser
}
case P1KeyBase:
{
const auto ch = ParseInt(val_view);
const auto ch = ParseInt(val);
if (ch == Lnobj && lastNote[laneNumber] != nullptr)
{
if (isScratch)
Expand Down Expand Up @@ -708,7 +708,7 @@ namespace bms_parser
}
else
{
auto note = new Note{ToWaveId(new_chart, val_view, metaOnly)};
auto note = new Note{ToWaveId(new_chart, val, metaOnly)};
lastNote[laneNumber] = note;
++totalNotes;
if (isScratch)
Expand All @@ -731,7 +731,7 @@ namespace bms_parser
{
break;
}
auto invNote = new Note{ToWaveId(new_chart, val_view, metaOnly)};
auto invNote = new Note{ToWaveId(new_chart, val, metaOnly)};
timeline->SetInvisibleNote(
laneNumber, invNote);
break;
Expand All @@ -752,7 +752,7 @@ namespace bms_parser
++totalLongNotes;
}

auto ln = new LongNote{ToWaveId(new_chart, val_view, metaOnly)};
auto ln = new LongNote{ToWaveId(new_chart, val, metaOnly)};
lnStart[laneNumber] = ln;

if (metaOnly)
Expand Down Expand Up @@ -786,7 +786,7 @@ namespace bms_parser
{
break;
}
const auto damage = ParseInt(val_view, true) / 2.0f;
const auto damage = ParseInt(val, true) / 2.0f;
timeline->SetNote(
laneNumber, new LandmineNote{damage});
break;
Expand All @@ -798,6 +798,7 @@ namespace bms_parser
new_chart->Meta.TotalLongNotes = totalLongNotes;
new_chart->Meta.TotalScratchNotes = totalScratchNotes;
new_chart->Meta.TotalBackSpinNotes = totalBackSpinNotes;
new_chart->Meta.TotalLandmineNotes = totalLandmineNotes;

auto lastPosition = 0.0;

Expand Down
2 changes: 1 addition & 1 deletion src/SHA256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace bms_parser
buf[2 * SHA256::DIGEST_SIZE] = 0;
for (unsigned int i = 0; i < SHA256::DIGEST_SIZE; i++)
{
sprintf(buf + i * 2, "%02x", digest[i]);
snprintf(buf + i * 2, 3, "%02x", digest[i]);
}
return buf;
}
Expand Down
2 changes: 1 addition & 1 deletion src/md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ namespace bms_parser

char buf[33];
for (int i = 0; i < 16; i++)
sprintf(buf + i * 2, "%02x", digest[i]);
snprintf(buf + i * 2,3, "%02x", digest[i]);
buf[32] = 0;

return buf;
Expand Down
5 changes: 5 additions & 0 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ int main()
auto out = std::stoi(line.substr(21));
ASSERT_EQ(out, chart->Meta.TotalScratchNotes, "total_scratch_notes: ");
}
else if (line.rfind(L"total_landmine_notes: ", 0) == 0)
{
auto out = std::stoi(line.substr(22));
ASSERT_EQ(out, chart->Meta.TotalLandmineNotes, "total_landmine_notes: ");
}
else if (line.rfind(L"min_bpm: ", 0) == 0)
{
auto out = std::stod(line.substr(9));
Expand Down

0 comments on commit 19d71b3

Please sign in to comment.