当前位置: 首页>>代码示例>>C++>>正文


C++ prt函数代码示例

本文整理汇总了C++中prt函数的典型用法代码示例。如果您正苦于以下问题:C++ prt函数的具体用法?C++ prt怎么用?C++ prt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了prt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: show_file


//.........这里部分代码省略.........
            /* Highlight "shower" */
            if (shower[0])
            {
                const char *str = lc_buf;

                /* Display matches */
                while ((str = strstr(str, shower)) != NULL)
                {
                    int len = strlen(shower);

                    /* Display the match */
                    Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);

                    /* Advance */
                    str += len;
                }
            }

            /* Count the printed lines */
            i++;
        }

        /* Hack -- failed search */
        if (find)
        {
            bell("Search string not found!");
            line = back;
            find = NULL;
            continue;
        }


        /* Show a general "title" */
        prt(format("[%s, %s, Line %d-%d/%d]", buildid,
                   caption, line, line + hgt - 4, size), 0, 0);


        /* Prompt -- menu screen */
        if (menu)
        {
            /* Wait for it */
            prt("[Press a Letter, or ESC to exit.]", hgt - 1, 0);
        }

        /* Prompt -- small files */
        else if (size <= hgt - 4)
        {
            /* Wait for it */
            prt("[Press ESC to exit.]", hgt - 1, 0);
        }

        /* Prompt -- large files */
        else
        {
            /* Wait for it */
            prt("[Press Space to advance, or ESC to exit.]", hgt - 1, 0);
        }

        /* Get a keypress */
        ch = inkey();

        /* Exit the help */
        if (ch.code == '?') break;

        /* Toggle case sensitive on/off */
        if (ch.code == '!')
开发者ID:bscottm,项目名称:angband,代码行数:67,代码来源:files.c

示例2: textui_get_item


//.........这里部分代码省略.........
			int ne = 0;

			/* If inven or equip is on the main screen, and only one of them
			 * is slated for a subwindow, we should show the opposite there */
			for (j = 0; j < ANGBAND_TERM_MAX; j++) {
				/* Unused */
				if (!angband_term[j]) continue;

				/* Count windows displaying inven */
				if (window_flag[j] & (PW_INVEN)) ni++;

				/* Count windows displaying equip */
				if (window_flag[j] & (PW_EQUIP)) ne++;
			}

			/* Are we in the situation where toggling makes sense? */
			if ((ni && !ne) || (!ni && ne)) {
				if (player->upkeep->command_wrk == USE_EQUIP) {
					if ((ne && !toggle) || (ni && toggle)) {
						/* Main screen is equipment, so is subwindow */
						toggle_inven_equip();
						toggle = !toggle;
					}
				} else if (player->upkeep->command_wrk == USE_INVEN) {
					if ((ni && !toggle) || (ne && toggle)) {
						/* Main screen is inventory, so is subwindow */
						toggle_inven_equip();
						toggle = !toggle;
					}
				} else {
					/* Quiver or floor, go back to the original */
					if (toggle) {
						toggle_inven_equip();
						toggle = !toggle;
					}
				}
			}

			/* Redraw */
			player->upkeep->redraw |= (PR_INVEN | PR_EQUIP);

			/* Redraw windows */
			redraw_stuff(player);

			/* Save screen */
			screen_save();

			/* Build object list */
			wipe_obj_list();
			if (player->upkeep->command_wrk == USE_INVEN)
				build_obj_list(i2, player->upkeep->inven, tester_m, olist_mode);
			else if (player->upkeep->command_wrk == USE_EQUIP)
				build_obj_list(e2, NULL, tester_m, olist_mode);
			else if (player->upkeep->command_wrk == USE_QUIVER)
				build_obj_list(q2, player->upkeep->quiver, tester_m,olist_mode);
			else if (player->upkeep->command_wrk == USE_FLOOR)
				build_obj_list(f2, floor_list, tester_m, olist_mode);

			/* Show the prompt */
			menu_header();
			if (pmt) {
				prt(pmt, 0, 0);
				prt(header, 0, strlen(pmt) + 1);
			}

			/* No menu change request */
			newmenu = FALSE;

			/* Get an item choice */
			*choice = item_menu(cmd, MAX(strlen(pmt), 15), mode);

			/* Fix the screen */
			screen_load();

			/* Update */
			player->upkeep->redraw |= (PR_INVEN | PR_EQUIP);
			redraw_stuff(player);

			/* Clear the prompt line */
			prt("", 0, 0);

			/* We have a selection, or are backing out */
			if (*choice || !newmenu) {
				if (toggle) toggle_inven_equip();
				break;
			}
		}
	} else {
		/* Warning if needed */
		if (str) msg("%s", str);
		*choice = NULL;
	}

	/* Clean up */
	player->upkeep->command_wrk = 0;
	mem_free(floor_list);

	/* Result */
	return (*choice != NULL) ? TRUE : FALSE;
}
开发者ID:danaris,项目名称:tgcangband,代码行数:101,代码来源:ui-object.c

示例3: show_obj

/**
 * Display an object.  Each object may be prefixed with a label.
 * Used by show_inven(), show_equip(), show_quiver() and show_floor().
 * Mode flags are documented in object.h
 */
static void show_obj(int obj_num, int row, int col, bool cursor,
					 olist_detail_t mode)
{
	int attr;
	int label_attr = cursor ? COLOUR_L_BLUE : COLOUR_WHITE;
	int ex_offset_ctr;
	char buf[80];
	struct object *obj = items[obj_num].object;
	bool show_label = (mode & OLIST_WINDOW || player->is_dead) ? TRUE : FALSE;
	int label_size = show_label ? strlen(items[obj_num].label) : 0;
	int equip_label_size = strlen(items[obj_num].equip_label);

	/* Clear the line */
	prt("", row + obj_num, MAX(col - 1, 0));

	/* If we have no label then we won't display anything */
	if (!strlen(items[obj_num].label)) return;

	/* Print the label */
	if (show_label)
		c_put_str(label_attr, items[obj_num].label, row + obj_num, col);

	/* Print the equipment label */
	c_put_str(label_attr, items[obj_num].equip_label, row + obj_num,
			  col + label_size);

	/* Limit object name */
	if (label_size + equip_label_size + strlen(items[obj_num].o_name) >
		(size_t)ex_offset) {
		int truncate = ex_offset - label_size - equip_label_size;

		if (truncate < 0) truncate = 0;
		if ((size_t)truncate > sizeof(items[obj_num].o_name) - 1)
			truncate = sizeof(items[obj_num].o_name) - 1;

		items[obj_num].o_name[truncate] = '\0';
	}

	/* Item kind determines the color of the output */
	if (obj)
		attr = obj->kind->base->attr;
	else
		attr = COLOUR_SLATE;

	/* Object name */
	c_put_str(attr, items[obj_num].o_name, row + obj_num,
			  col + label_size + equip_label_size);

	/* If we don't have an object, we can skip the rest of the output */
	if (!obj) return;

	/* Extra fields */
	ex_offset_ctr = ex_offset;

	/* Price */
	if (mode & OLIST_PRICE) {
		struct store *store = store_at(cave, player->py, player->px);
		if (store) {
			int price = price_item(store, obj, TRUE, obj->number);

			strnfmt(buf, sizeof(buf), "%6d au", price);
			put_str(buf, row + obj_num, col + ex_offset_ctr);
			ex_offset_ctr += 9;
		}
	}

	/* Failure chance for magic devices and activations */
	if (mode & OLIST_FAIL && obj_can_fail(obj)) {
		int fail = (9 + get_use_device_chance(obj)) / 10;
		if (object_effect_is_known(obj))
			strnfmt(buf, sizeof(buf), "%4d%% fail", fail);
		else
			my_strcpy(buf, "    ? fail", sizeof(buf));
		put_str(buf, row + obj_num, col + ex_offset_ctr);
		ex_offset_ctr += 10;
	}

	/* Weight */
	if (mode & OLIST_WEIGHT) {
		int weight = obj->weight * obj->number;
		strnfmt(buf, sizeof(buf), "%4d.%1d lb", weight / 10, weight % 10);
		put_str(buf, row + obj_num, col + ex_offset_ctr);
		ex_offset_ctr += 9;
	}
}
开发者ID:danaris,项目名称:tgcangband,代码行数:90,代码来源:ui-object.c

示例4: wiz_display_item

/**
 * Display an item's properties
 */
static void wiz_display_item(object_type * o_ptr)
{
	int j = 0;

	char buf[256];


	/* Clear screen */
	Term_clear();

	/* Describe fully */
	object_desc(buf, sizeof(buf), o_ptr,
				ODESC_PREFIX | ODESC_FULL | ODESC_SPOIL);
	prt(buf, 2, j);

	prt(format
		("kind = %-5d  level = %-4d  tval = %-5d  sval = %-5d",
		 o_ptr->k_idx, k_info[o_ptr->k_idx].level, o_ptr->tval,
		 o_ptr->sval), 4, j);

	prt(format
		("number = %-3d  wgt = %-6d  ac = %-5d    damage = %dd%d",
		 o_ptr->number, o_ptr->weight, o_ptr->ac, o_ptr->dd, o_ptr->ds), 5,
		j);

	prt(format
		("pval = %-5d  toac = %-5d  tohit = %-4d  todam = %-4d",
		 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);

	prt(format
		("name1 = %-4d  name2 = %-4d  cost = %ld", o_ptr->name1,
		 o_ptr->name2, (long) object_value(o_ptr)), 7, j);

	prt(format
		("ident = %04x  timeout = %-d", o_ptr->ident, o_ptr->timeout), 8,
		j);

	prt("+------------FLAGS_------------+", 10, j);
	prt("..SUST..POWERS....OTHER.........", 11, j);
	prt("                                ", 12, j);
	prt("tbsiwdcc  re   s  ttbiaefc   f..", 13, j);
	prt("hatnieohsfessfhefphhlmcliosspr..", 14, j);
	prt("rlrtsxnadfgpialerlrdspppppmcca..", 15, j);
	prt_binary(o_ptr->flags_obj, 0, 16, j, '*', 32);

	prt("+------------CURSES------------+", 17, j);
	prt("	n r    b b       b             ", 18, j);
	prt("ttaasahppcuhdaassppdddd.........", 19, j);
	prt("eeggrfuooutawduttaaxssc.........", 20, j);
	prt("llggerniitrlemncwrrppth.........", 21, j);
	prt_binary(o_ptr->flags_curse, 0, 22, j, '*', 32);
	prt("Resists, bonuses and slays coming soon...", 23, j);
}
开发者ID:NickMcConnell,项目名称:Beleriand,代码行数:56,代码来源:wizard2.c

示例5: death_info

/**
 * Menu command: view character dump and inventory.
 */
static void death_info(const char *title, int row)
{
	struct store *home = &stores[STORE_HOME];

	screen_save();

	/* Display player */
	display_player(0);

	/* Prompt for inventory */
	prt("Hit any key to see more information: ", 0, 0);

	/* Allow abort at this point */
	(void)anykey();


	/* Show equipment and inventory */

	/* Equipment -- if any */
	if (player->upkeep->equip_cnt) {
		Term_clear();
		show_equip(OLIST_WEIGHT | OLIST_SEMPTY, NULL);
		prt("You are using: -more-", 0, 0);
		(void)anykey();
	}

	/* Inventory -- if any */
	if (player->upkeep->inven_cnt) {
		Term_clear();
		show_inven(OLIST_WEIGHT, NULL);
		prt("You are carrying: -more-", 0, 0);
		(void)anykey();
	}

	/* Home -- if anything there */
	if (home->stock) {
		int page;
		struct object *obj = home->stock;

		/* Display contents of the home */
		for (page = 1; obj; page++) {
			int line;

			/* Clear screen */
			Term_clear();

			/* Show 12 items */
			for (line = 0; obj && line < 12; obj = obj->next, line++) {
				byte attr;

				char o_name[80];
				char tmp_val[80];

				/* Print header, clear line */
				strnfmt(tmp_val, sizeof(tmp_val), "%c) ", I2A(line));
				prt(tmp_val, line + 2, 4);

				/* Get the object description */
				object_desc(o_name, sizeof(o_name), obj,
						ODESC_PREFIX | ODESC_FULL);

				/* Get the inventory color */
				attr = obj->kind->base->attr;

				/* Display the object */
				c_put_str(attr, o_name, line + 2, 7);
			}

			/* Caption */
			prt(format("Your home contains (page %d): -more-", page), 0, 0);

			/* Wait for it */
			(void)anykey();
		}
	}

	screen_load();
}
开发者ID:TricksterWolf,项目名称:ponyband,代码行数:81,代码来源:ui-death.c

示例6: do_cmd_racial_power


//.........这里部分代码省略.........
	redraw = FALSE;

	/* Build a prompt */
	(void)strnfmt(out_val, 78, "(Powers %c-%c, *=List, ESC=exit) Use which power? ",
		I2A(0), (num <= 26) ? I2A(num - 1) : '0' + num - 27);

	if (!repeat_pull(&i) || i<0 || i>=num)
	{
		/* Get a spell from the user */
		while (!flag && get_com(out_val, &choice))
		{
			/* Request redraw */
			if ((choice == ' ') || (choice == '*') || (choice == '?'))
			{
				/* Show the list */
				if (!redraw)
				{
					byte y = 1, x = 0;
					int ctr = 0;
					char dummy[80];
					char letter;
					int x1, y1;

					strcpy(dummy, "");

					/* Show list */
					redraw = TRUE;

					/* Save the screen */
					screen_save();

					/* Print header(s) */
					if (num < 17)
						prt("                            Lv Cost Fail", y++, x);
					else
						prt("                            Lv Cost Fail                            Lv Cost Fail", y++, x);

					/* Print list */
					while (ctr < num)
					{
						/* letter/number for power selection */
						if (ctr < 26)
							letter = I2A(ctr);
						else
							letter = '0' + ctr - 26;
						x1 = ((ctr < 17) ? x : x + 40);
						y1 = ((ctr < 17) ? y + ctr : y + ctr - 17);

						sprintf(dummy, " %c) %-23.23s %2d %4d %3d%%",
							letter,
							power_desc[ctr].name,
							power_desc[ctr].level,
							power_desc[ctr].cost,
							power_desc[ctr].fail);
						prt(dummy, y1, x1);
						ctr++;
					}
				}

				/* Hide the list */
				else
				{
					/* Hide list */
					redraw = FALSE;

					/* Restore the screen */
开发者ID:BackupTheBerlios,项目名称:randomband,代码行数:67,代码来源:racial.c

示例7: wiz_statistics

/**
 * Try to create an item again. Output some statistics. -Bernd-
 *
 * The statistics are correct now.  We acquire a clean grid, and then
 * repeatedly place an object in this grid, copying it into an item
 * holder, and then deleting the object.  We fiddle with the artifact
 * counter flags to prevent weirdness.  We use the items to collect
 * statistics on item creation relative to the initial item.
 */
static void wiz_statistics(object_type * o_ptr)
{
	long i, matches, better, worse, other;

	struct keypress ch;
	char *quality;

	bool good, great;

	object_type *i_ptr;
	object_type object_type_body;

	const char *q =
		"Rolls: %ld, Matches: %ld, Better: %ld, Worse: %ld, Other: %ld";


	/* Mega-Hack -- allow multiple artifacts XXX XXX XXX */
	if (artifact_p(o_ptr))
		a_info[o_ptr->name1].created = FALSE;


	/* Interact */
	while (TRUE) {
		const char *pmt =
			"Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";

		/* Display item */
		wiz_display_item(o_ptr);

		/* Get choices */
		if (!get_com(pmt, &ch))
			break;

		if (ch.code == 'n' || ch.code == 'N') {
			good = FALSE;
			great = FALSE;
			quality = "normal";
		} else if (ch.code == 'g' || ch.code == 'G') {
			good = TRUE;
			great = FALSE;
			quality = "good";
		} else if (ch.code == 'e' || ch.code == 'E') {
			good = TRUE;
			great = TRUE;
			quality = "excellent";
		} else {
			good = FALSE;
			great = FALSE;
			break;
		}

		/* Let us know what we are doing */
		msg("Creating a lot of %s items. Base level = %d.", quality,
			p_ptr->danger);
		message_flush();

		/* Set counters to zero */
		matches = better = worse = other = 0;

		/* Let's rock and roll */
		for (i = 0; i <= TEST_ROLL; i++) {
			/* Output every few rolls */
			if ((i < 100) || (i % 100 == 0)) {
				struct keypress kp;

				/* Do not wait */
				inkey_scan = SCAN_INSTANT;

				/* Allow interupt */
				kp = inkey();
				if (kp.type != EVT_NONE) {
					flush();
					break;
				}

				/* Dump the stats */
				prt(format(q, i, matches, better, worse, other), 0, 0);
				Term_fresh();
			}


			/* Get local object */
			i_ptr = &object_type_body;

			/* Wipe the object */
			object_wipe(i_ptr);

			/* Create an object */
			make_object(i_ptr, good, great, FALSE);


//.........这里部分代码省略.........
开发者ID:NickMcConnell,项目名称:Beleriand,代码行数:101,代码来源:wizard2.c

示例8: prterr

void
prterr(char *prefix)
{
	prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
}
开发者ID:CzBiX,项目名称:ceph,代码行数:5,代码来源:fsx.c

示例9: prterrcode

void
prterrcode(char *prefix, int code)
{
	prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(-code));
}
开发者ID:CzBiX,项目名称:ceph,代码行数:5,代码来源:fsx.c

示例10: check_clone

void
check_clone(int clonenum)
{
	char filename[128];
	char imagename[128];
	int ret, fd;
	struct rbd_ctx cur_ctx = RBD_CTX_INIT;
	struct stat file_info;
	char *good_buf, *temp_buf;

	clone_imagename(imagename, sizeof(imagename), clonenum);
	if ((ret = ops->open(imagename, &cur_ctx)) < 0) {
		prterrcode("check_clone: ops->open", ret);
		exit(167);
	}

	clone_filename(filename, sizeof(filename), clonenum + 1);
	if ((fd = open(filename, O_RDONLY)) < 0) {
		simple_err("check_clone: open", -errno);
		exit(168);
	}

	prt("checking clone #%d, image %s against file %s\n",
	    clonenum, imagename, filename);
	if ((ret = fstat(fd, &file_info)) < 0) {
		simple_err("check_clone: fstat", -errno);
		exit(169);
	}

	good_buf = NULL;
	ret = posix_memalign((void **)&good_buf,
			     MAX(writebdy, (int)sizeof(void *)),
			     file_info.st_size);
	if (ret > 0) {
		prterrcode("check_clone: posix_memalign(good_buf)", -ret);
		exit(96);
	}

	temp_buf = NULL;
	ret = posix_memalign((void **)&temp_buf,
			     MAX(readbdy, (int)sizeof(void *)),
			     file_info.st_size);
	if (ret > 0) {
		prterrcode("check_clone: posix_memalign(temp_buf)", -ret);
		exit(97);
	}

	if ((ret = pread(fd, good_buf, file_info.st_size, 0)) < 0) {
		simple_err("check_clone: pread", -errno);
		exit(170);
	}
	if ((ret = ops->read(&cur_ctx, 0, file_info.st_size, temp_buf)) < 0) {
		prterrcode("check_clone: ops->read", ret);
		exit(171);
	}
	close(fd);
	if ((ret = ops->close(&cur_ctx)) < 0) {
		prterrcode("check_clone: ops->close", ret);
		exit(174);
	}
	check_buffers(good_buf, temp_buf, 0, file_info.st_size);

	unlink(filename);

	free(good_buf);
	free(temp_buf);
}
开发者ID:CzBiX,项目名称:ceph,代码行数:67,代码来源:fsx.c

示例11: test

void
test(void)
{
	unsigned long	offset;
	unsigned long	size = maxoplen;
	unsigned long	rv = get_random();
	unsigned long	op;

	if (simulatedopcount > 0 && testcalls == simulatedopcount)
		writefileimage();

	testcalls++;

	if (closeprob)
		closeopen = (rv >> 3) < (1u << 28) / (unsigned)closeprob;

	if (debugstart > 0 && testcalls >= debugstart)
		debug = 1;

	if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
		prt("%lu...\n", testcalls);

	offset = get_random();
	if (randomoplen)
		size = get_random() % (maxoplen + 1);

	/* calculate appropriate op to run */
	if (lite)
		op = rv % OP_MAX_LITE;
	else
		op = rv % OP_MAX_FULL;

	switch (op) {
	case OP_MAPREAD:
		if (!mapped_reads)
			op = OP_READ;
		break;
	case OP_MAPWRITE:
		if (!mapped_writes)
			op = OP_WRITE;
		break;
	case OP_FALLOCATE:
		if (!fallocate_calls) {
			log4(OP_SKIPPED, OP_FALLOCATE, offset, size);
			goto out;
		}
		break;
	case OP_PUNCH_HOLE:
		if (!punch_hole_calls) {
			log4(OP_SKIPPED, OP_PUNCH_HOLE, offset, size);
			goto out;
		}
		break;
	case OP_CLONE:
		/* clone, 8% chance */
		if (!clone_calls || file_size == 0 || get_random() % 100 >= 8) {
			log4(OP_SKIPPED, OP_CLONE, 0, 0);
			goto out;
		}
		break;
	case OP_FLATTEN:
		/* flatten four times as rarely as clone, 2% chance */
		if (get_random() % 100 >= 2) {
			log4(OP_SKIPPED, OP_FLATTEN, 0, 0);
			goto out;
		}
		break;
	}

	switch (op) {
	case OP_READ:
		TRIM_OFF_LEN(offset, size, file_size);
		doread(offset, size);
		break;

	case OP_WRITE:
		TRIM_OFF_LEN(offset, size, maxfilelen);
		dowrite(offset, size);
		break;

	case OP_MAPREAD:
		TRIM_OFF_LEN(offset, size, file_size);
		exit(183);
		break;

	case OP_MAPWRITE:
		TRIM_OFF_LEN(offset, size, maxfilelen);
		exit(182);
		break;

	case OP_TRUNCATE:
		if (!style)
			size = get_random() % maxfilelen;
		dotruncate(size);
		break;

	case OP_PUNCH_HOLE:
		TRIM_OFF_LEN(offset, size, file_size);
		do_punch_hole(offset, size);
		break;
//.........这里部分代码省略.........
开发者ID:CzBiX,项目名称:ceph,代码行数:101,代码来源:fsx.c

示例12: do_clone

void
do_clone()
{
	char filename[1024];
	char imagename[1024];
	char lastimagename[1024];
	int ret, fd;
	int order = 0, stripe_unit = 0, stripe_count = 0;
	uint64_t newsize = file_size;

	log4(OP_CLONE, 0, 0, 0);
	++num_clones;

	if (randomize_striping) {
		order = 18 + get_random() % 8;
		stripe_unit = 1ull << (order - 1 - (get_random() % 8));
		stripe_count = 2 + get_random() % 14;
	}

	prt("%lu clone\t%d order %d su %d sc %d\n", testcalls, num_clones,
	    order, stripe_unit, stripe_count);

	clone_imagename(imagename, sizeof(imagename), num_clones);
	clone_imagename(lastimagename, sizeof(lastimagename),
			num_clones - 1);
	assert(strcmp(lastimagename, ctx.name) == 0);

	ret = ops->clone(&ctx, "snap", imagename, &order, stripe_unit,
			 stripe_count);
	if (ret < 0) {
		prterrcode("do_clone: ops->clone", ret);
		exit(165);
	}

	if (randomize_parent_overlap && rbd_image_has_parent(&ctx)) {
		int rand = get_random() % 16 + 1; // [1..16]

		if (rand < 13) {
			uint64_t overlap;

			ret = rbd_get_overlap(ctx.image, &overlap);
			if (ret < 0) {
				prterrcode("do_clone: rbd_get_overlap", ret);
				exit(1);
			}

			if (rand < 10) {	// 9/16
				newsize = overlap * ((double)rand / 10);
				newsize -= newsize % truncbdy;
			} else {		// 3/16
				newsize = 0;
			}

			assert(newsize != (uint64_t)file_size);
			prt("truncating image %s from 0x%llx (overlap 0x%llx) to 0x%llx\n",
			    ctx.name, file_size, overlap, newsize);

			ret = ops->resize(&ctx, newsize);
			if (ret < 0) {
				prterrcode("do_clone: ops->resize", ret);
				exit(1);
			}
		} else if (rand < 15) {		// 2/16
			prt("flattening image %s\n", ctx.name);

			ret = ops->flatten(&ctx);
			if (ret < 0) {
				prterrcode("do_clone: ops->flatten", ret);
				exit(1);
			}
		} else {			// 2/16
			prt("leaving image %s intact\n", ctx.name);
		}
	}

	clone_filename(filename, sizeof(filename), num_clones);
	if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) {
		simple_err("do_clone: open", -errno);
		exit(162);
	}
	save_buffer(good_buf, newsize, fd);
	if ((ret = close(fd)) < 0) {
		simple_err("do_clone: close", -errno);
		exit(163);
	}

	/*
	 * Close parent.
	 */
	if ((ret = ops->close(&ctx)) < 0) {
		prterrcode("do_clone: ops->close", ret);
		exit(174);
	}

	/*
	 * Open freshly made clone.
	 */
	if ((ret = ops->open(imagename, &ctx)) < 0) {
		prterrcode("do_clone: ops->open", ret);
		exit(166);
//.........这里部分代码省略.........
开发者ID:CzBiX,项目名称:ceph,代码行数:101,代码来源:fsx.c

示例13: assertmsg

void Prop2D::render(Camera *cam, DrawBatchList *bl ) {
    if( debug_id ) {
        assertmsg(deck || grid_used_num > 0 || children_num > 0 || prim_drawer , "no deck/grid/prim_drawer is set. deck:%p grid:%d child:%d prim:%p", deck, grid_used_num, children_num, prim_drawer );
    }
    
	float camx=0.0f;
	float camy=0.0f;
	if(cam){
		camx = cam->loc.x;
		camy = cam->loc.y;
	}

	if( children_num > 0 && render_children_first ){
		for(int i=0;i<children_num;i++){
			Prop2D *p = (Prop2D*) children[i];
            if( p->visible ) {
                if( !p->parent_group ) {
                    p->parent_group = parent_group;
                }
                p->render( cam, bl );
            }
		}
	}

	if( grid_used_num > 0 ){
		glEnable(GL_TEXTURE_2D);
		glColor4f(color.r,color.g,color.b,color.a);        
		for(int i=0;i<grid_used_num;i++){
			Grid *grid = grids[i];
			if(!grid)break;
			if(!grid->visible)continue;
            if(!grid->index_table)continue;

			Deck *draw_deck = deck;
			if( grid->deck ) draw_deck = grid->deck;
			if( grid->fragment_shader ){
#if !(TARGET_IPHONE_SIMULATOR ||TARGET_OS_IPHONE || defined(__linux__) )
				glUseProgram(grid->fragment_shader->program );
#endif                
				grid->fragment_shader->updateUniforms();
			}

            if(!grid->mesh) {
                //                print("new grid mesh! wh:%d,%d", grid->width, grid->height );
                grid->mesh = new Mesh();
                VertexFormat *vf = DrawBatch::getVertexFormat( VFTYPE_COORD_COLOR_UV );
                IndexBuffer *ib = new IndexBuffer();
                VertexBuffer *vb = new VertexBuffer();
                vb->setFormat(vf);
                /*
                  3+--+--+--+--+
                   |  |  |  |  |
                  2+--+--+--+--+
                   |  |  |  |  |
                  1+--+--+--+--+
                   |  |  |  |  |
                  0+--+--+--+--+
                   0  1  2  3  4
                 */
                int quad_num = grid->width * grid->height;
                int triangle_num = quad_num * 2;
                int vert_num = quad_num * 4; // Can't share vertices because each vert has different UVs 
                vb->reserve( vert_num);
                ib->reserve( triangle_num*3 );
                grid->mesh->setVertexBuffer(vb);
                grid->mesh->setIndexBuffer(ib);
                grid->mesh->setPrimType( GL_TRIANGLES );

                grid->uv_changed = true;
                grid->color_changed = true;
            }

            if( grid->uv_changed || grid->color_changed ) {
                if(grid->debug) {
                    print("debug:%d Grid changed: uv:%d col:%d", grid->debug, grid->uv_changed, grid->color_changed );
                }
                grid->uv_changed = false;
                grid->color_changed = false;
                
                VertexBuffer *vb = grid->mesh->vb;
                IndexBuffer *ib = grid->mesh->ib;
                vb->unbless();
                ib->unbless();

                int quad_cnt=0;
                for(int y=0;y<grid->height;y++) {
                    for(int x=0;x<grid->width;x++) {
                        int ind = x+y*grid->width;
                        if(grid->debug) {
                            if(grid->texofs_table) {
                                prt("%.2f,%.2f ", grid->texofs_table[ind].x, grid->texofs_table[ind].y );
                            } else if( grid->index_table ) {
                                prt("%3d ", grid->index_table[ind] );
                            }
                        }
                        if( grid->index_table[ind] == Grid::GRID_NOT_USED ) continue;
                        
                        
                        Vec2 left_bottom, right_top;
                        float u0,v0,u1,v1;
//.........这里部分代码省略.........
开发者ID:kengonakajima,项目名称:moyai,代码行数:101,代码来源:Prop2D.cpp

示例14: ccnl_lambdaStrToTerm

struct ccnl_lambdaTerm_s*
ccnl_lambdaStrToTerm(int lev, char **cp, int (*prt)(char* fmt, ...))
{
/* t = (v, m, n)

   var:     v!=0, m=0, n=0
   app:     v=0, m=f, n=arg
   lambda:  v!=0, m=body, n=0
 */
    struct ccnl_lambdaTerm_s *t = 0, *s, *u;

    while (**cp) {
        while (isspace(**cp))
            *cp += 1;

    //  myprintf(stderr, "parseKRIVINE %d %s\n", lev, *cp);

        if (**cp == ')')
            return t;
        if (**cp == '(') {
            *cp += 1;
            s = ccnl_lambdaStrToTerm(lev+1, cp, prt);
            if (!s)
                return 0;
            if (**cp != ')') {
                if (prt) {
                    prt("parseKRIVINE error: missing )\n");
                }
                return 0;
            } else {
                *cp += 1;
            }
        } else if (**cp == LAMBDACHAR) {
            *cp += 1;
            s = ccnl_calloc(1, sizeof(*s));
            s->v = ccnl_lambdaParseVar(cp);
            s->m = ccnl_lambdaStrToTerm(lev+1, cp, prt);
    //      printKRIVINE(dummybuf, s->m, 0);
    //      printf("  after lambda: /%s %s --> <%s>\n", s->v, dummybuf, *cp);
        } else {
            s = ccnl_calloc(1, sizeof(*s));
            s->v = ccnl_lambdaParseVar(cp);
    //      printf("  var: <%s>\n", s->v);
        }
        if (t) {
    //      printKRIVINE(dummybuf, t, 0);
    //      printf("  old term: <%s>\n", dummybuf);
            u = ccnl_calloc(1, sizeof(*u));
            u->m = t;
            u->n = s;
            t = u;
        } else {
            t = s;
        }
//  printKRIVINE(dummybuf, t, 0);
//  printf("  new term: <%s>\n", dummybuf);
    }
//    printKRIVINE(dummybuf, t, 0);
//    printf("  we return <%s>\n", dummybuf);
    return t;
}
开发者ID:DimaMansour,项目名称:ccn-lite,代码行数:61,代码来源:ccnl-ext-nfnparse.c

示例15: wiz_create_itemtype

/*
 * Specify tval and sval (type and subtype of object) originally
 * by RAK, heavily modified by -Bernd-
 *
 * This function returns the k_idx of an object type, or zero if failed
 *
 * List up to 50 choices in three columns
 */
static int wiz_create_itemtype(void)
{
	int i, num, max_num;
	int col, row;
	int tval;

	cptr tval_desc;
	char ch;

	int choice[80];

	char buf[160];


	/* Clear screen */
	Term_clear();

	/* Print all tval's and their descriptions */
	for (num = 0; (num < 80) && tvals[num].tval; num++)
	{
		row = 2 + (num % 20);
		col = 20 * (num / 20);
		ch = listsym[num];
		prt(format("[%c] %s", ch, tvals[num].desc), row, col);
	}

	/* Me need to know the maximal possible tval_index */
	max_num = num;

	/* Choose! */
	if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);

	/* Analyze choice */
	for (num = 0; num < max_num; num++)
	{
		if (listsym[num] == ch) break;
	}

	/* Bail out if choice is illegal */
	if ((num < 0) || (num >= max_num)) return (0);

	/* Base object type chosen, fill in tval */
	tval = tvals[num].tval;
	tval_desc = tvals[num].desc;


	/*** And now we go for k_idx ***/

	/* Clear screen */
	Term_clear();

	/* We have to search the whole itemlist. */
	for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
	{
		object_kind *k_ptr = &k_info[i];

		/* Analyze matching items */
		if (k_ptr->tval == tval)
		{
			/* Prepare it */
			row = 2 + (num % 20);
			col = 20 * (num / 20);
			ch = listsym[num];
			strcpy(buf,"                    ");

			/* Acquire the "name" of object "i" */
			strip_name(buf, i);

			/* Print it */
			prt(format("[%c] %s", ch, buf), row, col);

			/* Remember the object index */
			choice[num++] = i;
		}
	}

	/* Me need to know the maximal possible remembered object_index */
	max_num = num;

	/* Choose! */
	if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);

	/* Analyze choice */
	for (num = 0; num < max_num; num++)
	{
		if (listsym[num] == ch) break;
	}

	/* Bail out if choice is "illegal" */
	if ((num < 0) || (num >= max_num)) return (0);

	/* And return successful */
//.........这里部分代码省略.........
开发者ID:shimitei,项目名称:hengband-cocoa,代码行数:101,代码来源:wizard2.c


注:本文中的prt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。