Changeset 385 for code/branches/FICN/src/network
- Timestamp:
- Dec 5, 2007, 12:05:46 AM (17 years ago)
- Location:
- code/branches/FICN/src/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/GameStateManager.cc
r369 r385 118 118 * @return iterator pointing to the next object in the list 119 119 */ 120 // orxonox::Iterator<Synchronisable> removeObject(orxonox::Iterator<Synchronisable> it){121 120 void GameStateManager::removeObject(orxonox::Iterator<Synchronisable> &it){ 122 121 orxonox::Iterator<Synchronisable> temp=it; … … 126 125 } 127 126 127 GameState GameStateManager::encode(GameState a, GameState b){ 128 GameState r = diff(a,b); 129 return compress(r); 130 } 131 132 GameState GameStateManager::decode(GameState a, GameState x){ 133 GameState t = decompress(x); 134 return diff(a, t); 135 } 136 137 GameState GameStateManager::diff(GameState a, GameState b){ 138 unsigned char *ap = a.data, *bp = b.data; 139 int of=0; // pointers offset 140 int dest_length=0; 141 if(a.size>=b.size) 142 dest_length=a.size; 143 else 144 dest_length=b.size; 145 unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char)); 146 while(of<a.size && of<b.size){ 147 *(dp+of)=*(ap+of)^*(bp+of); // do the xor 148 ++of; 149 } 150 if(a.size!=b.size){ // do we have to fill up ? 151 unsigned char n=0; 152 if(a.size<b.size){ 153 while(of<dest_length){ 154 *(dp+of)=n^*(bp+of); 155 of++; 156 } 157 } else{ 158 while(of<dest_length){ 159 *(dp+of)=*(ap+of)^n; 160 of++; 161 } 162 } 163 } 164 // should be finished now 165 GameState r = {b.id, dest_length, dp}; 166 return r; 167 } 168 169 GameState GameStateManager::compress(GameState a){ 170 // to be implemented !!!!!!!!!!!!!! 171 return a; 172 } 173 174 GameState GameStateManager::decompress(GameState a){ 175 // to be implemented !!!!!!!!!!!!!! 176 return a; 177 } 128 178 129 179 } -
code/branches/FICN/src/network/GameStateManager.h
r346 r385 35 35 * - writing gamestates to universe 36 36 * - diffing gamestates ? 37 * 38 * EN/DECODATION: 39 * a: last Gamestate a client has received 40 * b: new Gamestate 41 * x: diffed and compressed gamestate 42 * x=(a^b) 43 * b=(a^x) 44 * diff(a,diff(a,x))=x (hope this is correct) 37 45 * @author Oliver Scheuss 38 46 */ … … 43 51 GameState getSnapshot(int id); 44 52 bool loadSnapshot(GameState state); 53 GameState encode(GameState a, GameState b); 54 GameState decode(GameState a, GameState x); 45 55 private: 46 56 void removeObject(orxonox::Iterator<Synchronisable> &it); 47 57 GameState diff(GameState a, GameState b); 58 GameState compress(GameState a); 59 GameState decompress(GameState a); 48 60 }; 49 61
Note: See TracChangeset
for help on using the changeset viewer.