forked from jewalky/redhat
-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.hpp
146 lines (118 loc) · 3.76 KB
/
server.hpp
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef SERVER_HPP_INCLUDED
#define SERVER_HPP_INCLUDED
#include "listener.hpp"
#include "config.hpp"
#include "socket.hpp"
#include <windows.h>
#define SERVER_CONNECTED 0x00000001
#define SERVER_LOGGED_IN 0x00000002
#define SERVER_CAP_DETAILED_INFO 0x00000001
#define SERVER_CAP_FIXED_MAPLIST 0x00000002
#define SERVER_CAP_SOFTCORE 0x00000004
#define SVF_CLOSED 0x00000001
#define SVF_PVM 0x00000002
#define SVF_MUTED 0x00000004
#define SVF_ADVPVM 0x00000040
#define SVF_ONEMAP 0x00000080
#define SVF_NOHEALING 0x00000100
#define SVF_NOOBSRV 0x00000200
#define SVF_SOFTCORE 0x00000400
#define SVF_NODROP 0x00000800
#define SVF_FNODROP 0x00001000
#define SVF_NOSAVING 0x00002000
#define SVF_SANDBOX 0x00004000
#define SVF_ENTERMAGE 0x00008000
#define SVF_ENTERWARRIOR 0x00010000
struct ServerPlayer
{
std::string Nickname;
std::string Login;
unsigned long Id1;
unsigned long Id2;
bool Connected;
std::string IPAddress;
};
struct ServerInfo
{
unsigned long ServerCaps;
unsigned long Time;
std::string MapName;
unsigned long MapWidth;
unsigned long MapHeight;
unsigned long MapLevel;
unsigned long PlayerCount;
std::string Address;
unsigned long GameMode;
unsigned long ServerMode;
std::vector<ServerPlayer> Players;
std::vector<std::string> Locked;
};
struct Server;
struct ServerConnection
{
SOCKET Socket;
unsigned long Flags;
unsigned long Version;
unsigned long ID;
bool Active;
PacketReceiver Receiver;
Server* Parent;
};
struct ServerLayer
{
SOCKET Socket;
struct LayerFlags
{
bool Connected;
bool Active;
bool ShuttingDown;
bool Closed;
} Flags;
PacketReceiver Receiver;
ServerLayer()
{
this->Flags.Connected = false;
this->Flags.Active = false;
this->Flags.ShuttingDown = false;
this->Flags.Closed = true;
this->Socket = NULL;
}
};
struct Server
{
unsigned long Number;
std::string Name;
std::string Address;
unsigned short Port;
std::string IAddress;
unsigned short IPort;
signed int HatId;
ServerConnection* Connection;
ServerLayer* Layer;
ServerInfo Info;
bool ShuttingDown;
};
extern std::vector<Server*> Servers;
bool SV_Login(ServerConnection* conn, Packet& pack);
bool SV_UpdateInfo(ServerConnection* conn, Packet& pack);
bool SV_UpdateInfo20(ServerConnection* conn, Packet& pack);
bool SV_Initialized20(ServerConnection* conn, Packet& pack);
bool SV_ReturnCharacter(ServerConnection* conn, Packet& pack);
bool SV_ConfirmClient(ServerConnection* conn, Packet& pack);
bool SV_RejectClient(ServerConnection* conn, Packet& pack);
unsigned long SV_TryClient(ServerConnection* conn, unsigned long id1, unsigned long id2, std::string login, std::string nickname, unsigned char sex);
bool SVCMD_Welcome(ServerConnection* conn);
bool SVCMD_ReceivedCharacter(ServerConnection* conn, std::string login);
bool SV_AddConnection(SOCKET socket, sockaddr_in addr);
bool SV_Process(Server* srv);
bool SV_ProcessLayer(Server* srv);
void SV_Disconnect(Server* srv);
void SV_DisconnectLayer(Server* srv);
bool SL_Initialized(Server* layer, Packet& pack);
bool SL_Shutdown(Server* layer, Packet& pack);
bool SL_UpdateInfo(Server* srv, Packet& pack);
bool SL_Broadcast(Server* srv, Packet& pack);
bool SLCMD_Screenshot(Server* srv, std::string login, uint32_t uid, bool done, std::string url);
bool SLCMD_MutePlayer(Server* srv, std::string login, uint32_t unmutedate);
void Net_ProcessServers();
#endif // SERVER_HPP_INCLUDED