Exemple #1
0
void advance_time(struct station *kipling, struct train **first)
{
	// Simulates one minute of the Bloor-Danforth line
	// PRE: *kipling, *first, **first all are not null, there is more than one train on the track
	// POST: the stations and trains will be altered: trains will advance, stations' passengers will increase/decrease

	assert(kipling);
	assert(first);
	assert(*first);
	assert((*first)->next);

	// increment passenger waiting times
	passengers_wait(kipling);

	// add trains if appropriate
	add_trains(first);

	// passengers arrive
	enter_passengers(kipling);

	// load the trains
	load_trains(kipling, first);

	// first advance any trains that can move; delete any that advance into position 83
	advance_trains(kipling, first);
}
Exemple #2
0
void on_btnupdate_clicked(GtkButton *button) {
	//down em all
	GSList *lurl = NULL;
	GSList *ldest = NULL;
	for(gint i=0;i<num_of_lines;++i) {
		gchar trainfolder[512];
		g_snprintf(trainfolder,512,"%s/%s",getProgData("trains"),lines[i].line);
		g_mkdir_with_parents(trainfolder,0755);
		for(gint j=0;j<lines[i].num;++j) {
			gchar url[200];
			gchar dest[512];
			g_snprintf(dest,512,"%s/%s.pdf",trainfolder,lines[i].stations[j].name);
			g_snprintf(url,200,"http://transitchicago.com/maps/rail/%s/%s.pdf\n",lines[i].line,lines[i].stations[j].name);
			lurl = g_slist_prepend(lurl,url);
			ldest = g_slist_prepend(ldest,dest);
		}
	}
	if(!downFile(lurl,ldest)) goto died;
	load_trains();
	return;
died:
	//TODO: delete train info already dled
	return;
}