Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 23, 2011, 9:41:21 PM (13 years ago)
Author:
dafrick
Message:

Done documenting Pong.
Also resolved some doxygen warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tetris/src/modules/pong/PongScore.cc

    r6417 r8107  
    2727 */
    2828
     29/**
     30    @file PongScore.cc
     31    @brief Implementation of the PongScore class.
     32*/
     33
    2934#include "PongScore.h"
    3035
    31 #include "util/Convert.h"
    3236#include "core/CoreIncludes.h"
    3337#include "core/XMLPort.h"
     38#include "util/Convert.h"
     39
     40#include "infos/PlayerInfo.h"
     41
    3442#include "Pong.h"
    35 #include "infos/PlayerInfo.h"
    3643
    3744namespace orxonox
     
    3946    CreateFactory(PongScore);
    4047
     48    /**
     49    @brief
     50        Constructor. Registers and initializes the object.
     51    */
    4152    PongScore::PongScore(BaseObject* creator) : OverlayText(creator)
    4253    {
     
    5162    }
    5263
     64    /**
     65    @brief
     66        Destructor.
     67    */
    5368    PongScore::~PongScore()
    5469    {
    5570    }
    5671
     72    /**
     73    @brief
     74        Method to create a PongScore through XML.
     75    */
    5776    void PongScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5877    {
     
    6584    }
    6685
     86    /**
     87    @brief
     88        Is called each tick.
     89        Creates and sets the caption to be displayed by the PongScore.
     90    @param dt
     91        The time that has elapsed since the last tick.
     92    */
    6793    void PongScore::tick(float dt)
    6894    {
    6995        SUPER(PongScore, tick, dt);
    7096
    71         if (this->owner_)
     97        // If the owner is set. The owner being a Pong game.
     98        if (this->owner_ != NULL)
    7299        {
     100            // Get the two players.
    73101            PlayerInfo* player1 = this->owner_->getLeftPlayer();
    74102            PlayerInfo* player2 = this->owner_->getRightPlayer();
     
    80108            std::string score2("0");
    81109
    82             if (player1)
     110            // Save the name and score of each player as a string.
     111            if (player1 != NULL)
    83112            {
    84113                name1 = player1->getName();
    85114                score1 = multi_cast<std::string>(this->owner_->getScore(player1));
    86115            }
    87 
    88             if (player2)
     116            if (player2 != NULL)
    89117            {
    90118                name2 = player2->getName();
     
    92120            }
    93121
     122            // Assemble the strings, depending on what should all be displayed.
    94123            std::string output1;
    95124            if (this->bShowLeftPlayer_)
    96125            {
    97                 if (this->bShowName_ && this->bShowScore_ && player1)
     126                if (this->bShowName_ && this->bShowScore_ && player1 != NULL)
    98127                    output1 = name1 + " - " + score1;
    99128                else if (this->bShowScore_)
     
    106135            if (this->bShowRightPlayer_)
    107136            {
    108                 if (this->bShowName_ && this->bShowScore_ && player2)
     137                if (this->bShowName_ && this->bShowScore_ && player2 != NULL)
    109138                    output2 = score2 + " - " + name2;
    110139                else if (this->bShowScore_)
     
    127156    }
    128157
    129 
     158    /**
     159    @brief
     160        Is called when the owner changes.
     161        Sets the owner to NULL, if it is not a pointer to a Pong game.
     162    */
    130163    void PongScore::changedOwner()
    131164    {
    132165        SUPER(PongScore, changedOwner);
    133166
    134         if (this->getOwner() && this->getOwner()->getGametype())
     167        if (this->getOwner() != NULL && this->getOwner()->getGametype())
    135168            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    136169        else
Note: See TracChangeset for help on using the changeset viewer.