1 /*************************************************************************** 2 copyright : (C) 2003 by Michael Speck 3 email : kulkanie@gmx.net 4 ***************************************************************************/ 5 6 /*************************************************************************** 7 * * 8 * This program is free software; you can redistribute it and/or modify * 9 * it under the terms of the GNU General Public License as published by * 10 * the Free Software Foundation; either version 2 of the License, or * 11 * (at your option) any later version. * 12 * * 13 ***************************************************************************/ 14 15 #ifndef __COMM_H 16 #define __COMM_H 17 18 /***** INCLUDES ************************************************************/ 19 20 /***** TYPE DEFINITIONS ****************************************************/ 21 22 /***** PUBLIC FUNCTIONS ****************************************************/ 23 24 /* pack paddle information 25 * 0-9 x position 26 * 10 left fire 27 * 11 right fire 28 * 12 return key pressed 29 * 30 * the invisible state is not send as the server has 31 * its own copy of it. 32 */ 33 void comm_pack_paddle( Paddle *paddle, unsigned char *msg, int *pos ); 34 35 /* apply packed paddle */ 36 void comm_unpack_paddle( Paddle *paddle, unsigned char *msg, int *pos ); 37 38 /* pack moving/attached ball and sound information 39 * 0-4 moving ball count (max: 31) 40 * 5 reflect sound 41 * 6 attach sound 42 * 7 fire sound (weapon) 43 * 24 each: 44 * 0-7 lower x 45 * 8-15 lower y 46 * 16 9th bit of x 47 * 17 10th bit of x 48 * 18 9th bit of y 49 * 0-7 attached ball count (max: 31) 50 * 16 each: 51 * 0-7 x + 20 52 * 8-14 y + 20 53 * 15 paddle (bottom or top) 54 */ 55 void comm_pack_balls( unsigned char *msg, int *pos ); 56 57 /* apply ball information */ 58 void comm_unpack_balls( unsigned char *msg, int *pos ); 59 60 /* pack shot information 61 * 0-7 shot count 62 * 24 each: 63 * 0-7 lower x 64 * 8-15 lower y 65 * 16 9th bit of x 66 * 17 10th bit of x 67 * 18 9th bit of y 68 */ 69 void comm_pack_shots( unsigned char *msg, int *pos ); 70 71 /* apply shots */ 72 void comm_unpack_shots( unsigned char *msg, int *pos ); 73 74 /* pack brick hit information 75 * 0-7 hit count (loose duration) 76 * 8 each: 77 * 0-7 id in edit window 78 * 0-7 heal count (one point) 79 * 8 each: 80 * 0-7 id in edit window 81 * 0-7 grow count (random client id) 82 * 0-7 id in edit window 83 * 0-7 remove count 84 * 16(+8) each: 85 * 0-7 id in edit window 86 * 8-9 destroy type (00 normal, 01 energy, 10 shot, 11 expl) 87 * 10 paddle (top or bottom) 88 * 11 goldshower (release 1000P) 89 * 12-15 unused 90 * (16-23) clockwise impact position 0-180 for normal animation 91 */ 92 void comm_pack_brick_hits( unsigned char *msg, int *pos ); 93 94 /* build client brick hits */ 95 void comm_unpack_brick_hits( unsigned char *msg, int *pos ); 96 97 /* pack collected extra information 98 * 0-7 paddle bottom count 99 * 8 each: 100 * 0-7 extra id 101 * 0-7 paddle top count 102 * 8 each: 103 * 0-7 extra id 104 */ 105 void comm_pack_collected_extras( unsigned char *msg, int *pos ); 106 107 /* build client collected extras */ 108 void comm_unpack_collected_extras( unsigned char *msg, int *pos ); 109 110 /* pack level data (in byte) 111 * 16 title 112 * 16 author 113 * 252 bricks 114 * 252 extras 115 */ 116 void comm_pack_level( Level *level, unsigned char *msg, int *pos ); 117 118 /* unpack leveldata */ 119 void comm_unpack_level( Level *level, unsigned char *msg, int *pos ); 120 121 /* pack scores 122 * 0-23 paddle bottom 123 * 24-47 paddle top 124 */ 125 void comm_pack_scores( unsigned char *msg, int *pos ); 126 127 /* apply scores to paddles */ 128 void comm_unpack_scores( unsigned char *msg, int *pos ); 129 130 /* dummy unpack the various things thus simply adjust the 'pos' 131 * pointer but don't handle the message data */ 132 void comm_unpack_paddle_dummy(unsigned char *msg, int *pos ); 133 void comm_unpack_balls_dummy(unsigned char *msg, int *pos ); 134 void comm_unpack_shots_dummy(unsigned char *msg, int *pos ); 135 void comm_unpack_scores_dummy(unsigned char *msg, int *pos ); 136 void comm_unpack_brick_hits_dummy(unsigned char *msg, int *pos ); 137 void comm_unpack_collected_extras_dummy(unsigned char *msg, int *pos ); 138 139 #endif 140 141