mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Migrate code to for_each_dive and for_each_dc
[Dirk Hohndel: this overlapped with my commit 09e7c61fee ("Consistently
	       use for_each_dive (and use it correctly)") so I took the
	       pieces that I had missed]
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
			
			
This commit is contained in:
		
							parent
							
								
									91c20357f5
								
							
						
					
					
						commit
						05d9cc409c
					
				
					 6 changed files with 9 additions and 21 deletions
				
			
		
							
								
								
									
										5
									
								
								dive.c
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								dive.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1320,11 +1320,8 @@ static void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, int
 | 
			
		|||
static void cylinder_renumber(struct dive *dive, int mapping[])
 | 
			
		||||
{
 | 
			
		||||
	struct divecomputer *dc;
 | 
			
		||||
 | 
			
		||||
	dc = &dive->dc;
 | 
			
		||||
	do {
 | 
			
		||||
	for_each_dc(dive, dc)
 | 
			
		||||
		dc_cylinder_renumber(dive, dc, mapping);
 | 
			
		||||
	} while ((dc = dc->next) != NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -162,9 +162,9 @@ extern "C" void set_dc_nickname(struct dive *dive)
 | 
			
		|||
	if (!dive)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	struct divecomputer *dc = &dive->dc;
 | 
			
		||||
	struct divecomputer *dc;
 | 
			
		||||
 | 
			
		||||
	while (dc) {
 | 
			
		||||
	for_each_dc(dive, dc) {
 | 
			
		||||
		if (dc->model && *dc->model && dc->deviceid &&
 | 
			
		||||
		    !dcList.getExact(dc->model, dc->deviceid)) {
 | 
			
		||||
			// we don't have this one, yet
 | 
			
		||||
| 
						 | 
				
			
			@ -181,6 +181,5 @@ extern "C" void set_dc_nickname(struct dive *dive)
 | 
			
		|||
				dcList.addDC(dc->model, dc->deviceid);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		dc = dc->next;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -887,8 +887,7 @@ void DiveListView::loadImages()
 | 
			
		|||
		for_each_dive(j, dive) {
 | 
			
		||||
			if (!dive->selected)
 | 
			
		||||
				continue;
 | 
			
		||||
			dc = &(dive->dc);
 | 
			
		||||
			while (dc) {
 | 
			
		||||
			for_each_dc(dive, dc) {
 | 
			
		||||
				when = dc->when ? dc->when : dive->when;
 | 
			
		||||
				duration_s = dc->duration.seconds ? dc->duration.seconds : dive->duration.seconds;
 | 
			
		||||
				if (when - 3600 < imagetime && when + duration_s + 3600 > imagetime) {
 | 
			
		||||
| 
						 | 
				
			
			@ -909,7 +908,6 @@ void DiveListView::loadImages()
 | 
			
		|||
					MainWindow::instance()->refreshDisplay();
 | 
			
		||||
					MainWindow::instance()->graphics()->replot();
 | 
			
		||||
				}
 | 
			
		||||
				dc = dc->next;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -392,12 +392,8 @@ void save_one_dive(struct membuffer *b, struct dive *dive)
 | 
			
		|||
	save_weightsystem_info(b, dive);
 | 
			
		||||
	save_dive_temperature(b, dive);
 | 
			
		||||
	/* Save the dive computer data */
 | 
			
		||||
	dc = &dive->dc;
 | 
			
		||||
	do {
 | 
			
		||||
	for_each_dc(dive, dc)
 | 
			
		||||
		save_dc(b, dive, dc);
 | 
			
		||||
		dc = dc->next;
 | 
			
		||||
	} while (dc);
 | 
			
		||||
 | 
			
		||||
	put_format(b, "</dive>\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -294,12 +294,12 @@ void get_selected_dives_text(char *buffer, int size)
 | 
			
		|||
 | 
			
		||||
static bool is_gas_used(struct dive *dive, int idx)
 | 
			
		||||
{
 | 
			
		||||
	struct divecomputer *dc = &dive->dc;
 | 
			
		||||
	struct divecomputer *dc;
 | 
			
		||||
	bool firstGasExplicit = false;
 | 
			
		||||
	if (cylinder_none(&dive->cylinder[idx]))
 | 
			
		||||
		return false;
 | 
			
		||||
 | 
			
		||||
	while (dc) {
 | 
			
		||||
	for_each_dc(dive, dc) {
 | 
			
		||||
		struct event *event = get_next_event(dc->events, "gaschange");
 | 
			
		||||
		while (event) {
 | 
			
		||||
			if (event->time.seconds < 30)
 | 
			
		||||
| 
						 | 
				
			
			@ -308,7 +308,6 @@ static bool is_gas_used(struct dive *dive, int idx)
 | 
			
		|||
				return true;
 | 
			
		||||
			event = get_next_event(event->next, "gaschange");
 | 
			
		||||
		}
 | 
			
		||||
		dc = dc->next;
 | 
			
		||||
	}
 | 
			
		||||
	if (idx == 0 && !firstGasExplicit)
 | 
			
		||||
		return true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -795,13 +795,12 @@ static char *uemis_get_divenr(char *deviceidstr)
 | 
			
		|||
	deviceid = atoi(deviceidstr);
 | 
			
		||||
	struct dive *d;
 | 
			
		||||
	for_each_dive (i, d) {
 | 
			
		||||
		struct divecomputer *dc = &d->dc;
 | 
			
		||||
		while (dc) {
 | 
			
		||||
		struct divecomputer *dc;
 | 
			
		||||
		for_each_dc(d, dc) {
 | 
			
		||||
			if (dc->model && !strcmp(dc->model, "Uemis Zurich") &&
 | 
			
		||||
			    (dc->deviceid == 0 || dc->deviceid == 0x7fffffff || dc->deviceid == deviceid) &&
 | 
			
		||||
			    dc->diveid > maxdiveid)
 | 
			
		||||
				maxdiveid = dc->diveid;
 | 
			
		||||
			dc = dc->next;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	snprintf(divenr, 10, "%d", maxdiveid);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue