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


C++ NetBuffer::read_short方法代码示例

本文整理汇总了C++中NetBuffer::read_short方法的典型用法代码示例。如果您正苦于以下问题:C++ NetBuffer::read_short方法的具体用法?C++ NetBuffer::read_short怎么用?C++ NetBuffer::read_short使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetBuffer的用法示例。


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

示例1: read_client_move

void Server::read_client_move(Client *client) {
	NetBuffer *msg = client->m_netconnection->m_receiveMessage;
	usercmd_t *move = &client->m_cmd;

	int		i;
	vec3_t	angle;
	int		bits;

	// read ping time
	client->m_ping_times[client->m_num_pings%NUM_PING_TIMES]
		= m_time - msg->read_float();
	client->m_num_pings++;

	// read current angles	
	for (i = 0; i<3; i++)
		angle[i] = msg->read_angle();

	VectorCopy(angle, client->m_edict->v.v_angle);

	// read movement
	move->forwardmove = msg->read_short();
	move->sidemove = msg->read_short();
	move->upmove = msg->read_short();

	// read buttons
	bits = msg->read_byte();
	client->m_edict->v.button0 = (bits & 1);
	client->m_edict->v.button2 = (bits & 2) >> 1;

	i = msg->read_byte();
	if (i)
		client->m_edict->v.impulse = i;
}
开发者ID:elhobbs,项目名称:spectre3ds,代码行数:33,代码来源:Server.cpp

示例2: read_client_message

bool Server::read_client_message(Client *client) {
	NetBuffer *msg = client->m_netconnection->m_receiveMessage;
	char *s;
	int ret;

	do {
		if (msg->pos() == 0 || msg->read_pos() == msg->pos()) {
			break;
		}
		int r = msg->read_byte();
		if (r == -1) {
			return false;
		}
		int len = msg->read_short();
		/*int skip = */msg->read_byte();

		int end = msg->read_pos() + len;

		do {
			if (len == 0 || !client->is_active()) {
				return false;
			}
			int cmd = msg->read_byte();

			//check end of message
			if (cmd == -1) {
				break;
			}
			switch (cmd)
			{
			case -1:
				//goto nextmsg;		// end of message

			default:
				printf("SV_ReadClientMessage: unknown command char\n");
				return false;

			case clc_nop:
				printf("clc_nop\n");
				break;

			case clc_stringcmd:
				s = msg->read_string();
				ret = 0;
				if (strncasecmp(s, "status", 6) == 0)
					ret = 1;
				else if (strncasecmp(s, "god", 3) == 0)
					ret = 1;
				else if (strncasecmp(s, "notarget", 8) == 0)
					ret = 1;
				else if (strncasecmp(s, "fly", 3) == 0)
					ret = 1;
				else if (strncasecmp(s, "name", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "noclip", 6) == 0)
					ret = 1;
				else if (strncasecmp(s, "create", 6) == 0)
					ret = 1;
				else if (strncasecmp(s, "say", 3) == 0)
					ret = 1;
				else if (strncasecmp(s, "say_team", 8) == 0)
					ret = 1;
				else if (strncasecmp(s, "tell", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "color", 5) == 0)
					ret = 1;
				else if (strncasecmp(s, "kill", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "pause", 5) == 0)
					ret = 1;
				else if (strncasecmp(s, "spawn", 5) == 0) {
					ret = 1;
				}
				else if (strncasecmp(s, "begin", 5) == 0) {
					ret = 1;
					client->m_spawned = true;
					break;
				}
				else if (strncasecmp(s, "prespawn", 8) == 0) {
					ret = 1;
				}
				else if (strncasecmp(s, "kick", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "ping", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "give", 4) == 0)
					ret = 1;

				if (ret == 2)
					Cbuf_InsertText(s);
				else if (ret == 1) {
					m_cmds.call(s, client);
					Cmd_ExecuteString(s, src_client);
				}
				else
					printf("%s tried to %s\n", client->m_name, s);
				break;

			case clc_disconnect:
				printf("SV_ReadClientMessage: client disconnected\n");
//.........这里部分代码省略.........
开发者ID:elhobbs,项目名称:spectre3ds,代码行数:101,代码来源:Server.cpp


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