From 2f1b3562c5a75183ca13667f75e55dc3a2a44095 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 3 Jan 2019 19:58:38 +0100 Subject: [PATCH] racing:: official Vizier ghost is drawn --- racing.cpp | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/racing.cpp b/racing.cpp index 3d239c62..28f66bcd 100644 --- a/racing.cpp +++ b/racing.cpp @@ -73,6 +73,8 @@ struct ghost { map, map > > race_ghosts; +map, map > > official_race_ghosts; + array, MAXPLAYER> current_history; string ghost_prefix = "default"; @@ -114,7 +116,21 @@ void hwrite(hstream& hs, const ghost& gh) { hwrite(hs, gh.cs, gh.result, gh.timestamp, gh.checksum, gh.history); } + bool read_ghosts(string seed, int mcode) { + + if(seed == "OFFICIAL" && mcode == 2) { + fhstream f("vizier.data", "rb"); + if(f.f) { + f.get(); + hread(f, official_race_ghosts[{seed, mcode}]); + for(auto& p: official_race_ghosts) + for(auto& v: p.second) + for(auto& w: v.second) + w.cs.charid = -1, w.cs.uicolor = moVizier, w.cs.dresscolor = 0xC00000; + } + } + string fname = ghost_filename(seed, mcode); println(hlog, "trying to read ghosts from: ", fname); fhstream f(fname, "rb"); @@ -988,6 +1004,24 @@ void race_won() { } } +void draw_ghost(ghost& ghost) { + auto p = std::find_if(ghost.history.begin(), ghost.history.end(), [] (const ghostmoment gm) { return gm.step > ticks - race_start_tick;} ); + if(p == ghost.history.end()) p--, p->footphase = 0; + cell *w = rti[p->where_id].c; + if(!gmatrix.count(w)) return; + dynamicval x(getcs(), ghost.cs); + + transmatrix T = spin_uchar(p->alpha) * xpush(uchar_to_frac(p->distance) * distance_multiplier) * spin_uchar(p->beta); + + if(ghost.cs.charid == -1) { + dynamicval pc(peace::on, true); + drawMonsterType(eMonster(ghost.cs.uicolor), w, gmatrix[w] * T, ghost.cs.dresscolor, uchar_to_frac(p->footphase)); + return; + } + + drawMonsterType(moPlayer, w, gmatrix[w] * T, 0, uchar_to_frac(p->footphase)); + } + void markers() { if(!racing::on) return; if(racing::player_relative) { @@ -1006,17 +1040,12 @@ void markers() { for(auto& ghost: race_ghosts[{track_code, modecode()}][specialland]) { if(!ghosts_left) break; ghosts_left--; - auto p = std::find_if(ghost.history.begin(), ghost.history.end(), [] (const ghostmoment gm) { return gm.step > ticks - race_start_tick;} ); - if(p == ghost.history.end()) p--, p->footphase = 0; - cell *w = rti[p->where_id].c; - if(!gmatrix.count(w)) continue; - dynamicval x(getcs(), ghost.cs); - - transmatrix T = spin_uchar(p->alpha) * xpush(uchar_to_frac(p->distance) * distance_multiplier) * spin_uchar(p->beta); - - drawMonsterType(moPlayer, w, gmatrix[w] * T, 0, uchar_to_frac(p->footphase)); + draw_ghost(ghost); } + for(auto& ghost: official_race_ghosts[{track_code, modecode()}][specialland]) + draw_ghost(ghost); + if(gmatrix.count(track[0])) { for(ld z=-start_line_width; z<=start_line_width; z+=0.1) curvepoint(ggmatrix(track[0]) * straight * parabolic1(z) * C0);