Skip to content

Commit 08bf553

Browse files
authored
Merge pull request #159 from OpenBrickProtocolFoundation/bug-fixes
Fix known bugs
2 parents 44dd620 + 401cb1f commit 08bf553

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+297
-207
lines changed

src/application.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "helper/console_helpers.hpp"
2121
#endif
2222

23-
#ifdef DEBUG_BUILD
23+
#if !defined(NDEBUG)
2424
#include "graphics/text.hpp"
2525
#endif
2626

@@ -58,7 +58,7 @@ Application::Application(std::shared_ptr<Window>&& window, const std::vector<std
5858
void Application::run() {
5959
m_event_dispatcher.register_listener(this);
6060

61-
#ifdef DEBUG_BUILD
61+
#if !defined(NDEBUG)
6262
auto start_time = SDL_GetPerformanceCounter();
6363
const auto update_time = SDL_GetPerformanceFrequency() / 2; //0.5 s
6464
const auto count_per_s = static_cast<double>(SDL_GetPerformanceFrequency());
@@ -84,7 +84,7 @@ void Application::run() {
8484
render();
8585
m_renderer.present();
8686

87-
#ifdef DEBUG_BUILD
87+
#if !defined(NDEBUG)
8888
++frame_counter;
8989

9090
const Uint64 current_time = SDL_GetPerformanceCounter();
@@ -244,7 +244,7 @@ void Application::render() const {
244244
for (const auto& scene : m_scene_stack) {
245245
scene->render(*this);
246246
}
247-
#ifdef DEBUG_BUILD
247+
#if !defined(NDEBUG)
248248
m_fps_text->render(*this);
249249
#endif
250250
}
@@ -266,7 +266,7 @@ void Application::initialize() {
266266

267267
this->load_resources();
268268

269-
#ifdef DEBUG_BUILD
269+
#if !defined(NDEBUG)
270270
m_fps_text = std::make_unique<ui::Label>(
271271
this, "FPS: ?", font_manager().get(FontId::Default), Color::white(),
272272
std::pair<double, double>{ 0.95, 0.95 },

src/application.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct Application final : public EventListener, public ServiceProvider {
3434
std::unique_ptr<FontManager> m_font_manager;
3535

3636

37-
#ifdef DEBUG_BUILD
37+
#if !defined(NDEBUG)
3838
std::unique_ptr<ui::Label> m_fps_text{ nullptr };
3939
#endif
4040

src/discord/core.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
case ArtAsset::logo:
1616
return "logo";
1717
default:
18-
utils::unreachable();
18+
UNREACHABLE();
1919
}
2020
}
2121

@@ -50,7 +50,7 @@ void DiscordInstance::after_setup() {
5050

5151

5252
core->SetLogHook(
53-
#ifdef DEBUG_BUILD
53+
#if !defined(NDEBUG)
5454
discord::LogLevel::Debug
5555
#else
5656
discord::LogLevel::Error

src/game/game.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ Game::Game(
88
ServiceProvider* const service_provider,
99
const std::shared_ptr<input::GameInput>& input,
1010
const tetrion::StartingParameters& starting_parameters,
11+
u32 simulation_frequency,
1112
const ui::Layout& layout,
1213
bool is_top_level
1314
)
1415
: ui::Widget{ layout, ui::WidgetType::Component, is_top_level },
15-
m_clock_source{ std::make_unique<LocalClock>(starting_parameters.target_fps) },
16+
m_clock_source{ std::make_unique<LocalClock>(simulation_frequency) },
1617
m_input{ input } {
1718

1819

src/game/game.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct Game : public ui::Widget {
2121
ServiceProvider* service_provider,
2222
const std::shared_ptr<input::GameInput>& input,
2323
const tetrion::StartingParameters& starting_parameters,
24+
u32 simulation_frequency,
2425
const ui::Layout& layout,
2526
bool is_top_level
2627
);

src/game/graphic_helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace {
2121
case MinoTransparency::Solid:
2222
return utils::to_underlying(transparency);
2323
default:
24-
utils::unreachable();
24+
UNREACHABLE();
2525
}
2626
}
2727
} // namespace

src/game/tetrion.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void Tetrion::lock_active_tetromino(const SimulationStep simulation_step_index)
452452
reset_lock_delay(simulation_step_index);
453453

454454
// save a snapshot on every freeze (only in debug builds)
455-
#ifdef DEBUG_BUILD
455+
#if !defined(NDEBUG)
456456
if (m_recording_writer) {
457457
spdlog::debug("adding snapshot at step {}", simulation_step_index);
458458
(*m_recording_writer)->add_snapshot(m_tetrion_index, simulation_step_index, core_information());
@@ -561,7 +561,7 @@ u8 Tetrion::rotation_to_index(const Rotation from, const Rotation rotation_to) {
561561
if (from == Rotation::North and rotation_to == Rotation::West) {
562562
return 7;
563563
}
564-
utils::unreachable();
564+
UNREACHABLE();
565565
}
566566

567567
bool Tetrion::is_tetromino_position_valid(const Tetromino& tetromino) const {
@@ -628,7 +628,7 @@ bool Tetrion::move(const Tetrion::MoveDirection move_direction) {
628628
return true;
629629
}
630630

631-
utils::unreachable();
631+
UNREACHABLE();
632632
}
633633

634634
helper::optional<const Tetrion::WallKickTable*> Tetrion::get_wall_kick_table() const {
@@ -646,6 +646,6 @@ helper::optional<const Tetrion::WallKickTable*> Tetrion::get_wall_kick_table() c
646646
case helper::TetrominoType::O:
647647
return {};
648648
default:
649-
utils::unreachable();
649+
UNREACHABLE();
650650
}
651651
}

src/graphics/texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Texture Texture::prerender_text(
3737
font.get(), text.c_str(), text_color, utils::sdl_color_from_color(background_color)
3838
);
3939
} else {
40-
utils::unreachable();
40+
UNREACHABLE();
4141
}
4242
if (surface == nullptr) {
4343
throw std::runtime_error(fmt::format("Failed to pre-render text into surface with error: {}", SDL_GetError()));

src/helper/color.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ namespace {
153153
return color.to_string(force_alpha);
154154
}
155155
default:
156-
utils::unreachable();
156+
UNREACHABLE();
157157
}
158158
}
159159

src/helper/color.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ struct Color {
208208
d_b = x_offset;
209209
break;
210210
default:
211-
utils::unreachable();
211+
UNREACHABLE();
212212
}
213213

214214

0 commit comments

Comments
 (0)