[Orxonox-commit 535] r3083 - in branches/netp3/src/network: . packet
scheusso at orxonox.net
scheusso at orxonox.net
Tue May 26 20:11:37 CEST 2009
Author: scheusso
Date: 2009-05-26 20:11:37 +0200 (Tue, 26 May 2009)
New Revision: 3083
Modified:
branches/netp3/src/network/Client.cc
branches/netp3/src/network/TrafficControl.cc
branches/netp3/src/network/TrafficControl.h
branches/netp3/src/network/packet/Gamestate.cc
branches/netp3/src/network/packet/Gamestate.h
Log:
some changes/fixes in gamestates and trafficcontrol
Modified: branches/netp3/src/network/Client.cc
===================================================================
--- branches/netp3/src/network/Client.cc 2009-05-26 17:29:40 UTC (rev 3082)
+++ branches/netp3/src/network/Client.cc 2009-05-26 18:11:37 UTC (rev 3083)
@@ -148,7 +148,7 @@
if(client_connection.isConnected() && isSynched_){
COUT(4) << "popping partial gamestate: " << std::endl;
packet::Gamestate *gs = gamestate.getGamestate();
- assert(gs);
+ //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
if(gs){
COUT(4) << "client tick: sending gs " << gs << std::endl;
if( !gs->send() )
Modified: branches/netp3/src/network/TrafficControl.cc
===================================================================
--- branches/netp3/src/network/TrafficControl.cc 2009-05-26 17:29:40 UTC (rev 3082)
+++ branches/netp3/src/network/TrafficControl.cc 2009-05-26 18:11:37 UTC (rev 3083)
@@ -120,7 +120,7 @@
- void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>& list)
+ void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list)
{
currentClientID=clientID;
currentGamestateID=gamestateID;
@@ -136,7 +136,7 @@
void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
{
- std::vector<obj>::iterator itvec; // iterator to iterate through the acked objects
+ std::list<obj>::iterator itvec; // iterator to iterate through the acked objects
//assertions to make sure the maps already exist
assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
@@ -145,7 +145,7 @@
// shortcut for maps
std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
- std::map<unsigned int, std::vector<obj> >& objectListTemp = clientListTemp_[clientID];
+ std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID];
for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
{
@@ -186,19 +186,19 @@
* updateClientListTemp
* takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
*/
- void TrafficControl::updateClientListTemp(std::vector<obj>& list)
+ void TrafficControl::updateClientListTemp(std::list<obj>& list)
{
- clientListTemp_[currentClientID][currentGamestateID] = std::vector<obj>(list);
+ clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(list);
}
/**
*cut
*takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
*/
- void TrafficControl::cut(std::vector<obj>& list, unsigned int targetsize)
+ void TrafficControl::cut(std::list<obj>& list, unsigned int targetsize)
{
unsigned int size=0;
- std::vector<obj>::iterator itvec, ittemp;
+ std::list<obj>::iterator itvec, ittemp;
assert(!list.empty());
for(itvec = list.begin(); itvec != list.end();)
{
@@ -211,7 +211,8 @@
else
{
clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
- list.erase(itvec++);
+ list.erase(itvec, list.end());
+ break;
}
// printList(list, currentClientID);
}
@@ -222,14 +223,14 @@
/**
*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
*/
- void TrafficControl::evaluateList(unsigned int clientID, std::vector<obj>& list)
+ void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list)
{
//now the sorting
//compare listToProcess vs clientListPerm
//if listToProcess contains new Objects, add them to clientListPerm
- std::vector<obj>::iterator itvec;
+ std::list<obj>::iterator itvec;
std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
@@ -255,11 +256,13 @@
{
//sort copied list according to priorities
// use boost bind here because we need to pass a memberfunction to stl sort
- sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+// sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+ list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+
// list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
//now we check, that the creator of an object always exists on a client
- std::vector<obj>::iterator itcreator;
+ std::list<obj>::iterator itcreator;
for(itvec = list.begin(); itvec != list.end(); itvec++)
{
fixCreatorDependencies(itvec, list, clientID);
@@ -268,30 +271,30 @@
//now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden.
// printList(list, clientID);
cut(list, targetSize);
-
//now sort again after objDataOffset
- sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
+// sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
+ list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
}
//diese Funktion updateClientList muss noch gemacht werden
updateClientListTemp(list);
//end of sorting
}
- void TrafficControl::printList(std::vector<obj>& list, unsigned int clientID)
+ void TrafficControl::printList(std::list<obj>& list, unsigned int clientID)
{
- std::vector<obj>::iterator it;
+ std::list<obj>::iterator it;
COUT(0) << "=========== Objectlist ===========" << endl;
for( it=list.begin(); it!=list.end(); it++)
COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
}
- void TrafficControl::fixCreatorDependencies(std::vector<obj>::iterator it1, std::vector<obj>& list, unsigned int clientID)
+ void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
{
if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
return;
if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
return;
- std::vector<obj>::iterator it2, it3=it1;
+ std::list<obj>::iterator it2, it3=it1;
for( it2 = ++it3; it2 != list.end(); it2++ )
{
if( (*it2).objID == (*it1).objCreatorID )
Modified: branches/netp3/src/network/TrafficControl.h
===================================================================
--- branches/netp3/src/network/TrafficControl.h 2009-05-26 17:29:40 UTC (rev 3082)
+++ branches/netp3/src/network/TrafficControl.h 2009-05-26 18:11:37 UTC (rev 3083)
@@ -31,7 +31,7 @@
#include "NetworkPrereqs.h"
#include <string>
-#include <vector>
+#include <list>
#include <map>
#include <utility>
#include <algorithm>
@@ -90,7 +90,7 @@
/**
*temporary client list: contains client ids, gamestate ids and object ids (in this order)
*/
- std::map<unsigned int, std::map<unsigned int, std::vector<obj> > > clientListTemp_;
+ std::map<unsigned int, std::map<unsigned int, std::list<obj> > > clientListTemp_;
/**updateReferenceList
*currentGamestateID and currentClientID will be defined as soon as TrafficControl is being called by Server
@@ -102,12 +102,12 @@
void insertinClientListPerm(unsigned int clientID, obj objinf);
- void cut(std::vector<obj>& list, unsigned int targetsize);
- void updateClientListTemp(std::vector<obj>& list);//done
+ void cut(std::list<obj>& list, unsigned int targetsize);
+ void updateClientListTemp(std::list<obj>& list);//done
/**
*evaluates Data given (list) and produces result(->Data to be updated)
*/
- void evaluateList(unsigned int clientID, std::vector<obj>& list);//done
+ void evaluateList(unsigned int clientID, std::list<obj>& list);//done
void ack(unsigned int clientID, unsigned int gamestateID); // this function gets called when the server receives an ack from the client
//ClientConnectionListener functions
@@ -129,15 +129,15 @@
*/
void setConfigValues();
static TrafficControl *getInstance();
- void processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it
+ void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it
static void processAck(unsigned int clientID, unsigned int gamestateID)
{ return instance_->ack(clientID, gamestateID); }
void deleteObject(unsigned int objectID); // this function gets called when an object has been deleted (in order to clean up lists and maps)
bool prioritySort(uint32_t clientID, obj i, obj j);
bool dataSort(obj i, obj j);
- void printList(std::vector<obj>& list, unsigned int clientID);
- void fixCreatorDependencies(std::vector<obj>::iterator it, std::vector<obj>& list, unsigned int clientID);
+ void printList(std::list<obj>& list, unsigned int clientID);
+ void fixCreatorDependencies(std::list<obj>::iterator it, std::list<obj>& list, unsigned int clientID);
};
}
Modified: branches/netp3/src/network/packet/Gamestate.cc
===================================================================
--- branches/netp3/src/network/packet/Gamestate.cc 2009-05-26 17:29:40 UTC (rev 3082)
+++ branches/netp3/src/network/packet/Gamestate.cc 2009-05-26 18:11:37 UTC (rev 3083)
@@ -181,7 +181,7 @@
// In debug mode, check first, whether there are no duplicate objectIDs
#ifndef NDEBUG
if(this->getID()%1000==0){
- std::vector<uint32_t> v1;
+ std::list<uint32_t> v1;
ObjectList<Synchronisable>::iterator it;
for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
if (it->getObjectID() == OBJECTID_UNKNOWN) {
@@ -193,7 +193,7 @@
}
}
else {
- std::vector<uint32_t>::iterator it2;
+ std::list<uint32_t>::iterator it2;
for (it2 = v1.begin(); it2 != v1.end(); ++it2) {
if (it->getObjectID() == *it2) {
COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
@@ -411,7 +411,7 @@
Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
assert(data_);
- std::vector<obj>::iterator it;
+ std::list<obj>::iterator it;
// allocate memory for new data
uint8_t *gdata = new uint8_t[header_->getDataSize()+GamestateHeader::getSize()];
@@ -433,6 +433,11 @@
TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), dataVector_ );
//copy in the zeros
+// std::list<obj>::iterator itt;
+// COUT(0) << "myvector contains:";
+// for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
+// COUT(0) << " " << (*itt).objID;
+// COUT(0) << endl;
for(it=dataVector_.begin(); it!=dataVector_.end();){
SynchronisableHeader oldobjectheader(origdata);
SynchronisableHeader newobjectheader(newdata);
Modified: branches/netp3/src/network/packet/Gamestate.h
===================================================================
--- branches/netp3/src/network/packet/Gamestate.h 2009-05-26 17:29:40 UTC (rev 3082)
+++ branches/netp3/src/network/packet/Gamestate.h 2009-05-26 18:11:37 UTC (rev 3083)
@@ -128,7 +128,7 @@
private:
uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
- std::vector<obj> dataVector_;
+ std::list<obj> dataVector_;
GamestateHeader* header_;
};
More information about the Orxonox-commit
mailing list