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


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

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


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

示例1: spawn

void Server::spawn(char *cmdline, void *p, ...) {
	Client *client = reinterpret_cast<Client *>(p);
	if (client->m_spawned) {
		printf("Spawn not valid -- allready spawned\n");
		return;
	}

	if (m_loadgame) {
		m_paused = false;
	} else {
		edict_t *ent = client->m_edict;
		memset(&ent->v, 0, m_progs->m_programs.entityfields * 4);
		ent->v.colormap = m_progs->NUM_FOR_EDICT(ent);
		ent->v.team = (client->m_colors & 15) + 1;
		ent->v.netname = client->m_name - m_progs->m_strings;

		// copy spawn parms out of the client_t

		for (int i = 0; i< NUM_SPAWN_PARMS; i++)
			(&m_progs->m_global_struct->parm1)[i] = client->m_spawn_parms[i];

		// call the spawn function

		m_progs->m_global_struct->time = m_time;
		m_progs->m_global_struct->self = m_progs->edict_to_prog(ent);
		m_progs->program_execute(m_progs->m_global_struct->ClientConnect);

		if ((sys.seconds() - client->m_netconnection->m_connecttime) <= m_time)
			printf("%s entered the game\n", client->m_name);

		m_progs->program_execute(m_progs->m_global_struct->PutClientInServer);
	}

	NetBuffer *msg = &client->m_msg;
	msg->clear();

	// send time of update
	msg->write_byte(svc_time);
	msg->write_float(m_time);

	for (int i = 0; i<m_maxclients; i++)
	{
		Client *client2 = &m_clients[i];
		msg->write_byte(svc_updatename);
		msg->write_byte(i);
		msg->write_string(client2->m_name);
		msg->write_byte(svc_updatefrags);
		msg->write_byte(i);
		msg->write_short(client2->m_old_frags);
		msg->write_byte(svc_updatecolors);
		msg->write_byte(i);
		msg->write_byte(client2->m_colors);
	}

	// send all current light styles
	for (int i = 0; i<MAX_LIGHTSTYLES; i++)
	{
		msg->write_byte(svc_lightstyle);
		msg->write_byte((char)i);
		msg->write_string(m_progs->m_lightstyles[i]);
	}

	//
	// send some stats
	//
	msg->write_byte(svc_updatestat);
	msg->write_byte(STAT_TOTALSECRETS);
	msg->write_long((int)m_progs->m_global_struct->total_secrets);

	msg->write_byte(svc_updatestat);
	msg->write_byte(STAT_TOTALMONSTERS);
	msg->write_long((int)m_progs->m_global_struct->total_monsters);

	msg->write_byte(svc_updatestat);
	msg->write_byte(STAT_SECRETS);
	msg->write_long((int)m_progs->m_global_struct->found_secrets);

	msg->write_byte(svc_updatestat);
	msg->write_byte(STAT_MONSTERS);
	msg->write_long((int)m_progs->m_global_struct->killed_monsters);


	//
	// send a fixangle
	// Never send a roll angle, because savegames can catch the server
	// in a state where it is expecting the client to correct the angle
	// and it won't happen if the game was just loaded, so you wind up
	// with a permanent head tilt
	edict_t *ent = m_progs->EDICT_NUM(1 + (client - m_clients));
	msg->write_byte(svc_setangle);
	for (int i = 0; i < 2; i++) {
		msg->write_angle(ent->v.angles[i]);
	}
	msg->write_angle(0);

	write_client_data_to_message(ent, msg);

	//SV_WriteClientdataToMessage(sv_player, &host_client->message);

	msg->write_byte(svc_signonnum);
//.........这里部分代码省略.........
开发者ID:elhobbs,项目名称:spectre3ds,代码行数:101,代码来源:Server.cpp


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