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


C++ PlayerInfo::setName方法代码示例

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


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

示例1: handle

void* handle(void* par) {

	signal(SIGPIPE, SIG_IGN);

	HandleThreadParameter* parameter = (HandleThreadParameter*) par;
	int clientSocket = parameter->clientID;
	Server* server = parameter->server;

	std::vector<std::string> withBase = server->listFilesInDirectoryWithBase(
			"sendFiles");
	std::vector<std::string> withoutBase = server->listFilesInDirectory(
			"sendFiles");

	// Manda las imagenes y sonidos necesarios que se utilizaran.
	server->sendFiles(withBase, withoutBase, clientSocket);

	PlayerInfo* info = server->recieveNewPlayer(clientSocket);
	if (!info){
		Logs::logErrorMessage("No se ha recibido la informacion del jugador");
		return NULL;
	}
	string playerName = info->getPlayer()->getName();

	int result = server->isNameAbilivable(playerName);
	server->sendAproval(clientSocket, result);
	if (result != OK) {
		playerName = server->getAbilivableName(playerName);
		server->sendNewName(clientSocket, playerName);
		info->setName(playerName);
		info->getPlayer()->setName(playerName);
	}
	cont++;
	info->getPlayer()->setTeam(cont%2 +1);

	bool playing = true;
	cout << playerName << " has conected and joined team: " << info->getPlayer()->getTeam() <<endl;
	// Antes de agregarlo al juego creo el thread para chequear el estado en el que se encuentra.
	TimerThreadParameter param = {server,clientSocket,playerName, &playing};
	pthread_t timerThread;

	server->addPlayerToGame(clientSocket, info);

	pthread_create(&timerThread,NULL,timerChecker,(void*)&param);

	server->runMainLoop(clientSocket,playerName);

	pthread_cancel(timerThread);
	server->disconectPlayer(clientSocket,playerName);
	close(clientSocket);

	return NULL;

}
开发者ID:YangJJDD,项目名称:2013taller1c,代码行数:53,代码来源:Server.cpp


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