Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 23, 2009, 12:44:10 AM (16 years ago)
Author:
landauf
Message:

Split Gametype into Gametype+Deathmatch. The only difference is output like "player x killed player y" which only appears in Deathmatch now. TeamGametype inherits from Deathmatch (and will shortly be renamed into TeamDeathmatch).

Location:
code/branches/miniprojects/src/orxonox/objects/gametypes
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/miniprojects/src/orxonox/objects/gametypes/CMakeLists.txt

    r2768 r2820  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  Gametype.cc
     3  Deathmatch.cc
    34  TeamGametype.cc
    45)
  • code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc

    r2818 r2820  
    4444#include "objects/worldentities/Camera.h"
    4545
    46 #include "network/Host.h"
    47 
    4846namespace orxonox
    4947{
     
    105103        this->addBots(this->numberOfBots_);
    106104
    107         COUT(0) << "game started" << std::endl;
    108105        this->gtinfo_.bStarted_ = true;
    109106
     
    113110    void Gametype::end()
    114111    {
    115         COUT(0) << "game ended" << std::endl;
    116112        this->gtinfo_.bEnded_ = true;
    117113    }
     
    120116    {
    121117        this->players_[player].state_ = PlayerState::Joined;
    122 
    123         std::string message = player->getName() + " entered the game";
    124         COUT(0) << message << std::endl;
    125         Host::Broadcast(message);
    126     }
    127 
    128     void Gametype::playerLeft(PlayerInfo* player)
     118    }
     119
     120    bool Gametype::playerLeft(PlayerInfo* player)
    129121    {
    130122        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
     
    132124        {
    133125            this->players_.erase(it);
    134 
    135             std::string message = player->getName() + " left the game";
    136             COUT(0) << message << std::endl;
    137             Host::Broadcast(message);
    138         }
     126            return true;
     127        }
     128        return false;
    139129    }
    140130
     
    147137    }
    148138
    149     void Gametype::playerChangedName(PlayerInfo* player)
     139    bool Gametype::playerChangedName(PlayerInfo* player)
    150140    {
    151141        if (this->players_.find(player) != this->players_.end())
     
    153143            if (player->getName() != player->getOldName())
    154144            {
    155                 std::string message = player->getOldName() + " changed name to " + player->getName();
    156                 COUT(0) << message << std::endl;
    157                 Host::Broadcast(message);
    158             }
    159         }
     145                return true;
     146            }
     147        }
     148        return false;
    160149    }
    161150
     
    201190    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
    202191    {
    203         if (victim && victim->getPlayer())
    204         {
    205             std::string message;
    206             if (killer)
    207             {
    208                 if (killer->getPlayer())
    209                     message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
    210                 else
    211                     message = victim->getPlayer()->getName() + " was killed";
    212             }
    213             else
    214                 message = victim->getPlayer()->getName() + " died";
    215 
    216             COUT(0) << message << std::endl;
    217             Host::Broadcast(message);
    218         }
    219 
    220192        if (victim && victim->getPlayer())
    221193        {
  • code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h

    r2818 r2820  
    8484            virtual void end();
    8585            virtual void playerEntered(PlayerInfo* player);
    86             virtual void playerLeft(PlayerInfo* player);
     86            virtual bool playerLeft(PlayerInfo* player);
    8787            virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype);
    8888            virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype);
    89             virtual void playerChangedName(PlayerInfo* player);
     89            virtual bool playerChangedName(PlayerInfo* player);
    9090
    9191            virtual void playerScored(Player& player);
  • code/branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc

    r2818 r2820  
    3939    CreateUnloadableFactory(TeamGametype);
    4040
    41     TeamGametype::TeamGametype(BaseObject* creator) : Gametype(creator)
     41    TeamGametype::TeamGametype(BaseObject* creator) : Deathmatch(creator)
    4242    {
    4343        RegisterObject(TeamGametype);
     
    6666    void TeamGametype::playerEntered(PlayerInfo* player)
    6767    {
    68         Gametype::playerEntered(player);
     68        Deathmatch::playerEntered(player);
    6969
    7070        std::vector<unsigned int> playersperteam(this->teams_, 0);
     
    8888    }
    8989
    90     void TeamGametype::playerLeft(PlayerInfo* player)
     90    bool TeamGametype::playerLeft(PlayerInfo* player)
    9191    {
    92         Gametype::playerLeft(player);
     92        bool valid_player = Deathmatch::playerLeft(player);
    9393
    94         this->players_.erase(player);
     94        if (valid_player)
     95            this->players_.erase(player);
     96
     97        return valid_player;
    9598    }
    9699
  • code/branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h

    r2818 r2820  
    3434#include <vector>
    3535
    36 #include "Gametype.h"
     36#include "Deathmatch.h"
    3737
    3838namespace orxonox
    3939{
    40     class _OrxonoxExport TeamGametype : public Gametype
     40    class _OrxonoxExport TeamGametype : public Deathmatch
    4141    {
    4242        public:
     
    4747
    4848            virtual void playerEntered(PlayerInfo* player);
    49             virtual void playerLeft(PlayerInfo* player);
     49            virtual bool playerLeft(PlayerInfo* player);
    5050
    5151            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
Note: See TracChangeset for help on using the changeset viewer.