⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acthandler.cpp

📁 robocup 3d, a 3d base team similar to UvA 2d
💻 CPP
字号:
/***********************************************************************************                            In the name of Almighty                            **                                                                               **         ActHandler.cpp : Robocup 3D Soccer Simulation Team Zigorat            **                     (This team was previously named Gcyrus)                   **                                                                               **  Date: 03/20/2007                                                             **  Author: Mahdi Hamdarsi                                                       **  Comments: This file contains class definitions for Acthandler which handles  **            command sending to simulation server                               **                                                                               ***********************************************************************************//*! \file ActHandler.cpp<pre><b>File:</b>          ActHandler.cpp<b>Project:</b>       Robocup Soccer Simulation Team: Zigorat<b>Authors:</b>       Mahdi Hamdarsi<b>Created:</b>       03/20/2007<b>Last Revision:</b> $ID$<b>Contents:</b>      This file contains class definitions for Acthandler               which handles command sending to server.<hr size=2><h2><b>Changes</b></h2><b>Date</b>             <b>Author</b>          <b>Comment</b>03/20/2007       Mahdi           Initial version created</pre>*/#include "ActHandler.h"/*! This is the constructor for the ActHandler class. All the variables are    initialized.    \param c Connection that messages are going to be sent by */ActHandler::ActHandler( TRoboCupConnection *c ){  connection = c;  emptyQueue();}/*! This method empties the queue in which all the commands are stored. */void ActHandler::emptyQueue( ){  int i;  m_SayCommand.commandType = CMD_ILLEGAL;  for( i = 0; i < MAX_JOINTS; i++ )  {    m_queueJointCommands[i].commandType = CMD_JOINT;    m_queueJointCommands[i].JID         = (JointT)i;    m_queueJointCommands[i].dSpeed1     = m_queueJointCommands[i].dSpeed2 = 0.0;  }}/*! This method converts all commands in the queue to text strings and sends    these text strings to the server (connected by Connection).    \return true when sending of messages succeeded, false otherwise */bool ActHandler::sendCommands( ){  int i;  for( i = 0; i < MAX_JOINTS; i++ )    sendCommand( m_queueJointCommands[i] );  sendCommand( m_SayCommand );  emptyQueue();  return true;}/*! This method puts a SoccerCommand in the queue. The added commands will    be sent to the soccerserver when the method sendCommands is performed.    Normally this is done when thinkin' finishes.    \param command SoccerCommand that should be put in the queue.    \return always true when command is added */bool ActHandler::putCommandInQueue( SoccerCommand command ){  if( command.isIllegal() )    return false;  if( command.commandType == CMD_JOINT )    m_queueJointCommands[ command.JID ] = command;  else if( command.commandType == CMD_SAY )    m_SayCommand = command;  return true;}/*! This method sends a single command directly to the server. First a string    is made from the SoccerCommand and afterwards this string is send to the    server using the method sendMessage.    \param soc SoccerCommand that should be send to the server.    \return true when message was sent, false otherwise */bool ActHandler::sendCommand( const SoccerCommand & soc ) const{  char strCommand[MAX_MSG];  if( soc.getCommandString( strCommand ) )    return sendMessage( strCommand );  else    return false;}/*! This method sends a single string directly to the server.    \param str string that should be sent to the server    \return true when message was sent, false otherwise */bool ActHandler::sendMessage( const char * str ) const{  return connection->sendCommand( str );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -