1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-02-11 08:30:08 +00:00

Fix bugs and C++ compilance

- use 'noexcept' for constexpr
- allocate dynamic array
- enable CAP_TEXTURE on CAP_ROGUEVIZ
This commit is contained in:
Locria Cyber 2023-02-01 13:00:30 +00:00
parent 99e3b25560
commit 5e8839f3a9
No known key found for this signature in database
GPG Key ID: ED0D424AE4406330
3 changed files with 6 additions and 6 deletions

View File

@ -128,7 +128,7 @@ endif
ifeq (${HYPERROGUE_USE_ROGUEVIZ},1)
# Enable RogueViz. RogueViz requires C++17.
CXXFLAGS_STD = -std=c++17
CXXFLAGS_EARLY += -DCAP_ROGUEVIZ=1
CXXFLAGS_EARLY += -DCAP_ROGUEVIZ=1 -DCAP_TEXTURE=1
endif

View File

@ -21,8 +21,8 @@ namespace hr {
static constexpr ld A_PI = M_PI;
static constexpr ld TAU = 2 * A_PI;
static constexpr ld degree = A_PI / 180;
static constexpr ld golden_phi = (sqrt(5)+1)/2;
static constexpr ld log_golden_phi = log(golden_phi);
static constexpr ld golden_phi = noexcept((sqrt(5)+1)/2);
static constexpr ld log_golden_phi = noexcept(log(golden_phi));
constexpr ld operator"" _deg(long double deg) { return deg * A_PI / 180; }
#endif

View File

@ -139,7 +139,7 @@ void cellcoords() {
// needs cellcoords/rvcoords/origcoords
void build_disttable() {
indenter_finish im("build_disttable");
int tab[N];
std::vector<int> tab(N);
for(int i=0; i<N; i++) tab[i] = N;
disttable0.clear();
disttable1.clear();
@ -269,7 +269,7 @@ void writestats() {
ld placement_loglik = loglik_placement();
for(int u=0; u<MAXDIST; u++) if(tally[u]) {
println(hlog, format("* %4d: %8d / %12Ld = %lf %.10" PLDF " %.10" PLDF,
println(hlog, format("* %4d: %8d / %12lld = %lf %.10" PLDF " %.10" PLDF,
u, edgetally[u], tally[u], double(edgetally[u]) / tally[u],
saved_logistic.yes(u), current_logistic.yes(u)));
}
@ -338,7 +338,7 @@ void build_disttable_approx() {
for(int k=0; k<threads; k++)
v.emplace_back([&,k] () {
auto& dt = results[k];
int tab[N];
std::vector<int> tab(N);
for(int i=0; i<N; i++) tab[i] = N;
auto p = k ? nullptr : new progressbar(N/threads, "build_disttable_approx");
for(int i=k; i<N; i+=threads) {