Changeset 514 for code/branches/FICN/src/network/PacketDecoder.cc
- Timestamp:
- Dec 13, 2007, 6:02:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketDecoder.cc
r440 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 * Dumeni Manatschal, (C) 2007 23 * Co-authors: 24 * ... 25 * 26 */ 27 1 28 /* 2 29 * Class contains functions to determine and decode incomming packages 3 30 * ->don't read this without the class PacketGenerator, since they belong together 4 * 31 * 5 32 * Autor: Dumeni Manatschal 6 * 33 * 7 34 */ 8 35 … … 58 85 ack* a = new ack; 59 86 *a = *(ack*)packet->data; //press pattern of ack on new data 60 61 //clean memory 62 enet_packet_destroy( packet ); 63 87 88 //clean memory 89 enet_packet_destroy( packet ); 90 64 91 printAck( a ); //debug info 65 92 } … … 69 96 mouse* mouseMove = new mouse; 70 97 //copy data of packet->data to new struct 71 *mouseMove = *(mouse*)packet->data; 72 73 //clean memory 74 enet_packet_destroy( packet ); 75 98 *mouseMove = *(mouse*)packet->data; 99 100 //clean memory 101 enet_packet_destroy( packet ); 102 76 103 printMouse( mouseMove ); //debug info 77 104 } … … 81 108 keyboard* key = new keyboard; 82 109 *key = *(keyboard*)packet->data; //see above 83 84 //clean memory 85 enet_packet_destroy( packet ); 86 110 111 //clean memory 112 enet_packet_destroy( packet ); 113 87 114 printKey( key ); //debug info 88 115 … … 94 121 chatting->id = (int)*packet->data; //first copy id into new struct 95 122 //since the chat message is a char*, allocate the memory needed 96 char* reserve = new char[packet->dataLength-4]; 123 char* reserve = new char[packet->dataLength-4]; 97 124 //copy the transmitted bytestream into the new generated char*, 98 //note the lenght of the message is represented as "packet->dataLength-sizeof( int )" 125 //note the lenght of the message is represented as "packet->dataLength-sizeof( int )" 99 126 memcpy( &reserve[0], packet->data+sizeof(int), packet->dataLength-sizeof(int) ); 100 127 //put pointer of chatting struct to the begining of the new generated char* 101 128 chatting->message = reserve; 102 103 //clean memory 104 enet_packet_destroy( packet ); 105 129 130 //clean memory 131 enet_packet_destroy( packet ); 132 106 133 processChat( chatting, clientId ); //debug info 107 134 108 135 } 109 136 … … 126 153 //copy the GameStateCompressed data 127 154 memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize ); 128 155 129 156 //clean memory 130 157 enet_packet_destroy( packet );
Note: See TracChangeset
for help on using the changeset viewer.