Initial Import
[glAntsMech.git] / glants_mech / linux / src / network / include / msg.h
blobbbe90b719cd0a327340537df2cd82b6783eeaa51
1 //
2 // msg.h
3 //
4 #ifndef _MSG_H_
5 #define _MSG_H_
7 // timeout at 5 seconds
8 // 1 is really too long but we will be nice
9 #define ALARM_TIMEOUT 10
11 // you may need a lot, you may need a little
12 #define MAX_MESSAGES 200
14 #define RELEASE_OBJ(x) \
15 if (x != NULL) \
16 free(x) \
18 enum MsgType {
19 MSG_MOVE = 0,
20 MSG_CHAT = 1,
21 MSG_LOGIN = 2,
22 MSG_REPLY = 3,
23 MSG_LOAD = 4
26 enum MoveType {
27 MOVE_FORWARD = 8,
28 MOVE_BACKWARD = 16,
29 MOVE_TURNLEFT = 32,
30 MOVE_TURNRIGHT = 64,
31 MOVE_FIRE = 128,
32 MOVE_NOMOVE = 256,
33 MOVE_COLLIDE = 512,
36 //
38 // have to be careful, dont want
39 // too many variables
41 // most messages will revolve around
42 // movement
43 typedef struct tagMsg {
45 int msg_type;
46 int move_type;
47 int msg_id; // the index
48 int object_id; // the client connect id
50 // move
51 float pos_x;
52 float pos_y;
53 float heading;
55 // misc messages
56 char msg[42];
58 struct tagMsg *next;
59 } Msg, *MsgPtr;
62 // MsgList
63 typedef struct tagMsgList {
64 Msg *front;
65 int objects;
66 } MsgList;
69 Msg *CreateMsgObj(void);
70 void Create_Msg_List(void);
71 void Delete_Msg_List(void);
72 void Print_Msg_List(void);
74 void Msg_Test(void);
75 void Msg_AddQueue(int msg_type, int move_type, int obj_id, float px, float py, float h);
76 void *Convert_MsgList(void);
77 Msg *GetMsgCluster(void);
78 void Print_MsgTest(void);
80 void Clear_FirstMsg(void);
83 // stats.c
84 void Start_Net_Time(void);
85 void End_Net_Time(void);
86 void Print_Net_Time(void);
87 void Send_Net_Packet(int sock, int serv_sock);
88 void Recv_Net_Packet(int sock, int serv_sock);
90 MsgPtr Get_FirstMsg(void);
92 int Get_MessageCount(void);
94 void Set_MsgIndex(int val);
95 void Set_MsgId(int val);
96 Msg *Get_Messages(int *msg_count, int *msg_id);
97 void *Finalize_Messages(int *res_count);
98 void Reset_Message(void);
100 #endif