make windows-compliant
- fix BS_thread_pool include error (pulls in windows.h, symbols were redefined) - remove all std::println uses :(, seems like mingw doesn't like those - allow to disable backward from cmake
This commit is contained in:
@ -44,7 +44,7 @@ auto Grid::Bounds() const -> Rectangle {
|
||||
|
||||
auto Grid::Bounds(int _x, int _y, int _width, int _height) const -> Rectangle {
|
||||
if (_x < 0 || _x + _width > columns || _y < 0 || _y + _height > rows) {
|
||||
std::println("Grid bounds are outside range.");
|
||||
std::cout << std::format("Grid bounds are outside range.") << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ auto Grid::SquareBounds(int _x, int _y, int _width, int _height) const
|
||||
// filled
|
||||
|
||||
if (_x < 0 || _x + _width > columns || _y < 0 || _y + _height > rows) {
|
||||
std::println("Grid bounds are outside range.");
|
||||
std::cout << std::format("Grid bounds are outside range.") << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
#include "input.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <print>
|
||||
#include <raylib.h>
|
||||
|
||||
#ifdef TRACY
|
||||
@ -269,16 +267,18 @@ auto InputHandler::MoveBlockWes() -> void {
|
||||
}
|
||||
|
||||
auto InputHandler::PrintState() const -> void {
|
||||
std::println("State: \"{}\"", state.current_state.state);
|
||||
std::cout << std::format("State: \"{}\"", state.current_state.state)
|
||||
<< std::endl;
|
||||
Block sel = state.current_state.GetBlock(sel_x, sel_y);
|
||||
int idx = state.current_state.GetIndex(sel.x, sel.y) - State::prefix;
|
||||
if (sel.IsValid()) {
|
||||
std::println("Sel: \"{}{}{}{}\"",
|
||||
state.current_state.state.substr(0, State::prefix),
|
||||
std::string(idx, '.'), sel.ToString(),
|
||||
std::string(state.current_state.state.length() - idx -
|
||||
State::prefix - 2,
|
||||
'.'));
|
||||
std::cout << std::format("Sel: \"{}{}{}{}\"",
|
||||
state.current_state.state.substr(0, State::prefix),
|
||||
std::string(idx, '.'), sel.ToString(),
|
||||
std::string(state.current_state.state.length() -
|
||||
idx - State::prefix - 2,
|
||||
'.'))
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@ -36,6 +36,18 @@ auto main(int argc, char *argv[]) -> int {
|
||||
preset_file = argv[1];
|
||||
}
|
||||
|
||||
#ifdef BACKWARD
|
||||
std::cout << std::format("Backward stack-traces enabled.") << std::endl;
|
||||
#else
|
||||
std::cout << std::format("Backward stack-traces disabled.") << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef TRACY
|
||||
std::cout << std::format("Tracy adapter enabled.") << std::endl;
|
||||
#else
|
||||
std::cout << std::format("Tracy adapter disabled.") << std::endl;
|
||||
#endif
|
||||
|
||||
// RayLib window setup
|
||||
SetTraceLogLevel(LOG_ERROR);
|
||||
SetConfigFlags(FLAG_VSYNC_HINT);
|
||||
|
||||
@ -10,11 +10,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#ifdef THREADPOOL
|
||||
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
||||
#include <BS_thread_pool.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef TRACY
|
||||
#include "tracy.hpp"
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "puzzle.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
#include <print>
|
||||
#include <unordered_set>
|
||||
|
||||
#ifdef TRACY
|
||||
@ -389,8 +388,9 @@ auto State::Closure() const
|
||||
}
|
||||
} while (remaining_states.size() > 0);
|
||||
|
||||
std::println("State space has size {} with {} transitions.", states.size(),
|
||||
links.size());
|
||||
std::cout << std::format("State space has size {} with {} transitions.",
|
||||
states.size(), links.size())
|
||||
<< std::endl;
|
||||
|
||||
return std::make_pair(states, links);
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <print>
|
||||
#include <raymath.h>
|
||||
|
||||
#ifdef TRACY
|
||||
@ -17,7 +16,9 @@ auto StateManager::ParsePresetFile(const std::string &_preset_file) -> bool {
|
||||
|
||||
std::ifstream file(preset_file);
|
||||
if (!file) {
|
||||
std::println("Preset file \"{}\" couldn't be loaded.", preset_file);
|
||||
std::cout << std::format("Preset file \"{}\" couldn't be loaded.",
|
||||
preset_file)
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -33,7 +34,9 @@ auto StateManager::ParsePresetFile(const std::string &_preset_file) -> bool {
|
||||
}
|
||||
|
||||
if (preset_lines.size() == 0 || comment_lines.size() != preset_lines.size()) {
|
||||
std::println("Preset file \"{}\" couldn't be loaded.", preset_file);
|
||||
std::cout << std::format("Preset file \"{}\" couldn't be loaded.",
|
||||
preset_file)
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -43,24 +46,29 @@ auto StateManager::ParsePresetFile(const std::string &_preset_file) -> bool {
|
||||
}
|
||||
comments = comment_lines;
|
||||
|
||||
std::println("Loaded {} presets from \"{}\".", preset_lines.size(),
|
||||
preset_file);
|
||||
std::cout << std::format("Loaded {} presets from \"{}\".",
|
||||
preset_lines.size(), preset_file)
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto StateManager::AppendPresetFile(const std::string preset_name) -> void {
|
||||
std::println("Saving preset \"{}\" to \"{}\"", preset_name, preset_file);
|
||||
std::cout << std::format("Saving preset \"{}\" to \"{}\"", preset_name,
|
||||
preset_file)
|
||||
<< std::endl;
|
||||
|
||||
std::ofstream file(preset_file, std::ios_base::app | std::ios_base::out);
|
||||
if (!file) {
|
||||
std::println("Preset file \"{}\" couldn't be loaded.", preset_file);
|
||||
std::cout << std::format("Preset file \"{}\" couldn't be loaded.",
|
||||
preset_file)
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
file << "\n# " << preset_name << "\n" << current_state.state << std::flush;
|
||||
|
||||
std::println("Refreshing presets...");
|
||||
std::cout << std::format("Refreshing presets...") << std::endl;
|
||||
if (ParsePresetFile(preset_file)) {
|
||||
LoadPreset(presets.size() - 1);
|
||||
}
|
||||
@ -139,7 +147,8 @@ auto StateManager::FillGraph() -> void {
|
||||
|
||||
// Sanity check. Both values need to be equal
|
||||
// for (const auto &[mass, state] : masses) {
|
||||
// std::println("Masses: {}, States: {}", mass, states.at(state));
|
||||
// std::cout << std::format("Masses: {}, States: {}", mass,
|
||||
// states.at(state)) << std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
@ -226,8 +235,8 @@ auto StateManager::FindTargetDistances() -> void {
|
||||
|
||||
target_distances = CalculateDistances(states.size(), springs, targets);
|
||||
|
||||
// std::println("Calculated {} distances to {} targets.",
|
||||
// target_distances.distances.size(), targets.size());
|
||||
// std::cout << std::format("Calculated {} distances to {} targets.",
|
||||
// target_distances.distances.size(), targets.size()) << std::endl;
|
||||
}
|
||||
|
||||
auto StateManager::FindTargetPath() -> void {
|
||||
@ -236,7 +245,8 @@ auto StateManager::FindTargetPath() -> void {
|
||||
}
|
||||
|
||||
winning_path = GetPath(target_distances, CurrentMassIndex());
|
||||
// std::println("Nearest target is {} moves away.", winning_path.size());
|
||||
// std::cout << std::format("Nearest target is {} moves away.",
|
||||
// winning_path.size()) << std::endl;
|
||||
}
|
||||
|
||||
auto StateManager::FindWorstState() -> State {
|
||||
|
||||
Reference in New Issue
Block a user