Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2041


Ignore:
Timestamp:
Oct 29, 2008, 12:48:11 AM (16 years ago)
Author:
landauf
Message:

bugs—
network++
endurance—
tiredness++

but it still doesn't work properly
(commit because oli is very impatient)

Location:
code/branches/objecthierarchy/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/Synchronisable.cc

    r2035 r2041  
    7777    if (creator)
    7878    {
    79         if (creator->isA(Class(Synchronisable)))
     79        Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
     80        if (synchronisable_creator && synchronisable_creator->objectMode_)
    8081        {
    81             Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
    8282            this->creatorID = synchronisable_creator->getObjectID();
    8383        }
     
    147147    synchronisableHeader *header = (synchronisableHeader *)mem;
    148148
    149     COUT(3) << "fabricating object with id: " << header->objectID << std::endl;
     149    COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
    150150
    151151    orxonox::Identifier* id = ClassByID(header->classID);
     
    170170    no->creatorID=header->creatorID; //TODO: remove this
    171171    no->classID=header->classID;
    172     COUT(3) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
     172    COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
    173173          // update data and create object/entity...
    174174    bool b = no->updateData(mem, mode, true);
  • code/branches/objecthierarchy/src/network/packet/Gamestate.cc

    r2035 r2041  
    254254  HEADER->compressed = true;
    255255  assert(HEADER->compressed);
    256   COUT(3) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
     256  COUT(4) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
    257257  return true;
    258258}
     
    261261  assert(HEADER);
    262262  assert(HEADER->compressed);
    263   COUT(3) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
     263  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
    264264  unsigned int datasize = HEADER->datasize;
    265265  unsigned int compsize = HEADER->compsize;
  • code/branches/objecthierarchy/src/orxonox/LevelManager.cc

    r2040 r2041  
    112112        assert(!this->clients_[clientID]);
    113113        this->clients_[clientID] = player;
     114
     115        if (this->getActiveLevel())
     116            this->getActiveLevel()->playerEntered(player);
    114117    }
    115118
     
    121124        PlayerInfo* player = this->clients_[clientID];
    122125        this->clients_.erase(clientID);
     126
     127        if (this->getActiveLevel())
     128            this->getActiveLevel()->playerLeft(player);
    123129
    124130        // delete PlayerInfo instance
  • code/branches/objecthierarchy/src/orxonox/objects/controllers/Controller.h

    r2040 r2041  
    4848
    4949            virtual inline void setControllableEntity(ControllableEntity* entity)
    50                 { this->controllableEntity_ = entity; }
     50                { COUT(0) << "HC: start controlling entity" << std::endl; this->controllableEntity_ = entity; }
    5151            virtual inline ControllableEntity* getControllableEntity() const
    5252                { return this->controllableEntity_; }
  • code/branches/objecthierarchy/src/orxonox/objects/controllers/HumanController.cc

    r2040 r2041  
    5757
    5858        HumanController::localController_s = this;
     59
     60        COUT(0) << "HumanController created" << std::endl;
    5961    }
    6062
  • code/branches/objecthierarchy/src/orxonox/objects/infos/HumanPlayer.cc

    r2040 r2041  
    5555        this->registerVariables();
    5656
    57         COUT(0) << "HumanPlayer created" << std::endl;
     57COUT(0) << this->getObjectID() << ": HumanPlayer created" << std::endl;
     58        network::Synchronisable* temp = dynamic_cast<network::Synchronisable*>(creator);
     59        if (temp)
     60        {
     61COUT(0) << this->getObjectID() << ": CreatorID: " << temp->getObjectID() << std::endl;
     62        }
     63        else
     64        {
     65COUT(0) << this->getObjectID() << ": Creator is no Synchronisable" << std::endl;
     66        }
     67    unsigned int creatorID = network::OBJECTID_UNKNOWN;
     68    searchcreatorID:
     69    if (creator)
     70    {
     71        if (creator->isA(Class(Synchronisable)))
     72        {
     73            Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
     74            creatorID = synchronisable_creator->getObjectID();
     75        }
     76        else if (creator != creator->getCreator())
     77        {
     78            creator = creator->getCreator();
     79            goto searchcreatorID;
     80        }
     81    }
     82COUT(0) << this->getObjectID() << ": ### tranmitted creatorID: " << creatorID << std::endl;
    5883    }
    5984
    6085    HumanPlayer::~HumanPlayer()
    6186    {
     87COUT(0) << this->getObjectID() << ": HumanPlayer destroyed" << std::endl;
    6288    }
    6389
     
    94120    void HumanPlayer::networkcallback_clientIDchanged()
    95121    {
     122COUT(0) << this->getObjectID() << ": PI: clientID changed to " << this->clientID_ << std::endl;
    96123        if (this->clientID_ == network::Host::getPlayerID())
    97124        {
     125COUT(0) << this->getObjectID() << ": PI: it's my clientID" << std::endl;
    98126            this->bLocalPlayer_ = true;
    99127            this->synchronize_nick_ = this->nick_;
     
    101129
    102130            if (!Core::isMaster())
     131            {
    103132                this->setObjectMode(network::direction::bidirectional);
     133COUT(0) << this->getObjectID() << ": PI: set objectmode to bidirectional" << std::endl;
     134            }
    104135            else
    105136                this->setName(this->nick_);
     
    112143    {
    113144        this->client_ready_ = true;
     145COUT(0) << this->getObjectID() << ": PI: server ready, client set ready too" << std::endl;
    114146    }
    115147
    116148    void HumanPlayer::networkcallback_client_ready()
    117149    {
     150COUT(0) << this->getObjectID() << ": PI: client ready" << std::endl;
    118151        if (this->getGametype())
     152        {
     153COUT(0) << this->getObjectID() << ": PI: adding client to gametype" << std::endl;
    119154            this->getGametype()->playerEntered(this);
     155        }
    120156    }
    121157
     
    137173    void HumanPlayer::setClientID(unsigned int clientID)
    138174    {
     175COUT(0) << this->getObjectID() << ": PI: set clientID to " << clientID << std::endl;
    139176        this->clientID_ = clientID;
    140177        this->networkcallback_clientIDchanged();
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc

    r2040 r2041  
    7171        REGISTERSTRING(this->name_,                 network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    7272        REGISTERDATA  (this->controllableEntityID_, network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
     73        REGISTERDATA  (this->bReadyToSpawn_,        network::direction::toserver);
    7374    }
    7475
     
    127128            this->controllableEntityID_ = network::OBJECTID_UNKNOWN;
    128129        }
    129 
     130COUT(0) << this->getObjectID() << ": PI: start control" << std::endl;
    130131        if (this->controller_)
    131132            this->controller_->setControllableEntity(entity);
    132133    }
    133134
    134     void PlayerInfo::stopControl(ControllableEntity* entity)
     135    void PlayerInfo::stopControl(ControllableEntity* entity, bool callback)
    135136    {
    136137        if (entity && this->controllableEntity_ == entity)
     
    142143                this->controller_->setControllableEntity(0);
    143144
    144             entity->removePlayer();
     145            if (callback)
     146                entity->removePlayer();
    145147        }
    146148    }
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.h

    r2040 r2041  
    6666
    6767            void startControl(ControllableEntity* entity);
    68             void stopControl(ControllableEntity* entity);
     68            void stopControl(ControllableEntity* entity, bool callback = true);
    6969
    7070            inline ControllableEntity* getControllableEntity() const
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2040 r2041  
    8181            if (this->camera_)
    8282                delete this->camera_;
     83
     84            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
     85                this->getPlayer()->stopControl(this, false);
    8386        }
    8487    }
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2040 r2041  
    5858        this->bInvertYAxis_ = false;
    5959
     60        this->setDestroyWhenPlayerLeft(true);
     61
    6062        this->setConfigValues();
    6163        this->registerVariables();
     
    8082    void SpaceShip::registerVariables()
    8183    {
     84        REGISTERDATA(this->maxSpeed_,                network::direction::toclient);
     85        REGISTERDATA(this->maxSecondarySpeed_,       network::direction::toclient);
     86        REGISTERDATA(this->maxRotation_,             network::direction::toclient);
     87        REGISTERDATA(this->translationAcceleration_, network::direction::toclient);
     88        REGISTERDATA(this->rotationAcceleration_,    network::direction::toclient);
     89        REGISTERDATA(this->translationDamping_,      network::direction::toclient);
    8290    }
    8391
     
    8997    void SpaceShip::tick(float dt)
    9098    {
    91         // #####################################
    92         // ############# STEERING ##############
    93         // #####################################
    94 
    95         Vector3 velocity = this->getVelocity();
    96         if (velocity.x > this->maxSecondarySpeed_)
    97             velocity.x = this->maxSecondarySpeed_;
    98         if (velocity.x < -this->maxSecondarySpeed_)
    99             velocity.x = -this->maxSecondarySpeed_;
    100         if (velocity.y > this->maxSecondarySpeed_)
    101             velocity.y = this->maxSecondarySpeed_;
    102         if (velocity.y < -this->maxSecondarySpeed_)
    103             velocity.y = -this->maxSecondarySpeed_;
    104         if (velocity.z > this->maxSecondarySpeed_)
    105             velocity.z = this->maxSecondarySpeed_;
    106         if (velocity.z < -this->maxSpeed_)
    107             velocity.z = -this->maxSpeed_;
    108 
    109         // normalize velocity and acceleration
    110         for (size_t dimension = 0; dimension < 3; ++dimension)
     99        if (this->isLocallyControlled())
    111100        {
    112             if (this->acceleration_[dimension] == 0)
     101            // #####################################
     102            // ############# STEERING ##############
     103            // #####################################
     104
     105            Vector3 velocity = this->getVelocity();
     106            if (velocity.x > this->maxSecondarySpeed_)
     107                velocity.x = this->maxSecondarySpeed_;
     108            if (velocity.x < -this->maxSecondarySpeed_)
     109                velocity.x = -this->maxSecondarySpeed_;
     110            if (velocity.y > this->maxSecondarySpeed_)
     111                velocity.y = this->maxSecondarySpeed_;
     112            if (velocity.y < -this->maxSecondarySpeed_)
     113                velocity.y = -this->maxSecondarySpeed_;
     114            if (velocity.z > this->maxSecondarySpeed_)
     115                velocity.z = this->maxSecondarySpeed_;
     116            if (velocity.z < -this->maxSpeed_)
     117                velocity.z = -this->maxSpeed_;
     118
     119            // normalize velocity and acceleration
     120            for (size_t dimension = 0; dimension < 3; ++dimension)
    113121            {
    114                 if (velocity[dimension] > 0)
     122                if (this->acceleration_[dimension] == 0)
    115123                {
    116                     velocity[dimension] -= (this->translationDamping_ * dt);
    117                     if (velocity[dimension] < 0)
    118                         velocity[dimension] = 0;
    119                 }
    120                 else if (velocity[dimension] < 0)
    121                 {
    122                     velocity[dimension] += (this->translationDamping_ * dt);
    123124                    if (velocity[dimension] > 0)
    124                         velocity[dimension] = 0;
     125                    {
     126                        velocity[dimension] -= (this->translationDamping_ * dt);
     127                        if (velocity[dimension] < 0)
     128                            velocity[dimension] = 0;
     129                    }
     130                    else if (velocity[dimension] < 0)
     131                    {
     132                        velocity[dimension] += (this->translationDamping_ * dt);
     133                        if (velocity[dimension] > 0)
     134                            velocity[dimension] = 0;
     135                    }
    125136                }
    126137            }
     138
     139            this->setVelocity(velocity);
    127140        }
    128141
    129         this->setVelocity(velocity);
    130 
    131142
    132143        SUPER(SpaceShip, tick, dt);
    133144
    134145
    135         this->yaw(this->yawRotation_ * dt);
    136         if (this->bInvertYAxis_)
    137             this->pitch(Degree(-this->pitchRotation_ * dt));
    138         else
    139             this->pitch(Degree( this->pitchRotation_ * dt));
    140         this->roll(this->rollRotation_ * dt);
    141 
    142         this->acceleration_.x = 0;
    143         this->acceleration_.y = 0;
    144         this->acceleration_.z = 0;
    145 
    146         this->yawRotation_   = this->zeroDegree_;
    147         this->pitchRotation_ = this->zeroDegree_;
    148         this->rollRotation_  = this->zeroDegree_;
     146        if (this->isLocallyControlled())
     147        {
     148            this->yaw(this->yawRotation_ * dt);
     149            if (this->bInvertYAxis_)
     150                this->pitch(Degree(-this->pitchRotation_ * dt));
     151            else
     152                this->pitch(Degree( this->pitchRotation_ * dt));
     153            this->roll(this->rollRotation_ * dt);
     154
     155            this->acceleration_.x = 0;
     156            this->acceleration_.y = 0;
     157            this->acceleration_.z = 0;
     158
     159            this->yawRotation_   = this->zeroDegree_;
     160            this->pitchRotation_ = this->zeroDegree_;
     161            this->rollRotation_  = this->zeroDegree_;
     162        }
    149163    }
    150164
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2040 r2041  
    5656        this->roll_ = 0;
    5757        this->setHudTemplate("spectatorhud");
     58        this->hudmode_ = 0;
    5859
    5960        this->setDestroyWhenPlayerLeft(true);
     
    8586        REGISTERDATA(this->bGreetingFlareVisible_, network::direction::toclient, new network::NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
    8687        REGISTERDATA(this->bGreeting_,             network::direction::toserver, new network::NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
     88        REGISTERDATA(this->hudmode_,               network::direction::toclient);
    8789    }
    8890
     
    100102    void Spectator::tick(float dt)
    101103    {
     104        this->updateHUD();
     105
    102106        if (this->isLocallyControlled())
    103107        {
    104             this->updateHUD();
    105 
    106108            Vector3 velocity = this->getVelocity();
    107109            velocity.normalise();
     
    187189    {
    188190        // <hack>
    189         if (this->getHUD())
    190         {
    191             std::string text;
    192 
     191        if (Core::isMaster())
     192        {
    193193            if (this->getPlayer() && this->getGametype())
    194194            {
     
    196196                {
    197197                    if (!this->getPlayer()->isReadyToSpawn())
    198                         text = "Press [Fire] to start the match";
     198                        this->hudmode_ = 0;
    199199                    else
    200                         text = "Waiting for other players";
     200                        this->hudmode_ = 1;
    201201                }
    202202                else if (!this->getGametype()->hasEnded())
    203203                {
    204204                    if (this->getGametype()->isStartCountdownRunning())
    205                     {
    206                         text = convertToString(ceil(this->getGametype()->getStartCountdown()));
    207                     }
     205                        this->hudmode_ = 2 + 10*ceil(this->getGametype()->getStartCountdown());
    208206                    else
    209                     {
    210                         text = "Press [Fire] to respawn";
    211                     }
     207                        this->hudmode_ = 3;
    212208                }
    213209                else
    214                 {
     210                    this->hudmode_ = 4;
     211            }
     212            else
     213                return;
     214        }
     215
     216        if (this->getHUD())
     217        {
     218            std::string text;
     219            int hudmode = this->hudmode_ % 10;
     220
     221            switch (hudmode)
     222            {
     223                case 0:
     224                    text = "Press [Fire] to start the match";
     225                    break;
     226                case 1:
     227                    text = "Waiting for other players";
     228                    break;
     229                case 2:
     230                    text = convertToString((this->hudmode_ - 2) / 10);
     231                    break;
     232                case 3:
     233                    text = "Press [Fire] to respawn";
     234                    break;
     235                case 4:
    215236                    text = "Game has ended";
    216                 }
    217             }
    218             else
    219             {
    220                 return;
     237                    break;
     238                default:;
    221239            }
    222240
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2040 r2041  
    7474            float pitch_;
    7575            float roll_;
     76
     77            int hudmode_;
    7678    };
    7779}
Note: See TracChangeset for help on using the changeset viewer.