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


C++ Com_Print函数代码示例

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


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

示例1: Svc_RemoteCommand

/*
 * @brief A client issued an rcon command. Shift down the remaining args and
 * redirect all output to the invoking client.
 */
static void Svc_RemoteCommand(void) {
	const _Bool auth = Sv_RconAuthenticate();
	const char *addr = Net_NetaddrToString(&net_from);

	// first print to the server console
	if (auth)
		Com_Print("Rcon from %s:\n%s\n", addr, net_message.data + 4);
	else
		Com_Print("Bad rcon from %s:\n%s\n", addr, net_message.data + 4);

	// then redirect the remaining output back to the client
	Com_BeginRedirect(RD_PACKET, sv_outputbuf, SV_OUTPUTBUF_LENGTH, Sv_FlushRedirect);

	if (auth) {
		char remaining[MAX_STRING_CHARS];
		int32_t i;

		remaining[0] = 0;

		for (i = 2; i < Cmd_Argc(); i++) {
			strcat(remaining, Cmd_Argv(i));
			strcat(remaining, " ");
		}

		Cmd_ExecuteString(remaining);
	} else {
		Com_Print("Bad rcon_password\n");
	}

	Com_EndRedirect();
}
开发者ID:jayschwa,项目名称:quake2world,代码行数:35,代码来源:sv_main.c

示例2: Cl_Ping_f

/*
 * Cl_Ping_f
 */
void Cl_Ping_f(void) {
	net_addr_t addr;
	cl_server_info_t *server;

	if (Cmd_Argc() != 2) {
		Com_Print("Usage: %s <address>\n", Cmd_Argv(0));
		return;
	}

	server = NULL;

	if (!Net_StringToNetaddr(Cmd_Argv(1), &addr)) {
		Com_Print("Invalid address\n");
		return;
	}

	if (!addr.port) // use default
		addr.port = (unsigned short) BigShort(PORT_SERVER);

	server = Cl_ServerForNetaddr(&addr);

	if (!server) { // add it
		server = Cl_AddServer(&addr);
		server->source = SERVER_SOURCE_USER;
	}

	server->ping_time = cls.real_time;
	server->ping = 0;

	Com_Print("Pinging %s\n", Net_NetaddrToString(server->addr));

	Netchan_OutOfBandPrint(NS_CLIENT, server->addr, "info %i", PROTOCOL);
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:36,代码来源:cl_server.c

示例3: R_Init

/*
 * @brief Creates the OpenGL context and initializes all GL state.
 */
void R_Init(void) {

	Com_Print("Video initialization...\n");

	R_InitLocal();

	R_InitContext();

	R_InitConfig();

	R_EnforceGlVersion();

	R_InitGlExtensions();

	R_InitState();

	R_InitPrograms();

	R_InitMedia();

	R_InitImages();

	R_InitDraw();

	R_InitModels();

	R_InitView();

	Com_Print(
			"Video initialized %dx%dx%dbpp %s\n",
			r_context.width,
			r_context.height,
			(r_context.red_bits + r_context.green_bits + r_context.blue_bits + r_context.alpha_bits),
			(r_context.fullscreen ? "fullscreen" : "windowed"));
}
开发者ID:devilx4,项目名称:quake2world,代码行数:38,代码来源:r_main.c

示例4: Cl_Record_f

/**
 * @brief record <demo name>
 *
 * Begin recording a demo from the current frame until `stop` is issued.
 */
void Cl_Record_f(void) {

	if (Cmd_Argc() != 2) {
		Com_Print("Usage: %s <demo name>\n", Cmd_Argv(0));
		return;
	}

	if (cls.demo_file) {
		Com_Print("Already recording\n");
		return;
	}

	if (cls.state != CL_ACTIVE) {
		Com_Print("You must be in a level to record\n");
		return;
	}

	g_snprintf(cls.demo_filename, sizeof(cls.demo_filename), "demos/%s.demo", Cmd_Argv(1));

	// open the demo file
	if (!(cls.demo_file = Fs_OpenWrite(cls.demo_filename))) {
		Com_Warn("Couldn't open %s\n", cls.demo_filename);
		return;
	}

	Com_Print("Recording to %s\n", cls.demo_filename);
}
开发者ID:jdolan,项目名称:quetoo,代码行数:32,代码来源:cl_demo.c

示例5: Cl_Bind_f

/*
 * Cl_Bind_f
 */
static void Cl_Bind_f(void) {
	int i, c, b;
	char cmd[1024];

	c = Cmd_Argc();

	if (c < 2) {
		Com_Print("Usage: %s <key> [command] : attach a command to a key\n",
				Cmd_Argv(0));
		return;
	}
	b = Cl_StringToKeyNum(Cmd_Argv(1));
	if (b == -1) {
		Com_Print("\"%s\" isn't a valid key\n", Cmd_Argv(1));
		return;
	}

	if (c == 2) {
		if (ks->binds[b])
			Com_Print("\"%s\" = \"%s\"\n", Cmd_Argv(1), ks->binds[b]);
		else
			Com_Print("\"%s\" is not bound\n", Cmd_Argv(1));
		return;
	}

	// copy the rest of the command line
	cmd[0] = 0; // start out with a null string
	for (i = 2; i < c; i++) {
		strcat(cmd, Cmd_Argv(i));
		if (i != (c - 1))
			strcat(cmd, " ");
	}

	Cl_Bind(b, cmd);
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:38,代码来源:cl_keys.c

示例6: Cl_Record_f

/*
 * Cl_Record_f
 *
 * record <demo name>
 *
 * Begin recording a demo from the current frame until `stop` is issued.
 */
void Cl_Record_f(void) {

	if (Cmd_Argc() != 2) {
		Com_Print("Usage: %s <demo name>\n", Cmd_Argv(0));
		return;
	}

	if (cls.demo_file) {
		Com_Print("Already recording.\n");
		return;
	}

	if (cls.state != CL_ACTIVE) {
		Com_Print("You must be in a level to record.\n");
		return;
	}

	// open the demo file
	snprintf(cls.demo_path, sizeof(cls.demo_path), "%s/demos/%s.dem", Fs_Gamedir(), Cmd_Argv(1));

	Fs_CreatePath(cls.demo_path);
	cls.demo_file = fopen(cls.demo_path, "wb");
	if (!cls.demo_file) {
		Com_Warn("Cl_Record_f: couldn't open %s.\n", cls.demo_path);
		return;
	}

	// don't start saving messages until a non-delta compressed message is received
	cls.demo_waiting = true;

	// update user info var to inform server to send angles
	Cvar_ForceSet("recording", "1");

	Com_Print("Requesting demo support from server...\n");
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:42,代码来源:cl_demo.c

示例7: Ms_AddServer

/*
 * @brief Adds the specified server to the master.
 */
static void Ms_AddServer(struct sockaddr_in *from) {
	struct sockaddr_in addr;

	if (Ms_GetServer(from)) {
		Com_Print("Duplicate ping from %s\n", inet_ntoa(from->sin_addr));
		return;
	}

	if (Ms_BlacklistServer(from)) {
		Com_Print("Server %s has been blacklisted\n", inet_ntoa(from->sin_addr));
		return;
	}

	ms_server_t *server = Z_Malloc(sizeof(*server));

	server->ip = *from;
	server->last_heartbeat = time(0);
	server->port = from->sin_port;

	ms_servers = g_list_prepend(ms_servers, server);
	Com_Print("Server %s registered\n", inet_ntoa(from->sin_addr));

	// send an acknowledgment
	addr.sin_addr = server->ip.sin_addr;
	addr.sin_family = AF_INET;
	addr.sin_port = server->port;
	memset(&addr.sin_zero, 0, sizeof(addr.sin_zero));
	sendto(ms_sock, "\xFF\xFF\xFF\xFF" "ack", 7, 0, (struct sockaddr*) &addr, sizeof(addr));
}
开发者ID:devilx4,项目名称:quake2world,代码行数:32,代码来源:main.c

示例8: CalcVis

/*
 * @brief
 */
static void CalcVis(void) {
	uint32_t i;

	RunThreadsOn(map_vis.num_portals * 2, true, BaseVis);

	SortPortals();

	// fast vis just uses migh_tsee for a very loose bound
	if (fastvis) {
		for (i = 0; i < map_vis.num_portals * 2; i++) {
			map_vis.portals[i].vis = map_vis.portals[i].flood;
			map_vis.portals[i].status = stat_done;
		}
	} else {
		RunThreadsOn(map_vis.num_portals * 2, true, FinalVis);
	}

	// assemble the leaf vis lists by OR-ing and compressing the portal lists
	for (i = 0; i < map_vis.portal_clusters; i++)
		ClusterMerge(i);

	if (map_vis.portal_clusters)
		Com_Print("Average clusters visible: %i\n", visibility_count / map_vis.portal_clusters);
	else
		Com_Print("Average clusters visible: 0\n");
}
开发者ID:jayschwa,项目名称:quake2world,代码行数:29,代码来源:qvis.c

示例9: S_Init

/*
 * S_Init
 */
void S_Init(void) {
	int freq, channels;
	unsigned short format;

	memset(&s_env, 0, sizeof(s_env));

	if (Cvar_GetValue("s_disable")) {
		Com_Warn("Sound disabled.\n");
		return;
	}

	Com_Print("Sound initialization...\n");

	s_rate = Cvar_Get("s_rate", "44100", CVAR_ARCHIVE | CVAR_S_DEVICE,
			"Sound sampling rate in Hz.");
	s_reverse = Cvar_Get("s_reverse", "0", CVAR_ARCHIVE,
			"Reverse left and right channels.");
	s_volume = Cvar_Get("s_volume", "1.0", CVAR_ARCHIVE,
			"Global sound volume level.");

	Cmd_AddCommand("s_restart", S_Restart_f, "Restart the sound subsystem");
	Cmd_AddCommand("s_play", S_Play_f, NULL);
	Cmd_AddCommand("s_stop", S_Stop_f, NULL);
	Cmd_AddCommand("s_list", S_List_f, NULL);

	if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
		if (SDL_Init(SDL_INIT_AUDIO) < 0) {
			Com_Warn("S_Init: %s.\n", SDL_GetError());
			return;
		}
	} else if (SDL_WasInit(SDL_INIT_AUDIO) == 0) {
		if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
			Com_Warn("S_Init: %s.\n", SDL_GetError());
			return;
		}
	}

	if (Mix_OpenAudio(s_rate->integer, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	if (Mix_QuerySpec(&freq, &format, &channels) == 0) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	if (Mix_AllocateChannels(MAX_CHANNELS) != MAX_CHANNELS) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	Mix_ChannelFinished(S_FreeChannel);

	Com_Print("Sound initialized %dKHz %d channels.\n", freq, channels);

	s_env.initialized = true;

	S_InitMusic();
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:63,代码来源:s_main.c

示例10: AAS_Main

/*
 * @brief Generates ${bsp_name}.aas for AI navigation.
 */
int32_t AAS_Main(void) {

	Com_Print("\n----- AAS -----\n\n");

	const time_t start = time(NULL);

	LoadBSPFile(bsp_name);

	if (d_bsp.num_nodes == 0) {
		Com_Error(ERR_FATAL, "No nodes");
	}

	memset(&d_aas, 0, sizeof(d_aas));

	CreateAASNodes();

	PruneAASNodes();

	WriteAASFile();

	const time_t end = time(NULL);
	const time_t duration = end - start;
	Com_Print("\nAAS Time: ");
	if (duration > 59)
		Com_Print("%d Minutes ", (int32_t) (duration / 60));
	Com_Print("%d Seconds\n", (int32_t) (duration % 60));

	return 0;
}
开发者ID:EEmmanuel7,项目名称:quetoo,代码行数:32,代码来源:qaas.c

示例11: Sv_UserInfoChanged

/*
 * Sv_UserInfoChanged
 *
 * Enforces safe user_info data before passing onto game module.
 */
void Sv_UserInfoChanged(sv_client_t *cl) {
	char *val;
	size_t i;

	if (*cl->user_info == '\0') { // catch empty user_info
		Com_Print("Empty user_info from %s\n", Sv_NetaddrToString(cl));
		Sv_KickClient(cl, "Bad user info");
		return;
	}

	if (strchr(cl->user_info, '\xFF')) { // catch end of message exploit
		Com_Print("Illegal user_info contained xFF from %s\n",
				Sv_NetaddrToString(cl));
		Sv_KickClient(cl, "Bad user info");
		return;
	}

	if (!ValidateUserInfo(cl->user_info)) { // catch otherwise invalid user_info
		Com_Print("Invalid user_info from %s\n", Sv_NetaddrToString(cl));
		Sv_KickClient(cl, "Bad user info");
		return;
	}

	val = GetUserInfo(cl->user_info, "skin");
	if (strstr(val, "..")) // catch malformed skins
		SetUserInfo(cl->user_info, "skin", "enforcer/qforcer");

	// call game code to allow overrides
	svs.game->ClientUserInfoChanged(cl->edict, cl->user_info);

	// name for C code, mask off high bit
	strncpy(cl->name, GetUserInfo(cl->user_info, "name"), sizeof(cl->name) - 1);
	for (i = 0; i < sizeof(cl->name); i++) {
		cl->name[i] &= 127;
	}

	// rate command
	val = GetUserInfo(cl->user_info, "rate");
	if (*val != '\0') {
		cl->rate = atoi(val);

		if (cl->rate > CLIENT_RATE_MAX)
			cl->rate = CLIENT_RATE_MAX;
		else if (cl->rate < CLIENT_RATE_MIN)
			cl->rate = CLIENT_RATE_MIN;
	}

	// limit the print messages the client receives
	val = GetUserInfo(cl->user_info, "message_level");
	if (*val != '\0') {
		cl->message_level = atoi(val);
	}

	// start/stop sending view angles for demo recording
	val = GetUserInfo(cl->user_info, "recording");
	cl->recording = atoi(val) == 1;
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:62,代码来源:sv_main.c

示例12: CalcPHS

/*
 * @brief Calculate the PHS (Potentially Hearable Set)
 * by ORing together all the PVS visible from a leaf
 */
static void CalcPHS(void) {
	uint32_t i, j, k, l, index;
	int32_t bitbyte;
	long *dest, *src;
	byte *scan;
	int32_t count;
	byte uncompressed[MAX_BSP_LEAFS / 8];
	byte compressed[MAX_BSP_LEAFS / 8];

	Com_Verbose("Building PHS...\n");

	count = 0;
	for (i = 0; i < map_vis.portal_clusters; i++) {
		scan = map_vis.uncompressed + i * map_vis.leaf_bytes;
		memcpy(uncompressed, scan, map_vis.leaf_bytes);
		for (j = 0; j < map_vis.leaf_bytes; j++) {
			bitbyte = scan[j];
			if (!bitbyte)
				continue;
			for (k = 0; k < 8; k++) {
				if (!(bitbyte & (1 << k)))
					continue;
				// OR this pvs row into the phs
				index = ((j << 3) + k);
				if (index >= map_vis.portal_clusters)
					Com_Error(ERR_FATAL, "Bad bit vector in PVS\n"); // pad bits should be 0
				src = (long *) (map_vis.uncompressed + index * map_vis.leaf_bytes);
				for (l = 0; l < map_vis.leaf_longs; l++)
					((long *) uncompressed)[l] |= src[l];
			}
		}
		for (j = 0; j < map_vis.portal_clusters; j++)
			if (uncompressed[j >> 3] & (1 << (j & 7)))
				count++;

		// compress the bit string
		j = CompressVis(uncompressed, compressed);

		dest = (long *) map_vis.pointer;
		map_vis.pointer += j;

		if (map_vis.pointer > map_vis.end)
			Com_Error(ERR_FATAL, "Overflow\n");

		d_vis->bit_offsets[i][DVIS_PHS] = (byte *) dest - map_vis.base;

		memcpy(dest, compressed, j);
	}

	if (map_vis.portal_clusters)
		Com_Print("Average clusters hearable: %i\n", count / map_vis.portal_clusters);
	else
		Com_Print("Average clusters hearable: 0\n");
}
开发者ID:jayschwa,项目名称:quake2world,代码行数:58,代码来源:qvis.c

示例13: BSP_Main

/*
 * BSP_Main
 */
int BSP_Main(void){
	time_t start, end;
	char base[MAX_OSPATH];
	int total_bsp_time;

	#ifdef _WIN32
		char title[MAX_OSPATH];
		sprintf(title, "Q2WMap [Compiling BSP]");
		SetConsoleTitle(title);
	#endif

	Com_Print("\n----- BSP -----\n\n");

	start = time(NULL);

	StripExtension(map_name, base);

	// clear the whole bsp structure
	memset(&d_bsp, 0, sizeof(d_bsp));

	// delete portal and line files
	remove(va("%s.prt", base));
	remove(va("%s.lin", base));

	// if onlyents, just grab the entities and re-save
	if(onlyents){

		LoadBSPFile(bsp_name);
		num_entities = 0;

		LoadMapFile(map_name);
		SetModelNumbers();

		UnparseEntities();

		WriteBSPFile(bsp_name);
	} else {
		// start from scratch
		LoadMapFile(map_name);
		SetModelNumbers();

		ProcessModels();
	}

	end = time(NULL);
	total_bsp_time = (int)(end - start);
	Com_Print("\nBSP Time: ");
	if(total_bsp_time > 59)
		Com_Print("%d Minutes ", total_bsp_time / 60);
	Com_Print("%d Seconds\n", total_bsp_time % 60);

	return 0;
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:56,代码来源:qbsp.c

示例14: S_ListMedia_f

/*
 * @brief Prints information about all currently loaded media to the console.
 */
void S_ListMedia_f(void) {

	Com_Print("Loaded media:\n");

	GList *key = s_media_state.keys;
	while (key) {
		s_media_t *media = g_hash_table_lookup(s_media_state.media, key->data);

		Com_Print("%s\n", media->name);

		key = key->next;
	}
}
开发者ID:jayschwa,项目名称:quake2world,代码行数:16,代码来源:s_media.c

示例15: Ms_RemoveServer

/*
 * @brief Removes the specified server.
 */
static void Ms_RemoveServer(struct sockaddr_in *from, ms_server_t *server) {

	if (!server) // resolve from address
		server = Ms_GetServer(from);

	if (!server) {
		Com_Print("Shutdown from unregistered server %s\n", inet_ntoa(from->sin_addr));
		return;
	}

	Com_Print("Shutdown from %s\n", inet_ntoa(from->sin_addr));
	Ms_DropServer(server);
}
开发者ID:devilx4,项目名称:quake2world,代码行数:16,代码来源:main.c


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