Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3083


Ignore:
Timestamp:
May 26, 2009, 8:11:37 PM (15 years ago)
Author:
scheusso
Message:

some changes/fixes in gamestates and trafficcontrol

Location:
code/branches/netp3/src/network
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp3/src/network/Client.cc

    r3066 r3083  
    149149        COUT(4) << "popping partial gamestate: " << std::endl;
    150150        packet::Gamestate *gs = gamestate.getGamestate();
    151         assert(gs);
     151        //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
    152152        if(gs){
    153153          COUT(4) << "client tick: sending gs " << gs << std::endl;
  • code/branches/netp3/src/network/TrafficControl.cc

    r3043 r3083  
    121121
    122122
    123         void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>& list)
     123        void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list)
    124124        {
    125125          currentClientID=clientID;
     
    137137        void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
    138138        {
    139           std::vector<obj>::iterator itvec;  // iterator to iterate through the acked objects
     139          std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
    140140
    141141    //assertions to make sure the maps already exist
     
    146146    // shortcut for maps
    147147    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
    148     std::map<unsigned int, std::vector<obj> >& objectListTemp = clientListTemp_[clientID];
     148    std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID];
    149149
    150150    for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
     
    187187  * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
    188188  */
    189   void TrafficControl::updateClientListTemp(std::vector<obj>& list)
    190   {
    191     clientListTemp_[currentClientID][currentGamestateID] = std::vector<obj>(list);
     189  void TrafficControl::updateClientListTemp(std::list<obj>& list)
     190  {
     191    clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(list);
    192192  }
    193193
     
    196196  *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
    197197  */
    198   void TrafficControl::cut(std::vector<obj>& list, unsigned int targetsize)
     198  void TrafficControl::cut(std::list<obj>& list, unsigned int targetsize)
    199199  {
    200200    unsigned int size=0;
    201     std::vector<obj>::iterator itvec, ittemp;
     201    std::list<obj>::iterator itvec, ittemp;
    202202    assert(!list.empty());
    203203    for(itvec = list.begin(); itvec != list.end();)
     
    212212      {
    213213        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
    214         list.erase(itvec++);
     214        list.erase(itvec, list.end());
     215        break;
    215216      }
    216217//       printList(list, currentClientID);
     
    223224        *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
    224225        */
    225         void TrafficControl::evaluateList(unsigned int clientID, std::vector<obj>& list)
     226        void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list)
    226227        {
    227228
     
    230231          //compare listToProcess vs clientListPerm
    231232    //if listToProcess contains new Objects, add them to clientListPerm
    232     std::vector<obj>::iterator itvec;
     233    std::list<obj>::iterator itvec;
    233234   
    234235    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
     
    256257      //sort copied list according to priorities
    257258      // use boost bind here because we need to pass a memberfunction to stl sort
    258       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     259//       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     260      list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     261     
    259262//       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    260263
    261264      //now we check, that the creator of an object always exists on a client
    262       std::vector<obj>::iterator itcreator;
     265      std::list<obj>::iterator itcreator;
    263266      for(itvec = list.begin(); itvec != list.end(); itvec++)
    264267      {
     
    269272//       printList(list, clientID);
    270273      cut(list, targetSize);
    271 
    272274      //now sort again after objDataOffset
    273       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     275//       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     276      list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
    274277    }
    275278    //diese Funktion updateClientList muss noch gemacht werden
     
    278281  }
    279282
    280   void TrafficControl::printList(std::vector<obj>& list, unsigned int clientID)
    281   {
    282     std::vector<obj>::iterator it;
     283  void TrafficControl::printList(std::list<obj>& list, unsigned int clientID)
     284  {
     285    std::list<obj>::iterator it;
    283286    COUT(0) << "=========== Objectlist ===========" << endl;
    284287    for( it=list.begin(); it!=list.end(); it++)
     
    286289  }
    287290
    288   void TrafficControl::fixCreatorDependencies(std::vector<obj>::iterator it1, std::vector<obj>& list, unsigned int clientID)
     291  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
    289292  {
    290293    if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
     
    292295    if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
    293296      return;
    294     std::vector<obj>::iterator it2, it3=it1;
     297    std::list<obj>::iterator it2, it3=it1;
    295298    for( it2 = ++it3; it2 != list.end(); it2++ )
    296299    {
  • code/branches/netp3/src/network/TrafficControl.h

    r3015 r3083  
    3232
    3333#include <string>
    34 #include <vector>
     34#include <list>
    3535#include <map>
    3636#include <utility>
     
    9191    *temporary client list: contains client ids, gamestate ids and object ids (in this order)
    9292    */
    93     std::map<unsigned int, std::map<unsigned int, std::vector<obj> > > clientListTemp_;
     93    std::map<unsigned int, std::map<unsigned int, std::list<obj> > > clientListTemp_;
    9494
    9595    /**updateReferenceList
     
    103103    void insertinClientListPerm(unsigned int clientID, obj objinf);
    104104   
    105     void cut(std::vector<obj>& list, unsigned int targetsize);
    106     void updateClientListTemp(std::vector<obj>& list);//done
     105    void cut(std::list<obj>& list, unsigned int targetsize);
     106    void updateClientListTemp(std::list<obj>& list);//done
    107107    /**
    108108    *evaluates Data given (list) and produces result(->Data to be updated)
    109109    */
    110     void evaluateList(unsigned int clientID, std::vector<obj>& list);//done   
     110    void evaluateList(unsigned int clientID, std::list<obj>& list);//done   
    111111    void ack(unsigned int clientID, unsigned int gamestateID);  // this function gets called when the server receives an ack from the client
    112112   
     
    130130    void setConfigValues();
    131131    static TrafficControl *getInstance();
    132     void processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it
     132    void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it
    133133    static void processAck(unsigned int clientID, unsigned int gamestateID)
    134134    { return instance_->ack(clientID, gamestateID); }
     
    137137    bool prioritySort(uint32_t clientID, obj i, obj j);
    138138    bool dataSort(obj i, obj j);
    139     void printList(std::vector<obj>& list, unsigned int clientID);
    140     void fixCreatorDependencies(std::vector<obj>::iterator it, std::vector<obj>& list, unsigned int clientID);
     139    void printList(std::list<obj>& list, unsigned int clientID);
     140    void fixCreatorDependencies(std::list<obj>::iterator it, std::list<obj>& list, unsigned int clientID);
    141141};
    142142
  • code/branches/netp3/src/network/packet/Gamestate.cc

    r3047 r3083  
    182182#ifndef NDEBUG
    183183  if(this->getID()%1000==0){
    184     std::vector<uint32_t> v1;
     184    std::list<uint32_t> v1;
    185185    ObjectList<Synchronisable>::iterator it;
    186186    for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
     
    194194      }
    195195      else {
    196         std::vector<uint32_t>::iterator it2;
     196        std::list<uint32_t>::iterator it2;
    197197        for (it2 = v1.begin(); it2 != v1.end(); ++it2) {
    198198          if (it->getObjectID() == *it2) {
     
    412412Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
    413413  assert(data_);
    414   std::vector<obj>::iterator it;
     414  std::list<obj>::iterator it;
    415415
    416416  // allocate memory for new data
     
    434434
    435435  //copy in the zeros
     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;
    436441  for(it=dataVector_.begin(); it!=dataVector_.end();){
    437442    SynchronisableHeader oldobjectheader(origdata);
  • code/branches/netp3/src/network/packet/Gamestate.h

    r3047 r3083  
    129129  private:
    130130    uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
    131     std::vector<obj> dataVector_;
     131    std::list<obj> dataVector_;
    132132    GamestateHeader* header_;
    133133};
Note: See TracChangeset for help on using the changeset viewer.