Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

packet.h

Go to the documentation of this file.
00001 #ifndef _PACKET_H_
00002 #define _PACKET_H_
00003 
00004 #include <Windows.h>
00005 #include <string.h>
00006 #include "Message.h"
00007 
00008 #define uint16_t unsigned short int
00009 #define PKT_CONNECTION_REQUEST 1
00010 #define PKT_CONNECTION_RESPONSE 2
00011 #define PKT_PLAYER_INFO 3
00012 #define PKT_CHAT_MSG 4
00013 #define PKT_REQUEST_PLAYERS 5
00014 #define PKT_DISCONNECT 6
00015 #define PKT_PLAYER_POSITION 7
00016 #define PKT_ATTACK 8
00017 #define PKT_PLAYER_STATE 9
00018 #define PKT_PLAYER_SCORE 10
00019 #define PKT_PLAYER_ACTION 11
00020 #define PKT_PLAYER_KILLED 12
00021 #define PKT_PLAYER_EXTRAS 13
00022 #define PKT_DEAL_EXTRAS 14
00023 #define PKT_PLAYER_NAME 15
00024 #define PKT_INFO 16
00025 
00026 struct packetHeader{
00027         char pktType;
00028         int pktLen;     //payload of the data (not the header)
00029         int from;
00030         DWORD timeStamp;
00031 };
00032 
00033 
00034 struct packetConnect{
00035         packetHeader header;
00036         int vid; //version indentifier
00037 };
00038 
00039 
00040 struct packetConnectionResponse{
00041         packetHeader header;
00042         bool acceptionFlag;
00043 };
00044 
00045 
00046 struct packetChatMsg{
00047         packetHeader header;
00048         int len;
00049         msgstruct msg;
00050 };
00051 
00052 
00053 struct packetPlayerInfo{
00054         packetHeader header;
00055         int id;
00056         char name[25];
00057 };
00058 
00059 
00060 struct packetRequestAllPlayersInfo{
00061         packetHeader header;
00062 };
00063 
00064 
00065 struct packetDisconnect{
00066         packetHeader header;
00067         int id;
00068 };
00069 
00070 
00071 struct packetPlayerPosition{
00072         packetHeader header;
00073         int id;
00074         float x;
00075         float y;
00076         float angle;
00077         bool overwriteself;
00078         int move;
00079         int rotation;
00080 };
00081 
00082 
00083 //ta med motståndarens position också??
00084 struct packetAttack{
00085         packetHeader header;
00086         int id;
00087         int attack;
00088         float x;
00089         float y;
00090         float z;
00091         float dx;
00092         float dy;
00093         float dz;
00094 };
00095 
00096 
00097 struct packetPlayerState{
00098         packetHeader header;
00099         int id;
00100         int state;
00101 };
00102 
00103 
00104 struct packetPlayerScore{
00105         packetHeader header;
00106         int id;
00107         int kills;
00108         int frags;
00109         int deaths;
00110 };
00111 
00112 
00113 struct packetPlayerAction{
00114         packetHeader header;
00115         int id;
00116         int action;
00117 };
00118 
00119 
00120 struct packetPlayerKilled{
00121         packetHeader header;
00122         int id;
00123         int killer;
00124 };
00125 
00126 
00127 struct packetPlayerExtras{
00128         packetHeader header;
00129         int id;
00130         int extras;
00131         int value;
00132 };
00133 
00134 
00135 struct packetDealExtras{
00136         packetHeader header;
00137         int detype;
00138         float x;
00139         float y;
00140         int flag;
00141 };
00142 
00143 
00144 struct packetPlayerName{
00145         packetHeader header;
00146         int id;
00147         char name[25];
00148         int flag;
00149 };
00150 
00151 
00152 
00153 struct packetInfo{
00154         packetHeader header;
00155         int id;
00156         int valA;
00157         int valB;
00158         int valC;
00159 };
00160 
00161 
00162 
00163 
00164 void setTimeStamp(packetHeader *header);
00165 void setPacketFrom(packetHeader *header, int id);
00166 packetChatMsg createPacketChatMsg(int playerid, const char *msg);
00167 packetConnect createPacketConnect(int vid);
00168 packetConnectionResponse createPacketConnectionResponse(bool flag);
00169 packetPlayerInfo createPacketPlayerInfo(const char name[25], int id);
00170 packetRequestAllPlayersInfo createPacketRequestAllPlayersInfo();
00171 packetDisconnect createPacketDisconnect(int id);
00172 packetPlayerPosition createPacketPlayerPosition(int id, int rotation, int move, float x, float y, float angle, bool overwriteself);
00173 packetAttack createPacketAttack(int playerid,int type, float x, float y, float z, float dx, float dy, float dz);
00174 packetPlayerState createPacketPlayerState(int id, int state);
00175 packetPlayerScore createPacketPlayerScore(int id, int kills, int frags, int deaths);
00176 packetPlayerAction createPacketPlayerAction(int id, int action);
00177 packetPlayerKilled createPacketPlayerKilled(int id, int killer);
00178 packetPlayerExtras createPacketPlayerExtras(int id, int extras, int value);
00179 packetDealExtras createPacketDealExtras(int detype, float x, float y, int flag);
00180 packetPlayerName createPacketPlayerName(int playerid, const char *name, int flag);
00181 packetInfo createPacketInfo(int playerid, int valA, int valB,int valC);
00182 
00183 
00184 #endif

Generated on Sun Jun 5 15:47:05 2005 for Defacto by  doxygen 1.4.3