mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	cellid / fixed some situations when the same seed did not reproduce the same game / fixed a bug with multi::cpid overflow / golems no longer consider Orbs of Safety safe
This commit is contained in:
		| @@ -1597,7 +1597,7 @@ namespace hive { | ||||
|         } | ||||
|       } | ||||
|      | ||||
|     random_shuffle(bugtomove.begin(), bugtomove.end()); | ||||
|     hrandom_shuffle(&bugtomove[0], size(bugtomove)); | ||||
|     sort(bugtomove.begin(), bugtomove.end()); | ||||
|      | ||||
|     int battlecount = 0; | ||||
| @@ -2613,7 +2613,7 @@ namespace kraken { | ||||
|         int qdir = 0; | ||||
|         cell *ctab[MAX_EDGE]; | ||||
|         forCellEx(c2, c) if(isWatery(c2)) ctab[qdir++] = c2; | ||||
|         random_shuffle(ctab, ctab+qdir); | ||||
|         hrandom_shuffle(ctab, qdir); | ||||
|         while(qdir--) trymove(ctab[qdir]); | ||||
|         } | ||||
|       } | ||||
| @@ -3083,7 +3083,7 @@ namespace windmap { | ||||
|     bool inqueue[N]; | ||||
|     vector<int> tocheck; | ||||
|     for(int i=0; i<N; i++) tocheck.push_back(i), inqueue[i] = true; | ||||
|     random_shuffle(tocheck.begin(), tocheck.end());     | ||||
|     hrandom_shuffle(&tocheck[0], size(tocheck)); | ||||
|      | ||||
|     for(int a=0; a<size(tocheck); a++) { | ||||
|       if(a >= 200*N) { printf("does not converge\n"); break; } | ||||
|   | ||||
							
								
								
									
										19
									
								
								game.cpp
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								game.cpp
									
									
									
									
									
								
							| @@ -154,6 +154,11 @@ ld hrandf() { | ||||
|   return (r() & HRANDMAX) / (HRANDMAX + 1.0); | ||||
|   } | ||||
|  | ||||
| int hrandstate() { | ||||
|   mt19937 r2 = r; | ||||
|   return r2() % 1000000; | ||||
|   } | ||||
|  | ||||
| void initcell(cell *c) { | ||||
|   c->mpdist = INFD;   // minimum distance from the player, ever | ||||
|   c->cpdist = INFD;   // current distance from the player | ||||
| @@ -1308,7 +1313,8 @@ int monstersnear2() { | ||||
|     dynamicval<eMonster> sw(passive_switch, passive_switch); | ||||
|  | ||||
|     // check for safe orbs and switching first | ||||
|     for(auto &sm: stalemate::moves) { | ||||
|     for(auto &sm: stalemate::moves) if(sm.who == moPlayer) { | ||||
|  | ||||
|       if(hasSafeOrb(sm.moveto)) { | ||||
|         multi::cpid--; return 0; | ||||
|         } | ||||
| @@ -1318,10 +1324,12 @@ int monstersnear2() { | ||||
|         if(canPickupItemWithMagnetism(c2, sm.comefrom)) { | ||||
|           if(itemclass(c2->item) == IC_TREASURE) | ||||
|             passive_switch = active_switch(); | ||||
|           if(hasSafeOrb(c2)) | ||||
|           if(hasSafeOrb(c2)) { | ||||
|             multi::cpid--; | ||||
|             return 0; | ||||
|             } | ||||
|           } | ||||
|       }     | ||||
|  | ||||
|     for(int i=0; i<size(stalemate::moves); i++) | ||||
|     for(int j=0; j<size(stalemate::moves); j++) if(i != j) { | ||||
| @@ -4053,7 +4061,7 @@ void killThePlayer(eMonster m, int id, flagtype flags) { | ||||
|     items[itOrbSafety] = 0; | ||||
|     } | ||||
|   else { | ||||
|     printf("confused!\n"); | ||||
| //  printf("confused!\n"); | ||||
|     addMessage(XLAT("%The1 is confused!", m)); | ||||
|     } | ||||
|   } | ||||
| @@ -4495,7 +4503,8 @@ void groupmove(eMonster movtype, flagtype mf) { | ||||
|     int dirtable[10], qdirtable=0; | ||||
|      | ||||
|     forCellIdAll(c2,t,c) dirtable[qdirtable++] = t; | ||||
|     random_shuffle(dirtable, dirtable + qdirtable); | ||||
|     hrandom_shuffle(dirtable, qdirtable); | ||||
|  | ||||
|     while(qdirtable--) { | ||||
|       int t = dirtable[qdirtable]; | ||||
|       groupmove2(c->mov[t],c,t,movtype,mf); | ||||
| @@ -6008,7 +6017,7 @@ void activateSafety(eLand l) { | ||||
|     l = laCrossroads; | ||||
|   firstland = l; | ||||
|   safetyland = l; | ||||
|   safetyseed = time(NULL); | ||||
|   safetyseed = 0; | ||||
|   clear_euland(firstland); | ||||
|   safety = true; avengers = 0; | ||||
|   clearMemory(); | ||||
|   | ||||
							
								
								
									
										15
									
								
								hyper.h
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								hyper.h
									
									
									
									
									
								
							| @@ -109,7 +109,15 @@ struct gcell { | ||||
|    | ||||
|   } LHU; | ||||
|    | ||||
|   gcell() { cellcount++; } | ||||
|   #ifdef CELLID | ||||
|   int cellid; | ||||
|   #endif | ||||
|    | ||||
|   gcell() { cellcount++;  | ||||
|     #ifdef CELLID | ||||
|     cellid = cellcount;   | ||||
|     #endif | ||||
|     } | ||||
|   ~gcell() { cellcount--; } | ||||
|   }; | ||||
|  | ||||
| @@ -2445,3 +2453,8 @@ bool cannotPickupItem(cell *c, bool telekinesis); | ||||
| bool canPickupItemWithMagnetism(cell *c, cell *from); | ||||
| void pickupMovedItems(cell *c); | ||||
| eMonster genRuinMonster(cell *c); | ||||
|  | ||||
| template<class T> void hrandom_shuffle(T* x, int n) { | ||||
|   for(int k=1; k<n; k++) swap(x[k], x[hrand(k+1)]); | ||||
|   } | ||||
|    | ||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue