Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

merged netp3 branch back to trunk

Location:
code/trunk
Files:
7 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/network/packet/CMakeLists.txt

    r2710 r3084  
    11ADD_SOURCE_FILES(NETWORK_SRC_FILES
    22  Packet.cc
     3  Acknowledgement.cc
    34  Chat.cc
    45  ClassID.cc
    5   Acknowledgement.cc
     6  DeleteObjects.cc
     7  FunctionIDs.cc
     8  FunctionCalls.cc
    69  Gamestate.cc
    710  Welcome.cc
    8   DeleteObjects.cc
    911)
  • code/trunk/src/network/packet/ClassID.cc

    r2773 r3084  
    9393  }
    9494 
    95   COUT(0) << "classid packetSize is " << packetSize << endl;
     95  COUT(5) << "classid packetSize is " << packetSize << endl;
    9696 
    9797}
  • code/trunk/src/network/packet/FunctionCalls.cc

    • Property svn:eol-style set to native
  • code/trunk/src/network/packet/FunctionCalls.h

    • Property svn:eol-style set to native
  • code/trunk/src/network/packet/FunctionIDs.cc

    • Property svn:eol-style set to native
  • code/trunk/src/network/packet/FunctionIDs.h

    • Property svn:eol-style set to native
  • code/trunk/src/network/packet/Gamestate.cc

    r2896 r3084  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss, (C) 2008
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    107107  for(it = ObjectList<Synchronisable>::begin(); it; ++it){
    108108   
    109     tempsize=it->getSize(id, mode);
     109//     tempsize=it->getSize(id, mode);
     110
     111    tempsize = it->getData(mem, id, mode);
     112    if ( tempsize != 0 )
     113      dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
     114   
    110115#ifndef NDEBUG
    111116    if(currentsize+tempsize > size){
     
    123128    }// stop allocate additional memory
    124129#endif
    125 
    126     if ( it->doSync( id, mode ) )
    127       dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
    128     if(!it->getData(mem, id, mode))
    129       return false; // mem pointer gets automatically increased because of call by reference
     130//     if(!it->getData(mem, id, mode))
     131//       return false; // mem pointer gets automatically increased because of call by reference
    130132    // increase size counter by size of current synchronisable
    131133    currentsize+=tempsize;
     
    177179    }
    178180  }
    179 
    180181   // In debug mode, check first, whether there are no duplicate objectIDs
    181182#ifndef NDEBUG
    182   ObjectList<Synchronisable>::iterator it;
    183   for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
    184     if (it->getObjectID() == OBJECTID_UNKNOWN) {
    185       if (it->objectMode_ != 0x0) {
    186         COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
    187         COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
    188         COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
    189         assert(false);
     183  if(this->getID()%1000==0){
     184    std::list<uint32_t> v1;
     185    ObjectList<Synchronisable>::iterator it;
     186    for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
     187      if (it->getObjectID() == OBJECTID_UNKNOWN) {
     188        if (it->objectMode_ != 0x0) {
     189          COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
     190          COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
     191          COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
     192          assert(false);
     193        }
    190194      }
    191     }
    192     else {
    193       ObjectList<Synchronisable>::iterator it2;
    194       for (it2 = ObjectList<Synchronisable>::begin(); it2 != ObjectList<Synchronisable>::end(); ++it2) {
    195         if (it->getObjectID() == it2->getObjectID() && *it != *it2) {
    196            COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
    197                    << "Are you sure you don't create a Sychnronisable objcect with 'new' \
    198                        that doesn't have objectMode = 0x0?" << std::endl;
    199            assert(false);
     195      else {
     196        std::list<uint32_t>::iterator it2;
     197        for (it2 = v1.begin(); it2 != v1.end(); ++it2) {
     198          if (it->getObjectID() == *it2) {
     199            COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
     200                    << "Are you sure you don't create a Sychnronisable objcect with 'new' \
     201                        that doesn't have objectMode = 0x0?" << std::endl;
     202            assert(false);
     203          }
    200204        }
     205        v1.push_back(it->getObjectID());
    201206      }
    202207    }
     
    221226  uint8_t *d1 = data_+GamestateHeader::getSize();
    222227  uint8_t *d2 = gs.data_+GamestateHeader::getSize();
     228  GamestateHeader* h1 = new GamestateHeader(data_);
     229  GamestateHeader* h2 = new GamestateHeader(gs.data_);
     230  assert(h1->getDataSize() == h2->getDataSize());
    223231  assert(!isCompressed());
    224232  assert(!gs.isCompressed());
    225   while(d1<data_+header_->getDataSize())
    226   {
    227     if(*d1!=*d2)
    228       return false;
    229     d1++;
    230     d2++;
    231   }
    232   return true;
     233  return memcmp(d1, d2, h1->getDataSize())==0;
    233234}
    234235
     
    357358}
    358359
     360// Gamestate *Gamestate::diff(Gamestate *base)
     361// {
     362//   assert(data_);
     363//   assert(!header_->isCompressed());
     364//   assert(!header_->isDiffed());
     365//   GamestateHeader diffHeader(base->data_);
     366//   uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
     367//   uint32_t of=0; // pointers offset
     368//   uint32_t dest_length=0;
     369//   dest_length=header_->getDataSize();
     370//   if(dest_length==0)
     371//     return NULL;
     372//   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
     373//   uint8_t *dest = ndata + GamestateHeader::getSize();
     374//   
     375//   
     376//   // LOOP-UNROLLED DIFFING
     377//   uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs;
     378//   // diff in 4-byte steps
     379//   while( of < (uint32_t)(header_->getDataSize())/4 ){
     380//     if( of < (uint32_t)(diffHeader.getDataSize())/4 )
     381//     {
     382//       *(dest32+of)=*(base32+of) ^ *(gs32+of); // do the xor
     383//       ++of;
     384//     }
     385//     else
     386//     {
     387//       *(dest32+of)=*(gs32+of); // same as 0 ^ *(gs32+of)
     388//       ++of;
     389//     }
     390//   }
     391//   for( unsigned int of2 = 0; of2 < header_->getDataSize()%4; ++of2 )
     392//   {
     393//     if( of*4+of2 < diffHeader.getDataSize() )
     394//     {
     395//       *(dest+4*of+of2)=*(basep+4*of+of2) ^ *(gs+4*of+of2); // do the xor
     396//     }
     397//     else
     398//     {
     399//       *(dest+4*of+of2)=*(gs+4*of+of2); // same as 0 ^ *(gs32+of)
     400//     }
     401//   }
     402//
     403//   Gamestate *g = new Gamestate(ndata, getClientID());
     404//   *(g->header_) = *header_;
     405//   g->header_->setDiffed( true );
     406//   g->header_->setBaseID( base->getID() );
     407//   g->flags_=flags_;
     408//   g->packetDirection_ = packetDirection_;
     409//   return g;
     410// }
     411
    359412Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
    360413  assert(data_);
     
    378431
    379432  //call TrafficControl
    380   TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ );
     433  TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), dataVector_ );
    381434
    382435  //copy in the zeros
    383   for(it=dataMap_.begin(); it!=dataMap_.end();){
     436//   std::list<obj>::iterator itt;
     437//   COUT(0) << "myvector contains:";
     438//   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
     439//     COUT(0) << " " << (*itt).objID;
     440//   COUT(0) << endl;
     441  for(it=dataVector_.begin(); it!=dataVector_.end();){
    384442    SynchronisableHeader oldobjectheader(origdata);
    385443    SynchronisableHeader newobjectheader(newdata);
  • code/trunk/src/network/packet/Gamestate.h

    r2896 r3084  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss, (C) 2008
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    3737#include <string.h>
    3838#include <map>
    39 #include <list>
     39#include <vector>
    4040#include <cassert>
    4141#ifndef NDEBUG
     
    120120    bool compressData();
    121121    bool decompressData();
     122    bool operator ==(packet::Gamestate gs);
    122123
    123124    // Packet functions
     
    126127    virtual inline bool process();
    127128
    128     bool operator ==(packet::Gamestate gs);
    129129  private:
    130130    uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
    131     std::list<obj> dataMap_;
     131    std::list<obj> dataVector_;
    132132    GamestateHeader* header_;
    133133};
  • code/trunk/src/network/packet/Packet.cc

    r2773 r3084  
    3939
    4040#include "Acknowledgement.h"
     41#include "DeleteObjects.h"
    4142#include "Chat.h"
    4243#include "ClassID.h"
     44#include "FunctionCalls.h"
     45#include "FunctionIDs.h"
    4346#include "Gamestate.h"
    4447#include "Welcome.h"
    45 #include "DeleteObjects.h"
    4648#include "network/Host.h"
    4749#include "core/CoreIncludes.h"
     
    153155    case ENUM::Welcome:
    154156    case ENUM::DeleteObjects:
     157    case ENUM::FunctionIDs:
     158    case ENUM::FunctionCalls:
    155159      break;
    156160    default:
     
    170174  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    171175  Packet *p = 0;
    172   COUT(5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
     176  COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
    173177  switch( *(ENUM::Type *)(data + _PACKETID) )
    174178  {
    175179    case ENUM::Acknowledgement:
    176       COUT(4) << "ack" << std::endl;
     180      COUT(5) << "ack" << std::endl;
    177181      p = new Acknowledgement( data, clientID );
    178182      break;
    179183    case ENUM::Chat:
    180       COUT(4) << "chat" << std::endl;
     184      COUT(5) << "chat" << std::endl;
    181185      p = new Chat( data, clientID );
    182186      break;
    183187    case ENUM::ClassID:
    184       COUT(4) << "classid" << std::endl;
     188      COUT(5) << "classid" << std::endl;
    185189      p = new ClassID( data, clientID );
    186190      break;
    187191    case ENUM::Gamestate:
    188       COUT(4) << "gamestate" << std::endl;
     192      COUT(5) << "gamestate" << std::endl;
    189193      // TODO: remove brackets
    190194      p = new Gamestate( data, clientID );
    191195      break;
    192196    case ENUM::Welcome:
    193       COUT(4) << "welcome" << std::endl;
     197      COUT(5) << "welcome" << std::endl;
    194198      p = new Welcome( data, clientID );
    195199      break;
    196200    case ENUM::DeleteObjects:
    197       COUT(4) << "deleteobjects" << std::endl;
     201      COUT(5) << "deleteobjects" << std::endl;
    198202      p = new DeleteObjects( data, clientID );
     203      break;
     204    case ENUM::FunctionCalls:
     205      COUT(5) << "functionCalls" << std::endl;
     206      p = new FunctionCalls( data, clientID );
     207      break;
     208    case ENUM::FunctionIDs:
     209      COUT(5) << "functionIDs" << std::endl;
     210      p = new FunctionIDs( data, clientID );
    199211      break;
    200212    default:
  • code/trunk/src/network/packet/Packet.h

    r2773 r3084  
    4545  enum Type{
    4646    Acknowledgement,
     47    Chat,
     48    ClassID,
     49    DeleteObjects,
     50    FunctionIDs,
     51    FunctionCalls,
    4752    Gamestate,
    48     ClassID,
    49     Chat,
    50     Welcome,
    51     DeleteObjects
     53    Welcome
    5254  };
    5355}
     
    6668    virtual unsigned int getSize() const =0;
    6769    virtual bool process()=0;
    68     uint32_t getFlags()
     70    inline uint32_t getFlags()
    6971      { return flags_; }
    70     int getClientID()
     72    inline int getClientID()
    7173      { return clientID_; }
    72     void setClientID( int id )
     74    inline void setClientID( int id )
    7375      { clientID_ = id; }
    7476
     
    7880    Packet(uint8_t *data, unsigned int clientID);
    7981//    Packet(ENetPacket *packet, ENetPeer *peer);
     82    inline bool isDataENetAllocated() const
     83      { return bDataENetAllocated_; }
     84
    8085    uint32_t flags_;
    8186    unsigned int clientID_;
Note: See TracChangeset for help on using the changeset viewer.