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


C++ pr函数代码示例

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


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

示例1: payo

int
payo(void)
{
    struct sctstr sect;
    int nships;
    struct nstr_item ni;
    struct shpstr ship;
    struct mchrstr *mp;
    int dist;
    float cash = 0.0;

    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
	return RET_SYN;

    nships = 0;
    while (nxtitem(&ni, &ship)) {
	if (!player->owner || ship.shp_own == 0)
	    continue;
	mp = &mchr[(int)ship.shp_type];

	if (!(mp->m_flags & M_TRADE))
	    continue;

	if (nships++ == 0) {
	    if (player->god)
		pr("own ");
	    pr("shp#     ship type  orig x,y       x,y    dist $$\n");
	}
	if (player->god)
	    pr("%3d ", ship.shp_own);
	pr("%4d ", ni.cur);
	pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
	if (ship.shp_own != ship.shp_orig_own && !player->god) {
	    /* Don't disclose construction site to pirates! */
	    pr("    ?     ");
	    prxy("%4d,%-4d ", ship.shp_x, ship.shp_y);
	    pr("   ? $  ?\n");
	    continue;
	}
	prxy("%4d,%-4d ", ship.shp_orig_x, ship.shp_orig_y);
	prxy("%4d,%-4d ", ship.shp_x, ship.shp_y);

	getsect(ship.shp_x, ship.shp_y, &sect);

	dist = mapdist(ship.shp_x, ship.shp_y,
		       ship.shp_orig_x, ship.shp_orig_y);
	pr("%4d ", dist);

	if (dist < trade_1_dist)
	    cash = 0;
	else if (dist < trade_2_dist)
	    cash = 1.0 + trade_1 * dist;
	else if (dist < trade_3_dist)
	    cash = 1.0 + trade_2 * dist;
	else
	    cash = 1.0 + trade_3 * dist;

	cash *= mp->m_cost;
	cash *= ship.shp_effic / 100.0;

	if (sect.sct_own && (sect.sct_own != ship.shp_own))
	    cash *= (1.0 + trade_ally_bonus);
	pr("$%6.2f\n", cash);
    }
    if (nships == 0) {
	if (player->argp[1])
	    pr("%s: No ship(s)\n", player->argp[1]);
	else
	    pr("%s: No ship(s)\n", "");
	return RET_FAIL;
    } else
	pr("%d ship%s\n", nships, splur(nships));
    return RET_OK;
}
开发者ID:fstltna,项目名称:empserver,代码行数:74,代码来源:payo.c

示例2: pr

void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed,
	v3s16 nmin, v3s16 nmax, u8 *biomemap)
{
	PcgRandom pr(blockseed + 2404);
	MapNode n_ore(c_ore, 0, ore_param2);

	u32 sizex  = (nmax.X - nmin.X + 1);
	u32 volume = (nmax.X - nmin.X + 1) *
				 (nmax.Y - nmin.Y + 1) *
				 (nmax.Z - nmin.Z + 1);
	u32 csize  = clust_size;
	u32 nblobs = volume / clust_scarcity;

	if (!noise)
		noise = new Noise(&np, mapseed, csize, csize, csize);

	for (u32 i = 0; i != nblobs; i++) {
		int x0 = pr.range(nmin.X, nmax.X - csize + 1);
		int y0 = pr.range(nmin.Y, nmax.Y - csize + 1);
		int z0 = pr.range(nmin.Z, nmax.Z - csize + 1);

		if (biomemap && !biomes.empty()) {
			u32 bmapidx = sizex * (z0 - nmin.Z) + (x0 - nmin.X);
			std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[bmapidx]);
			if (it == biomes.end())
				continue;
		}

		bool noise_generated = false;
		noise->seed = blockseed + i;

		size_t index = 0;
		for (u32 z1 = 0; z1 != csize; z1++)
		for (u32 y1 = 0; y1 != csize; y1++)
		for (u32 x1 = 0; x1 != csize; x1++, index++) {
			u32 i = vm->m_area.index(x0 + x1, y0 + y1, z0 + z1);
			if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
				continue;

			// Lazily generate noise only if there's a chance of ore being placed
			// This simple optimization makes calls 6x faster on average
			if (!noise_generated) {
				noise_generated = true;
				noise->perlinMap3D(x0, y0, z0);
			}

			float noiseval = noise->result[index];

			float xdist = (s32)x1 - (s32)csize / 2;
			float ydist = (s32)y1 - (s32)csize / 2;
			float zdist = (s32)z1 - (s32)csize / 2;

			noiseval -= (sqrt(xdist * xdist + ydist * ydist + zdist * zdist) / csize);

			if (noiseval < nthresh)
				continue;

			vm->m_data[i] = n_ore;
		}
	}
}
开发者ID:EXio4,项目名称:minetest,代码行数:61,代码来源:mg_ore.cpp

示例3: write_format

void write_format(FILE* fd) {
    pr("BINARY\n"); /* ASCII, BINARY */
}
开发者ID:uDeviceX,项目名称:uDeviceX,代码行数:3,代码来源:ply2pbc0.c

示例4: pr

bool GodotSharpBuilds::make_api_sln(GodotSharpBuilds::APIType p_api_type) {

	String api_name = p_api_type == API_CORE ? API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
	String api_build_config = "Release";

	EditorProgress pr("mono_build_release_" + api_name, "Building " + api_name + " solution...", 4);

	pr.step("Generating " + api_name + " solution");

	uint64_t core_hash = GDMono::get_singleton()->get_api_core_hash();
	uint64_t editor_hash = GDMono::get_singleton()->get_api_editor_hash();

	String core_api_sln_dir = GodotSharpDirs::get_mono_solutions_dir().plus_file(API_ASSEMBLY_NAME "_" + itos(core_hash));
	String editor_api_sln_dir = GodotSharpDirs::get_mono_solutions_dir().plus_file(EDITOR_API_ASSEMBLY_NAME "_" + itos(editor_hash));

	String api_sln_dir = p_api_type == API_CORE ? core_api_sln_dir : editor_api_sln_dir;
	String api_sln_file = api_sln_dir.plus_file(api_name + ".sln");

	if (!DirAccess::exists(api_sln_dir) || !FileAccess::exists(api_sln_file)) {
		String core_api_assembly;

		if (p_api_type == API_EDITOR) {
			core_api_assembly = core_api_sln_dir.plus_file("bin")
										.plus_file(api_build_config)
										.plus_file(API_ASSEMBLY_NAME ".dll");
		}

#ifndef DEBUG_METHODS_ENABLED
#error "How am I supposed to generate the bindings?"
#endif

		BindingsGenerator &gen = BindingsGenerator::get_singleton();
		bool gen_verbose = OS::get_singleton()->is_stdout_verbose();

		Error err = p_api_type == API_CORE ?
							gen.generate_cs_core_project(api_sln_dir, gen_verbose) :
							gen.generate_cs_editor_project(api_sln_dir, core_api_assembly, gen_verbose);

		if (err != OK) {
			show_build_error_dialog("Failed to generate " + api_name + " solution. Error: " + itos(err));
			return false;
		}
	}

	pr.step("Building " + api_name + " solution");

	if (!GodotSharpBuilds::build_api_sln(api_name, api_sln_dir, api_build_config))
		return false;

	pr.step("Copying " + api_name + " assembly");

	String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();

	// Create assemblies directory if needed
	if (!DirAccess::exists(res_assemblies_dir)) {
		DirAccess *da = DirAccess::create_for_path(res_assemblies_dir);
		Error err = da->make_dir_recursive(res_assemblies_dir);
		memdelete(da);

		if (err != OK) {
			show_build_error_dialog("Failed to create assemblies directory. Error: " + itos(err));
			return false;
		}
	}

	// Copy the built assembly to the assemblies directory
	String api_assembly_dir = api_sln_dir.plus_file("bin").plus_file(api_build_config);
	if (!GodotSharpBuilds::copy_api_assembly(api_assembly_dir, res_assemblies_dir, api_name))
		return false;

	pr.step("Done");

	return true;
}
开发者ID:sutao80216,项目名称:godot,代码行数:74,代码来源:godotsharp_builds.cpp

示例5: OpenHistoricConnections

//
// return true on success else false
//
bool OpenHistoricConnections()	// open the connections with the historical server
{
	IT_IT("OpenHistoricConnections");

	bool res = true;  
	QString DbUserName;
	QString DbPassword;
			
	QString ini_file = GetScadaHomeDirectory() + "\\bin\\historicdb.ini";
	Inifile iniFile((const char*)ini_file);
	
	if( iniFile.find("user","sqlserver") &&
		iniFile.find("password","sqlserver") )
	{
		DbUserName = iniFile.find("user","sqlserver");
		DbPassword = iniFile.find("password","sqlserver");
	}
	else
	{
		res = false;
	}

	char buff[INIFILE_MAX_LINELEN+2];
	char* token;
	char seps[]   = " ,\t\n";

	bool is_low_freq = true;

	//open connection with databases
	if(iniFile.find("online","databases"))
	{
		strcpy(buff, iniFile.find("online","databases"));
				
		token = strtok( buff, seps );
								
		for(int i = 0; token != NULL ;i++)
		{
			if( iniFile.find("address",token) && 
				iniFile.find("port",token) &&
				iniFile.find("is_low_freq",token) )
			{
				QString host = QString(iniFile.find("address",token)) + ":" + QString(iniFile.find("port",token));

				QString dbname = token;

				HistoricDbDict::value_type pr(dbname,new HISTORIC_DB());
				databases.insert(pr); // put in the dictionary

				if(!strcmp("1",iniFile.find("is_low_freq",token)))
				{
					is_low_freq =  true;
				}
				else
				{
					is_low_freq =  false;				
				}

				HistoricDbDict::iterator j =  databases.find(token);

				if(!(j == databases.end()))
				{
					res &= (*j).second->Connect (host, dbname, DbUserName, DbPassword, is_low_freq);
				}
				else
				{
					res = false;
				}
			}
			else
			{
				res = false;
			}
			
			token = strtok( NULL, seps );
		}
	}
	else
	{
		res = false;
	}

	if(res == false)
	{
		for(HistoricDbDict::iterator it = databases.begin(); it != databases.end(); it++)
		{
			(*it).second->Disconnect();
			delete ((*it).second);

			databases.erase(it);
		}
	}

	return res;
};
开发者ID:jiajw0426,项目名称:easyscada,代码行数:97,代码来源:historicdb.cpp

示例6: write_file_version

void write_file_version(FILE* fd) {
    pr("# vtk DataFile Version 2.0\n");
}
开发者ID:uDeviceX,项目名称:uDeviceX,代码行数:3,代码来源:ply2pbc0.c

示例7: pr

void Help::Print_Help(){
	String a = Serial.readStringUntil(',');
	//vergleiche alle Eingaben mit den jeweiligen Moduleinträgen
	
	#define pr XSERIAL.println
	
	if(a == "?"){
		pr("----------------------------------- Help -----------------------------------\n");
		pr("If you want to enter a command over the Serial Input, ");
		pr("you simply have to enter the numbers in the following order:");
		pr("\n  ID, MODULE, FUNCION, PARAMETER1, ..., PARAMETERN");
		pr("\nWhere ID stands for the Component you want to give the command to,");
		pr("Module stands for the module you want to use,");
		pr("Functions stands for the function you want to use in cunjunction");
		pr("with the module,");
		pr("and PARAMETER1 - N are all the parameter one needs for the given function.");
		
		pr("\nIf you need more specific help for a certain module, you need to type in:");
		pr("\n  ? + M");
		pr("\nWhere M stands for either the module name or -number");
		pr("For example: ?LED01 or ?30 will give you more specific information on");
		pr("how to use the LED module and which IDs correspond to which LEDs.");
		pr("This also tells you whether the module is even active or not.");
		
		pr("\nIf you need a reminder on which modules there even are, simply type:");
		pr("?Module");
	}
	else if (a == "?Module"){
		pr("-------------------------------- Modules --------------------------------\n");
		pr("");
		#ifdef ColorView_Module
			pr("ColorView : CV01 or 10");
		#endif
		#ifdef PingEcho_Module
			pr("Ping Echo 2 : PE02  or 21");
		#endif
		#ifdef LED_Module
			pr("LED         : LED01 or 30");
		#endif
		#ifdef Relay_Module
			pr("Relay       : REL01 or 40");
		#endif
		#ifdef Motor_Module
			pr("Motor       : MM01  or 50");
		#endif
		#ifdef Button_Module
			pr("Button      : DR01  or 60");
		#endif
		#ifdef Lightsensor_Module
			pr("Lightsensor : LS01  or 70");
		#endif
		#ifdef RFID_Module
			pr("RFID        : RF01  or 80");
		#endif
		#ifdef Theft_Module
			pr("LED-Strip   : TD01  or 85");
		#endif
		#ifdef Stripe_Module
			pr("LED-Strip   : IR01  or 90");
		#endif
	}			
	else if (a == "?CV01" || a == "?10"){
		pr("spezifische Hilfe");
	}
	else if (a == "?PE02" || a == "?21"){
		pr("spezifische Hilfe");
	}
	else if (a == "?LED01" || a == "?30"){
		pr("spezifische Hilfe");
	}
	else if (a == "?REL01" || a == "?40"){
		pr("spezifische Hilfe");
	}
	else if (a == "?MM01" || a == "?50"){
		pr("spezifische Hilfe");
	}
	else if (a == "?DR01" || a == "?60"){
		pr("spezifische Hilfe");
	}
	else if (a == "?LS01" || a == "?70"){
		pr("spezifische Hilfe");
	}
	else if (a == "?RF01" || a == "?80"){
		pr("spezifische Hilfe");
	}
	else if (a == "?IR01" || a == "?90"){
		pr("spezifische Hilfe");
	}
	else if (a == "?TD01" || a == "?85"){
		pr("spezifische Hilfe");
	}
	
	#undef pr
}
开发者ID:Spirent-TestingTechnologies,项目名称:PlayITS-2016,代码行数:94,代码来源:PhyIOHelp.cpp

示例8: setXPathNS

void TXFMXPath::evaluateExpr(DOMNode *h, safeBuffer inexpr) {

	// Temporarily add any necessary name spaces into the document

	XSECXPathNodeList addedNodes;
	setXPathNS(document, XPathAtts, addedNodes, formatter, mp_nse);

	XPathProcessorImpl	xppi;					// The processor
	XercesParserLiaison xpl;
#if XALAN_VERSION_MAJOR == 1 && XALAN_VERSION_MINOR > 10
	XercesDOMSupport	xds(xpl);
#else
	XercesDOMSupport	xds;
#endif
	XPathEvaluator		xpe;
	XPathFactoryDefault xpf;
	XPathConstructionContextDefault xpcc;

	XalanDocument		* xd;
	XalanNode			* contextNode;

	// Xalan can throw exceptions in all functions, so do one broad catch point.

	try {
	
		// Map to Xalan
		xd = xpl.createDocument(document);

		// For performing mapping
		XercesDocumentWrapper *xdw = xpl.mapDocumentToWrapper(xd);
		XercesWrapperNavigator xwn(xdw);

		// Map the "here" node - but only if part of current document

		XalanNode * hereNode = NULL;

		if (h->getOwnerDocument() == document) {
			
			hereNode = xwn.mapNode(h);

			if (hereNode == NULL) {

				hereNode = findHereNodeFromXalan(&xwn, xd, h);

				if (hereNode == NULL) {

					throw XSECException(XSECException::XPathError,
					   "Unable to find here node in Xalan Wrapper map");
				}

			}
		}

		// Now work out what we have to set up in the new processing

		TXFMBase::nodeType inputType = input->getNodeType();

		XalanDOMString cd;		// For the moment assume the root is the context

		const XalanDOMChar * cexpr;

		safeBuffer contextExpr;

		switch (inputType) {

		case DOM_NODE_DOCUMENT :
		case DOM_NODE_XPATH_NODESET :
			// do XPath over the whole document and, if the input was an 
			// XPath Nodeset, then later intersect the result with the input nodelist			
			cd = XalanDOMString("/");		// Root node
			cexpr = cd.c_str();

			// The context node is the "root" node
			contextNode =
				xpe.selectSingleNode(
				xds,
				xd,
				cexpr,
				xd->getDocumentElement());

			break;

		case DOM_NODE_DOCUMENT_FRAGMENT :
			{

				// Need to map the DOM_Node that we are given from the input to the appropriate XalanNode

				// Create the XPath expression to find the node

				if (input->getFragmentId() != NULL) {

					contextExpr.sbTranscodeIn("//descendant-or-self::node()[attribute::Id='");
					contextExpr.sbXMLChCat(input->getFragmentId());
					contextExpr.sbXMLChCat("']");

					// Map the node

					contextNode = 
						xpe.selectSingleNode(
						xds,
//.........这里部分代码省略.........
开发者ID:okean,项目名称:cpputils,代码行数:101,代码来源:TXFMXPath.cpp

示例9: scra

int
scra(void)
{
    struct nstr_item ni;
    union empobj_storage item;
    int type, n;
    struct sctstr sect;
    struct mchrstr *mp;
    struct plchrstr *pp;
    struct lchrstr *lp;
    char *p;
    i_type i;
    char prompt[128];
    char buf[1024];
    float eff;
    short *mvec;
    int amt;

    if (!(p = getstarg(player->argp[1], "Ship, land, or plane? ", buf)))
	return RET_SYN;
    switch (*p) {
    case 's':
	type = EF_SHIP;
	break;
    case 'p':
	type = EF_PLANE;
	break;
    case 'l':
	type = EF_LAND;
	break;
    default:
	pr("Ships, land units, or planes only! (s, l, p)\n");
	return RET_SYN;
    }

    if (!snxtitem(&ni, type, player->argp[2], NULL))
	return RET_SYN;
    n = 0;
    while (nxtitem(&ni, &item)) {
	if (!player->owner)
	    continue;
	n++;
    }
    snprintf(prompt, sizeof(prompt), "Really scrap %d %s%s [n]? ",
			    n, ef_nameof(type), splur(n));
    if (!confirm(prompt))
	return RET_FAIL;

    snxtitem_rewind(&ni);
    while (nxtitem(&ni, &item)) {
	if (!player->owner)
	    continue;

	if (opt_MARKET) {
	    if (ontradingblock(type, &item.ship)) {
		pr("You cannot scrap an item on the trading block!\n");
		continue;
	    }
	}

	getsect(item.gen.x, item.gen.y, &sect);
	if (type == EF_SHIP) {
	    if (!player->owner
		&& relations_with(sect.sct_own, player->cnum) < FRIENDLY) {
		pr("%s is not in a friendly harbor!\n",
		   prship(&item.ship));
		continue;
	    }
	    if (sect.sct_type != SCT_HARBR || sect.sct_effic < 60) {
		pr("%s is not in a 60%% efficient harbor!\n",
		   prship(&item.ship));
		continue;
	    }
	    if (mchr[item.ship.shp_type].m_flags & M_TRADE) {
		pr("WARNING: You only collect money from trade ships if you \"scuttle\" them!\n");
		sprintf(prompt,
			"Are you really sure that you want to scrap %s (n)? ",
			prship(&item.ship));
		if (!confirm(prompt)) {
		    pr("%s not scrapped\n", prship(&item.ship));
		    continue;
		}
	    }
	} else {
	    if (!player->owner
		&& relations_with(sect.sct_own, player->cnum) != ALLIED) {
		pr("%s is not in an allied sector!\n",
		   unit_nameof(&item.gen));
		continue;
	    }
	    if (type == EF_PLANE
		&& (sect.sct_type != SCT_AIRPT || sect.sct_effic < 60)) {
		pr("%s is not in a 60%% efficient airfield!\n",
		   prplane(&item.plane));
		continue;
	    }
	}

	pr("%s scrapped in %s\n",
	   unit_nameof(&item.gen),
//.........这里部分代码省略.........
开发者ID:gefla,项目名称:empserver,代码行数:101,代码来源:scra.c

示例10: dispatch

/*
 * Execute command named by player->argp[0].
 * BUF is the raw UTF-8 command line.  It should have been passed to
 * parse() to set up player->argp.
 * If REDIR is not null, it's the command's redirection, in UTF-8.
 * Return -1 if the command is not unique or doesn't exist, else 0.
 */
int
dispatch(char *buf, char *redir)
{
    struct natstr *np;
    struct cmndstr *command;
    int cmd;

    cmd = comtch(player->argp[0], player_coms, player->nstat);
    if (cmd < 0) {
	if (cmd == M_NOTUNIQUE)
	    pr("Command \"%s\" is ambiguous -- ", player->argp[0]);
	else if (cmd == M_IGNORE)
	    return 0;
	else
	    pr("\"%s\" is not a legal command\n", player->argp[0]);
	return -1;
    }
    command = &player_coms[cmd];
    np = getnatp(player->cnum);
    if (np->nat_btu < command->c_cost && command->c_cost > 0) {
	if (player->god || opt_BLITZ)
	    np->nat_btu = max_btus;
	else {
	    pr("You don't have the BTU's, bozo\n");
	    return 0;
	}
    }
    if (!command->c_addr) {
	pr("Command not implemented\n");
	return 0;
    }
    player->may_sleep = command->c_flags & C_MOD
	? PLAYER_SLEEP_ON_INPUT : PLAYER_SLEEP_FREELY;
    player->command = command;
    empth_rwlock_rdlock(update_lock);
    if (redir) {
	prredir(redir);
	uprnf(buf);
	pr("\n");
    }
    journal_command(command->c_form);
    switch (command->c_addr()) {
    case RET_OK:
	player->btused += command->c_cost;
	break;
    case RET_FAIL:
	pr("command failed\n");
	player->btused += command->c_cost;
	break;
    case RET_SYN:
	pr("Usage: %s\n", command->c_form);
	break;
    default:
	CANT_REACH();
	break;
    }
    empth_rwlock_unlock(update_lock);
    player->command = NULL;
    if (player->may_sleep != PLAYER_SLEEP_NEVER || !io_eof(player->iop))
	player->may_sleep = PLAYER_SLEEP_FREELY;
    /* else we're being kicked out */
    return 0;
}
开发者ID:fstltna,项目名称:empserver,代码行数:70,代码来源:dispatch.c

示例11: set

/*
 * format: set <type> <SHIP/NUKE> <PRICE>
 */
int
set(void)
{
    static int ef_saleable[] = { EF_SHIP, EF_PLANE, EF_LAND, EF_NUKE, EF_BAD };
    char *p;
    int type;
    int price;
    char prompt[80];
    struct trdstr trade;
    struct nstr_item ni;
    struct nstr_item ni_trade;
    union empobj_storage item;
    struct sctstr sect;
    int freeslot;
    int foundslot;
    int id;
    time_t now;
    char buf[1024];

    if (!opt_MARKET) {
	pr("The market is disabled.\n");
	return RET_FAIL;
    }
    check_market();
    check_trade();

    p = getstarg(player->argp[1], "Ship, plane, land unit or nuke? ", buf);
    if (!p)
	return RET_SYN;
    if ((type = ef_byname_from(p, ef_saleable)) < 0) {
	pr("You can sell only ships, planes, land units or nukes\n");
	return RET_SYN;
    }
    if (!snxtitem(&ni, type, player->argp[2], NULL))
	return RET_SYN;
    while (nxtitem(&ni, &item)) {
	if (!player->owner && !player->god)
	    continue;
	getsect(item.gen.x, item.gen.y, &sect);
	if (!military_control(&sect)) {
	    pr("Military control required to sell goods.\n");
	    return RET_FAIL;
	}
	trade.trd_type = type;
	sprintf(prompt, "%s #%d; price? ",
		trade_nameof(&trade, &item.gen), ni.cur);
	if (!(p = getstarg(player->argp[3], prompt, buf)))
	    return RET_FAIL;
	if (!check_obj_ok(&item.gen))
	    return RET_FAIL;
	if ((price = atoi(p)) < 0)
	    continue;
	foundslot = -1;
	freeslot = -1;
	snxtitem_all(&ni_trade, EF_TRADE);
	while (nxtitem(&ni_trade, &trade)) {
	    if (trade.trd_owner == 0)
		freeslot = ni_trade.cur;
	    if (trade.trd_unitid == ni.cur && trade.trd_type == type) {
		foundslot = ni_trade.cur;
		break;
	    }
	}
	if (price <= 0) {
	    if (foundslot >= 0) {
		pr("%s #%d (lot #%d) removed from trading\n",
		   trade_nameof(&trade, &item.gen), ni.cur, foundslot);
		trade.trd_owner = 0;
		puttrade(ni_trade.cur, &trade);
	    }
	} else {
	    if (trade_has_unsalable_cargo(&item.gen, 1))
		return RET_FAIL;
	    if (foundslot >= 0)
		id = foundslot;
	    else if (freeslot >= 0)
		id = freeslot;
	    else
		id = ni_trade.cur;
	    ef_blank(EF_TRADE, id, &trade);
	    trade.trd_x = 1;
	    trade.trd_y = 0;
	    trade.trd_type = type;
	    trade.trd_owner = player->cnum;
	    trade.trd_unitid = ni.cur;
	    trade.trd_price = price;
	    (void)time(&now);
	    trade.trd_markettime = now;
	    trade.trd_maxbidder = player->cnum;
	    puttrade(id, &trade);
	    pr("%s #%d (lot #%d) price %s to $%d\n",
	       trade_nameof(&trade, &item.gen), ni.cur,
	       id, foundslot >= 0 ? "reset" : "set", price);
	}
    }
    return RET_OK;
}
开发者ID:gefla,项目名称:empserver,代码行数:100,代码来源:set.c

示例12: pr

void expr_replacer::operator()(expr * t, expr_ref & result) {
    proof_ref pr(m());
    operator()(t, result, pr);
}
开发者ID:jackluo923,项目名称:juxta,代码行数:4,代码来源:expr_replacer.cpp

示例13: upda

/*
 * Tell what the update policy is, and when the next update
 * is likely to be.
 */
int
upda(void)
{
    time_t now, next, stop;

    if (updates_disabled())
	pr("UPDATES ARE DISABLED!\n");

    (void)time(&now);
    next = update_time[0];
    if (next) {
	pr("\nUpdates occur at times specified by the ETU rates.\n\n");
	pr("The next update is at %19.19s.\n", ctime(&next));
    } else {
	pr("There are no regularly scheduled updates.\n");
    }
    pr("The current time is   %19.19s.\n\n", ctime(&now));

    if (next && update_window) {
	pr("The next update window starts at %19.19s.\n", ctime(&next));
	stop = next + update_window;
	pr("The next update window stops at %19.19s.\n", ctime(&stop));
    }

    switch (update_demand) {
    case UPD_DEMAND_NONE:
    default:
	break;
    case UPD_DEMAND_SCHED:
	pr("Demand updates occur at update CHECK times.\n");
	if (next) {
	    pr("The next update check is at %19.19s.\n", ctime(&next));
	}
	pr("Demand updates require %d country(s) to want one.\n",
	   update_wantmin);
	break;
    case UPD_DEMAND_ASYNC:
	pr("Demand updates occur right after the demand is set.\n");
	if (*update_demandtimes != 0) {
	    pr("Demand updates are allowed during: %s\n",
	       update_demandtimes);
	}
	pr("Demand updates require %d country(s) to want one.\n",
	   update_wantmin);
    }

    if (*game_days != 0)
	pr("Game days are: %s\n", game_days);
    if (*game_hours != 0)
	pr("Game hours are: %s\n", game_hours);

    pr("\nThis command is obsolete and will go away in a future version.\n"
       "Please use \"show updates\".\n");
    return 0;
}
开发者ID:gefla,项目名称:empserver,代码行数:59,代码来源:upda.c

示例14: emit_term

static void emit_term(cql_transform_t ct,
                      struct cql_node *cn,
                      const char *term, int length,
                      void (*pr)(const char *buf, void *client_data),
                      void *client_data)
{
    int i;
    const char *ns = cn->u.st.index_uri;
    int z3958_mode = 0;
    int process_term = 1;

    if (has_modifier(cn, "regexp"))
        process_term = 0;
    else if (cql_lookup_property(ct, "truncation", 0, "cql"))
    {
        process_term = 0;
        cql_pr_attr(ct, "truncation", "cql", 0,
                    pr, client_data, YAZ_SRW_MASKING_CHAR_UNSUPP);
    }
    assert(cn->which == CQL_NODE_ST);

    if (process_term)
    {
        unsigned anchor = 0;
        unsigned trunc = 0;
        for (i = 0; i < length; i++)
        {
            if (term[i] == '\\' && i < length - 1)
                i++;
            else
            {
                switch (term[i])
                {
                case '^':
                    if (i == 0)
                        anchor |= 1;
                    else if (i == length - 1)
                        anchor |= 2;
                    break;
                case '*':
                    if (i == 0)
                        trunc |= 1;
                    else if (i == length - 1)
                        trunc |= 2;
                    else
                        z3958_mode = 1;
                    break;
                case '?':
                    z3958_mode = 1;
                    break;
                }
            }
        }
        if (anchor == 3)
        {
            cql_pr_attr(ct, "position", "firstAndLast", 0,
                        pr, client_data, YAZ_SRW_ANCHORING_CHAR_IN_UNSUPP_POSITION);
            term++;
            length -= 2;
        }
        else if (anchor == 1)
        {
            cql_pr_attr(ct, "position", "first", 0,
                        pr, client_data, YAZ_SRW_ANCHORING_CHAR_IN_UNSUPP_POSITION);
            term++;
            length--;
        }
        else if (anchor == 2)
        {
            cql_pr_attr(ct, "position", "last", 0,
                        pr, client_data, YAZ_SRW_ANCHORING_CHAR_IN_UNSUPP_POSITION);
            length--;
        }
        else
        {
            cql_pr_attr(ct, "position", "any", 0,
                        pr, client_data, YAZ_SRW_ANCHORING_CHAR_IN_UNSUPP_POSITION);
        }
        if (z3958_mode == 0)
        {
            if (trunc == 3 && cql_pr_attr(ct, "truncation",
                                          "both", 0, pr, client_data, 0))
            {
                term++;
                length -= 2;
            }
            else if (trunc == 1 && cql_pr_attr(ct, "truncation",
                                               "left", 0, pr, client_data, 0))
            {
                term++;
                length--;
            }
            else if (trunc == 2 && cql_pr_attr(ct, "truncation", "right", 0,
                                               pr, client_data, 0))
            {
                length--;
            }
            else if (trunc)
                z3958_mode = 1;
            else
//.........这里部分代码省略.........
开发者ID:nla,项目名称:yaz,代码行数:101,代码来源:cqltransform.c

示例15: show

int
show(void)
{
    char *p;
    void (*cfunc)(int);
    void (*sfunc)(int);
    void (*bfunc)(int);
    struct natstr *natp;
    int tlev;
    char buf[1024];
    int rlev;

again:
    p = getstarg(player->argp[1], "Show what ('?' to list options)? ", buf);
    if (!p || !*p)
	return RET_SYN;
    if (*p == '?') {
	pr("bridge, item, land, news, nuke, plane, sect, ship, product, tower, updates\n");
	goto again;
    }

    natp = getnatp(player->cnum);
    rlev = (int)(1.25 * natp->nat_level[NAT_RLEV]);

    if (!player->argp[3]) {
	tlev = (int)(1.25 * natp->nat_level[NAT_TLEV]);
	if (player->god)
	    tlev = 1000;
    } else {
	tlev = (int)atoi(player->argp[3]);
	if (tlev > (int)(1.25 * natp->nat_level[NAT_TLEV]) && !player->god)
	    tlev = (int)(1.25 * natp->nat_level[NAT_TLEV]);
    }
    if (player->god)
	rlev = 1000;
    switch (*p) {
    case 'b':
	show_bridge(99999);
	return RET_OK;
    case 't':
	show_tower(99999);
	return RET_OK;
    case 'i':
	show_item(99999);
	return RET_OK;
    case 'n':
	if (*(p + 1) == 'e') {
	    show_news(99999);
	    return RET_OK;
	}
	if (drnuke_const > MIN_DRNUKE_CONST)
	    tlev = ((rlev / drnuke_const) > tlev ? tlev :
		    (rlev / drnuke_const));
	bfunc = show_nuke_build;
	cfunc = show_nuke_capab;
	sfunc = show_nuke_stats;
	break;
    case 'l':
	bfunc = show_land_build;
	sfunc = show_land_stats;
	cfunc = show_land_capab;
	break;
    case 'p':
	if (p[1] == 'r') {
	    show_product(99999);
	    return RET_OK;
	}
	bfunc = show_plane_build;
	sfunc = show_plane_stats;
	cfunc = show_plane_capab;
	break;
    case 's':
	if (*(p + 1) == 'e') {
	    bfunc = show_sect_build;
	    sfunc = show_sect_stats;
	    cfunc = show_sect_capab;
	} else {
	    bfunc = show_ship_build;
	    sfunc = show_ship_stats;
	    cfunc = show_ship_capab;
	}
	break;
    case 'u':
	show_updates(player->argp[2] ? atoi(player->argp[2]) : 8);
	return RET_OK;
    default:
	return RET_SYN;
    }

    p = getstarg(player->argp[2],
		 "Build, stats, or capability data (b,s,c)? ", buf);
    if (!p || !*p)
	return RET_SYN;
    pr("Printing for tech level '%d'\n", tlev);
    if (*p == 'B' || *p == 'b')
	bfunc(tlev);
    else if (*p == 'C' || *p == 'c')
	cfunc(tlev);
    else if (*p == 'S' || *p == 's')
	sfunc(tlev);
//.........这里部分代码省略.........
开发者ID:fstltna,项目名称:empserver,代码行数:101,代码来源:show.c


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