Changeset 514 for code/branches/FICN/src/network/GameStateManager.cc
- Timestamp:
- Dec 13, 2007, 6:02:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/GameStateManager.cc
r436 r514 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Oliver Scheuss, (C) 2007 23 * Co-authors: 24 * ... 25 * 26 */ 27 1 28 // 2 29 // C++ Implementation: GameStateManager 3 30 // 4 // Description: 31 // Description: 5 32 // 6 33 // … … 47 74 48 75 /** 49 * This function goes through the whole list of synchronisables and 76 * This function goes through the whole list of synchronisables and 50 77 * saves all the synchronisables to a flat "list". 51 78 * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list … … 61 88 // struct for return value of Synchronisable::getData() 62 89 syncData sync; 63 90 64 91 GameState *retval=new GameState; //return value 65 92 retval->id=id; 66 93 // reserve a little memory and increase it later on 67 94 retval->data = (unsigned char*)malloc(1); 68 95 69 96 // offset of memory functions 70 97 int offset=0; … … 77 104 // allocate additional space 78 105 retval->data = (unsigned char *)realloc((void *)retval->data, totalsize); 79 106 80 107 // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length) 81 108 sync=it->getData(retval->data+offset+3*sizeof(int)); … … 140 167 unsigned char* dest = (unsigned char*)malloc( buffer ); 141 168 int retval; 142 retval = compress( dest, &buffer, a->data, (uLong)size ); 143 169 retval = compress( dest, &buffer, a->data, (uLong)size ); 170 144 171 switch ( retval ) { 145 172 case Z_OK: std::cout << "successfully compressed" << std::endl; break; … … 148 175 case Z_DATA_ERROR: std::cout << "data corrupted" << std::endl; break; 149 176 } 150 177 151 178 GameStateCompressed compressedGamestate; 152 179 compressedGamestate.compsize = buffer; … … 155 182 compressedGamestate.data = dest; 156 183 compressedGamestate.diffed = a->diffed; 157 184 158 185 return compressedGamestate; 159 186 }
Note: See TracChangeset
for help on using the changeset viewer.