Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (15 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.cc

    r2907 r2908  
    3636#include "core/ConfigValueIncludes.h"
    3737#include "core/Template.h"
    38 #include "core/GameMode.h"
     38#include "core/Core.h"
    3939#include "overlays/OverlayGroup.h"
    4040#include "objects/infos/PlayerInfo.h"
     
    4444#include "objects/worldentities/Camera.h"
    4545
     46#include "network/Host.h"
     47
    4648namespace orxonox
    4749{
     
    6466        this->setConfigValues();
    6567
     68        this->addBots(this->numberOfBots_);
     69
    6670        // load the corresponding score board
    67         if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "")
     71        if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
    6872        {
    6973            this->scoreboard_ = new OverlayGroup(this);
     
    101105    void Gametype::start()
    102106    {
    103         this->addBots(this->numberOfBots_);
    104 
     107        COUT(0) << "game started" << std::endl;
    105108        this->gtinfo_.bStarted_ = true;
    106109
     
    110113    void Gametype::end()
    111114    {
     115        COUT(0) << "game ended" << std::endl;
    112116        this->gtinfo_.bEnded_ = true;
    113117    }
     
    116120    {
    117121        this->players_[player].state_ = PlayerState::Joined;
    118     }
    119 
    120     bool Gametype::playerLeft(PlayerInfo* player)
     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)
    121129    {
    122130        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
     
    124132        {
    125133            this->players_.erase(it);
    126             return true;
    127         }
    128         return false;
     134
     135            std::string message = player->getName() + " left the game";
     136            COUT(0) << message << std::endl;
     137            Host::Broadcast(message);
     138        }
    129139    }
    130140
     
    137147    }
    138148
    139     bool Gametype::playerChangedName(PlayerInfo* player)
     149    void Gametype::playerChangedName(PlayerInfo* player)
    140150    {
    141151        if (this->players_.find(player) != this->players_.end())
     
    143153            if (player->getName() != player->getOldName())
    144154            {
    145                 return true;
    146             }
    147         }
    148         return false;
     155                std::string message = player->getOldName() + " changed name to " + player->getName();
     156                COUT(0) << message << std::endl;
     157                Host::Broadcast(message);
     158            }
     159        }
    149160    }
    150161
     
    157168    }
    158169
    159     void Gametype::playerPreSpawn(PlayerInfo* player)
    160     {
    161     }
    162 
    163     void Gametype::playerPostSpawn(PlayerInfo* player)
    164     {
    165     }
    166 
    167     void Gametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
    168     {
    169     }
    170 
    171     void Gametype::playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn)
    172     {
    173     }
    174 
    175     bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)
    176     {
    177         return true;
    178     }
    179 
    180     bool Gametype::allowPawnDamage(Pawn* victim, Pawn* originator)
    181     {
    182         return true;
    183     }
    184 
    185     bool Gametype::allowPawnDeath(Pawn* victim, Pawn* originator)
    186     {
    187         return true;
    188     }
    189 
    190170    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
    191171    {
     172        if (victim && victim->getPlayer())
     173        {
     174            std::string message;
     175            if (killer)
     176            {
     177                if (killer->getPlayer())
     178                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
     179                else
     180                    message = victim->getPlayer()->getName() + " was killed";
     181            }
     182            else
     183                message = victim->getPlayer()->getName() + " died";
     184
     185            COUT(0) << message << std::endl;
     186            Host::Broadcast(message);
     187        }
     188
    192189        if (victim && victim->getPlayer())
    193190        {
     
    201198                if (killer)
    202199                {
    203                     std::map<PlayerInfo*, Player>::iterator it = this->players_.find(killer->getPlayer());
    204                     if (it != this->players_.end())
    205                         it->second.frags_++;
     200                    std::map<PlayerInfo*, Player>::iterator itKiller = this->players_.find(killer->getPlayer());
     201                    if (itKiller != this->players_.end())
     202                    {
     203                        this->playerScored(itKiller->second);
     204                    }
     205                    else
     206                        COUT(2) << "Warning: Killing Pawn was not in the playerlist" << std::endl;
    206207                }
    207208
     
    224225    }
    225226
    226     void Gametype::playerScored(PlayerInfo* player)
    227     {
    228         std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
    229         if (it != this->players_.end())
    230             it->second.frags_++;
    231     }
    232 
    233     int Gametype::getScore(PlayerInfo* player) const
    234     {
    235         std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player);
    236         if (it != this->players_.end())
    237             return it->second.frags_;
    238         else
    239             return 0;
     227    void Gametype::playerScored(Player& player)
     228    {
     229        player.frags_++;
    240230    }
    241231
     
    346336        if (spawnpoint)
    347337        {
    348             this->playerPreSpawn(player);
    349338            player->startControl(spawnpoint->spawn());
    350339            this->players_[player].state_ = PlayerState::Alive;
    351             this->playerPostSpawn(player);
    352340        }
    353341        else
     
    361349    {
    362350        for (unsigned int i = 0; i < amount; ++i)
    363             this->botclass_.fabricate(this);
     351            new Bot(this);
    364352    }
    365353
Note: See TracChangeset for help on using the changeset viewer.