mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 14:02:59 +00:00 
			
		
		
		
	nilrider:: load plans as ghosts
This commit is contained in:
		| @@ -63,6 +63,17 @@ void frame() { | |||||||
|   curlev->draw_level_rec(V); |   curlev->draw_level_rec(V); | ||||||
|  |  | ||||||
|   curlev->current.draw_unilcycle(V); |   curlev->current.draw_unilcycle(V); | ||||||
|  |  | ||||||
|  |   for(auto g: curlev->ghosts) { | ||||||
|  |     ld t = curlev->current.timer; | ||||||
|  |     int a = 0, b = isize(g.history); | ||||||
|  |     while(a != b) { | ||||||
|  |       int s = (a + b) / 2; | ||||||
|  |       if(g.history[s].timer < t) a = s + 1; | ||||||
|  |       else b = s; | ||||||
|  |       } | ||||||
|  |     if(b < isize(g.history)) g.history[b].draw_unilcycle(V); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
| bool crash_sound = true; | bool crash_sound = true; | ||||||
| @@ -756,6 +767,9 @@ auto celldemo = arg::add3("-unilcycle", initialize) + arg::add3("-unilplan", [] | |||||||
|       nisot::geodesic_movement = false; |       nisot::geodesic_movement = false; | ||||||
|       pmodel = mdPerspective; |       pmodel = mdPerspective; | ||||||
|       pconf.rotational_nil = 0; |       pconf.rotational_nil = 0; | ||||||
|  |       }) | ||||||
|  |     + arg::add3("-ghost-replays", [] { | ||||||
|  |       for(auto& g: curlev->plan_replays) curlev->load_plan_as_ghost(g); | ||||||
|       }); |       }); | ||||||
|  |  | ||||||
| auto hook0= addHook(hooks_configfile, 300, default_settings); | auto hook0= addHook(hooks_configfile, 300, default_settings); | ||||||
|   | |||||||
| @@ -105,6 +105,10 @@ struct goal { | |||||||
|  |  | ||||||
| using surface_fun = std::function<ld(hyperpoint h)>; | using surface_fun = std::function<ld(hyperpoint h)>; | ||||||
|  |  | ||||||
|  | struct ghost { | ||||||
|  |   vector<timestamp> history; | ||||||
|  |   }; | ||||||
|  |  | ||||||
| struct level { | struct level { | ||||||
|   string name; |   string name; | ||||||
|   char hotkey; |   char hotkey; | ||||||
| @@ -180,6 +184,7 @@ struct level { | |||||||
|   void init(); |   void init(); | ||||||
|  |  | ||||||
|   vector<timestamp> history; |   vector<timestamp> history; | ||||||
|  |   vector<ghost> ghosts; | ||||||
|    |    | ||||||
|   vector<manual_replay> manual_replays; |   vector<manual_replay> manual_replays; | ||||||
|   vector<plan_replay> plan_replays; |   vector<plan_replay> plan_replays; | ||||||
| @@ -221,6 +226,8 @@ struct level { | |||||||
|   vector<level*> gen_layer_list() { |   vector<level*> gen_layer_list() { | ||||||
|     vector<level*> res; gen_layer_list(res); return res; |     vector<level*> res; gen_layer_list(res); return res; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |   void load_plan_as_ghost(plan_replay&); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
| /** wheel radius */ | /** wheel radius */ | ||||||
|   | |||||||
| @@ -105,4 +105,23 @@ void load() { | |||||||
|   #endif |   #endif | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | void level::load_plan_as_ghost(plan_replay& r) { | ||||||
|  |   vector<timestamp> history_backup; | ||||||
|  |   swap(history_backup, history); | ||||||
|  |   swap(r.plan, plan); | ||||||
|  |   history.clear(); | ||||||
|  |   history.push_back(start); | ||||||
|  |   while(true) { | ||||||
|  |     int s = isize(history); | ||||||
|  |     if(!simulate()) break; | ||||||
|  |     if(isize(history) == s) break; | ||||||
|  |     } | ||||||
|  |   println(hlog, "a history of length ", isize(history), " becomes a ghost"); | ||||||
|  |   ghosts.emplace_back(); | ||||||
|  |   auto& g = ghosts.back(); | ||||||
|  |   g.history = std::move(history); | ||||||
|  |   swap(history_backup, history); | ||||||
|  |   swap(r.plan, plan); | ||||||
|  |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue