-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlurk_structs.h
100 lines (87 loc) · 2.44 KB
/
lurk_structs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include<stdint.h>
#include<ctime>
#pragma pack(push, 1)
#define INITIAL_HEALTH 1000
#define MESSAGE_HEADER_SIZE 67
struct message {
uint8_t type; // 1
uint16_t msg_len;
char recipient[32];
char sender[32];
char* message;
}__attribute__((packed));
#define ERROR_HEADER_SIZE 4
struct error {
uint8_t type; // 7
uint8_t err_code;
uint16_t msg_len;
char message[1024];
}__attribute__((packed));
#define ACCEPT_HEADER_SIZE 2
struct accept {
uint8_t type; // 8
uint8_t accept_type;
}__attribute__((packed));
#define ROOM_HEADER_SIZE 37
struct room {
uint8_t type; // 9, change to 10 for a connection type
uint16_t room_num;
char room_name[32];
uint16_t desc_len;
char* description;
uint8_t locked; // not park of lurk, but allows for server-side checking of locked doors, denied access, etc
}__attribute__((packed));
// define the player flags
#define ALIVE 0b10000000
#define JOIN_BATTLE 0b01000000
#define MONSTER 0b00100000
#define STARTED 0b00010000
#define READY 0b00001000
#define CHARACTER_HEADER_SIZE 48
struct character {
uint8_t type; // 10
char name[32];
uint8_t flags;
uint16_t attack;
uint16_t defense;
uint16_t regen;
int16_t health;
uint16_t gold;
uint16_t room_num;
uint16_t desc_len;
char* description;
// The following fields are used server-side and are not part of LURK
int16_t fd; // client file descriptor
uint8_t npc; // Used to differentiate between player-made characters and NPCs
int16_t initial_health; // Used to track the initial health of enemies
time_t last_active_time; // Used to track when the player / enemy was last active for the cleanup routine
}__attribute__((packed));
#define STAT_LIMIT 65535
#define INITIAL_STATS 1000
#define GAME_HEADER_SIZE 7
struct game {
uint8_t type; // 11
uint16_t init_points;
uint16_t stat_limit;
uint16_t desc_len;
char description[1500];
}__attribute__((packed));
/* not needed, just send room struct with the type changed to 13
#define CONNECTION_HEADER_SIZE 37
struct connection {
const uint8_t type = 13;
uint16_t room_num;
char room_name[32];
uint16_t desc_len;
char* description;
}__attribute__((packed));
*/
#define VERSION_HEADER_SIZE 5
struct version {
uint8_t type; // 14
uint8_t major; // 2
uint8_t minor; // 3
uint16_t exten_size; // 0
// list of extensions not implemented
}__attribute__((packed));
#pragma pack(pop)