Beispiel #1
0
/*
 *	The function "mon()" is the dialog user interface, called
 *	from the simulation just after program start.
 */
void mon(void)
{
	register int eoj = 1;
	static char cmd[LENCMD];

	tcgetattr(0, &old_term);

	if (x_flag) {
		if (do_getfile(xfn) == 0)
			do_go();
	}
	while (eoj) {
		next:
		printf(">>> ");
		fflush(stdout);
		if (fgets(cmd, LENCMD, stdin) == NULL) {
			putchar('\n');
			goto next;
		}
		switch (*cmd) {
		case '\n':
			do_step();
			break;
		case 't':
			do_trace(cmd + 1);
			break;
		case 'g':
			do_go();
			break;
		case 'd':
			do_dump(cmd + 1);
			break;
		case 'l':
			do_list(cmd + 1);
			break;
		case 'm':
			do_modify(cmd +	1);
			break;
		case 'f':
			do_fill(cmd + 1);
			break;
		case 'v':
			do_move(cmd + 1);
			break;
		case 'x':
			do_reg(cmd + 1);
			break;
		case 'p':
			do_port(cmd + 1);
			break;
		case 'b':
			do_break(cmd + 1);
			break;
		case 'h':
			do_hist(cmd + 1);
			break;
		case 'z':
			do_count(cmd + 1);
			break;
		case 'c':
			do_clock();
			break;
		case 's':
			do_show();
			break;
		case '?':
			do_help();
			break;
		case 'r':
			do_getfile(cmd + 1);
			break;
		case '!':
			do_unix(cmd + 1);
			break;
		case 'q':
			eoj = 0;
			break;
		default:
			puts("what??");
			break;
		}
	}
}
static void 
simulate_mappoints (void)
{
    int xx, yy;
    shuffle_mappoint_array ();
    for (yy = 0; yy < WORLD_SIDE_LEN; yy++) {
	/* indirection to rand array to stop lots of linear effects */
	int y = mappoint_array_y[yy];
	for (xx = 0; xx < WORLD_SIDE_LEN; xx++) {
	    int x = mappoint_array_x[xx];
	    short grp = MP_GROUP(x,y);
	    if (grp == GROUP_USED || grp == GROUP_BARE)
		continue;
	    switch (grp) {
	    case GROUP_TRACK:
		do_track (x, y);
		break;
	    case GROUP_RAIL:
		do_rail (x, y);
		break;
	    case GROUP_ROAD:
		do_road (x, y);
		break;
	    case GROUP_ORGANIC_FARM:
		do_organic_farm (x, y);
		break;
	    case GROUP_MARKET:
		do_market (x, y);
		break;
	    case GROUP_RESIDENCE_LL:
		do_residence (x, y);
		break;
	    case GROUP_RESIDENCE_ML:
		do_residence (x, y);
		break;
	    case GROUP_RESIDENCE_HL:
		do_residence (x, y);
		break;
	    case GROUP_RESIDENCE_LH:
		do_residence (x, y);
		break;
	    case GROUP_RESIDENCE_MH:
		do_residence (x, y);
		break;
	    case GROUP_RESIDENCE_HH:
		do_residence (x, y);
		break;
	    case GROUP_POWER_LINE:
	        do_power_line (x, y);
		break;
	    case GROUP_SOLAR_POWER:
		do_power_source (x, y);
		break;
	    case GROUP_SUBSTATION:
		do_power_substation (x, y);
		break;
	    case GROUP_COALMINE:
		do_coalmine (x, y);
		break;
	    case GROUP_COAL_POWER:
		do_power_source_coal (x, y);
		break;
	    case GROUP_INDUSTRY_L:
		do_industry_l (x, y);
		break;
	    case GROUP_INDUSTRY_H:
		do_industry_h (x, y);
		break;
	    case GROUP_COMMUNE:
		do_commune (x, y);
		break;
	    case GROUP_OREMINE:
		do_oremine (x, y);
		break;
	    case GROUP_PORT:
		do_port (x, y);
		break;
	    case GROUP_TIP:
		do_tip (x, y);
		break;
	    case GROUP_PARKLAND:
		do_parkland (x, y);
		break;
	    case GROUP_UNIVERSITY:
		do_university (x, y);
		break;
	    case GROUP_RECYCLE:
		do_recycle (x, y);
		break;
	    case GROUP_HEALTH:
		do_health_centre (x, y);
		break;
	    case GROUP_ROCKET:
		do_rocket_pad (x, y);
		break;
	    case GROUP_WINDMILL:
		do_windmill (x, y);
		break;
	    case GROUP_MONUMENT:
		do_monument (x, y);
		break;
	    case GROUP_SCHOOL:
		do_school (x, y);
		break;
	    case GROUP_BLACKSMITH:
		do_blacksmith (x, y);
		break;
	    case GROUP_MILL:
		do_mill (x, y);
		break;
	    case GROUP_POTTERY:
		do_pottery (x, y);
		break;
	    case GROUP_FIRESTATION:
		do_firestation (x, y);
		break;
	    case GROUP_CRICKET:
		do_cricket (x, y);
		break;
	    case GROUP_FIRE:
		do_fire (x, y);
		break;
	    case GROUP_SHANTY:
		do_shanty (x, y);
		break;
	    }
	}
    }
}