Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6695 in orxonox.OLD for trunk/src/lib/coord


Ignore:
Timestamp:
Jan 25, 2006, 2:39:53 PM (19 years ago)
Author:
patrick
Message:

merged the network branche to the trunk

Location:
trunk/src/lib/coord
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r6634 r6695  
    4242 */
    4343PNode::PNode (PNode* parent, long nodeFlags)
     44  : Synchronizeable(), BaseObject()
    4445{
    4546  this->setClassID(CL_PARENT_NODE, "PNode");
     
    487488      this->children.push_back(child);
    488489    child->parentCoorChanged();
     490
     491//     if(this->getUniqueID() == NET_UID_UNASSIGNED)
     492//     {
     493//       PRINTF(1)("Adding to an UNASSIGNED PNode - looking for next assigned Node\n");
     494//       PNode* node = this->seekNextAssignedPNode(this);
     495//       if( node == NULL)
     496//         PRINTF(1)("    Got NULL - Is this the NULLParent - uid %i\n", this->getUniqueID());
     497//       else
     498//         PRINTF(1)("    Found next assigned node: %i\n", node->getUniqueID());
     499//     }
    489500  }
    490501  else
     
    495506    child->parentCoorChanged();
    496507  }
     508}
     509
     510
     511PNode* PNode::seekNextAssignedPNode(PNode* node) const
     512{
     513  PNode* tmpNode = node->parent;
     514  printf("entering seek PNode loop for name: %s, uid: %i\n", node->getName(), node->getUniqueID());
     515  if(tmpNode)
     516    printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
     517  while( tmpNode != NULL && tmpNode->getUniqueID() == NET_UID_UNASSIGNED)
     518  {
     519    printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
     520    tmpNode = tmpNode->parent;
     521  }
     522  printf("leaving PNode loop\n\n");
     523
     524  return tmpNode;
    497525}
    498526
     
    695723  {
    696724    PNode::nullParent = new PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL);
     725    PNode::nullParent->setClassID(CL_NULL_PARENT, "NullParent");
    697726    PNode::nullParent->setName("NullParent");
     727    PNode::nullParent->setSynchronized(true);
    698728  }
    699729  return PNode::nullParent;
     
    10491079  SYNCHELP_READ_FKT( BaseObject::writeState );
    10501080
    1051   char * parentName = NULL;
    1052   SYNCHELP_READ_STRINGM( parentName );
    1053 
    1054   if ( strcmp(parentName, "")==0 )
    1055   {
    1056     setParent( (char*)NULL );
    1057   }
    1058   else
    1059   {
    1060     setParent( parentName );
    1061   }
    1062 
    1063   delete[] parentName;
     1081//   char * parentName = NULL;
     1082//   SYNCHELP_READ_STRINGM( parentName );
     1083//
     1084//   if ( strcmp(parentName, "")==0 )
     1085//   {
     1086//     setParent( (char*)NULL );
     1087//   }
     1088//   else
     1089//   {
     1090//     setParent( parentName );
     1091//   }
     1092//
     1093//  delete[] parentName;
    10641094
    10651095  int parentMode;
     
    10811111  this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
    10821112
    1083   int n;
    1084   char * childName;
    1085 
    1086   PRINTF(0)("JKLO %d %d %d %d\n", data[__synchelp_read_i], data[__synchelp_read_i+1], data[__synchelp_read_i+2], data[__synchelp_read_i+3]);
    1087   SYNCHELP_READ_INT( n );
    1088   PRINTF(0)("read %s:n=%d\n", this->getName(), n);
    1089 
    1090   for (int i = 0; i<n; i++)
    1091   {
    1092     SYNCHELP_READ_STRINGM( childName );
    1093     PRINTF(0)("RCVD CHILD = %s\n", childName);
    1094     addChild( childName );
    1095     delete childName;
    1096     childName = NULL;
    1097   }
     1113//   int n;
     1114//   char * childName;
     1115//
     1116//   PRINTF(0)("JKLO %d %d %d %d\n", data[__synchelp_read_i], data[__synchelp_read_i+1], data[__synchelp_read_i+2], data[__synchelp_read_i+3]);
     1117//   SYNCHELP_READ_INT( n );
     1118//   PRINTF(0)("read %s:n=%d\n", this->getName(), n);
     1119//
     1120//   for (int i = 0; i<n; i++)
     1121//   {
     1122//     SYNCHELP_READ_STRINGM( childName );
     1123//     PRINTF(0)("RCVD CHILD = %s\n", childName);
     1124//     addChild( childName );
     1125//     delete childName;
     1126//     childName = NULL;
     1127//   }
    10981128
    10991129  return SYNCHELP_READ_N;
     
    11121142  SYNCHELP_WRITE_FKT( BaseObject::readState );
    11131143
    1114   if ( this->parent )
    1115   {
    1116     SYNCHELP_WRITE_STRING( parent->getName() );
    1117   }
    1118   else
    1119   {
    1120     SYNCHELP_WRITE_STRING( "" );
    1121   }
     1144//   if ( this->parent )
     1145//   {
     1146//     SYNCHELP_WRITE_STRING( parent->getName() );
     1147//   }
     1148//   else
     1149//   {
     1150//     SYNCHELP_WRITE_STRING( "" );
     1151//   }
    11221152
    11231153  SYNCHELP_WRITE_INT( this->parentMode );
     
    11321162  SYNCHELP_WRITE_FLOAT( this->relDirection.v.z );
    11331163
    1134   int n = children.size();
    1135 
    1136   //check if camera is in children
    1137   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
    1138   {
    1139     if ( (*it)->isA(CL_CAMERA) )
    1140       n--;
    1141   }
    1142   PRINTF(0)("write %s:n=%d\n", this->getName(), n);
    1143   SYNCHELP_WRITE_INT( n );
    1144   PRINTF(0)("ASDF %d %d %d %d\n", data[__synchelp_write_i-4], data[__synchelp_write_i-3], data[__synchelp_write_i-2], data[__synchelp_write_i-1]);
    1145 
    1146   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
    1147   {
    1148     //dont add camera because there is only one camera attached to local player
    1149     if ( !(*it)->isA(CL_CAMERA) )
    1150     {
    1151       PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
    1152       SYNCHELP_WRITE_STRING( (*it)->getName() );
    1153     }
    1154   }
     1164//   int n = children.size();
     1165//   //check if camera is in children
     1166//   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
     1167//   {
     1168//     if ( (*it)->isA(CL_CAMERA) )
     1169//       n--;
     1170//   }
     1171//   PRINTF(0)("write %s:n=%d\n", this->getName(), n);
     1172//   SYNCHELP_WRITE_INT( n );
     1173//   PRINTF(0)("ASDF %d %d %d %d\n", data[__synchelp_write_i-4], data[__synchelp_write_i-3], data[__synchelp_write_i-2], data[__synchelp_write_i-1]);
     1174//
     1175//
     1176//   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
     1177//   {
     1178//     //dont add camera because there is only one camera attached to local player
     1179//     if ( !(*it)->isA(CL_CAMERA) )
     1180//     {
     1181//       PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
     1182//       SYNCHELP_WRITE_STRING( (*it)->getName() );
     1183//     }
     1184//   }
    11551185
    11561186  return SYNCHELP_WRITE_N;
  • trunk/src/lib/coord/p_node.h

    r6634 r6695  
    147147  void removeNode();
    148148
     149  PNode* seekNextAssignedPNode(PNode* node) const;
     150
    149151  /** @param parent the new parent of this node */
    150152  inline void setParent (PNode* parent) { parent->addChild(this); };
Note: See TracChangeset for help on using the changeset viewer.