From d5ce7dc30b19fdde822351856242653136a42b5e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 18 Nov 2018 01:42:00 +0100 Subject: [PATCH] racing:: improved Euclidean track generation --- bigstuff.cpp | 6 ++++++ hyper.h | 2 +- racing.cpp | 35 +++++++++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/bigstuff.cpp b/bigstuff.cpp index d6535802..f3fecd45 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -817,6 +817,12 @@ eLand getEuclidLand(int c) { } void setLandEuclid(cell *c) { + #if CAP_RACING + if(racing::track_ready) { + setland(c, laMemory); + return; + } + #endif setland(c, specialland); if(specialland == laCrossroads4 || chaosmode) { int x, y; diff --git a/hyper.h b/hyper.h index 6b8fb8ef..cbeb4d03 100644 --- a/hyper.h +++ b/hyper.h @@ -4677,7 +4677,7 @@ bool do_draw(cell *c, const transmatrix& T); #if CAP_RACING namespace racing { - extern bool on, player_relative; + extern bool on, player_relative, track_ready; void generate_track(); void show(); void prepare_subscreens(); diff --git a/racing.cpp b/racing.cpp index 04190ecf..1d3dcf27 100644 --- a/racing.cpp +++ b/racing.cpp @@ -11,6 +11,7 @@ namespace racing { bool on; bool player_relative = false; +bool track_ready; static const int LENGTH = 250; static const int TWIDTH = 6; @@ -76,13 +77,28 @@ void generate_track() { } } - while(goal != s) { - track.push_back(goal); - forCellEx(c2, goal) if(celldist(c2) < celldist(goal)) { goal = c2; break; } + if(euclid) { + using namespace hyperpoint_vec; + track.push_back(s); + hyperpoint h = tC0(calc_relative_matrix(goal, s, C0)) - C0; + cell *x = s; + hyperpoint h1 = C0; + for(int i=0; i<=1000; i++) { + h1 += h / 1000.; + virtualRebase(x, h1, true); + if(x != track.back()) track.push_back(x); + } + } + + else { + while(goal != s) { + track.push_back(goal); + forCellEx(c2, goal) if(celldist(c2) < celldist(goal)) { goal = c2; break; } + } + + track.push_back(s); + reverse(track.begin(), track.end()); } - - track.push_back(s); - reverse(track.begin(), track.end()); /* @@ -196,6 +212,8 @@ void generate_track() { if(i >= 5) c->item = itBone; } */ + + track_ready = true; } vector > history; @@ -315,6 +333,11 @@ bool akh(int sym, int uni) { #if CAP_COMMANDLINE auto hook = addHook(hooks_args, 100, readArgs) ++ addHook(clearmemory, 0, []() { + track_ready = false; + track.clear(); + trackstage.clear(); + }) // + addHook(hooks_handleKey, 120, akh); ; #endif