Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/TrafficControl.h @ 2341

Last change on this file since 2341 was 2341, checked in by scheusso, 15 years ago

made some changes, but now yet complete

File size: 4.9 KB
RevLine 
[2052]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
24 *   Co-authors:
25 *      ...
26 *
27 */
28#ifndef NETWORKTRAFFICCONTROL_H
29#define NETWORKTRAFFICCONTROL_H
30
31#include <string>
32#include <vector>
33#include <map>
[2231]34#include <utility>
[2276]35#include <algorithm>
[2052]36
37#include "NetworkPrereqs.h"
38#include "Synchronisable.h"
[2341]39#include "util/Integers.h"
[2052]40
41namespace network {
42
43/**
[2231]44*a vector of objects of this type will be given by the Server's Gamestate Manager
45*/
46struct objInfo
47{
[2341]48  uint32_t objID;
49  uint32_t objCreatorID;
50  int32_t objCurGS;//current GameState ID
51  int32_t objDiffGS;//difference between current and latest GameState
52  uint32_t objSize;
[2276]53  unsigned int objValuePerm;
54  unsigned int objValueSched;
[2231]55};
56
57/**
58*a vector of objects of this type will be given by the Server's Gamestate Manager
59*/
60struct obj
61{
62  unsigned int objID;
63  unsigned int objCreatorID;
64  unsigned int objSize;
65};
66
67
[2334]68
[2231]69/**
[2052]70*
71*/
[2231]72class TrafficControl{
[2052]73  private:
74
[2332]75    /**
76    *Lists that will be used:
77    *listToProcess
78    *clientListPerm
79    *clientListTemp
80    *referenceList
81    *permObjPrio list
82    *schedObjPrio
83    */
[2231]84    //start: lists to be used
85    /**
86    *creates list (typ map) that contains objids, struct with info concerning object(objid)
87    */
[2332]88    std::map<unsigned int, objInfo> listToProcess_;//copy of argument, when traffic control tool is being called, the original of this must be returned later on, eg the vector given by GS
[2231]89    /**
[2332]90    *permanent client list: contains client ids, object ids and objectInfos (in this order)
[2231]91    */
[2341]92    std::map<unsigned int, std::map<unsigned int, std::vector<objInfo> > > clientListPerm_;
[2276]93    //has to be created with constructor and then needs to be updated by evaluateList().
94
[2231]95    /**
96    *temporary client list: contains client ids, gamestate ids and object ids (in this order)
97    */
[2341]98    std::map<unsigned int, std::map<unsigned int, std::vector<obj> > > clientListTemp_;
[2231]99    /**
100    *static priority list: contains obj id, basic priority (in this order)
101    */
[2332]102    std::map<unsigned int, unsigned int> permObjPrio_;
[2231]103    /**
104    *dynamic priority list: contains obj id, dynamic priority (eg scheduled) (in this order)
105    */
[2332]106    std::map<unsigned int, unsigned int> schedObjPrio_;
[2231]107    //end: lists to be used
[2052]108
[2341]109    /**updateReferenceList
[2231]110    *currentGamestateID and currentClientID will be defined as soon as TrafficControl is being called by Server
111    */
112    unsigned int currentGamestateID;
113    unsigned int currentClientID;
[2340]114    unsigned int targetSize;
[2332]115    /**
116    *copiedVector is a copy of the given Vector by the GSmanager, on this vector all manipulations are performed
117    */
118    std::vector<obj> copiedVector;
[2052]119
[2332]120    void updateReferenceList(std::map<unsigned int, objInfo> *list);//done
[2340]121    void insertinClientListPerm(unsigned int clientid, unsigned int objid, objInfo objinf);//done
[2231]122    /**
123    *creates listToProcess, which can be easialy compared with other lists
124    */
[2332]125    void copyList(std::vector<obj> *list);//done
126   
[2340]127    void cut(std::vector<obj> *list,int targetsize);
128    void updateClientListTemp(std::vector<obj> *list);//done
[2231]129    /**
130    *evaluates Data given (vector) and produces result(->Data to be updated)
131    */
[2340]132    void evaluateList(std::vector<obj> *list);//done
[2231]133
[2052]134  protected:
135    TrafficControl();
[2231]136    virtual ~TrafficControl();//virtual because???
[2052]137    static TrafficControl *instance_;
138
139  public:
[2231]140    /**
141    *is being used by GSManager from Server:
142    *vector contains: ObjIds, CreatorIds, Size (in this order) from Client XY
143    *Elements of vector are accessed by *list[i]
144    *Elements of struct i are therefore: *list[i].objID
145    */
146    std::vector<obj>* processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>* list); //gets a pointer to the vector (containing objectIDs) and sorts it
[2332]147    //done
[2052]148    void processAck(unsigned int clientID, unsigned int gamestateID);   // this function gets called when the server receives an ack from the client
[2332]149    //done
[2052]150    void deleteObject(unsigned int objectID);                           // this function gets called when an object has been deleted (in order to clean up lists and maps)
[2334]151   
152    bool priodiffer(obj i, obj j);
[2052]153};
154
155}
156
157#endif
158
Note: See TracBrowser for help on using the repository browser.