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:
@ -4,9 +4,9 @@
|
||||
#include <raylib.h>
|
||||
|
||||
#define THREADPOOL // Enable physics threadpool
|
||||
#define BACKWARD // Enable pretty stack traces
|
||||
|
||||
// Gets set by CMake
|
||||
// #define BACKWARD // Enable pretty stack traces
|
||||
// #define TRACY // Enable tracy profiling support
|
||||
|
||||
// Window
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
#include <print>
|
||||
#include <queue>
|
||||
#include <raylib.h>
|
||||
#include <raymath.h>
|
||||
@ -17,8 +16,16 @@
|
||||
#include <vector>
|
||||
|
||||
#ifdef THREADPOOL
|
||||
#if defined(_WIN32)
|
||||
#define NOGDI // All GDI defines and routines
|
||||
#define NOUSER // All USER defines and routines
|
||||
#endif
|
||||
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
||||
#include <BS_thread_pool.hpp>
|
||||
#if defined(_WIN32) // raylib uses these names as function parameters
|
||||
#undef near
|
||||
#undef far
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TRACY
|
||||
@ -78,10 +85,16 @@ public:
|
||||
: threads(std::thread::hardware_concurrency() - 1, SetThreadName)
|
||||
#endif
|
||||
{
|
||||
std::println("Using Barnes-Hut + Octree repulsion force calculation.");
|
||||
std::cout << std::format(
|
||||
"Using Barnes-Hut + Octree repulsion force calculation.")
|
||||
<< std::endl;
|
||||
|
||||
#ifdef THREADPOOL
|
||||
std::println("Thread-pool: {} threads.", threads.get_thread_count());
|
||||
std::cout << std::format("Thread-pool: {} threads.",
|
||||
threads.get_thread_count())
|
||||
<< std::endl;
|
||||
#else
|
||||
std::cout << std::format("Thread-pool: Disabled.") << std::endl;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include <cstddef>
|
||||
#include <format>
|
||||
#include <functional>
|
||||
#include <print>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -40,7 +40,7 @@ public:
|
||||
: x(_x), y(_y), width(_width), height(_height), target(_target),
|
||||
immovable(_immovable) {
|
||||
if (_x < 0 || _x + _width >= 10 || _y < 0 || _y + _height >= 10) {
|
||||
std::println("Block must fit in a 9x9 board!");
|
||||
std::cout << std::format("Block must fit in a 9x9 board!") << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -92,11 +92,12 @@ public:
|
||||
}
|
||||
|
||||
if (_x < 0 || _x + width >= 10 || _y < 0 || _y + height >= 10) {
|
||||
std::println("Block must fit in a 9x9 board!");
|
||||
std::cout << std::format("Block must fit in a 9x9 board!") << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
if (block.length() != 2) {
|
||||
std::println("Block representation must have length 2!");
|
||||
std::cout << std::format("Block representation must have length 2!")
|
||||
<< std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -186,12 +187,15 @@ public:
|
||||
_height, _target_x, _target_y,
|
||||
std::string(_width * _height * 2, '.'))) {
|
||||
if (_width < 1 || _width > 9 || _height < 1 || _height > 9) {
|
||||
std::println("State width/height must be in [1, 9]!");
|
||||
std::cout << std::format("State width/height must be in [1, 9]!")
|
||||
<< std::endl;
|
||||
exit(1);
|
||||
}
|
||||
if (_target_x < 0 || _target_x >= 9 || _target_y < 0 || _target_y >= 9) {
|
||||
if (_target_x != 9 && _target_y != 9) {
|
||||
std::println("State target must be within the board bounds!");
|
||||
std::cout << std::format(
|
||||
"State target must be within the board bounds!")
|
||||
<< std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -209,19 +213,23 @@ public:
|
||||
target_y(std::stoi(_state.substr(4, 1))),
|
||||
restricted(_state.substr(0, 1) == "R"), state(_state) {
|
||||
if (width < 1 || width > 9 || height < 1 || height > 9) {
|
||||
std::println("State width/height must be in [1, 9]!");
|
||||
std::cout << std::format("State width/height must be in [1, 9]!")
|
||||
<< std::endl;
|
||||
exit(1);
|
||||
}
|
||||
if (target_x < 0 || target_x >= 9 || target_y < 0 || target_y >= 9) {
|
||||
if (target_x != 9 && target_y != 9) {
|
||||
std::println("State target must be within the board bounds!");
|
||||
std::cout << std::format(
|
||||
"State target must be within the board bounds!")
|
||||
<< std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (static_cast<int>(_state.length()) != width * height * 2 + prefix) {
|
||||
std::println(
|
||||
"State representation must have length width * height * 2 + {}!",
|
||||
prefix);
|
||||
std::cout << std::format("State representation must have length width * "
|
||||
"height * 2 + {}!",
|
||||
prefix)
|
||||
<< std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user