LCOV - code coverage report
Current view: top level - src/network - clientopcodes.cpp (source / functions) Hit Total Coverage
Test: report Lines: 1 1 100.0 %
Date: 2015-07-11 18:23:49 Functions: 2 2 100.0 %

          Line data    Source code
       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 = {"TOCLIENT_NULL", TOCLIENT_STATE_ALL, &Client::handleCommand_Null};
      24             : 
      25             : const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
      26             : {
      27             :         null_command_handler, // 0x00 (never use this)
      28             :         null_command_handler, // 0x01
      29             :         { "TOCLIENT_HELLO",                   TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_Hello }, // 0x02
      30             :         { "TOCLIENT_AUTH_ACCEPT",             TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_AuthAccept }, // 0x03
      31             :         { "TOCLIENT_ACCEPT_SUDO_MODE",        TOCLIENT_STATE_CONNECTED, &Client::handleCommand_AcceptSudoMode}, // 0x04
      32             :         { "TOCLIENT_DENY_SUDO_MODE",          TOCLIENT_STATE_CONNECTED, &Client::handleCommand_DenySudoMode}, // 0x05
      33             :         null_command_handler, // 0x06
      34             :         null_command_handler, // 0x07
      35             :         null_command_handler, // 0x08
      36             :         null_command_handler, // 0x09
      37             :         { "TOCLIENT_ACCESS_DENIED",           TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_AccessDenied }, // 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             :         { "TOCLIENT_INIT",                    TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_InitLegacy }, // 0x10
      44             :         null_command_handler,
      45             :         null_command_handler,
      46             :         null_command_handler,
      47             :         null_command_handler,
      48             :         null_command_handler,
      49             :         null_command_handler,
      50             :         null_command_handler,
      51             :         null_command_handler,
      52             :         null_command_handler,
      53             :         null_command_handler,
      54             :         null_command_handler,
      55             :         null_command_handler,
      56             :         null_command_handler,
      57             :         null_command_handler,
      58             :         null_command_handler,
      59             :         { "TOCLIENT_BLOCKDATA",                TOCLIENT_STATE_CONNECTED, &Client::handleCommand_BlockData }, // 0x20
      60             :         { "TOCLIENT_ADDNODE",                  TOCLIENT_STATE_CONNECTED, &Client::handleCommand_AddNode }, // 0x21
      61             :         { "TOCLIENT_REMOVENODE",               TOCLIENT_STATE_CONNECTED, &Client::handleCommand_RemoveNode }, // 0x22
      62             :         null_command_handler,
      63             :         null_command_handler,
      64             :         null_command_handler,
      65             :         null_command_handler,
      66             :         { "TOCLIENT_INVENTORY",                TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Inventory }, // 0x27
      67             :         null_command_handler,
      68             :         { "TOCLIENT_TIME_OF_DAY",              TOCLIENT_STATE_CONNECTED, &Client::handleCommand_TimeOfDay }, // 0x29
      69             :         null_command_handler,
      70             :         null_command_handler,
      71             :         null_command_handler,
      72             :         null_command_handler,
      73             :         null_command_handler,
      74             :         null_command_handler,
      75             :         { "TOCLIENT_CHAT_MESSAGE",             TOCLIENT_STATE_CONNECTED, &Client::handleCommand_ChatMessage }, // 0x30
      76             :         { "TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_ActiveObjectRemoveAdd }, // 0x31
      77             :         { "TOCLIENT_ACTIVE_OBJECT_MESSAGES",   TOCLIENT_STATE_CONNECTED, &Client::handleCommand_ActiveObjectMessages }, // 0x32
      78             :         { "TOCLIENT_HP",                       TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HP }, // 0x33
      79             :         { "TOCLIENT_MOVE_PLAYER",              TOCLIENT_STATE_CONNECTED, &Client::handleCommand_MovePlayer }, // 0x34
      80             :         { "TOCLIENT_ACCESS_DENIED_LEGACY",     TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_AccessDenied }, // 0x35
      81             :         { "TOCLIENT_PLAYERITEM",               TOCLIENT_STATE_CONNECTED, &Client::handleCommand_PlayerItem }, // 0x36
      82             :         { "TOCLIENT_DEATHSCREEN",              TOCLIENT_STATE_CONNECTED, &Client::handleCommand_DeathScreen }, // 0x37
      83             :         { "TOCLIENT_MEDIA",                    TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Media }, // 0x38
      84             :         { "TOCLIENT_TOOLDEF",                  TOCLIENT_STATE_CONNECTED, &Client::handleCommand_ToolDef }, // 0x39
      85             :         { "TOCLIENT_NODEDEF",                  TOCLIENT_STATE_CONNECTED, &Client::handleCommand_NodeDef }, // 0x3a
      86             :         { "TOCLIENT_CRAFTITEMDEF",             TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CraftItemDef }, // 0x3b
      87             :         { "TOCLIENT_ANNOUNCE_MEDIA",           TOCLIENT_STATE_CONNECTED, &Client::handleCommand_AnnounceMedia }, // 0x3c
      88             :         { "TOCLIENT_ITEMDEF",                  TOCLIENT_STATE_CONNECTED, &Client::handleCommand_ItemDef }, // 0x3d
      89             :         null_command_handler,
      90             :         { "TOCLIENT_PLAY_SOUND",               TOCLIENT_STATE_CONNECTED, &Client::handleCommand_PlaySound }, // 0x3f
      91             :         { "TOCLIENT_STOP_SOUND",               TOCLIENT_STATE_CONNECTED, &Client::handleCommand_StopSound }, // 0x40
      92             :         { "TOCLIENT_PRIVILEGES",               TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Privileges }, // 0x41
      93             :         { "TOCLIENT_INVENTORY_FORMSPEC",       TOCLIENT_STATE_CONNECTED, &Client::handleCommand_InventoryFormSpec }, // 0x42
      94             :         { "TOCLIENT_DETACHED_INVENTORY",       TOCLIENT_STATE_CONNECTED, &Client::handleCommand_DetachedInventory }, // 0x43
      95             :         { "TOCLIENT_SHOW_FORMSPEC",            TOCLIENT_STATE_CONNECTED, &Client::handleCommand_ShowFormSpec }, // 0x44
      96             :         { "TOCLIENT_MOVEMENT",                 TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Movement }, // 0x45
      97             :         { "TOCLIENT_SPAWN_PARTICLE",           TOCLIENT_STATE_CONNECTED, &Client::handleCommand_SpawnParticle }, // 0x46
      98             :         { "TOCLIENT_ADD_PARTICLESPAWNER",      TOCLIENT_STATE_CONNECTED, &Client::handleCommand_AddParticleSpawner }, // 0x47
      99             :         { "TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY",   TOCLIENT_STATE_CONNECTED, &Client::handleCommand_DeleteParticleSpawner }, // 0x48
     100             :         { "TOCLIENT_HUDADD",                   TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudAdd }, // 0x49
     101             :         { "TOCLIENT_HUDRM",                    TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudRemove }, // 0x4a
     102             :         { "TOCLIENT_HUDCHANGE",                TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudChange }, // 0x4b
     103             :         { "TOCLIENT_HUD_SET_FLAGS",            TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudSetFlags }, // 0x4c
     104             :         { "TOCLIENT_HUD_SET_PARAM",            TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudSetParam }, // 0x4d
     105             :         { "TOCLIENT_BREATH",                   TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Breath }, // 0x4e
     106             :         { "TOCLIENT_SET_SKY",                  TOCLIENT_STATE_CONNECTED, &Client::handleCommand_HudSetSky }, // 0x4f
     107             :         { "TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_OverrideDayNightRatio }, // 0x50
     108             :         { "TOCLIENT_LOCAL_PLAYER_ANIMATIONS",  TOCLIENT_STATE_CONNECTED, &Client::handleCommand_LocalPlayerAnimations }, // 0x51
     109             :         { "TOCLIENT_EYE_OFFSET",               TOCLIENT_STATE_CONNECTED, &Client::handleCommand_EyeOffset }, // 0x52
     110             :         { "TOCLIENT_DELETE_PARTICLESPAWNER",   TOCLIENT_STATE_CONNECTED, &Client::handleCommand_DeleteParticleSpawner }, // 0x53
     111             :         null_command_handler,
     112             :         null_command_handler,
     113             :         null_command_handler,
     114             :         null_command_handler,
     115             :         null_command_handler,
     116             :         null_command_handler,
     117             :         null_command_handler,
     118             :         null_command_handler,
     119             :         null_command_handler,
     120             :         null_command_handler,
     121             :         null_command_handler,
     122             :         null_command_handler,
     123             :         { "TOCLIENT_SRP_BYTES_S_B",            TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_SrpBytesSandB }, // 0x60
     124             : };
     125             : 
     126             : const static ServerCommandFactory null_command_factory = { "TOSERVER_NULL", 0, false };
     127             : 
     128             : const ServerCommandFactory serverCommandFactoryTable[TOSERVER_NUM_MSG_TYPES] =
     129             : {
     130             :         null_command_factory, // 0x00
     131             :         null_command_factory, // 0x01
     132             :         { "TOSERVER_INIT",               1, false }, // 0x02
     133             :         null_command_factory, // 0x03
     134             :         null_command_factory, // 0x04
     135             :         null_command_factory, // 0x05
     136             :         null_command_factory, // 0x06
     137             :         null_command_factory, // 0x07
     138             :         null_command_factory, // 0x08
     139             :         null_command_factory, // 0x09
     140             :         null_command_factory, // 0x0a
     141             :         null_command_factory, // 0x0b
     142             :         null_command_factory, // 0x0c
     143             :         null_command_factory, // 0x0d
     144             :         null_command_factory, // 0x0e
     145             :         null_command_factory, // 0x0F
     146             :         { "TOSERVER_INIT_LEGACY",        1, false }, // 0x10
     147             :         { "TOSERVER_INIT2",              1, true }, // 0x11
     148             :         null_command_factory, // 0x12
     149             :         null_command_factory, // 0x13
     150             :         null_command_factory, // 0x14
     151             :         null_command_factory, // 0x15
     152             :         null_command_factory, // 0x16
     153             :         null_command_factory, // 0x17
     154             :         null_command_factory, // 0x18
     155             :         null_command_factory, // 0x19
     156             :         null_command_factory, // 0x1a
     157             :         null_command_factory, // 0x1b
     158             :         null_command_factory, // 0x1c
     159             :         null_command_factory, // 0x1d
     160             :         null_command_factory, // 0x1e
     161             :         null_command_factory, // 0x1f
     162             :         null_command_factory, // 0x20
     163             :         null_command_factory, // 0x21
     164             :         null_command_factory, // 0x22
     165             :         { "TOSERVER_PLAYERPOS",          0, false }, // 0x23
     166             :         { "TOSERVER_GOTBLOCKS",          2, true }, // 0x24
     167             :         { "TOSERVER_DELETEDBLOCKS",      2, true }, // 0x25
     168             :         null_command_factory, // 0x26
     169             :         { "TOSERVER_CLICK_OBJECT",       0, false }, // 0x27
     170             :         { "TOSERVER_GROUND_ACTION",      0, false }, // 0x28
     171             :         { "TOSERVER_RELEASE",            0, false }, // 0x29
     172             :         null_command_factory, // 0x2a
     173             :         null_command_factory, // 0x2b
     174             :         null_command_factory, // 0x2c
     175             :         null_command_factory, // 0x2d
     176             :         null_command_factory, // 0x2e
     177             :         null_command_factory, // 0x2f
     178             :         { "TOSERVER_SIGNTEXT",           0, false }, // 0x30
     179             :         { "TOSERVER_INVENTORY_ACTION",   0, true }, // 0x31
     180             :         { "TOSERVER_CHAT_MESSAGE",       0, true }, // 0x32
     181             :         { "TOSERVER_SIGNNODETEXT",       0, false }, // 0x33
     182             :         { "TOSERVER_CLICK_ACTIVEOBJECT", 0, false }, // 0x34
     183             :         { "TOSERVER_DAMAGE",             0, true }, // 0x35
     184             :         { "TOSERVER_PASSWORD_LEGACY",    0, true }, // 0x36
     185             :         { "TOSERVER_PLAYERITEM",         0, true }, // 0x37
     186             :         { "TOSERVER_RESPAWN",            0, true }, // 0x38
     187             :         { "TOSERVER_INTERACT",           0, true }, // 0x39
     188             :         { "TOSERVER_REMOVED_SOUNDS",     1, true }, // 0x3a
     189             :         { "TOSERVER_NODEMETA_FIELDS",    0, true }, // 0x3b
     190             :         { "TOSERVER_INVENTORY_FIELDS",   0, true }, // 0x3c
     191             :         null_command_factory, // 0x3d
     192             :         null_command_factory, // 0x3e
     193             :         null_command_factory, // 0x3f
     194             :         { "TOSERVER_REQUEST_MEDIA",      1, true }, // 0x40
     195             :         { "TOSERVER_RECEIVED_MEDIA",     1, true }, // 0x41
     196             :         { "TOSERVER_BREATH",             0, true }, // 0x42
     197             :         { "TOSERVER_CLIENT_READY",       0, true }, // 0x43
     198             :         null_command_factory, // 0x44
     199             :         null_command_factory, // 0x45
     200             :         null_command_factory, // 0x46
     201             :         null_command_factory, // 0x47
     202             :         null_command_factory, // 0x48
     203             :         null_command_factory, // 0x49
     204             :         null_command_factory, // 0x4a
     205             :         null_command_factory, // 0x4b
     206             :         null_command_factory, // 0x4c
     207             :         null_command_factory, // 0x4d
     208             :         null_command_factory, // 0x4e
     209             :         null_command_factory, // 0x4f
     210             :         { "TOSERVER_FIRST_SRP",          1, true }, // 0x50
     211             :         { "TOSERVER_SRP_BYTES_A",        1, true }, // 0x51
     212             :         { "TOSERVER_SRP_BYTES_M",        1, true }, // 0x52
     213           3 : };

Generated by: LCOV version 1.11