Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2230


Ignore:
Timestamp:
Nov 19, 2008, 5:15:32 PM (16 years ago)
Author:
chpeter
Message:

traffic tool network

File:
1 edited

Legend:

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

    r2052 r2230  
    3333namespace network {
    3434
     35/**
     36*Initializing protected members
     37*/
    3538TrafficControl *TraffiControl::instance_=0;
    3639
     
    4245  assert(instance_=0);
    4346  instance_=this;
    44 
    45 
     47  clientListPerm_=new std::map<unsigned int,std::map<unsigned int, unsigned int>>;
     48  referenceList_=new std::map<unsigned int, Synchronisable*>;
    4649}
    47 
    4850
    4951/**
     
    5355{
    5456  instance_=0;
     57}
     58
     59/**
     60*Definition of public members
     61*/
     62
     63TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<unsigned> *list)
     64{
     65  currentClientID=clientID;
     66  currentGamestateID=gamestateID;
     67  list = evaluateList(list);
     68  return list;
     69}
     70
     71/**
     72*Definition of private members
     73*/
     74
     75//brauch ich die noch??
     76TrafficControl::createReferenceList(Synchronisable *list)
     77{
     78  map<unsigned int, Synchronisable*>::iterator itref;
     79  itref=referenceList_->begin();
     80  referenceList_->insert(itref,pair<unsigned int, Synchronisable*>(itref->getObjectID,itref->getSynchronisable));
     81}
     82//end brauch ich die noch
     83
     84/**
     85*copyList gets vector of Gamestate Manager and turns it to *listToProcess
     86*/
     87TrafficControl::copyList(std::map<obj> *list)
     88{
     89  listToProcess_=new std::map<unsigned int,std::map<unsigned int, unsigned int>>;
     90  vector<obj>::iterator itvec;
     91  for(itvec = list->begin(); itvec < list->end(); itvec++)
     92  {
     93   objInfo * objectA = new objInfo;
     94   objectA.objCreatorID=*itvec.objCreatorID;
     95   objectA.objSize = *itvec.objSize;
     96   listToProcess_->insert(pair<currentClientID, map<*itvec.objID,objectA>)//unsicher: ob map<...> so richtig ist
     97  }
     98}
     99/**
     100*updateReferenceList compares the sent list by GSmanager with *the current reference list and updates it.
     101*returns void
     102*/
     103TrafficControl::updateReferenceList(std::map<unsigned int, objInfo> *list)
     104{
     105  map<unsigned int, Synchronisable*>::iterator itref;
     106  map<unsigned int, objInfo>::iterator itproc;
     107  for(itproc=listToProcess_->begin();itproc != listToProcess_->.end(); itproc++)
     108  {
     109    //itproc->first=objectid that is looked for
     110    if(referenceList_->find(itproc->first))
     111    {
     112      continue;
     113    }
     114    else
     115    {
     116      referenceList_->insert(pair<unsigned int, Synchronisable*>(itproc->first,Synchronisable::getSynchronisable(itproc->first));
     117      insertinClientListPerm(itproc->first,itproc->second);
     118    }
     119  }
     120}
     121/**
     122*updateClientListPerm
     123*returns void
     124*/
     125TrafficControl::insertinClientListPerm(unsigned int objid, objInfo objinf)
     126{
     127  clientListPerm_->insert(pair<unsigned int,objInfo>(objid,objinf));
     128}
     129
     130
     131/**
     132*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
     133*/
     134TrafficControl::evaluateList(std::map<obj> *list)
     135{
     136  copyList(list);
     137  updateReferenceList(listToProcess_);
     138
     139  //now the sorting
     140 
     141  //end of sorting
     142  return evaluatedList_;
    55143}
    56144
Note: See TracChangeset for help on using the changeset viewer.