Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 26, 2008, 5:00:33 PM (16 years ago)
Author:
chpeter
Message:

network traffic current progress

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

Legend:

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

    r2230 r2276  
    6161*/
    6262
    63 TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<unsigned> *list)
     63TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list)
    6464{
    6565  currentClientID=clientID;
     
    136136  copyList(list);
    137137  updateReferenceList(listToProcess_);
    138 
     138 
    139139  //now the sorting
     140
     141  //compare listToProcess vs clientListPerm
     142  map<unsigned int, objInfo>::iterator itproc;
     143  map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;
     144  map<unsigned int, objInfo>::iterator itpermobj;
     145  map<unsigned int, unsigned int>::iterator itpermprio
     146  for(itproc=listToProcess_->begin(); itproc != listToProcess_->end();it++)
     147  {
     148    itperm=clientListPerm->find(currentClientID);
     149    itpermobj=itperm->find(itproc->first);
     150    if(currentGamestateID < (itpermobj->second).objCurGS)
     151    {
     152      //obj bleibt in liste und permanente prio wird berechnet
     153      (itpermobj->second).objDiffGS = (itpermobj->second).objCurGS - currentGamestateID;
     154      itpermprio = permObjPrio_->find(itproc->first);
     155      (itpermobj->second).objValuePerm = (itpermobj->second).objDiffGS * itpermprio->second;
     156      continue;//check next objId
     157    }
     158    else
     159    {
     160      listToProcess_->erase (itproc);
     161    }
     162  }
     163  //end compare listToProcess vs clientListPerm
     164
     165  //listToProc vs clientListTemp
     166  map<unsigned int, std::map<unsigned int, unsigned int>>::iterator ittemp;
     167  map<unsigned int, unsigned int>::iterator ittempgs;
     168  for(itproc=listToProcess_->begin(); itproc != listToProcess_->end();it++)
     169  {
     170    ittemp = clientListTemp_->find(currentClientID);
     171    if(ittempgs = ittemp->find(currentGamestateID))
     172    {
     173      if(itproc->first == ittempgs->find(itproc->first))
     174      {
     175        listToProcess_->erase (itproc);
     176      }
     177      else continue;
     178    }
     179    else continue;
     180  }
     181  //end listToProc vs clientListTemp
    140182 
     183  //listToProcess contains obj to send now, shorten copiedvector therefor too.
     184  vector<obj>::iterator itvec;
     185  for(itvec = copiedvector.begin(); itvec < copiedvector.end(); itvec++)
     186  {
     187    if(listToProcess_->find(itvec->objID))
     188    {
     189      continue;
     190    }
     191    else
     192    {
     193      copiedvector.remove(itvec);
     194    }
     195  }
     196  //sort copied vector aufgrund der objprioperm in clientlistperm
     197  sort(copiedvector.begin(),copiedvector.end(),priodiffer);
     198  //swappen aufgrund von creator oder ganz rausnehmen!?
     199
    141200  //end of sorting
    142201  return evaluatedList_;
  • code/branches/network/src/network/TrafficControl.h

    r2231 r2276  
    3333#include <map>
    3434#include <utility>
     35#include <algorithm>
    3536
    3637#include "NetworkPrereqs.h"
     
    4041
    4142// Synchronisable *bla = Synchronisable::getSynchronisable(objectID);
     43
     44//stuff to iterate through:  map<unsigned int, objInfo>::iterator itproc;
     45//   map<unsigned int, Synchronisable>::iterator itref;
     46//   for(it=listToProcess_->begin(); it != listToProcess_->end();it++)
     47//   {
     48//   
     49//     itref=referenceList_->find((*itproc).first);
     50//     refCurObj=(*itref).second;
    4251
    4352/**
     
    5059  unsigned int objDiffGS;//difference between current and latest GameState
    5160  unsigned int objSize;
     61  unsigned int objValuePerm;
     62  unsigned int objValueSched;
    5263};
    5364
     
    6273};
    6374
     75/**
     76*eigener sortieralgorithmus
     77*/
     78bool priodiffer(obj i, obj j)
     79{
     80  map<unsigned int, objInfo>::iterator iti;
     81  map<unsigned int, objInfo>::iterator itj;
     82  iti=listToProcess_->find(i.objID);
     83  itj=listToProcess_->find(j.objID);
     84  return iti->second.objValuePerm < itj->second.objValuePerm;
     85}
    6486
    6587/**
     
    7799    *reference list: contains object ids and the reference belonging to this id.
    78100    */
    79     std::map<unsigned int, Synchronisable*> *referenceList_;//has to be created with constructor and then needs to be updated by evaluateList().
     101//     std::map<unsigned int, Synchronisable*> *referenceList_;//has to be created with constructor and then needs to be updated by evaluateList().
    80102    /**
    81103    *permanent client list: contains client ids, gamestate ids and object ids (in this order)
    82104    */
    83     std::map<unsigned int, objInfo> *clientListPerm_; //has to be created with constructor and then needs to be updated by evaluateList().
     105    std::map<unsigned int, std::map<unsigned int, objInfo>> *clientListPerm_;
     106    //has to be created with constructor and then needs to be updated by evaluateList().
     107
    84108    /**
    85109    *temporary client list: contains client ids, gamestate ids and object ids (in this order)
    86110    */
    87     std::map<unsigned int,std::map<unsigned int, unsigned int>> *clientListTemp_;
     111    std::map<unsigned int, std::map<unsigned int, std::vector<obj>>> *clientListTemp_;
    88112    /**
    89113    *static priority list: contains obj id, basic priority (in this order)
     
    101125    unsigned int currentGamestateID;
    102126    unsigned int currentClientID;
     127    Synchronisable *refCurObj;//reference to current object, uninitialized yet, do I have to or can I just set refCurObj=...; later on?
     128    //not used yet anyway
     129    std::vector<obj> copiedVector; //copy of original that I get from GSmanager
    103130
    104131    void updateReferenceList(std::map<unsigned int, objInfo> *list);
Note: See TracChangeset for help on using the changeset viewer.