[Change] You can no longer buy a star map if you already know the area.
This commit is contained in:
		
							parent
							
								
									82b210e6cc
								
							
						
					
					
						commit
						6ebb90dc23
					
				| @ -15,6 +15,7 @@ | ||||
| #include "ltime.h" | ||||
| #include "save.h" | ||||
| #include "music.h" | ||||
| #include "map.h" | ||||
| #include "land.h" | ||||
| 
 | ||||
| /* Global/main window. */ | ||||
| @ -393,6 +394,11 @@ static int outfit_canBuy(Outfit* outfit, int q, int errmsg) { | ||||
|     } | ||||
|     return 0; | ||||
|   } | ||||
|   else if(outfit_isMap(outfit) && map_isMapped(NULL, outfit->u.map.radius)) { | ||||
|     if(errmsg != 0) | ||||
|       dialogue_alert("You already own this map."); | ||||
|     return 0; | ||||
|   } | ||||
| 
 | ||||
|   return 1; | ||||
| } | ||||
|  | ||||
							
								
								
									
										45
									
								
								src/map.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								src/map.c
									
									
									
									
									
								
							| @ -790,3 +790,48 @@ int map_map(char* targ_sys, int r) { | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| /* Check to see if radius is mapped. */ | ||||
| int map_isMapped(char* targ_sys, int r) { | ||||
|   int i, dep, ret; | ||||
|   StarSystem* sys, *jsys; | ||||
|   SysNode* closed, *open, *cur, *neighbour; | ||||
| 
 | ||||
|   A_gc = NULL; | ||||
|   open = closed = NULL; | ||||
| 
 | ||||
|   if(targ_sys == NULL) sys = cur_system; | ||||
|   else sys = system_get(targ_sys); | ||||
|   open = A_newNode(sys, NULL); | ||||
|   open->r = 0; | ||||
|   ret = 1; | ||||
| 
 | ||||
|   while((cur = A_lowest(open)) != NULL) { | ||||
|     /* Mark system as known and go to next. */ | ||||
|     sys = cur->sys; | ||||
|     dep = cur->r; | ||||
|     if(!sys_isFlag(sys, SYSTEM_KNOWN)) { | ||||
|       ret = 0; | ||||
|       break; | ||||
|     } | ||||
|     open = A_rm(open, sys); | ||||
|     closed = A_add(closed, cur); | ||||
| 
 | ||||
|     /* Check it's jumps. */ | ||||
|     for(i = 0; i < sys->njumps; i++) { | ||||
|       jsys = &systems_stack[cur->sys->jumps[i]]; | ||||
| 
 | ||||
|       /* System has already been parsed or is too deep. */ | ||||
|       if((A_in(closed, jsys) != NULL) || (dep+1 > r)) | ||||
|         continue; | ||||
| 
 | ||||
|       /* Create new node and such. */ | ||||
|       neighbour = A_newNode(jsys, NULL); | ||||
|       neighbour->r = dep+1; | ||||
|       open = A_add(open, neighbour); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   A_freeList(A_gc); | ||||
|   return ret; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis