mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-11-04 07:43:02 +00:00 
			
		
		
		
	whirl:: celldist and celldistAlt now work
This commit is contained in:
		@@ -105,6 +105,8 @@ void generateAlts(heptagon *h, int levs, bool link_cdata) {
 | 
			
		||||
  if(!h->alt) return;
 | 
			
		||||
  preventbarriers(h->c7);
 | 
			
		||||
  for(int i=0; i<S7; i++) preventbarriers(h->c7->mov[i]);
 | 
			
		||||
  if(whirl::whirl)
 | 
			
		||||
    for(int i=0; i<S7; i++) preventbarriers(createStep(h, i)->c7);
 | 
			
		||||
  for(int i=0; i<S7; i++) 
 | 
			
		||||
    createStep(h->alt, i)->alt = h->alt->alt;
 | 
			
		||||
  int relspin = -4; // for horocycles it must go the other way
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								cell.cpp
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								cell.cpp
									
									
									
									
									
								
							@@ -983,6 +983,7 @@ int celldist(cell *c) {
 | 
			
		||||
    }
 | 
			
		||||
  if(sphere) return celldistance(c, currentmap->gamestart());
 | 
			
		||||
  if(ctof(c)) return c->master->distance;
 | 
			
		||||
  if(whirl::whirl) return whirl::compute_dist(c, celldist);
 | 
			
		||||
  int dx[MAX_S3];
 | 
			
		||||
  for(int u=0; u<S3; u++)
 | 
			
		||||
    dx[u] = createMov(c, u+u)->master->distance;
 | 
			
		||||
@@ -1009,6 +1010,7 @@ int celldistAlt(cell *c) {
 | 
			
		||||
    }
 | 
			
		||||
  if(!c->master->alt) return 0;
 | 
			
		||||
  if(ctof(c)) return c->master->alt->distance;
 | 
			
		||||
  if(whirl::whirl) return whirl::compute_dist(c, celldistAlt);
 | 
			
		||||
  int dx[MAX_S3]; dx[0] = 0;
 | 
			
		||||
  for(int u=0; u<S3; u++) if(createMov(c, u+u)->master->alt == NULL)
 | 
			
		||||
    return ALTDIST_UNKNOWN;
 | 
			
		||||
 
 | 
			
		||||
@@ -321,7 +321,10 @@ void debugScreen() {
 | 
			
		||||
    dialog::addSelItem("cpdist", its(mouseover->cpdist), 0);
 | 
			
		||||
    dialog::addSelItem("celldist", its(celldist(mouseover)), 0);
 | 
			
		||||
    dialog::addSelItem("pathdist", its(mouseover->pathdist), 0);
 | 
			
		||||
    dialog::addSelItem("celldistAlt", mouseover->master->alt ? its(celldistAlt(mouseover)) : "--", 0);
 | 
			
		||||
    dialog::addSelItem("temporary", its(mouseover->aitmp), 0);
 | 
			
		||||
    if(whirl::whirl)
 | 
			
		||||
      dialog::addSelItem("whirl", whirl::disp(whirl::get_local_info(mouseover).relative), 0);
 | 
			
		||||
    dialog::addBreak(50);
 | 
			
		||||
    dialog::addSelItem("monster", dnameof2(mouseover->monst, mouseover->mondir), 0);
 | 
			
		||||
    dialog::addSelItem("stuntime/hitpoints", its(mouseover->stuntime)+"/"+its(mouseover->hitpoints), 0);
 | 
			
		||||
 
 | 
			
		||||
@@ -96,6 +96,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
 | 
			
		||||
  if(pard == 0) {
 | 
			
		||||
    h->dm4 = parent->dm4+1;
 | 
			
		||||
    if(fixdistance != COMPUTE) h->distance = fixdistance;
 | 
			
		||||
    else if(whirl::whirl) h->distance = parent->distance + whirl::param.first;
 | 
			
		||||
    else if(nonbitrunc) h->distance = parent->distance + 1;
 | 
			
		||||
    else if(parent->s == hsOrigin) h->distance = parent->distance + 2;
 | 
			
		||||
    else if(S3 == 4) {
 | 
			
		||||
@@ -128,7 +129,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
 | 
			
		||||
    else h->distance = parent->distance + 2;
 | 
			
		||||
    }
 | 
			
		||||
  else {
 | 
			
		||||
    h->distance = parent->distance - (nonbitrunc?1:2);
 | 
			
		||||
    h->distance = parent->distance - (whirl::whirl?whirl::param.first:nonbitrunc?1:2);
 | 
			
		||||
    if(S3 == 4 && S7 == 5) {
 | 
			
		||||
      if(h->s == hsOrigin) {
 | 
			
		||||
        printf("had to cheat!\n");
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								hyper.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								hyper.h
									
									
									
									
									
								
							@@ -2981,6 +2981,8 @@ namespace whirl {
 | 
			
		||||
  
 | 
			
		||||
  local_info get_local_info(cell *c);
 | 
			
		||||
  const char *disp(loc at);
 | 
			
		||||
 | 
			
		||||
  int compute_dist(cell *c, int master_function(cell*));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
int get_sightrange();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										37
									
								
								whirl.cpp
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								whirl.cpp
									
									
									
									
									
								
							@@ -488,5 +488,42 @@ namespace whirl {
 | 
			
		||||
    param = loc(config_x, config_y);
 | 
			
		||||
    pushScreen(whirl::show);
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
  int compute_dist(cell *c, int master_function(cell*)) {
 | 
			
		||||
    auto li = get_local_info(c);
 | 
			
		||||
    
 | 
			
		||||
    cell *cm = c->master->c7;
 | 
			
		||||
    
 | 
			
		||||
    int i = li.last_dir;
 | 
			
		||||
    auto at = li.relative;
 | 
			
		||||
 | 
			
		||||
    while(at.first < 0 || at.second < 0) {
 | 
			
		||||
      at = at * eudir(1);
 | 
			
		||||
      i = fixdir(i-1, cm);
 | 
			
		||||
      }
 | 
			
		||||
    
 | 
			
		||||
    auto dmain = master_function(cm);
 | 
			
		||||
    auto d0 = master_function(createStep(cm->master, i)->c7);
 | 
			
		||||
    auto d1 = master_function(createStep(cm->master, fixdir(i+1, cm))->c7);
 | 
			
		||||
        
 | 
			
		||||
    int w = param.first;
 | 
			
		||||
    
 | 
			
		||||
    while(true) {
 | 
			
		||||
      if(dmain < d0 && dmain < d1)
 | 
			
		||||
        return dmain + at.first + at.second;
 | 
			
		||||
      if(dmain > d0 && dmain > d1)
 | 
			
		||||
        return dmain - at.first - at.second;
 | 
			
		||||
      if(dmain == d0 && dmain == d1)
 | 
			
		||||
        return dmain;
 | 
			
		||||
      // main ~ (0,0)
 | 
			
		||||
      // d0 ~ (w,0)
 | 
			
		||||
      // d1 ~ (0,w)
 | 
			
		||||
      tie(dmain, d0, d1) = make_tuple(d0, d1, dmain);
 | 
			
		||||
      // (0,0) -> (0,w)
 | 
			
		||||
      // (w,0) -> (0,0)
 | 
			
		||||
      // (0,w) -> (w,0)
 | 
			
		||||
      at = loc(at.second, w - at.first - at.second);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user