本文整理汇总了C++中PlayerInfo::getPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerInfo::getPlayer方法的具体用法?C++ PlayerInfo::getPlayer怎么用?C++ PlayerInfo::getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerInfo
的用法示例。
在下文中一共展示了PlayerInfo::getPlayer方法的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*)¶m);
server->runMainLoop(clientSocket,playerName);
pthread_cancel(timerThread);
server->disconectPlayer(clientSocket,playerName);
close(clientSocket);
return NULL;
}