Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2532


Ignore:
Timestamp:
Dec 23, 2008, 11:15:09 PM (16 years ago)
Author:
rgrieder
Message:

Merged revisions 2377-2382 to bugger from presentation.

Location:
code/branches/bugger/src/network
Files:
6 edited

Legend:

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

    r2531 r2532  
    5757  GamestateManager::GamestateManager() {
    5858    id_=0;
     59    trafficControl_ = new TrafficControl();
    5960  }
    6061
    6162  GamestateManager::~GamestateManager() {
     63    delete trafficControl_;
    6264  }
    6365
     
    185187    }
    186188    temp->setGamestateID(gamestateID);
     189    TrafficControl::processAck(clientID, gamestateID);
    187190    return true;
    188191  }
  • code/branches/bugger/src/network/GamestateManager.h

    r2171 r2532  
    4343#include "NetworkPrereqs.h"
    4444#include "GamestateHandler.h"
     45#include "TrafficControl.h"
    4546#include <map>
    4647
     
    8990    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    9091    packet::Gamestate *reference;
     92    TrafficControl *trafficControl_;
    9193    unsigned int id_;
    9294  };
  • code/branches/bugger/src/network/TrafficControl.cc

    r2531 r2532  
    3030
    3131#include "synchronisable/Synchronisable.h"
     32#include "core/ConfigValueIncludes.h"
    3233
    3334#include <cassert>
     
    6768        TrafficControl::TrafficControl()
    6869        {
     70    RegisterRootObject(TrafficControl);
    6971          assert(instance_==0);
    7072          instance_=this;
    71     targetSize = 1000;//5000bytes
     73//     targetSize = 2500;//5000bytes
     74    SetConfigValue ( targetSize, 28000./25. );
    7275        }
    7376       
     
    127130          return;
    128131        }
    129        
    130         void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)
     132 
     133  TrafficControl *TrafficControl::getInstance()
     134  {
     135    assert(instance_);
     136    return instance_;
     137  }
     138       
     139        void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
    131140        {
    132141          std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
     
    141150      if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
    142151      {
    143         clientListPerm_[clientID][(*itvec).objID].objID = gamestateID;
     152        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
     153        clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back
    144154      }
    145155      else
    146156      {
     157        assert(0);
    147158        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
    148159        clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
     
    225236//     for(itvec = list.begin(); itvec!=list.end(), itvec++)
    226237//     {
    227 //       ittempgs.insert(itvec);
     238//       ittempgs.insert(itvec);static
    228239//     }
    229240  }
     
    236247  {
    237248    unsigned int size=0;
    238     std::list<obj>::iterator itvec;
     249    std::list<obj>::iterator itvec, ittemp;
    239250    assert(!list->empty());
    240     itvec = list->begin();
    241     for(itvec = list->begin(); itvec != list->end() && size<targetsize; itvec++)
     251    for(itvec = list->begin(); itvec != list->end();)
    242252    {
    243253      assert( (*itvec).objSize < 1000);
    244       if ( size + (*itvec).objSize < targetsize )
    245       {
     254//       COUT(0) << "==targetsize==  " << targetsize << endl;
     255      if ( ( size + (*itvec).objSize ) < targetsize )
     256      {
     257//         COUT(0) << "no cut" << endl;
    246258        size += (*itvec).objSize;//objSize is given in bytes
     259        ++itvec;
    247260      }
    248261      else
    249262      {
    250         clientListPerm_[currentClientID][(*itvec).objID].objValueSched -= SCHED_PRIORITY_OFFSET;
     263//         COUT(0) << "cut" << endl;
     264        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
     265//         ittemp = itvec;
    251266        list->erase(itvec++);
    252       }
     267//         itvec = ittemp;
     268      }
     269//       printList(list, currentClientID);
    253270    }
    254271    assert(!list->empty());
     
    339356   
    340357    //now we check, that the creator of an object always exists on a client
    341     printList(list, clientID);
     358//     printList(list, clientID);
    342359    std::list<obj>::iterator itcreator;
    343360    for(itvec = list->begin(); itvec != list->end(); itvec++)
     
    348365    //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden.
    349366    cut(list, targetSize);
    350     printList(list, clientID);
     367//     printList(list, clientID);
    351368    //diese Funktion updateClientList muss noch gemacht werden
    352369    updateClientListTemp(list);
     
    359376    COUT(0) << "=========== Objectlist ===========" << endl;
    360377    for( it=list->begin(); it!=list->end(); it++)
    361       COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << endl;
     378      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
    362379  }
    363380 
  • code/branches/bugger/src/network/TrafficControl.h

    r2531 r2532  
    3737#include <algorithm>
    3838#include "util/Integers.h"
     39#include "core/OrxonoxClass.h"
    3940
    4041namespace orxonox {
     
    5253      uint32_t objDiffGS;//difference between current and latest GameState
    5354      uint32_t objSize;
    54       unsigned int objValuePerm;
    55       unsigned int objValueSched;
     55      int objValuePerm;
     56      int objValueSched;
    5657      objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched);
    5758      objInfo();
     
    7879*
    7980*/
    80 class TrafficControl{
     81class TrafficControl : public OrxonoxClass{
    8182  private:
    8283
     
    139140    */
    140141    void evaluateList(unsigned int clientID, std::list<obj> *list);//done   
     142    void ack(unsigned int clientID, unsigned int gamestateID);  // this function gets called when the server receives an ack from the client
    141143
    142144  protected:
     
    152154    *Elements of struct i are therefore: *list[i].objID
    153155    */
     156    static TrafficControl *getInstance();
    154157    void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>* list); //gets a pointer to the list (containing objectIDs) and sorts it
    155158    //done
    156     void processAck(unsigned int clientID, unsigned int gamestateID);   // this function gets called when the server receives an ack from the client
     159    static void processAck(unsigned int clientID, unsigned int gamestateID)
     160    { return instance_->ack(clientID, gamestateID); }
    157161    //done
    158162    void deleteObject(unsigned int objectID);                           // this function gets called when an object has been deleted (in order to clean up lists and maps)
  • code/branches/bugger/src/network/packet/Gamestate.cc

    r2531 r2532  
    5050
    5151#define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
    52  
    53 TrafficControl Gamestate::trafficControl_;
    5452
    5553Gamestate::Gamestate()
     
    362360
    363361  //call TrafficControl
    364   trafficControl_.processObjectList( clientID, HEADER->id, &dataMap_ );
     362  TrafficControl::getInstance()->processObjectList( clientID, HEADER->id, &dataMap_ );
    365363 
    366364  //copy in the zeros
  • code/branches/bugger/src/network/packet/Gamestate.h

    r2531 r2532  
    9595    void removeObject(ObjectListIterator<Synchronisable> &it);
    9696    std::list<obj> dataMap_;
    97     static TrafficControl trafficControl_;
     97//     static TrafficControl *trafficControl_;
    9898};
    9999
Note: See TracChangeset for help on using the changeset viewer.