Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2008, 10:57:09 PM (15 years ago)
Author:
scheusso
Message:

some changes. still not working yet, but will correct theese problems after merge with network64

File:
1 edited

Legend:

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

    r2348 r2351  
    3131#include <cassert>
    3232#include <boost/bind.hpp>
    33 #include "Synchronisable.h"
    34 #include "ClientInformation.h"
    3533
    3634namespace network {
     
    8684    assert(clientListPerm_[clientID].find(j.objID) != clientListPerm_[clientID].end()); // make sure the object j is in the client list
    8785   
    88     return clientListPerm_[clientID][i.objID].objID < clientListPerm_[clientID][j.objID].objID;
     86    int prio1 = clientListPerm_[clientID][i.objID].objValuePerm + clientListPerm_[clientID][i.objID].objValueSched;
     87    int prio2 = clientListPerm_[clientID][j.objID].objValuePerm + clientListPerm_[clientID][j.objID].objValueSched;
     88    // NOTE: smaller priority is better
     89    return prio1 < prio2;
    8990  }
    9091
    9192
    92         std::vector<obj>* TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list)
     93        void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list)
    9394        {
    94           copiedVector = *list;
     95//        copiedVector = *list;
    9596          currentClientID=clientID;
    9697          currentGamestateID=gamestateID;
    9798          evaluateList(clientID, list);
    9899          //list hatte vorher ja vielmehr elemente, nach zuweisung nicht mehr... speicherplatz??
    99           *list=copiedVector;
     100//        *list=copiedVector;
    100101    //später wird copiedVector ja überschrieben, ist das ein problem für list-dh. für gamestatemanager?
    101           return list;
     102          return;
    102103        }
    103104       
     
    212213    std::vector<obj>::iterator itvec;
    213214    itvec = list->begin();
    214 //     unsigned int i=0;
    215215    for(itvec = list->begin(); itvec != list->end() && size<targetsize; itvec++)
    216 //     while(size<targetsize && (itvec!=list.end()))
    217216    {
    218       size = size + (*itvec).objSize;//objSize is given in bytes!??
    219 //       i++;
    220 //       itvec = list.begin()+i;
     217      if ( size + (*itvec).objSize < targetsize )
     218      {
     219        size = size + (*itvec).objSize;//objSize is given in bytes
     220      }
     221      else
     222      {
     223        clientListPerm_[currentClientID][(*itvec).objID].objValueSched -= SCHED_PRIORITY_OFFSET;
     224        list->erase(itvec++);
     225      }
    221226    }
    222     list->erase(itvec, list->end());
    223227  }
    224228
     
    235239          //compare listToProcess vs clientListPerm
    236240    //if listToProcess contains new Objects, add them to clientListPerm
    237           std::map<unsigned int, objInfo>::iterator itproc;
     241//        std::map<unsigned int, objInfo>::iterator itproc;
    238242    std::vector<obj>::iterator itvec;
    239           std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm;
     243//        std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm;
    240244//        std::map<unsigned int, objInfo>::iterator itpermobj;
    241           unsigned int permprio;
    242245          for( itvec=list->begin(); itvec != list->end(); itvec++)
    243246          {
    244             itperm = clientListPerm_.find(clientID);
     247//          itperm = clientListPerm_.find(clientID);
    245248            if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )
    246249      {
     
    306309    // use boost bind here because we need to pass a memberfunction to stl sort
    307310    sort(list->begin(), list->end(), boost::bind(&TrafficControl::priodiffer, this, clientID, _1, _2) );
    308     //swappen aufgrund von creator oder ganz rausnehmen!?
     311   
     312    //now we check, that the creator of an object always exists on a client
     313    std::vector<obj>::iterator itcreator;
    309314    for(itvec = list->begin(); itvec != list->end(); itvec++)
    310315    {
    311       //TODO: TODO TODO TODO
    312       itproc = (listToProcess_).find((*itvec).objID);
    313       if((*itproc).second.objCreatorID)
    314       {
    315       //vor dem child in copiedvector einfügen, wie?
    316         copiedVector.insert(copiedVector.find((*itproc).first),(*itproc).second.objCreatorID);
    317       }
    318       else continue;
     316      if ( (*itvec).objCreatorID != OBJECTID_UNKNOWN )
     317      {
     318        if( clientListPerm_[clientID][(*itvec).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
     319          continue;
     320        for( itcreator = list->begin(); itcreator != list->end(); itcreator++)
     321        {
     322          if ( (*itcreator).objID == (*itvec).objCreatorID )
     323            break;
     324        }
     325        // if the creator is before the object everything is fine
     326        if( itcreator < itvec )
     327          continue;
     328        // otherwise insert the creator right before our object and delete it at the old position
     329        list->insert(itvec, *itcreator);
     330        list->erase(itcreator);
     331      }
    319332    }
    320333    //end of sorting
    321334    //now the cutting, work the same obj out in processobjectlist and copiedvector, compression rate muss noch festgelegt werden.
    322     cut(copiedVector,targetSize);
     335    cut(list, targetSize);
    323336    //diese Funktion updateClientList muss noch gemacht werden
    324337    updateClientListTemp(list);
    325338    //end of sorting
    326339  }
    327 
    328340
    329341
Note: See TracChangeset for help on using the changeset viewer.