Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 24, 2008, 2:48:43 AM (16 years ago)
Author:
landauf
Message:

many changes, can't remember everything, but these are the most important:

  • attaching entities to other entities works
  • displaying models, lights and shadows works
  • controlling a spectator works
  • removed an update hack in PositionableEntity because I've found a much better solution

and with "works" I mean: it works on client, server and standalone

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc

    r1993 r2006  
    3131
    3232#include "core/CoreIncludes.h"
    33 #include "core/ConsoleCommand.h"
    3433#include "objects/infos/PlayerInfo.h"
    3534#include "objects/worldentities/pawns/Spectator.h"
     
    3938namespace orxonox
    4039{
    41     SetConsoleCommand(Gametype, listPlayers, true);
    42 
    4340    CreateUnloadableFactory(Gametype);
    4441
     
    4845
    4946        this->defaultPawn_ = Class(Spectator);
    50         this->getConnectedClients();
    5147
    5248        COUT(0) << "created Gametype" << std::endl;
    53     }
    54 
    55     Gametype* Gametype::getCurrentGametype()
    56     {
    57         for (ObjectList<Gametype>::iterator it = ObjectList<Gametype>::begin(); it != ObjectList<Gametype>::end(); ++it)
    58             return (*it);
    59 
    60         return 0;
    61     }
    62 
    63     PlayerInfo* Gametype::getClient(unsigned int clientID)
    64     {
    65         Gametype* gametype = Gametype::getCurrentGametype();
    66         if (gametype)
    67         {
    68             std::map<unsigned int, PlayerInfo*>::const_iterator it = gametype->clients_.find(clientID);
    69             if (it != gametype->clients_.end())
    70                 return it->second;
    71         }
    72         else
    73         {
    74             for (ObjectList<PlayerInfo>::iterator it = ObjectList<PlayerInfo>::begin(); it != ObjectList<PlayerInfo>::end(); ++it)
    75                 if (it->getClientID() == clientID)
    76                     return (*it);
    77         }
    78         return 0;
    79     }
    80 
    81     void Gametype::listPlayers()
    82     {
    83         Gametype* gametype = Gametype::getCurrentGametype();
    84 
    85         if (gametype)
    86         {
    87             for (std::set<PlayerInfo*>::const_iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
    88                 COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl;
    89         }
    90         else
    91         {
    92             for (ObjectList<PlayerInfo>::iterator it = ObjectList<PlayerInfo>::begin(); it != ObjectList<PlayerInfo>::end(); ++it)
    93                 COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl;
    94         }
    95     }
    96 
    97     void Gametype::clientConnected(unsigned int clientID)
    98     {
    99         COUT(0) << "client connected" << std::endl;
    100 
    101         // create new PlayerInfo instance
    102         PlayerInfo* player = new PlayerInfo();
    103         player->setClientID(clientID);
    104 
    105         // add to clients-map
    106         assert(!this->clients_[clientID]);
    107         this->clients_[clientID] = player;
    108     }
    109 
    110     void Gametype::clientDisconnected(unsigned int clientID)
    111     {
    112         COUT(0) << "client disconnected" << std::endl;
    113 
    114         // remove from clients-map
    115         PlayerInfo* player = this->clients_[clientID];
    116         this->clients_.erase(clientID);
    117 
    118         // delete PlayerInfo instance
    119         delete player;
    12049    }
    12150
     
    13160    void Gametype::removePlayer(PlayerInfo* player)
    13261    {
    133         player->stopControl();
    134         this->players_.erase(player);
    135         this->playerLeft(player);
     62        if (this->players_.find(player) != this->players_.end())
     63        {
     64            player->stopControl();
     65            this->players_.erase(player);
     66            this->playerLeft(player);
     67        }
    13668    }
    13769
Note: See TracChangeset for help on using the changeset viewer.