Changeset 514 for code/branches/FICN/src/network/PacketGenerator.cc
- Timestamp:
- Dec 13, 2007, 6:02:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketGenerator.cc
r437 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 generates packets that can be send by enet 3 30 * ->don't read this without the class PacketDecoder, since they belong together 4 * 31 * 5 32 * Autor: Dumeni Manatschal 6 * 33 * 7 34 */ 8 35 … … 26 53 ackreq->id = ACK; 27 54 ackreq->a = state; 28 55 29 56 ENetPacket *packet = enet_packet_create( ackreq , sizeof( *ackreq ), reliable ); 30 57 31 58 return packet; 32 59 } … … 39 66 mousemove->x = x; 40 67 mousemove->y = y; 41 68 42 69 ENetPacket *packet = enet_packet_create( mousemove , sizeof( *mousemove ), reliable ); 43 70 44 71 return packet; 45 72 } … … 51 78 key->id = KEYBOARD; 52 79 key->press = press; 53 80 54 81 ENetPacket *packet = enet_packet_create( key , sizeof( *key ), reliable ); 55 82 56 83 return packet; 57 84 } … … 64 91 memcpy( &trans[1], (const void*)message, strlen( message ) + 1); 65 92 ENetPacket *packet = enet_packet_create( trans , sizeof( int ) + strlen( message ) + 1, reliable ); 66 93 67 94 return packet; 68 95 } … … 71 98 ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable ) 72 99 { 73 int* gid = new int; 100 int* gid = new int; 74 101 *gid = GAMESTATE; //first assign the correct enet id 75 102 int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory … … 87 114 //create an enet packet with the generated bytestream 88 115 ENetPacket *packet = enet_packet_create( data , totalLen, reliable ); 89 116 90 117 return packet; 91 118 }
Note: See TracChangeset
for help on using the changeset viewer.