Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9406 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Jul 24, 2006, 11:09:47 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

Location:
trunk/src/lib
Files:
8 deleted
167 edited
24 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/Makefile.am

    r8367 r9406  
    3131        collision_detection \
    3232        collision_reaction \
     33        gui \
    3334        network \
    3435        parser \
    3536        shell \
    36         script_engine \
    37         gui
     37        script_engine
  • trunk/src/lib/collision_detection/aabb.cc

    r8724 r9406  
    1919#include "vector.h"
    2020
    21 using namespace std;
     21
    2222
    2323
  • trunk/src/lib/collision_detection/aabb_tree_node.cc

    r8724 r9406  
    3434
    3535
    36 using namespace std;
     36
    3737
    3838
     
    262262    const int* triangleIndexes, int length)
    263263{
    264 
    265   Vector         axis[3];                            //!< the references to the obb axis
    266264  Matrix         covMat(  box.covarianceMatrix  );   //!< covariance matrix (in the matrix dataform)
    267265
     
    501499  if( this->overlapTest(this->bvElement, treeNode->bvElement, nodeA, nodeB))
    502500  {
    503     PRINTF(5)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClassName(), nodeB->getClassName(), this->nodeLeft, this->nodeRight);
     501    PRINTF(5)("collision @ lvl %i, object %s::%s vs. %s::%s, (%p, %p)\n", this->depth, nodeA->getClassCName(), nodeA->getCName(), nodeB->getClassCName(), nodeA->getCName(), this->nodeLeft, this->nodeRight);
    504502
    505503
  • trunk/src/lib/collision_detection/bounding_sphere.cc

    r7711 r9406  
    1818#include "bounding_sphere.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/collision_detection/bounding_volume.cc

    r7711 r9406  
    1818#include "bounding_volume.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/collision_detection/bv_tree.cc

    r7711 r9406  
    1818#include "bv_tree.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/collision_detection/bv_tree_node.cc

    r7711 r9406  
    1818#include "bv_tree_node.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/collision_detection/cd_engine.cc

    r9110 r9406  
    3434#include "bsp_entity.h"
    3535
    36 using namespace std;
     36
    3737
    3838
     
    4545
    4646  this->bAbordOnFirstCollision = false;
    47  
     47
    4848  this->terrain = NULL;
    4949}
     
    8686        if( likely((*entity2) != this->terrain))
    8787        {
    88           PRINTF(5)("checking object %s (%s) against %s (%s)\n", (*entity1)->getClassName(), (*entity1)->getName(), (*entity2)->getClassName(), (*entity2)->getName());
     88          PRINTF(5)("checking object %s (%s) against %s (%s)\n",
     89            (*entity1)->getClassCName(), (*entity1)->getCName(), (*entity2)->getClassCName(), (*entity2)->getCName());
    8990          tree = (*entity1)->getOBBTree();
    9091          if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL)
     
    113114      for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
    114115      {
    115 //         PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassName());
     116//         PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassCName());
    116117        (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator);
    117118      }
  • trunk/src/lib/collision_detection/obb.cc

    r7711 r9406  
    1919#include "vector.h"
    2020
    21 using namespace std;
     21
    2222
    2323
  • trunk/src/lib/collision_detection/obb_tree.cc

    r9235 r9406  
    2525#include "p_node.h"
    2626
    27 using namespace std;
     27
    2828
    2929
  • trunk/src/lib/collision_detection/obb_tree_node.cc

    r9235 r9406  
    3333
    3434
    35 using namespace std;
     35
    3636
    3737
     
    434434    }
    435435  }
     436  delete [] triangleCenter;
    436437  PRINTF(4)("\nPartition1: got \t%i Vertices \nPartition2: got \t%i Vertices\n", partition1.size(), partition2.size());
    437438
     
    476477    return;
    477478
    478   float distanceMax = this->bvElement->radius + ((OBBTreeNode*)treeNode)->bvElement->radius;
    479   float distance = fabs((nodeA->getAbsCoor() - nodeB->getAbsCoor()).len());
     479//   float distanceMax = this->bvElement->radius + ((OBBTreeNode*)treeNode)->bvElement->radius;
     480//   float distance = fabs((nodeA->getAbsCoor() - nodeB->getAbsCoor()).len());
    480481
    481482
    482483//   if( distance < distanceMax)
    483 //     PRINTF(0)(" %s (%s: group %i) vs %s (%s: group %i): distanceMax: %f, distance: %f\n", nodeA->getClassName(), nodeA->getName(), nodeA->getOMListNumber(), nodeB->getClassName(),  nodeB->getName(), nodeB->getOMListNumber(), distanceMax, distance);
     484//     PRINTF(0)(" %s (%s: group %i) vs %s (%s: group %i): distanceMax: %f, distance: %f\n", nodeA->getClassCName(), nodeA->getName(), nodeA->getOMListNumber(), nodeB->getClassCName(),  nodeB->getName(), nodeB->getOMListNumber(), distanceMax, distance);
    484485
    485486
     
    504505  if( this->overlapTest(this->bvElement, treeNode->bvElement, nodeA, nodeB))
    505506  {
    506     PRINTF(5)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClassName(), nodeB->getClassName(), this->nodeLeft, this->nodeRight);
     507    PRINTF(5)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClassCName(), nodeB->getClassCName(), this->nodeLeft, this->nodeRight);
    507508
    508509
     
    806807      if( this->obbTree->getOwner() != NULL)
    807808      {
    808         PRINTF(4)("debug poly draw: depth: %i, mode: %i, entity-name: %s, class: %s\n", depth, drawMode, this->obbTree->getOwner()->getName(), this->obbTree->getOwner()->getClassName());
     809        PRINTF(4)("debug poly draw: depth: %i, mode: %i, entity-name: %s, class: %s\n", depth, drawMode, this->obbTree->getOwner()->getCName(), this->obbTree->getOwner()->getClassCName());
    809810      }
    810811      else
  • trunk/src/lib/collision_reaction/collision.cc

    r8190 r9406  
    1919#include "debug.h"
    2020
    21 using namespace std;
     21
    2222
    2323
  • trunk/src/lib/collision_reaction/collision_event.cc

    r8190 r9406  
    1919#include "debug.h"
    2020
    21 using namespace std;
     21
    2222
    2323
  • trunk/src/lib/collision_reaction/collision_handle.cc

    r9235 r9406  
    2929#include "debug.h"
    3030
    31 using namespace std;
     31
    3232
    3333
     
    178178
    179179 c->registerCollisionEvent(collisionEvent);
    180  PRINTF(5)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassName(), collisionEvent->getEntityB()->getClassName());
     180 PRINTF(5)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassCName(), collisionEvent->getEntityB()->getClassCName());
    181181}
    182182
     
    204204
    205205  // collision reaction calculations (for every collision there will be a reaction)
    206   vector<Collision*>::iterator it = this->collisionList.begin();
     206  std::vector<Collision*>::iterator it = this->collisionList.begin();
    207207  for(; it < this->collisionList.end(); it++) {
    208208    if( !(*it)->isDispatched())
     
    227227bool CollisionHandle::filterCollisionEvent(CollisionEvent* collisionEvent)
    228228{
    229   vector<long>::iterator it = this->targetList.begin();
     229  std::vector<long>::iterator it = this->targetList.begin();
    230230  for(; it < this->targetList.end(); it++)
    231231  {
    232232//     if(collisionEvent->getEntityB()->isA(CL_AIMING_SYSTEM) || collisionEvent->getEntityA()->isA(CL_AIMING_SYSTEM))
    233233//     {
    234 //        PRINTF(0)("I am: %s colliding with: %s\n", owner->getClassName(), collisionEvent->getEntityB()->getClassName(), *it);
     234//        PRINTF(0)("I am: %s colliding with: %s\n", owner->getClassCName(), collisionEvent->getEntityB()->getClassCName(), *it);
    235235//        if( collisionEvent->getEntityA() == this->owner) {
    236 //          PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassName(),
    237 //          collisionEvent->getEntityB()->getClassName(), *it);
     236//          PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassCName(),
     237//          collisionEvent->getEntityB()->getClassCName(), *it);
    238238//          if( collisionEvent->getEntityB()->isA((ClassID)(*it))) {
    239 //            PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    240 //            collisionEvent->getEntityB()->getClassName(), *it);
     239//            PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
     240//            collisionEvent->getEntityB()->getClassCName(), *it);
    241241//             }
    242242//        }
    243243//        else {
    244 //          PRINTF(0)("I am not owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassName(),
    245 //          collisionEvent->getEntityB()->getClassName(), *it);
     244//          PRINTF(0)("I am not owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassCName(),
     245//          collisionEvent->getEntityB()->getClassCName(), *it);
    246246//          if( collisionEvent->getEntityA()->isA((ClassID)(*it))) {
    247 //            PRINTF(0)("I'm not owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    248 //            collisionEvent->getEntityA()->getClassName(), *it);
     247//            PRINTF(0)("I'm not owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
     248//            collisionEvent->getEntityA()->getClassCName(), *it);
    249249//             }
    250250//        }
     
    254254    if( collisionEvent->getEntityA() == this->owner) {
    255255      if( collisionEvent->getEntityB()->isA((ClassID)(*it))) {
    256         PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    257                   collisionEvent->getEntityB()->getClassName(), *it);
     256        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
     257                  collisionEvent->getEntityB()->getClassCName(), *it);
    258258        return true; }
    259259    }
    260260    else {
    261261      if( collisionEvent->getEntityA()->isA((ClassID)(*it))) {
    262         PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    263                   collisionEvent->getEntityA()->getClassName(), *it);
     262        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
     263                  collisionEvent->getEntityA()->getClassCName(), *it);
    264264      return true; }
    265265    }
     
    276276bool CollisionHandle::filterCollision(Collision* collision)
    277277{
    278   vector<long>::iterator it = this->targetList.begin();
     278  std::vector<long>::iterator it = this->targetList.begin();
    279279  for(; it < this->targetList.end(); it++)
    280280  {
     
    282282//     if(collision->getEntityB()->isA(CL_AIMING_SYSTEM) || collision->getEntityA()->isA(CL_AIMING_SYSTEM))
    283283//     {
    284 //       PRINTF(0)("Shared!!! I am: %s colliding with: %s\n", owner->getClassName(), collision->getEntityB()->getClassName(), *it);
     284//       PRINTF(0)("Shared!!! I am: %s colliding with: %s\n", owner->getClassCName(), collision->getEntityB()->getClassCName(), *it);
    285285//       if( collision->getEntityA() == this->owner) {
    286 //         PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassName(),
    287 //         collision->getEntityB()->getClassName(), *it);
     286//         PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassCName(),
     287//         collision->getEntityB()->getClassCName(), *it);
    288288//         if( collision->getEntityB()->isA((ClassID)(*it))) {
    289 //           PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    290 //           collision->getEntityB()->getClassName(), *it);
     289//           PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
     290//           collision->getEntityB()->getClassCName(), *it);
    291291//         }
    292292//       }
    293293//       else {
    294 //         PRINTF(0)("I'm not owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassName(),
    295 //         collision->getEntityB()->getClassName(), *it);
     294//         PRINTF(0)("I'm not owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClassCName(),
     295//         collision->getEntityB()->getClassCName(), *it);
    296296//         if( collision->getEntityA()->isA((ClassID)(*it))) {
    297 //           PRINTF(0)("I'm not owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    298 //           collision->getEntityA()->getClassName(), *it);
     297//           PRINTF(0)("I'm not owner -> I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
     298//           collision->getEntityA()->getClassCName(), *it);
    299299//         }
    300300//       }
  • trunk/src/lib/collision_reaction/collision_reaction.cc

    r8190 r9406  
    1919
    2020
    21 using namespace std;
     21
    2222
    2323
  • trunk/src/lib/collision_reaction/cr_engine.cc

    r8490 r9406  
    2727#include "debug.h"
    2828
    29 using namespace std;
     29
    3030
    3131
     
    6161  this->reset();
    6262
    63   vector<Collision*>::iterator it1 = this->collisionsUnused.begin();
     63  std::vector<Collision*>::iterator it1 = this->collisionsUnused.begin();
    6464  for(; it1 < this->collisionsUnused.end(); it1++)
    6565    delete *it1;
    66   vector<CollisionEvent*>::iterator it2 = this->collisionEventsUnused.begin();
     66  std::vector<CollisionEvent*>::iterator it2 = this->collisionEventsUnused.begin();
    6767  for(; it2 < this->collisionEventsUnused.end(); it2++)
    6868    delete *it2;
     
    9292  // first clear all CollisionHandles
    9393
    94   vector<CollisionHandle*>::iterator it = this->collisionHandles.begin();
     94  std::vector<CollisionHandle*>::iterator it = this->collisionHandles.begin();
    9595  for(; it < this->collisionHandles.end(); it++)
    9696  {
     
    159159void CREngine::flushCollisions()
    160160{
    161   vector<Collision*>::iterator it1 = this->collisionsUsed.begin();
     161  std::vector<Collision*>::iterator it1 = this->collisionsUsed.begin();
    162162  for(; it1 < this->collisionsUsed.end(); it1++)
    163163    this->collisionsUnused.push_back(*it1);
    164164
    165   vector<CollisionEvent*>::iterator it2 = this->collisionEventsUsed.begin();
     165  std::vector<CollisionEvent*>::iterator it2 = this->collisionEventsUsed.begin();
    166166  for(; it2 < this->collisionEventsUsed.end(); it2++)
    167167    this->collisionEventsUnused.push_back(*it2);
  • trunk/src/lib/collision_reaction/cr_object_damage.cc

    r9235 r9406  
    2626#include "debug.h"
    2727
    28 using namespace std;
     28
    2929
    3030
     
    5757
    5858  PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n",
    59             collision->getEntityA()->getClassName(),
    60             collision->getEntityB()->getClassName());
     59            collision->getEntityA()->getClassCName(),
     60            collision->getEntityB()->getClassCName());
    6161
    6262  // the collision damage been dealed by the entity
     
    6464    damage = collision->getEntityB()->getDamage();
    6565    collision->getEntityA()->hit(damage, collision->getEntityB());
    66     PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
     66    PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassCName());
    6767  }
    6868
     
    7070    damage = collision->getEntityA()->getDamage();
    7171    collision->getEntityB()->hit(damage, collision->getEntityA());
    72     PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
     72    PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassCName());
    7373  }
    7474
  • trunk/src/lib/collision_reaction/cr_physics_full_walk.cc

    r9235 r9406  
    3333#include "cr_defs.h"
    3434
    35 using namespace std;
     35
    3636
    3737
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r9235 r9406  
    3333#include "cr_defs.h"
    3434
    35 using namespace std;
     35
    3636
    3737
  • trunk/src/lib/coord/p_node.cc

    r9235 r9406  
    2121#include "class_list.h"
    2222
     23#include "netdefs.h"
     24
    2325#include <algorithm>
    2426#include "compiler.h"
     
    2729#include "glincl.h"
    2830#include "color.h"
    29 
    30 #include "synchronizeable.h"
    3131
    3232/**
     
    7777PNode::~PNode ()
    7878{
    79   PRINTF(4)("delete %s::%s\n", this->getClassName(), this->getName());
     79  PRINTF(4)("delete %s::%s\n", this->getClassCName(), this->getCName());
    8080  // remove the Node, delete it's children (if required).
    8181  std::list<PNode*>::iterator deleteNode;
     
    9191      {
    9292        PRINTF(4)("%s::%s deletes %s::%s\n",
    93                   this->getClassName(), this->getName(),
    94                   (*deleteNode)->getClassName(), (*deleteNode)->getName());
     93                  this->getClassCName(), this->getCName(),
     94                  (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    9595        delete (*deleteNode);
    9696      }
     
    9898      {
    9999        PRINTF(4)("%s::%s reparents %s::%s\n",
    100                   this->getClassName(), this->getName(),
    101                   (*deleteNode)->getClassName(), (*deleteNode)->getName());
     100                  this->getClassCName(), this->getCName(),
     101                  (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    102102        (*deleteNode)->reparent();
    103103      }
     
    106106    {
    107107      PRINTF(4)("%s::%s deletes PNode: %s::%s\n",
    108                 this->getClassName(), this->getName(),
    109                 (*deleteNode)->getClassName(), (*deleteNode)->getName());
     108                this->getClassCName(), this->getCName(),
     109                (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    110110      delete (*deleteNode);
    111111    }
     
    509509  {
    510510    PRINTF(1)("Tried to reparent to own child '%s::%s' to '%s::%s'.\n",
    511               this->getClassName(), this->getName(), child->getClassName(), child->getName());
     511              this->getClassCName(), this->getCName(), child->getClassCName(), child->getCName());
    512512    child->parent = NULL;
    513513    child->parentCoorChanged();
     
    519519{
    520520  PNode* tmpNode = node->parent;
    521   printf("entering seek PNode loop for name: %s, uid: %i\n", node->getName(), node->getUniqueID());
     521  printf("entering seek PNode loop for name: %s, uid: %i\n", node->getCName(), node->getUniqueID());
    522522  if(tmpNode)
    523     printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
     523    printf("  @node name: %s, uid: %d\n", tmpNode->getCName(), tmpNode->getUniqueID());
    524524  while( tmpNode != NULL && tmpNode->getUniqueID() == NET_UID_UNASSIGNED)
    525525  {
    526     printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
     526    printf("  @node name: %s, uid: %d\n", tmpNode->getCName(), tmpNode->getUniqueID());
    527527    tmpNode = tmpNode->parent;
    528528  }
     
    604604        (*reparenter)->parentMode & PNODE_REPARENT_ON_PARENTS_REMOVE)
    605605    {
    606       printf("TEST----------------%s ---- %s\n", this->getClassName(), (*reparenter)->getClassName());
     606      printf("TEST----------------%s ---- %s\n", this->getClassCName(), (*reparenter)->getClassCName());
    607607      (*reparenter)->reparent();
    608       printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClassName(),(*reparenter)->getParent()->getName());
     608      printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClassCName(),(*reparenter)->getParent()->getCName());
    609609    }
    610610  }
     
    628628  else
    629629    PRINTF(2)("Not Found PNode's (%s::%s) new Parent by Name: %s\n",
    630         this->getClassName(), this->getName(), parentName.c_str());
     630        this->getClassCName(), this->getCName(), parentName.c_str());
    631631}
    632632
     
    785785          delete this->toCoordinate;
    786786          this->toCoordinate = NULL;
    787           PRINTF(5)("SmoothMove of %s finished\n", this->getName());
     787          PRINTF(5)("SmoothMove of %s finished\n", this->getCName());
    788788        }
    789789      }
     
    793793        if (unlikely (shiftLen >= 1.0))
    794794          shiftLen = 1.0;
    795         //printf("%s::%s %f\n", this->getClassName(), this->getName(), this->toStep );
     795        //printf("%s::%s %f\n", this->getClassCName(), this->getName(), this->toStep );
    796796        Quaternion rotQuat = Quaternion::quatSlerp(this->relDirection,*this->toDirection, shiftLen);
    797797        if (this->relDirection.distance(rotQuat) > PNODE_ITERATION_DELTA)
     
    804804          delete this->toDirection;
    805805          this->toDirection = NULL;
    806           PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
     806          PRINTF(5)("SmoothRotate of %s finished\n", this->getCName());
    807807          this->bRelDirChanged = true;
    808808        }
     
    812812      this->lastAbsCoordinate = this->absCoordinate;
    813813
    814       PRINTF(5)("PNode::update - '%s::%s' - (%f, %f, %f)\n", this->getClassName(), this->getName(),
     814      PRINTF(5)("PNode::update - '%s::%s' - (%f, %f, %f)\n", this->getClassCName(), this->getCName(),
    815815                this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    816816
     
    840840    else // Nodes without a Parent are handled faster :: MOST LIKELY THE NULLPARENT
    841841    {
    842       PRINTF(4)("update ParentLess Node (%s::%s) - (%f, %f, %f)\n", this->getClassName(), this->getName(),
     842      PRINTF(4)("update ParentLess Node (%s::%s) - (%f, %f, %f)\n", this->getClassCName(), this->getCName(),
    843843                this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    844844      if (this->bRelCoorChanged)
     
    913913
    914914  PRINT(0)("PNode(%s::%s) - absCoord: (%0.2f, %0.2f, %0.2f), relCoord(%0.2f, %0.2f, %0.2f), direction(%0.2f, %0.2f, %0.2f) - %s - %d childs\n",
    915            this->getClassName(),
    916            this->getName(),
     915           this->getClassCName(),
     916           this->getCName(),
    917917           this->absCoordinate.x,
    918918           this->absCoordinate.y,
     
    10901090{
    10911091  Synchronizeable::varChangeHandler( id );
    1092  
     1092
    10931093  if ( std::find( id.begin(), id.end(), relCoordinate_handle ) != id.end() )
    10941094  {
  • trunk/src/lib/coord/p_node.h

    r8711 r9406  
    2020
    2121#include "base_object.h"
    22 #include "stdincl.h"
    2322#include "synchronizeable.h"
    2423
     
    112111  /** @returns the absolute position */
    113112  inline const Vector& getLastAbsCoor () const { return this->lastAbsCoordinate; };
    114  
     113
    115114  void shiftCoor (const Vector& shift);
    116115  void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); };
  • trunk/src/lib/event/event_handler.cc

    r9240 r9406  
    207207      else
    208208      {
    209         PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassName(), el->getName(), i, eventType);
     209        PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassCName(), el->getCName(), i, eventType);
    210210      }
    211211  }
     
    216216    else
    217217    {
    218       PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassName(), el->getName(), state, eventType);
     218      PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassCName(), el->getCName(), state, eventType);
    219219    }
    220220  }
     
    463463  {
    464464    PRINT(4)("=  Event dispatcher msg: This event has been consumed\n");
    465     PRINT(4)("=  Got Event nr %i, for state %i (%d registered) to %s::%s(%p)\n", event.type, i, state, this->listeners[state][event.type][i]->getClassName(), this->listeners[state][event.type][i]->getName(), this->listeners[state][event.type][i]);
     465    PRINT(4)("=  Got Event nr %i, for state %i (%d registered) to %s::%s(%p)\n",
     466      event.type,
     467      i, state,
     468      this->listeners[state][event.type][i]->getClassCName(),
     469      this->listeners[state][event.type][i]->getCName(),
     470      this->listeners[state][event.type][i]);
    466471    PRINT(4)("=======================================================\n");
    467472    this->listeners[state][event.type][i]->process(event);
     
    563568        EVToKeyName(j).c_str(), j,
    564569        ELStateToString((elState)i).c_str(), i,
    565         this->listeners[i][j][evl]->getName(), this->listeners[i][j][evl]);
     570        this->listeners[i][j][evl]->getCName(), this->listeners[i][j][evl]);
    566571  }
    567572  PRINT(0)("============================EH=\n");
  • trunk/src/lib/event/key_mapper.cc

    r8724 r9406  
    3131
    3232
    33 using namespace std;
     33
    3434
    3535
  • trunk/src/lib/graphics/effects/atmospheric_engine.cc

    r8495 r9406  
    2525
    2626
    27 using namespace std;
     27
    2828
    2929/**
     
    116116        std::list<BaseObject*>::const_iterator it;
    117117        for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) {
    118             /*      printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());*/
     118            /*      printf("%s::%s \n", (*it)->getClassCName(), (*it)->getName());*/
    119119            dynamic_cast<WeatherEffect*>(*it)->tick(dt);
    120120        }
  • trunk/src/lib/graphics/effects/cloud_effect.cc

    r9235 r9406  
    4040float     CloudEffect::fadeTime;
    4141
    42 using namespace std;
     42
    4343
    4444SHELL_COMMAND(activate, CloudEffect, activateCloud);
  • trunk/src/lib/graphics/effects/fog_effect.cc

    r9235 r9406  
    2828SHELL_COMMAND(fadeout, FogEffect, fadeOutFog);
    2929
    30 using namespace std;
     30
    3131
    3232CREATE_SCRIPTABLE_CLASS(FogEffect, CL_FOG_EFFECT,
  • trunk/src/lib/graphics/effects/graphics_effect.cc

    r8495 r9406  
    2323
    2424
    25 using namespace std;
     25
    2626
    2727
  • trunk/src/lib/graphics/effects/lense_flare.cc

    r9006 r9406  
    3434
    3535
    36 using namespace std;
     36
    3737
    3838
  • trunk/src/lib/graphics/effects/lightning_effect.cc

    r9235 r9406  
    3434SHELL_COMMAND(deactivate, LightningEffect, deactivateLightning);
    3535
    36 using namespace std;
     36
    3737
    3838CREATE_SCRIPTABLE_CLASS(LightningEffect, CL_LIGHTNING_EFFECT,
     
    130130
    131131    //load sound
    132     if (this->thunderBuffer != NULL)
    133         ResourceManager::getInstance()->unload(this->thunderBuffer);
    134132    this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/thunder.wav", WAV);
    135133
  • trunk/src/lib/graphics/effects/rain_effect.cc

    r9235 r9406  
    3939SHELL_COMMAND(stopraining, RainEffect, stopRaining);
    4040
    41 using namespace std;
     41
    4242
    4343CREATE_SCRIPTABLE_CLASS(RainEffect, CL_RAIN_EFFECT,
  • trunk/src/lib/graphics/effects/snow_effect.cc

    r9235 r9406  
    11/*
    2         orxonox - the future of 3D-vertical-scrollers
    3 
    4         Copyright (C) 2004 orx
    5 
    6         This program is free software; you can redistribute it and/or modify
    7         it under the terms of the GNU General Public License as published by
    8         the Free Software Foundation; either version 2, or (at your option)
    9         any later version.
     2        orxonox - the future of 3D-vertical-scrollers
     3
     4        Copyright (C) 2004 orx
     5
     6        This program is free software; you can redistribute it and/or modify
     7        it under the terms of the GNU General Public License as published by
     8        the Free Software Foundation; either version 2, or (at your option)
     9        any later version.
    1010
    1111### File Specific:
    12         main-programmer: hdavid, amaechler
     12        main-programmer: hdavid, amaechler
    1313*/
    1414
     
    3535SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow);
    3636
    37 using namespace std;
    3837
    3938CREATE_SCRIPTABLE_CLASS(SnowEffect, CL_SNOW_EFFECT,
     
    4645SnowEffect::SnowEffect(const TiXmlElement* root)
    4746{
    48         this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
    49 
    50         this->init();
    51 
    52         if (root != NULL)
    53                 this->loadParams(root);
    54 
    55         //load wind sound
    56         if (this->snowWindForce >= 1) {
    57                 if (this->windBuffer != NULL)
    58                         ResourceManager::getInstance()->unload(this->windBuffer);
    59           this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
    60         }
     47        this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
     48
     49        this->init();
     50
     51        if (root != NULL)
     52                this->loadParams(root);
     53
     54        this->windBuffer = NULL;
     55        //load wind sound
     56        if (this->snowWindForce >= 1) {
     57          this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
     58        }
    6159
    6260  if(snowActivate) {
    63                 this->activate();
     61                this->activate();
    6462    SnowEffect::snowParticles->precache((int) this->snowLife);
    6563  }
     
    6967SnowEffect::~SnowEffect()
    7068{
    71         this->deactivate();
     69        this->deactivate();
    7270}
    7371
     
    7674void SnowEffect::loadParams(const TiXmlElement* root)
    7775{
    78         WeatherEffect::loadParams(root);
    79 
    80         LoadParam(root, "numParticles", this, SnowEffect, numParticles);
    81         LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
    82         LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
    83         LoadParam(root, "radius", this, SnowEffect, radius);
    84         LoadParam(root, "mass", this, SnowEffect, mass);
    85         LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
    86         LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
    87         LoadParam(root, "wind", this, SnowEffect, wind);
    88         LoadParam(root, "size", this, SnowEffect, size);
    89         LoadParam(root, "coord", this, SnowEffect, coord);
     76        WeatherEffect::loadParams(root);
     77
     78        LoadParam(root, "numParticles", this, SnowEffect, numParticles);
     79        LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
     80        LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
     81        LoadParam(root, "radius", this, SnowEffect, radius);
     82        LoadParam(root, "mass", this, SnowEffect, mass);
     83        LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
     84        LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
     85        LoadParam(root, "wind", this, SnowEffect, wind);
     86        LoadParam(root, "size", this, SnowEffect, size);
     87        LoadParam(root, "coord", this, SnowEffect, coord);
    9088  LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor);
    9189  LoadParam(root, "skycolor", this, SnowEffect, setSkyColor);
    9290  LoadParam(root, "fadetime", this, SnowEffect, setFadeTime);
    9391
    94         LOAD_PARAM_START_CYCLE(root, element);
    95         {
    96                 LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
    97         }
    98         LOAD_PARAM_END_CYCLE(element);
     92        LOAD_PARAM_START_CYCLE(root, element);
     93        {
     94                LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
     95        }
     96        LOAD_PARAM_END_CYCLE(element);
    9997}
    10098
    10199void SnowEffect::init()
    102100{
    103         this->emitter = new PlaneEmitter();
    104 
    105         // Default values
    106         this->snowActivate = false;
    107         this->snowMove = false;
    108         this->particles = 12000;
    109         this->texture = "maps/snow_flake_01_32x32.png";
    110         this->snowLife = 8;
    111         this->randomLife = 2;
    112         this->snowRadius = 3.5;
    113         this->randomRadius = 1;
    114         this->snowMass = 1.0;
    115         this->randomMass = 0.3;
    116         this->rate = 900;
    117         this->velocity = -100;
    118         this->randomVelocity = 5;
    119         this->angle = 0.5;
    120         this->randomAngle = 0.2;
    121         this->alpha = 0.5;
    122         this->snowSize = Vector2D(2500, 2500);
    123         this->snowCoord = Vector(100,450,400);
    124         this->snowWindForce = 1;
    125  
     101        this->emitter = new PlaneEmitter();
     102
     103        // Default values
     104        this->snowActivate = false;
     105        this->snowMove = false;
     106        this->particles = 12000;
     107        this->texture = "maps/snow_flake_01_32x32.png";
     108        this->snowLife = 8;
     109        this->randomLife = 2;
     110        this->snowRadius = 3.5;
     111        this->randomRadius = 1;
     112        this->snowMass = 1.0;
     113        this->randomMass = 0.3;
     114        this->rate = 900;
     115        this->velocity = -100;
     116        this->randomVelocity = 5;
     117        this->angle = 0.5;
     118        this->randomAngle = 0.2;
     119        this->alpha = 0.5;
     120        this->snowSize = Vector2D(2500, 2500);
     121        this->snowCoord = Vector(100,450,400);
     122        this->snowWindForce = 1;
     123
    126124  this->fadeTime = 10;
    127125  this->cloudColor = Vector(0.2f, 0.2f, 0.2f);
     
    131129void SnowEffect::activate()
    132130{
    133         PRINTF(3)("Activating SnowEffect\n");
    134 
    135         this->snowActivate = true;
    136 
    137         SnowEffect::snowParticles = new SpriteParticles(particles);
    138         SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
    139         SnowEffect::snowParticles->setMaterialTexture(texture);
    140         SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
    141         SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
    142         SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
    143         SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
    144         SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
    145         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    146         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    147         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    148 
    149         this->emitter->setSystem(SnowEffect::snowParticles);
    150 
    151         this->emitter->setRelCoor(snowCoord);
    152         this->emitter->setEmissionRate(rate);
    153         this->emitter->setEmissionVelocity(velocity, randomVelocity);
    154         this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
    155         this->emitter->setSize(snowSize);
     131        PRINTF(3)("Activating SnowEffect\n");
     132
     133        this->snowActivate = true;
     134
     135        SnowEffect::snowParticles = new SpriteParticles(particles);
     136        SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
     137        SnowEffect::snowParticles->setMaterialTexture(texture);
     138        SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
     139        SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
     140        SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
     141        SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
     142        SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
     143        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     144        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     145        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     146
     147        this->emitter->setSystem(SnowEffect::snowParticles);
     148
     149        this->emitter->setRelCoor(snowCoord);
     150        this->emitter->setEmissionRate(rate);
     151        this->emitter->setEmissionVelocity(velocity, randomVelocity);
     152        this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
     153        this->emitter->setSize(snowSize);
    156154
    157155  if (this->snowWindForce != 0)
    158156    this->soundSource.play(this->windBuffer, 0.1f * this->snowWindForce, true);
    159  
     157
    160158  // Store cloud- and sky color before the snow
    161159  this->oldCloudColor = CloudEffect::cloudColor;
     
    171169void SnowEffect::deactivate()
    172170{
    173         PRINTF(3)("Deactivating SnowEffect\n");
    174 
    175         this->snowActivate = false;
    176         this->emitter->setSystem(NULL);
    177 
    178         if (this->windBuffer != NULL)
    179                 ResourceManager::getInstance()->unload(this->windBuffer);
    180  
     171        PRINTF(3)("Deactivating SnowEffect\n");
     172
     173        this->snowActivate = false;
     174        this->emitter->setSystem(NULL);
     175
     176        if (this->windBuffer != NULL)
     177                ResourceManager::getInstance()->unload(this->windBuffer);
     178
    181179  // Restore the old cloud- and sky color
    182180  CloudEffect::changeCloudColor(this->oldCloudColor, this->fadeTime);
     
    186184void SnowEffect::draw() const
    187185{
    188         if (!this->snowActivate)
    189                 return;
     186        if (!this->snowActivate)
     187                return;
    190188}
    191189
    192190void SnowEffect::tick(float dt)
    193191{
    194         if (!this->snowActivate)
    195                 return;
    196 
    197         /*
    198         float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
    199 
    200         if(activated)
    201         {
    202         if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
    203                         this->deactivate();
    204         else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
    205         this->alpha = 0.15;
    206         else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
    207         this->alpha = 0.25;
    208         else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
    209         this->alpha = 0.4;
    210 
    211         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    212         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    213         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    214         }
    215         else
    216         {
    217         if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
    218         this->activate();
    219         if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
    220         this->alpha = 0.25;
    221         else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
    222         this->alpha = 0.4;
    223         else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
    224         this->alpha = 0.5;
    225 
    226         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    227         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    228         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    229         }*/
    230 
    231         if (this->snowMove) {
    232                 this->snowCoord = State::getCameraNode()->getAbsCoor();
    233                 this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
    234         }
    235 }
     192        if (!this->snowActivate)
     193                return;
     194
     195        /*
     196        float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
     197
     198        if(activated)
     199        {
     200        if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
     201                        this->deactivate();
     202        else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
     203        this->alpha = 0.15;
     204        else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
     205        this->alpha = 0.25;
     206        else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
     207        this->alpha = 0.4;
     208
     209        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     210        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     211        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     212        }
     213        else
     214        {
     215        if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
     216        this->activate();
     217        if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
     218        this->alpha = 0.25;
     219        else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
     220        this->alpha = 0.4;
     221        else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
     222        this->alpha = 0.5;
     223
     224        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     225        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     226        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     227        }*/
     228
     229        if (this->snowMove) {
     230                this->snowCoord = State::getCameraNode()->getAbsCoor();
     231                this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
     232        }
     233}
  • trunk/src/lib/graphics/effects/snow_effect.h

    r9235 r9406  
    101101
    102102private:
    103     int         particles;
     103    int               particles;
    104104    std::string       texture;
    105     float       snowLife, randomLife;
    106     float       snowRadius, randomRadius;
    107     float       snowMass, randomMass;
    108     float         rate;
    109     float         velocity, randomVelocity;
    110     float         angle, randomAngle;
    111     float         alpha;
    112     float         fadeTime;
    113     Vector        snowCoord;
    114     Vector2D      snowSize;
    115     int       snowWindForce;
     105    float             snowLife, randomLife;
     106    float             snowRadius, randomRadius;
     107    float             snowMass, randomMass;
     108    float             rate;
     109    float             velocity, randomVelocity;
     110    float             angle, randomAngle;
     111    float             alpha;
     112    float             fadeTime;
     113    Vector            snowCoord;
     114    Vector2D          snowSize;
     115    int               snowWindForce;
    116116
    117     bool        snowMove;
    118     bool        snowActivate;
     117    bool              snowMove;
     118    bool              snowActivate;
    119119
    120120    PlaneEmitter*     emitter;
    121121
    122122    static SpriteParticles*   snowParticles;
    123     OrxSound::SoundSource   soundSource;
     123    OrxSound::SoundSource     soundSource;
    124124    OrxSound::SoundBuffer*    windBuffer;
    125125
    126     Vector oldSkyColor;
    127     Vector oldCloudColor;
    128     Vector skyColor;
    129     Vector cloudColor;
     126    Vector            oldSkyColor;
     127    Vector            oldCloudColor;
     128    Vector            skyColor;
     129    Vector            cloudColor;
    130130};
    131131
  • trunk/src/lib/graphics/effects/sun_effect.cc

    r8793 r9406  
    2121
    2222
    23 using namespace std;
     23
    2424
    2525
  • trunk/src/lib/graphics/effects/volfog_effect.cc

    r9006 r9406  
    4747
    4848
    49 using namespace std;
     49
    5050
    5151CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT);
  • trunk/src/lib/graphics/effects/weather_effect.cc

    r8495 r9406  
    2121
    2222
    23 using namespace std;
     23
    2424
    2525
  • trunk/src/lib/graphics/graphics_engine.cc

    r8740 r9406  
    5050 #include "static_model.h"
    5151#endif
    52 using namespace std;
    5352
    5453SHELL_COMMAND(wireframe, GraphicsEngine, wireframe);
    55 
     54SHELL_COMMAND(fps, GraphicsEngine, toggleFPSdisplay);
    5655
    5756/**
     
    6766  this->bDisplayFPS = false;
    6867  this->bAntialiasing = false;
     68  this->bDedicated = false;
    6969  this->minFPS = 9999;
    7070  this->maxFPS = 0;
     
    164164  MultiType textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "1");
    165165  Texture::setTextureEnableState(textures.getBool());
     166
     167  // check it is a dedicated network node: so no drawings are made
     168  MultiType dedicated = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_NO_RENDER, "0");
     169  this->bDedicated = dedicated.getBool();
    166170
    167171  // searching for a usefull resolution
     
    604608}
    605609
     610/**
     611 * this draws the graphics engines graphics effecs
     612 */
    606613void GraphicsEngine::draw() const
    607614{
    608   //  LightManager::getInstance()->draw();
    609 
    610   if (this->graphicsEffects != NULL)
     615  if( this->graphicsEffects != NULL)
    611616  {
    612617    //draw the graphics effects
    613     list<BaseObject*>::const_iterator it;
     618    std::list<BaseObject*>::const_iterator it;
    614619    for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++)
    615620      dynamic_cast<GraphicsEffect*>(*it)->draw();
     
    618623  Render2D::getInstance()->draw(E2D_LAYER_BOTTOM, E2D_LAYER_ABOVE_ALL);
    619624  Shader::restoreShader();
     625}
     626
     627
     628void GraphicsEngine::toggleFPSdisplay()
     629{
     630  this->displayFPS(!this->bDisplayFPS);
    620631}
    621632
  • trunk/src/lib/graphics/graphics_engine.h

    r8518 r9406  
    4646    void toggleFullscreen();
    4747    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
     48    inline bool isDedicated() { return this->bDedicated; }
    4849
    4950    inline void setAntialiasing(bool flag) { this->bAntialiasing = flag; }
     
    7475    void drawBackgroundElements() const;
    7576    void draw() const;
     77    void toggleFPSdisplay();
    7678    void displayFPS(bool display);
    7779
     
    113115    bool                       particlesEnabled;   //!< If particles should be enabled.
    114116    bool                       bAntialiasing;      //!< true if antialiasing enabled
     117    bool                       bDedicated;         //!< true if this server is a dedicated server and should not render the scene
    115118
    116119    int                        particlesValue;     //!< How many particles
  • trunk/src/lib/graphics/importer/bsp_file.cc

    r9025 r9406  
    4040#include <vector>
    4141
    42 using namespace std;
     42
    4343
    4444
     
    9696  if (stat( name , &results) == 0) {
    9797    PRINTF(0)("BSP FILE: Datei %s gefunden. \n", name);
    98     ifstream bspFile (name, ios::in | ios::binary);
     98    std::ifstream bspFile (name, std::ios::in | std::ios::binary);
    9999    bspFile.read(this->header, 260);
    100100    PRINTF(0)("BSP FILE: BSPVersion: %i. \n", ((int *)(header) )[1]);
  • trunk/src/lib/graphics/importer/grid.cc

    r6467 r9406  
    1818#include "grid.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/graphics/importer/interactive_model.cc

    r8490 r9406  
    2020#include "glincl.h"
    2121
    22 using namespace std;
     22
    2323
    2424/**
  • trunk/src/lib/graphics/importer/material.cc

    r8761 r9406  
    8888Material::~Material()
    8989{
    90   PRINTF(5)("delete Material %s.\n", this->getName());
     90  PRINTF(5)("delete Material %s.\n", this->getCName());
    9191
    9292  if (this->ambientTexture != NULL)
     
    217217void Material::setIllum (int illum)
    218218{
    219   PRINTF(4)("setting illumModel of Material %s to %i\n", this->getName(), illum);
     219  PRINTF(4)("setting illumModel of Material %s to %i\n", this->getCName(), illum);
    220220  this->illumModel = illum;
    221221}
     
    229229void Material::setDiffuse (float r, float g, float b)
    230230{
    231   PRINTF(4)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
     231  PRINTF(4)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->getCName(), r, g, b);
    232232  this->diffuse = Color(r, g, b, this->diffuse.a() );
    233233}
     
    242242void Material::setAmbient (float r, float g, float b)
    243243{
    244   PRINTF(4)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
     244  PRINTF(4)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->getCName(), r, g, b);
    245245  this->ambient = Color(r, g, b, 1.0);
    246246}
     
    254254void Material::setSpecular (float r, float g, float b)
    255255{
    256   PRINTF(4)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
     256  PRINTF(4)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->getCName(), r, g, b);
    257257  this->specular = Color (r, g, b, 1.0);
    258258}
     
    273273void Material::setTransparency (float trans)
    274274{
    275   PRINTF(4)("setting Transparency of Material %s to %f.\n", this->getName(), trans);
     275  PRINTF(4)("setting Transparency of Material %s to %f.\n", this->getCName(), trans);
    276276  this->diffuse.a() = trans;
    277277}
     
    455455void Material::debug() const
    456456{
    457   PRINT(0)("Debug Material: %s\n", this->getName());
     457  PRINT(0)("Debug Material: %s\n", this->getCName());
    458458  PRINT(0)("illumModel: %d ; ShiniNess %f\n", this->illumModel, shininess);
    459459  PRINT(0)("diffuseColor: "); diffuse.debug();
  • trunk/src/lib/graphics/importer/md2/md2Model.cc

    r9235 r9406  
    2222
    2323
    24 using namespace std;
     24
    2525
    2626//! the model anorms
  • trunk/src/lib/graphics/importer/md3/md3_animation_cfg.cc

    r9391 r9406  
    1919#include "md3_animation.h"
    2020
    21 #include "tokenizer.h"
     21#include "substring.h"
    2222#include "helper_functions.h"
    2323
    2424#include "debug.h"
    2525
    26 #include <stdio.h>
    27 #include <stdlib.h>
    28 
    29 
    30 using namespace std;
     26
     27
     28
    3129
    3230namespace md3
     
    10098        if( inHeader && line.find("sex") == 0) {
    10199          //parse line: sex [m | f | ...]
    102           std::vector<std::string> tokens;
    103           Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
     100          SubString tokens(line, " \t\n\r\f/");
    104101
    105102          std::string sexStr = tokens.back();
     
    117114        else if( inHeader && line.find("headoffset") == 0) {
    118115          // parse line: headoffset X Y Z
    119           std::vector<std::string> tokens;
    120           Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
     116          SubString tokens(line, " \t\n\r\f/");
    121117
    122118          float z = atof(tokens.back().c_str()); tokens.pop_back();
     
    130126        else if( inHeader && line.find("footsteps") == 0) {
    131127          //parse line: footsteps [normal | mech | ...]
    132           std::vector<std::string> tokens;
    133           Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
     128          SubString tokens (line, " \t\n\r\f/");
    134129
    135130          this->footsteps = tokens.back();
     
    190185    // parse the line:
    191186    // first frame, num frames, looping frames, frames per second (fps)
    192     std::vector<std::string> tokens;
    193     Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
     187    SubString tokens(line, " \t\n\r\f/");
    194188
    195189    anim->fps = atoi(tokens.back().c_str()); tokens.pop_back();
  • trunk/src/lib/graphics/importer/model.cc

    r8316 r9406  
    2020#include "glincl.h"
    2121
    22 using namespace std;
     22
    2323
    2424/**
  • trunk/src/lib/graphics/importer/primitive_model.cc

    r9110 r9406  
    2121#include "debug.h"
    2222
    23 using namespace std;
     23
    2424
    2525/**
  • trunk/src/lib/graphics/importer/static_model.cc

    r8362 r9406  
    2323#include <stdarg.h>
    2424
    25 using namespace std;
     25
    2626
    2727
     
    161161{
    162162  PRINTF(4)("Deleting Model ");
    163   if (this->getName())
    164   {
    165     PRINT(4)("%s\n", this->getName());
     163  if (!this->getName().empty())
     164  {
     165    PRINT(4)("%s\n", this->getCName());
    166166  }
    167167  else
     
    178178
    179179  //! @todo do we really have to delete this material??
    180   list<ModelMaterial*>::iterator modMat;
     180  std::list<ModelMaterial*>::iterator modMat;
    181181  for(modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
    182182  {
     
    214214void StaticModel::rebuild()
    215215{
    216   PRINTF(3)("Rebuilding Model '%s'\n", this->getName());
     216  PRINTF(3)("Rebuilding Model '%s'\n", this->getCName());
    217217  this->finalize();
    218218}
     
    266266    tmpGroup = tmpGroup->next;
    267267  }
    268   PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getName());
     268  PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getCName());
    269269  return;
    270270}
     
    291291    tmpGroup = tmpGroup->next;
    292292  }
    293   PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getName());
     293  PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getCName());
    294294  return;
    295295}
     
    358358Material* StaticModel::findMaterialByName(const std::string& materialName)
    359359{
    360   list<ModelMaterial*>::iterator modMat;
     360  std::list<ModelMaterial*>::iterator modMat;
    361361  for  (modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
    362362    if (materialName == (*modMat)->material->getName())
     
    748748        {
    749749          tmpFace->material->select();
    750           PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName());
     750          PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getCName());
    751751        }
    752752      }
     
    840840      else if( tmpFace->vertexCount > 4) {
    841841        if (!warned)        {
    842           PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getName());
     842          PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getCName());
    843843          warned = true;
    844844        }
  • trunk/src/lib/graphics/importer/texture.cc

    r8761 r9406  
    230230  if (this->data->getStoredImage() != NULL)
    231231  {
    232     PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName());
     232    PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassCName(), this->getCName());
    233233    this->setTexture(Texture::loadTexToGL(this->data->getStoredImage()));
    234234  }
  • trunk/src/lib/graphics/importer/texture_sequence.cc

    r8619 r9406  
    225225bool TextureSequence::rebuild()
    226226{
    227   PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClassName(), this->getName());
     227  PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClassCName(), this->getCName());
    228228
    229229  for (unsigned int i = 0; i < this->textures.size(); i++)
  • trunk/src/lib/graphics/importer/vertex_array_model.cc

    r8362 r9406  
    2323#include "tc.h"
    2424
    25 using namespace std;
     25
    2626
    2727/////////////
     
    116116VertexArrayModel::~VertexArrayModel()
    117117{
    118   PRINTF(4)("Deleting VertexArrayModel %s\n", this->getName());
     118  PRINTF(4)("Deleting VertexArrayModel %s\n", this->getCName());
    119119}
    120120
     
    127127void VertexArrayModel::draw() const
    128128{
    129   PRINTF(4)("drawing 3D-VertexArrayModel %s\n", this->getName());
     129  PRINTF(4)("drawing 3D-VertexArrayModel %s\n", this->getCName());
    130130  glEnableClientState(GL_VERTEX_ARRAY );
    131131  glEnableClientState(GL_TEXTURE_COORD_ARRAY );
     
    343343void VertexArrayModel::debug() const
    344344{
    345   PRINT(0)("VertexArrayModel (%s): debug\n", this->getName());
     345  PRINT(0)("VertexArrayModel (%s): debug\n", this->getCName());
    346346  PRINT(0)("Stripes: %d; Indices: %d; Vertices: %d; Normals %d; TextCoords %d; Colors %d\n",
    347347            this->stripes.size(),
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r8989 r9406  
    104104      deleteNode = tmp;
    105105      tmp++;
    106       //      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());
     106      //      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassCName(), this->getName());
    107107      if ((this->parentMode & E2D_PROHIBIT_CHILD_DELETE) ||
    108108          ((*deleteNode)->parentMode & E2D_PROHIBIT_DELETE_WITH_PARENT))
     
    214214  {
    215215    PRINTF(2)("Unable to set %s to layer %s, because it's parent(%s) is of higher layer %s\n",
    216               this->getName(),
     216              this->getCName(),
    217217              Element2D::layer2DToChar(layer),
    218               this->parent->getName(),
     218              this->parent->getCName(),
    219219              Element2D::layer2DToChar(this->parent->getLayer()));
    220220    layer = this->parent->getLayer();
     
    602602      {
    603603        PRINTF(2)("Layer '%s' of Child(%s::%s) lower than parents(%s::%s) layer '%s'. updating...\n",
    604                   Element2D::layer2DToChar(child->getLayer()),child->getClassName(), child->getName(),
    605                   this->getClassName(), this->getName(), Element2D::layer2DToChar(this->layer));
     604                  Element2D::layer2DToChar(child->getLayer()),child->getClassCName(), child->getCName(),
     605                  this->getClassCName(), this->getCName(), Element2D::layer2DToChar(this->layer));
    606606        child->layer = this->layer;
    607607        this->children.push_front(child);
     
    627627    {
    628628      PRINTF(1)("Tried to reparent2D to own child '%s::%s' to '%s::%s'.\n",
    629                 this->getClassName(), this->getName(), child->getClassName(), child->getName());
     629                this->getClassCName(), this->getCName(), child->getClassCName(), child->getCName());
    630630      child->parent = NULL;
    631631    }
     
    701701    {
    702702      (*reparenter)->reparent2D();
    703       PRINTF(5)("REPARENTED TO: %s::%s\n",(*reparenter)->getParent2D()->getClassName(),(*reparenter)->getParent2D()->getName());
     703      PRINTF(5)("REPARENTED TO: %s::%s\n",(*reparenter)->getParent2D()->getClassCName(),(*reparenter)->getParent2D()->getCName());
    704704    }
    705705  }
     
    723723  else
    724724    PRINTF(2)("Not Found Element2D's (%s::%s) new Parent by Name: %s\n",
    725               this->getClassName(), this->getName(), parentName.c_str());
     725              this->getClassCName(), this->getCName(), parentName.c_str());
    726726}
    727727
     
    865865        Vector2D tmp = *this->toCoordinate;
    866866        this->setRelCoor2D(tmp);
    867         PRINTF(5)("SmoothMove of %s finished\n", this->getName());
     867        PRINTF(5)("SmoothMove of %s finished\n", this->getCName());
    868868      }
    869869    }
     
    879879        float tmp = *this->toDirection;
    880880        this->setRelDir2D(tmp);
    881         PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
     881        PRINTF(5)("SmoothRotate of %s finished\n", this->getCName());
    882882      }
    883883    }
     
    893893        delete this->toSize;
    894894        this->toSize = NULL;
    895         PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
     895        PRINTF(5)("SmoothRotate of %s finished\n", this->getCName());
    896896      }
    897897    }
     
    900900    this->lastAbsCoordinate = this->absCoordinate;
    901901
    902     PRINTF(5)("Element2D::update - %s - (%f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y);
     902    PRINTF(5)("Element2D::update - %s - (%f, %f)\n", this->getCName(), this->absCoordinate.x, this->absCoordinate.y);
    903903
    904904
     
    937937                 projectPos+1,
    938938                 projectPos+2);
    939       //       printf("%s::%s  == %f %f %f :: %f %f\n", this->getClassName(), this->getName(),
     939      //       printf("%s::%s  == %f %f %f :: %f %f\n", this->getClassCName(), this->getName(),
    940940      //              this->bindNode->getAbsCoor().x,
    941941      //              this->bindNode->getAbsCoor().y,
     
    10261026    PRINT(0)(" -");
    10271027  PRINT(0)("E2D(%s::%s);AC:(%0.2f, %0.2f);RC:(%0.2f, %0.2f);AD(%0.2f)->%s;Layer:(%s)\n",
    1028            this->getClassName(),
    1029            this->getName(),
     1028           this->getClassCName(),
     1029           this->getCName(),
    10301030           this->absCoordinate.x,
    10311031           this->absCoordinate.y,
  • trunk/src/lib/graphics/render2D/image_plane.cc

    r7843 r9406  
    2525
    2626
    27 using namespace std;
     27
    2828
    2929
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r7840 r9406  
    2222#include "element_2d.h"
    2323
    24 using namespace std;
     24
    2525
    2626/**
  • trunk/src/lib/graphics/shader.cc

    r8316 r9406  
    3232#endif
    3333
    34 using namespace std;
     34
    3535
    3636
  • trunk/src/lib/graphics/spatial_separation/quadtree.cc

    r9110 r9406  
    2424#include "debug.h"
    2525
    26 using namespace std;
     26
    2727#define QUADTREE_MATERIAL_COUNT       4
    2828
  • trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r9110 r9406  
    2626#include "util/list.h"
    2727
    28 using namespace std;
     28
    2929
    3030
  • trunk/src/lib/graphics/spatial_separation/spatial_separation.cc

    r6022 r9406  
    2323#include "compiler.h"
    2424
    25 using namespace std;
     25
    2626
    2727
  • trunk/src/lib/graphics/text_engine/limited_width_text.cc

    r8981 r9406  
    160160void LimitedWidthText::debug() const
    161161{
    162   printf("Debug %s::%s \n", this->getClassName(), this->getName() );
     162  printf("Debug %s::%s \n", this->getClassCName(), this->getCName() );
    163163}
  • trunk/src/lib/graphics/text_engine/multi_line_text.cc

    r8768 r9406  
    152152void MultiLineText::debug() const
    153153{
    154  printf("Debug %s::%s: %d lines\n", this->getClassName(), this->getName(), this->getLineCount());
     154 printf("Debug %s::%s: %d lines\n", this->getClassCName(), this->getCName(), this->getLineCount());
    155155
    156156 std::string tmpText = this->text();
  • trunk/src/lib/graphics/text_engine/text.cc

    r8769 r9406  
    2828 */
    2929Text::Text(const std::string& fontFile, unsigned int textSize)
    30     : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
     30    // : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    3131{
    3232  this->setClassID(CL_TEXT, "Text");
    3333
    3434  // initialize this Text
     35  this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    3536  this->_size = textSize;
    3637  this->setSizeY2D(textSize);
     
    278279void Text::debug() const
    279280{
    280   PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str());
     281  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getCName(), this->_font.getCName(), this->_text.c_str());
    281282  //  PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->_color.r(), this->_color.g(), this->_color.b(), this->_color.a());
    282283}
  • trunk/src/lib/graphics/text_engine/text_engine.cc

    r8761 r9406  
    2626#include "font.h"
    2727
    28 using namespace std;
     28
    2929
    3030#include <stdlib.h>
     
    122122void TextEngine::debug() const
    123123{
    124   const list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
     124  const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
    125125  if (textList != NULL)
    126126  {
     
    130130    PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size());
    131131
    132     list<BaseObject*>::const_iterator text;
     132    std::list<BaseObject*>::const_iterator text;
    133133    for ( text = textList->begin(); text != textList->end(); text++)
    134134      dynamic_cast<Text*>(*text)->debug();
  • trunk/src/lib/gui/gl/Makefile.am

    r8973 r9406  
    1313                \
    1414                glgui_handler.cc \
    15                 signal_connector.cc \
    1615                glgui_mainwidget.cc \
    1716                glgui_widget.cc \
     
    3837                glmenu/glmenu_imagescreen.h \
    3938                \
    40                 signal_connector.h \
    4139                glgui.h \
    4240                glgui_defs.h \
  • trunk/src/lib/gui/gl/glgui_button.cc

    r8769 r9406  
    7979  {
    8080    GLGuiWidget::clicking(pos);
    81     emit(clicked());
     81    clicked.emit();
    8282  }
    8383  void GLGuiButton::releasing(const Vector2D& pos, bool focused)
    8484  {
    8585    GLGuiWidget::releasing(pos, focused);
    86     emit(released());
     86    released.emit();
    8787  }
    8888
     
    103103    {
    104104      if (event.bPressed)
    105         emit(pushed());
     105        clicked.emit();
    106106      else
    107         emit(released());
     107        released.emit();
    108108      return true;
    109109    }
  • trunk/src/lib/gui/gl/glgui_button.h

    r8717 r9406  
    4242      virtual bool processEvent(const Event& event);
    4343
    44       DeclareSignal0(clicked);
    45       DeclareSignal0(released);
     44      sigslot::signal0<> clicked;
     45      sigslot::signal0<> released;
    4646
    4747
  • trunk/src/lib/gui/gl/glgui_checkbutton.cc

    r8717 r9406  
    5555  {
    5656    this->bActive = bActive;
    57     emit(this->toggled(this->bActive));
     57    this->toggled.emit(this->bActive);
    5858  }
    5959
  • trunk/src/lib/gui/gl/glgui_checkbutton.h

    r8717 r9406  
    3434    virtual void update() {};
    3535
    36     DeclareSignal1(toggled, bool);
     36    sigslot::signal1<bool> toggled;
    3737
    3838  protected:
  • trunk/src/lib/gui/gl/glgui_frame.cc

    r8145 r9406  
    5757    else
    5858    {
    59       PRINTF(2)("Frame %s is already filled, not filling with %s\n", this->getName(), widget->getName());
     59      PRINTF(2)("Frame %s is already filled, not filling with %s\n", this->getCName(), widget->getCName());
    6060    }
    6161  }
  • trunk/src/lib/gui/gl/glgui_image.h

    r8448 r9406  
    3434    virtual void draw() const;
    3535
    36     DeclareSignal0(imageChanged);
     36    sigslot::signal0<> imageChanged;
    3737
    3838  protected:
  • trunk/src/lib/gui/gl/glgui_inputline.cc

    r8717 r9406  
    124124    this->resize();
    125125    this->setFrontColor(Color(1,1,1,1), true);
    126     emit(this->textChanged(this->_text.text()));
     126    this->textChanged.emit(this->_text.text());
    127127  }
    128128
     
    146146  void GLGuiInputLine::pushEnter()
    147147  {
    148     emit(this->enterPushed(this->_text.text()));
     148    this->enterPushed.emit(this->_text.text());
    149149    if (this->_clearOnEnter)
    150150      this->clear();
  • trunk/src/lib/gui/gl/glgui_inputline.h

    r8619 r9406  
    4949    virtual bool processEvent(const Event& event);
    5050
    51     DeclareSignal1(textChanged, const std::string&);
    52     DeclareSignal1(enterPushed, const std::string&);
     51    sigslot::signal1<const std::string&> textChanged;
     52    sigslot::signal1<const std::string&> enterPushed;
    5353
    5454  protected:
  • trunk/src/lib/gui/gl/glgui_slider.cc

    r8717 r9406  
    7777    this->_handle.setCenter(this->sliderPosition(), borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0);
    7878
    79     emit(valueChanged(this->_value));
     79    valueChanged.emit(this->_value);
    8080  }
    8181
     
    9090    {
    9191      this->_minValue = minimum;
    92       emit(rangeChanged(this->_minValue, this->_maxValue));
     92      rangeChanged.emit(this->_minValue, this->_maxValue);
    9393    }
    9494    if (this->value() < this->min())
     
    107107    {
    108108      this->_maxValue = maximum;
    109       emit(rangeChanged(this->_minValue, this->_maxValue));
     109      rangeChanged.emit(this->_minValue, this->_maxValue);
    110110    }
    111111    if (this->value() > this->max())
     
    126126      this->_minValue = minimum;
    127127      this->_maxValue = maximum;
    128       emit(rangeChanged(this->_minValue, this->_maxValue));
     128      rangeChanged.emit(this->_minValue, this->_maxValue);
    129129    }
    130130    if (this->value() < this->min())
  • trunk/src/lib/gui/gl/glgui_slider.h

    r8717 r9406  
    5151    virtual void draw() const;
    5252
    53     DeclareSignal1(valueChanged, float);
    54     DeclareSignal2(rangeChanged, float, float);
     53    sigslot::signal1<float> valueChanged;
     54    sigslot::signal2<float, float> rangeChanged;
    5555
    5656  protected:
  • trunk/src/lib/gui/gl/glgui_text.cc

    r8991 r9406  
    113113    this->resize();
    114114    this->setFrontColor(_changedTextColor, true);
    115     emit(this->textChanged(this->_text.text()));
     115    this->textChanged.emit(this->_text.text());
    116116  }
    117117
  • trunk/src/lib/gui/gl/glgui_text.h

    r8991 r9406  
    3333    void setChangedTextColor(const Color& color);
    3434
     35    void setLineWidth(float lineWidth) { this->_text.setLineWidth(lineWidth); };
    3536    void setDotsPosition(LimitedWidthText::DotsPosition dotsPosition) { this->_text.setDotsPosition(dotsPosition); };
    3637
     
    4041    virtual void draw() const;
    4142
    42     DeclareSignal1(textChanged, const std::string&);
     43    sigslot::signal1<const std::string&> textChanged;
    4344
    4445  protected:
  • trunk/src/lib/gui/gl/glgui_textfield.cc

    r9015 r9406  
    112112    this->resize();
    113113    this->setFrontColor(_changedTextColor, true);
    114     emit(this->textChanged(this->_text.text()));
     114    this->textChanged.emit(this->_text.text());
    115115  }
    116116
  • trunk/src/lib/gui/gl/glgui_textfield.h

    r9015 r9406  
    3838    virtual void draw() const;
    3939
    40     DeclareSignal1(textChanged, const std::string&);
     40    sigslot::signal1<const std::string&> textChanged;
    4141
    4242  protected:
  • trunk/src/lib/gui/gl/glgui_widget.cc

    r9019 r9406  
    288288    this->setWidgetSize(Vector2D(x, y));
    289289  }
    290 
    291 
    292 
    293   void GLGuiWidget::connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor)
    294   {
    295     sender->connect(signal, receiver, executor);
    296   }
    297 
    298   void GLGuiWidget::connect(Signal& signal, BaseObject* receiver, Slot executor)
    299   {
    300     signal.push_back(SignalConnector(receiver, executor));
    301   }
    302 
    303290
    304291  void GLGuiWidget::show()
     
    806793    //this->_currentStyle = this->_style[state];
    807794    this->_state = state;
    808     PRINTF(4)("%s::%s Switches to state %s\n", this->getClassName(), this->getName(), OrxGui::StateString[state].c_str());
     795    PRINTF(4)("%s::%s Switches to state %s\n", this->getClassCName(), this->getCName(), OrxGui::StateString[state].c_str());
    809796
    810797    this->animateBack();
     
    874861  void GLGuiWidget::debug(unsigned int level) const
    875862  {
    876     PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName());
     863    PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassCName(), this->getCName());
    877864    if (_parent != NULL)
    878       PRINT(0)("- Parent %s::%s ", _parent->getClassName(), _parent->getName());
     865      PRINT(0)("- Parent %s::%s ", _parent->getClassCName(), _parent->getCName());
    879866    PRINT(0)("- State: %s", StateString[_state].c_str());
    880867
  • trunk/src/lib/gui/gl/glgui_widget.h

    r8990 r9406  
    1717
    1818#include "event.h"
    19 #include "signal_connector.h"
     19#include "sigslot/signal.h"
    2020
    2121namespace OrxGui
     
    7070    void release(const Vector2D& pos);
    7171    bool clickable() const { return this->_clickable; };
    72 
    73     static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor);
    74     void connect(Signal& signal, BaseObject* receiver, Slot executor);
    75 
    76     void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver);
    7772
    7873    OrxGui::State state() const { return this->_state; };
  • trunk/src/lib/gui/gl/glmenu/glmenu_imagescreen.cc

    r8316 r9406  
    2727CREATE_FACTORY(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN);
    2828
    29 using namespace std;
     29
    3030/**
    3131 * @param root The Element to load the GLMenu from
  • trunk/src/lib/gui/gui_saveable.cc

    r8362 r9406  
    6060  void Saveable::load()
    6161  {
    62     this->value() = Preferences::getInstance()->getMultiType(this->group->getName(), this->getName(), this->_defaultValue);
    63     PRINTF(4)("Loaded to '%s' of group '%s' value '%s'\n", this->getName(), this->group->getName(), this->value().getCString());
     62    this->value() = Preferences::getInstance()->getMultiType(this->group->getCName(), this->getCName(), this->_defaultValue);
     63    PRINTF(4)("Loaded to '%s' of group '%s' value '%s'\n", this->getCName(), this->group->getCName(), this->value().getCString());
    6464  }
    6565
    6666  void Saveable::save()
    6767  {
    68     Preferences::getInstance()->setMultiType(this->group->getName(), this->getName(), this->value() );
    69     PRINTF(4)("Saved to '%s' of group '%s' value '%s'\n", this->getName(), this->group->getName(), this->value().getCString());
     68    Preferences::getInstance()->setMultiType(this->group->getCName(), this->getCName(), this->value() );
     69    PRINTF(4)("Saved to '%s' of group '%s' value '%s'\n", this->getCName(), this->group->getCName(), this->value().getCString());
    7070  }
    7171
  • trunk/src/lib/gui/qt/gui_video.cc

    r8362 r9406  
    5050      layout->addWidget(fullscreen, 0, 0);
    5151
     52      QtGuiCheckBox* dedicated = new QtGuiCheckBox(CONFIG_NAME_NO_RENDER, this, false);
     53      //fullscreen->setName();
     54      layout->addWidget(dedicated, 1, 0);
     55
    5256      QtGuiCheckBox* wireframe = new QtGuiCheckBox(CONFIG_NAME_WIREFRAME, this, false);
    53       layout->addWidget(wireframe, 1, 0);
     57      layout->addWidget(wireframe, 2, 0);
    5458
    5559      {
    5660        QComboBox* resolution = new QtGuiComboBox(CONFIG_NAME_RESOLUTION, this, "640x480");
    5761        resolution->setEditable(true);
    58         layout->addWidget(resolution, 2, 0);
     62        layout->addWidget(resolution, 3, 0);
    5963        std::vector<QString> resolutions;
    6064        this->getResolutions(resolutions);
  • trunk/src/lib/lang/base_object.cc

    r8145 r9406  
    2121#include "util/loading/load_param.h"
    2222#include "class_list.h"
    23 
    24 #include "synchronizeable.h"
    25 
    26 using namespace std;
    27 
    2823
    2924/**
     
    5045  ClassList::removeFromClassList(this);
    5146
    52   //  delete []this->className;
    5347  if (this->xmlElem != NULL)
    5448    delete this->xmlElem;
     
    6155void BaseObject::loadParams(const TiXmlElement* root)
    6256{
    63   // all loadParams should sometime arrive here.
     57  // all loadParams should arrive here, and be tested for (root != NULL)
    6458  assert (root != NULL);
    6559
     60  // copy the xml-element for to know how it was loaded.
    6661  if (this->xmlElem != NULL)
    6762    delete this->xmlElem;
    6863  this->xmlElem = root->Clone();
     64
    6965  // name setup
    7066  LoadParam(root, "name", this, BaseObject, setName)
     
    9288/**
    9389 * @brief set the name of the Object
     90 * @param objectName The new name of the Object.
    9491 */
    9592void BaseObject::setName (const std::string& objectName)
     
    164161 * @returns true on match, false otherwise.
    165162 */
    166 bool BaseObject::operator==(const std::string& objectName)
     163bool BaseObject::operator==(const std::string& objectName) const
    167164{
    168165  return (this->objectName == objectName);
    169166}
    170167
    171 
    172 /**
    173  * @brief displays everything this class is
    174  * @TODO REIMPLEMENT WITH SENSE.
    175  */
    176 void BaseObject::whatIs() const
    177 {
    178 
    179 }
  • trunk/src/lib/lang/base_object.h

    r8362 r9406  
    11/*!
    22 * @file base_object.h
    3   *  Definition of the base object class.
    4 
    5     This is a global handler for all classes.
    6 */
     3 * @brief Definition of the BaseObject class.
     4 *
     5 * This is a global handler for all classes Object and Class names
     6 *
     7 * BaseObject is the class, that handles object registration and
     8 * is the only write-access member of ClassList, where the Objects
     9 * References are stored.
     10 */
    711
    812
    9 #ifndef _BASE_OBJECT_H
    10 #define _BASE_OBJECT_H
     13#ifndef __BASE_OBJECT_H_
     14#define __BASE_OBJECT_H_
    1115
    1216#include "class_id.h"
     17#include "sigslot/slot.h"
     18
    1319#include <string>
    1420
     
    1824
    1925//! A class all other classes are derived from
    20 class BaseObject
     26class BaseObject : public sigslot::has_slots<>
    2127{
    2228
     
    2935  void setName (const std::string& newName);
    3036  /** returns the Name of this Object */
    31   inline const char* getName ()const { return this->objectName.c_str(); };
     37  inline const std::string& getName() const { return this->objectName; };
     38  /** returns the Name of this Object as a C-compliant string (const char*) */
     39  inline const char* getCName() const { return this->objectName.c_str(); };
    3240  /** @returns the XML-Element with whicht this Object was loaded */
    3341  inline TiXmlNode* getXmlElem() const { return this->xmlElem; };
    3442
    3543  /** @returns the className of the corresponding Object */
    36   inline const char* getClassName() const { return this->className.c_str(); };
     44  inline const std::string& getClassName() const { return this->className; }
     45  /** @returns the className of the corresponding Object as a C-compliant string (const char*) */
     46  inline const char* getClassCName() const { return this->className.c_str(); };
    3747  /** @returns the classID of the corresponding Object */
    3848  inline int getClassID() const { return this->classID; };
     
    4151  bool isA (ClassID classID) const;
    4252  bool isA (const std::string& className) const;
    43   void whatIs() const;
    4453
    45   bool operator==(const std::string& objectName);
    4654  /** @param classID comparer for a ClassID @returns true on match, false otherwise */
    47   bool operator==(ClassID classID) { return this->isA(classID); };
     55  bool operator==(ClassID classID) const  { return this->isA(classID); };
     56  bool operator==(const std::string& objectName) const;
    4857
    4958protected:
     
    5463
    5564private:
    56 
    5765  std::string        className;        //!< the name of the class
    5866  long               classID;          //!< this is the id from the class_id.h enumeration
     
    6472};
    6573
    66 #endif /* _BASE_OBJECT_H */
     74#endif /* __BASE_OBJECT_H_ */
  • trunk/src/lib/lang/class_list.cc

    r8783 r9406  
    2323#include <cmath>
    2424
    25 using namespace std;
     25
    2626
    2727/**
     
    6161{
    6262  if (unlikely(classList == NULL))
    63     ClassList::classList = new list<ClassList>();
     63    ClassList::classList = new std::list<ClassList>();
    6464
    6565  PRINTF(5)("subscribe a '%s'\n", className.c_str() );
     
    8585void ClassList::removeFromClassList(BaseObject* objectPointer)
    8686{
    87   list<ClassList>::iterator cl;
     87  std::list<ClassList>::iterator cl;
    8888  for(cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    8989  {
     
    110110      ClassList::classNames.clear();
    111111
    112       list<ClassList>::const_iterator cl;
     112      std::list<ClassList>::const_iterator cl;
    113113      for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    114114        ClassList::classNames.push_back((*cl).className);
     
    207207      std::list<BaseObject*>::iterator bo;
    208208      for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++)
    209         if ((*bo)->getName() != NULL && objectName == (*bo)->getName())
     209        if (objectName == (*bo)->getName())
    210210          return (*bo);
    211211    }
     
    213213  else
    214214  {
    215     list<ClassList>::iterator cl;
     215    std::list<ClassList>::iterator cl;
    216216    for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    217217    {
    218218      std::list<BaseObject*>::iterator bo;
    219219      for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++)
    220         if ((*bo)->getName() != NULL && objectName == (*bo)->getName())
     220        if (objectName == (*bo)->getName())
    221221          return (*bo);
    222222    }
     
    241241    std::list<BaseObject*>::iterator bo;
    242242    for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++)
    243       if ((*bo)->getName() != NULL && objectName == (*bo)->getName())
     243      if (objectName == (*bo)->getName())
    244244        return (*bo);
    245245  }
     
    268268  else
    269269  {
    270     list<ClassList>::iterator cl;
     270    std::list<ClassList>::iterator cl;
    271271    for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    272272    {
     
    286286    std::list<BaseObject*>::iterator bo;
    287287    for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++)
    288       if ((*bo)->getName() != NULL && objectName == (*bo)->getName())
     288      if (objectName == (*bo)->getName())
    289289        return true;
    290290  }
     
    299299void ClassList::whatIs(const BaseObject* object)
    300300{
    301   list<ClassList>::iterator cl;
     301  std::list<ClassList>::iterator cl;
    302302  for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    303303    if (object->isA((*cl).classID))
     
    359359  int lenCount = 0;
    360360
    361   list<ClassList>::iterator cl;
     361  std::list<ClassList>::iterator cl;
    362362  for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    363363  {
     
    377377      {
    378378        PRINT(0)("|  Listing Instances:\n");
    379         list<BaseObject*>::const_iterator bo;
     379        std::list<BaseObject*>::const_iterator bo;
    380380        for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++)
    381381        {
    382           PRINT(0)("|   %s::%s::(0x%.8X->%p ", (*bo)->getClassName(), (*bo)->getName(), (*bo)->getClassID(), (*bo));
     382          PRINT(0)("|   %s::%s::(0x%.8X->%p ", (*bo)->getClassCName(), (*bo)->getCName(), (*bo)->getClassID(), (*bo));
    383383          if (debugLevel == 3)
    384384            ClassList::whatIs(*bo);
  • trunk/src/lib/math/line.cc

    r6617 r9406  
    2626#endif
    2727
    28 using namespace std;
     28
    2929
    3030/**
  • trunk/src/lib/math/plane.cc

    r7711 r9406  
    2424#endif
    2525
    26 using namespace std;
     26
    2727
    2828/**
  • trunk/src/lib/math/rotation_OBSOLETE.cc

    r6617 r9406  
    2424#endif
    2525
    26 using namespace std;
     26
    2727
    2828/**
  • trunk/src/lib/math/vector2D.cc

    r6615 r9406  
    2727#endif
    2828
    29 using namespace std;
     29
    3030
    3131/////////////
  • trunk/src/lib/network/Makefile.am

    r8623 r9406  
    88                      shared_network_data.cc \
    99                      network_socket.cc \
    10                       connection_monitor.cc \
    1110                      network_stream.cc \
    1211                      data_stream.cc \
     
    2019                      network_game_manager.cc \
    2120                      converter.cc \
     21                      peer_info.cc \
    2222                      message_manager.cc \
    2323                      network_log.cc \
     
    2525                      player_stats.cc \
    2626                      udp_broadcast.cc \
     27                      \
     28                      proxy/network_settings.cc \
     29                      \
     30                                  monitor/connection_monitor.cc \
     31                      monitor/network_monitor.cc \
     32                      monitor/network_node.cc \
    2733                      \
    2834                      synchronizeable_var/synchronizeable_var.cc \
     
    3339                      synchronizeable_var/synchronizeable_float.cc \
    3440                      synchronizeable_var/synchronizeable_bool.cc \
    35                       synchronizeable_var/synchronizeable_uint.cc
     41                      synchronizeable_var/synchronizeable_uint.cc \
     42                      synchronizeable_var/synchronizeable_ip.cc \
     43                      \
     44                      ip.cc
    3645
    3746
    3847
    3948
    40 noinst_HEADERS = synchronizeable.h \
    41                  network_manager.h \
    42                  shared_network_data.h \
    43                  network_socket.h \
    44                  connection_monitor.h \
    45                  network_stream.h \
    46                  data_stream.h \
    47                  network_protocol.h \
    48                  server_socket.h \
    49                  tcp_server_socket.h \
    50                  tcp_socket.h \
    51                  udp_server_socket.h \
    52                  udp_socket.h \
    53                  handshake.h \
    54                  network_game_manager.h \
    55                  converter.h \
    56                  netdefs.h \
    57                  message_manager.h \
    58                  network_log.h \
    59                  zip.h \
    60                  player_stats.h \
    61                  udp_broadcast.h \
    62                  \
    63                  synchronizeable_var/synchronizeable_var.h \
    64                  synchronizeable_var/synchronizeable_vector.h \
    65                  synchronizeable_var/synchronizeable_int.h \
    66                  synchronizeable_var/synchronizeable_quaternion.h \
    67                  synchronizeable_var/synchronizeable_string.h \
    68                  synchronizeable_var/synchronizeable_float.h \
    69                  synchronizeable_var/synchronizeable_bool.h \
    70                  synchronizeable_var/synchronizeable_uint.h
    71 
    72 
     49noinst_HEADERS = \
     50                netdefs.h \
     51                nettypes.h \
     52                netincl.h \
     53                \
     54                synchronizeable.h \
     55                network_manager.h \
     56                shared_network_data.h \
     57                network_socket.h \
     58                network_stream.h \
     59                data_stream.h \
     60                network_protocol.h \
     61                server_socket.h \
     62                tcp_server_socket.h \
     63                tcp_socket.h \
     64                udp_server_socket.h \
     65                udp_socket.h \
     66                handshake.h \
     67                network_game_manager.h \
     68                converter.h \
     69                peer_info.h \
     70                netdefs.h \
     71                message_manager.h \
     72                network_log.h \
     73                zip.h \
     74                player_stats.h \
     75                udp_broadcast.h \
     76                \
     77                proxy/network_settings.cc \
     78                \
     79                monitor/connection_monitor.h \
     80                monitor/network_monitor.h \
     81                monitor/network_node.h \
     82                \
     83                synchronizeable_var/synchronizeable_var.h \
     84                synchronizeable_var/synchronizeable_vector.h \
     85                synchronizeable_var/synchronizeable_int.h \
     86                synchronizeable_var/synchronizeable_quaternion.h \
     87                synchronizeable_var/synchronizeable_string.h \
     88                synchronizeable_var/synchronizeable_float.h \
     89                synchronizeable_var/synchronizeable_bool.h \
     90                synchronizeable_var/synchronizeable_uint.h \
     91                synchronizeable_var/synchronizeable_ip.h \
     92                \
     93                ip.h
  • trunk/src/lib/network/converter.cc

    r8362 r9406  
    1010
    1111### File Specific:
    12    main-programmer: Benjamin Wuest
    13    co-programmer: ...
     12   main-programmer: Benjamin Wuest (bwuest@ee.ethz.ch)
     13   co-programmer: Christoph Renner (rennerc@ee.ethz.ch)
    1414*/
    1515
     
    3030
    3131/* using namespace std is default, this needs to be here */
    32 using namespace std;
     32
    3333
    3434/*!
     
    3838{
    3939  /* set the class id for the base object */
    40   //this->setClassID(CL_ENTITY_MANAGER, "EntityManager");
    4140}
    4241
  • trunk/src/lib/network/data_stream.cc

    r8623 r9406  
    1919
    2020/* using namespace std is default, this needs to be here */
    21 using namespace std;
     21
    2222
    2323
  • trunk/src/lib/network/handshake.cc

    r9235 r9406  
    1010
    1111### File Specific:
    12    main-programmer: christoph
    13    co-programmer:
     12   main-programmer: Christoph Renner (rennerc@ee.ethz.ch)
     13   co-programmer: Patirck Boenzli (boenzlip@orxonox.ethz.ch)
    1414*/
    1515
    1616
    17 /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module
    18    For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
    19 */
    2017#define DEBUG_MODULE_NETWORK
    2118
     
    2522#include "debug.h"
    2623
    27 Handshake::Handshake( bool server, int clientId, int networkGameManagerId, int messageManagerId )
     24
     25
     26
     27
     28 Handshake::Handshake( int nodeType, int clientId, int networkGameManagerId, int messageManagerId )
    2829  : Synchronizeable()
    2930{
     
    3132  this->setClassID(CL_HANDSHAKE, "Handshake");
    3233
    33   this->setIsServer(server);
    3434
     35  // register all variable handlers
    3536  orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) );
    3637  version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) );
     
    4243  errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) );
    4344
     45  this->nodeTypeHandler = registerVarId( new SynchronizeableInt( &localState.nodeType, &remoteState.nodeType, "nodeType", PERMISSION_ALL ) );
     46
    4447  candel_id = registerVarId( new SynchronizeableInt( &localState.canDel, &remoteState.canDel, "canDel", PERMISSION_ALL ) );
    45  
     48
    4649  registerVar( new SynchronizeableString( &localState.preferedNickName, &remoteState.preferedNickName, "preferedNickName", PERMISSION_ALL ) );
     50  // now synchronize only two of the available proxy server addresses
     51  registerVar( new SynchronizeableIP( &this->proxy1, &this->proxy1, "proxy server 1", PERMISSION_MASTER_SERVER ) );
     52  registerVar( new SynchronizeableIP( &this->proxy2, &this->proxy2, "proxy server 2", PERMISSION_MASTER_SERVER ) );
     53  registerVar( new SynchronizeableInt( &this->redirectProxy, &this->redirectProxy, "proxy server redirection flag", PERMISSION_MASTER_SERVER ) );
    4754
     55
     56  // init the local state
    4857  localState.completed = 0;
    4958  localState.error = 0;
     
    5463  localState.orxId = _ORXONOX_ID;
    5564  localState.version = _ORXONOX_VERSION;
     65  localState.nodeType = nodeType;
    5666  localState.canDel = 0;
    5767
     68
     69  // init the remote state
    5870  remoteState.completed = 0;
    5971  remoteState.error = 0;
     
    6476  remoteState.orxId = 0;
    6577  remoteState.version = 0;
     78  remoteState.nodeType = NET_CLIENT;
    6679  remoteState.canDel = 0;
    6780
     81
     82  this->proxy1 = IP(0, 0);
     83  this->proxy2 = IP(0, 0);
     84  this->redirectProxy = 0;
     85
     86
     87  // activate the synchronization process
    6888  this->setSynchronized(true);
    6989  PRINTF(0)("Handshake created clientId = %d\n", clientId);
    7090}
     91
    7192
    7293/**
     
    7899  for ( std::list<int>::iterator it = id.begin(); it != id.end(); it++ )
    79100  {
    80     if ( *it == orxId_handler )
     101    // orxonox id handler
     102    if ( *it == this->orxId_handler )
    81103    {
    82104      if ( remoteState.orxId != _ORXONOX_ID )
     
    87109        continue;
    88110      }
    89 
    90111    }
    91112
    92     if ( *it == version_handler )
     113    // orxonox version handler
     114    if ( *it == this->version_handler )
    93115    {
    94116      if ( remoteState.version != _ORXONOX_VERSION )
     
    99121        continue;
    100122      }
    101 
    102123    }
    103124
     125    // node type handler: for each node type there is a specific action to be taken
     126    if ( *it == this->nodeTypeHandler)
     127    {
     128      if ( remoteState.nodeType == NET_MASTER_SERVER )
     129      {
     130        continue;
     131      }
     132      else if( remoteState.nodeType == NET_PROXY_SERVER_ACTIVE)
     133      {
     134        continue;
     135      }
     136      else if( remoteState.nodeType == NET_CLIENT)
     137      {
     138        continue;
     139      }
     140    }
     141
     142    // cancel
    104143    if ( *it == candel_id )
    105144    {
    106145      PRINTF(0)("handshake finished candel changed\n");
    107146    }
    108 
    109147  }
    110148
    111   if (
    112       remoteState.orxId == _ORXONOX_ID &&
    113       remoteState.version == _ORXONOX_VERSION
    114      )
     149  // handshake completed
     150  if ( remoteState.orxId == _ORXONOX_ID &&
     151       remoteState.version == _ORXONOX_VERSION )
     152  {
    115153    localState.completed = 1;
     154  }
    116155}
    117156
  • trunk/src/lib/network/handshake.h

    r9235 r9406  
    11/*!
    22 * @file network_stream.h
    3  *  implementation of a network pipe
     3 *  implementation of a network pipe. This node handles the handshake of two network nodes and exchanges informationas
     4 * vial to the connection setup.
     5 *
     6 * the local node only writes in the localState variable. the remoteState variable will be written from the remote network node
     7 * so don't write into it!
    48 */
    59
     
    812
    913#include "base_object.h"
     14#include "ip.h"
    1015#include "synchronizeable.h"
     16#include "shared_network_data.h"
    1117
    12 #define _ORXONOX_ID 0xF91337A0
     18//!< a struct to save the handshakes to
     19struct HandshakeState
     20{
     21  int           orxId;                         //!< orxonox id
     22  int           version;                       //!< network protocol version
    1323
    14 #define _ORXONOX_VERSION 1
     24  int           networkManagerId;              //!< unique id of the network manager
     25  int           messageManagerId;              //!< unique id of the message manager
     26  int           hostId;                        //!< host id
     27  int           nodeType;                      //!< type of the network node
    1528
    16 struct HandshakeState {
    17   int orxId;
    18   int version;
    19  
    20   int networkManagerId;
    21   int messageManagerId;
    22   int hostId;
    23  
    24   int completed;
    25   int canDel;
    26  
    27   int error;
    28  
    29   std::string errorString;
    30  
     29  int           completed;                     //!< true if completed
     30  int           canDel;                        //!< true if marked for deletion
     31
     32  int           error;                         //!< error number
     33
     34  std::string   errorString;                   //!< error string
     35
    3136  //additional data
    32   std::string preferedNickName;
     37  std::string   preferedNickName;              //!< prefered nick name
    3338};
    3439
     40
     41//!< the handshake itself with some interface functions
    3542class Handshake : public Synchronizeable
    3643{
     44
    3745  public:
    38     Handshake( bool server, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 );
    39     inline bool       completed(){ return localState.completed != 0 && remoteState.completed != 0; }
    40     inline bool       ok(){ return localState.error == 0 && remoteState.error == 0; }
    41     inline int        getHostId(){ return remoteState.hostId; }
    42     inline int        getNetworkGameManagerId(){ return remoteState.networkManagerId; }
    43     inline int        getMessageManagerId(){ return remoteState.messageManagerId; }
    44     inline void       doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
    45     inline bool       canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
    46     inline bool       allowDel(){ return localState.canDel == 1; }
    47     inline void       del(){ localState.canDel = 1; }
    48    
    49     inline void       setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; }
     46    Handshake( int nodeType, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 );
     47
     48
     49    /* functions indicating states of the handshake */
     50    /** @returns true if the handshake is completed */
     51    inline bool completed(){ return localState.completed != 0 && remoteState.completed != 0; }
     52    /** @returns true if no error has occured until now */
     53    inline bool ok(){ return localState.error == 0 && remoteState.error == 0; }
     54    /** stops the handshake and reject the other side with @param reason: string describing the reason */
     55    inline void doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
     56    /** @returns true if the handshake is finished and the instances can be deleted */
     57    inline bool canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
     58    /** @returns true if the local state can be removed*/
     59    inline bool allowDel(){ return localState.canDel == 1; }
     60    /** marks the handshake to be deleted */
     61    inline void del(){ localState.canDel = 1; }
     62
     63
     64    /* the actual informations exchanged in the handshake */
     65    /** @returns the host id of the remote host */
     66    inline int  getHostId(){ return remoteState.hostId; }
     67    /** @returns the unique id of the network game manager*/
     68    inline int  getNetworkGameManagerId(){ return remoteState.networkManagerId; }
     69    /** @returns the unique id of the message manager */
     70    inline int  getMessageManagerId(){ return remoteState.messageManagerId; }
     71    /** @returns the node type of the remote host */
     72    inline int getRemoteNodeType() { return this->remoteState.nodeType; }
     73
     74    /** sets @param nick the prefereded nick name */
     75    inline void setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; }
     76    /** @returns the prefered nick name */
    5077    inline std::string getPreferedNickName(){ return remoteState.preferedNickName; }
    51    
     78
     79    /** @returns if true the local client should reconnect to a proxy server from the proxy server list */
     80    inline bool redirect() { return this->redirectProxy;}
     81    /** @param flag: indicating if the client should be redirected */
     82    inline void setRedirect(bool flag) { if( SharedNetworkData::getInstance()->isClient()) return; this->redirectProxy = (int)flag; }
     83
     84    /** @param address: the address of the proxy server 1 if any */
     85    inline void setProxy1Address(IP address) { if( SharedNetworkData::getInstance()->isClient()) return; this->proxy1 = address; }
     86    /** @returns the address of the proxy server 1 if any */
     87    inline IP getProxy1Address() { return this->proxy1; }
     88    /** @param address: the address of the proxy server 2 if any */
     89    inline void setProxy2Address(IP address) { if( SharedNetworkData::getInstance()->isClient()) return; this->proxy2 = address; }
     90    /** @returns the address of the proxy server 2 if any */
     91    inline IP getProxy2Address() { return this->proxy2; }
     92
     93
     94    /* variable handler function */
    5295    virtual void varChangeHandler( std::list<int> & id );
    5396
     97
    5498  private:
    55     HandshakeState localState;
    56     HandshakeState remoteState;
    57    
    58     int netManId_handler;
    59     int msgManId_handler;
    60     int hostId_handler;
    61     int completed_handler;
    62     int error_handler;
    63     int errorString_handler;
    64     int orxId_handler;
    65     int version_handler;
    66     int candel_id;
     99    HandshakeState     localState;                            //!< the local handshake state
     100    HandshakeState     remoteState;                           //!< the remote handshake state
    67101
     102    int                orxId_handler;                         //!< orxonox id handler
     103    int                version_handler;                       //!< orxonox version id handler
     104    int                netManId_handler;                      //!< network manager handler
     105    int                msgManId_handler;                      //!< message manager handler
     106    int                hostId_handler;                        //!< host id handler
     107    int                nodeTypeHandler;                       //!< node type handler
     108    int                proxy1Handler;                         //!< handler for the proxy
     109    int                proxy2Handler;                         //!< handler for the proxy
     110
     111    int                completed_handler;                     //!< handshake completion handler
     112    int                error_handler;                         //!< handshake error handler
     113    int                errorString_handler;                   //!< handshake error string handler
     114    int                candel_id;                             //!< handshake deletion handler
     115    int                nodeType;                              //!, the type of the network node
     116
     117    int                redirectProxy;                         //!< true if the client should reconnect to a proxy server
     118    IP                 proxy1;                               //!< ip address of the first proxy (0.0.0.0 of not available)
     119    IP                 proxy2;                               //!< ip address of the second proxy (0.0.0.0 of not available)
    68120};
    69121
  • trunk/src/lib/network/message_manager.cc

    r9059 r9406  
    2020#include "network_stream.h"
    2121#include "shared_network_data.h"
    22 
    23 using namespace std;
     22#include "converter.h"
     23#include <cassert>
     24
     25
    2426
    2527MessageManager* MessageManager::singletonRef = NULL;
     
    5254      }
    5355    }
    54    
     56
    5557    it->second.messages.clear();
    5658    it->second.toAck.clear();
    5759  }
    58  
     60
    5961  messageQueue.clear();
    60  
     62
    6163  this->messageHandlerMap.clear();
    62  
     64
    6365  MessageManager::singletonRef = NULL;
    6466}
     
    8284  int i = 0;
    8385  int n;
    84  
     86
    8587  n = Converter::intToByteArray( messageQueue[userId].toAck.size(), data + i, maxLength );
    8688  i += n;
    8789  assert( n == INTSIZE );
    88  
     90
    8991  for ( std::list<int>::iterator it = messageQueue[userId].toAck.begin(); it != messageQueue[userId].toAck.end(); it++)
    9092  {
     
    9395    assert( n == INTSIZE );
    9496  }
    95  
     97
    9698  messageQueue[userId].toAck.clear();
    97  
     99
    98100  n = Converter::intToByteArray( messageQueue[userId].messages.size(), data + i, maxLength );
    99101  i += n;
    100102  assert( n == INTSIZE );
    101  
     103
    102104  for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ )
    103105  {
     
    105107    i += n;
    106108    assert( n == INTSIZE );
    107    
     109
    108110    n = Converter::intToByteArray( it->number, data + i, maxLength );
    109111    i += n;
    110112    assert( n == INTSIZE );
    111    
     113
    112114    n = Converter::intToByteArray( it->messageId, data + i, maxLength );
    113115    i += n;
    114116    assert( n == INTSIZE );
    115    
     117
    116118    assert( i + it->length <= maxLength );
    117119    memcpy( data + i, it->data, it->length );
    118120    i += it->length;
    119121  }
    120  
     122
    121123  return i;
    122124}
     
    136138  int i = 0;
    137139  int n;
    138  
     140
    139141  int nAcks;
    140  
     142
    141143  assert( i + INTSIZE <= length );
    142144  n = Converter::byteArrayToInt( data + i, &nAcks );
    143145  assert( n == INTSIZE );
    144146  i += n;
    145  
     147
    146148  std::list<int> acks;
    147  
     149
    148150  int number;
    149  
     151
    150152  for ( int j = 0; j < nAcks; j++ )
    151153  {
     
    154156    assert( n == INTSIZE );
    155157    i += n;
    156    
     158
    157159    acks.push_back( number );
    158160  }
    159  
     161
    160162  int nMessages;
    161  
     163
    162164  assert( i + INTSIZE <= length );
    163165  n = Converter::byteArrayToInt( data + i, &nMessages );
     
    166168
    167169  int messageLength, messageId;
    168  
     170
    169171  for ( int j = 0; j < nMessages; j++ )
    170172  {
     
    173175    assert( n == INTSIZE );
    174176    i += n;
    175    
     177
    176178    assert( i + INTSIZE <= length );
    177179    n = Converter::byteArrayToInt( data + i, &number );
    178180    assert( n == INTSIZE );
    179181    i += n;
    180  
     182
    181183    assert( i + INTSIZE <= length );
    182184    n = Converter::byteArrayToInt( data + i, &messageId );
    183185    assert( n == INTSIZE );
    184186    i += n;
    185    
     187
    186188    if ( number > 0 )
    187189      messageQueue[userId].toAck.push_back( number );
    188    
     190
    189191    assert( i + messageLength <= length );
    190192    assert( messageHandlerMap.find( (MessageId)messageId ) != messageHandlerMap.end() );
     
    194196      {
    195197        NetworkMessage msg;
    196        
     198
    197199        msg.data = new byte[messageLength];
    198200        memcpy( msg.data, data + i, messageLength );
     
    200202        msg.messageId = (MessageId)messageId;
    201203        msg.number = userId;
    202        
     204
    203205        incomingMessageBuffer.push_back( msg );
    204206      }
     
    207209    i += messageLength;
    208210  }
    209  
    210  
     211
     212
    211213  //TODO maybe handle incomingMessage in tick function. else local messages will not be handled if no clients are connected
    212214  for ( std::list<NetworkMessage>::iterator it = incomingMessageBuffer.begin(); it != incomingMessageBuffer.end();  )
     
    223225    it++;
    224226  }
    225  
     227
    226228  //walk throu message queue and remove acked messages
    227229  for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end();  )
     
    236238    it++;
    237239  }
    238  
     240
    239241  //TODO find bether way. maybe with timestamp
    240242  if ( messageQueue[userId].recievedMessages.size() > 1000 )
     
    255257  if ( messageQueue.find( userId ) == messageQueue.end() )
    256258    return;
    257    
     259
    258260  for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ )
    259261  {
     
    262264    it->data = NULL;
    263265  }
    264  
     266
    265267  messageQueue[userId].toAck.clear();
    266  
     268
    267269  messageQueue.erase( userId );
    268270}
     
    270272/**
    271273 * registers function to handle messages with id messageId. someData is passed to callbackfuntion
    272  * @param messageId message id to handle 
     274 * @param messageId message id to handle
    273275 * @param cb function pointer to callback function
    274276 * @param someData this pointer is passed to callback function without modification
     
    278280{
    279281  MessageHandler messageHandler;
    280  
     282
    281283  messageHandler.cb = cb;
    282284  messageHandler.messageId = messageId;
    283285  messageHandler.someData = someData;
    284  
     286
    285287  messageHandlerMap[messageId] = messageHandler;
    286  
     288
    287289  return true;
    288290}
     
    309311 * @param data pointer to data
    310312 * @param dataLength length of data
    311  * @param recieverType 
    312  * @param reciever 
     313 * @param recieverType
     314 * @param reciever
    313315 */
    314316void MessageManager::sendMessage( MessageId messageId, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority )
     
    316318  for ( MessageQueue::iterator it = messageQueue.begin(); it != messageQueue.end(); it++ )
    317319  {
    318     if ( 
     320    if (
    319321         recieverType == RT_ALL_ME ||
    320322         recieverType == RT_ALL_NOT_ME ||
    321323         recieverType == RT_USER && it->first == reciever ||
    322324         recieverType == RT_NOT_USER && it->first != reciever ||
    323          recieverType == RT_SERVER && getNetworkStream()->isUserServer( it->first )
     325         recieverType == RT_SERVER && getNetworkStream()->isUserMasterServer( it->first )
    324326       )
    325327    {
     
    336338    }
    337339  }
    338  
     340
    339341  if ( recieverType == RT_ALL_ME )
    340342  {
  • trunk/src/lib/network/netdefs.h

    r9246 r9406  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
    13
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11### File Specific:
     12   main-programmer: Christoph Renner rennerc@ee.ethz.ch
     13   co-programmer:   Patrick Boenzli  boenzlip@orxonox.ethz.ch
     14
     15     June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch)
     16     July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch)
     17*/
    218
    319/*!
    420 * @file network_manager.h
    521 *  Main interface for the network module. Manages all the modules
    6 
    722 */
    823
    9 #ifndef _NETDEFS
    10 #define _NETDEFS
     24#ifndef _NETDEFS_H
     25#define _NETDEFS_H
    1126
    12 #ifdef HAVE_SDL_NET_H
    13   #include <SDL_net.h>
    14 #else
    15   #include <SDL/SDL_net.h>
    16 #endif
     27#include "nettypes.h"
     28#include "netincl.h"
    1729
    1830
    19 #define MAX_CONNECTIONS 1000
    2031
     32//!< the amount of slots used before a proxy server is activated
     33#define NET_CONNECTION_SATURATION 0.75
     34
     35//!< network polling frequency
    2136#define NETWORK_FREQUENCY 66
    2237
    2338
    24 typedef unsigned char byte;
     39//!< orxonox protocol id
     40#define _ORXONOX_ID        0xF91337A0
     41//!< orxonox network version identifier
     42#define _ORXONOX_VERSION   1
    2543
    2644
    2745//!< enum indicating the type of the node
    2846typedef enum {
    29   NET_SERVER,
    30   NET_CLIENT
     47  NET_MASTER_SERVER,
     48  NET_PROXY_SERVER_ACTIVE,
     49  NET_PROXY_SERVER_PASSIVE,
     50  NET_CLIENT,
     51
     52  NET_NR_TYPES
     53
    3154} NodeType;
    3255
     
    4467} UidType;
    4568
    46 #endif /* _NETWORK_MANAGER */
     69#endif /* _NETDEFS_H */
  • trunk/src/lib/network/network_game_manager.cc

    r9235 r9406  
    1010
    1111### File Specific:
    12    main-programmer: Benjamin Wuest
    13    co-programmer: ...
     12   main-programmer: Christoph Renner rennerc@ee.ethz.ch
     13   co-programmer:   Patrick Boenzli  boenzlip@orxonox.ethz.ch
     14
     15     June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch)
     16     July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch)
    1417*/
    1518
    1619
    17 /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module
    18    For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
    19 */
     20
    2021#define DEBUG_MODULE_NETWORK
    2122
     
    4546
    4647
    47 /* using namespace std is default, this needs to be here */
    48 using namespace std;
     48
    4949
    5050NetworkGameManager* NetworkGameManager::singletonRef = NULL;
     
    6262
    6363  this->setSynchronized(true);
    64  
     64
    6565  MessageManager::getInstance()->registerMessageHandler( MSGID_DELETESYNCHRONIZEABLE, delSynchronizeableHandler, NULL );
    6666  MessageManager::getInstance()->registerMessageHandler( MSGID_PREFEREDTEAM, preferedTeamHandler, NULL );
    6767  MessageManager::getInstance()->registerMessageHandler( MSGID_CHATMESSAGE, chatMessageHandler, NULL );
    68  
     68
    6969  this->gameState = 0;
    7070  registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) );
     
    7777{
    7878  delete MessageManager::getInstance();
    79  
     79
    8080  PlayerStats::deleteAllPlayerStats();
    81  
     81
    8282  NetworkGameManager::singletonRef = NULL;
    8383}
     
    8686/**
    8787 * insert new player into game
    88  * @param userId 
    89  * @return 
     88 * @param userId
     89 * @return
    9090 */
    9191bool NetworkGameManager::signalNewPlayer( int userId )
    9292{
    93   assert( SharedNetworkData::getInstance()->isGameServer() );
     93  assert( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServer());
    9494  assert( State::getGameRules() );
    9595  assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
    96  
     96
    9797  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
    98  
     98
    9999  int team = rules.getTeamForNewUser();
    100100  ClassID playableClassId = rules.getPlayableClassId( userId, team );
     
    102102  std::string playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId );
    103103  float       playableScale = rules.getPlayableScale( userId, team, playableClassId );
    104  
     104
    105105  BaseObject * bo = Factory::fabricate( playableClassId );
    106  
     106
    107107  assert( bo != NULL );
    108108  assert( bo->isA( CL_PLAYABLE ) );
    109  
     109
    110110  Playable & playable = *(dynamic_cast<Playable*>(bo));
    111  
     111
    112112  playable.loadMD2Texture( playableTexture );
    113  
     113
    114114  playable.loadModel( playableModel, 100.0f );
    115115  playable.setOwner( userId );
    116116  playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    117117  playable.setSynchronized( true );
    118  
     118
    119119  PlayerStats * stats = rules.getNewPlayerStats( userId );
    120  
     120
    121121  stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    122122  stats->setSynchronized( true );
    123123  stats->setOwner( SharedNetworkData::getInstance()->getHostID() );
    124  
     124
    125125  stats->setTeamId( team );
    126126  stats->setPlayableClassId( playableClassId );
    127127  stats->setPlayableUniqueId( playable.getUniqueID() );
    128128  stats->setModelFileName( playableModel );
    129  
     129
    130130  if ( userId == 0 )
    131131    stats->setNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Server" ) );
    132  
     132
    133133  if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH ) )
    134134    dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f );
    135  
     135
    136136  return true;
    137137}
     
    140140/**
    141141 * remove player from game
    142  * @param userID 
    143  * @return 
     142 * @param userID
     143 * @return
    144144 */
    145145bool NetworkGameManager::signalLeftPlayer(int userID)
     
    151151    delete PlayerStats::getStats( userID );
    152152  }
    153  
     153
    154154  return true;
    155155}
     
    159159/**
    160160 * handler for remove synchronizeable messages
    161  * @param messageId 
    162  * @param data 
    163  * @param dataLength 
    164  * @param someData 
    165  * @param userId 
     161 * @param messageId
     162 * @param data
     163 * @param dataLength
     164 * @param someData
     165 * @param userId
    166166 * @return true on successfull handling else handler will be called again
    167167 */
    168168bool NetworkGameManager::delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
    169169{
    170   if ( getInstance()->isServer() )
     170  if ( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServer())
    171171  {
    172172    PRINTF(2)("Recieved DeleteSynchronizeable message from client %d!\n", userId);
    173173    return true;
    174174  }
    175  
     175
    176176  int uniqueId = 0;
    177177  int len = Converter::byteArrayToInt( data, &uniqueId );
    178  
     178
    179179  if ( len != dataLength )
    180180  {
     
    182182    return true;
    183183  }
    184  
     184
    185185  const std::list<BaseObject*> * list = ClassList::getList( CL_SYNCHRONIZEABLE );
    186  
     186
    187187  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    188188  {
     
    194194        return true;
    195195      }
    196      
     196
    197197      delete dynamic_cast<Synchronizeable*>(*it);
    198198      return true;
    199199    }
    200200  }
    201  
     201
    202202  return true;
    203203}
     
    210210{
    211211  byte buf[INTSIZE];
    212  
     212
    213213  assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE );
    214214
     
    220220/**
    221221 * handler for MSGID_PREFEREDTEAM message
    222  * @param messageId 
    223  * @param data 
    224  * @param dataLength 
    225  * @param someData 
    226  * @param userId 
    227  * @return 
     222 * @param messageId
     223 * @param data
     224 * @param dataLength
     225 * @param someData
     226 * @param userId
     227 * @return
    228228 */
    229229bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
    230230{
    231   assert( NetworkGameManager::getInstance()->isServer() );
    232  
     231  assert( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServer());
     232
    233233  int teamId = 0;
    234234  int len = Converter::byteArrayToInt( data, &teamId );
    235  
     235
    236236  if ( len != dataLength )
    237237  {
     
    239239    return true;
    240240  }
    241  
     241
    242242  NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId );
    243  
     243
    244244  return true;
    245245}
     
    249249  if ( !PlayerStats::getStats( userId ) )
    250250    return;
    251  
     251
    252252  PlayerStats & stats = *(PlayerStats::getStats( userId ));
    253  
     253
    254254  stats.setPreferedTeamId( teamId );
    255255}
     
    257257/**
    258258 * set prefered team for this host
    259  * @param teamId 
     259 * @param teamId
    260260 */
    261261void NetworkGameManager::prefereTeam( int teamId )
    262262{
    263   if ( isServer() )
     263  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
    264264    setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId );
    265265  else
    266266  {
    267267    byte buf[INTSIZE];
    268    
     268
    269269    assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE );
    270    
     270
    271271    MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH );
    272272  }
     
    285285    {
    286286      const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    287        
     287
    288288      if ( list && std::find( list->begin(), list->end(), *it ) != list->end() )
    289       {     
    290         PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassName(), (*it)->getOwner() );
     289      {
     290        PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassCName(), (*it)->getOwner() );
    291291        std::list<Playable*>::iterator delit = it;
    292292        it++;
     
    305305{
    306306  PRINTF(0)("NetworkGameManager::chatMessageHandler %d %d\n", userId, SharedNetworkData::getInstance()->getHostID() );
    307   if ( NetworkGameManager::getInstance()->isServer() && userId !=  SharedNetworkData::getInstance()->getHostID() )
     307  if ( (SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) && userId !=  SharedNetworkData::getInstance()->getHostID() )
    308308  {
    309309    MessageManager::getInstance()->sendMessage( messageId, data, dataLength, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
    310310  }
    311  
     311
    312312  assert( State::getGameRules() );
    313313  assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
    314  
     314
    315315  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
    316  
     316
    317317  if ( dataLength < 3*INTSIZE )
    318318  {
    319319    PRINTF(2)("got too small chatmessage from client %d\n", userId);
    320    
     320
    321321    return true;
    322322  }
    323  
     323
    324324  int messageType = 0;
    325325  Converter::byteArrayToInt( data, &messageType );
     
    328328  std::string message;
    329329  Converter::byteArrayToString( data+2*INTSIZE, message, dataLength-2*INTSIZE );
    330  
     330
    331331  rules.handleChatMessage( senderUserId, message, messageType );
    332332
     
    346346  assert( Converter::intToByteArray( SharedNetworkData::getInstance()->getHostID(), buf+INTSIZE, INTSIZE ) == INTSIZE );
    347347  assert( Converter::stringToByteArray(message, buf+2*INTSIZE, message.length()+INTSIZE) == message.length()+INTSIZE );
    348  
    349   if ( this->isServer() )
     348
     349  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
    350350    MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_ME, 0, MP_HIGHBANDWIDTH );
    351351  else
    352352    MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
    353353
    354  
     354
    355355  delete [] buf;
    356356}
  • trunk/src/lib/network/network_game_manager.h

    r8708 r9406  
    2828  NET_YOU_ARE_ENTITY,
    2929  NET_REQUEST_ENTITY_LIST,
    30   NET_REQUEST_PNODE_PATH,
    31   NET_SEND_PNODE_PATH,
    3230
    3331  NET_NUMBER
     
    4240
    4341/*!
    44  * a class that can create and remove entities
     42 * a class that can create and remove entities over the network
    4543 */
    4644class NetworkGameManager: public Synchronizeable
    4745{
     46
    4847  public:
    4948    virtual ~NetworkGameManager();
    50    
     49
    5150    static NetworkGameManager* NetworkGameManager::getInstance()
    5251    { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
     
    5554    bool signalNewPlayer( int userId );
    5655    bool signalLeftPlayer( int userID );
    57    
    58     void removeSynchronizeable( int uniqueId );
    59    
     56
    6057    void prefereTeam( int teamId );
     58
    6159
    6260    inline void setGameState( int gameState ){ this->gameState = gameState; }
    6361    inline int getGameState(){ return this->gameState; }
    64    
     62
    6563    void tick( float ds );
    66    
     64
     65    void removeSynchronizeable( int uniqueId );
    6766    void sendChatMessage( const std::string & message, int messageType );
     67
    6868
    6969  private:
    7070    NetworkGameManager();
    71    
     71
    7272    static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
    7373    static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
    7474    static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
    75    
     75
    7676    void setPreferedTeam( int userId, int teamId );
    7777
     78
     79  private:
    7880    static NetworkGameManager*    singletonRef;
    79    
     81
    8082    int                           gameState;
    81    
     83
    8284    std::list<Playable*>          playablesToDelete;
    8385};
  • trunk/src/lib/network/network_manager.cc

    r9059 r9406  
    1010
    1111   ### File Specific:
    12    main-programmer: Patrick Boenzli
    13    co-programmer: ...
     12   main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch)
     13   co-programmer: Christoph Renner (rennerc@ee.ethz.ch)
    1414*/
    1515
     
    3434
    3535/* using namespace std is default, this needs to be here */
    36 using namespace std;
     36
    3737
    3838SHELL_COMMAND(debug, NetworkManager, debug);
     
    5353  this->networkStream = NULL;
    5454  this->elapsedTime = 0.0f;
    55  
    56    
     55
     56
    5757  int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 );
    58  
     58
    5959  if ( port > 0 )
    6060    NetworkLog::getInstance()->listen( port );
     
    7575    this->networkStream = NULL;
    7676  }
    77  
     77
    7878  NetworkManager::singletonRef = NULL;
    7979}
     
    9595{
    9696
     97}
     98
     99
     100
     101/**
     102 *  creates a new NetworkStream of server type
     103 * @param port: number of the TCP port
     104 */
     105int NetworkManager::createMasterServer(unsigned int port)
     106{
     107  // load the network settings
     108  NetworkSettings::getInstance()->loadData();
     109
     110  // create the network stream
     111  this->networkStream = new NetworkStream(NET_MASTER_SERVER);
     112  this->networkStream->createServer( port);
     113
     114  // start the network game manager
     115  this->networkStream->createNetworkGameManager();
     116
     117  PRINTF(0)("Created Network Master Server\n");
     118  SDL_Delay(20);
     119  return 1;
     120}
     121
     122/**
     123 *  creates a new network stream of proxy server type
     124 * @param port: number of the TCP port
     125 */
     126int NetworkManager::createProxyServer(unsigned int port)
     127{
     128  // load the network settings
     129  NetworkSettings::getInstance()->loadData();
     130
     131  // create the network stream
     132  this->networkStream = new NetworkStream(NET_PROXY_SERVER_ACTIVE);
     133  this->networkStream->createServer( port);
     134  // and connect to the master server for synchronization
     135//   this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr());
     136  // and to the other proxy servers
     137
     138
     139
     140  // start the network game manager
     141  this->networkStream->createNetworkGameManager();
     142
     143
     144  PRINTF(0)("Created Network Proxy Server\n");
     145  SDL_Delay(20);
     146  return 1;
    97147}
    98148
     
    102152 * @param hostName: the name of the destination host
    103153 */
    104 int NetworkManager::establishConnection(const std::string & name, unsigned int port)
    105 {
    106   this->networkStream = new NetworkStream( name, port );
    107   SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
     154int NetworkManager::createClient(const std::string & name, unsigned int port)
     155{
     156  // load the network settings
     157  NetworkSettings::getInstance()->loadData();
     158
     159  // create the network stream
     160  this->networkStream = new NetworkStream(NET_CLIENT);
     161  // connect to the master server, if a redirection should occure, this is handled in the NetworkStream itself
     162  this->networkStream->connectToMasterServer( name, port);
     163
     164  // and start the handshake
    108165  this->networkStream->startHandshake();
     166
     167  PRINTF(0)("Created Network Client");
    109168  return 1;
    110169}
     
    112171
    113172/**
    114  *  creates a new NetworkStream of server type
    115  * @param port: number of the TCP port
    116  */
    117 int NetworkManager::createServer(unsigned int port)
    118 {
    119   SharedNetworkData::getInstance()->setHostID(0);
    120   SharedNetworkData::getInstance()->setGameServer(true);
    121   this->networkStream = new NetworkStream(port);
    122   SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
    123   this->networkStream->createNetworkGameManager();
    124   PRINTF(0)("CREATE SERVER\n");
    125   SDL_Delay(20);
    126   return 1;
    127 }
    128 
    129 
     173 * connects a synchronizeable to the network stream
     174 * @param sync: synchronizeable to connect
     175 */
    130176void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
    131177{
     
    144190  if( likely(this->elapsedTime < 1.0f / NETWORK_FREQUENCY))
    145191    return;
     192
    146193  this->elapsedTime = 0.0f;
    147194
    148   if ( networkStream )
     195  if ( this->networkStream )
    149196    networkStream->processData();
    150  
     197
    151198  NetworkGameManager::getInstance()->tick( this->elapsedTime );
    152199}
  • trunk/src/lib/network/network_manager.h

    r9059 r9406  
    3636    void shutdown();
    3737
    38     int establishConnection( const std::string & name, unsigned int port);
    39     int createServer(unsigned int port);
    40 
    41     /** Returns the hostID @return The hostID of the object */
    42     inline int getHostID() { return SharedNetworkData::getInstance()->getHostID(); }
    43     inline bool isGameServer() { return SharedNetworkData::getInstance()->isGameServer(); }
    44 
     38    int createClient( const std::string & name, unsigned int port);
     39    int createMasterServer( unsigned int port);
     40    int createProxyServer( unsigned int port);
    4541
    4642    void connectSynchronizeable(Synchronizeable& sync);
     
    5652  private:
    5753    static NetworkManager*           singletonRef;            //!< Pointer to the only instance of this Class
    58     NetworkStream*                   networkStream;       //!< pointer to network stream
     54    NetworkStream*                   networkStream;           //!< pointer to network stream
    5955
    6056    float                            elapsedTime;             //!< elapsed time since the last network update
  • trunk/src/lib/network/network_protocol.cc

    r6341 r9406  
    3333
    3434/* using namespace std is default, this needs to be here */
    35 using namespace std;
     35
    3636
    3737
  • trunk/src/lib/network/network_socket.cc

    r7954 r9406  
    3333{
    3434  bOk = true;
     35  this->ip.host = 0;
     36  this->ip.port = 0;
    3537}
    3638
  • trunk/src/lib/network/network_socket.h

    r7954 r9406  
    2727     */
    2828    virtual void connectToServer( std::string host, int port ) = 0;
    29    
     29
    3030    /**
    3131     * disconnect from server
    3232     */
    3333    virtual void disconnectServer() = 0;
     34
     35    /**
     36     * reconnecting to another server by terminating old connection and init a new connection
     37     */
     38    virtual void reconnectToServer( std::string host, int port) = 0;
     39
     40    /**
     41     * reconnecting to anoter server softly
     42     */
     43    virtual void reconnectToServerSoft( std::string host, int port) = 0;
    3444
    3545    /**
     
    4050     */
    4151    virtual bool writePacket(byte * data, int length) = 0;
    42    
     52
    4353    /**
    4454     * read a packet sent by another NetworkSocket
     
    5464     */
    5565    inline bool isOk() { return this->bOk; }
    56  
     66
     67    /** @returns the ip adderess of the destination socket */
     68    IPaddress getRemoteAddress() { return ip; }
     69
     70
    5771  protected:
    58     bool bOk;            //!< check for socket status
     72    bool              bOk;            //!< check for socket status
    5973
     74    IPaddress         ip;             //!< host,port
    6075};
    6176
  • trunk/src/lib/network/network_stream.cc

    r9246 r9406  
    1212   main-programmer: Christoph Renner rennerc@ee.ethz.ch
    1313   co-programmer:   Patrick Boenzli  boenzlip@orxonox.ethz.ch
     14
     15     June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch)
     16     July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch)
    1417*/
    1518
     
    2225#include "udp_socket.h"
    2326#include "udp_server_socket.h"
    24 #include "connection_monitor.h"
     27#include "monitor/connection_monitor.h"
     28#include "monitor/network_monitor.h"
    2529#include "synchronizeable.h"
     30#include "ip.h"
    2631#include "network_game_manager.h"
    2732#include "shared_network_data.h"
     
    4247#include <algorithm>
    4348
    44 /* include your own header */
     49
    4550#include "network_stream.h"
    4651
    47 /* probably unnecessary */
    48 using namespace std;
     52
     53#include "converter.h"
    4954
    5055
     
    5257
    5358
     59/**
     60 * empty constructor
     61 */
    5462NetworkStream::NetworkStream()
    5563    : DataStream()
     
    5765  this->init();
    5866  /* initialize the references */
    59   this->type = NET_CLIENT;
    60 }
    61 
    62 
    63 /**
    64  * connect to a server as a client
    65  *  @param host: host name (address)
    66  *  @param port: port number
    67  */
    68 NetworkStream::NetworkStream( std::string host, int port )
    69 {
    70   this->type = NET_CLIENT;
     67  this->pInfo->nodeType = NET_CLIENT;
     68}
     69
     70
     71NetworkStream::NetworkStream( int nodeType)
     72{
    7173  this->init();
    72   this->peers[0].socket = new UdpSocket( host, port );
    73   this->peers[0].userId = 0;
    74   this->peers[0].isServer = true;
    75   this->peers[0].connectionMonitor = new ConnectionMonitor( 0 );
    76 }
    77 
    78 
    79 /**
    80  * start as a server
    81  *  @param port: at this port
    82  */
    83 NetworkStream::NetworkStream( int port )
    84 {
    85   this->type = NET_SERVER;
    86   this->init();
    87   this->serverSocket = new UdpServerSocket(port);
    88   this->bActive = true;
    89 }
     74
     75  this->pInfo->nodeType = nodeType;
     76
     77  switch( nodeType)
     78  {
     79    case NET_MASTER_SERVER:
     80      // init the shared network data
     81      SharedNetworkData::getInstance()->setHostID(0);
     82//       SharedNetworkData::getInstance()->setNodeType(NET_MASTER_SERVER);
     83      break;
     84
     85    case NET_PROXY_SERVER_ACTIVE:
     86      // init the shared network data
     87      SharedNetworkData::getInstance()->setHostID(0);
     88//       SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_ACTIVE);
     89      break;
     90    case NET_PROXY_SERVER_PASSIVE:
     91            // init the shared network data
     92      SharedNetworkData::getInstance()->setHostID(0);
     93//       SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_PASSIVE);
     94      break;
     95    case NET_CLIENT:
     96//       SharedNetworkData::getInstance()->setNodeType(NET_CLIENT);
     97      break;
     98  }
     99
     100  SharedNetworkData::getInstance()->setDefaultSyncStream(this);
     101
     102  // get the local ip address
     103  IPaddress ip;
     104  SDLNet_ResolveHost( &ip, NULL, 0);
     105  this->pInfo->ip = ip;
     106}
     107
    90108
    91109
     
    97115  /* set the class id for the base object */
    98116  this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
    99   this->bActive = false;
    100117  this->serverSocket = NULL;
    101118  this->networkGameManager = NULL;
    102   myHostId = 0;
    103   currentState = 0;
     119  this->networkMonitor = NULL;
     120
     121  this->pInfo = new PeerInfo();
     122  this->pInfo->userId = 0;
     123  this->pInfo->lastAckedState = 0;
     124  this->pInfo->lastRecvedState = 0;
     125
     126
     127  this->currentState = 0;
    104128
    105129  remainingBytesToWriteToDict = Preferences::getInstance()->getInt( "compression", "writedict", 0 );
     
    147171  for ( SynchronizeableList::const_iterator it = getSyncBegin(); it != getSyncEnd(); it ++ )
    148172    (*it)->setNetworkStream( NULL );
     173
     174  if( this->pInfo)
     175    delete this->pInfo;
     176
     177  if( this->networkMonitor)
     178    delete this->networkMonitor;
     179}
     180
     181
     182/**
     183 * establish a connection to a remote master server
     184 * @param host: host name
     185 * @param port: the port number
     186 */
     187void NetworkStream::connectToMasterServer(std::string host, int port)
     188{
     189  int node = this->peers.size();
     190  this->peers[node].socket = new UdpSocket( host, port );
     191  this->peers[node].userId = 0;
     192
     193  this->peers[node].nodeType = NET_MASTER_SERVER;
     194  this->peers[node].connectionMonitor = new ConnectionMonitor( 0 );
     195  this->peers[node].ip = this->peers[node].socket->getRemoteAddress();
     196}
     197
     198
     199/**
     200 * establish a connection to a remote proxy server
     201 * @param host: host name
     202 * @param port: the port number
     203 */
     204void NetworkStream::connectToProxyServer(std::string host, int port)
     205{
     206  int node = this->peers.size();
     207  this->peers[node].socket = new UdpSocket( host, port );
     208  this->peers[node].userId = 0;
     209
     210  this->peers[node].nodeType = NET_PROXY_SERVER_ACTIVE;
     211  this->peers[node].connectionMonitor = new ConnectionMonitor( 0 );
     212  this->peers[node].ip = this->peers[node].socket->getRemoteAddress();
     213}
     214
     215
     216/**
     217 * create a server
     218 * @param port: interface port for all clients
     219 */
     220void NetworkStream::createServer(int port)
     221{
     222  this->serverSocket = new UdpServerSocket(port);
    149223}
    150224
     
    156230{
    157231  this->networkGameManager = NetworkGameManager::getInstance();
    158   // setUniqueID( maxCon+2 ) because we need one id for every handshake
    159   // and one for handshake to reject client maxCon+1
     232
    160233  this->networkGameManager->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    161234  MessageManager::getInstance()->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
     
    165238/**
    166239 * starts the network handshake
     240 * handsakes are always initialized from the client side first. this starts the handshake and therefore is only
     241 * executed as client
    167242 */
    168243void NetworkStream::startHandshake()
    169244{
    170   Handshake* hs = new Handshake(false);
     245  Handshake* hs = new Handshake(this->pInfo->nodeType);
    171246  hs->setUniqueID( 0 );
    172247  assert( peers[0].handshake == NULL );
    173248  peers[0].handshake = hs;
    174249
     250  // set the preferred nick name
    175251  hs->setPreferedNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Player" ) );
    176252
    177 //   peers[0].handshake->setSynchronized( true );
    178   //this->connectSynchronizeable(*hs);
    179   //this->connectSynchronizeable(*hs);
    180   PRINTF(0)("NetworkStream: Handshake created: %s\n", hs->getName());
     253  PRINTF(0)("NetworkStream: Handshake created: %s\n", hs->getCName());
    181254}
    182255
     
    192265  sync.setNetworkStream( this );
    193266
    194   this->bActive = true;
     267//   this->bActive = true;
    195268}
    196269
     
    215288void NetworkStream::processData()
    216289{
     290  // create the network monitor after all the init work and before there is any connection handlings
     291  if( this->networkMonitor == NULL)
     292    this->networkMonitor = new NetworkMonitor(this);
     293
     294
    217295  int tick = SDL_GetTicks();
    218296
    219   currentState++;
    220 
    221   if ( this->type == NET_SERVER )
    222   {
     297  this->currentState++;
     298  // there was a wrap around
     299  if( this->currentState < 0)
     300  {
     301    PRINTF(1)("A wrap around in the state variable as occured. The server was running so long? Pls restart server or write a mail to the supporters!\n");
     302  }
     303
     304  if ( this->pInfo->isMasterServer())
     305  {
     306    // execute everytthing the master server shoudl do
     307    if ( serverSocket )
     308      serverSocket->update();
     309
     310    this->updateConnectionList();
     311  }
     312  else if( this->pInfo->isProxyServer())
     313  {
     314    // execute everything the proxy server should do
    223315    if ( serverSocket )
    224316      serverSocket->update();
     
    249341  cleanUpOldSyncList();
    250342  handleHandshakes();
     343
     344  // update the network monitor
     345  this->networkMonitor->process();
    251346
    252347  // order of up/downstream is important!!!!
     
    258353
    259354/**
    260  * if we are a server update the connection list to accept new connections (clients)
    261  * also start the handsake for the new clients
     355 * if we are a NET_MASTER_SERVER or NET_PROXY_SERVER_ACTIVE update the connection list to accept new
     356 * connections (clients) also start the handsake for the new clients
    262357 */
    263358void NetworkStream::updateConnectionList( )
     
    276371      clientId = freeSocketSlots.back();
    277372      freeSocketSlots.pop_back();
    278       peers[clientId].socket = tempNetworkSocket;
    279       peers[clientId].handshake = new Handshake(true, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID() );
    280       peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
    281       peers[clientId].handshake->setUniqueID(clientId);
    282       peers[clientId].userId = clientId;
    283       peers[clientId].isServer = false;
    284373    }
    285374    else
     
    290379        if ( it->first >= clientId )
    291380          clientId = it->first + 1;
    292 
    293       peers[clientId].socket = tempNetworkSocket;
    294       peers[clientId].handshake = new Handshake(true, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
    295       peers[clientId].handshake->setUniqueID(clientId);
    296       peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
    297       peers[clientId].userId = clientId;
    298       peers[clientId].isServer = false;
    299 
    300       PRINTF(0)("num sync: %d\n", synchronizeables.size());
    301     }
    302 
    303     // check if there are too many clients connected
    304     if ( clientId > MAX_CONNECTIONS )
    305     {
    306       peers[clientId].handshake->doReject( "too many connections" );
    307       PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId);
    308     }
    309     else
    310     {
    311       PRINTF(0)("New Client: %d\n", clientId);
    312     }
    313 
    314     //this->connectSynchronizeable(*handshakes[clientId]);
     381    }
     382    peers[clientId].socket = tempNetworkSocket;
     383
     384
     385    // create new handshake and init its variables
     386    peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
     387    peers[clientId].handshake->setUniqueID(clientId);
     388
     389    peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
     390    peers[clientId].userId = clientId;
     391
     392    PRINTF(0)("num sync: %d\n", synchronizeables.size());
     393
     394    // get the proxy server informations and write them to the handshake, if any (proxy)
     395    assert( this->networkMonitor != NULL);
     396    PeerInfo* pi = this->networkMonitor->getFirstChoiceProxy();
     397    if( pi != NULL)
     398    {
     399      peers[clientId].handshake->setProxy1Address( pi->ip);
     400    }
     401    pi = this->networkMonitor->getSecondChoiceProxy();
     402    if( pi != NULL)
     403      peers[clientId].handshake->setProxy2Address( pi->ip);
     404
     405    // check if the connecting client should reconnect to a proxy server
     406    peers[clientId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);
     407
     408    // the connecting node of course is a client
     409    peers[clientId].nodeType = NET_CLIENT;
     410    peers[clientId].ip = peers[clientId].socket->getRemoteAddress();
     411
     412
     413    // check if there are too many clients connected (DEPRECATED: new: the masterserver sends a list of proxy servers)
     414//     if ( clientId > SharedNetworkData::getInstance()->getMaxPlayer() )
     415//     {
     416// //       peers[clientId].handshake->setRedirect(true);
     417// //
     418// //       peers[clientId].handshake->doReject( "too many connections" );
     419//       PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId);
     420//     }
     421//     else
     422//     {
     423//       PRINTF(0)("New Client: %d\n", clientId);
     424//     }
     425    PRINTF(0)("New Client: %d\n", clientId);
     426
     427
    315428  }
    316429
     
    339452      it->second.socket = NULL;
    340453
     454      // remove the old connectin monitor
    341455      if ( it->second.connectionMonitor )
    342456        delete it->second.connectionMonitor;
    343457      it->second.connectionMonitor = NULL;
    344458
     459      // remove the handshake
    345460      if ( it->second.handshake )
    346461        delete it->second.handshake;
    347462      it->second.handshake = NULL;
    348463
     464      // and cleanup the user infos
    349465      for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )
    350466      {
     
    373489void NetworkStream::debug()
    374490{
    375   if( this->isServer())
    376     PRINT(0)(" Host ist Server with ID: %i\n", this->myHostId);
    377   else
    378     PRINT(0)(" Host ist Client with ID: %i\n", this->myHostId);
     491  if( SharedNetworkData::getInstance()->isMasterServer()) {
     492    PRINT(0)(" Host ist Master Server with ID: %i\n", this->pInfo->userId);
     493  }
     494  else if( SharedNetworkData::getInstance()->isProxyServer()) {
     495    PRINT(0)(" Host ist Proxy Server with ID: %i\n", this->pInfo->userId);
     496  }
     497  else {
     498    PRINT(0)(" Host ist Client with ID: %i\n", this->pInfo->userId);
     499  }
    379500
    380501  PRINT(0)(" Got %i connected Synchronizeables, showing active Syncs:\n", this->synchronizeables.size());
     
    382503  {
    383504    if( (*it)->beSynchronized() == true)
    384       PRINT(0)("  Synchronizeable of class: %s::%s, with unique ID: %i, Synchronize: %i\n", (*it)->getClassName(), (*it)->getName(),
     505      PRINT(0)("  Synchronizeable of class: %s::%s, with unique ID: %i, Synchronize: %i\n", (*it)->getClassCName(), (*it)->getCName(),
    385506               (*it)->getUniqueID(), (*it)->beSynchronized());
    386507  }
    387   PRINT(0)(" Maximal Connections: %i\n", MAX_CONNECTIONS );
     508  PRINT(0)(" Maximal Connections: %i\n", SharedNetworkData::getInstance()->getMaxPlayer() );
    388509
    389510}
     
    414535    if ( it->second.handshake )
    415536    {
     537      // handshake finished
    416538      if ( it->second.handshake->completed() )
    417539      {
     540        //handshake is correct
    418541        if ( it->second.handshake->ok() )
    419542        {
     543          // the server gave it free for deletion
    420544          if ( !it->second.handshake->allowDel() )
    421545          {
    422             if ( type != NET_SERVER )
     546
     547            if ( this->pInfo->isClient() )
    423548            {
    424549              SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() );
    425               myHostId = SharedNetworkData::getInstance()->getHostID();
    426 
     550              this->pInfo->userId = SharedNetworkData::getInstance()->getHostID();
     551
     552              it->second.nodeType = it->second.handshake->getRemoteNodeType();
     553              it->second.ip = it->second.socket->getRemoteAddress();
     554              // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER)
     555              this->networkMonitor->addNode(&it->second);
     556              // get proxy 1 address and add it
     557              this->networkMonitor->addNode(it->second.handshake->getProxy1Address(), NET_PROXY_SERVER_ACTIVE);
     558              // get proxy 2 address and add it
     559              this->networkMonitor->addNode(it->second.handshake->getProxy2Address(), NET_PROXY_SERVER_ACTIVE);
     560
     561              // now check if the server accepted the connection
     562              if( it->second.handshake->redirect())
     563                this->handleReconnect( it->second.userId);
     564
     565              // create the new network game manager and init it
    427566              this->networkGameManager = NetworkGameManager::getInstance();
    428567              this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() );
     568              // init the new message manager
    429569              MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() );
    430570            }
     
    432572
    433573            PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId());
    434 
    435574            it->second.handshake->del();
    436575          }
    437576          else
    438577          {
     578            // handshake finished registring new player
    439579            if ( it->second.handshake->canDel() )
    440580            {
    441               if ( type == NET_SERVER )
     581
     582              if ( this->pInfo->isMasterServer() )
    442583              {
    443                 handleNewClient( it->second.userId );
     584                it->second.nodeType = it->second.handshake->getRemoteNodeType();
     585                it->second.ip = it->second.socket->getRemoteAddress();
     586
     587                this->networkMonitor->addNode(&it->second);
     588
     589                this->handleNewClient( it->second.userId );
     590
     591                if ( PlayerStats::getStats( it->second.userId ) && it->second.handshake->getPreferedNickName() != "" )
     592                {
     593                  PlayerStats::getStats( it->second.userId )->setNickName( it->second.handshake->getPreferedNickName() );
     594                }
     595              }
     596              else if ( this->pInfo->isProxyServer() )
     597              {
     598                it->second.nodeType = it->second.handshake->getRemoteNodeType();
     599                it->second.ip = it->second.socket->getRemoteAddress();
     600
     601                this->networkMonitor->addNode(&it->second);
     602
     603                this->handleNewClient( it->second.userId );
    444604
    445605                if ( PlayerStats::getStats( it->second.userId ) && it->second.handshake->getPreferedNickName() != "" )
     
    468628
    469629/**
     630 * this functions handles a reconnect event received from the a NET_MASTER_SERVER or NET_PROXY_SERVER
     631 */
     632void NetworkStream::handleReconnect(int userId)
     633{
     634  PRINTF(0)("===============================================\n");
     635  PRINTF(0)("Client is redirected to the other proxy servers\n");
     636  PRINTF(0)("===============================================\n");
     637
     638  return;
     639
     640  PeerInfo* pInfo = &this->peers[userId];
     641
     642  // reject the server
     643  pInfo->handshake->doReject( "redirected to different server");
     644
     645  // flush the old synchronization states, since the numbering could be completely different
     646  pInfo->lastAckedState = 0;
     647  pInfo->lastRecvedState = 0;
     648  // not sure if this works as expected
     649  if( pInfo->handshake)
     650    delete pInfo->handshake;
     651
     652  // disconnect from the current server and reconnect to proxy server
     653  pInfo->socket->reconnectToServer( pInfo->handshake->getProxy1Address().ipString(), pInfo->handshake->getProxy1Address().port());
     654
     655  // and restart the handshake
     656  this->startHandshake();
     657}
     658
     659
     660/**
    470661 * handle upstream network traffic
    471662 */
     
    501692    for ( SynchronizeableList::iterator it = synchronizeables.begin(); it != synchronizeables.end(); it++ )
    502693    {
     694
    503695      int oldOffset = offset;
    504696      Synchronizeable & sync = **it;
     697
    505698
    506699      // do not include synchronizeables with uninit id and syncs that don't want to be synchronized
     
    512705        continue;
    513706
    514       // if we are a server and this is not our handshake
    515       if ( isServer() && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
     707      // if we are a server (both master and proxy servers) and this is not our handshake
     708      if ( ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() ) && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
    516709        continue;
    517710
     
    521714        continue;
    522715
     716
     717      assert( sync.getLeafClassID() != 0);
     718
    523719      assert( offset + INTSIZE <= UDP_PACKET_SIZE );
    524720
    525721      // server fakes uniqueid == 0 for handshake
    526       if ( this->isServer() && sync.getUniqueID() < MAX_CONNECTIONS - 1 )
     722      if ( ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() ) &&
     723             sync.getUniqueID() <= SharedNetworkData::getInstance()->getMaxPlayer() + 1) // plus one to handle one client more than the max to redirect it
    527724        n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset );
    528725      else
    529726        n = Converter::intToByteArray( sync.getUniqueID(), buf + offset, UDP_PACKET_SIZE - offset );
    530727
     728
    531729      assert( n == INTSIZE );
    532730      offset += n;
    533731
    534       // make space for size
     732      // make space for packet size
    535733      offset += INTSIZE;
    536734
     
    573771    // now compress the data with the zip library
    574772    int compLength = 0;
    575     if ( this->isServer() )
     773    if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
    576774      compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictServer );
    577775    else
     
    637835      assert( Converter::byteArrayToInt( buf + 2*INTSIZE, &fromState ) == INTSIZE );
    638836      assert( Converter::byteArrayToInt( buf + 3*INTSIZE, &ackedState ) == INTSIZE );
    639       //NETPRINTF(n)("ackedstate: %d\n", ackedState);
    640837      offset = 4*INTSIZE;
    641838
    642839      peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, packetLength, state, ackedState );
    643840
    644       //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);
    645 
    646     //if this is an old state drop it
     841
     842      //if this is an old state drop it
    647843      if ( state <= peer->second.lastRecvedState )
    648844        continue;
     
    655851      }
    656852
    657       while ( offset + 2*INTSIZE < length )
     853      while ( offset + 2 * INTSIZE < length )
    658854      {
    659855        assert( offset > 0 );
     
    669865        Synchronizeable * sync = NULL;
    670866
     867        // look for the synchronizeable in question
    671868        for ( SynchronizeableList::iterator it = synchronizeables.begin(); it != synchronizeables.end(); it++ )
    672869        {
    673         //                                        client thinks his handshake has id 0!!!!!
     870          // client thinks his handshake has id 0!!!!!
    674871          if ( (*it)->getUniqueID() == uniqueId || ( uniqueId == 0 && (*it)->getUniqueID() == peer->second.userId ) )
    675872          {
     
    679876        }
    680877
     878        // this synchronizeable does not yet exist! create it
    681879        if ( sync == NULL )
    682880        {
    683881          PRINTF(0)("could not find sync with id %d. try to create it\n", uniqueId);
     882
     883          // if it is an old synchronizeable already removed, ignore it
    684884          if ( oldSynchronizeables.find( uniqueId ) != oldSynchronizeables.end() )
    685885          {
     
    688888          }
    689889
    690           if ( !peers[peer->second.userId].isServer )
     890          // if the node we got this unknown sync from is a client we ignore it (since it has no rights to create a new sync)
     891          if ( peers[peer->second.userId].isClient() )
    691892          {
    692893            offset += syncDataLength;
     
    705906          assert( leafClassId != 0 );
    706907
     908
    707909          BaseObject * b = NULL;
    708910          /* These are some small exeptions in creation: Not all objects can/should be created via Factory */
     
    710912          if( leafClassId == CL_NULL_PARENT || leafClassId == CL_SYNCHRONIZEABLE || leafClassId == CL_NETWORK_GAME_MANAGER )
    711913          {
    712             PRINTF(1)("Can not create Class with ID %x!\n", (int)leafClassId);
     914            PRINTF(1)("Don't create Object with ID %x, ignored!\n", (int)leafClassId);
    713915            offset += syncDataLength;
    714916            continue;
     
    730932            sync->setSynchronized(true);
    731933
    732             PRINTF(0)("Fabricated %s with id %d\n", sync->getClassName(), sync->getUniqueID());
     934            PRINTF(0)("Fabricated %s with id %d\n", sync->getClassCName(), sync->getUniqueID());
    733935          }
    734936          else
     
    744946        int n = sync->setStateDiff( peer->second.userId, buf+offset, syncDataLength, state, fromState );
    745947        offset += n;
    746         //NETPRINTF(0)("SSSSSEEEEETTTTT: %s %d\n",sync->getClassName(), n);
    747948
    748949      }
     
    779980/**
    780981 * is executed when a handshake has finished
    781  * @todo create playable for new user
    782982 */
    783983void NetworkStream::handleNewClient( int userId )
    784984{
     985  // init and assign the message manager
    785986  MessageManager::getInstance()->initUser( userId );
    786 
     987  // do all game relevant stuff here
    787988  networkGameManager->signalNewPlayer( userId );
    788989}
     990
    789991
    790992/**
  • trunk/src/lib/network/network_stream.h

    r9246 r9406  
    1414#include "server_socket.h"
    1515#include "handshake.h"
    16 #include "connection_monitor.h"
     16#include "monitor/connection_monitor.h"
    1717#include "udp_server_socket.h"
     18#include "peer_info.h"
     19
     20#include "shared_network_data.h"
    1821
    1922class Synchronizeable;
     
    2124class ServerSocket;
    2225class NetworkGameManager;
     26class NetworkMonitor;
    2327
    24 //!< this structure contains informations about the network node
    25 class PeerInfo
    26 {
    27   public:
    28     PeerInfo() { clear(); }
    29     void clear() { userId = 0; isServer = false; socket = NULL; handshake = NULL; lastAckedState = 0; lastRecvedState = 0; connectionMonitor = NULL; }
    30 
    31 
    32   public:
    33     int                 userId;
    34     bool                isServer;
    35     NetworkSocket *     socket;
    36     Handshake *         handshake;
    37     ConnectionMonitor * connectionMonitor;
    38     int                 lastAckedState;
    39     int                 lastRecvedState;
    40 };
    4128
    4229typedef std::list<Synchronizeable*>  SynchronizeableList;
     
    4936  public:
    5037    NetworkStream();
    51     NetworkStream( std::string host, int port);
    52     NetworkStream( int port );
     38    NetworkStream(int nodeType);
     39    virtual ~NetworkStream();
    5340
    54     virtual ~NetworkStream();
    5541    void init();
     42
     43    void connectToMasterServer(std::string host, int port);
     44    void connectToProxyServer(std::string host, int port);
     45    void createServer(int port);
    5646
    5747    void createNetworkGameManager();
    5848    void startHandshake();
    5949
     50    /* synchronizeable interface */
    6051    void connectSynchronizeable(Synchronizeable& sync);
    6152    void disconnectSynchronizeable(Synchronizeable& sync);
    6253
    63     inline bool isServer() const { return (this->type == NET_SERVER)? true:false; }
    64     inline bool isActive() const { return this->bActive; }
     54    inline int getMaxConnections(){ return SharedNetworkData::getInstance()->getMaxPlayer(); }
    6555
    66     inline int getMaxConnections(){ return MAX_CONNECTIONS; }
     56    /* functions for the peerInfo information retreival */
     57    inline bool isUserIdActive( int userID ) { return (peers.find(userID) != peers.end()); }
     58    inline bool isUserMasterServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isMasterServer(); }
     59    inline bool isUserProxyServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isProxyServer(); }
     60    inline bool isUserClient( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isClient(); }
    6761
     62    /* peering interface */
     63    inline PeerInfo & getPeerInfo( int userId ) { return peers[userId]; }
     64    inline PeerInfo* getPeerInfo() { return this->pInfo; }
     65    inline PeerList getPeerInfoList() { return this->peers; }
     66
     67    /* data processing*/
    6868    virtual void processData();
     69
     70    /* debugging */
     71    void debug();
     72
     73
     74  private:
    6975
    7076    inline SynchronizeableList::const_iterator getSyncBegin(){ return synchronizeables.begin(); }
    7177    inline SynchronizeableList::const_iterator getSyncEnd(){ return synchronizeables.end(); }
     78    void cleanUpOldSyncList();
    7279    int getSyncCount();
    7380
    74     inline bool isUserIdActive( int userID ) { return (peers.find(userID) != peers.end()); }
    75     inline bool isUserServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isServer; }
    76 
    77     void debug();
    78 
    79     inline PeerInfo & getPeerInfo( int userId ) { return peers[userId]; }
    80 
    81 
    82   private:
    8381    void updateConnectionList();
     82    /* handle processes */
    8483    void handleHandshakes();
    8584    void handleUpstream( int tick );
    8685    void handleDownstream(int tick );
     86
     87    /* handle events*/
    8788    void handleNewClient( int userId );
    88     void cleanUpOldSyncList();
     89    void handleReconnect( int userId );
    8990
    9091    void writeToNewDict( byte * data, int length, bool upstream );
     
    9293
    9394  private:
    94     SynchronizeableList        synchronizeables;
    95     PeerList                   peers;
    96     ServerSocket*              serverSocket;
    97     int                        type;
    98     bool                       bActive;
    99     std::list<int>             freeSocketSlots;
     95    PeerList                   peers;                       //!< list of the network node informations
    10096
    101     int                        myHostId;
     97    PeerInfo*                  pInfo;                       //!< the info about the local peer node (not in the PeerList)
    10298
     99    std::list<int>             freeSocketSlots;             //!< list of free sockets (to ensure not to resycle sockets)
    103100    int                        currentState;                //!< current state id
    104101
    105     NetworkGameManager*        networkGameManager;
     102    NetworkMonitor*            networkMonitor;              //!< the network monitor
     103    NetworkGameManager*        networkGameManager;          //!< reference to the network game manager
     104    ServerSocket*              serverSocket;                //!< the listening socket of the server
    106105
    107106    std::map<int,int>          oldSynchronizeables;         //!< used to save recently deleted sync ids to not recreate them
     107    SynchronizeableList        synchronizeables;            //!< list of the synchronizeables
    108108
    109109    byte                       buf[UDP_PACKET_SIZE];        //!< used by handleUp/Downstream
    110110    byte                       compBuf[UDP_PACKET_SIZE];    //!< used by handleUp/Downstream
    111 
    112111    int                        remainingBytesToWriteToDict; //!< if > 0 NetworkStream will write packets to DATA/dicts/newdict
    113112
    114     int dictServer;
    115     int dictClient;
     113    int                        dictServer;                  //!< the zip dict for the server
     114    int                        dictClient;                  //!< the zip dict for the client
    116115};
    117116#endif /* _NETWORK_STREAM */
  • trunk/src/lib/network/player_stats.cc

    r9235 r9406  
    2323#include "shared_network_data.h"
    2424
     25#include "converter.h"
     26
    2527#include "preferences.h"
    2628
     
    3840{
    3941  init();
    40  
     42
    4143  this->userId = userId;
    4244}
     
    6264  this->nickName = "Player";
    6365  this->oldNickName = "Player";
    64  
     66
    6567  userId_handle = registerVarId( new SynchronizeableInt( &userId, &userId, "userId" ) );
    6668  teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );
     
    7173  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    7274  nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName" ) );
    73  
     75
    7476  MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGENICKNAME, changeNickHandler, NULL );
    75  
     77
    7678  PRINTF(0)("PlayerStats created\n");
    7779}
     
    9698  {
    9799    this->setPlayableUniqueId( this->playableUniqueId );
    98    
     100
    99101    PRINTF(0)("uniqueID changed %d %d %d\n", userId, SharedNetworkData::getInstance()->getHostID(), getUniqueID());
    100102  }
    101  
     103
    102104  if ( std::find( id.begin(), id.end(), nickName_handler ) != id.end() )
    103105  {
     
    115117{
    116118  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    117  
     119
    118120  if ( !list )
    119121  {
    120122    return NULL;
    121123  }
    122  
     124
    123125  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    124126  {
     
    128130    }
    129131  }
    130  
     132
    131133  return NULL;
    132134}
     
    138140{
    139141  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    140  
     142
    141143  if ( !list )
    142144  {
     
    144146    return;
    145147  }
    146  
     148
    147149  this->playable = NULL;
    148150  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     
    156158    }
    157159  }
    158  
     160
    159161  if ( this->playable && userId == SharedNetworkData::getInstance()->getHostID() )
    160162  {
    161163    State::getPlayer()->setPlayable( this->playable );
    162164  }
    163  
     165
    164166  this->playableUniqueId = uniqueId;
    165167}
     
    173175  if ( playable )
    174176    return playable;
    175  
     177
    176178  assert( playableUniqueId > 0 );
    177  
     179
    178180  setPlayableUniqueId( playableUniqueId );
    179  
     181
    180182  assert( playable );
    181  
     183
    182184  return playable;
    183185}
     
    189191void PlayerStats::setNickName( std::string nick )
    190192{
    191   if ( SharedNetworkData::getInstance()->isGameServer() )
     193  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() )
    192194  {
    193195    this->nickName = nick;
     
    199201  {
    200202    byte * data = new byte[nick.length()+INTSIZE];
    201    
     203
    202204    assert( Converter::stringToByteArray( nick, data, nick.length()+INTSIZE) == nick.length()+INTSIZE );
    203    
     205
    204206    MessageManager::getInstance()->sendMessage( MSGID_CHANGENICKNAME, data, nick.length()+INTSIZE, RT_SERVER, 0, MP_HIGHBANDWIDTH );
    205207    return;
     
    211213  std::string newNick;
    212214  int res = Converter::byteArrayToString( data, newNick, dataLength );
    213  
     215
    214216  if ( res != dataLength )
    215217  {
     
    217219    newNick = "invalid";
    218220  }
    219  
     221
    220222  if ( PlayerStats::getStats( userId ) )
    221223    PlayerStats::getStats( userId )->setNickName( newNick );
    222  
     224
    223225  return true;
    224226}
     
    228230  if ( getStats( SharedNetworkData::getInstance()->getHostID() ) )
    229231    getStats( SharedNetworkData::getInstance()->getHostID() )->setNickName( newNick );
    230    
     232
    231233  Preferences::getInstance()->setString( "multiplayer", "nickname", newNick );
    232234}
     
    237239{
    238240  const std::list<BaseObject*> * list;
    239  
     241
    240242  while ( (list  = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() )
    241243    delete *list->begin();
     
    247249{
    248250  ScoreList result;
    249  
     251
    250252  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    251  
     253
    252254  if ( !list )
    253255  {
    254256    return result;
    255257  }
    256  
     258
    257259  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    258260  {
    259261    PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
    260    
     262
    261263    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
    262    
     264
    263265    while (  it != result[stats.getTeamId()].end() && stats.score > it->score )
    264266    {
    265267      it++;
    266268    }
    267    
     269
    268270    PlayerScore score;
    269271    score.name = stats.getNickName();
    270272    score.score = stats.getScore();
    271    
     273
    272274    result[stats.getTeamId()].insert(it, score);
    273275  }
    274  
     276
    275277  return result;
    276278}
  • trunk/src/lib/network/shared_network_data.cc

    r9110 r9406  
    1818#include "shared_network_data.h"
    1919#include "netdefs.h"
     20#include "state.h"
    2021
     22#include "debug.h"
    2123
    22 using namespace std;
    2324
    2425
     
    3334  this->setClassID(CL_SHARED_NETWORK_DATA, "SharedNetworkData");
    3435
     36  this->nodeType = NET_CLIENT;
    3537  this->hostID = -1;
    3638  this->defaultSyncStream = NULL;
    37   this->newUniqueID = MAX_CONNECTIONS + 2;
    38   this->bGameServer = false;
     39
     40  // setUniqueID( maxCon+2 ) because we need one id for every handshake
     41  // and one for handshake to reject client maxCon+1
     42  this->newUniqueID = 2;
    3943}
    4044
  • trunk/src/lib/network/shared_network_data.h

    r6695 r9406  
    88
    99#include "base_object.h"
     10#include "netdefs.h"
     11#include "proxy/network_settings.h"
    1012
     13//!< maximal connectinons for the server
     14#define NET_MAX_CONNECTIONS 2
    1115
    1216class NetworkStream;
    1317class Synchronizeable;
    14 template<typename>
    15     class tList;
     18
    1619
    1720/* and here is the class itsself*/
     
    2528
    2629    /** @returns the next uniqueID free for an object */
    27     inline int getNewUniqueID() { return ( this->bGameServer)?this->newUniqueID++:-1; }
     30    inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; }
     31    /** sets the @param newUniqueID: the new offset for the next unique id */
     32    inline void setNewUniqueID(int newUniqueID) { this->newUniqueID = newUniqueID; }
    2833
    29     /** @returns true is this node is a game server */
    30     inline bool isGameServer() { return this->bGameServer; }
     34    /** @returns true is this node is a master server */
     35    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
     36    /** @returns true is this node is a proxy server */
     37    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
     38    /** @returns true is this node is a client*/
     39    inline bool isClient() { return this->nodeType == NET_CLIENT; }
    3140    /** sets the game server flag @param bGameServer true if it is a game server */
    32     inline void setGameServer(bool bGameServer) { this->bGameServer = bGameServer; }
     41    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
     42
     43    /** @returns the maximum number of players for this server */
     44    inline int getMaxPlayer() { return NetworkSettings::getInstance()->getMaxPlayer(); }
    3345
    3446    /** @returns the hostID of the node */
     
    4961  private:
    5062    int                             newUniqueID;             //!< next uniqueID
    51     bool                            bGameServer;             //!< true if it is a server
     63    int                             nodeType;                //!< saves the node type here
     64
    5265    int                             hostID;                  //!< The Host-ID of the Manager
    5366    NetworkStream*                  defaultSyncStream;       //!< default synchronize NetworkStream
  • trunk/src/lib/network/synchronizeable.cc

    r9110 r9406  
    1111
    1212### File Specific:
    13    main-programmer: Silvan Nellen
    14    co-programmer: Benjamin Wuest
     13   main-programmer: Christoph Renner (rennerc@ee.ethz.ch)
     14   co-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch)
    1515*/
    1616
     
    2929#include "synchronizeable.h"
    3030
     31#include "converter.h"
     32
    3133
    3234
     
    3840  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
    3941  this->owner = 0;
    40   this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0);
     42//   this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0);
    4143  this->uniqueID = NET_UID_UNASSIGNED;
    4244  this->networkStream = NULL;
    4345  this->bSynchronize = false;
    44  
     46
    4547  if( State::isOnline())
    4648  {
     
    5456  assert( syncVarList.size() == 0 );
    5557  mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) );
    56    
     58
    5759  this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) );
    5860  this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );
     
    6971  {
    7072    this->networkStream->disconnectSynchronizeable(*this);
    71  
    72     if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
     73
     74    if ( (SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() )
     75           && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
    7376      NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
    7477  }
    75    
     78
    7679  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    7780  {
     
    7982  }
    8083  syncVarList.clear();
    81  
     84
    8285  for ( UserStateHistory::iterator it = recvStates.begin(); it != recvStates.end(); it++ )
    8386  {
     
    9396
    9497  }
    95  
     98
    9699  for ( UserStateHistory::iterator it = sentStates.begin(); it != sentStates.end(); it++ )
    97100  {
     
    105108      delete *it2;
    106109    }
    107 
    108   }
    109 }
    110 
    111 /**
    112  * Sets the server flag to a given value
    113  * @param isServer: the boolean value which the server flag is to set to
    114  */
    115 void Synchronizeable::setIsServer(bool isServer)
    116 {
    117   if( isServer )
    118     this->state = this->state | STATE_SERVER;
    119   else
    120     this->state = this->state & (~STATE_SERVER);
    121 }
    122 
    123 
    124 /**
    125  * Determines if the server flag is set
    126  * @return true, if the server flag is true, false else
    127  */
    128 bool Synchronizeable::isServer()
    129 {
    130   return (this->state & STATE_SERVER) >0;
    131 }
    132 
    133 
    134 
     110  }
     111}
     112
     113
     114
     115/**
     116 * creates a diff image from two states
     117 * @param userId: the userid of the user where the image will be sent to
     118 * @param data: the binary data array to write to
     119 * @param maxLength: maximal length of the data written (length of available space in the array)
     120 * @param stateId: the state id that this diff will represent
     121 * @param priorityTH: the priority threshold: all syncs below this threshold won't be synchronized
     122 *
     123 * @todo check for permissions
     124 */
    135125int Synchronizeable::getStateDiff( int userId, byte* data, int maxLength, int stateId, int fromStateId, int priorityTH )
    136126{
     
    169159        (*it2)->data = NULL;
    170160      }
    171      
     161
    172162      delete *it2;
    173163    }
     
    181171  while ( it != sentStates[userId].end() && (*it)->stateId != fromStateId )
    182172    it++;
    183  
    184 //  if ( getLeafClassID() == CL_SPACE_SHIP )
    185 //  {
    186 //    PRINTF(0)("getStateDiff:SpaceShip from: %d stateId: %d\n", (it == sentStates[userId].end())?-1:fromStateId, stateId);
    187 //  }
    188173
    189174  if ( it == sentStates[userId].end() )
     
    196181
    197182    stateFrom = initialEntry;
    198    
     183
    199184    sentStates[userId].push_back( stateFrom );
    200185  }
     
    205190
    206191  sentStates[userId].push_back( stateTo );
    207  
     192
    208193  stateTo->stateId = stateId;
    209194  stateTo->dataLength = neededSize;
     
    214199  int i = 0;
    215200  int n;
    216  
    217   bool hasPermission;
     201
     202  bool hasPermission = false;
    218203  bool sizeChanged = false;
    219204
     
    221206  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    222207  {
    223     hasPermission = (
    224             this->isServer() && (*it)->checkPermission( PERMISSION_SERVER ) ||
    225         this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
    226             this->isServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) ||
    227             (*it)->checkPermission( PERMISSION_ALL )
    228                     );
    229    
    230     if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() )
     208    // DATA PERMISSIONS
     209    // check if this synchronizeable has the permissions to write the data
     210
     211    // first check MASTER_SERVER permissions
     212    if( SharedNetworkData::getInstance()->isMasterServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
     213      hasPermission = true;
     214    // now check PROXY_SERVER permissions
     215    else if( SharedNetworkData::getInstance()->isProxyServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
     216      hasPermission = true;
     217    // now check OWNER permissions
     218    else if( this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
     219      hasPermission = true;
     220    // now check ALL permissions
     221    else if( (*it)->checkPermission( PERMISSION_ALL ))
     222      hasPermission = true;
     223    // SPECIAL: get write permissions if i am master server and i am able to overwrite the client stuff
     224    else if( SharedNetworkData::getInstance()->isMasterServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
     225      hasPermission = true;
     226    // SPECIAL: get write permissions if i am proxy server and i am able to overwrite the client stuff
     227    else if( SharedNetworkData::getInstance()->isProxyServer()  && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
     228      hasPermission = true;
     229    else
     230      hasPermission = false;
     231
     232
     233    if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() )
    231234      sizeChanged = true;
    232    
     235
    233236    if ( ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeChanged )
    234237    {
    235238      n = (*it)->writeToBuf( stateTo->data+i, stateTo->dataLength - i );
    236239      //NETPRINTF(0)("getvar %s %d\n", (*it)->getName().c_str(), n);
     240      //PRINTF(0)("getvar %s %d\n", (*it)->getName().c_str(), n);
    237241      stateTo->sizeList.push_back( n );
    238       //(*it)->debug();
     242      // this is only for very hardcore debug sessions
     243      // (*it)->debug();
    239244      i += n;
    240245    }
     
    257262  if ( i != neededSize )
    258263  {
    259     PRINTF(0)("strange error: (%s) %d != %d\n", this->getClassName(), i, neededSize);
     264    PRINTF(0)("strange error: (%s) %d != %d\n", this->getClassCName(), i, neededSize);
    260265    assert(false);
    261266  }
     
    281286 * @param fromStateId id of the base state id
    282287 * @return number bytes read
     288 *
    283289 * @todo check for permissions
    284290 */
     
    299305  StateHistoryEntry * stateFrom = NULL;
    300306
     307  // search the state from wich the diff is made of
    301308  StateHistory::iterator it = recvStates[userId].begin();
    302309  while ( it != recvStates[userId].end() && (*it)->stateId != fromStateId )
    303310    it++;
    304311
    305  
    306 //  if ( getLeafClassID() == CL_SPACE_SHIP )
    307 //  {
    308 //    PRINTF(0)("setStateDiff:SpaceShip from: %d stateId: %d\n", (it == recvStates[userId].end())?-1:fromStateId, stateId);
    309 //  }
    310 
     312  // if this is the first state to receive
    311313  if ( it == recvStates[userId].end() )
    312314  {
     
    318320
    319321    stateFrom = initialEntry;
    320    
     322
    321323    recvStates[userId].push_back( stateFrom );
    322324  }
    323325  else
    324326    stateFrom = (*it);
    325  
    326   //apply diff
     327
     328
     329  // apply diff
    327330  for ( int i = 0; i<length; i++ )
    328331  {
     
    331334    else
    332335      stateTo->data[i] = data[i];
    333    
    334   }
    335  
     336  }
     337
    336338  //add state to state history
    337339  recvStates[userId].push_back( stateTo );
    338  
     340
    339341  int i = 0;
    340342  int n = 0;
    341343  std::list<int> changes;
    342  
     344  bool hasPermission = false;
     345
     346  // extract the new state for every client
    343347  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    344348  {
    345     if (
    346         (*it)->checkPermission( PERMISSION_SERVER ) && networkStream->isUserServer( userId ) ||
    347         (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId ||
    348         networkStream->isUserServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
    349         (*it)->checkPermission( PERMISSION_ALL )
    350        )
     349    // DATA PERMISSIONS
     350    // check if this synchronizeable has the permissions to write the data
     351
     352    // first check MASTER_SERVER permissions
     353    if(  this->networkStream->isUserMasterServer( userId ) && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
     354      hasPermission = true;
     355    // now check PROXY_SERVER permissions
     356    else if( this->networkStream->isUserProxyServer( userId )  && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
     357      hasPermission = true;
     358    // now check OWNER permissions
     359    else if( this->owner == userId && (*it)->checkPermission( PERMISSION_OWNER ))
     360      hasPermission = true;
     361    // now check ALL permissions
     362    else if( (*it)->checkPermission( PERMISSION_ALL ))
     363      hasPermission = true;
     364    // SPECIAL: get write permissions if im sending to a master server that does not own this sync
     365    else if( this->networkStream->isUserMasterServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
     366      hasPermission = true;
     367    // SPECIAL: get write permissions if im sending to a proxy server that does not own this sync
     368    else if( this->networkStream->isUserProxyServer( userId )  && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
     369      hasPermission = true;
     370    else
     371      hasPermission = false;
     372
     373
     374
     375    // if it has the permission to write do it
     376    if( hasPermission)
    351377    {
    352378      n = (*it)->readFromBuf( stateTo->data + i, stateTo->dataLength - i );
    353379      i += n;
    354       //NETPRINTF(0)("%s::setvar %s %d\n", getClassName(), (*it)->getName().c_str(), n);
     380      //NETPRINTF(0)("%s::setvar %s %d\n", getClassCName(), (*it)->getName().c_str(), n);
     381      //PRINTF(0)("%s::setvar %s %d\n", getClassCName(), (*it)->getName().c_str(), n);
    355382      //(*it)->debug();
    356383      if ( (*it)->getHasChanged() )
     
    361388    else
    362389    {
    363 //      PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s %d %d %d %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserServer( userId ), this->owner, userId );
     390//      PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s %d %d %d %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_MASTER_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserServer( userId ), this->owner, userId );
    364391      n = (*it)->getSizeFromBuf( stateTo->data + i, stateTo->dataLength - i );
    365       //NETPRINTF(0)("%s::setvar %s %d\n", getClassName(), (*it)->getName().c_str(), n);
     392      //NETPRINTF(0)("%s::setvar %s %d\n", getClassCName(), (*it)->getName().c_str(), n);
    366393      //(*it)->debug();
    367394      i += n;
     
    370397
    371398  this->varChangeHandler( changes );
    372  
     399
    373400  return i;
    374401}
     
    423450        (*it)->data = NULL;
    424451      }
    425    
     452
    426453      delete *it;
    427454    }
    428455    recvStates[userId].clear();
    429456  }
    430  
     457
    431458  if ( sentStates.size() > userId )
    432459  {
    433    
     460
    434461    for ( std::list<StateHistoryEntry*>::iterator it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ )
    435462    {
     
    439466        (*it)->data = NULL;
    440467      }
    441    
     468
    442469      delete *it;
    443470    }
     
    448475/**
    449476 * this function is called after recieving a state.
    450  * @param userId 
    451  * @param stateId 
    452  * @param fromStateId 
     477 * @param userId
     478 * @param stateId
     479 * @param fromStateId
    453480 */
    454481void Synchronizeable::handleRecvState( int userId, int stateId, int fromStateId )
     
    457484  if ( recvStates.size() <= userId )
    458485    recvStates.resize( userId+1 );
    459  
     486
    460487  //remove old states
    461488  StateHistory::iterator it = recvStates[userId].begin();
     
    485512      StateHistory::iterator delIt = it;
    486513      it ++;
    487      
     514
    488515      if ( (*delIt)->data )
    489516      {
     
    493520      delete *delIt;
    494521      recvStates[userId].erase( delIt );
    495      
     522
    496523      continue;
    497524    }
    498525    it++;
    499526  }
    500  
     527
    501528  StateHistory::iterator fromState = recvStates[userId].end();
    502529  StateHistory::iterator toState = recvStates[userId].end();
    503  
     530
    504531  for ( it = recvStates[userId].begin(); it != recvStates[userId].end(); it++ )
    505532  {
     
    508535    if ( (*it)->stateId == fromStateId )
    509536      fromState = it;
    510    
     537
    511538    if ( fromState != recvStates[userId].end() && toState != recvStates[userId].end() )
    512539      break;
    513540  }
    514  
     541
    515542  // setStateDiff was not called and i know fromStateId
    516543  if ( fromState != recvStates[userId].end() && toState == recvStates[userId].end() )
    517544  {
    518545    StateHistoryEntry * entry = new StateHistoryEntry;
    519    
     546
    520547    entry->dataLength = (*fromState)->dataLength;
    521548    if ( entry->dataLength > 0 )
    522549    {
    523550      entry->data = new byte[entry->dataLength];
    524          
     551
    525552      assert( (*fromState)->data );
    526553      memcpy( entry->data, (*fromState)->data, entry->dataLength );
     
    528555    else
    529556      entry->data = NULL;
    530    
     557
    531558    entry->sizeList = (*fromState)->sizeList;
    532559    entry->stateId = stateId;
    533    
     560
    534561    recvStates[userId].push_back(entry);
    535562  }
     
    538565/**
    539566 * this function is called after sending a state
    540  * @param userId 
    541  * @param stateId 
    542  * @param fromStateId 
     567 * @param userId
     568 * @param stateId
     569 * @param fromStateId
    543570 */
    544571void Synchronizeable::handleSentState( int userId, int stateId, int fromStateId )
     
    557584      StateHistory::iterator delIt = it;
    558585      it ++;
    559      
     586
    560587      if ( (*delIt)->data )
    561588      {
     
    565592      delete *delIt;
    566593      sentStates[userId].erase( delIt );
    567      
     594
    568595      continue;
    569596    }
     
    571598  }
    572599
    573  
     600
    574601  StateHistory::iterator fromState = sentStates[userId].end();
    575602  StateHistory::iterator toState = sentStates[userId].end();
    576  
     603
    577604  for ( it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ )
    578605  {
     
    581608    if ( (*it)->stateId == fromStateId )
    582609      fromState = it;
    583    
     610
    584611    if ( fromState != sentStates[userId].end() && toState != sentStates[userId].end() )
    585612      break;
    586613  }
    587614
    588  
     615
    589616  // getStateDiff was not called and i know fromStateId
    590617  if ( fromState != sentStates[userId].end() && toState == sentStates[userId].end() )
    591618  {
    592619    StateHistoryEntry * entry = new StateHistoryEntry;
    593    
     620
    594621    entry->dataLength = (*fromState)->dataLength;
    595622    if ( entry->dataLength > 0 )
    596623    {
    597624      entry->data = new byte[entry->dataLength];
    598      
     625
    599626      assert( (*fromState)->data );
    600627      memcpy( entry->data, (*fromState)->data, entry->dataLength );
     
    602629    else
    603630      entry->data = NULL;
    604    
     631
    605632    entry->sizeList = (*fromState)->sizeList;
    606633    entry->stateId = stateId;
    607    
     634
    608635    sentStates[userId].push_back(entry);
    609636  }
    610  
    611 }
    612 
    613 
    614 
     637
     638}
     639
     640
     641
  • trunk/src/lib/network/synchronizeable.h

    r8708 r9406  
    11/*!
    22 * @file synchronizeable.h
    3     \brief interface for all classes that have to be synchronized
     3 * @brief interface for all classes that have to be synchronized
    44 */
    55
     
    88
    99#include "base_object.h"
    10 #include "netdefs.h"
    11 #include "converter.h"
    12 #include "vector.h"
    13 #include "quaternion.h"
     10
    1411#include "synchronizeable_var/synchronizeable_var.h"
    1512#include "synchronizeable_var/synchronizeable_vector.h"
     
    2017#include "synchronizeable_var/synchronizeable_bool.h"
    2118#include "synchronizeable_var/synchronizeable_uint.h"
    22 
     19#include "synchronizeable_var/synchronizeable_ip.h"
    2320
    2421#include <vector>
    2522#include <list>
    2623
    27 //State constants: They have to be of the form 2^n
    28 #define STATE_SERVER 1
    2924
    3025struct StateHistoryEntry
     
    5146    virtual ~Synchronizeable();
    5247
    53     void setIsServer( bool isServer );
    54     bool isServer();
    55 
    5648    virtual void varChangeHandler( std::list<int> & id );
    5749
     
    6153    virtual void handleSentState( int userId, int stateId, int fromStateId );
    6254    virtual void handleRecvState( int userId, int stateId, int fromStateId );
    63    
     55
    6456    void registerVar( SynchronizeableVar * var );
    6557    int registerVarId( SynchronizeableVar * var );
     
    8274  protected:
    8375    NetworkStream*    networkStream;  //!< reference network stream we are connected to
    84     int               state;
     76
    8577
    8678  private:
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_bool.cc

    r7954 r9406  
    1616
    1717#include "synchronizeable_bool.h"
     18#include <cassert>
    1819
    1920
     
    4445{
    4546  assert( maxLength >= 1 );
    46  
     47
    4748  buf[0] = ( *vPtrIn ) ? 1 : 0;
    48  
     49
    4950  return 1;
    5051}
     
    5960{
    6061  assert( maxLength >= 1 );
    61  
     62
    6263  bool oldVal = *vPtrOut;
    63  
     64
    6465  *vPtrOut = buf[0] != 0;
    65  
     66
    6667  setHasChanged( oldVal != *vPtrOut );
    67  
     68
    6869  return 1;
    6970}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_bool.h

    r7954 r9406  
    22 * @file synchronizeable_int.h
    33 * @brief Definition of SynchronizeableInt
    4 */
    5 
    6 #include "synchronizeable_var/synchronizeable_var.h"
     4 */
    75
    86#ifndef _SYNCHRONIZEABLE_BOOL_H
    97#define _SYNCHRONIZEABLE_BOOL_H
    108
     9#include "synchronizeable_var.h"
     10
    1111class SynchronizeableBool : public SynchronizeableVar {
    1212
    1313  public:
    14     SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     14    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1515    virtual ~SynchronizeableBool();
    16    
     16
    1717    virtual int writeToBuf( byte * buf, int maxLength );
    1818    virtual int readFromBuf( byte * buf, int maxLength );
    19    
     19
    2020    /**
    2121     * check if writeToBuf will return the same size every time
     
    2323     */
    2424    virtual bool hasStaticSize(){ return true; };
    25    
     25
    2626    virtual void debug();
    27    
     27
    2828  private:
    2929    bool * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_float.cc

    r7954 r9406  
    1717#include "synchronizeable_float.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    4647{
    4748  int res = Converter::floatToByteArray( *vPtrIn, buf, maxLength );
    48  
     49
    4950  assert( res == FLOATSIZE );
    50  
     51
    5152  return res;
    5253}
     
    6162{
    6263  assert( maxLength >= FLOATSIZE );
    63  
     64
    6465  float oldVal = *vPtrOut;
    65  
     66
    6667  int res = Converter::byteArrayToFloat( buf, vPtrOut );
    67  
     68
    6869  setHasChanged( oldVal != *vPtrOut );
    69  
     70
    7071  assert( res == FLOATSIZE );
    71  
     72
    7273  return res;
    7374}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_float.h

    r7954 r9406  
    22 * @file synchronizeable_float.h
    33 * @brief Definition of SynchronizeableFloat
    4 */
     4 */
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    76
    87#ifndef _SYNCHRONIZEABLE_FLOAT_H
    98#define _SYNCHRONIZEABLE_FLOAT_H
    109
     10#include "synchronizeable_var.h"
     11
    1112class SynchronizeableFloat : public SynchronizeableVar {
    1213
    1314  public:
    14     SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     15    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1516    virtual ~SynchronizeableFloat();
    16    
     17
    1718    virtual int writeToBuf( byte * buf, int maxLength );
    1819    virtual int readFromBuf( byte * buf, int maxLength );
    19        
     20
    2021    /**
    2122     * check if writeToBuf will return the same size every time
     
    2324     */
    2425    virtual bool hasStaticSize(){ return true; };
    25    
     26
    2627    virtual void debug();
    27    
     28
    2829  private:
    2930    float * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_int.cc

    r7954 r9406  
    1818#include "converter.h"
    1919
     20#include <cassert>
    2021
    2122/**
     
    4647{
    4748  int res = Converter::intToByteArray( *vPtrIn, buf, maxLength );
    48  
     49
    4950  assert( res == INTSIZE );
    50  
     51
    5152  return res;
    5253}
     
    6162{
    6263  assert( maxLength >= INTSIZE );
    63  
     64
    6465  int oldVal = *vPtrOut;
    65  
     66
    6667  int res = Converter::byteArrayToInt( buf, vPtrOut );
    67  
     68
    6869  setHasChanged( oldVal != *vPtrOut );
    69  
     70
    7071  assert( res == INTSIZE );
    71  
     72
    7273  return res;
    7374}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_int.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    76
    87#ifndef _SYNCHRONIZEABLE_INT_H
    98#define _SYNCHRONIZEABLE_INT_H
    109
     10#include "synchronizeable_var.h"
     11
    1112class SynchronizeableInt : public SynchronizeableVar {
    1213
    1314  public:
    14     SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     15    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1516    virtual ~SynchronizeableInt();
    16    
     17
    1718    virtual int writeToBuf( byte * buf, int maxLength );
    1819    virtual int readFromBuf( byte * buf, int maxLength );
    19    
     20
    2021    /**
    2122     * check if writeToBuf will return the same size every time
     
    2324     */
    2425    virtual bool hasStaticSize(){ return true; };
    25    
     26
    2627    virtual void debug();
    27    
     28
    2829  protected:
    2930    int * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc

    r7954 r9406  
    1717#include "synchronizeable_quaternion.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    9899  assert( res > 0 );
    99100  n += res;
    100  
     101
    101102  Quaternion oldVal = *vPtrOut;
    102103
    103104  *vPtrOut = Quaternion( Vector(x, y, z), w );
    104  
     105
    105106  setHasChanged( ! ( oldVal == *vPtrOut ) );
    106107
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    7 
    86#ifndef _SYNCHRONIZEABLE_QUATERNION_H
    97#define _SYNCHRONIZEABLE_QUATERNION_H
     8
     9#include "synchronizeable_var.h"
    1010
    1111#include "quaternion.h"
     
    1414
    1515  public:
    16     SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     16    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1717    virtual ~SynchronizeableQuaternion();
    18    
     18
    1919    virtual int writeToBuf( byte * buf, int maxLength );
    2020    virtual int readFromBuf( byte * buf, int maxLength );
    21        
     21
    2222    /**
    2323     * check if writeToBuf will return the same size every time
     
    2525     */
    2626    virtual bool hasStaticSize(){ return true; };
    27    
     27
    2828    virtual void debug();
    29    
     29
    3030  private:
    3131    Quaternion * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_string.cc

    r8147 r9406  
    1717#include "synchronizeable_string.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    4647{
    4748  int res = Converter::stringToByteArray( *vPtrIn, buf, maxLength );
    48  
     49
    4950  assert( res > 0 );
    5051  assert( res == vPtrIn->length()+INTSIZE );
    51  
     52
    5253  return res;
     54}
     55
     56int SynchronizeableString::getSize()
     57{
     58   return vPtrIn->length()+INTSIZE;
    5359}
    5460
     
    6268{
    6369  std::string oldVal = *vPtrOut;
    64      
     70
    6571  int res = Converter::byteArrayToString( buf, *vPtrOut, maxLength );
    66  
     72
    6773  setHasChanged( oldVal != *vPtrOut );
    68  
     74
    6975  if ( res < 0 )
    7076  {
     
    7278  }
    7379  assert( res > 0 );
    74  
     80
    7581  return res;
    7682}
     
    94100{
    95101  std::string t;
    96  
     102
    97103  int res = Converter::byteArrayToString( buf, t, maxLength );
    98  
     104
    99105  assert( res > 0 );
    100  
     106
    101107  return res;
    102108}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_string.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    7 #include "converter.h"
    8 
    96#ifndef _SYNCHRONIZEABLE_STRING_H
    107#define _SYNCHRONIZEABLE_STRING_H
     8
     9#include "synchronizeable_var.h"
    1110
    1211#include <string>
     
    1514
    1615  public:
    17     SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     16    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1817    virtual ~SynchronizeableString();
    19    
     18
    2019    virtual int writeToBuf( byte * buf, int maxLength );
    2120    virtual int readFromBuf( byte * buf, int maxLength );
    22    
    23        
     21
     22
    2423    /**
    2524     * check if writeToBuf will return the same size every time
     
    2726     */
    2827    virtual bool hasStaticSize(){ return false; };
    29    
    30     virtual int getSize(){ return vPtrIn->length()+INTSIZE; }
    31    
     28
     29    virtual int getSize();
     30
    3231    virtual int getSizeFromBuf( byte * buf, int maxLength );
    33    
     32
    3433    virtual void debug();
    35    
     34
    3635  private:
    3736    std::string * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_uint.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_int.h"
    76
    87#ifndef _SYNCHRONIZEABLE_UINT_H
    98#define _SYNCHRONIZEABLE_UINT_H
    109
     10#include "synchronizeable_int.h"
     11
    1112class SynchronizeableUInt : public SynchronizeableInt {
    1213
    1314  public:
    14     SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     15    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1516    virtual ~SynchronizeableUInt();
    16    
     17
    1718    virtual void debug();
    1819
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_var.cc

    r7954 r9406  
    1616
    1717#include "synchronizeable_var.h"
    18 
     18#include "netdefs.h"
     19#include <cassert>
    1920
    2021
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_var.h

    r7954 r9406  
    77#define _SYNCHRONIZEABLE_VAR_H
    88
     9#include "nettypes.h"
    910#include <string>
    10 #include "netdefs.h"
    11 #include <assert.h>
    1211
    1312enum {
    14   PERMISSION_SERVER = 1,
    15   PERMISSION_OWNER  = 2,
    16   PERMISSION_ALL    = 4
     13  PERMISSION_MASTER_SERVER = 1,
     14  PERMISSION_PROXY_SERVER  = 2,
     15  PERMISSION_OWNER         = 4,
     16  PERMISSION_ALL           = 8
    1717};
    1818
     
    2020
    2121  public:
    22     SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_SERVER, int priority = 0 );
     22    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    2323    virtual ~SynchronizeableVar();
    2424
     
    2828     */
    2929    inline bool beWatched(){ return this->bWatched; }
    30    
    31     /** 
     30
     31    /**
    3232     * set flag if synchronizeable wants to be informed on changes
    3333     */
     
    9696     */
    9797    inline void resetPriority() { this->priority = this->realPriority; }
    98    
     98
    9999    /**
    100100     * reads actual size from buffer. this is used when size is not constant
     
    104104     */
    105105    virtual inline int getSizeFromBuf( byte * buf, int maxLength ){ return this->getSize(); }
    106    
     106
    107107    /**
    108108     * set variable id
     
    110110     */
    111111    inline void setVarId( int id ){ this->varId = id; }
    112    
    113     /** 
     112
     113    /**
    114114     * get variable id
    115115     * @return variable id
    116116     */
    117117    inline int getVarId(){ return varId; }
    118    
     118
    119119    /**
    120120     * set hasChanged
     
    122122     */
    123123    inline void setHasChanged( bool changed ){ this->changed = changed; }
    124    
    125     /** 
     124
     125    /**
    126126     * get hasChanged
    127127     * @return variable id
    128128     */
    129129    inline bool getHasChanged(){ return changed; }
    130    
     130
    131131    /**
    132132     * print out variable value
     
    137137  private:
    138138    bool bWatched;      //!< true if synchronizeable wants to be informed on changes
    139    
     139
    140140    int permission;     //!< who is allowed to change this var
    141141    int priority;       //!< priority assigned to var
    142142    int realPriority;   //!< priority assigned to var, increased every time not sent
    143143    int varId;          //!< id to identify varables
    144    
     144
    145145    bool changed;       //!< true if last readFromBuf changed anything
    146146
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_vector.cc

    r7954 r9406  
    1717#include "synchronizeable_vector.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    7980  int res;
    8081  int n = 0;
    81  
     82
    8283  Vector oldVec = *vPtrOut;
    8384
     
    9596
    9697  *vPtrOut = Vector( x, y, z );
    97  
     98
    9899  setHasChanged( !(*vPtrOut == oldVec) );
    99100
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_vector.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    7 
    86#ifndef _SYNCHRONIZEABLE_VECTOR_H
    97#define _SYNCHRONIZEABLE_VECTOR_H
     8
     9#include "synchronizeable_var.h"
    1010
    1111#include "vector.h"
     
    1414
    1515  public:
    16     SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     16    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1717    virtual ~SynchronizeableVector();
    18    
     18
    1919    virtual int writeToBuf( byte * buf, int maxLength );
    2020    virtual int readFromBuf( byte * buf, int maxLength );
    21    
     21
    2222    /**
    2323     * check if writeToBuf will return the same size every time
     
    2525     */
    2626    virtual bool hasStaticSize(){ return true; }
    27    
     27
    2828    virtual void debug();
    29    
     29
    3030  private:
    3131    Vector * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/tcp_server_socket.cc

    r7954 r9406  
    136136  _isListening = false;
    137137}
     138
  • trunk/src/lib/network/tcp_server_socket.h

    r7954 r9406  
    2828    virtual void close();
    2929    virtual void update() {};
    30    
     30
    3131  private:
    3232    TCPsocket listenSocket;
     
    3636
    3737    void init();
    38  
     38
    3939};
    4040
  • trunk/src/lib/network/tcp_socket.h

    r7954 r9406  
    11/*!
    2  * @file network_socket.h
    3   *  Main interface for the network module. Manages all the modules
     2 * @file tcp_socket.h
     3  *  tcp socket network interface
    44
    55*/
     
    1616#define _INCOMING_BUFFER_SIZE 2024000
    1717#define _OUTGOING_BUFFER_SIZE 2024000
    18 #define _LOCAL_BUFFER_SIZE 1024
     18#define _LOCAL_BUFFER_SIZE 2048
    1919//sleep if incoming buffer is full
    2020#define _MSECONDS_SLEEP_FULL_BUFFER 10
     
    4747
    4848    virtual void connectToServer( std::string host, int port );
    49    
     49
    5050    virtual void disconnectServer();
     51    virtual void reconnectToServer( std::string host, int port);
     52    virtual void reconnectToServerSoft( std::string host, int port);
    5153
    5254    virtual bool writePacket(byte * data, int length);
  • trunk/src/lib/network/udp_socket.cc

    r8802 r9406  
    7474{
    7575  this->init();
     76  this->ip = ip;
    7677  this->serverSocket = serverSocket;
    7778  this->userId = userId;
     
    105106  assert( serverSocket == NULL );
    106107
    107   IPaddress ip;
    108  
    109108  this->randomByte = generateNewRandomByte();
    110109
    111110  PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port);
    112111
    113   if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 )
     112  if ( SDLNet_ResolveHost( &this->ip, host.c_str(), port ) != 0 )
    114113  {
    115114    PRINTF(1)("SDLNet_ResolveHost: %s\n", SDLNet_GetError() );
     
    126125  }
    127126
    128   int channel = SDLNet_UDP_Bind(socket, 1, &ip);
     127  int channel = SDLNet_UDP_Bind(socket, 1, &this->ip);
    129128  if ( channel == -1 )
    130129  {
     
    147146  bOk = false;
    148147  socket = NULL;
    149 }
     148
     149  this->ip.host = 0;
     150  this->ip.port = 0;
     151}
     152
     153
     154/**
     155 * reconnects to
     156 * @param host new server address
     157 * @param port new port number
     158 *
     159 * this terminates the current connection and starts a new connection to the new server
     160 */
     161void UdpSocket::reconnectToServer( std::string host, int port)
     162{
     163  // first disconnect the old server
     164  this->disconnectServer();
     165
     166  // now connect to the new
     167  this->connectToServer( host, port);
     168}
     169
     170
     171/**
     172 * reconnects to
     173 * @param host new server address
     174 * @param port new port number
     175 *
     176 * this terminates the current connection and starts a new connection to the new server
     177 */
     178void UdpSocket::reconnectToServerSoft( std::string host, int port)
     179{}
     180
    150181
    151182/**
     
    179210
    180211    byte udpCmd = 0;
    181    
     212
    182213    if ( networkPacket.length > 0 )
    183214    {
     
    189220    else
    190221      return 0;
    191      
     222
    192223    if ( !checkRandomByte( networkPacket.data[0] ) )
    193224      return 0;
     
    198229      networkPacket.data = NULL;
    199230    }
    200    
     231
    201232    if ( !checkUdpCmd( udpCmd ) )
    202233      return 0;
     
    207238  {
    208239    int numrecv = SDLNet_UDP_Recv( socket, packet);
    209    
     240
    210241    byte udpCmd = 0;
    211242
     
    218249      else
    219250        return 0;
    220            
     251
    221252      if ( !checkRandomByte( packet->data[0] ) )
    222253        return 0;
    223              
     254
    224255      if ( !checkUdpCmd( udpCmd ) )
    225256        return 0;
     
    283314    return false;
    284315  }
    285  
     316
    286317  if ( !this->serverSocket && ( udpCmd & UDPCMD_INVALIDRNDBYTE ) )
    287318  {
     
    292323    return false;
    293324  }
    294  
     325
    295326  return true;
    296327}
     
    300331  srand( SDL_GetTicks() );
    301332  byte res = ( rand() & 0xFC );
    302  
     333
    303334  PRINTF(0)("generated random byte: %x\n", res);
    304  
     335
    305336  return res;
    306337}
  • trunk/src/lib/network/udp_socket.h

    r8802 r9406  
    3131
    3232    virtual void connectToServer( std::string host, int port );
    33    
    3433    virtual void disconnectServer();
    3534
     35    virtual void reconnectToServer( std::string host, int port);
     36    virtual void reconnectToServerSoft( std::string host, int port);
     37
    3638    virtual bool writePacket(byte * data, int length );
     39    virtual int readPacket(byte * data, int maxLength);
    3740
    38     virtual int readPacket(byte * data, int maxLength);
    39    
     41
    4042  private:
    4143    UdpServerSocket * serverSocket;   //!< will get packets here
    4244    int               userId;         //!< user id used by serverSocket
    43     IPaddress         ip;             //!< host,port
    4445    UDPsocket         socket;         //!< socket used to send/recieve
    4546    UDPpacket *       packet;
    46    
     47
    4748    byte              randomByte;     //!< contains random bytes & 0xFC
    48    
     49
    4950    bool writeRawPacket( byte * data, int length );
    5051    bool checkUdpCmd( byte udpCmd );
    5152    bool checkRandomByte( byte rndByte );
    5253    byte generateNewRandomByte();
    53    
     54
    5455    void init();
    5556
  • trunk/src/lib/parser/cmdline_parser/cmdline_parser.cc

    r8316 r9406  
    1818#include "src/lib/util/substring.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/parser/ini_parser/ini_parser.cc

    r7729 r9406  
    3535#endif
    3636
    37 using namespace std;
     37
    3838
    3939/**
     
    142142      if ( (*lineBegin == '#' || *lineBegin == ';'))
    143143      {
    144         string newCommenLine = lineBegin;
     144        std::string newCommenLine = lineBegin;
    145145        this->commentList.push_back(newCommenLine);
    146146        continue;
     
    242242  }
    243243  fclose(stream);
     244  return true;
    244245}
    245246
  • trunk/src/lib/parser/preferences/cmd_line_prefs_reader.cc

    r8316 r9406  
    2020#include "preferences.h"
    2121
    22 using namespace std;
     22
    2323
    2424RegistredArgs CmdLinePrefsReader::regArgs;
  • trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc

    r7661 r9406  
    1818#include "ini_file_prefs_reader.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/particles/box_emitter.cc

    r7198 r9406  
    2525#include "stdlibincl.h"
    2626
    27 using namespace std;
     27
    2828
    2929
  • trunk/src/lib/particles/dot_emitter.cc

    r7661 r9406  
    2424#include "debug.h"
    2525
    26 using namespace std;
     26
    2727
    2828
  • trunk/src/lib/particles/dot_particles.cc

    r7198 r9406  
    3333    ->defaultValues("maps/evil-flower.png");
    3434
    35 using namespace std;
     35
    3636
    3737/**
  • trunk/src/lib/particles/engine/particle_engine.cc

    r7225 r9406  
    2424#include "util/loading/load_param.h"
    2525
    26 using namespace std;
     26
    2727
    2828/**
  • trunk/src/lib/particles/model_particles.cc

    r7221 r9406  
    3333->defaultValues("maps/evil-flower.png");
    3434
    35 using namespace std;
     35
    3636
    3737/**
     
    136136    }
    137137  else
    138     PRINTF(2)("no model loaded onto ParticleSystem-%s\n", this->getName());
     138    PRINTF(2)("no model loaded onto ParticleSystem-%s\n", this->getCName());
    139139  glPopAttrib();
    140140}
  • trunk/src/lib/particles/particle_emitter.cc

    r7193 r9406  
    2424#include "stdlibincl.h"
    2525
    26 using namespace std;
     26
    2727
    2828/**
     
    198198void ParticleEmitter::debug() const
    199199{
    200   PRINT(0)(" ParticleEmitter %s::%s\n", this->getClassName(), this->getName());
     200  PRINT(0)(" ParticleEmitter %s::%s\n", this->getClassCName(), this->getCName());
    201201  PRINT(0)("  EmissionRate: %f, Speed: %f, SpreadAngle: %f\n", this->getEmissionRate(), this->getEmissionVelocity(), this->getSpread());
    202202}
  • trunk/src/lib/particles/particle_system.cc

    r9235 r9406  
    3232#include <algorithm>
    3333
    34 using namespace std;
     34
    3535/**
    3636 *  standard constructor
     
    139139      {
    140140        PRINTF(2)("Tried to load an Element of type '%s' that should be a ParticleEmitter onto '%s::%s'.\n",
    141                   emitter->getClassName(), this->getClassName(), this->getName());
     141                  emitter->getClassCName(), this->getClassCName(), this->getCName());
    142142        delete emitter;
    143143      }
     
    145145    else
    146146    {
    147       PRINTF(2)("Could not Generate Emitter for system %s::%s (wrong type in XML-format)\n", this->getClassName(), getName());
     147      PRINTF(2)("Could not Generate Emitter for system %s::%s (wrong type in XML-format)\n", this->getClassCName(), getCName());
    148148    }
    149149  }
     
    157157{
    158158  this->maxCount = maxCount;
    159   PRINTF(4)("MAXCOUNT of %s::%s is %d\n", this->getClassName(), this->getName(),maxCount);
     159  PRINTF(4)("MAXCOUNT of %s::%s is %d\n", this->getClassCName(), this->getCName(), maxCount);
    160160}
    161161
     
    170170  this->lifeSpan = lifeSpan;
    171171  this->randomLifeSpan = randomLifeSpan;
    172   PRINTF(4)("LifeTime of %s::%s is %f\n", this->getClassName(), this->getName(), lifeSpan);
     172  PRINTF(4)("LifeTime of %s::%s is %f\n", this->getClassCName(), this->getCName(), lifeSpan);
    173173}
    174174
     
    188188    this->conserve = conserve;
    189189
    190   PRINTF(4)("Conserve of %s::%s is %f\n", this->getClassName(), this->getName(),conserve);
     190  PRINTF(4)("Conserve of %s::%s is %f\n", this->getClassCName(), this->getCName(), conserve);
    191191}
    192192
     
    206206
    207207  PRINTF(4)("Radius of %s::%s at timeSlice %f is %f with a Random of %f\n",
    208     this->getClassName(), this->getName(),lifeCycleTime, radius, randRadius);
     208    this->getClassCName(), this->getCName(), lifeCycleTime, radius, randRadius);
    209209}
    210210
     
    237237
    238238  PRINTF(4)("Color of %s::%s on timeslice %f is r:%f g:%f b:%f a:%f\n",
    239     this->getClassName(), this->getName(), lifeCycleTime, red, green, blue, alpha);
     239    this->getClassCName(), this->getCName(), lifeCycleTime, red, green, blue, alpha);
    240240}
    241241
     
    278278    (*emitter)->updateNode(.1), (*emitter)->updateNode(.1);
    279279
    280   PRINTF(4)("Precaching %s::%s %d seconds %d timesPerSecond\n", this->getClassName(), this->getName(), seconds, ticksPerSecond);
     280  PRINTF(4)("Precaching %s::%s %d seconds %d timesPerSecond\n", this->getClassCName(), this->getCName(), seconds, ticksPerSecond);
    281281  for (unsigned int i = 0; i < seconds*ticksPerSecond; i++)
    282282    this->tick(1.0/(float)ticksPerSecond);
     
    460460    int i = 1;
    461461    Particle* tmpPart = this->deadList;
    462     while (tmpPart = tmpPart->next) { ++i; }
     462    while ((tmpPart = tmpPart->next) != NULL) { ++i; }
    463463    PRINT(0)("count: %d\n", i);
    464464  }
  • trunk/src/lib/particles/plane_emitter.cc

    r7198 r9406  
    2525#include "stdlibincl.h"
    2626
    27 using namespace std;
     27
    2828
    2929
  • trunk/src/lib/particles/quick_animation.cc

    r7335 r9406  
    2020#include <algorithm>
    2121
    22 using namespace std;
     22
    2323
    2424/**
  • trunk/src/lib/particles/spark_particles.cc

    r7221 r9406  
    2929
    3030
    31 using namespace std;
     31
    3232
    3333CREATE_FACTORY(SparkParticles, CL_SPARK_PARTICLES);
  • trunk/src/lib/particles/sprite_particles.cc

    r7221 r9406  
    3333    ->defaultValues("maps/evil-flower.png");
    3434
    35 using namespace std;
     35
    3636
    3737/**
  • trunk/src/lib/physics/fields/field.cc

    r7199 r9406  
    2222#include "util/loading/factory.h"
    2323#include "util/loading/load_param.h"
    24 using namespace std;
     24
    2525
    2626/**
  • trunk/src/lib/physics/fields/gravity.cc

    r7193 r9406  
    2121#include "util/loading/factory.h"
    2222
    23 using namespace std;
     23
    2424
    2525CREATE_FACTORY(Gravity, CL_FIELD_GRAVITY);
  • trunk/src/lib/physics/fields/point_gravity.cc

    r5357 r9406  
    1818#include "point_gravity.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/physics/fields/twirl.cc

    r5357 r9406  
    1818#include "twirl.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/physics/physics_connection.cc

    r7221 r9406  
    2727#include "util/loading/load_param.h"
    2828
    29 using namespace std;
     29
    3030
    3131CREATE_FACTORY(PhysicsConnection, CL_PHYSICS_CONNECTION);
     
    8181  }
    8282  else
    83     PRINTF(5)("subject::%s\n", this->subject->getName());
     83    PRINTF(5)("subject::%s\n", this->subject->getCName());
    8484}
    8585
     
    9595  }
    9696  else
    97     PRINTF(5)("field::%s\n", this->field->getName());
     97    PRINTF(5)("field::%s\n", this->field->getCName());
    9898
    9999}
  • trunk/src/lib/physics/physics_engine.cc

    r7221 r9406  
    2323#include "util/loading/load_param.h"
    2424
    25 using namespace std;
     25
    2626
    2727
     
    162162Field* PhysicsEngine::getFieldByName(const std::string& fieldName) const
    163163{
    164   list<Field*>::const_iterator field;
     164  std::list<Field*>::const_iterator field;
    165165  for (field = this->fields.begin(); field != this->fields.end(); field++)
    166166    if (fieldName == (*field)->getName())
     
    199199PhysicsConnection* PhysicsEngine::getPhysicsConnectionByName(const std::string& physicsConnectionName) const
    200200{
    201   list<PhysicsConnection*>::const_iterator pc;
     201  std::list<PhysicsConnection*>::const_iterator pc;
    202202  for (pc = this->connections.begin(); pc != this->connections.end(); pc++)
    203203    if (physicsConnectionName == (*pc)->getName())
     
    218218  /* go through all the PhysicsInterface(s) and tick them,
    219219  meaning let the fields work */
    220   list<PhysicsConnection*>::iterator pc;
     220  std::list<PhysicsConnection*>::iterator pc;
    221221  for (pc = this->connections.begin(); pc != this->connections.end(); pc++)
    222222    (*pc)->apply();
     
    225225  if (this->interfaces != NULL || (this->interfaces = ClassList::getList(CL_PHYSICS_INTERFACE)) != NULL)
    226226  {
    227     list<BaseObject*>::const_iterator tickPhys;
     227    std::list<BaseObject*>::const_iterator tickPhys;
    228228    for (tickPhys = this->interfaces->begin(); tickPhys != this->interfaces->end(); tickPhys++)
    229229      dynamic_cast<PhysicsInterface*>(*tickPhys)->tickPhys(dt);
  • trunk/src/lib/physics/physics_interface.cc

    r8350 r9406  
    2929#include "stdincl.h"
    3030
    31 using namespace std;
     31
    3232
    3333
     
    6868    {
    6969    // todo: find out if children are PhysicsInterface in an efficient way
    70     if (strcmp( pn->getClassName(), "PhysicsInterface")) {
     70    if (strcmp( pn->getClassCName(), "PhysicsInterface")) {
    7171    massSum += ((PhysicsInterface*)pn)->getTotalMass();
    7272    }
     
    7777    if (massSum != this->massChildren ) {
    7878    this->massChildren = massSum;
    79     if (strcmp( massCalcPNode->parent->getClassName(), "PhysicsInterface"))
     79    if (strcmp( massCalcPNode->parent->getClassCName(), "PhysicsInterface"))
    8080    ((PhysicsInterface*)massCalcPNode->parent)->recalcMass();
    8181    } else {
  • trunk/src/lib/shell/shell_command.cc

    r9112 r9406  
    119119
    120120    CmdList::const_iterator elem;
    121     for (elem = cmdClass->commandList.begin(); elem != cmdClass->commandList.end(); elem++)
    122       if (commandName == (*elem)->getName())
    123         return (*elem);
     121    for (unsigned int i = 0; i < cmdClass->commandList.size(); i++)
     122    {
     123      if (commandName == cmdClass->commandList[i]->getName())
     124        return (cmdClass->commandList[i]);
     125    }
    124126    return NULL;
    125127  }
     
    137139    if (likely(checkClass != NULL))
    138140      return ShellCommand::getCommand(commandName, checkClass);
    139     return NULL;
     141    else
     142      return NULL;
    140143  }
    141144
     
    149152  const ShellCommand* const ShellCommand::getCommandFromInput(const std::string& inputLine, unsigned int& paramBegin, std::vector<BaseObject*>* boList)
    150153  {
    151     return ShellCommand::getCommandFromInput(SubString(inputLine, SubString::WhiteSpaces), paramBegin);
     154    return ShellCommand::getCommandFromInput(SubString(inputLine, SubString::WhiteSpaces), paramBegin, boList);
    152155  }
    153156
     
    199202      {
    200203        // Search for Objects.
    201         retCmd = ShellCommand::getCommand(strings[1], cmdClass);
     204        retCmd = ShellCommand::getCommand((strings.size() > 1) ? strings[1] : "", cmdClass);
    202205        if (retCmd != NULL)
    203206        {
     
    210213      if (retCmd == NULL && strings.size() >= 2)
    211214      {
    212         retCmd = ShellCommand::getCommand(strings[2], cmdClass);
     215        retCmd = ShellCommand::getCommand((strings.size() > 2) ? strings[2] : "", cmdClass);
    213216        if (retCmd != NULL)
    214217        {
     
    254257      {
    255258        for (bo = objectList->begin(); bo != objectList->end(); bo++)
    256           if ((*bo)->getName() != NULL && !nocaseCmp(objectDescriptor, (*bo)->getName(), objectDescriptor.size()))
     259          if (!nocaseCmp(objectDescriptor, (*bo)->getName(), objectDescriptor.size()))
    257260            boList->push_back(*bo);
    258261      }
     
    298301      for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo)
    299302      {
    300         PRINT(0)("Command '%s' on '%s::%s'\n", sc->getName(), (*bo)->getClassName(), (*bo)->getName());
    301         (*sc->executor)((*bo), inputSplits.getSubSet(paramBegin));
     303        PRINT(0)("Command '%s' on '%s::%s'\n", sc->getCName(), (*bo)->getClassCName(), (*bo)->getCName());
     304        (*sc->executor)((*bo), inputSplits.subSet(paramBegin));
    302305      }
    303306      return true;
     
    331334    if (this->alias != NULL)
    332335    {
    333       PRINTF(2)("not more than one Alias allowed for functions (%s::%s)\n", this->getName(), this->shellClass->getName());
     336      PRINTF(2)("not more than one Alias allowed for functions (%s::%s)\n", this->getCName(), this->shellClass->getCName());
    334337    }
    335338    else
     
    369372    {
    370373      PRINTF(1)("Parameter %d not inside of valid ParameterCount %d of Command %s::%s\n",
    371                 parameter, this->executor->getParamCount(), this->getName(), this->shellClass->getName());
     374                parameter, this->executor->getParamCount(), this->getCName(), this->shellClass->getCName());
    372375    }
    373376    else
     
    375378//       if(this->completors[parameter] == NULL)
    376379//       delete this->completors[parameter];
    377 //       this->completors[parameter] = completorPlugin.clone(); 
     380//       this->completors[parameter] = completorPlugin.clone();
    378381    }
    379382    return this;
     
    385388  void ShellCommand::help() const
    386389  {
    387     PRINT(0)("%s ", this->getName());
     390    PRINT(0)("%s ", this->getCName());
    388391  }
    389392
  • trunk/src/lib/shell/shell_command_class.cc

    r7743 r9406  
    199199        for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
    200200        {
    201           PRINT(0)("  command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount());
     201          PRINT(0)("  command:'%s' : params:%d: ", (*cmdIT)->getCName(), (*cmdIT)->executor->getParamCount());
    202202          /// FIXME
    203203          /*          for (unsigned int i = 0; i< elem->paramCount; i++)
  • trunk/src/lib/shell/shell_completion.cc

    r7764 r9406  
    290290    for(bo = inputList.begin(); bo != inputList.end(); bo++)
    291291    {
    292       if ((*bo)->getName() != NULL &&
    293           strlen((*bo)->getName()) >= searchLength &&
     292      if ((*bo)->getName().size() >= searchLength &&
    294293          !nocaseCmp((*bo)->getName(), completionBegin, searchLength))
    295294      {
  • trunk/src/lib/sound/ogg_player.cc

    r9019 r9406  
    481481    if (comment == NULL)
    482482    {
    483       PRINTF(2)("Retrieving Comment of %s failed\n", this->getName());
     483      PRINTF(2)("Retrieving Comment of %s failed\n", this->getCName());
    484484      return;
    485485    }
  • trunk/src/lib/util/Makefile.am

    r8724 r9406  
    66libORXlibutil_a_SOURCES = \
    77                substring.cc \
    8                 tokenizer.cc \
    98                color.cc \
    109                helper_functions.cc \
     
    2423                filesys/file.cc \
    2524                filesys/directory.cc \
     25                filesys/net_link.cc \
    2626                \
    2727                preferences.cc \
     
    3232noinst_HEADERS = \
    3333                substring.h \
    34                 tokenizer.h \
    3534                multi_type.h \
    3635                color.h \
     
    4443                filesys/file.h \
    4544                filesys/directory.h \
     45                filesys/net_link.h \
    4646                \
    4747                preferences.h \
  • trunk/src/lib/util/executor/executor_functional.h

    r8271 r9406  
    179179  {
    180180    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    181       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) );
     181      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])));
    182182  };
    183183
     
    222222  {
    223223    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    224       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    225       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)));
     224      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     225      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])));
    226226  };
    227227
     
    276276  {
    277277    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    278       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    279       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
    280       fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)));
     278      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     279      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
     280      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])));
    281281  };
    282282
     
    333333  {
    334334    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    335       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    336       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
    337       fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)),
    338       fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)));
     335      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     336      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
     337      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
     338      (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])));
    339339  };
    340340
     
    392392  {
    393393    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    394       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    395       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
    396       fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)),
    397       fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)),
    398       fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)));
     394      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     395      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
     396      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
     397      (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])),
     398      (sub.size() > 4) ? fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)) : (fromMulti<type4>(this->defaultValue[4])));
    399399  };
    400400
  • trunk/src/lib/util/executor/functor_list.h

    r8894 r9406  
    135135
    136136  //! mixed values:
     137  FUNCTOR_LIST(2)(l_STRING, l_INT);
    137138  FUNCTOR_LIST(2)(l_STRING, l_FLOAT);
    138139  FUNCTOR_LIST(2)(l_UINT, l_LONG);
  • trunk/src/lib/util/helper_functions.cc

    r7714 r9406  
    1919#include "stdlibincl.h"
    2020
    21 using namespace std;
     21
    2222
    2323/**
  • trunk/src/lib/util/loading/dynamic_loader.cc

    r8362 r9406  
    2323
    2424
    25 using namespace std;
     25
    2626
    2727
  • trunk/src/lib/util/loading/factory.cc

    r8362 r9406  
    1919//#include "shell_command.h"
    2020
    21 using namespace std;
     21
    2222
    2323//SHELL_COMMAND(create, Factory, fabricate);
     
    117117  if (factory != Factory::factoryList->end())
    118118  {
    119     PRINTF(2)("Create a new Object of type %s\n", (*factory)->getName());
     119    PRINTF(2)("Create a new Object of type %s\n", (*factory)->getCName());
    120120    return (*factory)->fabricateObject(root);
    121121  }
     
    145145  if (factory != Factory::factoryList->end())
    146146  {
    147     PRINTF(4)("Create a new Object of type %s\n", (*factory)->getName());
     147    PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
    148148    return (*factory)->fabricateObject(NULL);
    149149  }
     
    173173  if (factory != Factory::factoryList->end())
    174174  {
    175     PRINTF(4)("Create a new Object of type %s\n", (*factory)->getName());
     175    PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
    176176    return (*factory)->fabricateObject(NULL);
    177177  }
  • trunk/src/lib/util/loading/load_param.cc

    r8408 r9406  
    6565          ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))
    6666    {
    67       PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", this->paramName.c_str(), loadString.c_str(), this->object->getClassName(), this->object->getName());
     67      PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", this->paramName.c_str(), loadString.c_str(), this->object->getClassCName(), this->object->getCName());
    6868      (*this->executor)(this->object, SubString(loadString, ",", SubString::WhiteSpaces, false, '\\'));
    6969    }
     
    164164{
    165165    // locating the class
    166     this->classDesc = LoadClassDescription::addClass(object->getClassName());
     166    this->classDesc = LoadClassDescription::addClass(object->getClassCName());
    167167
    168168    if ((this->paramDesc = this->classDesc->addParam(paramName)) != NULL)
  • trunk/src/lib/util/loading/resource.cc

    r8271 r9406  
    1818#include "resource.h"
    1919
    20 using namespace std;
     20
    2121
    2222
  • trunk/src/lib/util/loading/resource_manager.cc

    r8724 r9406  
    5050#include <unistd.h>
    5151
    52 using namespace std;
     52
    5353
    5454/**
  • trunk/src/lib/util/multi_type.cc

    r8316 r9406  
    1818#include "multi_type.h"
    1919
    20 //#include "stdincl.h"
    21 #include <stddef.h>
    22 #include <stdlib.h>
    23 #include <string.h>
    24 #include <stdio.h>
    2520#include <sstream>
    2621
     
    2823#include "debug.h"
    2924#endif
    30 
    31 using namespace std;
    3225
    3326/**
  • trunk/src/lib/util/substring.cc

    r7477 r9406  
    2828#include "substring.h"
    2929
    30 #include <string.h>
    31 #include <cassert>
    32 
    33 
    3430/**
    3531 * @brief default constructor
     
    108104
    109105/** @brief An empty String */
    110 const std::string SubString::emptyString = "";
     106// const std::string SubString::emptyString = "";
    111107/** @brief Helper that gets you a String consisting of all White Spaces */
    112108const std::string SubString::WhiteSpaces = " \n\t";
     
    238234  }
    239235  else
    240     return SubString::emptyString;
     236  {
     237    static std::string empty;
     238    return empty;
     239  }
    241240}
    242241
     
    250249 * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
    251250 */
    252 SubString SubString::getSubSet(unsigned int subSetBegin) const
     251SubString SubString::subSet(unsigned int subSetBegin) const
    253252{
    254253  return SubString(*this, subSetBegin);
     
    265264 * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
    266265 */
    267 SubString SubString::getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const
     266SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const
    268267{
    269268  return SubString(*this, subSetBegin, subSetEnd);
     
    289288 * Supports delimiters, escape characters,
    290289 * ignores special  characters between safemode_char and between comment_char and linend '\n'.
    291  *
    292  *
    293290 */
    294291SubString::SPLIT_LINE_STATE
  • trunk/src/lib/util/substring.h

    r8408 r9406  
    22 * @file substring.h
    33 * @brief a small class to get the parts of a string separated by commas
     4 *
     5 * This class is also identified as a Tokenizer. It splits up one long
     6 * String into multiple small ones by a designated Delimiter.
     7 *
     8 * Substring is Advanced, and it is possible, to split a string by ','
     9 * but also removing leading and trailing spaces around the comma.
     10 *
     11 * @example
     12 * Split the String std::string st = "1345, The new empire   , is , orxonox"
     13 * is splitted with:
     14 * SubString(st, ',', " \n\t")
     15 * into
     16 * "1345", "The new empire", "is", "orxonox"
     17 * As you can see, the useless spaces around ',' were removed.
    418 */
    519
    6 #ifndef _SUBSTRING_H
    7 #define _SUBSTRING_H
     20#ifndef __SUBSTRING_H__
     21#define __SUBSTRING_H__
    822
    923#include <vector>
     
    6175
    6276  // retrieve a SubSet from the String
    63   SubString getSubSet(unsigned int subSetBegin) const;
    64   SubString getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
     77  SubString subSet(unsigned int subSetBegin) const;
     78  SubString subSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
    6579
    6680  // retrieve Information from within
     
    7084  inline unsigned int size() const { return this->strings.size(); };
    7185  /** @param i the i'th String @returns the i'th string from the subset of Strings */
    72   inline const std::string& operator[](unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
     86  inline const std::string& operator[](unsigned int i) const { return this->strings[i]; };
    7387  /** @param i the i'th String @returns the i'th string from the subset of Strings */
    7488  inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
     89  /** @returns the front of the StringList. */
     90  inline const std::string& front() const { return this->strings.front(); };
     91  /** @returns the back of the StringList. */
     92  inline const std::string& back() const { return this->strings.back(); };
     93  /** @brief removes the back of the strings list. */
     94  inline void pop_back() { this->strings.pop_back(); };
    7595
    7696  // the almighty algorithm.
     
    93113private:
    94114  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
    95 
    96   static const std::string emptyString;
    97115};
    98116
    99 #endif /* _SUBSTRING_H */
     117#endif /* __SUBSTRING_H__ */
  • trunk/src/lib/util/threading.cc

    r7847 r9406  
    1818#include "threading.h"
    1919
    20 using namespace std;
     20
    2121
    2222namespace OrxThread
Note: See TracChangeset for help on using the changeset viewer.