Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2341


Ignore:
Timestamp:
Dec 4, 2008, 12:03:25 AM (15 years ago)
Author:
scheusso
Message:

made some changes, but now yet complete

Location:
code/branches/network/src/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/GamestateManager.cc

    r2035 r2341  
    135135      return 0;
    136136    gs = reference->doSelection(clientID);
    137 //     gs = new packet::Gamestate(*reference);
    138 //     gs = new packet::Gamestate(*reference);
    139137    // save the (undiffed) gamestate in the clients gamestate map
    140138    gamestateMap_[clientID].insert(std::pair<int, packet::Gamestate*>(gs->getID(), gs));
  • code/branches/network/src/network/TrafficControl.cc

    r2340 r2341  
    4646          assert(instance_=0);
    4747          instance_=this;
    48           listToProcess_ = new std::map<unsigned int, objInfo>;
    49           clientListPerm_ = new std::map<unsigned int,std::map<unsigned int, objInfo>>;
    50           clientListTemp_ = new std::map std::map<unsigned int, std::map<unsigned int, std::vector<obj>>>;
    51           permObjPrio_ = new std::map<unsigned int, unsigned int> ;
    52           schedObjPrio_ = new std::map<unsigned int, unsigned int> schedObjPrio_;
    53           copiedVector = new std::vector<obj>;
    54           targetSize = 5000;//5000bytes
     48    targetSize = 5000;//5000bytes
    5549        }
    5650       
     
    7468        bool TrafficControl::priodiffer(obj i, obj j)
    7569        {
    76           map<unsigned int, objInfo>::iterator iti;
    77           map<unsigned int, objInfo>::iterator itj;
    78           iti=listToProcess_->find(i.objID);
    79           itj=listToProcess_->find(j.objID);
     70          std::map<unsigned int, objInfo>::iterator iti;
     71          std::map<unsigned int, objInfo>::iterator itj;
     72          iti=listToProcess_.find(i.objID);
     73          itj=listToProcess_.find(j.objID);
    8074          return iti->second.objValuePerm < itj->second.objValuePerm;
    8175        }
     
    9084          evaluateList(list);
    9185          //list hatte vorher ja vielmehr elemente, nach zuweisung nicht mehr... speicherplatz??
    92           list=copiedVector;
     86          *list=copiedVector;
    9387          //später wird copiedVector ja überschrieben, ist das ein problem für list-dh. für gamestatemanager?
    9488          return list;
     
    9791        void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)
    9892        {
    99           map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm
    100           map<unsigned int, objInfo>::iterator itpermoid;//iterator over objectid
    101           map<unsigned int, std::map<unsigned int, obj>>::iterator ittemp;//iterator clientListTemp, iterates over clientIDs
    102           map<unsigned int, unsigned int>::iterator ittempgs;//iterator that iterates over gsIDs of a client
    103           vector<obj>::iterator itvec;
     93          std::map<unsigned int, std::map<unsigned int, std::vector<objInfo> > >::iterator itperm;//iterator clientListPerm
     94          std::map<unsigned int, std::vector<objInfo> >::iterator itpermObjectIDList;//iterator over objectid
     95    std::vector<objInfo>::iterator itpermObjectID;
     96    std::map<unsigned int, std::map<unsigned int, std::vector<obj> > >::iterator ittemp;//iterator clientListTemp, iterates over clientIDs
     97          std::map<unsigned int, std::vector<obj> >::iterator ittempgs;//iterator that iterates over gsIDs of a client
     98          std::vector<obj>::iterator itvec;
    10499          //following code helps to put clientListTemp infos into clientListPerm infos
    105           ittemp = (clientListTemp_).find(clientID);
    106           assert(ittemp != clientListTemp_.end() ); //muss da nicht was anderes überprüft werden?
    107           itperm = (clientListPerm_).find(clientID);
     100          ittemp = clientListTemp_.find(clientID);
     101          assert(ittemp != clientListTemp_.end() ); //muss da nicht was anderes überprüft werden? -> nein
     102          itperm = clientListPerm_.find(clientID);
    108103          assert(itperm != clientListPerm_.end() );
    109           ittempgs = (*ittemp).find(gamestateID);
    110           assert( ittempgs != (*ittemp).end() );//gleiche frage wie vorher
    111           for(itvec = *ittempgs.begin(); itvec = *ittempgs.end(); itvec++)
    112           {
    113             if(itpermoid = (*itperm).find(itvec.objID))
    114             {
    115               if(gamestateID>(*itpermoid).second.objCurGS)
    116               {
    117                 (*itpermoid).second.objCurGS = gamestateID;
    118               }
    119               else continue;
    120             }
    121             else
    122             {
    123               objInfo objinf = new objInfo;
    124               objinf.objCurGS = gamestateID;
    125               insertinClientListPerm(clientID, itvec.objID, objinf);
    126             }
    127             //entferne objekt aus temporärer liste
    128             ittempgs.erase(itvec);
    129           }
    130        
     104          ittempgs = ittemp->second.find(gamestateID);
     105          assert( ittempgs != ittemp->second.end() );//gleiche frage wie vorher -> nein
     106          for(itvec = ittempgs->second.begin(); itvec != ittempgs->second.end(); itvec++)
     107          {
     108      bool alreadyExisting = false;
     109      itpermObjectIDList = itperm->second.find(gamestateID);
     110      assert(itpermObjectIDList != itperm->second.end());
     111      for (itpermObjectID = itpermObjectIDList->second.begin(); itpermObjectID != itpermObjectIDList->second.end(); itpermObjectID++ )
     112      {
     113        if ( (*itpermObjectID).objID == (*itvec).objID)
     114        {
     115          (*itpermObjectID).objCurGS = gamestateID;
     116          alreadyExisting = true;
     117          break;
     118        }
     119        if ( !alreadyExisting )
     120        {
     121          objInfo objinf;    // TODO: is this initialisation complete ?
     122          objinf.objCurGS = gamestateID;
     123          objinf.objID = (*itvec).objID;
     124          insertinClientListPerm(clientID, (*itvec).objID, objinf);
     125        }
     126      }
     127          }
     128           // remove temporary vector (with acked objects) from the map
     129    ittemp->second.erase(ittempgs);
    131130        }
    132131
     
    139138        *copyList gets vector of Gamestate Manager and turns it to *listToProcess
    140139        */
    141         void TrafficControl::copyList(std::map<obj> *list)
    142         {
    143           vector<obj>::iterator itvec;
    144           for(itvec = (*list).begin(); itvec < (*list).end(); itvec++)
    145           {
    146             objInfo objectA = new objInfo;
    147             (*objectA).objCreatorID=(*itvec).objCreatorID;
    148             (*objectA).objSize = (*itvec).objSize;
    149             (*listToProcess_).insert(pair<currentClientID, map<(*itvec).objID,objectA>>);//unsicher: ob map<...> so richtig ist
     140        void TrafficControl::copyList(std::vector<obj> *list)
     141        {
     142          std::vector<obj>::iterator itvec;
     143          for(itvec = (*list).begin(); itvec != (*list).end(); itvec++)
     144          {
     145            objInfo objectA;
     146            objectA.objCreatorID=(*itvec).objCreatorID;
     147            objectA.objSize = (*itvec).objSize;
     148            listToProcess_.insert(pair<currentClientID, map<(*itvec).objID,objectA>>);//unsicher: ob map<...> so richtig ist
    150149          }
    151150        }
     
    228227        {
    229228          copyList(list);
    230           updateReferenceList(listToProcess_);
    231229       
    232230          //now the sorting
     
    235233          //if listToProcess contains new Objects, add them to clientListPerm
    236234          std::map<unsigned int, objInfo>::iterator itproc;
    237           std::map<unsigned int, std::map<unsigned int, objInfo>>::iterator itperm;
     235          std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm;
    238236          std::map<unsigned int, objInfo>::iterator itpermobj;
    239237          std::map<unsigned int, unsigned int>::iterator itpermprio;
     
    269267       
    270268        //listToProc vs clientListTemp
    271         map<unsigned int, std::map<unsigned int, unsigned int>>::iterator ittemp;
     269        map<unsigned int, std::map<unsigned int, unsigned int> >::iterator ittemp;
    272270        map<unsigned int, unsigned int>::iterator ittempgs;
    273271        for((itproc=listToProcess_).begin(); itproc != (listToProcess_).end();itproc++)
  • code/branches/network/src/network/TrafficControl.h

    r2340 r2341  
    3737#include "NetworkPrereqs.h"
    3838#include "Synchronisable.h"
     39#include "util/Integers.h"
    3940
    4041namespace network {
     
    4546struct objInfo
    4647{
    47   unsigned int objCreatorID;
    48   unsigned int objCurGS;//current GameState ID
    49   unsigned int objDiffGS;//difference between current and latest GameState
    50   unsigned int objSize;
     48  uint32_t objID;
     49  uint32_t objCreatorID;
     50  int32_t objCurGS;//current GameState ID
     51  int32_t objDiffGS;//difference between current and latest GameState
     52  uint32_t objSize;
    5153  unsigned int objValuePerm;
    5254  unsigned int objValueSched;
     
    8890    *permanent client list: contains client ids, object ids and objectInfos (in this order)
    8991    */
    90     std::map<unsigned int, std::map<unsigned int, objInfo>> clientListPerm_;
     92    std::map<unsigned int, std::map<unsigned int, std::vector<objInfo> > > clientListPerm_;
    9193    //has to be created with constructor and then needs to be updated by evaluateList().
    9294
     
    9496    *temporary client list: contains client ids, gamestate ids and object ids (in this order)
    9597    */
    96     std::map<unsigned int, std::map<unsigned int, std::vector<obj>>> clientListTemp_;
     98    std::map<unsigned int, std::map<unsigned int, std::vector<obj> > > clientListTemp_;
    9799    /**
    98100    *static priority list: contains obj id, basic priority (in this order)
     
    105107    //end: lists to be used
    106108
    107     /**
     109    /**updateReferenceList
    108110    *currentGamestateID and currentClientID will be defined as soon as TrafficControl is being called by Server
    109111    */
Note: See TracChangeset for help on using the changeset viewer.