Пример #1
0
/**
 * ボードを上から表示
 * @param stone_t board[][] 盤面
 */
void print_board(const stone_t board[HIGHT][AREA])
{
	int i;

	for (i = HIGHT - 1; i >= 0; i--) {
		printf("---%2d段目---\n", i + 1);
		print_plane(board[i]);
	}
}
Пример #2
0
void print_crtc(Crtc& cc, int ind)
{
	printf("%sCRTC Id %d BufferId %d %dx%d at %dx%d gamma_size %d\n",
	       width(ind, "").c_str(), cc.id(), cc.buffer_id(), cc.width(),
	       cc.height(), cc.x(), cc.y(), cc.gamma_size());

	printf("%s   Mode ", width(ind, "").c_str());
	print_mode(cc.mode(), 0);

	if (opts.print_props)
		print_properties(cc, ind+2);

	if (opts.recurse)
		for (auto p : cc.get_possible_planes())
			print_plane(*p, ind + 2);
}
Пример #3
0
int
edit(void)
{
    union empobj_storage item;
    char *what;
    struct nstr_item ni;
    char *key, *ptr;
    struct natstr *np;
    int type, arg_index, ret;
    char buf[1024];

    what = getstarg(player->argp[1],
		    "Edit what (country, land, ship, plane, nuke, unit)? ",
		    buf);
    if (!what)
	return RET_SYN;
    switch (what[0]) {
    case 'l':
	type = EF_SECTOR;
	break;
    case 'p':
	type = EF_PLANE;
	break;
    case 's':
	type = EF_SHIP;
	break;
    case 'u':
	type = EF_LAND;
	break;
    case 'n':
	type = EF_NUKE;
	break;
    case 'c':
	type = EF_NATION;
	break;
    default:
	pr("huh?\n");
	return RET_SYN;
    }

    if (!snxtitem(&ni, type, player->argp[2], NULL))
	return RET_SYN;
    while (nxtitem(&ni, &item)) {
	if (!player->argp[3]) {
	    switch (type) {
	    case EF_SECTOR:
		print_sect(&item.sect);
		break;
	    case EF_SHIP:
		print_ship(&item.ship);
		break;
	    case EF_PLANE:
		print_plane(&item.plane);
		break;
	    case EF_LAND:
		print_land(&item.land);
		break;
	    case EF_NUKE:
		print_nuke(&item.nuke);
		break;
	    case EF_NATION:
		print_nat(&item.nat);
		break;
	    default:
		CANT_REACH();
	    }
	}

	arg_index = 3;
	for (;;) {
	    if (player->argp[arg_index]) {
		if (player->argp[arg_index+1]) {
		    key = player->argp[arg_index++];
		    ptr = player->argp[arg_index++];
		} else
		    return RET_SYN;
	    } else if (arg_index == 3) {
		key = getin(buf, &ptr);
		if (!key)
		    return RET_SYN;
		if (!*key)
		    break;
	    } else
		break;

	    if (!check_obj_ok(&item.gen))
		return RET_FAIL;
	    switch (type) {
	    case EF_NATION:
		/*
		 * edit_nat() may update the edited country by sending
		 * it bulletins.  Writing back item.nat would trigger
		 * a seqno mismatch oops.  Workaround: edit in-place.
		 */
		np = getnatp(item.nat.nat_cnum);
		ret = edit_nat(np, key, ptr);
		if (ret != RET_OK)
		    return ret;
		if (!putnat(np))
		    return RET_FAIL;
		item.nat = *np;
		continue;
	    case EF_SECTOR:
		ret = edit_sect(&item.sect, key, ptr);
		break;
	    case EF_SHIP:
		ret = edit_ship(&item.ship, key, ptr);
		break;
	    case EF_LAND:
		ret = edit_land(&item.land, key, ptr);
		break;
	    case EF_PLANE:
		ret = edit_plane(&item.plane, key, ptr);
		break;
	    case EF_NUKE:
		ret = edit_nuke(&item.nuke, key, ptr);
		break;
	    default:
		CANT_REACH();
	    }
	    if (ret != RET_OK)
		return ret;
	    if (!put_empobj(type, item.gen.uid, &item.gen))
		return RET_FAIL;
	}
    }

    return RET_OK;
}