Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2009, 9:20:57 PM (15 years ago)
Author:
landauf
Message:

merged netp3 branch back to trunk

Location:
code/trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r3079 r3084  
    140140    class SpawnPoint;
    141141    class TeamSpawnPoint;
     142    class Test;
    142143
    143144    class Spectator;
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r2928 r3084  
    5757namespace orxonox
    5858{
    59     AddGameState(GSGraphics, "graphics");
    60 
    61     GSGraphics::GSGraphics(const std::string& name)
    62         : GameState(name)
     59    AddGameState(GSGraphics, "graphics", false);
     60
     61    GSGraphics::GSGraphics(const std::string& name, bool countTickTime)
     62        : GameState(name, countTickTime)
    6363        , inputManager_(0)
    6464        , console_(0)
     
    213213        uint64_t timeBeforeTick = time.getRealMicroseconds();
    214214
    215         this->inputManager_->update(time);        // tick console
     215        this->inputManager_->update(time);
    216216        this->console_->update(time);
    217         this->guiManager_->update(time);
    218217
    219218        uint64_t timeAfterTick = time.getRealMicroseconds();
     
    222221        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    223222
     223        // Process gui events
     224        this->guiManager_->update(time);
    224225        // Render
    225226        this->graphicsManager_->update(time);
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r2896 r3084  
    5151    {
    5252    public:
    53         GSGraphics(const std::string& name);
     53        GSGraphics(const std::string& name, bool countTickTime);
    5454        ~GSGraphics();
    5555        void setConfigValues();
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r2928 r3084  
    4343namespace orxonox
    4444{
    45     AddGameState(GSRoot, "root");
     45    AddGameState(GSRoot, "root", false);
    4646    SetCommandLineSwitch(console);
    4747    // Shortcuts for easy direct loading
     
    5151    SetCommandLineSwitch(standalone);
    5252
    53     GSRoot::GSRoot(const std::string& name)
    54         : GameState(name)
     53    GSRoot::GSRoot(const std::string& name, bool countTickTime)
     54        : GameState(name, countTickTime)
    5555        , timeFactor_(1.0f)
    5656        , bPaused_(false)
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r2896 r3084  
    3939    {
    4040    public:
    41         GSRoot(const std::string& name);
     41        GSRoot(const std::string& name, bool countTickTime);
    4242        ~GSRoot();
    4343
  • code/trunk/src/orxonox/objects/CMakeLists.txt

    r3053 r3084  
    1010  Teamcolourable.cc
    1111  Tickable.cc
    12   Test.cc
    1312  Scene.cc
    1413  Script.cc
  • code/trunk/src/orxonox/objects/Test.cc

    r2662 r3084  
    3131#include "core/ConfigValueIncludes.h"
    3232#include "core/ConsoleCommand.h"
     33#include "network/NetworkFunction.h"
    3334#include "Test.h"
     35#include "util/MultiType.h"
    3436
    3537namespace orxonox
     
    4143  SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
    4244  SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
     45  SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
     46  SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
     47 
     48 
     49  //void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
     50  //void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
     51//   NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
     52 
     53  registerStaticNetworkFunction( &Test::printV1 );
     54  registerMemberNetworkFunction( Test, checkU1 );
     55  registerMemberNetworkFunction( Test, printBlaBla );
    4356 
    4457  Test* Test::instance_ = 0;
     
    7386
    7487
    75         void Test::registerVariables()
    76         {
    77                 registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
     88  void Test::registerVariables()
     89  {
     90    registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
    7891    registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
    79                 registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
     92    registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
    8093    registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
    8194   
     
    8497    registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
    8598    registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
    86         }
    87 
     99  }
     100 
     101  void Test::call(unsigned int clientID)
     102  {
     103    callStaticNetworkFunction( &Test::printV1, clientID );
     104    callStaticNetworkFunction( &Test::printV1, clientID );
     105  }
     106 
     107  void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
     108  {
     109    callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
     110  }
     111 
     112  void Test::tick(float dt)
     113  {
     114//     std::string str1 = "blub";
     115//     //MultiType mt1(std::string("blub"));
     116//     MultiType mt1(str1);
     117//     uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
     118//     uint8_t* temp = mem;
     119//     mt1.exportData( temp );
     120//     assert( temp-mem == mt1.getNetworkSize() );
     121//     MultiType mt2;
     122//     temp = mem;
     123//     mt2.importData( temp );
     124//     assert( temp-mem == mt1.getNetworkSize() );
     125//     COUT(0) << mt2 << endl;
     126    if(!Core::isMaster())
     127      call2(0, "bal", "a", "n", "ce");
     128//       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
     129  }
     130 
     131  void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
     132  {
     133    COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
     134  }
     135 
    88136  void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
    89137  void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
  • code/trunk/src/orxonox/objects/Test.h

    r2662 r3084  
    3333#include "core/BaseObject.h"
    3434#include "network/synchronisable/Synchronisable.h"
     35#include "Tickable.h"
    3536
    3637
     
    4142namespace orxonox
    4243{
    43   class _OrxonoxExport Test: public BaseObject, public Synchronisable
     44  class _OrxonoxExport Test: public BaseObject, public Synchronisable, public Tickable
    4445  {
    4546    public:
     
    4950      void setConfigValues();
    5051      void registerVariables();
     52     
     53      static void call(unsigned int clientID);
     54      void call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4);
     55      virtual void tick(float dt);
    5156
    5257
     
    7580      static void printV3(){ instance_->checkU3(); }
    7681      static void printV4(){ instance_->checkU4(); }
     82     
     83      void printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5);
    7784
    7885    private:
  • code/trunk/src/orxonox/objects/controllers/AIController.cc

    r3053 r3084  
    3030#include "AIController.h"
    3131
    32 #include "core/GameMode.h"
    3332#include "core/CoreIncludes.h"
    3433#include "core/Executor.h"
     
    4544        RegisterObject(AIController);
    4645
    47         if (GameMode::isMaster())
    48             this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
     46        this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
    4947    }
    5048
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc

    r3049 r3084  
    379379        registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    380380        registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     381       
    381382
    382383        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
  • code/trunk/src/orxonox/objects/worldentities/MobileEntity.h

    r3068 r3084  
    6161                { this->setAngularVelocity(Vector3(x, y, z)); }
    6262            inline const Vector3& getAngularVelocity() const
    63                 { return this->linearAcceleration_; }
     63                { return this->angularVelocity_; }
    6464
    6565            void setAcceleration(const Vector3& acceleration);
  • code/trunk/src/orxonox/objects/worldentities/PongBall.cc

    r2896 r3084  
    3232#include "core/CoreIncludes.h"
    3333#include "core/GameMode.h"
    34 #include "objects/worldentities/PongBat.h"
    3534#include "objects/gametypes/Gametype.h"
    3635
     
    4746        this->speed_ = 0;
    4847        this->bat_ = 0;
     48        this->batID_ = new unsigned int[2];
     49        this->batID_[0] = OBJECTID_UNKNOWN;
     50        this->batID_[1] = OBJECTID_UNKNOWN;
    4951        this->relMercyOffset_ = 0.05;
     52       
     53        this->registerVariables();
     54    }
     55   
     56    void PongBall::registerVariables()
     57    {
     58        registerVariable( this->fieldWidth_ );
     59        registerVariable( this->fieldHeight_ );
     60        registerVariable( this->batlength_ );
     61        registerVariable( this->speed_ );
     62        registerVariable( this->relMercyOffset_ );
     63        registerVariable( this->batID_[0] );
     64        registerVariable( this->batID_[1], variableDirection::toclient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) );
    5065    }
    5166
     
    119134                this->setPosition(position);
    120135        }
     136        else
     137        {
     138          Vector3 position = this->getPosition();
     139          Vector3 velocity = this->getVelocity();
     140
     141          if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
     142          {
     143            velocity.z = -velocity.z;
     144
     145            if (position.z > this->fieldHeight_ / 2)
     146              position.z = this->fieldHeight_ / 2;
     147            if (position.z < -this->fieldHeight_ / 2)
     148              position.z = -this->fieldHeight_ / 2;
     149          }
     150
     151          if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
     152          {
     153            float distance = 0;
     154
     155            if (this->bat_)
     156            {
     157              if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
     158              {
     159                distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
     160                if (fabs(distance) <= 1)
     161                {
     162                  position.x = this->fieldWidth_ / 2;
     163                  velocity.x = -velocity.x;
     164                  velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     165                }
     166              }
     167              if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
     168              {
     169                distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
     170                if (fabs(distance) <= 1)
     171                {
     172                  position.x = -this->fieldWidth_ / 2;
     173                  velocity.x = -velocity.x;
     174                  velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     175                }
     176              }
     177            }
     178          }
     179
     180          if (velocity != this->getVelocity())
     181            this->setVelocity(velocity);
     182          if (position != this->getPosition())
     183            this->setPosition(position);
     184        }
    121185    }
    122186
  • code/trunk/src/orxonox/objects/worldentities/PongBall.h

    r2885 r3084  
    3333
    3434#include "objects/worldentities/MovableEntity.h"
     35#include "objects/worldentities/PongBat.h"
    3536
    3637namespace orxonox
     
    4344
    4445            virtual void tick(float dt);
     46           
     47            void registerVariables();
    4548
    4649            void setFieldDimension(float width, float height)
     
    6164
    6265            void setBats(PongBat** bats)
    63                 { this->bat_ = bats; }
     66            { this->bat_ = bats; this->batID_[0] = this->bat_[0]->getObjectID(); this->batID_[1] = this->bat_[1]->getObjectID(); }
     67           
     68            void applyBats()
     69            { if(!this->bat_) this->bat_ = new PongBat*[2]; if(this->batID_[0] != OBJECTID_UNKNOWN) this->bat_[0] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[0])); if(this->batID_[1] != OBJECTID_UNKNOWN) this->bat_[1] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1])); }
    6470
    6571            static const float MAX_REL_Z_VELOCITY;
     
    7177            float batlength_;
    7278            PongBat** bat_;
     79            unsigned int* batID_;
    7380            float relMercyOffset_;
    7481    };
  • code/trunk/src/orxonox/objects/worldentities/PongBat.cc

    r2839 r3084  
    5454    {
    5555        registerVariable(this->speed_);
    56         registerVariable(this->speed_);
    57         registerVariable(this->speed_);
     56        registerVariable(this->fieldHeight_);
     57        registerVariable(this->length_);
    5858    }
    5959
     
    9191            position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2;
    9292        if (position != this->getPosition())
     93        {
    9394            this->setPosition(position);
     95            this->setVelocity( Vector3::ZERO );
     96        }
    9497    }
    9598
     
    97100    {
    98101        this->bMoveLocal_ = false;
    99         this->movement_ -= value.x;
     102        this->movement_ = -value.x;
    100103    }
    101104
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r3073 r3084  
    3939#include "objects/worldentities/ParticleSpawner.h"
    4040#include "objects/worldentities/ExplosionChunk.h"
     41
    4142#include "objects/weaponsystem/WeaponSystem.h"
    4243#include "objects/weaponsystem/WeaponSlot.h"
     
    4445#include "objects/weaponsystem/WeaponSet.h"
    4546
     47#include "network/NetworkFunction.h"
     48
    4649namespace orxonox
    4750{
    4851    CreateFactory(Pawn);
     52
     53    registerMemberNetworkFunction( Pawn, doFire );
    4954
    5055    Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
     
    123128        SUPER(Pawn, tick, dt);
    124129
    125         if (this->weaponSystem_ && GameMode::isMaster())
    126         {
    127             for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++)
    128                 if (this->fire_ & WeaponSystem::getFiremodeMask(firemode))
    129                     this->weaponSystem_->fire(firemode);
    130 
    131             if (this->bReload_)
    132                 this->weaponSystem_->reload();
    133         }
    134 
    135         this->fire_ = this->firehack_;
    136         this->firehack_ = 0x0;
     130//        if (this->weaponSystem_ && GameMode::isMaster())
     131//        {
     132//            for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++)
     133//                if (this->fire_ & WeaponSystem::getFiremodeMask(firemode))
     134//                    this->weaponSystem_->fire(firemode);
     135//
     136//            if (this->bReload_)
     137//                this->weaponSystem_->reload();
     138//        }
     139//
     140//        this->fire_ = this->firehack_;
     141//        this->firehack_ = 0x0;
    137142        this->bReload_ = false;
    138143
    139         if (this->health_ <= 0)
     144        if (GameMode::isMaster())
     145          if (this->health_ <= 0)
    140146            this->death();
    141147    }
     
    263269    void Pawn::fire(unsigned int firemode)
    264270    {
    265         this->firehack_ |= WeaponSystem::getFiremodeMask(firemode);
     271        this->doFire(firemode);
     272    }
     273
     274    void Pawn::doFire(uint8_t firemode)
     275    {
     276        if(GameMode::isMaster())
     277        {
     278            if (this->weaponSystem_)
     279                this->weaponSystem_->fire(firemode);
     280        }
     281        else
     282        {
     283            callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, ((uint8_t)firemode));
     284            if (this->weaponSystem_)
     285                this->weaponSystem_->fire(firemode);
     286        }
    266287    }
    267288
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h

    r3073 r3084  
    7979            virtual void fire(unsigned int firemode);
    8080            virtual void reload();
     81            virtual void doFire(uint8_t firemode);
    8182            virtual void postSpawn();
    8283
Note: See TracChangeset for help on using the changeset viewer.