]> git.lizzy.rs Git - minetest.git/blob - src/network/serveropcodes.cpp
Add clouds API
[minetest.git] / src / network / serveropcodes.cpp
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2015 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "serveropcodes.h"
22
23 const static ToServerCommandHandler null_command_handler = { "TOSERVER_NULL", TOSERVER_STATE_ALL, &Server::handleCommand_Null };
24
25 const ToServerCommandHandler toServerCommandTable[TOSERVER_NUM_MSG_TYPES] =
26 {
27         null_command_handler, // 0x00 (never use this)
28         null_command_handler, // 0x01
29         { "TOSERVER_INIT",                     TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_Init }, // 0x02
30         null_command_handler, // 0x03
31         null_command_handler, // 0x04
32         null_command_handler, // 0x05
33         null_command_handler, // 0x06
34         null_command_handler, // 0x07
35         null_command_handler, // 0x08
36         null_command_handler, // 0x09
37         null_command_handler, // 0x0a
38         null_command_handler, // 0x0b
39         null_command_handler, // 0x0c
40         null_command_handler, // 0x0d
41         null_command_handler, // 0x0e
42         null_command_handler, // 0x0f
43         { "TOSERVER_INIT_LEGACY",              TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_Init_Legacy }, // 0x10
44         { "TOSERVER_INIT2",                    TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_Init2 }, // 0x11
45         null_command_handler, // 0x12
46         null_command_handler, // 0x13
47         null_command_handler, // 0x14
48         null_command_handler, // 0x15
49         null_command_handler, // 0x16
50         null_command_handler, // 0x17
51         null_command_handler, // 0x18
52         null_command_handler, // 0x19
53         null_command_handler, // 0x1a
54         null_command_handler, // 0x1b
55         null_command_handler, // 0x1c
56         null_command_handler, // 0x1d
57         null_command_handler, // 0x1e
58         null_command_handler, // 0x1f
59         null_command_handler, // 0x20
60         null_command_handler, // 0x21
61         null_command_handler, // 0x22
62         { "TOSERVER_PLAYERPOS",                TOSERVER_STATE_INGAME, &Server::handleCommand_PlayerPos }, // 0x23
63         { "TOSERVER_GOTBLOCKS",                TOSERVER_STATE_STARTUP, &Server::handleCommand_GotBlocks }, // 0x24
64         { "TOSERVER_DELETEDBLOCKS",            TOSERVER_STATE_INGAME, &Server::handleCommand_DeletedBlocks }, // 0x25
65         null_command_handler, // 0x26
66         { "TOSERVER_CLICK_OBJECT",             TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x27
67         { "TOSERVER_GROUND_ACTION",            TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x28
68         { "TOSERVER_RELEASE",                  TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x29
69         null_command_handler, // 0x2a
70         null_command_handler, // 0x2b
71         null_command_handler, // 0x2c
72         null_command_handler, // 0x2d
73         null_command_handler, // 0x2e
74         null_command_handler, // 0x2f
75         { "TOSERVER_SIGNTEXT",                 TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x30
76         { "TOSERVER_INVENTORY_ACTION",         TOSERVER_STATE_INGAME, &Server::handleCommand_InventoryAction }, // 0x31
77         { "TOSERVER_CHAT_MESSAGE",             TOSERVER_STATE_INGAME, &Server::handleCommand_ChatMessage }, // 0x32
78         { "TOSERVER_SIGNNODETEXT",             TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x33
79         { "TOSERVER_CLICK_ACTIVEOBJECT",       TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x34
80         { "TOSERVER_DAMAGE",                   TOSERVER_STATE_INGAME, &Server::handleCommand_Damage }, // 0x35
81         { "TOSERVER_PASSWORD_LEGACY",          TOSERVER_STATE_INGAME, &Server::handleCommand_Password }, // 0x36
82         { "TOSERVER_PLAYERITEM",               TOSERVER_STATE_INGAME, &Server::handleCommand_PlayerItem }, // 0x37
83         { "TOSERVER_RESPAWN",                  TOSERVER_STATE_INGAME, &Server::handleCommand_Respawn }, // 0x38
84         { "TOSERVER_INTERACT",                 TOSERVER_STATE_INGAME, &Server::handleCommand_Interact }, // 0x39
85         { "TOSERVER_REMOVED_SOUNDS",           TOSERVER_STATE_INGAME, &Server::handleCommand_RemovedSounds }, // 0x3a
86         { "TOSERVER_NODEMETA_FIELDS",          TOSERVER_STATE_INGAME, &Server::handleCommand_NodeMetaFields }, // 0x3b
87         { "TOSERVER_INVENTORY_FIELDS",         TOSERVER_STATE_INGAME, &Server::handleCommand_InventoryFields }, // 0x3c
88         null_command_handler, // 0x3d
89         null_command_handler, // 0x3e
90         null_command_handler, // 0x3f
91         { "TOSERVER_REQUEST_MEDIA",            TOSERVER_STATE_STARTUP, &Server::handleCommand_RequestMedia }, // 0x40
92         { "TOSERVER_RECEIVED_MEDIA",           TOSERVER_STATE_STARTUP, &Server::handleCommand_Deprecated }, // 0x41 not used by the server since protocol version 23
93         { "TOSERVER_BREATH",                   TOSERVER_STATE_INGAME, &Server::handleCommand_Deprecated }, // 0x42 Old breath model which is now deprecated for anticheating
94         { "TOSERVER_CLIENT_READY",             TOSERVER_STATE_STARTUP, &Server::handleCommand_ClientReady }, // 0x43
95         null_command_handler, // 0x44
96         null_command_handler, // 0x45
97         null_command_handler, // 0x46
98         null_command_handler, // 0x47
99         null_command_handler, // 0x48
100         null_command_handler, // 0x49
101         null_command_handler, // 0x4a
102         null_command_handler, // 0x4b
103         null_command_handler, // 0x4c
104         null_command_handler, // 0x4d
105         null_command_handler, // 0x4e
106         null_command_handler, // 0x4f
107         { "TOSERVER_FIRST_SRP",          TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_FirstSrp }, // 0x50
108         { "TOSERVER_SRP_BYTES_A",        TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_SrpBytesA }, // 0x51
109         { "TOSERVER_SRP_BYTES_M",        TOSERVER_STATE_NOT_CONNECTED, &Server::handleCommand_SrpBytesM }, // 0x52
110 };
111
112 const static ClientCommandFactory null_command_factory = { "TOCLIENT_NULL", 0, false };
113
114 const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
115 {
116         null_command_factory, // 0x00
117         null_command_factory, // 0x01
118         { "TOCLIENT_HELLO",             0, true }, // 0x02
119         { "TOCLIENT_AUTH_ACCEPT",       0, true }, // 0x03
120         { "TOCLIENT_ACCEPT_SUDO_MODE",  0, true }, // 0x04
121         { "TOCLIENT_DENY_SUDO_MODE",    0, true }, // 0x05
122         null_command_factory, // 0x06
123         null_command_factory, // 0x07
124         null_command_factory, // 0x08
125         null_command_factory, // 0x09
126         { "TOCLIENT_ACCESS_DENIED",     0, true }, // 0x0A
127         null_command_factory, // 0x0B
128         null_command_factory, // 0x0C
129         null_command_factory, // 0x0D
130         null_command_factory, // 0x0E
131         null_command_factory, // 0x0F
132         { "TOCLIENT_INIT",              0, true }, // 0x10
133         null_command_factory,
134         null_command_factory,
135         null_command_factory,
136         null_command_factory,
137         null_command_factory,
138         null_command_factory,
139         null_command_factory,
140         null_command_factory,
141         null_command_factory,
142         null_command_factory,
143         null_command_factory,
144         null_command_factory,
145         null_command_factory,
146         null_command_factory,
147         null_command_factory,
148         { "TOCLIENT_BLOCKDATA",                2, true }, // 0x20
149         { "TOCLIENT_ADDNODE",                  0, true }, // 0x21
150         { "TOCLIENT_REMOVENODE",               0, true }, // 0x22
151         null_command_factory,
152         null_command_factory,
153         null_command_factory,
154         null_command_factory,
155         { "TOCLIENT_INVENTORY",                0, true }, // 0x27
156         null_command_factory,
157         { "TOCLIENT_TIME_OF_DAY",              0, true }, // 0x29
158         null_command_factory,
159         null_command_factory,
160         null_command_factory,
161         null_command_factory,
162         null_command_factory,
163         null_command_factory,
164         { "TOCLIENT_CHAT_MESSAGE",             0, true }, // 0x30
165         { "TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD", 0, true }, // 0x31
166         { "TOCLIENT_ACTIVE_OBJECT_MESSAGES",   0, true }, // 0x32 Special packet, sent by 0 (rel) and 1 (unrel) channel
167         { "TOCLIENT_HP",                       0, true }, // 0x33
168         { "TOCLIENT_MOVE_PLAYER",              0, true }, // 0x34
169         { "TOCLIENT_ACCESS_DENIED_LEGACY",     0, true }, // 0x35
170         { "TOCLIENT_PLAYERITEM",               0, false }, // 0x36 obsolete
171         { "TOCLIENT_DEATHSCREEN",              0, true }, // 0x37
172         { "TOCLIENT_MEDIA",                    2, true }, // 0x38
173         { "TOCLIENT_TOOLDEF",                  0, false }, // 0x39 obsolete
174         { "TOCLIENT_NODEDEF",                  0, true }, // 0x3a
175         { "TOCLIENT_CRAFTITEMDEF",             0, false }, // 0x3b obsolete
176         { "TOCLIENT_ANNOUNCE_MEDIA",           0, true }, // 0x3c
177         { "TOCLIENT_ITEMDEF",                  0, true }, // 0x3d
178         null_command_factory,
179         { "TOCLIENT_PLAY_SOUND",               0, true }, // 0x3f
180         { "TOCLIENT_STOP_SOUND",               0, true }, // 0x40
181         { "TOCLIENT_PRIVILEGES",               0, true }, // 0x41
182         { "TOCLIENT_INVENTORY_FORMSPEC",       0, true }, // 0x42
183         { "TOCLIENT_DETACHED_INVENTORY",       0, true }, // 0x43
184         { "TOCLIENT_SHOW_FORMSPEC",            0, true }, // 0x44
185         { "TOCLIENT_MOVEMENT",                 0, true }, // 0x45
186         { "TOCLIENT_SPAWN_PARTICLE",           0, true }, // 0x46
187         { "TOCLIENT_ADD_PARTICLESPAWNER",      0, true }, // 0x47
188         { "TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY",   0, true }, // 0x48
189         { "TOCLIENT_HUDADD",                   1, true }, // 0x49
190         { "TOCLIENT_HUDRM",                    1, true }, // 0x4a
191         { "TOCLIENT_HUDCHANGE",                0, true }, // 0x4b
192         { "TOCLIENT_HUD_SET_FLAGS",            0, true }, // 0x4c
193         { "TOCLIENT_HUD_SET_PARAM",            0, true }, // 0x4d
194         { "TOCLIENT_BREATH",                   0, true }, // 0x4e
195         { "TOCLIENT_SET_SKY",                  0, true }, // 0x4f
196         { "TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO", 0, true }, // 0x50
197         { "TOCLIENT_LOCAL_PLAYER_ANIMATIONS",  0, true }, // 0x51
198         { "TOCLIENT_EYE_OFFSET",               0, true }, // 0x52
199         { "TOCLIENT_DELETE_PARTICLESPAWNER",   0, true }, // 0x53
200         { "TOCLIENT_CLOUD_PARAMS",             0, true }, // 0x54
201         null_command_factory,
202         null_command_factory,
203         null_command_factory,
204         null_command_factory,
205         null_command_factory,
206         null_command_factory,
207         null_command_factory,
208         null_command_factory,
209         null_command_factory,
210         null_command_factory,
211         null_command_factory,
212         { "TOSERVER_SRP_BYTES_S_B",            0, true }, // 0x60
213 };