Changeset 9406 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Jul 24, 2006, 11:09:47 AM (18 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 8 deleted
- 167 edited
- 24 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/Makefile.am
r8367 r9406 31 31 collision_detection \ 32 32 collision_reaction \ 33 gui \ 33 34 network \ 34 35 parser \ 35 36 shell \ 36 script_engine \ 37 gui 37 script_engine -
trunk/src/lib/collision_detection/aabb.cc
r8724 r9406 19 19 #include "vector.h" 20 20 21 using namespace std; 21 22 22 23 23 -
trunk/src/lib/collision_detection/aabb_tree_node.cc
r8724 r9406 34 34 35 35 36 using namespace std; 36 37 37 38 38 … … 262 262 const int* triangleIndexes, int length) 263 263 { 264 265 Vector axis[3]; //!< the references to the obb axis266 264 Matrix covMat( box.covarianceMatrix ); //!< covariance matrix (in the matrix dataform) 267 265 … … 501 499 if( this->overlapTest(this->bvElement, treeNode->bvElement, nodeA, nodeB)) 502 500 { 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); 504 502 505 503 -
trunk/src/lib/collision_detection/bounding_sphere.cc
r7711 r9406 18 18 #include "bounding_sphere.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/collision_detection/bounding_volume.cc
r7711 r9406 18 18 #include "bounding_volume.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/collision_detection/bv_tree.cc
r7711 r9406 18 18 #include "bv_tree.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/collision_detection/bv_tree_node.cc
r7711 r9406 18 18 #include "bv_tree_node.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/collision_detection/cd_engine.cc
r9110 r9406 34 34 #include "bsp_entity.h" 35 35 36 using namespace std; 36 37 37 38 38 … … 45 45 46 46 this->bAbordOnFirstCollision = false; 47 47 48 48 this->terrain = NULL; 49 49 } … … 86 86 if( likely((*entity2) != this->terrain)) 87 87 { 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()); 89 90 tree = (*entity1)->getOBBTree(); 90 91 if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL) … … 113 114 for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++) 114 115 { 115 // PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClass Name());116 // PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassCName()); 116 117 (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator); 117 118 } -
trunk/src/lib/collision_detection/obb.cc
r7711 r9406 19 19 #include "vector.h" 20 20 21 using namespace std; 21 22 22 23 23 -
trunk/src/lib/collision_detection/obb_tree.cc
r9235 r9406 25 25 #include "p_node.h" 26 26 27 using namespace std; 27 28 28 29 29 -
trunk/src/lib/collision_detection/obb_tree_node.cc
r9235 r9406 33 33 34 34 35 using namespace std; 35 36 36 37 37 … … 434 434 } 435 435 } 436 delete [] triangleCenter; 436 437 PRINTF(4)("\nPartition1: got \t%i Vertices \nPartition2: got \t%i Vertices\n", partition1.size(), partition2.size()); 437 438 … … 476 477 return; 477 478 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()); 480 481 481 482 482 483 // if( distance < distanceMax) 483 // PRINTF(0)(" %s (%s: group %i) vs %s (%s: group %i): distanceMax: %f, distance: %f\n", nodeA->getClass Name(), 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); 484 485 485 486 … … 504 505 if( this->overlapTest(this->bvElement, treeNode->bvElement, nodeA, nodeB)) 505 506 { 506 PRINTF(5)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClass Name(), 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); 507 508 508 509 … … 806 807 if( this->obbTree->getOwner() != NULL) 807 808 { 808 PRINTF(4)("debug poly draw: depth: %i, mode: %i, entity-name: %s, class: %s\n", depth, drawMode, this->obbTree->getOwner()->get Name(), 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()); 809 810 } 810 811 else -
trunk/src/lib/collision_reaction/collision.cc
r8190 r9406 19 19 #include "debug.h" 20 20 21 using namespace std; 21 22 22 23 23 -
trunk/src/lib/collision_reaction/collision_event.cc
r8190 r9406 19 19 #include "debug.h" 20 20 21 using namespace std; 21 22 22 23 23 -
trunk/src/lib/collision_reaction/collision_handle.cc
r9235 r9406 29 29 #include "debug.h" 30 30 31 using namespace std; 31 32 32 33 33 … … 178 178 179 179 c->registerCollisionEvent(collisionEvent); 180 PRINTF(5)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClass Name(), collisionEvent->getEntityB()->getClassName());180 PRINTF(5)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassCName(), collisionEvent->getEntityB()->getClassCName()); 181 181 } 182 182 … … 204 204 205 205 // 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(); 207 207 for(; it < this->collisionList.end(); it++) { 208 208 if( !(*it)->isDispatched()) … … 227 227 bool CollisionHandle::filterCollisionEvent(CollisionEvent* collisionEvent) 228 228 { 229 vector<long>::iterator it = this->targetList.begin();229 std::vector<long>::iterator it = this->targetList.begin(); 230 230 for(; it < this->targetList.end(); it++) 231 231 { 232 232 // if(collisionEvent->getEntityB()->isA(CL_AIMING_SYSTEM) || collisionEvent->getEntityA()->isA(CL_AIMING_SYSTEM)) 233 233 // { 234 // PRINTF(0)("I am: %s colliding with: %s\n", owner->getClass Name(), collisionEvent->getEntityB()->getClassName(), *it);234 // PRINTF(0)("I am: %s colliding with: %s\n", owner->getClassCName(), collisionEvent->getEntityB()->getClassCName(), *it); 235 235 // if( collisionEvent->getEntityA() == this->owner) { 236 // PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClass Name(),237 // collisionEvent->getEntityB()->getClass Name(), *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); 238 238 // 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->getClass Name(),240 // collisionEvent->getEntityB()->getClass Name(), *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); 241 241 // } 242 242 // } 243 243 // else { 244 // PRINTF(0)("I am not owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClass Name(),245 // collisionEvent->getEntityB()->getClass Name(), *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); 246 246 // 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->getClass Name(),248 // collisionEvent->getEntityA()->getClass Name(), *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); 249 249 // } 250 250 // } … … 254 254 if( collisionEvent->getEntityA() == this->owner) { 255 255 if( collisionEvent->getEntityB()->isA((ClassID)(*it))) { 256 PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClass Name(),257 collisionEvent->getEntityB()->getClass Name(), *it);256 PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(), 257 collisionEvent->getEntityB()->getClassCName(), *it); 258 258 return true; } 259 259 } 260 260 else { 261 261 if( collisionEvent->getEntityA()->isA((ClassID)(*it))) { 262 PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClass Name(),263 collisionEvent->getEntityA()->getClass Name(), *it);262 PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(), 263 collisionEvent->getEntityA()->getClassCName(), *it); 264 264 return true; } 265 265 } … … 276 276 bool CollisionHandle::filterCollision(Collision* collision) 277 277 { 278 vector<long>::iterator it = this->targetList.begin();278 std::vector<long>::iterator it = this->targetList.begin(); 279 279 for(; it < this->targetList.end(); it++) 280 280 { … … 282 282 // if(collision->getEntityB()->isA(CL_AIMING_SYSTEM) || collision->getEntityA()->isA(CL_AIMING_SYSTEM)) 283 283 // { 284 // PRINTF(0)("Shared!!! I am: %s colliding with: %s\n", owner->getClass Name(), collision->getEntityB()->getClassName(), *it);284 // PRINTF(0)("Shared!!! I am: %s colliding with: %s\n", owner->getClassCName(), collision->getEntityB()->getClassCName(), *it); 285 285 // if( collision->getEntityA() == this->owner) { 286 // PRINTF(0)("I am owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClass Name(),287 // collision->getEntityB()->getClass Name(), *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); 288 288 // 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->getClass Name(),290 // collision->getEntityB()->getClass Name(), *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); 291 291 // } 292 292 // } 293 293 // else { 294 // PRINTF(0)("I'm not owner -> I am: %s colliding with: %s is a %i filter?\n", owner->getClass Name(),295 // collision->getEntityB()->getClass Name(), *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); 296 296 // 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->getClass Name(),298 // collision->getEntityA()->getClass Name(), *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); 299 299 // } 300 300 // } -
trunk/src/lib/collision_reaction/collision_reaction.cc
r8190 r9406 19 19 20 20 21 using namespace std; 21 22 22 23 23 -
trunk/src/lib/collision_reaction/cr_engine.cc
r8490 r9406 27 27 #include "debug.h" 28 28 29 using namespace std; 29 30 30 31 31 … … 61 61 this->reset(); 62 62 63 vector<Collision*>::iterator it1 = this->collisionsUnused.begin();63 std::vector<Collision*>::iterator it1 = this->collisionsUnused.begin(); 64 64 for(; it1 < this->collisionsUnused.end(); it1++) 65 65 delete *it1; 66 vector<CollisionEvent*>::iterator it2 = this->collisionEventsUnused.begin();66 std::vector<CollisionEvent*>::iterator it2 = this->collisionEventsUnused.begin(); 67 67 for(; it2 < this->collisionEventsUnused.end(); it2++) 68 68 delete *it2; … … 92 92 // first clear all CollisionHandles 93 93 94 vector<CollisionHandle*>::iterator it = this->collisionHandles.begin();94 std::vector<CollisionHandle*>::iterator it = this->collisionHandles.begin(); 95 95 for(; it < this->collisionHandles.end(); it++) 96 96 { … … 159 159 void CREngine::flushCollisions() 160 160 { 161 vector<Collision*>::iterator it1 = this->collisionsUsed.begin();161 std::vector<Collision*>::iterator it1 = this->collisionsUsed.begin(); 162 162 for(; it1 < this->collisionsUsed.end(); it1++) 163 163 this->collisionsUnused.push_back(*it1); 164 164 165 vector<CollisionEvent*>::iterator it2 = this->collisionEventsUsed.begin();165 std::vector<CollisionEvent*>::iterator it2 = this->collisionEventsUsed.begin(); 166 166 for(; it2 < this->collisionEventsUsed.end(); it2++) 167 167 this->collisionEventsUnused.push_back(*it2); -
trunk/src/lib/collision_reaction/cr_object_damage.cc
r9235 r9406 26 26 #include "debug.h" 27 27 28 using namespace std; 28 29 29 30 30 … … 57 57 58 58 PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n", 59 collision->getEntityA()->getClass Name(),60 collision->getEntityB()->getClass Name());59 collision->getEntityA()->getClassCName(), 60 collision->getEntityB()->getClassCName()); 61 61 62 62 // the collision damage been dealed by the entity … … 64 64 damage = collision->getEntityB()->getDamage(); 65 65 collision->getEntityA()->hit(damage, collision->getEntityB()); 66 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClass Name());66 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassCName()); 67 67 } 68 68 … … 70 70 damage = collision->getEntityA()->getDamage(); 71 71 collision->getEntityB()->hit(damage, collision->getEntityA()); 72 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClass Name());72 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassCName()); 73 73 } 74 74 -
trunk/src/lib/collision_reaction/cr_physics_full_walk.cc
r9235 r9406 33 33 #include "cr_defs.h" 34 34 35 using namespace std; 35 36 36 37 37 -
trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
r9235 r9406 33 33 #include "cr_defs.h" 34 34 35 using namespace std; 35 36 36 37 37 -
trunk/src/lib/coord/p_node.cc
r9235 r9406 21 21 #include "class_list.h" 22 22 23 #include "netdefs.h" 24 23 25 #include <algorithm> 24 26 #include "compiler.h" … … 27 29 #include "glincl.h" 28 30 #include "color.h" 29 30 #include "synchronizeable.h"31 31 32 32 /** … … 77 77 PNode::~PNode () 78 78 { 79 PRINTF(4)("delete %s::%s\n", this->getClass Name(), this->getName());79 PRINTF(4)("delete %s::%s\n", this->getClassCName(), this->getCName()); 80 80 // remove the Node, delete it's children (if required). 81 81 std::list<PNode*>::iterator deleteNode; … … 91 91 { 92 92 PRINTF(4)("%s::%s deletes %s::%s\n", 93 this->getClass Name(), this->getName(),94 (*deleteNode)->getClass Name(), (*deleteNode)->getName());93 this->getClassCName(), this->getCName(), 94 (*deleteNode)->getClassCName(), (*deleteNode)->getCName()); 95 95 delete (*deleteNode); 96 96 } … … 98 98 { 99 99 PRINTF(4)("%s::%s reparents %s::%s\n", 100 this->getClass Name(), this->getName(),101 (*deleteNode)->getClass Name(), (*deleteNode)->getName());100 this->getClassCName(), this->getCName(), 101 (*deleteNode)->getClassCName(), (*deleteNode)->getCName()); 102 102 (*deleteNode)->reparent(); 103 103 } … … 106 106 { 107 107 PRINTF(4)("%s::%s deletes PNode: %s::%s\n", 108 this->getClass Name(), this->getName(),109 (*deleteNode)->getClass Name(), (*deleteNode)->getName());108 this->getClassCName(), this->getCName(), 109 (*deleteNode)->getClassCName(), (*deleteNode)->getCName()); 110 110 delete (*deleteNode); 111 111 } … … 509 509 { 510 510 PRINTF(1)("Tried to reparent to own child '%s::%s' to '%s::%s'.\n", 511 this->getClass Name(), this->getName(), child->getClassName(), child->getName());511 this->getClassCName(), this->getCName(), child->getClassCName(), child->getCName()); 512 512 child->parent = NULL; 513 513 child->parentCoorChanged(); … … 519 519 { 520 520 PNode* tmpNode = node->parent; 521 printf("entering seek PNode loop for name: %s, uid: %i\n", node->get Name(), node->getUniqueID());521 printf("entering seek PNode loop for name: %s, uid: %i\n", node->getCName(), node->getUniqueID()); 522 522 if(tmpNode) 523 printf(" @node name: %s, uid: %d\n", tmpNode->get Name(), tmpNode->getUniqueID());523 printf(" @node name: %s, uid: %d\n", tmpNode->getCName(), tmpNode->getUniqueID()); 524 524 while( tmpNode != NULL && tmpNode->getUniqueID() == NET_UID_UNASSIGNED) 525 525 { 526 printf(" @node name: %s, uid: %d\n", tmpNode->get Name(), tmpNode->getUniqueID());526 printf(" @node name: %s, uid: %d\n", tmpNode->getCName(), tmpNode->getUniqueID()); 527 527 tmpNode = tmpNode->parent; 528 528 } … … 604 604 (*reparenter)->parentMode & PNODE_REPARENT_ON_PARENTS_REMOVE) 605 605 { 606 printf("TEST----------------%s ---- %s\n", this->getClass Name(), (*reparenter)->getClassName());606 printf("TEST----------------%s ---- %s\n", this->getClassCName(), (*reparenter)->getClassCName()); 607 607 (*reparenter)->reparent(); 608 printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClass Name(),(*reparenter)->getParent()->getName());608 printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClassCName(),(*reparenter)->getParent()->getCName()); 609 609 } 610 610 } … … 628 628 else 629 629 PRINTF(2)("Not Found PNode's (%s::%s) new Parent by Name: %s\n", 630 this->getClass Name(), this->getName(), parentName.c_str());630 this->getClassCName(), this->getCName(), parentName.c_str()); 631 631 } 632 632 … … 785 785 delete this->toCoordinate; 786 786 this->toCoordinate = NULL; 787 PRINTF(5)("SmoothMove of %s finished\n", this->get Name());787 PRINTF(5)("SmoothMove of %s finished\n", this->getCName()); 788 788 } 789 789 } … … 793 793 if (unlikely (shiftLen >= 1.0)) 794 794 shiftLen = 1.0; 795 //printf("%s::%s %f\n", this->getClass Name(), this->getName(), this->toStep );795 //printf("%s::%s %f\n", this->getClassCName(), this->getName(), this->toStep ); 796 796 Quaternion rotQuat = Quaternion::quatSlerp(this->relDirection,*this->toDirection, shiftLen); 797 797 if (this->relDirection.distance(rotQuat) > PNODE_ITERATION_DELTA) … … 804 804 delete this->toDirection; 805 805 this->toDirection = NULL; 806 PRINTF(5)("SmoothRotate of %s finished\n", this->get Name());806 PRINTF(5)("SmoothRotate of %s finished\n", this->getCName()); 807 807 this->bRelDirChanged = true; 808 808 } … … 812 812 this->lastAbsCoordinate = this->absCoordinate; 813 813 814 PRINTF(5)("PNode::update - '%s::%s' - (%f, %f, %f)\n", this->getClass Name(), this->getName(),814 PRINTF(5)("PNode::update - '%s::%s' - (%f, %f, %f)\n", this->getClassCName(), this->getCName(), 815 815 this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 816 816 … … 840 840 else // Nodes without a Parent are handled faster :: MOST LIKELY THE NULLPARENT 841 841 { 842 PRINTF(4)("update ParentLess Node (%s::%s) - (%f, %f, %f)\n", this->getClass Name(), this->getName(),842 PRINTF(4)("update ParentLess Node (%s::%s) - (%f, %f, %f)\n", this->getClassCName(), this->getCName(), 843 843 this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); 844 844 if (this->bRelCoorChanged) … … 913 913 914 914 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->getClass Name(),916 this->get Name(),915 this->getClassCName(), 916 this->getCName(), 917 917 this->absCoordinate.x, 918 918 this->absCoordinate.y, … … 1090 1090 { 1091 1091 Synchronizeable::varChangeHandler( id ); 1092 1092 1093 1093 if ( std::find( id.begin(), id.end(), relCoordinate_handle ) != id.end() ) 1094 1094 { -
trunk/src/lib/coord/p_node.h
r8711 r9406 20 20 21 21 #include "base_object.h" 22 #include "stdincl.h"23 22 #include "synchronizeable.h" 24 23 … … 112 111 /** @returns the absolute position */ 113 112 inline const Vector& getLastAbsCoor () const { return this->lastAbsCoordinate; }; 114 113 115 114 void shiftCoor (const Vector& shift); 116 115 void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); }; -
trunk/src/lib/event/event_handler.cc
r9240 r9406 207 207 else 208 208 { 209 PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClass Name(), el->getName(), i, eventType);209 PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassCName(), el->getCName(), i, eventType); 210 210 } 211 211 } … … 216 216 else 217 217 { 218 PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClass Name(), el->getName(), state, eventType);218 PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassCName(), el->getCName(), state, eventType); 219 219 } 220 220 } … … 463 463 { 464 464 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]); 466 471 PRINT(4)("=======================================================\n"); 467 472 this->listeners[state][event.type][i]->process(event); … … 563 568 EVToKeyName(j).c_str(), j, 564 569 ELStateToString((elState)i).c_str(), i, 565 this->listeners[i][j][evl]->get Name(), this->listeners[i][j][evl]);570 this->listeners[i][j][evl]->getCName(), this->listeners[i][j][evl]); 566 571 } 567 572 PRINT(0)("============================EH=\n"); -
trunk/src/lib/event/key_mapper.cc
r8724 r9406 31 31 32 32 33 using namespace std; 33 34 34 35 35 -
trunk/src/lib/graphics/effects/atmospheric_engine.cc
r8495 r9406 25 25 26 26 27 using namespace std; 27 28 28 29 29 /** … … 116 116 std::list<BaseObject*>::const_iterator it; 117 117 for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) { 118 /* printf("%s::%s \n", (*it)->getClass Name(), (*it)->getName());*/118 /* printf("%s::%s \n", (*it)->getClassCName(), (*it)->getName());*/ 119 119 dynamic_cast<WeatherEffect*>(*it)->tick(dt); 120 120 } -
trunk/src/lib/graphics/effects/cloud_effect.cc
r9235 r9406 40 40 float CloudEffect::fadeTime; 41 41 42 using namespace std; 42 43 43 44 44 SHELL_COMMAND(activate, CloudEffect, activateCloud); -
trunk/src/lib/graphics/effects/fog_effect.cc
r9235 r9406 28 28 SHELL_COMMAND(fadeout, FogEffect, fadeOutFog); 29 29 30 using namespace std; 30 31 31 32 32 CREATE_SCRIPTABLE_CLASS(FogEffect, CL_FOG_EFFECT, -
trunk/src/lib/graphics/effects/graphics_effect.cc
r8495 r9406 23 23 24 24 25 using namespace std; 25 26 26 27 27 -
trunk/src/lib/graphics/effects/lense_flare.cc
r9006 r9406 34 34 35 35 36 using namespace std; 36 37 37 38 38 -
trunk/src/lib/graphics/effects/lightning_effect.cc
r9235 r9406 34 34 SHELL_COMMAND(deactivate, LightningEffect, deactivateLightning); 35 35 36 using namespace std; 36 37 37 38 38 CREATE_SCRIPTABLE_CLASS(LightningEffect, CL_LIGHTNING_EFFECT, … … 130 130 131 131 //load sound 132 if (this->thunderBuffer != NULL)133 ResourceManager::getInstance()->unload(this->thunderBuffer);134 132 this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/thunder.wav", WAV); 135 133 -
trunk/src/lib/graphics/effects/rain_effect.cc
r9235 r9406 39 39 SHELL_COMMAND(stopraining, RainEffect, stopRaining); 40 40 41 using namespace std; 41 42 42 43 43 CREATE_SCRIPTABLE_CLASS(RainEffect, CL_RAIN_EFFECT, -
trunk/src/lib/graphics/effects/snow_effect.cc
r9235 r9406 1 1 /* 2 3 4 5 6 7 8 9 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. 10 10 11 11 ### File Specific: 12 12 main-programmer: hdavid, amaechler 13 13 */ 14 14 … … 35 35 SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow); 36 36 37 using namespace std;38 37 39 38 CREATE_SCRIPTABLE_CLASS(SnowEffect, CL_SNOW_EFFECT, … … 46 45 SnowEffect::SnowEffect(const TiXmlElement* root) 47 46 { 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 } 61 59 62 60 if(snowActivate) { 63 61 this->activate(); 64 62 SnowEffect::snowParticles->precache((int) this->snowLife); 65 63 } … … 69 67 SnowEffect::~SnowEffect() 70 68 { 71 69 this->deactivate(); 72 70 } 73 71 … … 76 74 void SnowEffect::loadParams(const TiXmlElement* root) 77 75 { 78 79 80 81 82 83 84 85 86 87 88 89 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); 90 88 LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor); 91 89 LoadParam(root, "skycolor", this, SnowEffect, setSkyColor); 92 90 LoadParam(root, "fadetime", this, SnowEffect, setFadeTime); 93 91 94 95 96 97 98 92 LOAD_PARAM_START_CYCLE(root, element); 93 { 94 LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption); 95 } 96 LOAD_PARAM_END_CYCLE(element); 99 97 } 100 98 101 99 void SnowEffect::init() 102 100 { 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 126 124 this->fadeTime = 10; 127 125 this->cloudColor = Vector(0.2f, 0.2f, 0.2f); … … 131 129 void SnowEffect::activate() 132 130 { 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 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); 156 154 157 155 if (this->snowWindForce != 0) 158 156 this->soundSource.play(this->windBuffer, 0.1f * this->snowWindForce, true); 159 157 160 158 // Store cloud- and sky color before the snow 161 159 this->oldCloudColor = CloudEffect::cloudColor; … … 171 169 void SnowEffect::deactivate() 172 170 { 173 174 175 176 177 178 179 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 181 179 // Restore the old cloud- and sky color 182 180 CloudEffect::changeCloudColor(this->oldCloudColor, this->fadeTime); … … 186 184 void SnowEffect::draw() const 187 185 { 188 189 186 if (!this->snowActivate) 187 return; 190 188 } 191 189 192 190 void SnowEffect::tick(float dt) 193 191 { 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 101 101 102 102 private: 103 int particles;103 int particles; 104 104 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; 116 116 117 bool snowMove;118 bool snowActivate;117 bool snowMove; 118 bool snowActivate; 119 119 120 120 PlaneEmitter* emitter; 121 121 122 122 static SpriteParticles* snowParticles; 123 OrxSound::SoundSource soundSource;123 OrxSound::SoundSource soundSource; 124 124 OrxSound::SoundBuffer* windBuffer; 125 125 126 Vector oldSkyColor;127 Vector oldCloudColor;128 Vector skyColor;129 Vector cloudColor;126 Vector oldSkyColor; 127 Vector oldCloudColor; 128 Vector skyColor; 129 Vector cloudColor; 130 130 }; 131 131 -
trunk/src/lib/graphics/effects/sun_effect.cc
r8793 r9406 21 21 22 22 23 using namespace std; 23 24 24 25 25 -
trunk/src/lib/graphics/effects/volfog_effect.cc
r9006 r9406 47 47 48 48 49 using namespace std; 49 50 50 51 51 CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT); -
trunk/src/lib/graphics/effects/weather_effect.cc
r8495 r9406 21 21 22 22 23 using namespace std; 23 24 24 25 25 -
trunk/src/lib/graphics/graphics_engine.cc
r8740 r9406 50 50 #include "static_model.h" 51 51 #endif 52 using namespace std;53 52 54 53 SHELL_COMMAND(wireframe, GraphicsEngine, wireframe); 55 54 SHELL_COMMAND(fps, GraphicsEngine, toggleFPSdisplay); 56 55 57 56 /** … … 67 66 this->bDisplayFPS = false; 68 67 this->bAntialiasing = false; 68 this->bDedicated = false; 69 69 this->minFPS = 9999; 70 70 this->maxFPS = 0; … … 164 164 MultiType textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "1"); 165 165 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(); 166 170 167 171 // searching for a usefull resolution … … 604 608 } 605 609 610 /** 611 * this draws the graphics engines graphics effecs 612 */ 606 613 void GraphicsEngine::draw() const 607 614 { 608 // LightManager::getInstance()->draw(); 609 610 if (this->graphicsEffects != NULL) 615 if( this->graphicsEffects != NULL) 611 616 { 612 617 //draw the graphics effects 613 list<BaseObject*>::const_iterator it;618 std::list<BaseObject*>::const_iterator it; 614 619 for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++) 615 620 dynamic_cast<GraphicsEffect*>(*it)->draw(); … … 618 623 Render2D::getInstance()->draw(E2D_LAYER_BOTTOM, E2D_LAYER_ABOVE_ALL); 619 624 Shader::restoreShader(); 625 } 626 627 628 void GraphicsEngine::toggleFPSdisplay() 629 { 630 this->displayFPS(!this->bDisplayFPS); 620 631 } 621 632 -
trunk/src/lib/graphics/graphics_engine.h
r8518 r9406 46 46 void toggleFullscreen(); 47 47 static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0); 48 inline bool isDedicated() { return this->bDedicated; } 48 49 49 50 inline void setAntialiasing(bool flag) { this->bAntialiasing = flag; } … … 74 75 void drawBackgroundElements() const; 75 76 void draw() const; 77 void toggleFPSdisplay(); 76 78 void displayFPS(bool display); 77 79 … … 113 115 bool particlesEnabled; //!< If particles should be enabled. 114 116 bool bAntialiasing; //!< true if antialiasing enabled 117 bool bDedicated; //!< true if this server is a dedicated server and should not render the scene 115 118 116 119 int particlesValue; //!< How many particles -
trunk/src/lib/graphics/importer/bsp_file.cc
r9025 r9406 40 40 #include <vector> 41 41 42 using namespace std; 42 43 43 44 44 … … 96 96 if (stat( name , &results) == 0) { 97 97 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); 99 99 bspFile.read(this->header, 260); 100 100 PRINTF(0)("BSP FILE: BSPVersion: %i. \n", ((int *)(header) )[1]); -
trunk/src/lib/graphics/importer/grid.cc
r6467 r9406 18 18 #include "grid.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/graphics/importer/interactive_model.cc
r8490 r9406 20 20 #include "glincl.h" 21 21 22 using namespace std; 22 23 23 24 24 /** -
trunk/src/lib/graphics/importer/material.cc
r8761 r9406 88 88 Material::~Material() 89 89 { 90 PRINTF(5)("delete Material %s.\n", this->get Name());90 PRINTF(5)("delete Material %s.\n", this->getCName()); 91 91 92 92 if (this->ambientTexture != NULL) … … 217 217 void Material::setIllum (int illum) 218 218 { 219 PRINTF(4)("setting illumModel of Material %s to %i\n", this->get Name(), illum);219 PRINTF(4)("setting illumModel of Material %s to %i\n", this->getCName(), illum); 220 220 this->illumModel = illum; 221 221 } … … 229 229 void Material::setDiffuse (float r, float g, float b) 230 230 { 231 PRINTF(4)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->get Name(), 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); 232 232 this->diffuse = Color(r, g, b, this->diffuse.a() ); 233 233 } … … 242 242 void Material::setAmbient (float r, float g, float b) 243 243 { 244 PRINTF(4)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->get Name(), 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); 245 245 this->ambient = Color(r, g, b, 1.0); 246 246 } … … 254 254 void Material::setSpecular (float r, float g, float b) 255 255 { 256 PRINTF(4)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->get Name(), 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); 257 257 this->specular = Color (r, g, b, 1.0); 258 258 } … … 273 273 void Material::setTransparency (float trans) 274 274 { 275 PRINTF(4)("setting Transparency of Material %s to %f.\n", this->get Name(), trans);275 PRINTF(4)("setting Transparency of Material %s to %f.\n", this->getCName(), trans); 276 276 this->diffuse.a() = trans; 277 277 } … … 455 455 void Material::debug() const 456 456 { 457 PRINT(0)("Debug Material: %s\n", this->get Name());457 PRINT(0)("Debug Material: %s\n", this->getCName()); 458 458 PRINT(0)("illumModel: %d ; ShiniNess %f\n", this->illumModel, shininess); 459 459 PRINT(0)("diffuseColor: "); diffuse.debug(); -
trunk/src/lib/graphics/importer/md2/md2Model.cc
r9235 r9406 22 22 23 23 24 using namespace std; 24 25 25 26 26 //! the model anorms -
trunk/src/lib/graphics/importer/md3/md3_animation_cfg.cc
r9391 r9406 19 19 #include "md3_animation.h" 20 20 21 #include " tokenizer.h"21 #include "substring.h" 22 22 #include "helper_functions.h" 23 23 24 24 #include "debug.h" 25 25 26 #include <stdio.h> 27 #include <stdlib.h> 28 29 30 using namespace std; 26 27 28 31 29 32 30 namespace md3 … … 100 98 if( inHeader && line.find("sex") == 0) { 101 99 //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/"); 104 101 105 102 std::string sexStr = tokens.back(); … … 117 114 else if( inHeader && line.find("headoffset") == 0) { 118 115 // 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/"); 121 117 122 118 float z = atof(tokens.back().c_str()); tokens.pop_back(); … … 130 126 else if( inHeader && line.find("footsteps") == 0) { 131 127 //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/"); 134 129 135 130 this->footsteps = tokens.back(); … … 190 185 // parse the line: 191 186 // 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/"); 194 188 195 189 anim->fps = atoi(tokens.back().c_str()); tokens.pop_back(); -
trunk/src/lib/graphics/importer/model.cc
r8316 r9406 20 20 #include "glincl.h" 21 21 22 using namespace std; 22 23 23 24 24 /** -
trunk/src/lib/graphics/importer/primitive_model.cc
r9110 r9406 21 21 #include "debug.h" 22 22 23 using namespace std; 23 24 24 25 25 /** -
trunk/src/lib/graphics/importer/static_model.cc
r8362 r9406 23 23 #include <stdarg.h> 24 24 25 using namespace std; 25 26 26 27 27 … … 161 161 { 162 162 PRINTF(4)("Deleting Model "); 163 if ( this->getName())164 { 165 PRINT(4)("%s\n", this->get Name());163 if (!this->getName().empty()) 164 { 165 PRINT(4)("%s\n", this->getCName()); 166 166 } 167 167 else … … 178 178 179 179 //! @todo do we really have to delete this material?? 180 list<ModelMaterial*>::iterator modMat;180 std::list<ModelMaterial*>::iterator modMat; 181 181 for(modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++) 182 182 { … … 214 214 void StaticModel::rebuild() 215 215 { 216 PRINTF(3)("Rebuilding Model '%s'\n", this->get Name());216 PRINTF(3)("Rebuilding Model '%s'\n", this->getCName()); 217 217 this->finalize(); 218 218 } … … 266 266 tmpGroup = tmpGroup->next; 267 267 } 268 PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->get Name());268 PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getCName()); 269 269 return; 270 270 } … … 291 291 tmpGroup = tmpGroup->next; 292 292 } 293 PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->get Name());293 PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getCName()); 294 294 return; 295 295 } … … 358 358 Material* StaticModel::findMaterialByName(const std::string& materialName) 359 359 { 360 list<ModelMaterial*>::iterator modMat;360 std::list<ModelMaterial*>::iterator modMat; 361 361 for (modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++) 362 362 if (materialName == (*modMat)->material->getName()) … … 748 748 { 749 749 tmpFace->material->select(); 750 PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->get Name());750 PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getCName()); 751 751 } 752 752 } … … 840 840 else if( tmpFace->vertexCount > 4) { 841 841 if (!warned) { 842 PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->get Name());842 PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getCName()); 843 843 warned = true; 844 844 } -
trunk/src/lib/graphics/importer/texture.cc
r8761 r9406 230 230 if (this->data->getStoredImage() != NULL) 231 231 { 232 PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClass Name(), this->getName());232 PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassCName(), this->getCName()); 233 233 this->setTexture(Texture::loadTexToGL(this->data->getStoredImage())); 234 234 } -
trunk/src/lib/graphics/importer/texture_sequence.cc
r8619 r9406 225 225 bool TextureSequence::rebuild() 226 226 { 227 PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClass Name(), this->getName());227 PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClassCName(), this->getCName()); 228 228 229 229 for (unsigned int i = 0; i < this->textures.size(); i++) -
trunk/src/lib/graphics/importer/vertex_array_model.cc
r8362 r9406 23 23 #include "tc.h" 24 24 25 using namespace std; 25 26 26 27 27 ///////////// … … 116 116 VertexArrayModel::~VertexArrayModel() 117 117 { 118 PRINTF(4)("Deleting VertexArrayModel %s\n", this->get Name());118 PRINTF(4)("Deleting VertexArrayModel %s\n", this->getCName()); 119 119 } 120 120 … … 127 127 void VertexArrayModel::draw() const 128 128 { 129 PRINTF(4)("drawing 3D-VertexArrayModel %s\n", this->get Name());129 PRINTF(4)("drawing 3D-VertexArrayModel %s\n", this->getCName()); 130 130 glEnableClientState(GL_VERTEX_ARRAY ); 131 131 glEnableClientState(GL_TEXTURE_COORD_ARRAY ); … … 343 343 void VertexArrayModel::debug() const 344 344 { 345 PRINT(0)("VertexArrayModel (%s): debug\n", this->get Name());345 PRINT(0)("VertexArrayModel (%s): debug\n", this->getCName()); 346 346 PRINT(0)("Stripes: %d; Indices: %d; Vertices: %d; Normals %d; TextCoords %d; Colors %d\n", 347 347 this->stripes.size(), -
trunk/src/lib/graphics/render2D/element_2d.cc
r8989 r9406 104 104 deleteNode = tmp; 105 105 tmp++; 106 // printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClass Name(), this->getName());106 // printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassCName(), this->getName()); 107 107 if ((this->parentMode & E2D_PROHIBIT_CHILD_DELETE) || 108 108 ((*deleteNode)->parentMode & E2D_PROHIBIT_DELETE_WITH_PARENT)) … … 214 214 { 215 215 PRINTF(2)("Unable to set %s to layer %s, because it's parent(%s) is of higher layer %s\n", 216 this->get Name(),216 this->getCName(), 217 217 Element2D::layer2DToChar(layer), 218 this->parent->get Name(),218 this->parent->getCName(), 219 219 Element2D::layer2DToChar(this->parent->getLayer())); 220 220 layer = this->parent->getLayer(); … … 602 602 { 603 603 PRINTF(2)("Layer '%s' of Child(%s::%s) lower than parents(%s::%s) layer '%s'. updating...\n", 604 Element2D::layer2DToChar(child->getLayer()),child->getClass Name(), child->getName(),605 this->getClass Name(), this->getName(), Element2D::layer2DToChar(this->layer));604 Element2D::layer2DToChar(child->getLayer()),child->getClassCName(), child->getCName(), 605 this->getClassCName(), this->getCName(), Element2D::layer2DToChar(this->layer)); 606 606 child->layer = this->layer; 607 607 this->children.push_front(child); … … 627 627 { 628 628 PRINTF(1)("Tried to reparent2D to own child '%s::%s' to '%s::%s'.\n", 629 this->getClass Name(), this->getName(), child->getClassName(), child->getName());629 this->getClassCName(), this->getCName(), child->getClassCName(), child->getCName()); 630 630 child->parent = NULL; 631 631 } … … 701 701 { 702 702 (*reparenter)->reparent2D(); 703 PRINTF(5)("REPARENTED TO: %s::%s\n",(*reparenter)->getParent2D()->getClass Name(),(*reparenter)->getParent2D()->getName());703 PRINTF(5)("REPARENTED TO: %s::%s\n",(*reparenter)->getParent2D()->getClassCName(),(*reparenter)->getParent2D()->getCName()); 704 704 } 705 705 } … … 723 723 else 724 724 PRINTF(2)("Not Found Element2D's (%s::%s) new Parent by Name: %s\n", 725 this->getClass Name(), this->getName(), parentName.c_str());725 this->getClassCName(), this->getCName(), parentName.c_str()); 726 726 } 727 727 … … 865 865 Vector2D tmp = *this->toCoordinate; 866 866 this->setRelCoor2D(tmp); 867 PRINTF(5)("SmoothMove of %s finished\n", this->get Name());867 PRINTF(5)("SmoothMove of %s finished\n", this->getCName()); 868 868 } 869 869 } … … 879 879 float tmp = *this->toDirection; 880 880 this->setRelDir2D(tmp); 881 PRINTF(5)("SmoothRotate of %s finished\n", this->get Name());881 PRINTF(5)("SmoothRotate of %s finished\n", this->getCName()); 882 882 } 883 883 } … … 893 893 delete this->toSize; 894 894 this->toSize = NULL; 895 PRINTF(5)("SmoothRotate of %s finished\n", this->get Name());895 PRINTF(5)("SmoothRotate of %s finished\n", this->getCName()); 896 896 } 897 897 } … … 900 900 this->lastAbsCoordinate = this->absCoordinate; 901 901 902 PRINTF(5)("Element2D::update - %s - (%f, %f)\n", this->get Name(), this->absCoordinate.x, this->absCoordinate.y);902 PRINTF(5)("Element2D::update - %s - (%f, %f)\n", this->getCName(), this->absCoordinate.x, this->absCoordinate.y); 903 903 904 904 … … 937 937 projectPos+1, 938 938 projectPos+2); 939 // printf("%s::%s == %f %f %f :: %f %f\n", this->getClass Name(), this->getName(),939 // printf("%s::%s == %f %f %f :: %f %f\n", this->getClassCName(), this->getName(), 940 940 // this->bindNode->getAbsCoor().x, 941 941 // this->bindNode->getAbsCoor().y, … … 1026 1026 PRINT(0)(" -"); 1027 1027 PRINT(0)("E2D(%s::%s);AC:(%0.2f, %0.2f);RC:(%0.2f, %0.2f);AD(%0.2f)->%s;Layer:(%s)\n", 1028 this->getClass Name(),1029 this->get Name(),1028 this->getClassCName(), 1029 this->getCName(), 1030 1030 this->absCoordinate.x, 1031 1031 this->absCoordinate.y, -
trunk/src/lib/graphics/render2D/image_plane.cc
r7843 r9406 25 25 26 26 27 using namespace std; 27 28 28 29 29 -
trunk/src/lib/graphics/render2D/render_2d.cc
r7840 r9406 22 22 #include "element_2d.h" 23 23 24 using namespace std; 24 25 25 26 26 /** -
trunk/src/lib/graphics/shader.cc
r8316 r9406 32 32 #endif 33 33 34 using namespace std; 34 35 35 36 36 -
trunk/src/lib/graphics/spatial_separation/quadtree.cc
r9110 r9406 24 24 #include "debug.h" 25 25 26 using namespace std; 26 27 27 #define QUADTREE_MATERIAL_COUNT 4 28 28 -
trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r9110 r9406 26 26 #include "util/list.h" 27 27 28 using namespace std; 28 29 29 30 30 -
trunk/src/lib/graphics/spatial_separation/spatial_separation.cc
r6022 r9406 23 23 #include "compiler.h" 24 24 25 using namespace std; 25 26 26 27 27 -
trunk/src/lib/graphics/text_engine/limited_width_text.cc
r8981 r9406 160 160 void LimitedWidthText::debug() const 161 161 { 162 printf("Debug %s::%s \n", this->getClass Name(), this->getName() );162 printf("Debug %s::%s \n", this->getClassCName(), this->getCName() ); 163 163 } -
trunk/src/lib/graphics/text_engine/multi_line_text.cc
r8768 r9406 152 152 void MultiLineText::debug() const 153 153 { 154 printf("Debug %s::%s: %d lines\n", this->getClass Name(), this->getName(), this->getLineCount());154 printf("Debug %s::%s: %d lines\n", this->getClassCName(), this->getCName(), this->getLineCount()); 155 155 156 156 std::string tmpText = this->text(); -
trunk/src/lib/graphics/text_engine/text.cc
r8769 r9406 28 28 */ 29 29 Text::Text(const std::string& fontFile, unsigned int textSize) 30 : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)30 // : _font(fontFile, FONT_DEFAULT_RENDER_SIZE) 31 31 { 32 32 this->setClassID(CL_TEXT, "Text"); 33 33 34 34 // initialize this Text 35 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE); 35 36 this->_size = textSize; 36 37 this->setSizeY2D(textSize); … … 278 279 void Text::debug() const 279 280 { 280 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->get Name(), 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()); 281 282 // 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()); 282 283 } -
trunk/src/lib/graphics/text_engine/text_engine.cc
r8761 r9406 26 26 #include "font.h" 27 27 28 using namespace std; 28 29 29 30 30 #include <stdlib.h> … … 122 122 void TextEngine::debug() const 123 123 { 124 const list<BaseObject*>* textList = ClassList::getList(CL_TEXT);124 const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT); 125 125 if (textList != NULL) 126 126 { … … 130 130 PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size()); 131 131 132 list<BaseObject*>::const_iterator text;132 std::list<BaseObject*>::const_iterator text; 133 133 for ( text = textList->begin(); text != textList->end(); text++) 134 134 dynamic_cast<Text*>(*text)->debug(); -
trunk/src/lib/gui/gl/Makefile.am
r8973 r9406 13 13 \ 14 14 glgui_handler.cc \ 15 signal_connector.cc \16 15 glgui_mainwidget.cc \ 17 16 glgui_widget.cc \ … … 38 37 glmenu/glmenu_imagescreen.h \ 39 38 \ 40 signal_connector.h \41 39 glgui.h \ 42 40 glgui_defs.h \ -
trunk/src/lib/gui/gl/glgui_button.cc
r8769 r9406 79 79 { 80 80 GLGuiWidget::clicking(pos); 81 emit(clicked());81 clicked.emit(); 82 82 } 83 83 void GLGuiButton::releasing(const Vector2D& pos, bool focused) 84 84 { 85 85 GLGuiWidget::releasing(pos, focused); 86 emit(released());86 released.emit(); 87 87 } 88 88 … … 103 103 { 104 104 if (event.bPressed) 105 emit(pushed());105 clicked.emit(); 106 106 else 107 emit(released());107 released.emit(); 108 108 return true; 109 109 } -
trunk/src/lib/gui/gl/glgui_button.h
r8717 r9406 42 42 virtual bool processEvent(const Event& event); 43 43 44 DeclareSignal0(clicked);45 DeclareSignal0(released);44 sigslot::signal0<> clicked; 45 sigslot::signal0<> released; 46 46 47 47 -
trunk/src/lib/gui/gl/glgui_checkbutton.cc
r8717 r9406 55 55 { 56 56 this->bActive = bActive; 57 emit(this->toggled(this->bActive));57 this->toggled.emit(this->bActive); 58 58 } 59 59 -
trunk/src/lib/gui/gl/glgui_checkbutton.h
r8717 r9406 34 34 virtual void update() {}; 35 35 36 DeclareSignal1(toggled, bool);36 sigslot::signal1<bool> toggled; 37 37 38 38 protected: -
trunk/src/lib/gui/gl/glgui_frame.cc
r8145 r9406 57 57 else 58 58 { 59 PRINTF(2)("Frame %s is already filled, not filling with %s\n", this->get Name(), widget->getName());59 PRINTF(2)("Frame %s is already filled, not filling with %s\n", this->getCName(), widget->getCName()); 60 60 } 61 61 } -
trunk/src/lib/gui/gl/glgui_image.h
r8448 r9406 34 34 virtual void draw() const; 35 35 36 DeclareSignal0(imageChanged);36 sigslot::signal0<> imageChanged; 37 37 38 38 protected: -
trunk/src/lib/gui/gl/glgui_inputline.cc
r8717 r9406 124 124 this->resize(); 125 125 this->setFrontColor(Color(1,1,1,1), true); 126 emit(this->textChanged(this->_text.text()));126 this->textChanged.emit(this->_text.text()); 127 127 } 128 128 … … 146 146 void GLGuiInputLine::pushEnter() 147 147 { 148 emit(this->enterPushed(this->_text.text()));148 this->enterPushed.emit(this->_text.text()); 149 149 if (this->_clearOnEnter) 150 150 this->clear(); -
trunk/src/lib/gui/gl/glgui_inputline.h
r8619 r9406 49 49 virtual bool processEvent(const Event& event); 50 50 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; 53 53 54 54 protected: -
trunk/src/lib/gui/gl/glgui_slider.cc
r8717 r9406 77 77 this->_handle.setCenter(this->sliderPosition(), borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0); 78 78 79 emit(valueChanged(this->_value));79 valueChanged.emit(this->_value); 80 80 } 81 81 … … 90 90 { 91 91 this->_minValue = minimum; 92 emit(rangeChanged(this->_minValue, this->_maxValue));92 rangeChanged.emit(this->_minValue, this->_maxValue); 93 93 } 94 94 if (this->value() < this->min()) … … 107 107 { 108 108 this->_maxValue = maximum; 109 emit(rangeChanged(this->_minValue, this->_maxValue));109 rangeChanged.emit(this->_minValue, this->_maxValue); 110 110 } 111 111 if (this->value() > this->max()) … … 126 126 this->_minValue = minimum; 127 127 this->_maxValue = maximum; 128 emit(rangeChanged(this->_minValue, this->_maxValue));128 rangeChanged.emit(this->_minValue, this->_maxValue); 129 129 } 130 130 if (this->value() < this->min()) -
trunk/src/lib/gui/gl/glgui_slider.h
r8717 r9406 51 51 virtual void draw() const; 52 52 53 DeclareSignal1(valueChanged, float);54 DeclareSignal2(rangeChanged, float, float);53 sigslot::signal1<float> valueChanged; 54 sigslot::signal2<float, float> rangeChanged; 55 55 56 56 protected: -
trunk/src/lib/gui/gl/glgui_text.cc
r8991 r9406 113 113 this->resize(); 114 114 this->setFrontColor(_changedTextColor, true); 115 emit(this->textChanged(this->_text.text()));115 this->textChanged.emit(this->_text.text()); 116 116 } 117 117 -
trunk/src/lib/gui/gl/glgui_text.h
r8991 r9406 33 33 void setChangedTextColor(const Color& color); 34 34 35 void setLineWidth(float lineWidth) { this->_text.setLineWidth(lineWidth); }; 35 36 void setDotsPosition(LimitedWidthText::DotsPosition dotsPosition) { this->_text.setDotsPosition(dotsPosition); }; 36 37 … … 40 41 virtual void draw() const; 41 42 42 DeclareSignal1(textChanged, const std::string&);43 sigslot::signal1<const std::string&> textChanged; 43 44 44 45 protected: -
trunk/src/lib/gui/gl/glgui_textfield.cc
r9015 r9406 112 112 this->resize(); 113 113 this->setFrontColor(_changedTextColor, true); 114 emit(this->textChanged(this->_text.text()));114 this->textChanged.emit(this->_text.text()); 115 115 } 116 116 -
trunk/src/lib/gui/gl/glgui_textfield.h
r9015 r9406 38 38 virtual void draw() const; 39 39 40 DeclareSignal1(textChanged, const std::string&);40 sigslot::signal1<const std::string&> textChanged; 41 41 42 42 protected: -
trunk/src/lib/gui/gl/glgui_widget.cc
r9019 r9406 288 288 this->setWidgetSize(Vector2D(x, y)); 289 289 } 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 303 290 304 291 void GLGuiWidget::show() … … 806 793 //this->_currentStyle = this->_style[state]; 807 794 this->_state = state; 808 PRINTF(4)("%s::%s Switches to state %s\n", this->getClass Name(), 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()); 809 796 810 797 this->animateBack(); … … 874 861 void GLGuiWidget::debug(unsigned int level) const 875 862 { 876 PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClass Name(), this->getName());863 PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassCName(), this->getCName()); 877 864 if (_parent != NULL) 878 PRINT(0)("- Parent %s::%s ", _parent->getClass Name(), _parent->getName());865 PRINT(0)("- Parent %s::%s ", _parent->getClassCName(), _parent->getCName()); 879 866 PRINT(0)("- State: %s", StateString[_state].c_str()); 880 867 -
trunk/src/lib/gui/gl/glgui_widget.h
r8990 r9406 17 17 18 18 #include "event.h" 19 #include "sig nal_connector.h"19 #include "sigslot/signal.h" 20 20 21 21 namespace OrxGui … … 70 70 void release(const Vector2D& pos); 71 71 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);77 72 78 73 OrxGui::State state() const { return this->_state; }; -
trunk/src/lib/gui/gl/glmenu/glmenu_imagescreen.cc
r8316 r9406 27 27 CREATE_FACTORY(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN); 28 28 29 using namespace std; 29 30 30 /** 31 31 * @param root The Element to load the GLMenu from -
trunk/src/lib/gui/gui_saveable.cc
r8362 r9406 60 60 void Saveable::load() 61 61 { 62 this->value() = Preferences::getInstance()->getMultiType(this->group->get Name(), this->getName(), this->_defaultValue);63 PRINTF(4)("Loaded to '%s' of group '%s' value '%s'\n", this->get Name(), 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()); 64 64 } 65 65 66 66 void Saveable::save() 67 67 { 68 Preferences::getInstance()->setMultiType(this->group->get Name(), this->getName(), this->value() );69 PRINTF(4)("Saved to '%s' of group '%s' value '%s'\n", this->get Name(), 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()); 70 70 } 71 71 -
trunk/src/lib/gui/qt/gui_video.cc
r8362 r9406 50 50 layout->addWidget(fullscreen, 0, 0); 51 51 52 QtGuiCheckBox* dedicated = new QtGuiCheckBox(CONFIG_NAME_NO_RENDER, this, false); 53 //fullscreen->setName(); 54 layout->addWidget(dedicated, 1, 0); 55 52 56 QtGuiCheckBox* wireframe = new QtGuiCheckBox(CONFIG_NAME_WIREFRAME, this, false); 53 layout->addWidget(wireframe, 1, 0);57 layout->addWidget(wireframe, 2, 0); 54 58 55 59 { 56 60 QComboBox* resolution = new QtGuiComboBox(CONFIG_NAME_RESOLUTION, this, "640x480"); 57 61 resolution->setEditable(true); 58 layout->addWidget(resolution, 2, 0);62 layout->addWidget(resolution, 3, 0); 59 63 std::vector<QString> resolutions; 60 64 this->getResolutions(resolutions); -
trunk/src/lib/lang/base_object.cc
r8145 r9406 21 21 #include "util/loading/load_param.h" 22 22 #include "class_list.h" 23 24 #include "synchronizeable.h"25 26 using namespace std;27 28 23 29 24 /** … … 50 45 ClassList::removeFromClassList(this); 51 46 52 // delete []this->className;53 47 if (this->xmlElem != NULL) 54 48 delete this->xmlElem; … … 61 55 void BaseObject::loadParams(const TiXmlElement* root) 62 56 { 63 // all loadParams should sometime arrive here.57 // all loadParams should arrive here, and be tested for (root != NULL) 64 58 assert (root != NULL); 65 59 60 // copy the xml-element for to know how it was loaded. 66 61 if (this->xmlElem != NULL) 67 62 delete this->xmlElem; 68 63 this->xmlElem = root->Clone(); 64 69 65 // name setup 70 66 LoadParam(root, "name", this, BaseObject, setName) … … 92 88 /** 93 89 * @brief set the name of the Object 90 * @param objectName The new name of the Object. 94 91 */ 95 92 void BaseObject::setName (const std::string& objectName) … … 164 161 * @returns true on match, false otherwise. 165 162 */ 166 bool BaseObject::operator==(const std::string& objectName) 163 bool BaseObject::operator==(const std::string& objectName) const 167 164 { 168 165 return (this->objectName == objectName); 169 166 } 170 167 171 172 /**173 * @brief displays everything this class is174 * @TODO REIMPLEMENT WITH SENSE.175 */176 void BaseObject::whatIs() const177 {178 179 } -
trunk/src/lib/lang/base_object.h
r8362 r9406 1 1 /*! 2 2 * @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 */ 7 11 8 12 9 #ifndef _ BASE_OBJECT_H10 #define _ BASE_OBJECT_H13 #ifndef __BASE_OBJECT_H_ 14 #define __BASE_OBJECT_H_ 11 15 12 16 #include "class_id.h" 17 #include "sigslot/slot.h" 18 13 19 #include <string> 14 20 … … 18 24 19 25 //! A class all other classes are derived from 20 class BaseObject 26 class BaseObject : public sigslot::has_slots<> 21 27 { 22 28 … … 29 35 void setName (const std::string& newName); 30 36 /** 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(); }; 32 40 /** @returns the XML-Element with whicht this Object was loaded */ 33 41 inline TiXmlNode* getXmlElem() const { return this->xmlElem; }; 34 42 35 43 /** @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(); }; 37 47 /** @returns the classID of the corresponding Object */ 38 48 inline int getClassID() const { return this->classID; }; … … 41 51 bool isA (ClassID classID) const; 42 52 bool isA (const std::string& className) const; 43 void whatIs() const;44 53 45 bool operator==(const std::string& objectName);46 54 /** @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; 48 57 49 58 protected: … … 54 63 55 64 private: 56 57 65 std::string className; //!< the name of the class 58 66 long classID; //!< this is the id from the class_id.h enumeration … … 64 72 }; 65 73 66 #endif /* _ BASE_OBJECT_H*/74 #endif /* __BASE_OBJECT_H_ */ -
trunk/src/lib/lang/class_list.cc
r8783 r9406 23 23 #include <cmath> 24 24 25 using namespace std; 25 26 26 27 27 /** … … 61 61 { 62 62 if (unlikely(classList == NULL)) 63 ClassList::classList = new list<ClassList>();63 ClassList::classList = new std::list<ClassList>(); 64 64 65 65 PRINTF(5)("subscribe a '%s'\n", className.c_str() ); … … 85 85 void ClassList::removeFromClassList(BaseObject* objectPointer) 86 86 { 87 list<ClassList>::iterator cl;87 std::list<ClassList>::iterator cl; 88 88 for(cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 89 89 { … … 110 110 ClassList::classNames.clear(); 111 111 112 list<ClassList>::const_iterator cl;112 std::list<ClassList>::const_iterator cl; 113 113 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 114 114 ClassList::classNames.push_back((*cl).className); … … 207 207 std::list<BaseObject*>::iterator bo; 208 208 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 209 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())209 if (objectName == (*bo)->getName()) 210 210 return (*bo); 211 211 } … … 213 213 else 214 214 { 215 list<ClassList>::iterator cl;215 std::list<ClassList>::iterator cl; 216 216 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 217 217 { 218 218 std::list<BaseObject*>::iterator bo; 219 219 for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++) 220 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())220 if (objectName == (*bo)->getName()) 221 221 return (*bo); 222 222 } … … 241 241 std::list<BaseObject*>::iterator bo; 242 242 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 243 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())243 if (objectName == (*bo)->getName()) 244 244 return (*bo); 245 245 } … … 268 268 else 269 269 { 270 list<ClassList>::iterator cl;270 std::list<ClassList>::iterator cl; 271 271 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 272 272 { … … 286 286 std::list<BaseObject*>::iterator bo; 287 287 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 288 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())288 if (objectName == (*bo)->getName()) 289 289 return true; 290 290 } … … 299 299 void ClassList::whatIs(const BaseObject* object) 300 300 { 301 list<ClassList>::iterator cl;301 std::list<ClassList>::iterator cl; 302 302 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 303 303 if (object->isA((*cl).classID)) … … 359 359 int lenCount = 0; 360 360 361 list<ClassList>::iterator cl;361 std::list<ClassList>::iterator cl; 362 362 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 363 363 { … … 377 377 { 378 378 PRINT(0)("| Listing Instances:\n"); 379 list<BaseObject*>::const_iterator bo;379 std::list<BaseObject*>::const_iterator bo; 380 380 for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++) 381 381 { 382 PRINT(0)("| %s::%s::(0x%.8X->%p ", (*bo)->getClass Name(), (*bo)->getName(), (*bo)->getClassID(), (*bo));382 PRINT(0)("| %s::%s::(0x%.8X->%p ", (*bo)->getClassCName(), (*bo)->getCName(), (*bo)->getClassID(), (*bo)); 383 383 if (debugLevel == 3) 384 384 ClassList::whatIs(*bo); -
trunk/src/lib/math/line.cc
r6617 r9406 26 26 #endif 27 27 28 using namespace std; 28 29 29 30 30 /** -
trunk/src/lib/math/plane.cc
r7711 r9406 24 24 #endif 25 25 26 using namespace std; 26 27 27 28 28 /** -
trunk/src/lib/math/rotation_OBSOLETE.cc
r6617 r9406 24 24 #endif 25 25 26 using namespace std; 26 27 27 28 28 /** -
trunk/src/lib/math/vector2D.cc
r6615 r9406 27 27 #endif 28 28 29 using namespace std; 29 30 30 31 31 ///////////// -
trunk/src/lib/network/Makefile.am
r8623 r9406 8 8 shared_network_data.cc \ 9 9 network_socket.cc \ 10 connection_monitor.cc \11 10 network_stream.cc \ 12 11 data_stream.cc \ … … 20 19 network_game_manager.cc \ 21 20 converter.cc \ 21 peer_info.cc \ 22 22 message_manager.cc \ 23 23 network_log.cc \ … … 25 25 player_stats.cc \ 26 26 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 \ 27 33 \ 28 34 synchronizeable_var/synchronizeable_var.cc \ … … 33 39 synchronizeable_var/synchronizeable_float.cc \ 34 40 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 36 45 37 46 38 47 39 48 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 49 noinst_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 10 10 11 11 ### 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) 14 14 */ 15 15 … … 30 30 31 31 /* using namespace std is default, this needs to be here */ 32 using namespace std; 32 33 33 34 34 /*! … … 38 38 { 39 39 /* set the class id for the base object */ 40 //this->setClassID(CL_ENTITY_MANAGER, "EntityManager");41 40 } 42 41 -
trunk/src/lib/network/data_stream.cc
r8623 r9406 19 19 20 20 /* using namespace std is default, this needs to be here */ 21 using namespace std; 21 22 22 23 23 -
trunk/src/lib/network/handshake.cc
r9235 r9406 10 10 11 11 ### File Specific: 12 main-programmer: christoph13 co-programmer: 12 main-programmer: Christoph Renner (rennerc@ee.ethz.ch) 13 co-programmer: Patirck Boenzli (boenzlip@orxonox.ethz.ch) 14 14 */ 15 15 16 16 17 /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module18 For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput19 */20 17 #define DEBUG_MODULE_NETWORK 21 18 … … 25 22 #include "debug.h" 26 23 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 ) 28 29 : Synchronizeable() 29 30 { … … 31 32 this->setClassID(CL_HANDSHAKE, "Handshake"); 32 33 33 this->setIsServer(server);34 34 35 // register all variable handlers 35 36 orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) ); 36 37 version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) ); … … 42 43 errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) ); 43 44 45 this->nodeTypeHandler = registerVarId( new SynchronizeableInt( &localState.nodeType, &remoteState.nodeType, "nodeType", PERMISSION_ALL ) ); 46 44 47 candel_id = registerVarId( new SynchronizeableInt( &localState.canDel, &remoteState.canDel, "canDel", PERMISSION_ALL ) ); 45 48 46 49 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 ) ); 47 54 55 56 // init the local state 48 57 localState.completed = 0; 49 58 localState.error = 0; … … 54 63 localState.orxId = _ORXONOX_ID; 55 64 localState.version = _ORXONOX_VERSION; 65 localState.nodeType = nodeType; 56 66 localState.canDel = 0; 57 67 68 69 // init the remote state 58 70 remoteState.completed = 0; 59 71 remoteState.error = 0; … … 64 76 remoteState.orxId = 0; 65 77 remoteState.version = 0; 78 remoteState.nodeType = NET_CLIENT; 66 79 remoteState.canDel = 0; 67 80 81 82 this->proxy1 = IP(0, 0); 83 this->proxy2 = IP(0, 0); 84 this->redirectProxy = 0; 85 86 87 // activate the synchronization process 68 88 this->setSynchronized(true); 69 89 PRINTF(0)("Handshake created clientId = %d\n", clientId); 70 90 } 91 71 92 72 93 /** … … 78 99 for ( std::list<int>::iterator it = id.begin(); it != id.end(); it++ ) 79 100 { 80 if ( *it == orxId_handler ) 101 // orxonox id handler 102 if ( *it == this->orxId_handler ) 81 103 { 82 104 if ( remoteState.orxId != _ORXONOX_ID ) … … 87 109 continue; 88 110 } 89 90 111 } 91 112 92 if ( *it == version_handler ) 113 // orxonox version handler 114 if ( *it == this->version_handler ) 93 115 { 94 116 if ( remoteState.version != _ORXONOX_VERSION ) … … 99 121 continue; 100 122 } 101 102 123 } 103 124 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 104 143 if ( *it == candel_id ) 105 144 { 106 145 PRINTF(0)("handshake finished candel changed\n"); 107 146 } 108 109 147 } 110 148 111 if (112 113 remoteState.version == _ORXONOX_VERSION114 )149 // handshake completed 150 if ( remoteState.orxId == _ORXONOX_ID && 151 remoteState.version == _ORXONOX_VERSION ) 152 { 115 153 localState.completed = 1; 154 } 116 155 } 117 156 -
trunk/src/lib/network/handshake.h
r9235 r9406 1 1 /*! 2 2 * @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! 4 8 */ 5 9 … … 8 12 9 13 #include "base_object.h" 14 #include "ip.h" 10 15 #include "synchronizeable.h" 16 #include "shared_network_data.h" 11 17 12 #define _ORXONOX_ID 0xF91337A0 18 //!< a struct to save the handshakes to 19 struct HandshakeState 20 { 21 int orxId; //!< orxonox id 22 int version; //!< network protocol version 13 23 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 15 28 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 31 36 //additional data 32 std::string preferedNickName;37 std::string preferedNickName; //!< prefered nick name 33 38 }; 34 39 40 41 //!< the handshake itself with some interface functions 35 42 class Handshake : public Synchronizeable 36 43 { 44 37 45 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 */ 50 77 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 */ 52 95 virtual void varChangeHandler( std::list<int> & id ); 53 96 97 54 98 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 67 101 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) 68 120 }; 69 121 -
trunk/src/lib/network/message_manager.cc
r9059 r9406 20 20 #include "network_stream.h" 21 21 #include "shared_network_data.h" 22 23 using namespace std; 22 #include "converter.h" 23 #include <cassert> 24 25 24 26 25 27 MessageManager* MessageManager::singletonRef = NULL; … … 52 54 } 53 55 } 54 56 55 57 it->second.messages.clear(); 56 58 it->second.toAck.clear(); 57 59 } 58 60 59 61 messageQueue.clear(); 60 62 61 63 this->messageHandlerMap.clear(); 62 64 63 65 MessageManager::singletonRef = NULL; 64 66 } … … 82 84 int i = 0; 83 85 int n; 84 86 85 87 n = Converter::intToByteArray( messageQueue[userId].toAck.size(), data + i, maxLength ); 86 88 i += n; 87 89 assert( n == INTSIZE ); 88 90 89 91 for ( std::list<int>::iterator it = messageQueue[userId].toAck.begin(); it != messageQueue[userId].toAck.end(); it++) 90 92 { … … 93 95 assert( n == INTSIZE ); 94 96 } 95 97 96 98 messageQueue[userId].toAck.clear(); 97 99 98 100 n = Converter::intToByteArray( messageQueue[userId].messages.size(), data + i, maxLength ); 99 101 i += n; 100 102 assert( n == INTSIZE ); 101 103 102 104 for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ ) 103 105 { … … 105 107 i += n; 106 108 assert( n == INTSIZE ); 107 109 108 110 n = Converter::intToByteArray( it->number, data + i, maxLength ); 109 111 i += n; 110 112 assert( n == INTSIZE ); 111 113 112 114 n = Converter::intToByteArray( it->messageId, data + i, maxLength ); 113 115 i += n; 114 116 assert( n == INTSIZE ); 115 117 116 118 assert( i + it->length <= maxLength ); 117 119 memcpy( data + i, it->data, it->length ); 118 120 i += it->length; 119 121 } 120 122 121 123 return i; 122 124 } … … 136 138 int i = 0; 137 139 int n; 138 140 139 141 int nAcks; 140 142 141 143 assert( i + INTSIZE <= length ); 142 144 n = Converter::byteArrayToInt( data + i, &nAcks ); 143 145 assert( n == INTSIZE ); 144 146 i += n; 145 147 146 148 std::list<int> acks; 147 149 148 150 int number; 149 151 150 152 for ( int j = 0; j < nAcks; j++ ) 151 153 { … … 154 156 assert( n == INTSIZE ); 155 157 i += n; 156 158 157 159 acks.push_back( number ); 158 160 } 159 161 160 162 int nMessages; 161 163 162 164 assert( i + INTSIZE <= length ); 163 165 n = Converter::byteArrayToInt( data + i, &nMessages ); … … 166 168 167 169 int messageLength, messageId; 168 170 169 171 for ( int j = 0; j < nMessages; j++ ) 170 172 { … … 173 175 assert( n == INTSIZE ); 174 176 i += n; 175 177 176 178 assert( i + INTSIZE <= length ); 177 179 n = Converter::byteArrayToInt( data + i, &number ); 178 180 assert( n == INTSIZE ); 179 181 i += n; 180 182 181 183 assert( i + INTSIZE <= length ); 182 184 n = Converter::byteArrayToInt( data + i, &messageId ); 183 185 assert( n == INTSIZE ); 184 186 i += n; 185 187 186 188 if ( number > 0 ) 187 189 messageQueue[userId].toAck.push_back( number ); 188 190 189 191 assert( i + messageLength <= length ); 190 192 assert( messageHandlerMap.find( (MessageId)messageId ) != messageHandlerMap.end() ); … … 194 196 { 195 197 NetworkMessage msg; 196 198 197 199 msg.data = new byte[messageLength]; 198 200 memcpy( msg.data, data + i, messageLength ); … … 200 202 msg.messageId = (MessageId)messageId; 201 203 msg.number = userId; 202 204 203 205 incomingMessageBuffer.push_back( msg ); 204 206 } … … 207 209 i += messageLength; 208 210 } 209 210 211 212 211 213 //TODO maybe handle incomingMessage in tick function. else local messages will not be handled if no clients are connected 212 214 for ( std::list<NetworkMessage>::iterator it = incomingMessageBuffer.begin(); it != incomingMessageBuffer.end(); ) … … 223 225 it++; 224 226 } 225 227 226 228 //walk throu message queue and remove acked messages 227 229 for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); ) … … 236 238 it++; 237 239 } 238 240 239 241 //TODO find bether way. maybe with timestamp 240 242 if ( messageQueue[userId].recievedMessages.size() > 1000 ) … … 255 257 if ( messageQueue.find( userId ) == messageQueue.end() ) 256 258 return; 257 259 258 260 for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ ) 259 261 { … … 262 264 it->data = NULL; 263 265 } 264 266 265 267 messageQueue[userId].toAck.clear(); 266 268 267 269 messageQueue.erase( userId ); 268 270 } … … 270 272 /** 271 273 * 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 273 275 * @param cb function pointer to callback function 274 276 * @param someData this pointer is passed to callback function without modification … … 278 280 { 279 281 MessageHandler messageHandler; 280 282 281 283 messageHandler.cb = cb; 282 284 messageHandler.messageId = messageId; 283 285 messageHandler.someData = someData; 284 286 285 287 messageHandlerMap[messageId] = messageHandler; 286 288 287 289 return true; 288 290 } … … 309 311 * @param data pointer to data 310 312 * @param dataLength length of data 311 * @param recieverType 312 * @param reciever 313 * @param recieverType 314 * @param reciever 313 315 */ 314 316 void MessageManager::sendMessage( MessageId messageId, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority ) … … 316 318 for ( MessageQueue::iterator it = messageQueue.begin(); it != messageQueue.end(); it++ ) 317 319 { 318 if ( 320 if ( 319 321 recieverType == RT_ALL_ME || 320 322 recieverType == RT_ALL_NOT_ME || 321 323 recieverType == RT_USER && it->first == reciever || 322 324 recieverType == RT_NOT_USER && it->first != reciever || 323 recieverType == RT_SERVER && getNetworkStream()->isUser Server( it->first )325 recieverType == RT_SERVER && getNetworkStream()->isUserMasterServer( it->first ) 324 326 ) 325 327 { … … 336 338 } 337 339 } 338 340 339 341 if ( recieverType == RT_ALL_ME ) 340 342 { -
trunk/src/lib/network/netdefs.h
r9246 r9406 1 /* 2 orxonox - the future of 3D-vertical-scrollers 1 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. 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 */ 2 18 3 19 /*! 4 20 * @file network_manager.h 5 21 * Main interface for the network module. Manages all the modules 6 7 22 */ 8 23 9 #ifndef _NETDEFS 10 #define _NETDEFS 24 #ifndef _NETDEFS_H 25 #define _NETDEFS_H 11 26 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" 17 29 18 30 19 #define MAX_CONNECTIONS 100020 31 32 //!< the amount of slots used before a proxy server is activated 33 #define NET_CONNECTION_SATURATION 0.75 34 35 //!< network polling frequency 21 36 #define NETWORK_FREQUENCY 66 22 37 23 38 24 typedef unsigned char byte; 39 //!< orxonox protocol id 40 #define _ORXONOX_ID 0xF91337A0 41 //!< orxonox network version identifier 42 #define _ORXONOX_VERSION 1 25 43 26 44 27 45 //!< enum indicating the type of the node 28 46 typedef 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 31 54 } NodeType; 32 55 … … 44 67 } UidType; 45 68 46 #endif /* _NET WORK_MANAGER*/69 #endif /* _NETDEFS_H */ -
trunk/src/lib/network/network_game_manager.cc
r9235 r9406 10 10 11 11 ### 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) 14 17 */ 15 18 16 19 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 20 21 #define DEBUG_MODULE_NETWORK 21 22 … … 45 46 46 47 47 /* using namespace std is default, this needs to be here */ 48 using namespace std; 48 49 49 50 50 NetworkGameManager* NetworkGameManager::singletonRef = NULL; … … 62 62 63 63 this->setSynchronized(true); 64 64 65 65 MessageManager::getInstance()->registerMessageHandler( MSGID_DELETESYNCHRONIZEABLE, delSynchronizeableHandler, NULL ); 66 66 MessageManager::getInstance()->registerMessageHandler( MSGID_PREFEREDTEAM, preferedTeamHandler, NULL ); 67 67 MessageManager::getInstance()->registerMessageHandler( MSGID_CHATMESSAGE, chatMessageHandler, NULL ); 68 68 69 69 this->gameState = 0; 70 70 registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) ); … … 77 77 { 78 78 delete MessageManager::getInstance(); 79 79 80 80 PlayerStats::deleteAllPlayerStats(); 81 81 82 82 NetworkGameManager::singletonRef = NULL; 83 83 } … … 86 86 /** 87 87 * insert new player into game 88 * @param userId 89 * @return 88 * @param userId 89 * @return 90 90 */ 91 91 bool NetworkGameManager::signalNewPlayer( int userId ) 92 92 { 93 assert( SharedNetworkData::getInstance()->is GameServer());93 assert( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()); 94 94 assert( State::getGameRules() ); 95 95 assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) ); 96 96 97 97 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); 98 98 99 99 int team = rules.getTeamForNewUser(); 100 100 ClassID playableClassId = rules.getPlayableClassId( userId, team ); … … 102 102 std::string playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId ); 103 103 float playableScale = rules.getPlayableScale( userId, team, playableClassId ); 104 104 105 105 BaseObject * bo = Factory::fabricate( playableClassId ); 106 106 107 107 assert( bo != NULL ); 108 108 assert( bo->isA( CL_PLAYABLE ) ); 109 109 110 110 Playable & playable = *(dynamic_cast<Playable*>(bo)); 111 111 112 112 playable.loadMD2Texture( playableTexture ); 113 113 114 114 playable.loadModel( playableModel, 100.0f ); 115 115 playable.setOwner( userId ); 116 116 playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 117 117 playable.setSynchronized( true ); 118 118 119 119 PlayerStats * stats = rules.getNewPlayerStats( userId ); 120 120 121 121 stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 122 122 stats->setSynchronized( true ); 123 123 stats->setOwner( SharedNetworkData::getInstance()->getHostID() ); 124 124 125 125 stats->setTeamId( team ); 126 126 stats->setPlayableClassId( playableClassId ); 127 127 stats->setPlayableUniqueId( playable.getUniqueID() ); 128 128 stats->setModelFileName( playableModel ); 129 129 130 130 if ( userId == 0 ) 131 131 stats->setNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Server" ) ); 132 132 133 133 if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH ) ) 134 134 dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f ); 135 135 136 136 return true; 137 137 } … … 140 140 /** 141 141 * remove player from game 142 * @param userID 143 * @return 142 * @param userID 143 * @return 144 144 */ 145 145 bool NetworkGameManager::signalLeftPlayer(int userID) … … 151 151 delete PlayerStats::getStats( userID ); 152 152 } 153 153 154 154 return true; 155 155 } … … 159 159 /** 160 160 * 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 166 166 * @return true on successfull handling else handler will be called again 167 167 */ 168 168 bool NetworkGameManager::delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 169 169 { 170 if ( getInstance()->isServer())170 if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) 171 171 { 172 172 PRINTF(2)("Recieved DeleteSynchronizeable message from client %d!\n", userId); 173 173 return true; 174 174 } 175 175 176 176 int uniqueId = 0; 177 177 int len = Converter::byteArrayToInt( data, &uniqueId ); 178 178 179 179 if ( len != dataLength ) 180 180 { … … 182 182 return true; 183 183 } 184 184 185 185 const std::list<BaseObject*> * list = ClassList::getList( CL_SYNCHRONIZEABLE ); 186 186 187 187 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 188 188 { … … 194 194 return true; 195 195 } 196 196 197 197 delete dynamic_cast<Synchronizeable*>(*it); 198 198 return true; 199 199 } 200 200 } 201 201 202 202 return true; 203 203 } … … 210 210 { 211 211 byte buf[INTSIZE]; 212 212 213 213 assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE ); 214 214 … … 220 220 /** 221 221 * 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 228 228 */ 229 229 bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 230 230 { 231 assert( NetworkGameManager::getInstance()->isServer());232 231 assert( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()); 232 233 233 int teamId = 0; 234 234 int len = Converter::byteArrayToInt( data, &teamId ); 235 235 236 236 if ( len != dataLength ) 237 237 { … … 239 239 return true; 240 240 } 241 241 242 242 NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId ); 243 243 244 244 return true; 245 245 } … … 249 249 if ( !PlayerStats::getStats( userId ) ) 250 250 return; 251 251 252 252 PlayerStats & stats = *(PlayerStats::getStats( userId )); 253 253 254 254 stats.setPreferedTeamId( teamId ); 255 255 } … … 257 257 /** 258 258 * set prefered team for this host 259 * @param teamId 259 * @param teamId 260 260 */ 261 261 void NetworkGameManager::prefereTeam( int teamId ) 262 262 { 263 if ( isServer())263 if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) 264 264 setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId ); 265 265 else 266 266 { 267 267 byte buf[INTSIZE]; 268 268 269 269 assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE ); 270 270 271 271 MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH ); 272 272 } … … 285 285 { 286 286 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 287 287 288 288 if ( list && std::find( list->begin(), list->end(), *it ) != list->end() ) 289 { 290 PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClass Name(), (*it)->getOwner() );289 { 290 PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassCName(), (*it)->getOwner() ); 291 291 std::list<Playable*>::iterator delit = it; 292 292 it++; … … 305 305 { 306 306 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() ) 308 308 { 309 309 MessageManager::getInstance()->sendMessage( messageId, data, dataLength, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 310 310 } 311 311 312 312 assert( State::getGameRules() ); 313 313 assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) ); 314 314 315 315 NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules())); 316 316 317 317 if ( dataLength < 3*INTSIZE ) 318 318 { 319 319 PRINTF(2)("got too small chatmessage from client %d\n", userId); 320 320 321 321 return true; 322 322 } 323 323 324 324 int messageType = 0; 325 325 Converter::byteArrayToInt( data, &messageType ); … … 328 328 std::string message; 329 329 Converter::byteArrayToString( data+2*INTSIZE, message, dataLength-2*INTSIZE ); 330 330 331 331 rules.handleChatMessage( senderUserId, message, messageType ); 332 332 … … 346 346 assert( Converter::intToByteArray( SharedNetworkData::getInstance()->getHostID(), buf+INTSIZE, INTSIZE ) == INTSIZE ); 347 347 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()) 350 350 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_ME, 0, MP_HIGHBANDWIDTH ); 351 351 else 352 352 MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 353 353 354 354 355 355 delete [] buf; 356 356 } -
trunk/src/lib/network/network_game_manager.h
r8708 r9406 28 28 NET_YOU_ARE_ENTITY, 29 29 NET_REQUEST_ENTITY_LIST, 30 NET_REQUEST_PNODE_PATH,31 NET_SEND_PNODE_PATH,32 30 33 31 NET_NUMBER … … 42 40 43 41 /*! 44 * a class that can create and remove entities 42 * a class that can create and remove entities over the network 45 43 */ 46 44 class NetworkGameManager: public Synchronizeable 47 45 { 46 48 47 public: 49 48 virtual ~NetworkGameManager(); 50 49 51 50 static NetworkGameManager* NetworkGameManager::getInstance() 52 51 { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; } … … 55 54 bool signalNewPlayer( int userId ); 56 55 bool signalLeftPlayer( int userID ); 57 58 void removeSynchronizeable( int uniqueId ); 59 56 60 57 void prefereTeam( int teamId ); 58 61 59 62 60 inline void setGameState( int gameState ){ this->gameState = gameState; } 63 61 inline int getGameState(){ return this->gameState; } 64 62 65 63 void tick( float ds ); 66 64 65 void removeSynchronizeable( int uniqueId ); 67 66 void sendChatMessage( const std::string & message, int messageType ); 67 68 68 69 69 private: 70 70 NetworkGameManager(); 71 71 72 72 static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 73 73 static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 74 74 static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 75 75 76 76 void setPreferedTeam( int userId, int teamId ); 77 77 78 79 private: 78 80 static NetworkGameManager* singletonRef; 79 81 80 82 int gameState; 81 83 82 84 std::list<Playable*> playablesToDelete; 83 85 }; -
trunk/src/lib/network/network_manager.cc
r9059 r9406 10 10 11 11 ### 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) 14 14 */ 15 15 … … 34 34 35 35 /* using namespace std is default, this needs to be here */ 36 using namespace std; 36 37 37 38 38 SHELL_COMMAND(debug, NetworkManager, debug); … … 53 53 this->networkStream = NULL; 54 54 this->elapsedTime = 0.0f; 55 56 55 56 57 57 int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 ); 58 58 59 59 if ( port > 0 ) 60 60 NetworkLog::getInstance()->listen( port ); … … 75 75 this->networkStream = NULL; 76 76 } 77 77 78 78 NetworkManager::singletonRef = NULL; 79 79 } … … 95 95 { 96 96 97 } 98 99 100 101 /** 102 * creates a new NetworkStream of server type 103 * @param port: number of the TCP port 104 */ 105 int 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 */ 126 int 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; 97 147 } 98 148 … … 102 152 * @param hostName: the name of the destination host 103 153 */ 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); 154 int 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 108 165 this->networkStream->startHandshake(); 166 167 PRINTF(0)("Created Network Client"); 109 168 return 1; 110 169 } … … 112 171 113 172 /** 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 */ 130 176 void NetworkManager::connectSynchronizeable(Synchronizeable& sync) 131 177 { … … 144 190 if( likely(this->elapsedTime < 1.0f / NETWORK_FREQUENCY)) 145 191 return; 192 146 193 this->elapsedTime = 0.0f; 147 194 148 if ( networkStream )195 if ( this->networkStream ) 149 196 networkStream->processData(); 150 197 151 198 NetworkGameManager::getInstance()->tick( this->elapsedTime ); 152 199 } -
trunk/src/lib/network/network_manager.h
r9059 r9406 36 36 void shutdown(); 37 37 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); 45 41 46 42 void connectSynchronizeable(Synchronizeable& sync); … … 56 52 private: 57 53 static NetworkManager* singletonRef; //!< Pointer to the only instance of this Class 58 NetworkStream* networkStream; //!< pointer to network stream54 NetworkStream* networkStream; //!< pointer to network stream 59 55 60 56 float elapsedTime; //!< elapsed time since the last network update -
trunk/src/lib/network/network_protocol.cc
r6341 r9406 33 33 34 34 /* using namespace std is default, this needs to be here */ 35 using namespace std; 35 36 36 37 37 -
trunk/src/lib/network/network_socket.cc
r7954 r9406 33 33 { 34 34 bOk = true; 35 this->ip.host = 0; 36 this->ip.port = 0; 35 37 } 36 38 -
trunk/src/lib/network/network_socket.h
r7954 r9406 27 27 */ 28 28 virtual void connectToServer( std::string host, int port ) = 0; 29 29 30 30 /** 31 31 * disconnect from server 32 32 */ 33 33 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; 34 44 35 45 /** … … 40 50 */ 41 51 virtual bool writePacket(byte * data, int length) = 0; 42 52 43 53 /** 44 54 * read a packet sent by another NetworkSocket … … 54 64 */ 55 65 inline bool isOk() { return this->bOk; } 56 66 67 /** @returns the ip adderess of the destination socket */ 68 IPaddress getRemoteAddress() { return ip; } 69 70 57 71 protected: 58 bool bOk; //!< check for socket status72 bool bOk; //!< check for socket status 59 73 74 IPaddress ip; //!< host,port 60 75 }; 61 76 -
trunk/src/lib/network/network_stream.cc
r9246 r9406 12 12 main-programmer: Christoph Renner rennerc@ee.ethz.ch 13 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) 14 17 */ 15 18 … … 22 25 #include "udp_socket.h" 23 26 #include "udp_server_socket.h" 24 #include "connection_monitor.h" 27 #include "monitor/connection_monitor.h" 28 #include "monitor/network_monitor.h" 25 29 #include "synchronizeable.h" 30 #include "ip.h" 26 31 #include "network_game_manager.h" 27 32 #include "shared_network_data.h" … … 42 47 #include <algorithm> 43 48 44 /* include your own header */ 49 45 50 #include "network_stream.h" 46 51 47 /* probably unnecessary */ 48 using namespace std; 52 53 #include "converter.h" 49 54 50 55 … … 52 57 53 58 59 /** 60 * empty constructor 61 */ 54 62 NetworkStream::NetworkStream() 55 63 : DataStream() … … 57 65 this->init(); 58 66 /* 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 71 NetworkStream::NetworkStream( int nodeType) 72 { 71 73 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 90 108 91 109 … … 97 115 /* set the class id for the base object */ 98 116 this->setClassID(CL_NETWORK_STREAM, "NetworkStream"); 99 this->bActive = false;100 117 this->serverSocket = NULL; 101 118 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; 104 128 105 129 remainingBytesToWriteToDict = Preferences::getInstance()->getInt( "compression", "writedict", 0 ); … … 147 171 for ( SynchronizeableList::const_iterator it = getSyncBegin(); it != getSyncEnd(); it ++ ) 148 172 (*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 */ 187 void 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 */ 204 void 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 */ 220 void NetworkStream::createServer(int port) 221 { 222 this->serverSocket = new UdpServerSocket(port); 149 223 } 150 224 … … 156 230 { 157 231 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 160 233 this->networkGameManager->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 161 234 MessageManager::getInstance()->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); … … 165 238 /** 166 239 * 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 167 242 */ 168 243 void NetworkStream::startHandshake() 169 244 { 170 Handshake* hs = new Handshake( false);245 Handshake* hs = new Handshake(this->pInfo->nodeType); 171 246 hs->setUniqueID( 0 ); 172 247 assert( peers[0].handshake == NULL ); 173 248 peers[0].handshake = hs; 174 249 250 // set the preferred nick name 175 251 hs->setPreferedNickName( Preferences::getInstance()->getString( "multiplayer", "nickname", "Player" ) ); 176 252 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()); 181 254 } 182 255 … … 192 265 sync.setNetworkStream( this ); 193 266 194 this->bActive = true;267 // this->bActive = true; 195 268 } 196 269 … … 215 288 void NetworkStream::processData() 216 289 { 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 217 295 int tick = SDL_GetTicks(); 218 296 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 223 315 if ( serverSocket ) 224 316 serverSocket->update(); … … 249 341 cleanUpOldSyncList(); 250 342 handleHandshakes(); 343 344 // update the network monitor 345 this->networkMonitor->process(); 251 346 252 347 // order of up/downstream is important!!!! … … 258 353 259 354 /** 260 * if we are a server update the connection list to accept new connections (clients)261 * also start the handsake for the new clients355 * 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 262 357 */ 263 358 void NetworkStream::updateConnectionList( ) … … 276 371 clientId = freeSocketSlots.back(); 277 372 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;284 373 } 285 374 else … … 290 379 if ( it->first >= clientId ) 291 380 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 315 428 } 316 429 … … 339 452 it->second.socket = NULL; 340 453 454 // remove the old connectin monitor 341 455 if ( it->second.connectionMonitor ) 342 456 delete it->second.connectionMonitor; 343 457 it->second.connectionMonitor = NULL; 344 458 459 // remove the handshake 345 460 if ( it->second.handshake ) 346 461 delete it->second.handshake; 347 462 it->second.handshake = NULL; 348 463 464 // and cleanup the user infos 349 465 for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ ) 350 466 { … … 373 489 void NetworkStream::debug() 374 490 { 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 } 379 500 380 501 PRINT(0)(" Got %i connected Synchronizeables, showing active Syncs:\n", this->synchronizeables.size()); … … 382 503 { 383 504 if( (*it)->beSynchronized() == true) 384 PRINT(0)(" Synchronizeable of class: %s::%s, with unique ID: %i, Synchronize: %i\n", (*it)->getClass Name(), (*it)->getName(),505 PRINT(0)(" Synchronizeable of class: %s::%s, with unique ID: %i, Synchronize: %i\n", (*it)->getClassCName(), (*it)->getCName(), 385 506 (*it)->getUniqueID(), (*it)->beSynchronized()); 386 507 } 387 PRINT(0)(" Maximal Connections: %i\n", MAX_CONNECTIONS);508 PRINT(0)(" Maximal Connections: %i\n", SharedNetworkData::getInstance()->getMaxPlayer() ); 388 509 389 510 } … … 414 535 if ( it->second.handshake ) 415 536 { 537 // handshake finished 416 538 if ( it->second.handshake->completed() ) 417 539 { 540 //handshake is correct 418 541 if ( it->second.handshake->ok() ) 419 542 { 543 // the server gave it free for deletion 420 544 if ( !it->second.handshake->allowDel() ) 421 545 { 422 if ( type != NET_SERVER ) 546 547 if ( this->pInfo->isClient() ) 423 548 { 424 549 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 427 566 this->networkGameManager = NetworkGameManager::getInstance(); 428 567 this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() ); 568 // init the new message manager 429 569 MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() ); 430 570 } … … 432 572 433 573 PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId()); 434 435 574 it->second.handshake->del(); 436 575 } 437 576 else 438 577 { 578 // handshake finished registring new player 439 579 if ( it->second.handshake->canDel() ) 440 580 { 441 if ( type == NET_SERVER ) 581 582 if ( this->pInfo->isMasterServer() ) 442 583 { 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 ); 444 604 445 605 if ( PlayerStats::getStats( it->second.userId ) && it->second.handshake->getPreferedNickName() != "" ) … … 468 628 469 629 /** 630 * this functions handles a reconnect event received from the a NET_MASTER_SERVER or NET_PROXY_SERVER 631 */ 632 void 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 /** 470 661 * handle upstream network traffic 471 662 */ … … 501 692 for ( SynchronizeableList::iterator it = synchronizeables.begin(); it != synchronizeables.end(); it++ ) 502 693 { 694 503 695 int oldOffset = offset; 504 696 Synchronizeable & sync = **it; 697 505 698 506 699 // do not include synchronizeables with uninit id and syncs that don't want to be synchronized … … 512 705 continue; 513 706 514 // if we are a server and this is not our handshake515 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 ) 516 709 continue; 517 710 … … 521 714 continue; 522 715 716 717 assert( sync.getLeafClassID() != 0); 718 523 719 assert( offset + INTSIZE <= UDP_PACKET_SIZE ); 524 720 525 721 // 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 527 724 n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset ); 528 725 else 529 726 n = Converter::intToByteArray( sync.getUniqueID(), buf + offset, UDP_PACKET_SIZE - offset ); 530 727 728 531 729 assert( n == INTSIZE ); 532 730 offset += n; 533 731 534 // make space for size732 // make space for packet size 535 733 offset += INTSIZE; 536 734 … … 573 771 // now compress the data with the zip library 574 772 int compLength = 0; 575 if ( this->isServer())773 if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) 576 774 compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictServer ); 577 775 else … … 637 835 assert( Converter::byteArrayToInt( buf + 2*INTSIZE, &fromState ) == INTSIZE ); 638 836 assert( Converter::byteArrayToInt( buf + 3*INTSIZE, &ackedState ) == INTSIZE ); 639 //NETPRINTF(n)("ackedstate: %d\n", ackedState);640 837 offset = 4*INTSIZE; 641 838 642 839 peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, packetLength, state, ackedState ); 643 840 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 647 843 if ( state <= peer->second.lastRecvedState ) 648 844 continue; … … 655 851 } 656 852 657 while ( offset + 2 *INTSIZE < length )853 while ( offset + 2 * INTSIZE < length ) 658 854 { 659 855 assert( offset > 0 ); … … 669 865 Synchronizeable * sync = NULL; 670 866 867 // look for the synchronizeable in question 671 868 for ( SynchronizeableList::iterator it = synchronizeables.begin(); it != synchronizeables.end(); it++ ) 672 869 { 673 //client thinks his handshake has id 0!!!!!870 // client thinks his handshake has id 0!!!!! 674 871 if ( (*it)->getUniqueID() == uniqueId || ( uniqueId == 0 && (*it)->getUniqueID() == peer->second.userId ) ) 675 872 { … … 679 876 } 680 877 878 // this synchronizeable does not yet exist! create it 681 879 if ( sync == NULL ) 682 880 { 683 881 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 684 884 if ( oldSynchronizeables.find( uniqueId ) != oldSynchronizeables.end() ) 685 885 { … … 688 888 } 689 889 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() ) 691 892 { 692 893 offset += syncDataLength; … … 705 906 assert( leafClassId != 0 ); 706 907 908 707 909 BaseObject * b = NULL; 708 910 /* These are some small exeptions in creation: Not all objects can/should be created via Factory */ … … 710 912 if( leafClassId == CL_NULL_PARENT || leafClassId == CL_SYNCHRONIZEABLE || leafClassId == CL_NETWORK_GAME_MANAGER ) 711 913 { 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); 713 915 offset += syncDataLength; 714 916 continue; … … 730 932 sync->setSynchronized(true); 731 933 732 PRINTF(0)("Fabricated %s with id %d\n", sync->getClass Name(), sync->getUniqueID());934 PRINTF(0)("Fabricated %s with id %d\n", sync->getClassCName(), sync->getUniqueID()); 733 935 } 734 936 else … … 744 946 int n = sync->setStateDiff( peer->second.userId, buf+offset, syncDataLength, state, fromState ); 745 947 offset += n; 746 //NETPRINTF(0)("SSSSSEEEEETTTTT: %s %d\n",sync->getClassName(), n);747 948 748 949 } … … 779 980 /** 780 981 * is executed when a handshake has finished 781 * @todo create playable for new user782 982 */ 783 983 void NetworkStream::handleNewClient( int userId ) 784 984 { 985 // init and assign the message manager 785 986 MessageManager::getInstance()->initUser( userId ); 786 987 // do all game relevant stuff here 787 988 networkGameManager->signalNewPlayer( userId ); 788 989 } 990 789 991 790 992 /** -
trunk/src/lib/network/network_stream.h
r9246 r9406 14 14 #include "server_socket.h" 15 15 #include "handshake.h" 16 #include " connection_monitor.h"16 #include "monitor/connection_monitor.h" 17 17 #include "udp_server_socket.h" 18 #include "peer_info.h" 19 20 #include "shared_network_data.h" 18 21 19 22 class Synchronizeable; … … 21 24 class ServerSocket; 22 25 class NetworkGameManager; 26 class NetworkMonitor; 23 27 24 //!< this structure contains informations about the network node25 class PeerInfo26 {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 };41 28 42 29 typedef std::list<Synchronizeable*> SynchronizeableList; … … 49 36 public: 50 37 NetworkStream(); 51 NetworkStream( std::string host, int port);52 NetworkStream( int port);38 NetworkStream(int nodeType); 39 virtual ~NetworkStream(); 53 40 54 virtual ~NetworkStream();55 41 void init(); 42 43 void connectToMasterServer(std::string host, int port); 44 void connectToProxyServer(std::string host, int port); 45 void createServer(int port); 56 46 57 47 void createNetworkGameManager(); 58 48 void startHandshake(); 59 49 50 /* synchronizeable interface */ 60 51 void connectSynchronizeable(Synchronizeable& sync); 61 52 void disconnectSynchronizeable(Synchronizeable& sync); 62 53 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(); } 65 55 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(); } 67 61 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*/ 68 68 virtual void processData(); 69 70 /* debugging */ 71 void debug(); 72 73 74 private: 69 75 70 76 inline SynchronizeableList::const_iterator getSyncBegin(){ return synchronizeables.begin(); } 71 77 inline SynchronizeableList::const_iterator getSyncEnd(){ return synchronizeables.end(); } 78 void cleanUpOldSyncList(); 72 79 int getSyncCount(); 73 80 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:83 81 void updateConnectionList(); 82 /* handle processes */ 84 83 void handleHandshakes(); 85 84 void handleUpstream( int tick ); 86 85 void handleDownstream(int tick ); 86 87 /* handle events*/ 87 88 void handleNewClient( int userId ); 88 void cleanUpOldSyncList();89 void handleReconnect( int userId ); 89 90 90 91 void writeToNewDict( byte * data, int length, bool upstream ); … … 92 93 93 94 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 100 96 101 int myHostId;97 PeerInfo* pInfo; //!< the info about the local peer node (not in the PeerList) 102 98 99 std::list<int> freeSocketSlots; //!< list of free sockets (to ensure not to resycle sockets) 103 100 int currentState; //!< current state id 104 101 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 106 105 107 106 std::map<int,int> oldSynchronizeables; //!< used to save recently deleted sync ids to not recreate them 107 SynchronizeableList synchronizeables; //!< list of the synchronizeables 108 108 109 109 byte buf[UDP_PACKET_SIZE]; //!< used by handleUp/Downstream 110 110 byte compBuf[UDP_PACKET_SIZE]; //!< used by handleUp/Downstream 111 112 111 int remainingBytesToWriteToDict; //!< if > 0 NetworkStream will write packets to DATA/dicts/newdict 113 112 114 int dictServer;115 int dictClient;113 int dictServer; //!< the zip dict for the server 114 int dictClient; //!< the zip dict for the client 116 115 }; 117 116 #endif /* _NETWORK_STREAM */ -
trunk/src/lib/network/player_stats.cc
r9235 r9406 23 23 #include "shared_network_data.h" 24 24 25 #include "converter.h" 26 25 27 #include "preferences.h" 26 28 … … 38 40 { 39 41 init(); 40 42 41 43 this->userId = userId; 42 44 } … … 62 64 this->nickName = "Player"; 63 65 this->oldNickName = "Player"; 64 66 65 67 userId_handle = registerVarId( new SynchronizeableInt( &userId, &userId, "userId" ) ); 66 68 teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) ); … … 71 73 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) ); 72 74 nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName" ) ); 73 75 74 76 MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGENICKNAME, changeNickHandler, NULL ); 75 77 76 78 PRINTF(0)("PlayerStats created\n"); 77 79 } … … 96 98 { 97 99 this->setPlayableUniqueId( this->playableUniqueId ); 98 100 99 101 PRINTF(0)("uniqueID changed %d %d %d\n", userId, SharedNetworkData::getInstance()->getHostID(), getUniqueID()); 100 102 } 101 103 102 104 if ( std::find( id.begin(), id.end(), nickName_handler ) != id.end() ) 103 105 { … … 115 117 { 116 118 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 117 119 118 120 if ( !list ) 119 121 { 120 122 return NULL; 121 123 } 122 124 123 125 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 124 126 { … … 128 130 } 129 131 } 130 132 131 133 return NULL; 132 134 } … … 138 140 { 139 141 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 140 142 141 143 if ( !list ) 142 144 { … … 144 146 return; 145 147 } 146 148 147 149 this->playable = NULL; 148 150 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) … … 156 158 } 157 159 } 158 160 159 161 if ( this->playable && userId == SharedNetworkData::getInstance()->getHostID() ) 160 162 { 161 163 State::getPlayer()->setPlayable( this->playable ); 162 164 } 163 165 164 166 this->playableUniqueId = uniqueId; 165 167 } … … 173 175 if ( playable ) 174 176 return playable; 175 177 176 178 assert( playableUniqueId > 0 ); 177 179 178 180 setPlayableUniqueId( playableUniqueId ); 179 181 180 182 assert( playable ); 181 183 182 184 return playable; 183 185 } … … 189 191 void PlayerStats::setNickName( std::string nick ) 190 192 { 191 if ( SharedNetworkData::getInstance()->is GameServer() )193 if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() ) 192 194 { 193 195 this->nickName = nick; … … 199 201 { 200 202 byte * data = new byte[nick.length()+INTSIZE]; 201 203 202 204 assert( Converter::stringToByteArray( nick, data, nick.length()+INTSIZE) == nick.length()+INTSIZE ); 203 205 204 206 MessageManager::getInstance()->sendMessage( MSGID_CHANGENICKNAME, data, nick.length()+INTSIZE, RT_SERVER, 0, MP_HIGHBANDWIDTH ); 205 207 return; … … 211 213 std::string newNick; 212 214 int res = Converter::byteArrayToString( data, newNick, dataLength ); 213 215 214 216 if ( res != dataLength ) 215 217 { … … 217 219 newNick = "invalid"; 218 220 } 219 221 220 222 if ( PlayerStats::getStats( userId ) ) 221 223 PlayerStats::getStats( userId )->setNickName( newNick ); 222 224 223 225 return true; 224 226 } … … 228 230 if ( getStats( SharedNetworkData::getInstance()->getHostID() ) ) 229 231 getStats( SharedNetworkData::getInstance()->getHostID() )->setNickName( newNick ); 230 232 231 233 Preferences::getInstance()->setString( "multiplayer", "nickname", newNick ); 232 234 } … … 237 239 { 238 240 const std::list<BaseObject*> * list; 239 241 240 242 while ( (list = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() ) 241 243 delete *list->begin(); … … 247 249 { 248 250 ScoreList result; 249 251 250 252 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 251 253 252 254 if ( !list ) 253 255 { 254 256 return result; 255 257 } 256 258 257 259 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 258 260 { 259 261 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 260 262 261 263 TeamScoreList::iterator it = result[stats.getTeamId()].begin(); 262 264 263 265 while ( it != result[stats.getTeamId()].end() && stats.score > it->score ) 264 266 { 265 267 it++; 266 268 } 267 269 268 270 PlayerScore score; 269 271 score.name = stats.getNickName(); 270 272 score.score = stats.getScore(); 271 273 272 274 result[stats.getTeamId()].insert(it, score); 273 275 } 274 276 275 277 return result; 276 278 } -
trunk/src/lib/network/shared_network_data.cc
r9110 r9406 18 18 #include "shared_network_data.h" 19 19 #include "netdefs.h" 20 #include "state.h" 20 21 22 #include "debug.h" 21 23 22 using namespace std;23 24 24 25 … … 33 34 this->setClassID(CL_SHARED_NETWORK_DATA, "SharedNetworkData"); 34 35 36 this->nodeType = NET_CLIENT; 35 37 this->hostID = -1; 36 38 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; 39 43 } 40 44 -
trunk/src/lib/network/shared_network_data.h
r6695 r9406 8 8 9 9 #include "base_object.h" 10 #include "netdefs.h" 11 #include "proxy/network_settings.h" 10 12 13 //!< maximal connectinons for the server 14 #define NET_MAX_CONNECTIONS 2 11 15 12 16 class NetworkStream; 13 17 class Synchronizeable; 14 template<typename> 15 class tList; 18 16 19 17 20 /* and here is the class itsself*/ … … 25 28 26 29 /** @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; } 28 33 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; } 31 40 /** 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(); } 33 45 34 46 /** @returns the hostID of the node */ … … 49 61 private: 50 62 int newUniqueID; //!< next uniqueID 51 bool bGameServer; //!< true if it is a server 63 int nodeType; //!< saves the node type here 64 52 65 int hostID; //!< The Host-ID of the Manager 53 66 NetworkStream* defaultSyncStream; //!< default synchronize NetworkStream -
trunk/src/lib/network/synchronizeable.cc
r9110 r9406 11 11 12 12 ### File Specific: 13 main-programmer: Silvan Nellen14 co-programmer: Benjamin Wuest13 main-programmer: Christoph Renner (rennerc@ee.ethz.ch) 14 co-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch) 15 15 */ 16 16 … … 29 29 #include "synchronizeable.h" 30 30 31 #include "converter.h" 32 31 33 32 34 … … 38 40 this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable"); 39 41 this->owner = 0; 40 this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0);42 // this->setIsServer(SharedNetworkData::getInstance()->getHostID() == 0); 41 43 this->uniqueID = NET_UID_UNASSIGNED; 42 44 this->networkStream = NULL; 43 45 this->bSynchronize = false; 44 46 45 47 if( State::isOnline()) 46 48 { … … 54 56 assert( syncVarList.size() == 0 ); 55 57 mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) ); 56 58 57 59 this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) ); 58 60 this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) ); … … 69 71 { 70 72 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 ) ) 73 76 NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() ); 74 77 } 75 78 76 79 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) 77 80 { … … 79 82 } 80 83 syncVarList.clear(); 81 84 82 85 for ( UserStateHistory::iterator it = recvStates.begin(); it != recvStates.end(); it++ ) 83 86 { … … 93 96 94 97 } 95 98 96 99 for ( UserStateHistory::iterator it = sentStates.begin(); it != sentStates.end(); it++ ) 97 100 { … … 105 108 delete *it2; 106 109 } 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 */ 135 125 int Synchronizeable::getStateDiff( int userId, byte* data, int maxLength, int stateId, int fromStateId, int priorityTH ) 136 126 { … … 169 159 (*it2)->data = NULL; 170 160 } 171 161 172 162 delete *it2; 173 163 } … … 181 171 while ( it != sentStates[userId].end() && (*it)->stateId != fromStateId ) 182 172 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 // }188 173 189 174 if ( it == sentStates[userId].end() ) … … 196 181 197 182 stateFrom = initialEntry; 198 183 199 184 sentStates[userId].push_back( stateFrom ); 200 185 } … … 205 190 206 191 sentStates[userId].push_back( stateTo ); 207 192 208 193 stateTo->stateId = stateId; 209 194 stateTo->dataLength = neededSize; … … 214 199 int i = 0; 215 200 int n; 216 217 bool hasPermission ;201 202 bool hasPermission = false; 218 203 bool sizeChanged = false; 219 204 … … 221 206 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) 222 207 { 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() ) 231 234 sizeChanged = true; 232 235 233 236 if ( ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeChanged ) 234 237 { 235 238 n = (*it)->writeToBuf( stateTo->data+i, stateTo->dataLength - i ); 236 239 //NETPRINTF(0)("getvar %s %d\n", (*it)->getName().c_str(), n); 240 //PRINTF(0)("getvar %s %d\n", (*it)->getName().c_str(), n); 237 241 stateTo->sizeList.push_back( n ); 238 //(*it)->debug(); 242 // this is only for very hardcore debug sessions 243 // (*it)->debug(); 239 244 i += n; 240 245 } … … 257 262 if ( i != neededSize ) 258 263 { 259 PRINTF(0)("strange error: (%s) %d != %d\n", this->getClass Name(), i, neededSize);264 PRINTF(0)("strange error: (%s) %d != %d\n", this->getClassCName(), i, neededSize); 260 265 assert(false); 261 266 } … … 281 286 * @param fromStateId id of the base state id 282 287 * @return number bytes read 288 * 283 289 * @todo check for permissions 284 290 */ … … 299 305 StateHistoryEntry * stateFrom = NULL; 300 306 307 // search the state from wich the diff is made of 301 308 StateHistory::iterator it = recvStates[userId].begin(); 302 309 while ( it != recvStates[userId].end() && (*it)->stateId != fromStateId ) 303 310 it++; 304 311 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 311 313 if ( it == recvStates[userId].end() ) 312 314 { … … 318 320 319 321 stateFrom = initialEntry; 320 322 321 323 recvStates[userId].push_back( stateFrom ); 322 324 } 323 325 else 324 326 stateFrom = (*it); 325 326 //apply diff 327 328 329 // apply diff 327 330 for ( int i = 0; i<length; i++ ) 328 331 { … … 331 334 else 332 335 stateTo->data[i] = data[i]; 333 334 } 335 336 } 337 336 338 //add state to state history 337 339 recvStates[userId].push_back( stateTo ); 338 340 339 341 int i = 0; 340 342 int n = 0; 341 343 std::list<int> changes; 342 344 bool hasPermission = false; 345 346 // extract the new state for every client 343 347 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) 344 348 { 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) 351 377 { 352 378 n = (*it)->readFromBuf( stateTo->data + i, stateTo->dataLength - i ); 353 379 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); 355 382 //(*it)->debug(); 356 383 if ( (*it)->getHasChanged() ) … … 361 388 else 362 389 { 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 ); 364 391 n = (*it)->getSizeFromBuf( stateTo->data + i, stateTo->dataLength - i ); 365 //NETPRINTF(0)("%s::setvar %s %d\n", getClass Name(), (*it)->getName().c_str(), n);392 //NETPRINTF(0)("%s::setvar %s %d\n", getClassCName(), (*it)->getName().c_str(), n); 366 393 //(*it)->debug(); 367 394 i += n; … … 370 397 371 398 this->varChangeHandler( changes ); 372 399 373 400 return i; 374 401 } … … 423 450 (*it)->data = NULL; 424 451 } 425 452 426 453 delete *it; 427 454 } 428 455 recvStates[userId].clear(); 429 456 } 430 457 431 458 if ( sentStates.size() > userId ) 432 459 { 433 460 434 461 for ( std::list<StateHistoryEntry*>::iterator it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ ) 435 462 { … … 439 466 (*it)->data = NULL; 440 467 } 441 468 442 469 delete *it; 443 470 } … … 448 475 /** 449 476 * 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 453 480 */ 454 481 void Synchronizeable::handleRecvState( int userId, int stateId, int fromStateId ) … … 457 484 if ( recvStates.size() <= userId ) 458 485 recvStates.resize( userId+1 ); 459 486 460 487 //remove old states 461 488 StateHistory::iterator it = recvStates[userId].begin(); … … 485 512 StateHistory::iterator delIt = it; 486 513 it ++; 487 514 488 515 if ( (*delIt)->data ) 489 516 { … … 493 520 delete *delIt; 494 521 recvStates[userId].erase( delIt ); 495 522 496 523 continue; 497 524 } 498 525 it++; 499 526 } 500 527 501 528 StateHistory::iterator fromState = recvStates[userId].end(); 502 529 StateHistory::iterator toState = recvStates[userId].end(); 503 530 504 531 for ( it = recvStates[userId].begin(); it != recvStates[userId].end(); it++ ) 505 532 { … … 508 535 if ( (*it)->stateId == fromStateId ) 509 536 fromState = it; 510 537 511 538 if ( fromState != recvStates[userId].end() && toState != recvStates[userId].end() ) 512 539 break; 513 540 } 514 541 515 542 // setStateDiff was not called and i know fromStateId 516 543 if ( fromState != recvStates[userId].end() && toState == recvStates[userId].end() ) 517 544 { 518 545 StateHistoryEntry * entry = new StateHistoryEntry; 519 546 520 547 entry->dataLength = (*fromState)->dataLength; 521 548 if ( entry->dataLength > 0 ) 522 549 { 523 550 entry->data = new byte[entry->dataLength]; 524 551 525 552 assert( (*fromState)->data ); 526 553 memcpy( entry->data, (*fromState)->data, entry->dataLength ); … … 528 555 else 529 556 entry->data = NULL; 530 557 531 558 entry->sizeList = (*fromState)->sizeList; 532 559 entry->stateId = stateId; 533 560 534 561 recvStates[userId].push_back(entry); 535 562 } … … 538 565 /** 539 566 * 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 543 570 */ 544 571 void Synchronizeable::handleSentState( int userId, int stateId, int fromStateId ) … … 557 584 StateHistory::iterator delIt = it; 558 585 it ++; 559 586 560 587 if ( (*delIt)->data ) 561 588 { … … 565 592 delete *delIt; 566 593 sentStates[userId].erase( delIt ); 567 594 568 595 continue; 569 596 } … … 571 598 } 572 599 573 600 574 601 StateHistory::iterator fromState = sentStates[userId].end(); 575 602 StateHistory::iterator toState = sentStates[userId].end(); 576 603 577 604 for ( it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ ) 578 605 { … … 581 608 if ( (*it)->stateId == fromStateId ) 582 609 fromState = it; 583 610 584 611 if ( fromState != sentStates[userId].end() && toState != sentStates[userId].end() ) 585 612 break; 586 613 } 587 614 588 615 589 616 // getStateDiff was not called and i know fromStateId 590 617 if ( fromState != sentStates[userId].end() && toState == sentStates[userId].end() ) 591 618 { 592 619 StateHistoryEntry * entry = new StateHistoryEntry; 593 620 594 621 entry->dataLength = (*fromState)->dataLength; 595 622 if ( entry->dataLength > 0 ) 596 623 { 597 624 entry->data = new byte[entry->dataLength]; 598 625 599 626 assert( (*fromState)->data ); 600 627 memcpy( entry->data, (*fromState)->data, entry->dataLength ); … … 602 629 else 603 630 entry->data = NULL; 604 631 605 632 entry->sizeList = (*fromState)->sizeList; 606 633 entry->stateId = stateId; 607 634 608 635 sentStates[userId].push_back(entry); 609 636 } 610 611 } 612 613 614 637 638 } 639 640 641 -
trunk/src/lib/network/synchronizeable.h
r8708 r9406 1 1 /*! 2 2 * @file synchronizeable.h 3 \brief interface for all classes that have to be synchronized3 * @brief interface for all classes that have to be synchronized 4 4 */ 5 5 … … 8 8 9 9 #include "base_object.h" 10 #include "netdefs.h" 11 #include "converter.h" 12 #include "vector.h" 13 #include "quaternion.h" 10 14 11 #include "synchronizeable_var/synchronizeable_var.h" 15 12 #include "synchronizeable_var/synchronizeable_vector.h" … … 20 17 #include "synchronizeable_var/synchronizeable_bool.h" 21 18 #include "synchronizeable_var/synchronizeable_uint.h" 22 19 #include "synchronizeable_var/synchronizeable_ip.h" 23 20 24 21 #include <vector> 25 22 #include <list> 26 23 27 //State constants: They have to be of the form 2^n28 #define STATE_SERVER 129 24 30 25 struct StateHistoryEntry … … 51 46 virtual ~Synchronizeable(); 52 47 53 void setIsServer( bool isServer );54 bool isServer();55 56 48 virtual void varChangeHandler( std::list<int> & id ); 57 49 … … 61 53 virtual void handleSentState( int userId, int stateId, int fromStateId ); 62 54 virtual void handleRecvState( int userId, int stateId, int fromStateId ); 63 55 64 56 void registerVar( SynchronizeableVar * var ); 65 57 int registerVarId( SynchronizeableVar * var ); … … 82 74 protected: 83 75 NetworkStream* networkStream; //!< reference network stream we are connected to 84 int state; 76 85 77 86 78 private: -
trunk/src/lib/network/synchronizeable_var/synchronizeable_bool.cc
r7954 r9406 16 16 17 17 #include "synchronizeable_bool.h" 18 #include <cassert> 18 19 19 20 … … 44 45 { 45 46 assert( maxLength >= 1 ); 46 47 47 48 buf[0] = ( *vPtrIn ) ? 1 : 0; 48 49 49 50 return 1; 50 51 } … … 59 60 { 60 61 assert( maxLength >= 1 ); 61 62 62 63 bool oldVal = *vPtrOut; 63 64 64 65 *vPtrOut = buf[0] != 0; 65 66 66 67 setHasChanged( oldVal != *vPtrOut ); 67 68 68 69 return 1; 69 70 } -
trunk/src/lib/network/synchronizeable_var/synchronizeable_bool.h
r7954 r9406 2 2 * @file synchronizeable_int.h 3 3 * @brief Definition of SynchronizeableInt 4 */ 5 6 #include "synchronizeable_var/synchronizeable_var.h" 4 */ 7 5 8 6 #ifndef _SYNCHRONIZEABLE_BOOL_H 9 7 #define _SYNCHRONIZEABLE_BOOL_H 10 8 9 #include "synchronizeable_var.h" 10 11 11 class SynchronizeableBool : public SynchronizeableVar { 12 12 13 13 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 ); 15 15 virtual ~SynchronizeableBool(); 16 16 17 17 virtual int writeToBuf( byte * buf, int maxLength ); 18 18 virtual int readFromBuf( byte * buf, int maxLength ); 19 19 20 20 /** 21 21 * check if writeToBuf will return the same size every time … … 23 23 */ 24 24 virtual bool hasStaticSize(){ return true; }; 25 25 26 26 virtual void debug(); 27 27 28 28 private: 29 29 bool * vPtrIn; //!< pointer to data (read) -
trunk/src/lib/network/synchronizeable_var/synchronizeable_float.cc
r7954 r9406 17 17 #include "synchronizeable_float.h" 18 18 #include "converter.h" 19 #include <cassert> 19 20 20 21 … … 46 47 { 47 48 int res = Converter::floatToByteArray( *vPtrIn, buf, maxLength ); 48 49 49 50 assert( res == FLOATSIZE ); 50 51 51 52 return res; 52 53 } … … 61 62 { 62 63 assert( maxLength >= FLOATSIZE ); 63 64 64 65 float oldVal = *vPtrOut; 65 66 66 67 int res = Converter::byteArrayToFloat( buf, vPtrOut ); 67 68 68 69 setHasChanged( oldVal != *vPtrOut ); 69 70 70 71 assert( res == FLOATSIZE ); 71 72 72 73 return res; 73 74 } -
trunk/src/lib/network/synchronizeable_var/synchronizeable_float.h
r7954 r9406 2 2 * @file synchronizeable_float.h 3 3 * @brief Definition of SynchronizeableFloat 4 */4 */ 5 5 6 #include "synchronizeable_var/synchronizeable_var.h"7 6 8 7 #ifndef _SYNCHRONIZEABLE_FLOAT_H 9 8 #define _SYNCHRONIZEABLE_FLOAT_H 10 9 10 #include "synchronizeable_var.h" 11 11 12 class SynchronizeableFloat : public SynchronizeableVar { 12 13 13 14 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 ); 15 16 virtual ~SynchronizeableFloat(); 16 17 17 18 virtual int writeToBuf( byte * buf, int maxLength ); 18 19 virtual int readFromBuf( byte * buf, int maxLength ); 19 20 20 21 /** 21 22 * check if writeToBuf will return the same size every time … … 23 24 */ 24 25 virtual bool hasStaticSize(){ return true; }; 25 26 26 27 virtual void debug(); 27 28 28 29 private: 29 30 float * vPtrIn; //!< pointer to data (read) -
trunk/src/lib/network/synchronizeable_var/synchronizeable_int.cc
r7954 r9406 18 18 #include "converter.h" 19 19 20 #include <cassert> 20 21 21 22 /** … … 46 47 { 47 48 int res = Converter::intToByteArray( *vPtrIn, buf, maxLength ); 48 49 49 50 assert( res == INTSIZE ); 50 51 51 52 return res; 52 53 } … … 61 62 { 62 63 assert( maxLength >= INTSIZE ); 63 64 64 65 int oldVal = *vPtrOut; 65 66 66 67 int res = Converter::byteArrayToInt( buf, vPtrOut ); 67 68 68 69 setHasChanged( oldVal != *vPtrOut ); 69 70 70 71 assert( res == INTSIZE ); 71 72 72 73 return res; 73 74 } -
trunk/src/lib/network/synchronizeable_var/synchronizeable_int.h
r7954 r9406 4 4 */ 5 5 6 #include "synchronizeable_var/synchronizeable_var.h"7 6 8 7 #ifndef _SYNCHRONIZEABLE_INT_H 9 8 #define _SYNCHRONIZEABLE_INT_H 10 9 10 #include "synchronizeable_var.h" 11 11 12 class SynchronizeableInt : public SynchronizeableVar { 12 13 13 14 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 ); 15 16 virtual ~SynchronizeableInt(); 16 17 17 18 virtual int writeToBuf( byte * buf, int maxLength ); 18 19 virtual int readFromBuf( byte * buf, int maxLength ); 19 20 20 21 /** 21 22 * check if writeToBuf will return the same size every time … … 23 24 */ 24 25 virtual bool hasStaticSize(){ return true; }; 25 26 26 27 virtual void debug(); 27 28 28 29 protected: 29 30 int * vPtrIn; //!< pointer to data (read) -
trunk/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc
r7954 r9406 17 17 #include "synchronizeable_quaternion.h" 18 18 #include "converter.h" 19 #include <cassert> 19 20 20 21 … … 98 99 assert( res > 0 ); 99 100 n += res; 100 101 101 102 Quaternion oldVal = *vPtrOut; 102 103 103 104 *vPtrOut = Quaternion( Vector(x, y, z), w ); 104 105 105 106 setHasChanged( ! ( oldVal == *vPtrOut ) ); 106 107 -
trunk/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h
r7954 r9406 4 4 */ 5 5 6 #include "synchronizeable_var/synchronizeable_var.h"7 8 6 #ifndef _SYNCHRONIZEABLE_QUATERNION_H 9 7 #define _SYNCHRONIZEABLE_QUATERNION_H 8 9 #include "synchronizeable_var.h" 10 10 11 11 #include "quaternion.h" … … 14 14 15 15 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 ); 17 17 virtual ~SynchronizeableQuaternion(); 18 18 19 19 virtual int writeToBuf( byte * buf, int maxLength ); 20 20 virtual int readFromBuf( byte * buf, int maxLength ); 21 21 22 22 /** 23 23 * check if writeToBuf will return the same size every time … … 25 25 */ 26 26 virtual bool hasStaticSize(){ return true; }; 27 27 28 28 virtual void debug(); 29 29 30 30 private: 31 31 Quaternion * vPtrIn; //!< pointer to data (read) -
trunk/src/lib/network/synchronizeable_var/synchronizeable_string.cc
r8147 r9406 17 17 #include "synchronizeable_string.h" 18 18 #include "converter.h" 19 #include <cassert> 19 20 20 21 … … 46 47 { 47 48 int res = Converter::stringToByteArray( *vPtrIn, buf, maxLength ); 48 49 49 50 assert( res > 0 ); 50 51 assert( res == vPtrIn->length()+INTSIZE ); 51 52 52 53 return res; 54 } 55 56 int SynchronizeableString::getSize() 57 { 58 return vPtrIn->length()+INTSIZE; 53 59 } 54 60 … … 62 68 { 63 69 std::string oldVal = *vPtrOut; 64 70 65 71 int res = Converter::byteArrayToString( buf, *vPtrOut, maxLength ); 66 72 67 73 setHasChanged( oldVal != *vPtrOut ); 68 74 69 75 if ( res < 0 ) 70 76 { … … 72 78 } 73 79 assert( res > 0 ); 74 80 75 81 return res; 76 82 } … … 94 100 { 95 101 std::string t; 96 102 97 103 int res = Converter::byteArrayToString( buf, t, maxLength ); 98 104 99 105 assert( res > 0 ); 100 106 101 107 return res; 102 108 } -
trunk/src/lib/network/synchronizeable_var/synchronizeable_string.h
r7954 r9406 4 4 */ 5 5 6 #include "synchronizeable_var/synchronizeable_var.h"7 #include "converter.h"8 9 6 #ifndef _SYNCHRONIZEABLE_STRING_H 10 7 #define _SYNCHRONIZEABLE_STRING_H 8 9 #include "synchronizeable_var.h" 11 10 12 11 #include <string> … … 15 14 16 15 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 ); 18 17 virtual ~SynchronizeableString(); 19 18 20 19 virtual int writeToBuf( byte * buf, int maxLength ); 21 20 virtual int readFromBuf( byte * buf, int maxLength ); 22 23 21 22 24 23 /** 25 24 * check if writeToBuf will return the same size every time … … 27 26 */ 28 27 virtual bool hasStaticSize(){ return false; }; 29 30 virtual int getSize() { return vPtrIn->length()+INTSIZE; }31 28 29 virtual int getSize(); 30 32 31 virtual int getSizeFromBuf( byte * buf, int maxLength ); 33 32 34 33 virtual void debug(); 35 34 36 35 private: 37 36 std::string * vPtrIn; //!< pointer to data (read) -
trunk/src/lib/network/synchronizeable_var/synchronizeable_uint.h
r7954 r9406 4 4 */ 5 5 6 #include "synchronizeable_var/synchronizeable_int.h"7 6 8 7 #ifndef _SYNCHRONIZEABLE_UINT_H 9 8 #define _SYNCHRONIZEABLE_UINT_H 10 9 10 #include "synchronizeable_int.h" 11 11 12 class SynchronizeableUInt : public SynchronizeableInt { 12 13 13 14 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 ); 15 16 virtual ~SynchronizeableUInt(); 16 17 17 18 virtual void debug(); 18 19 -
trunk/src/lib/network/synchronizeable_var/synchronizeable_var.cc
r7954 r9406 16 16 17 17 #include "synchronizeable_var.h" 18 18 #include "netdefs.h" 19 #include <cassert> 19 20 20 21 -
trunk/src/lib/network/synchronizeable_var/synchronizeable_var.h
r7954 r9406 7 7 #define _SYNCHRONIZEABLE_VAR_H 8 8 9 #include "nettypes.h" 9 10 #include <string> 10 #include "netdefs.h"11 #include <assert.h>12 11 13 12 enum { 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 17 17 }; 18 18 … … 20 20 21 21 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 ); 23 23 virtual ~SynchronizeableVar(); 24 24 … … 28 28 */ 29 29 inline bool beWatched(){ return this->bWatched; } 30 31 /** 30 31 /** 32 32 * set flag if synchronizeable wants to be informed on changes 33 33 */ … … 96 96 */ 97 97 inline void resetPriority() { this->priority = this->realPriority; } 98 98 99 99 /** 100 100 * reads actual size from buffer. this is used when size is not constant … … 104 104 */ 105 105 virtual inline int getSizeFromBuf( byte * buf, int maxLength ){ return this->getSize(); } 106 106 107 107 /** 108 108 * set variable id … … 110 110 */ 111 111 inline void setVarId( int id ){ this->varId = id; } 112 113 /** 112 113 /** 114 114 * get variable id 115 115 * @return variable id 116 116 */ 117 117 inline int getVarId(){ return varId; } 118 118 119 119 /** 120 120 * set hasChanged … … 122 122 */ 123 123 inline void setHasChanged( bool changed ){ this->changed = changed; } 124 125 /** 124 125 /** 126 126 * get hasChanged 127 127 * @return variable id 128 128 */ 129 129 inline bool getHasChanged(){ return changed; } 130 130 131 131 /** 132 132 * print out variable value … … 137 137 private: 138 138 bool bWatched; //!< true if synchronizeable wants to be informed on changes 139 139 140 140 int permission; //!< who is allowed to change this var 141 141 int priority; //!< priority assigned to var 142 142 int realPriority; //!< priority assigned to var, increased every time not sent 143 143 int varId; //!< id to identify varables 144 144 145 145 bool changed; //!< true if last readFromBuf changed anything 146 146 -
trunk/src/lib/network/synchronizeable_var/synchronizeable_vector.cc
r7954 r9406 17 17 #include "synchronizeable_vector.h" 18 18 #include "converter.h" 19 #include <cassert> 19 20 20 21 … … 79 80 int res; 80 81 int n = 0; 81 82 82 83 Vector oldVec = *vPtrOut; 83 84 … … 95 96 96 97 *vPtrOut = Vector( x, y, z ); 97 98 98 99 setHasChanged( !(*vPtrOut == oldVec) ); 99 100 -
trunk/src/lib/network/synchronizeable_var/synchronizeable_vector.h
r7954 r9406 4 4 */ 5 5 6 #include "synchronizeable_var/synchronizeable_var.h"7 8 6 #ifndef _SYNCHRONIZEABLE_VECTOR_H 9 7 #define _SYNCHRONIZEABLE_VECTOR_H 8 9 #include "synchronizeable_var.h" 10 10 11 11 #include "vector.h" … … 14 14 15 15 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 ); 17 17 virtual ~SynchronizeableVector(); 18 18 19 19 virtual int writeToBuf( byte * buf, int maxLength ); 20 20 virtual int readFromBuf( byte * buf, int maxLength ); 21 21 22 22 /** 23 23 * check if writeToBuf will return the same size every time … … 25 25 */ 26 26 virtual bool hasStaticSize(){ return true; } 27 27 28 28 virtual void debug(); 29 29 30 30 private: 31 31 Vector * vPtrIn; //!< pointer to data (read) -
trunk/src/lib/network/tcp_server_socket.cc
r7954 r9406 136 136 _isListening = false; 137 137 } 138 -
trunk/src/lib/network/tcp_server_socket.h
r7954 r9406 28 28 virtual void close(); 29 29 virtual void update() {}; 30 30 31 31 private: 32 32 TCPsocket listenSocket; … … 36 36 37 37 void init(); 38 38 39 39 }; 40 40 -
trunk/src/lib/network/tcp_socket.h
r7954 r9406 1 1 /*! 2 * @file network_socket.h3 * Main interface for the network module. Manages all the modules2 * @file tcp_socket.h 3 * tcp socket network interface 4 4 5 5 */ … … 16 16 #define _INCOMING_BUFFER_SIZE 2024000 17 17 #define _OUTGOING_BUFFER_SIZE 2024000 18 #define _LOCAL_BUFFER_SIZE 102418 #define _LOCAL_BUFFER_SIZE 2048 19 19 //sleep if incoming buffer is full 20 20 #define _MSECONDS_SLEEP_FULL_BUFFER 10 … … 47 47 48 48 virtual void connectToServer( std::string host, int port ); 49 49 50 50 virtual void disconnectServer(); 51 virtual void reconnectToServer( std::string host, int port); 52 virtual void reconnectToServerSoft( std::string host, int port); 51 53 52 54 virtual bool writePacket(byte * data, int length); -
trunk/src/lib/network/udp_socket.cc
r8802 r9406 74 74 { 75 75 this->init(); 76 this->ip = ip; 76 77 this->serverSocket = serverSocket; 77 78 this->userId = userId; … … 105 106 assert( serverSocket == NULL ); 106 107 107 IPaddress ip;108 109 108 this->randomByte = generateNewRandomByte(); 110 109 111 110 PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port); 112 111 113 if ( SDLNet_ResolveHost( & ip, host.c_str(), port ) != 0 )112 if ( SDLNet_ResolveHost( &this->ip, host.c_str(), port ) != 0 ) 114 113 { 115 114 PRINTF(1)("SDLNet_ResolveHost: %s\n", SDLNet_GetError() ); … … 126 125 } 127 126 128 int channel = SDLNet_UDP_Bind(socket, 1, & ip);127 int channel = SDLNet_UDP_Bind(socket, 1, &this->ip); 129 128 if ( channel == -1 ) 130 129 { … … 147 146 bOk = false; 148 147 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 */ 161 void 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 */ 178 void UdpSocket::reconnectToServerSoft( std::string host, int port) 179 {} 180 150 181 151 182 /** … … 179 210 180 211 byte udpCmd = 0; 181 212 182 213 if ( networkPacket.length > 0 ) 183 214 { … … 189 220 else 190 221 return 0; 191 222 192 223 if ( !checkRandomByte( networkPacket.data[0] ) ) 193 224 return 0; … … 198 229 networkPacket.data = NULL; 199 230 } 200 231 201 232 if ( !checkUdpCmd( udpCmd ) ) 202 233 return 0; … … 207 238 { 208 239 int numrecv = SDLNet_UDP_Recv( socket, packet); 209 240 210 241 byte udpCmd = 0; 211 242 … … 218 249 else 219 250 return 0; 220 251 221 252 if ( !checkRandomByte( packet->data[0] ) ) 222 253 return 0; 223 254 224 255 if ( !checkUdpCmd( udpCmd ) ) 225 256 return 0; … … 283 314 return false; 284 315 } 285 316 286 317 if ( !this->serverSocket && ( udpCmd & UDPCMD_INVALIDRNDBYTE ) ) 287 318 { … … 292 323 return false; 293 324 } 294 325 295 326 return true; 296 327 } … … 300 331 srand( SDL_GetTicks() ); 301 332 byte res = ( rand() & 0xFC ); 302 333 303 334 PRINTF(0)("generated random byte: %x\n", res); 304 335 305 336 return res; 306 337 } -
trunk/src/lib/network/udp_socket.h
r8802 r9406 31 31 32 32 virtual void connectToServer( std::string host, int port ); 33 34 33 virtual void disconnectServer(); 35 34 35 virtual void reconnectToServer( std::string host, int port); 36 virtual void reconnectToServerSoft( std::string host, int port); 37 36 38 virtual bool writePacket(byte * data, int length ); 39 virtual int readPacket(byte * data, int maxLength); 37 40 38 virtual int readPacket(byte * data, int maxLength); 39 41 40 42 private: 41 43 UdpServerSocket * serverSocket; //!< will get packets here 42 44 int userId; //!< user id used by serverSocket 43 IPaddress ip; //!< host,port44 45 UDPsocket socket; //!< socket used to send/recieve 45 46 UDPpacket * packet; 46 47 47 48 byte randomByte; //!< contains random bytes & 0xFC 48 49 49 50 bool writeRawPacket( byte * data, int length ); 50 51 bool checkUdpCmd( byte udpCmd ); 51 52 bool checkRandomByte( byte rndByte ); 52 53 byte generateNewRandomByte(); 53 54 54 55 void init(); 55 56 -
trunk/src/lib/parser/cmdline_parser/cmdline_parser.cc
r8316 r9406 18 18 #include "src/lib/util/substring.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/parser/ini_parser/ini_parser.cc
r7729 r9406 35 35 #endif 36 36 37 using namespace std; 37 38 38 39 39 /** … … 142 142 if ( (*lineBegin == '#' || *lineBegin == ';')) 143 143 { 144 st ring newCommenLine = lineBegin;144 std::string newCommenLine = lineBegin; 145 145 this->commentList.push_back(newCommenLine); 146 146 continue; … … 242 242 } 243 243 fclose(stream); 244 return true; 244 245 } 245 246 -
trunk/src/lib/parser/preferences/cmd_line_prefs_reader.cc
r8316 r9406 20 20 #include "preferences.h" 21 21 22 using namespace std; 22 23 23 24 24 RegistredArgs CmdLinePrefsReader::regArgs; -
trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc
r7661 r9406 18 18 #include "ini_file_prefs_reader.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/particles/box_emitter.cc
r7198 r9406 25 25 #include "stdlibincl.h" 26 26 27 using namespace std; 27 28 28 29 29 -
trunk/src/lib/particles/dot_emitter.cc
r7661 r9406 24 24 #include "debug.h" 25 25 26 using namespace std; 26 27 27 28 28 -
trunk/src/lib/particles/dot_particles.cc
r7198 r9406 33 33 ->defaultValues("maps/evil-flower.png"); 34 34 35 using namespace std; 35 36 36 37 37 /** -
trunk/src/lib/particles/engine/particle_engine.cc
r7225 r9406 24 24 #include "util/loading/load_param.h" 25 25 26 using namespace std; 26 27 27 28 28 /** -
trunk/src/lib/particles/model_particles.cc
r7221 r9406 33 33 ->defaultValues("maps/evil-flower.png"); 34 34 35 using namespace std; 35 36 36 37 37 /** … … 136 136 } 137 137 else 138 PRINTF(2)("no model loaded onto ParticleSystem-%s\n", this->get Name());138 PRINTF(2)("no model loaded onto ParticleSystem-%s\n", this->getCName()); 139 139 glPopAttrib(); 140 140 } -
trunk/src/lib/particles/particle_emitter.cc
r7193 r9406 24 24 #include "stdlibincl.h" 25 25 26 using namespace std; 26 27 27 28 28 /** … … 198 198 void ParticleEmitter::debug() const 199 199 { 200 PRINT(0)(" ParticleEmitter %s::%s\n", this->getClass Name(), this->getName());200 PRINT(0)(" ParticleEmitter %s::%s\n", this->getClassCName(), this->getCName()); 201 201 PRINT(0)(" EmissionRate: %f, Speed: %f, SpreadAngle: %f\n", this->getEmissionRate(), this->getEmissionVelocity(), this->getSpread()); 202 202 } -
trunk/src/lib/particles/particle_system.cc
r9235 r9406 32 32 #include <algorithm> 33 33 34 using namespace std; 34 35 35 /** 36 36 * standard constructor … … 139 139 { 140 140 PRINTF(2)("Tried to load an Element of type '%s' that should be a ParticleEmitter onto '%s::%s'.\n", 141 emitter->getClass Name(), this->getClassName(), this->getName());141 emitter->getClassCName(), this->getClassCName(), this->getCName()); 142 142 delete emitter; 143 143 } … … 145 145 else 146 146 { 147 PRINTF(2)("Could not Generate Emitter for system %s::%s (wrong type in XML-format)\n", this->getClass Name(), getName());147 PRINTF(2)("Could not Generate Emitter for system %s::%s (wrong type in XML-format)\n", this->getClassCName(), getCName()); 148 148 } 149 149 } … … 157 157 { 158 158 this->maxCount = maxCount; 159 PRINTF(4)("MAXCOUNT of %s::%s is %d\n", this->getClass Name(), this->getName(),maxCount);159 PRINTF(4)("MAXCOUNT of %s::%s is %d\n", this->getClassCName(), this->getCName(), maxCount); 160 160 } 161 161 … … 170 170 this->lifeSpan = lifeSpan; 171 171 this->randomLifeSpan = randomLifeSpan; 172 PRINTF(4)("LifeTime of %s::%s is %f\n", this->getClass Name(), this->getName(), lifeSpan);172 PRINTF(4)("LifeTime of %s::%s is %f\n", this->getClassCName(), this->getCName(), lifeSpan); 173 173 } 174 174 … … 188 188 this->conserve = conserve; 189 189 190 PRINTF(4)("Conserve of %s::%s is %f\n", this->getClass Name(), this->getName(),conserve);190 PRINTF(4)("Conserve of %s::%s is %f\n", this->getClassCName(), this->getCName(), conserve); 191 191 } 192 192 … … 206 206 207 207 PRINTF(4)("Radius of %s::%s at timeSlice %f is %f with a Random of %f\n", 208 this->getClass Name(), this->getName(),lifeCycleTime, radius, randRadius);208 this->getClassCName(), this->getCName(), lifeCycleTime, radius, randRadius); 209 209 } 210 210 … … 237 237 238 238 PRINTF(4)("Color of %s::%s on timeslice %f is r:%f g:%f b:%f a:%f\n", 239 this->getClass Name(), this->getName(), lifeCycleTime, red, green, blue, alpha);239 this->getClassCName(), this->getCName(), lifeCycleTime, red, green, blue, alpha); 240 240 } 241 241 … … 278 278 (*emitter)->updateNode(.1), (*emitter)->updateNode(.1); 279 279 280 PRINTF(4)("Precaching %s::%s %d seconds %d timesPerSecond\n", this->getClass Name(), this->getName(), seconds, ticksPerSecond);280 PRINTF(4)("Precaching %s::%s %d seconds %d timesPerSecond\n", this->getClassCName(), this->getCName(), seconds, ticksPerSecond); 281 281 for (unsigned int i = 0; i < seconds*ticksPerSecond; i++) 282 282 this->tick(1.0/(float)ticksPerSecond); … … 460 460 int i = 1; 461 461 Particle* tmpPart = this->deadList; 462 while ( tmpPart = tmpPart->next) { ++i; }462 while ((tmpPart = tmpPart->next) != NULL) { ++i; } 463 463 PRINT(0)("count: %d\n", i); 464 464 } -
trunk/src/lib/particles/plane_emitter.cc
r7198 r9406 25 25 #include "stdlibincl.h" 26 26 27 using namespace std; 27 28 28 29 29 -
trunk/src/lib/particles/quick_animation.cc
r7335 r9406 20 20 #include <algorithm> 21 21 22 using namespace std; 22 23 23 24 24 /** -
trunk/src/lib/particles/spark_particles.cc
r7221 r9406 29 29 30 30 31 using namespace std; 31 32 32 33 33 CREATE_FACTORY(SparkParticles, CL_SPARK_PARTICLES); -
trunk/src/lib/particles/sprite_particles.cc
r7221 r9406 33 33 ->defaultValues("maps/evil-flower.png"); 34 34 35 using namespace std; 35 36 36 37 37 /** -
trunk/src/lib/physics/fields/field.cc
r7199 r9406 22 22 #include "util/loading/factory.h" 23 23 #include "util/loading/load_param.h" 24 using namespace std; 24 25 25 26 26 /** -
trunk/src/lib/physics/fields/gravity.cc
r7193 r9406 21 21 #include "util/loading/factory.h" 22 22 23 using namespace std; 23 24 24 25 25 CREATE_FACTORY(Gravity, CL_FIELD_GRAVITY); -
trunk/src/lib/physics/fields/point_gravity.cc
r5357 r9406 18 18 #include "point_gravity.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/physics/fields/twirl.cc
r5357 r9406 18 18 #include "twirl.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/physics/physics_connection.cc
r7221 r9406 27 27 #include "util/loading/load_param.h" 28 28 29 using namespace std; 29 30 30 31 31 CREATE_FACTORY(PhysicsConnection, CL_PHYSICS_CONNECTION); … … 81 81 } 82 82 else 83 PRINTF(5)("subject::%s\n", this->subject->get Name());83 PRINTF(5)("subject::%s\n", this->subject->getCName()); 84 84 } 85 85 … … 95 95 } 96 96 else 97 PRINTF(5)("field::%s\n", this->field->get Name());97 PRINTF(5)("field::%s\n", this->field->getCName()); 98 98 99 99 } -
trunk/src/lib/physics/physics_engine.cc
r7221 r9406 23 23 #include "util/loading/load_param.h" 24 24 25 using namespace std; 25 26 26 27 27 … … 162 162 Field* PhysicsEngine::getFieldByName(const std::string& fieldName) const 163 163 { 164 list<Field*>::const_iterator field;164 std::list<Field*>::const_iterator field; 165 165 for (field = this->fields.begin(); field != this->fields.end(); field++) 166 166 if (fieldName == (*field)->getName()) … … 199 199 PhysicsConnection* PhysicsEngine::getPhysicsConnectionByName(const std::string& physicsConnectionName) const 200 200 { 201 list<PhysicsConnection*>::const_iterator pc;201 std::list<PhysicsConnection*>::const_iterator pc; 202 202 for (pc = this->connections.begin(); pc != this->connections.end(); pc++) 203 203 if (physicsConnectionName == (*pc)->getName()) … … 218 218 /* go through all the PhysicsInterface(s) and tick them, 219 219 meaning let the fields work */ 220 list<PhysicsConnection*>::iterator pc;220 std::list<PhysicsConnection*>::iterator pc; 221 221 for (pc = this->connections.begin(); pc != this->connections.end(); pc++) 222 222 (*pc)->apply(); … … 225 225 if (this->interfaces != NULL || (this->interfaces = ClassList::getList(CL_PHYSICS_INTERFACE)) != NULL) 226 226 { 227 list<BaseObject*>::const_iterator tickPhys;227 std::list<BaseObject*>::const_iterator tickPhys; 228 228 for (tickPhys = this->interfaces->begin(); tickPhys != this->interfaces->end(); tickPhys++) 229 229 dynamic_cast<PhysicsInterface*>(*tickPhys)->tickPhys(dt); -
trunk/src/lib/physics/physics_interface.cc
r8350 r9406 29 29 #include "stdincl.h" 30 30 31 using namespace std; 31 32 32 33 33 … … 68 68 { 69 69 // todo: find out if children are PhysicsInterface in an efficient way 70 if (strcmp( pn->getClass Name(), "PhysicsInterface")) {70 if (strcmp( pn->getClassCName(), "PhysicsInterface")) { 71 71 massSum += ((PhysicsInterface*)pn)->getTotalMass(); 72 72 } … … 77 77 if (massSum != this->massChildren ) { 78 78 this->massChildren = massSum; 79 if (strcmp( massCalcPNode->parent->getClass Name(), "PhysicsInterface"))79 if (strcmp( massCalcPNode->parent->getClassCName(), "PhysicsInterface")) 80 80 ((PhysicsInterface*)massCalcPNode->parent)->recalcMass(); 81 81 } else { -
trunk/src/lib/shell/shell_command.cc
r9112 r9406 119 119 120 120 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 } 124 126 return NULL; 125 127 } … … 137 139 if (likely(checkClass != NULL)) 138 140 return ShellCommand::getCommand(commandName, checkClass); 139 return NULL; 141 else 142 return NULL; 140 143 } 141 144 … … 149 152 const ShellCommand* const ShellCommand::getCommandFromInput(const std::string& inputLine, unsigned int& paramBegin, std::vector<BaseObject*>* boList) 150 153 { 151 return ShellCommand::getCommandFromInput(SubString(inputLine, SubString::WhiteSpaces), paramBegin );154 return ShellCommand::getCommandFromInput(SubString(inputLine, SubString::WhiteSpaces), paramBegin, boList); 152 155 } 153 156 … … 199 202 { 200 203 // Search for Objects. 201 retCmd = ShellCommand::getCommand( strings[1], cmdClass);204 retCmd = ShellCommand::getCommand((strings.size() > 1) ? strings[1] : "", cmdClass); 202 205 if (retCmd != NULL) 203 206 { … … 210 213 if (retCmd == NULL && strings.size() >= 2) 211 214 { 212 retCmd = ShellCommand::getCommand( strings[2], cmdClass);215 retCmd = ShellCommand::getCommand((strings.size() > 2) ? strings[2] : "", cmdClass); 213 216 if (retCmd != NULL) 214 217 { … … 254 257 { 255 258 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())) 257 260 boList->push_back(*bo); 258 261 } … … 298 301 for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo) 299 302 { 300 PRINT(0)("Command '%s' on '%s::%s'\n", sc->get Name(), (*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)); 302 305 } 303 306 return true; … … 331 334 if (this->alias != NULL) 332 335 { 333 PRINTF(2)("not more than one Alias allowed for functions (%s::%s)\n", this->get Name(), this->shellClass->getName());336 PRINTF(2)("not more than one Alias allowed for functions (%s::%s)\n", this->getCName(), this->shellClass->getCName()); 334 337 } 335 338 else … … 369 372 { 370 373 PRINTF(1)("Parameter %d not inside of valid ParameterCount %d of Command %s::%s\n", 371 parameter, this->executor->getParamCount(), this->get Name(), this->shellClass->getName());374 parameter, this->executor->getParamCount(), this->getCName(), this->shellClass->getCName()); 372 375 } 373 376 else … … 375 378 // if(this->completors[parameter] == NULL) 376 379 // delete this->completors[parameter]; 377 // this->completors[parameter] = completorPlugin.clone(); 380 // this->completors[parameter] = completorPlugin.clone(); 378 381 } 379 382 return this; … … 385 388 void ShellCommand::help() const 386 389 { 387 PRINT(0)("%s ", this->get Name());390 PRINT(0)("%s ", this->getCName()); 388 391 } 389 392 -
trunk/src/lib/shell/shell_command_class.cc
r7743 r9406 199 199 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 200 200 { 201 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->get Name(), (*cmdIT)->executor->getParamCount());201 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->getCName(), (*cmdIT)->executor->getParamCount()); 202 202 /// FIXME 203 203 /* for (unsigned int i = 0; i< elem->paramCount; i++) -
trunk/src/lib/shell/shell_completion.cc
r7764 r9406 290 290 for(bo = inputList.begin(); bo != inputList.end(); bo++) 291 291 { 292 if ((*bo)->getName() != NULL && 293 strlen((*bo)->getName()) >= searchLength && 292 if ((*bo)->getName().size() >= searchLength && 294 293 !nocaseCmp((*bo)->getName(), completionBegin, searchLength)) 295 294 { -
trunk/src/lib/sound/ogg_player.cc
r9019 r9406 481 481 if (comment == NULL) 482 482 { 483 PRINTF(2)("Retrieving Comment of %s failed\n", this->get Name());483 PRINTF(2)("Retrieving Comment of %s failed\n", this->getCName()); 484 484 return; 485 485 } -
trunk/src/lib/util/Makefile.am
r8724 r9406 6 6 libORXlibutil_a_SOURCES = \ 7 7 substring.cc \ 8 tokenizer.cc \9 8 color.cc \ 10 9 helper_functions.cc \ … … 24 23 filesys/file.cc \ 25 24 filesys/directory.cc \ 25 filesys/net_link.cc \ 26 26 \ 27 27 preferences.cc \ … … 32 32 noinst_HEADERS = \ 33 33 substring.h \ 34 tokenizer.h \35 34 multi_type.h \ 36 35 color.h \ … … 44 43 filesys/file.h \ 45 44 filesys/directory.h \ 45 filesys/net_link.h \ 46 46 \ 47 47 preferences.h \ -
trunk/src/lib/util/executor/executor_functional.h
r8271 r9406 179 179 { 180 180 (__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]))); 182 182 }; 183 183 … … 222 222 { 223 223 (__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]))); 226 226 }; 227 227 … … 276 276 { 277 277 (__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]))); 281 281 }; 282 282 … … 333 333 { 334 334 (__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]))); 339 339 }; 340 340 … … 392 392 { 393 393 (__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]))); 399 399 }; 400 400 -
trunk/src/lib/util/executor/functor_list.h
r8894 r9406 135 135 136 136 //! mixed values: 137 FUNCTOR_LIST(2)(l_STRING, l_INT); 137 138 FUNCTOR_LIST(2)(l_STRING, l_FLOAT); 138 139 FUNCTOR_LIST(2)(l_UINT, l_LONG); -
trunk/src/lib/util/helper_functions.cc
r7714 r9406 19 19 #include "stdlibincl.h" 20 20 21 using namespace std; 21 22 22 23 23 /** -
trunk/src/lib/util/loading/dynamic_loader.cc
r8362 r9406 23 23 24 24 25 using namespace std; 25 26 26 27 27 -
trunk/src/lib/util/loading/factory.cc
r8362 r9406 19 19 //#include "shell_command.h" 20 20 21 using namespace std; 21 22 22 23 23 //SHELL_COMMAND(create, Factory, fabricate); … … 117 117 if (factory != Factory::factoryList->end()) 118 118 { 119 PRINTF(2)("Create a new Object of type %s\n", (*factory)->get Name());119 PRINTF(2)("Create a new Object of type %s\n", (*factory)->getCName()); 120 120 return (*factory)->fabricateObject(root); 121 121 } … … 145 145 if (factory != Factory::factoryList->end()) 146 146 { 147 PRINTF(4)("Create a new Object of type %s\n", (*factory)->get Name());147 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 148 148 return (*factory)->fabricateObject(NULL); 149 149 } … … 173 173 if (factory != Factory::factoryList->end()) 174 174 { 175 PRINTF(4)("Create a new Object of type %s\n", (*factory)->get Name());175 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 176 176 return (*factory)->fabricateObject(NULL); 177 177 } -
trunk/src/lib/util/loading/load_param.cc
r8408 r9406 65 65 ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString))) 66 66 { 67 PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", this->paramName.c_str(), loadString.c_str(), this->object->getClass Name(), 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()); 68 68 (*this->executor)(this->object, SubString(loadString, ",", SubString::WhiteSpaces, false, '\\')); 69 69 } … … 164 164 { 165 165 // locating the class 166 this->classDesc = LoadClassDescription::addClass(object->getClass Name());166 this->classDesc = LoadClassDescription::addClass(object->getClassCName()); 167 167 168 168 if ((this->paramDesc = this->classDesc->addParam(paramName)) != NULL) -
trunk/src/lib/util/loading/resource.cc
r8271 r9406 18 18 #include "resource.h" 19 19 20 using namespace std; 20 21 21 22 22 -
trunk/src/lib/util/loading/resource_manager.cc
r8724 r9406 50 50 #include <unistd.h> 51 51 52 using namespace std; 52 53 53 54 54 /** -
trunk/src/lib/util/multi_type.cc
r8316 r9406 18 18 #include "multi_type.h" 19 19 20 //#include "stdincl.h"21 #include <stddef.h>22 #include <stdlib.h>23 #include <string.h>24 #include <stdio.h>25 20 #include <sstream> 26 21 … … 28 23 #include "debug.h" 29 24 #endif 30 31 using namespace std;32 25 33 26 /** -
trunk/src/lib/util/substring.cc
r7477 r9406 28 28 #include "substring.h" 29 29 30 #include <string.h>31 #include <cassert>32 33 34 30 /** 35 31 * @brief default constructor … … 108 104 109 105 /** @brief An empty String */ 110 const std::string SubString::emptyString = "";106 // const std::string SubString::emptyString = ""; 111 107 /** @brief Helper that gets you a String consisting of all White Spaces */ 112 108 const std::string SubString::WhiteSpaces = " \n\t"; … … 238 234 } 239 235 else 240 return SubString::emptyString; 236 { 237 static std::string empty; 238 return empty; 239 } 241 240 } 242 241 … … 250 249 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 251 250 */ 252 SubString SubString:: getSubSet(unsigned int subSetBegin) const251 SubString SubString::subSet(unsigned int subSetBegin) const 253 252 { 254 253 return SubString(*this, subSetBegin); … … 265 264 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 266 265 */ 267 SubString SubString:: getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const266 SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const 268 267 { 269 268 return SubString(*this, subSetBegin, subSetEnd); … … 289 288 * Supports delimiters, escape characters, 290 289 * ignores special characters between safemode_char and between comment_char and linend '\n'. 291 *292 *293 290 */ 294 291 SubString::SPLIT_LINE_STATE -
trunk/src/lib/util/substring.h
r8408 r9406 2 2 * @file substring.h 3 3 * @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. 4 18 */ 5 19 6 #ifndef _ SUBSTRING_H7 #define _ SUBSTRING_H20 #ifndef __SUBSTRING_H__ 21 #define __SUBSTRING_H__ 8 22 9 23 #include <vector> … … 61 75 62 76 // 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; 65 79 66 80 // retrieve Information from within … … 70 84 inline unsigned int size() const { return this->strings.size(); }; 71 85 /** @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]; }; 73 87 /** @param i the i'th String @returns the i'th string from the subset of Strings */ 74 88 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(); }; 75 95 76 96 // the almighty algorithm. … … 93 113 private: 94 114 std::vector<std::string> strings; //!< strings produced from a single string splitted in multiple strings 95 96 static const std::string emptyString;97 115 }; 98 116 99 #endif /* _ SUBSTRING_H*/117 #endif /* __SUBSTRING_H__ */ -
trunk/src/lib/util/threading.cc
r7847 r9406 18 18 #include "threading.h" 19 19 20 using namespace std; 20 21 21 22 22 namespace OrxThread
Note: See TracChangeset
for help on using the changeset viewer.