Changeset 2231 for code/branches/network
- Timestamp:
- Nov 19, 2008, 5:16:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/TrafficControl.h
r2052 r2231 32 32 #include <vector> 33 33 #include <map> 34 #include <utility> 34 35 35 36 #include "NetworkPrereqs.h" … … 38 39 namespace network { 39 40 41 // Synchronisable *bla = Synchronisable::getSynchronisable(objectID); 42 43 /** 44 *a vector of objects of this type will be given by the Server's Gamestate Manager 45 */ 46 struct objInfo 47 { 48 unsigned int objCreatorID; 49 unsigned int objCurGS;//current GameState ID 50 unsigned int objDiffGS;//difference between current and latest GameState 51 unsigned int objSize; 52 }; 53 54 /** 55 *a vector of objects of this type will be given by the Server's Gamestate Manager 56 */ 57 struct obj 58 { 59 unsigned int objID; 60 unsigned int objCreatorID; 61 unsigned int objSize; 62 }; 63 64 40 65 /** 41 66 * 42 67 */ 43 class _NetworkExport Host{68 class TrafficControl{ 44 69 private: 70 71 //start: lists to be used 72 /** 73 *creates list (typ map) that contains objids, struct with info concerning object(objid) 74 */ 75 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 76 /** 77 *reference list: contains object ids and the reference belonging to this id. 78 */ 79 std::map<unsigned int, Synchronisable*> *referenceList_;//has to be created with constructor and then needs to be updated by evaluateList(). 80 /** 81 *permanent client list: contains client ids, gamestate ids and object ids (in this order) 82 */ 83 std::map<unsigned int, objInfo> *clientListPerm_; //has to be created with constructor and then needs to be updated by evaluateList(). 84 /** 85 *temporary client list: contains client ids, gamestate ids and object ids (in this order) 86 */ 87 std::map<unsigned int,std::map<unsigned int, unsigned int>> *clientListTemp_; 88 /** 89 *static priority list: contains obj id, basic priority (in this order) 90 */ 91 std::map<unsigned int, unsigned int> *permObjPrio_; 92 /** 93 *dynamic priority list: contains obj id, dynamic priority (eg scheduled) (in this order) 94 */ 95 std::map<unsigned int, unsigned int> *schedObjPrio_; 96 //end: lists to be used 97 98 /** 99 *currentGamestateID and currentClientID will be defined as soon as TrafficControl is being called by Server 100 */ 101 unsigned int currentGamestateID; 102 unsigned int currentClientID; 103 104 void updateReferenceList(std::map<unsigned int, objInfo> *list); 105 void insertinClientListPerm(unsigned int objid, objInfo objinf); 106 /** 107 *creates listToProcess, which can be easialy compared with other lists 108 */ 109 void copyList(std::vector<obj> *list); 110 /** 111 *copies Data to be updated into vector, therefore vector can trashed by server 112 */ 113 std::vector<unsigned int>* copyBackList(std::map<unsigned int,Synchronisable*>); 114 /** 115 *evaluates Data given (vector) and produces result(->Data to be updated) 116 */ 117 void evaluateList(std::map<obj> *list); 118 45 119 46 120 … … 48 122 protected: 49 123 TrafficControl(); 50 virtual ~TrafficControl(); 124 virtual ~TrafficControl();//virtual because??? 51 125 static TrafficControl *instance_; 52 126 53 127 public: 54 void processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<unsigned int> *list); //gets a pointer to the vector (containing objectIDs) and sorts it 128 /** 129 *is being used by GSManager from Server: 130 *vector contains: ObjIds, CreatorIds, Size (in this order) from Client XY 131 *Elements of vector are accessed by *list[i] 132 *Elements of struct i are therefore: *list[i].objID 133 */ 134 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 55 135 void processAck(unsigned int clientID, unsigned int gamestateID); // this function gets called when the server receives an ack from the client 56 136 void deleteObject(unsigned int objectID); // this function gets called when an object has been deleted (in order to clean up lists and maps)
Note: See TracChangeset
for help on using the changeset viewer.