-
Notifications
You must be signed in to change notification settings - Fork 4
/
common.h
132 lines (107 loc) · 2.26 KB
/
common.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#pragma once
#include "MySocket.h"
#include <cstdint>
enum //发送包
{
kRegister = 200,
kLogin,
kLoginOut,
kGetPlayerInfo,
};
enum //接收包
{
kRegisterResult = 600,
kLoginResult,
kGetPlayerInfoResult,
};
enum //错误码
{
kSucess = 0,
kError = 100,//未知错误
kSameNick,//相同Nick 玩家不能注册
kUserOrPasswdError,//用户名或密码错误
kForbidLogin,//禁止登陆
};
struct Nickname
{
uint32_t len;
char name[18];
};
typedef struct Nickname Nickname;
struct Register//c2s
{
static const uint32_t type = kRegister;
uint32_t age;
Nickname nick;
//uint32_t passworldLen;
uint32_t address1_len;
char address1[128];
uint32_t address2_len;
char address2[128];
uint32_t address3_len;
char address3[128];
uint32_t phone_len;
char phone[16];//电话号码
};
typedef struct Register Register;
struct RegisterResult
{
static const uint32_t type = kRegisterResult;
uint32_t result;//
};
typedef struct RegisterResult RegisterResult;//s2c
struct Login//c2s
{
static const uint32_t type = kLogin;
uint32_t phone_len;
char phone[12];
};
typedef struct Login Login;
struct LoginResult
{
static const uint32_t type = kLoginResult;
uint32_t result;//
};
typedef struct LoginResult LoginResult;//s2c
struct LoginOut{
static const uint32_t type = kLoginOut;
};
typedef struct LoginOut LoginOut;//c2s
struct UserRecord
{
uint32_t user_id; //用户id
uint32_t login_time; //登录时间
int16_t b_enable; //是否允许登录
int16_t age; //性别
uint32_t forbid_login_time; //禁止登陆时间
Nickname nick; //nick
ODSocket odSocket; //socket
char ip[32] ; //ip 地址
char phone[16]; //电话号码
uint32_t address1_len;
char address1[512]; //常用活动地址1
uint32_t address2_len;
char address2[512]; //常用活动地址2
uint32_t address3_len;
char address3[512]; //常用地址3
};
typedef UserRecord UserRecord;
struct GetPlayerInfo{
static const uint32_t type = kGetPlayerInfo;
int phone_len;
char phone[12];
};
typedef struct GetPlayerInfo GetPlayerInfo;//c2s
struct PlayerInfoResult//s2c
{
static const uint32_t type = kGetPlayerInfoResult;
uint32_t result;//
Nickname nick;
uint32_t address1_len;
char address1[128];
uint32_t address2_len;
char address2[128];
uint32_t address3_len;
char address3[128];
};
typedef struct PlayerInfoResult PlayerInfoResult;