]> git.lizzy.rs Git - dragonfireclient.git/blob - src/network/clientopcodes.cpp
Make Lint Happy
[dragonfireclient.git] / src / network / clientopcodes.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 "clientopcodes.h"
22
23 const static ToClientCommandHandler null_command_handler = {
24                 "TOCLIENT_NULL", TOCLIENT_STATE_ALL, &Client::handleCommand_Null};
25
26 const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] = {
27                 null_command_handler, // 0x00 (never use this)
28                 null_command_handler, // 0x01
29                 {"TOCLIENT_HELLO", TOCLIENT_STATE_NOT_CONNECTED,
30                                 &Client::handleCommand_Hello}, // 0x02
31                 {"TOCLIENT_AUTH_ACCEPT", TOCLIENT_STATE_NOT_CONNECTED,
32                                 &Client::handleCommand_AuthAccept}, // 0x03
33                 {"TOCLIENT_ACCEPT_SUDO_MODE", TOCLIENT_STATE_CONNECTED,
34                                 &Client::handleCommand_AcceptSudoMode}, // 0x04
35                 {"TOCLIENT_DENY_SUDO_MODE", TOCLIENT_STATE_CONNECTED,
36                                 &Client::handleCommand_DenySudoMode}, // 0x05
37                 null_command_handler,                                 // 0x06
38                 null_command_handler,                                 // 0x07
39                 null_command_handler,                                 // 0x08
40                 null_command_handler,                                 // 0x09
41                 {"TOCLIENT_ACCESS_DENIED", TOCLIENT_STATE_NOT_CONNECTED,
42                                 &Client::handleCommand_AccessDenied}, // 0x0A
43                 null_command_handler,                                 // 0x0B
44                 null_command_handler,                                 // 0x0C
45                 null_command_handler,                                 // 0x0D
46                 null_command_handler,                                 // 0x0E
47                 null_command_handler,                                 // 0x0F
48                 null_command_handler,                                 // 0x10
49                 null_command_handler, null_command_handler, null_command_handler,
50                 null_command_handler, null_command_handler, null_command_handler,
51                 null_command_handler, null_command_handler, null_command_handler,
52                 null_command_handler, null_command_handler, null_command_handler,
53                 null_command_handler, null_command_handler, null_command_handler,
54                 {"TOCLIENT_BLOCKDATA", TOCLIENT_STATE_CONNECTED,
55                                 &Client::handleCommand_BlockData}, // 0x20
56                 {"TOCLIENT_ADDNODE", TOCLIENT_STATE_CONNECTED,
57                                 &Client::handleCommand_AddNode}, // 0x21
58                 {"TOCLIENT_REMOVENODE", TOCLIENT_STATE_CONNECTED,
59                                 &Client::handleCommand_RemoveNode}, // 0x22
60                 null_command_handler, null_command_handler, null_command_handler,
61                 null_command_handler,
62                 {"TOCLIENT_INVENTORY", TOCLIENT_STATE_CONNECTED,
63                                 &Client::handleCommand_Inventory}, // 0x27
64                 null_command_handler,
65                 {"TOCLIENT_TIME_OF_DAY", TOCLIENT_STATE_CONNECTED,
66                                 &Client::handleCommand_TimeOfDay}, // 0x29
67                 {"TOCLIENT_CSM_RESTRICTION_FLAGS", TOCLIENT_STATE_CONNECTED,
68                                 &Client::handleCommand_CSMRestrictionFlags}, // 0x2A
69                 {"TOCLIENT_PLAYER_SPEED", TOCLIENT_STATE_CONNECTED,
70                                 &Client::handleCommand_PlayerSpeed}, // 0x2B
71                 {"TOCLIENT_MEDIA_PUSH", TOCLIENT_STATE_CONNECTED,
72                                 &Client::handleCommand_MediaPush}, // 0x2C
73                 null_command_handler, null_command_handler,
74                 {"TOCLIENT_CHAT_MESSAGE", TOCLIENT_STATE_CONNECTED,
75                                 &Client::handleCommand_ChatMessage}, // 0x2F
76                 null_command_handler,                                // 0x30
77                 {"TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD", TOCLIENT_STATE_CONNECTED,
78                                 &Client::handleCommand_ActiveObjectRemoveAdd}, // 0x31
79                 {"TOCLIENT_ACTIVE_OBJECT_MESSAGES", TOCLIENT_STATE_CONNECTED,
80                                 &Client::handleCommand_ActiveObjectMessages}, // 0x32
81                 {"TOCLIENT_HP", TOCLIENT_STATE_CONNECTED,
82                                 &Client::handleCommand_HP}, // 0x33
83                 {"TOCLIENT_MOVE_PLAYER", TOCLIENT_STATE_CONNECTED,
84                                 &Client::handleCommand_MovePlayer}, // 0x34
85                 {"TOCLIENT_ACCESS_DENIED_LEGACY", TOCLIENT_STATE_NOT_CONNECTED,
86                                 &Client::handleCommand_AccessDenied}, // 0x35
87                 {"TOCLIENT_FOV", TOCLIENT_STATE_CONNECTED,
88                                 &Client::handleCommand_Fov}, // 0x36
89                 {"TOCLIENT_DEATHSCREEN", TOCLIENT_STATE_CONNECTED,
90                                 &Client::handleCommand_DeathScreen}, // 0x37
91                 {"TOCLIENT_MEDIA", TOCLIENT_STATE_CONNECTED,
92                                 &Client::handleCommand_Media}, // 0x38
93                 null_command_handler,
94                 {"TOCLIENT_NODEDEF", TOCLIENT_STATE_CONNECTED,
95                                 &Client::handleCommand_NodeDef}, // 0x3a
96                 null_command_handler,
97                 {"TOCLIENT_ANNOUNCE_MEDIA", TOCLIENT_STATE_CONNECTED,
98                                 &Client::handleCommand_AnnounceMedia}, // 0x3c
99                 {"TOCLIENT_ITEMDEF", TOCLIENT_STATE_CONNECTED,
100                                 &Client::handleCommand_ItemDef}, // 0x3d
101                 null_command_handler,
102                 {"TOCLIENT_PLAY_SOUND", TOCLIENT_STATE_CONNECTED,
103                                 &Client::handleCommand_PlaySound}, // 0x3f
104                 {"TOCLIENT_STOP_SOUND", TOCLIENT_STATE_CONNECTED,
105                                 &Client::handleCommand_StopSound}, // 0x40
106                 {"TOCLIENT_PRIVILEGES", TOCLIENT_STATE_CONNECTED,
107                                 &Client::handleCommand_Privileges}, // 0x41
108                 {"TOCLIENT_INVENTORY_FORMSPEC", TOCLIENT_STATE_CONNECTED,
109                                 &Client::handleCommand_InventoryFormSpec}, // 0x42
110                 {"TOCLIENT_DETACHED_INVENTORY", TOCLIENT_STATE_CONNECTED,
111                                 &Client::handleCommand_DetachedInventory}, // 0x43
112                 {"TOCLIENT_SHOW_FORMSPEC", TOCLIENT_STATE_CONNECTED,
113                                 &Client::handleCommand_ShowFormSpec}, // 0x44
114                 {"TOCLIENT_MOVEMENT", TOCLIENT_STATE_CONNECTED,
115                                 &Client::handleCommand_Movement}, // 0x45
116                 {"TOCLIENT_SPAWN_PARTICLE", TOCLIENT_STATE_CONNECTED,
117                                 &Client::handleCommand_SpawnParticle}, // 0x46
118                 {"TOCLIENT_ADD_PARTICLESPAWNER", TOCLIENT_STATE_CONNECTED,
119                                 &Client::handleCommand_AddParticleSpawner}, // 0x47
120                 null_command_handler,
121                 {"TOCLIENT_HUDADD", TOCLIENT_STATE_CONNECTED,
122                                 &Client::handleCommand_HudAdd}, // 0x49
123                 {"TOCLIENT_HUDRM", TOCLIENT_STATE_CONNECTED,
124                                 &Client::handleCommand_HudRemove}, // 0x4a
125                 {"TOCLIENT_HUDCHANGE", TOCLIENT_STATE_CONNECTED,
126                                 &Client::handleCommand_HudChange}, // 0x4b
127                 {"TOCLIENT_HUD_SET_FLAGS", TOCLIENT_STATE_CONNECTED,
128                                 &Client::handleCommand_HudSetFlags}, // 0x4c
129                 {"TOCLIENT_HUD_SET_PARAM", TOCLIENT_STATE_CONNECTED,
130                                 &Client::handleCommand_HudSetParam}, // 0x4d
131                 {"TOCLIENT_BREATH", TOCLIENT_STATE_CONNECTED,
132                                 &Client::handleCommand_Breath}, // 0x4e
133                 {"TOCLIENT_SET_SKY", TOCLIENT_STATE_CONNECTED,
134                                 &Client::handleCommand_HudSetSky}, // 0x4f
135                 {"TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO", TOCLIENT_STATE_CONNECTED,
136                                 &Client::handleCommand_OverrideDayNightRatio}, // 0x50
137                 {"TOCLIENT_LOCAL_PLAYER_ANIMATIONS", TOCLIENT_STATE_CONNECTED,
138                                 &Client::handleCommand_LocalPlayerAnimations}, // 0x51
139                 {"TOCLIENT_EYE_OFFSET", TOCLIENT_STATE_CONNECTED,
140                                 &Client::handleCommand_EyeOffset}, // 0x52
141                 {"TOCLIENT_DELETE_PARTICLESPAWNER", TOCLIENT_STATE_CONNECTED,
142                                 &Client::handleCommand_DeleteParticleSpawner}, // 0x53
143                 {"TOCLIENT_CLOUD_PARAMS", TOCLIENT_STATE_CONNECTED,
144                                 &Client::handleCommand_CloudParams}, // 0x54
145                 {"TOCLIENT_FADE_SOUND", TOCLIENT_STATE_CONNECTED,
146                                 &Client::handleCommand_FadeSound}, // 0x55
147                 {"TOCLIENT_UPDATE_PLAYER_LIST", TOCLIENT_STATE_CONNECTED,
148                                 &Client::handleCommand_UpdatePlayerList}, // 0x56
149                 {"TOCLIENT_MODCHANNEL_MSG", TOCLIENT_STATE_CONNECTED,
150                                 &Client::handleCommand_ModChannelMsg}, // 0x57
151                 {"TOCLIENT_MODCHANNEL_SIGNAL", TOCLIENT_STATE_CONNECTED,
152                                 &Client::handleCommand_ModChannelSignal}, // 0x58
153                 {"TOCLIENT_NODEMETA_CHANGED", TOCLIENT_STATE_CONNECTED,
154                                 &Client::handleCommand_NodemetaChanged}, // 0x59
155                 {"TOCLIENT_SET_SUN", TOCLIENT_STATE_CONNECTED,
156                                 &Client::handleCommand_HudSetSun}, // 0x5a
157                 {"TOCLIENT_SET_MOON", TOCLIENT_STATE_CONNECTED,
158                                 &Client::handleCommand_HudSetMoon}, // 0x5b
159                 {"TOCLIENT_SET_STARS", TOCLIENT_STATE_CONNECTED,
160                                 &Client::handleCommand_HudSetStars}, // 0x5c
161                 null_command_handler, null_command_handler, null_command_handler,
162                 {"TOCLIENT_SRP_BYTES_S_B", TOCLIENT_STATE_NOT_CONNECTED,
163                                 &Client::handleCommand_SrpBytesSandB}, // 0x60
164                 {"TOCLIENT_FORMSPEC_PREPEND", TOCLIENT_STATE_CONNECTED,
165                                 &Client::handleCommand_FormspecPrepend}, // 0x61,
166 };
167
168 const static ServerCommandFactory null_command_factory = {"TOSERVER_NULL", 0, false};
169
170 /*
171         Channels used for Client -> Server communication
172         2: Notifications back to the server (e.g. GOTBLOCKS)
173         1: Init and Authentication
174         0: everything else
175
176         Packet order is only guaranteed inside a channel, so packets that operate on
177         the same objects are *required* to be in the same channel.
178 */
179
180 const ServerCommandFactory serverCommandFactoryTable[TOSERVER_NUM_MSG_TYPES] = {
181                 null_command_factory,                   // 0x00
182                 null_command_factory,                   // 0x01
183                 {"TOSERVER_INIT", 1, false},            // 0x02
184                 null_command_factory,                   // 0x03
185                 null_command_factory,                   // 0x04
186                 null_command_factory,                   // 0x05
187                 null_command_factory,                   // 0x06
188                 null_command_factory,                   // 0x07
189                 null_command_factory,                   // 0x08
190                 null_command_factory,                   // 0x09
191                 null_command_factory,                   // 0x0a
192                 null_command_factory,                   // 0x0b
193                 null_command_factory,                   // 0x0c
194                 null_command_factory,                   // 0x0d
195                 null_command_factory,                   // 0x0e
196                 null_command_factory,                   // 0x0f
197                 null_command_factory,                   // 0x10
198                 {"TOSERVER_INIT2", 1, true},            // 0x11
199                 null_command_factory,                   // 0x12
200                 null_command_factory,                   // 0x13
201                 null_command_factory,                   // 0x14
202                 null_command_factory,                   // 0x15
203                 null_command_factory,                   // 0x16
204                 {"TOSERVER_MODCHANNEL_JOIN", 0, true},  // 0x17
205                 {"TOSERVER_MODCHANNEL_LEAVE", 0, true}, // 0x18
206                 {"TOSERVER_MODCHANNEL_MSG", 0, true},   // 0x19
207                 null_command_factory,                   // 0x1a
208                 null_command_factory,                   // 0x1b
209                 null_command_factory,                   // 0x1c
210                 null_command_factory,                   // 0x1d
211                 null_command_factory,                   // 0x1e
212                 null_command_factory,                   // 0x1f
213                 null_command_factory,                   // 0x20
214                 null_command_factory,                   // 0x21
215                 null_command_factory,                   // 0x22
216                 {"TOSERVER_PLAYERPOS", 0, false},       // 0x23
217                 {"TOSERVER_GOTBLOCKS", 2, true},        // 0x24
218                 {"TOSERVER_DELETEDBLOCKS", 2, true},    // 0x25
219                 null_command_factory,                   // 0x26
220                 null_command_factory,                   // 0x27
221                 null_command_factory,                   // 0x28
222                 null_command_factory,                   // 0x29
223                 null_command_factory,                   // 0x2a
224                 null_command_factory,                   // 0x2b
225                 null_command_factory,                   // 0x2c
226                 null_command_factory,                   // 0x2d
227                 null_command_factory,                   // 0x2e
228                 null_command_factory,                   // 0x2f
229                 null_command_factory,                   // 0x30
230                 {"TOSERVER_INVENTORY_ACTION", 0, true}, // 0x31
231                 {"TOSERVER_CHAT_MESSAGE", 0, true},     // 0x32
232                 null_command_factory,                   // 0x33
233                 null_command_factory,                   // 0x34
234                 {"TOSERVER_DAMAGE", 0, true},           // 0x35
235                 null_command_factory,                   // 0x36
236                 {"TOSERVER_PLAYERITEM", 0, true},       // 0x37
237                 {"TOSERVER_RESPAWN", 0, true},          // 0x38
238                 {"TOSERVER_INTERACT", 0, true},         // 0x39
239                 {"TOSERVER_REMOVED_SOUNDS", 2, true},   // 0x3a
240                 {"TOSERVER_NODEMETA_FIELDS", 0, true},  // 0x3b
241                 {"TOSERVER_INVENTORY_FIELDS", 0, true}, // 0x3c
242                 null_command_factory,                   // 0x3d
243                 null_command_factory,                   // 0x3e
244                 null_command_factory,                   // 0x3f
245                 {"TOSERVER_REQUEST_MEDIA", 1, true},    // 0x40
246                 null_command_factory,                   // 0x41
247                 null_command_factory,                   // 0x42
248                 {"TOSERVER_CLIENT_READY", 1, true},     // 0x43
249                 null_command_factory,                   // 0x44
250                 null_command_factory,                   // 0x45
251                 null_command_factory,                   // 0x46
252                 null_command_factory,                   // 0x47
253                 null_command_factory,                   // 0x48
254                 null_command_factory,                   // 0x49
255                 null_command_factory,                   // 0x4a
256                 null_command_factory,                   // 0x4b
257                 null_command_factory,                   // 0x4c
258                 null_command_factory,                   // 0x4d
259                 null_command_factory,                   // 0x4e
260                 null_command_factory,                   // 0x4f
261                 {"TOSERVER_FIRST_SRP", 1, true},        // 0x50
262                 {"TOSERVER_SRP_BYTES_A", 1, true},      // 0x51
263                 {"TOSERVER_SRP_BYTES_M", 1, true},      // 0x52
264 };