Split networkprotocol.h
parent
ff4c3ccd33
commit
d9f6645c50
|
@ -1,5 +1,5 @@
|
|||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
if(${CMAKE_VERSION} STREQUAL "2.8.2")
|
||||
# Bug http://vtk.org/Bug/view.php?id=11020
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
project(freeminer)
|
||||
|
||||
|
@ -685,7 +685,6 @@ set(FMcommon_SRCS
|
|||
circuit_element_virtual.cpp
|
||||
key_value_storage.cpp
|
||||
fm_bitset.cpp
|
||||
mapgen_v5.cpp
|
||||
mapgen_indev.cpp
|
||||
mapgen_math.cpp
|
||||
log_types.cpp
|
||||
|
|
|
@ -33,7 +33,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "util/strfnd.h"
|
||||
#include "network/clientopcodes.h"
|
||||
#include "util/serialize.h"
|
||||
|
||||
#include "fm_networkprotocol.h"
|
||||
#include "settings.h"
|
||||
#include "emerge.h"
|
||||
#include "profiler.h"
|
||||
|
@ -101,7 +101,7 @@ void Client::handleCommand_InitLegacy(NetworkPacket* pkt) {
|
|||
// packet[TOCLIENT_INIT_PROTOCOL_VERSION_FM].convert( not used );
|
||||
|
||||
// Reply to server
|
||||
MSGPACK_PACKET_INIT(TOSERVER_INIT2, 0);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_INIT2, 0);
|
||||
m_con.Send(PEER_ID_SERVER, 1, buffer, true);
|
||||
|
||||
m_state = LC_Init;
|
||||
|
|
|
@ -14,12 +14,15 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "../util/auth.h"
|
||||
#include "client.h"
|
||||
#include "networkprotocol.h"
|
||||
|
||||
void Client::request_media(const std::vector<std::string> &file_requests)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOSERVER_REQUEST_MEDIA, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_REQUEST_MEDIA, 1);
|
||||
PACK(TOSERVER_REQUEST_MEDIA_FILES, file_requests);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -31,7 +34,7 @@ void Client::request_media(const std::vector<std::string> &file_requests)
|
|||
void Client::received_media()
|
||||
{
|
||||
// notify server we received everything
|
||||
MSGPACK_PACKET_INIT(TOSERVER_RECEIVED_MEDIA, 0);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_RECEIVED_MEDIA, 0);
|
||||
// Send as reliable
|
||||
Send(1, buffer, true);
|
||||
infostream<<"Client: Notifying server that we received all media"
|
||||
|
@ -61,7 +64,7 @@ void Client::interact(u8 action, const PointedThing& pointed)
|
|||
3: place block or item (to abovesurface)
|
||||
4: use item
|
||||
*/
|
||||
MSGPACK_PACKET_INIT(TOSERVER_INTERACT, 3);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_INTERACT, 3);
|
||||
PACK(TOSERVER_INTERACT_ACTION, action);
|
||||
PACK(TOSERVER_INTERACT_ITEM, getPlayerItem());
|
||||
PACK(TOSERVER_INTERACT_POINTED_THING, pointed);
|
||||
|
@ -80,7 +83,7 @@ void Client::sendLegacyInit(const std::string &playerName, const std::string &pl
|
|||
// [23] u8[28] password (new in some version)
|
||||
// [51] u16 minimum supported network protocol version (added sometime)
|
||||
// [53] u16 maximum supported network protocol version (added later than the previous one)
|
||||
MSGPACK_PACKET_INIT(TOSERVER_INIT_LEGACY, 6);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_INIT_LEGACY, 6);
|
||||
PACK(TOSERVER_INIT_LEGACY_FMT, SER_FMT_VER_HIGHEST_READ);
|
||||
PACK(TOSERVER_INIT_LEGACY_NAME, playerName);
|
||||
PACK(TOSERVER_INIT_LEGACY_PASSWORD, playerPassword);
|
||||
|
@ -94,7 +97,7 @@ void Client::sendLegacyInit(const std::string &playerName, const std::string &pl
|
|||
|
||||
void Client::sendInit(const std::string &playerName)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOSERVER_INIT, 4);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_INIT, 4);
|
||||
|
||||
// TODO (later) actually send supported compression modes
|
||||
PACK(TOSERVER_INIT_FMT, SER_FMT_VER_HIGHEST_READ);
|
||||
|
@ -109,7 +112,7 @@ void Client::sendInit(const std::string &playerName)
|
|||
void Client::sendDeletedBlocks(std::vector<v3s16> &blocks)
|
||||
{
|
||||
|
||||
MSGPACK_PACKET_INIT(TOSERVER_DELETEDBLOCKS, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_DELETEDBLOCKS, 1);
|
||||
PACK(TOSERVER_DELETEDBLOCKS_DATA, blocks);
|
||||
|
||||
m_con.Send(PEER_ID_SERVER, 2, buffer, true);
|
||||
|
@ -126,7 +129,7 @@ void Client::sendGotBlocks(v3s16 block)
|
|||
|
||||
void Client::sendRemovedSounds(std::vector<s32> &soundList)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOSERVER_REMOVED_SOUNDS, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_REMOVED_SOUNDS, 1);
|
||||
PACK(TOSERVER_REMOVED_SOUNDS_IDS, soundList);
|
||||
// Send as reliable
|
||||
Send(1, buffer, true);
|
||||
|
@ -135,7 +138,7 @@ void Client::sendRemovedSounds(std::vector<s32> &soundList)
|
|||
void Client::sendNodemetaFields(v3s16 p, const std::string &formname,
|
||||
const std::unordered_map<std::string, std::string> &fields)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOSERVER_NODEMETA_FIELDS, 3);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_NODEMETA_FIELDS, 3);
|
||||
PACK(TOSERVER_NODEMETA_FIELDS_POS, p);
|
||||
PACK(TOSERVER_NODEMETA_FIELDS_FORMNAME, formname);
|
||||
PACK(TOSERVER_NODEMETA_FIELDS_DATA, fields);
|
||||
|
@ -146,7 +149,7 @@ void Client::sendNodemetaFields(v3s16 p, const std::string &formname,
|
|||
void Client::sendInventoryFields(const std::string &formname,
|
||||
const std::unordered_map<std::string, std::string> &fields)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOSERVER_INVENTORY_FIELDS, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_INVENTORY_FIELDS, 2);
|
||||
PACK(TOSERVER_INVENTORY_FIELDS_FORMNAME, formname);
|
||||
PACK(TOSERVER_INVENTORY_FIELDS_DATA, fields);
|
||||
Send(0, buffer, true);
|
||||
|
@ -154,7 +157,7 @@ void Client::sendInventoryFields(const std::string &formname,
|
|||
|
||||
void Client::sendInventoryAction(InventoryAction *a)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOSERVER_INVENTORY_ACTION, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_INVENTORY_ACTION, 1);
|
||||
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
a->serialize(os);
|
||||
|
@ -168,7 +171,7 @@ void Client::sendInventoryAction(InventoryAction *a)
|
|||
|
||||
void Client::sendChatMessage(const std::string &message)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOSERVER_CHAT_MESSAGE, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_CHAT_MESSAGE, 1);
|
||||
PACK(TOSERVER_CHAT_MESSAGE_DATA, message);
|
||||
// Send as reliable
|
||||
Send(0, buffer, true);
|
||||
|
@ -185,7 +188,7 @@ void Client::sendChangePassword(const std::string &oldpassword,
|
|||
std::string oldpwd = translate_password(playername, oldpassword);
|
||||
std::string newpwd = translate_password(playername, newpassword);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOSERVER_CHANGE_PASSWORD, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_PASSWORD_LEGACY, 2);
|
||||
PACK(TOSERVER_CHANGE_PASSWORD_OLD, oldpwd);
|
||||
PACK(TOSERVER_CHANGE_PASSWORD_NEW, newpwd);
|
||||
|
||||
|
@ -197,7 +200,7 @@ void Client::sendChangePassword(const std::string &oldpassword,
|
|||
void Client::sendDamage(u8 damage)
|
||||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
MSGPACK_PACKET_INIT(TOSERVER_DAMAGE, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_DAMAGE, 1);
|
||||
PACK(TOSERVER_DAMAGE_VALUE, damage);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -208,7 +211,7 @@ void Client::sendBreath(u16 breath)
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOSERVER_BREATH, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_BREATH, 1);
|
||||
PACK(TOSERVER_BREATH_VALUE, breath);
|
||||
// Send as reliable
|
||||
Send(0, buffer, true);
|
||||
|
@ -218,7 +221,7 @@ void Client::sendRespawn()
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOSERVER_RESPAWN, 0);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_RESPAWN, 0);
|
||||
// Send as reliable
|
||||
Send(0, buffer, true);
|
||||
}
|
||||
|
@ -227,7 +230,7 @@ void Client::sendReady()
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOSERVER_CLIENT_READY, 5);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_CLIENT_READY, 5);
|
||||
PACK(TOSERVER_CLIENT_READY_VERSION_MAJOR, VERSION_MAJOR);
|
||||
PACK(TOSERVER_CLIENT_READY_VERSION_MINOR, VERSION_MINOR);
|
||||
PACK(TOSERVER_CLIENT_READY_VERSION_PATCH, VERSION_PATCH);
|
||||
|
@ -271,7 +274,7 @@ void Client::sendPlayerPos()
|
|||
if (myplayer->peer_id != our_peer_id)
|
||||
return;
|
||||
|
||||
MSGPACK_PACKET_INIT(TOSERVER_PLAYERPOS, 5);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_PLAYERPOS, 5);
|
||||
PACK(TOSERVER_PLAYERPOS_POSITION, myplayer->getPosition());
|
||||
PACK(TOSERVER_PLAYERPOS_SPEED, myplayer->getSpeed());
|
||||
PACK(TOSERVER_PLAYERPOS_PITCH, myplayer->getPitch());
|
||||
|
@ -295,7 +298,7 @@ void Client::sendPlayerItem(u16 item)
|
|||
// Check that an existing peer_id is the same as the connection's
|
||||
assert(myplayer->peer_id == our_peer_id);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOSERVER_PLAYERITEM, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_PLAYERITEM, 1);
|
||||
PACK(TOSERVER_PLAYERITEM_VALUE, item);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -304,7 +307,7 @@ void Client::sendPlayerItem(u16 item)
|
|||
|
||||
|
||||
void Client::sendDrawControl() {
|
||||
MSGPACK_PACKET_INIT(TOSERVER_DRAWCONTROL, 5);
|
||||
MSGPACK_PACKET_INIT((int)TOSERVER_DRAWCONTROL, 5);
|
||||
const auto & draw_control = m_env.getClientMap().getControl();
|
||||
PACK(TOSERVER_DRAWCONTROL_WANTED_RANGE, (u32)draw_control.wanted_range);
|
||||
PACK(TOSERVER_DRAWCONTROL_RANGE_ALL, (u32)draw_control.range_all);
|
||||
|
|
|
@ -0,0 +1,486 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include "../irrlichttypes.h"
|
||||
#include "../msgpack_fix.h"
|
||||
#include "../config.h"
|
||||
|
||||
#define CLIENT_PROTOCOL_VERSION_FM 2
|
||||
#define SERVER_PROTOCOL_VERSION_FM 0
|
||||
|
||||
enum
|
||||
{
|
||||
// u8 deployed version
|
||||
TOCLIENT_INIT_DEPLOYED,
|
||||
// u64 map seed
|
||||
TOCLIENT_INIT_SEED,
|
||||
// float recommended send interval (server step)
|
||||
TOCLIENT_INIT_STEP,
|
||||
// v3f player's position
|
||||
TOCLIENT_INIT_POS,
|
||||
// json map params
|
||||
TOCLIENT_INIT_MAP_PARAMS,
|
||||
TOCLIENT_INIT_PROTOCOL_VERSION_FM,
|
||||
TOCLIENT_INIT_WEATHER
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_BLOCKDATA_POS,
|
||||
TOCLIENT_BLOCKDATA_DATA,
|
||||
TOCLIENT_BLOCKDATA_HEAT,
|
||||
TOCLIENT_BLOCKDATA_HUMIDITY,
|
||||
TOCLIENT_BLOCKDATA_STEP,
|
||||
TOCLIENT_BLOCKDATA_CONTENT_ONLY,
|
||||
TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM1,
|
||||
TOCLIENT_BLOCKDATA_CONTENT_ONLY_PARAM2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_ADDNODE_POS,
|
||||
TOCLIENT_ADDNODE_NODE,
|
||||
TOCLIENT_ADDNODE_REMOVE_METADATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_REMOVENODE_POS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// string, serialized inventory
|
||||
TOCLIENT_INVENTORY_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// u16 time (0-23999)
|
||||
TOCLIENT_TIME_OF_DAY_TIME,
|
||||
// f32 time_speed
|
||||
TOCLIENT_TIME_OF_DAY_TIME_SPEED
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// string
|
||||
TOCLIENT_CHAT_MESSAGE_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// list of ids
|
||||
TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD_REMOVE,
|
||||
// list of [id, type, initialization_data]
|
||||
TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD_ADD
|
||||
};
|
||||
|
||||
struct ActiveObjectAddData
|
||||
{
|
||||
ActiveObjectAddData(u16 id_, u8 type_, std::string data_) :
|
||||
id(id_), type(type_), data(data_)
|
||||
{
|
||||
}
|
||||
ActiveObjectAddData() : id(0), type(0), data("") {}
|
||||
u16 id;
|
||||
u8 type;
|
||||
std::string data;
|
||||
MSGPACK_DEFINE(id, type, data);
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// list of pair<id, message> where id is u16 and message is string
|
||||
TOCLIENT_ACTIVE_OBJECT_MESSAGES_MESSAGES
|
||||
};
|
||||
|
||||
typedef std::vector<std::pair<unsigned int, std::string>> ActiveObjectMessages;
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_HP_HP
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// v3f player position
|
||||
TOCLIENT_MOVE_PLAYER_POS,
|
||||
// f32 pitch
|
||||
TOCLIENT_MOVE_PLAYER_PITCH,
|
||||
// f32 yaw
|
||||
TOCLIENT_MOVE_PLAYER_YAW
|
||||
// TOCLIENT_MOVE_PLAYER_SPEED
|
||||
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// string
|
||||
TOCLIENT_ACCESS_DENIED_CUSTOM_STRING,
|
||||
// u16 command
|
||||
TOCLIENT_ACCESS_DENIED_REASON,
|
||||
TOCLIENT_ACCESS_DENIED_RECONNECT
|
||||
};
|
||||
|
||||
#define TOCLIENT_PUNCH_PLAYER 0x36
|
||||
enum
|
||||
{
|
||||
// v3f player speed add
|
||||
TOCLIENT_PUNCH_PLAYER_SPEED,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// bool set camera point target
|
||||
TOCLIENT_DEATHSCREEN_SET_CAMERA,
|
||||
// v3f camera point target (to point the death cause or whatever)
|
||||
TOCLIENT_DEATHSCREEN_CAMERA_POINT
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// vector<pair<name, data>>
|
||||
TOCLIENT_MEDIA_MEDIA
|
||||
};
|
||||
|
||||
typedef std::vector<std::pair<std::string, std::string>> MediaData;
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_NODEDEF_DEFINITIONS,
|
||||
TOCLIENT_NODEDEF_DEFINITIONS_ZIP
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// list of [string name, string sha1_digest]
|
||||
TOCLIENT_ANNOUNCE_MEDIA_LIST,
|
||||
// string, url of remote media server
|
||||
TOCLIENT_ANNOUNCE_MEDIA_REMOTE_SERVER
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_ITEMDEF_DEFINITIONS,
|
||||
TOCLIENT_ITEMDEF_DEFINITIONS_ZIP
|
||||
};
|
||||
|
||||
typedef std::vector<std::pair<std::string, std::string>> MediaAnnounceList;
|
||||
|
||||
enum
|
||||
{
|
||||
// s32
|
||||
TOCLIENT_PLAY_SOUND_ID,
|
||||
// string
|
||||
TOCLIENT_PLAY_SOUND_NAME,
|
||||
// f32
|
||||
TOCLIENT_PLAY_SOUND_GAIN,
|
||||
// u8
|
||||
TOCLIENT_PLAY_SOUND_TYPE,
|
||||
// v3f
|
||||
TOCLIENT_PLAY_SOUND_POS,
|
||||
// u16
|
||||
TOCLIENT_PLAY_SOUND_OBJECT_ID,
|
||||
// bool
|
||||
TOCLIENT_PLAY_SOUND_LOOP
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// s32
|
||||
TOCLIENT_STOP_SOUND_ID
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// list of strings
|
||||
TOCLIENT_PRIVILEGES_PRIVILEGES
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// string
|
||||
TOCLIENT_INVENTORY_FORMSPEC_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_DETACHED_INVENTORY_NAME,
|
||||
TOCLIENT_DETACHED_INVENTORY_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// string formspec
|
||||
TOCLIENT_SHOW_FORMSPEC_DATA,
|
||||
// string formname
|
||||
TOCLIENT_SHOW_FORMSPEC_NAME
|
||||
};
|
||||
|
||||
// all values are floats here
|
||||
enum
|
||||
{
|
||||
TOCLIENT_MOVEMENT_ACCELERATION_DEFAULT,
|
||||
TOCLIENT_MOVEMENT_ACCELERATION_AIR,
|
||||
TOCLIENT_MOVEMENT_ACCELERATION_FAST,
|
||||
TOCLIENT_MOVEMENT_SPEED_WALK,
|
||||
TOCLIENT_MOVEMENT_SPEED_CROUCH,
|
||||
TOCLIENT_MOVEMENT_SPEED_FAST,
|
||||
TOCLIENT_MOVEMENT_SPEED_CLIMB,
|
||||
TOCLIENT_MOVEMENT_SPEED_JUMP,
|
||||
TOCLIENT_MOVEMENT_LIQUID_FLUIDITY,
|
||||
TOCLIENT_MOVEMENT_LIQUID_FLUIDITY_SMOOTH,
|
||||
TOCLIENT_MOVEMENT_LIQUID_SINK,
|
||||
TOCLIENT_MOVEMENT_GRAVITY,
|
||||
TOCLIENT_MOVEMENT_FALL_AERODYNAMICS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_SPAWN_PARTICLE_POS,
|
||||
TOCLIENT_SPAWN_PARTICLE_VELOCITY,
|
||||
TOCLIENT_SPAWN_PARTICLE_ACCELERATION,
|
||||
TOCLIENT_SPAWN_PARTICLE_EXPIRATIONTIME,
|
||||
TOCLIENT_SPAWN_PARTICLE_SIZE,
|
||||
TOCLIENT_SPAWN_PARTICLE_COLLISIONDETECTION,
|
||||
TOCLIENT_SPAWN_PARTICLE_VERTICAL,
|
||||
TOCLIENT_SPAWN_PARTICLE_TEXTURE,
|
||||
TOCLIENT_SPAWN_PARTICLE_COLLISION_REMOVAL,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_AMOUNT,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_SPAWNTIME,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MINPOS,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MAXPOS,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MINVEL,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MAXVEL,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MINACC,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MAXACC,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MINEXPTIME,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MAXEXPTIME,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MINSIZE,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_MAXSIZE,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_COLLISIONDETECTION,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_VERTICAL,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_TEXTURE,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_ID,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_COLLISION_REMOVAL,
|
||||
TOCLIENT_ADD_PARTICLESPAWNER_ATTACHED_ID,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_DELETE_PARTICLESPAWNER_ID
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_HUDADD_ID,
|
||||
TOCLIENT_HUDADD_TYPE,
|
||||
TOCLIENT_HUDADD_POS,
|
||||
TOCLIENT_HUDADD_NAME,
|
||||
TOCLIENT_HUDADD_SCALE,
|
||||
TOCLIENT_HUDADD_TEXT,
|
||||
TOCLIENT_HUDADD_NUMBER,
|
||||
TOCLIENT_HUDADD_ITEM,
|
||||
TOCLIENT_HUDADD_DIR,
|
||||
TOCLIENT_HUDADD_ALIGN,
|
||||
TOCLIENT_HUDADD_OFFSET,
|
||||
TOCLIENT_HUDADD_WORLD_POS,
|
||||
TOCLIENT_HUDADD_SIZE,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_HUDRM_ID
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_HUDCHANGE_ID,
|
||||
TOCLIENT_HUDCHANGE_STAT,
|
||||
TOCLIENT_HUDCHANGE_V2F,
|
||||
TOCLIENT_HUDCHANGE_V3F,
|
||||
TOCLIENT_HUDCHANGE_STRING,
|
||||
TOCLIENT_HUDCHANGE_U32,
|
||||
TOCLIENT_HUDCHANGE_V2S32
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_HUD_SET_FLAGS_FLAGS,
|
||||
TOCLIENT_HUD_SET_FLAGS_MASK
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_HUD_SET_PARAM_ID,
|
||||
TOCLIENT_HUD_SET_PARAM_VALUE
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// u16 breath
|
||||
TOCLIENT_BREATH_BREATH
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_SET_SKY_COLOR,
|
||||
TOCLIENT_SET_SKY_TYPE,
|
||||
TOCLIENT_SET_SKY_PARAMS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO_DO,
|
||||
TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO_VALUE
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_LOCAL_PLAYER_ANIMATIONS_IDLE,
|
||||
TOCLIENT_LOCAL_PLAYER_ANIMATIONS_WALK,
|
||||
TOCLIENT_LOCAL_PLAYER_ANIMATIONS_DIG,
|
||||
TOCLIENT_LOCAL_PLAYER_ANIMATIONS_WALKDIG,
|
||||
TOCLIENT_LOCAL_PLAYER_ANIMATIONS_FRAME_SPEED
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOCLIENT_EYE_OFFSET_FIRST,
|
||||
TOCLIENT_EYE_OFFSET_THIRD
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_INIT_FMT,
|
||||
TOSERVER_INIT_COMPRESSION,
|
||||
TOSERVER_INIT_PROTOCOL_VERSION_MIN,
|
||||
TOSERVER_INIT_PROTOCOL_VERSION_MAX,
|
||||
TOSERVER_INIT_NAME
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// u8 SER_FMT_VER_HIGHEST_READ
|
||||
TOSERVER_INIT_LEGACY_FMT,
|
||||
TOSERVER_INIT_LEGACY_NAME,
|
||||
TOSERVER_INIT_LEGACY_PASSWORD,
|
||||
TOSERVER_INIT_LEGACY_PROTOCOL_VERSION_MIN,
|
||||
TOSERVER_INIT_LEGACY_PROTOCOL_VERSION_MAX,
|
||||
TOSERVER_INIT_LEGACY_PROTOCOL_VERSION_FM
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// v3f
|
||||
TOSERVER_PLAYERPOS_POSITION,
|
||||
// v3f
|
||||
TOSERVER_PLAYERPOS_SPEED,
|
||||
// f32
|
||||
TOSERVER_PLAYERPOS_PITCH,
|
||||
// f32
|
||||
TOSERVER_PLAYERPOS_YAW,
|
||||
// u32
|
||||
TOSERVER_PLAYERPOS_KEY_PRESSED
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_DELETEDBLOCKS_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_INVENTORY_ACTION_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_CHAT_MESSAGE_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_DAMAGE_VALUE
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_CHANGE_PASSWORD_OLD,
|
||||
TOSERVER_CHANGE_PASSWORD_NEW
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_PLAYERITEM_VALUE
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_REMOVED_SOUNDS_IDS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_NODEMETA_FIELDS_POS,
|
||||
TOSERVER_NODEMETA_FIELDS_FORMNAME,
|
||||
TOSERVER_NODEMETA_FIELDS_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_INVENTORY_FIELDS_FORMNAME,
|
||||
TOSERVER_INVENTORY_FIELDS_DATA
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_REQUEST_MEDIA_FILES
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_BREATH_VALUE
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/*
|
||||
actions:
|
||||
0: start digging (from undersurface) or use
|
||||
1: stop digging (all parameters ignored)
|
||||
2: digging completed
|
||||
3: place block or item (to abovesurface)
|
||||
4: use item
|
||||
*/
|
||||
TOSERVER_INTERACT_ACTION,
|
||||
TOSERVER_INTERACT_ITEM,
|
||||
TOSERVER_INTERACT_POINTED_THING
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TOSERVER_CLIENT_READY_VERSION_MAJOR,
|
||||
TOSERVER_CLIENT_READY_VERSION_MINOR,
|
||||
TOSERVER_CLIENT_READY_VERSION_PATCH,
|
||||
TOSERVER_CLIENT_READY_VERSION_STRING,
|
||||
TOSERVER_CLIENT_READY_VERSION_TWEAK
|
||||
};
|
||||
|
||||
// freeminer only packet
|
||||
#define TOSERVER_DRAWCONTROL 0x44
|
||||
enum
|
||||
{
|
||||
TOSERVER_DRAWCONTROL_WANTED_RANGE,
|
||||
TOSERVER_DRAWCONTROL_RANGE_ALL,
|
||||
TOSERVER_DRAWCONTROL_FARMESH,
|
||||
TOSERVER_DRAWCONTROL_FOV,
|
||||
TOSERVER_DRAWCONTROL_BLOCK_OVERFLOW // not used
|
||||
};
|
|
@ -34,6 +34,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "tool.h"
|
||||
#include "version.h"
|
||||
#include "network/networkprotocol.h"
|
||||
#include "fm_networkprotocol.h"
|
||||
#include "network/serveropcodes.h"
|
||||
#include "util/base64.h"
|
||||
#include "util/pointedthing.h"
|
||||
|
@ -330,7 +331,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt) {
|
|||
Answer with a TOCLIENT_INIT
|
||||
*/
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_INIT_LEGACY, 6);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_INIT_LEGACY, 6);
|
||||
PACK(TOCLIENT_INIT_DEPLOYED, deployed);
|
||||
PACK(TOCLIENT_INIT_SEED, m_env->getServerMap().getSeed());
|
||||
PACK(TOCLIENT_INIT_STEP, g_settings->getFloat("dedicated_server_step"));
|
||||
|
|
|
@ -14,12 +14,13 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "server.h"
|
||||
|
||||
void Server::SendMovement(u16 peer_id)
|
||||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_MOVEMENT, 13);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_MOVEMENT, 13);
|
||||
|
||||
PACK(TOCLIENT_MOVEMENT_ACCELERATION_DEFAULT, g_settings->getFloat("movement_acceleration_default") * BS);
|
||||
PACK(TOCLIENT_MOVEMENT_ACCELERATION_AIR, g_settings->getFloat("movement_acceleration_air") * BS);
|
||||
|
@ -44,7 +45,7 @@ void Server::SendHP(u16 peer_id, u8 hp)
|
|||
DSTACK(FUNCTION_NAME);
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_HP, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_HP, 1);
|
||||
PACK(TOCLIENT_HP_HP, hp);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -54,7 +55,7 @@ void Server::SendHP(u16 peer_id, u8 hp)
|
|||
void Server::SendBreath(u16 peer_id, u16 breath)
|
||||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_BREATH, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_BREATH, 1);
|
||||
PACK(TOCLIENT_BREATH_BREATH, breath);
|
||||
// Send as reliable
|
||||
m_clients.send(peer_id, 0, buffer, true);
|
||||
|
@ -63,7 +64,7 @@ void Server::SendBreath(u16 peer_id, u16 breath)
|
|||
void Server::SendAccessDenied(u16 peer_id, AccessDeniedCode reason, const std::string &custom_reason, bool reconnect)
|
||||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_ACCESS_DENIED_LEGACY, 3);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_ACCESS_DENIED_LEGACY, 3);
|
||||
PACK(TOCLIENT_ACCESS_DENIED_CUSTOM_STRING, custom_reason);
|
||||
PACK(TOCLIENT_ACCESS_DENIED_REASON, (int)reason);
|
||||
PACK(TOCLIENT_ACCESS_DENIED_RECONNECT, reconnect);
|
||||
|
@ -77,7 +78,7 @@ void Server::SendDeathscreen(u16 peer_id,bool set_camera_point_target,
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_DEATHSCREEN, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_DEATHSCREEN, 2);
|
||||
PACK(TOCLIENT_DEATHSCREEN_SET_CAMERA, set_camera_point_target);
|
||||
PACK(TOCLIENT_DEATHSCREEN_CAMERA_POINT, camera_point_target);
|
||||
|
||||
|
@ -89,7 +90,7 @@ void Server::SendItemDef(u16 peer_id,
|
|||
IItemDefManager *itemdef, u16 protocol_version)
|
||||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_ITEMDEF, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_ITEMDEF, 1);
|
||||
|
||||
auto client = m_clients.getClient(peer_id, CS_InitDone);
|
||||
if (!client)
|
||||
|
@ -109,7 +110,7 @@ void Server::SendNodeDef(u16 peer_id,
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_NODEDEF, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_NODEDEF, 1);
|
||||
|
||||
auto client = m_clients.getClient(peer_id, CS_InitDone);
|
||||
if (!client)
|
||||
|
@ -143,7 +144,7 @@ void Server::SendInventory(PlayerSAO* playerSAO)
|
|||
|
||||
std::string s = os.str();
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_INVENTORY, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_INVENTORY, 1);
|
||||
PACK(TOCLIENT_INVENTORY_DATA, s);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -154,7 +155,7 @@ void Server::SendChatMessage(u16 peer_id, const std::string &message)
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_CHAT_MESSAGE, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_CHAT_MESSAGE, 1);
|
||||
PACK(TOCLIENT_CHAT_MESSAGE_DATA, message);
|
||||
|
||||
if (peer_id != PEER_ID_INEXISTENT)
|
||||
|
@ -173,7 +174,7 @@ void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec,
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_SHOW_FORMSPEC, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_SHOW_FORMSPEC, 2);
|
||||
PACK(TOCLIENT_SHOW_FORMSPEC_DATA, FORMSPEC_VERSION_STRING + formspec);
|
||||
PACK(TOCLIENT_SHOW_FORMSPEC_NAME, formname);
|
||||
|
||||
|
@ -189,7 +190,7 @@ void Server::SendSpawnParticle(u16 peer_id, v3f pos, v3f velocity, v3f accelerat
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_SPAWN_PARTICLE, 9);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_SPAWN_PARTICLE, 9);
|
||||
PACK(TOCLIENT_SPAWN_PARTICLE_POS, pos);
|
||||
PACK(TOCLIENT_SPAWN_PARTICLE_VELOCITY, velocity);
|
||||
PACK(TOCLIENT_SPAWN_PARTICLE_ACCELERATION, acceleration);
|
||||
|
@ -219,7 +220,7 @@ void Server::SendAddParticleSpawner(u16 peer_id, u16 amount, float spawntime, v3
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_ADD_PARTICLESPAWNER, 18);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_ADD_PARTICLESPAWNER, 18);
|
||||
PACK(TOCLIENT_ADD_PARTICLESPAWNER_AMOUNT, amount);
|
||||
PACK(TOCLIENT_ADD_PARTICLESPAWNER_SPAWNTIME, spawntime);
|
||||
PACK(TOCLIENT_ADD_PARTICLESPAWNER_MINPOS, minpos);
|
||||
|
@ -253,7 +254,7 @@ void Server::SendDeleteParticleSpawner(u16 peer_id, u32 id)
|
|||
{
|
||||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_DELETE_PARTICLESPAWNER, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_DELETE_PARTICLESPAWNER, 1);
|
||||
PACK(TOCLIENT_DELETE_PARTICLESPAWNER_ID, id);
|
||||
|
||||
if (peer_id != PEER_ID_INEXISTENT) {
|
||||
|
@ -268,7 +269,7 @@ void Server::SendDeleteParticleSpawner(u16 peer_id, u32 id)
|
|||
|
||||
void Server::SendHUDAdd(u16 peer_id, u32 id, HudElement *form)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_HUDADD, 13);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_HUDADD, 13);
|
||||
PACK(TOCLIENT_HUDADD_ID, id);
|
||||
PACK(TOCLIENT_HUDADD_TYPE, (int)form->type);
|
||||
PACK(TOCLIENT_HUDADD_POS, form->pos);
|
||||
|
@ -289,7 +290,7 @@ void Server::SendHUDAdd(u16 peer_id, u32 id, HudElement *form)
|
|||
|
||||
void Server::SendHUDRemove(u16 peer_id, u32 id)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_HUDRM, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_HUDRM, 1);
|
||||
PACK(TOCLIENT_HUDRM_ID, id);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -299,7 +300,7 @@ void Server::SendHUDRemove(u16 peer_id, u32 id)
|
|||
|
||||
void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_HUDCHANGE, 3);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_HUDCHANGE, 3);
|
||||
PACK(TOCLIENT_HUDCHANGE_ID, id);
|
||||
PACK(TOCLIENT_HUDCHANGE_STAT, (int)stat);
|
||||
|
||||
|
@ -334,7 +335,7 @@ void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value
|
|||
|
||||
void Server::SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_HUD_SET_FLAGS, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_HUD_SET_FLAGS, 2);
|
||||
//////////////////////////// compatibility code to be removed //////////////
|
||||
// ?? flags &= ~(HUD_FLAG_HEALTHBAR_VISIBLE | HUD_FLAG_BREATHBAR_VISIBLE);
|
||||
PACK(TOCLIENT_HUD_SET_FLAGS_FLAGS, flags);
|
||||
|
@ -346,7 +347,7 @@ void Server::SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask)
|
|||
|
||||
void Server::SendHUDSetParam(u16 peer_id, u16 param, const std::string &value)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_HUD_SET_PARAM, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_HUD_SET_PARAM, 2);
|
||||
PACK(TOCLIENT_HUD_SET_PARAM_ID, param);
|
||||
PACK(TOCLIENT_HUD_SET_PARAM_VALUE, value);
|
||||
|
||||
|
@ -357,7 +358,7 @@ void Server::SendHUDSetParam(u16 peer_id, u16 param, const std::string &value)
|
|||
void Server::SendSetSky(u16 peer_id, const video::SColor &bgcolor,
|
||||
const std::string &type, const std::vector<std::string> ¶ms)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_SET_SKY, 3);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_SET_SKY, 3);
|
||||
PACK(TOCLIENT_SET_SKY_COLOR, bgcolor);
|
||||
PACK(TOCLIENT_SET_SKY_TYPE, type);
|
||||
PACK(TOCLIENT_SET_SKY_PARAMS, params);
|
||||
|
@ -369,7 +370,7 @@ void Server::SendSetSky(u16 peer_id, const video::SColor &bgcolor,
|
|||
void Server::SendOverrideDayNightRatio(u16 peer_id, bool do_override,
|
||||
float ratio)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO, 2);
|
||||
PACK(TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO_DO, do_override);
|
||||
PACK(TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO_VALUE, ratio);
|
||||
|
||||
|
@ -382,7 +383,7 @@ void Server::SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed)
|
|||
DSTACK(FUNCTION_NAME);
|
||||
|
||||
// Make packet
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_TIME_OF_DAY, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_TIME_OF_DAY, 2);
|
||||
PACK(TOCLIENT_TIME_OF_DAY_TIME, time);
|
||||
PACK(TOCLIENT_TIME_OF_DAY_TIME_SPEED, time_speed);
|
||||
|
||||
|
@ -430,7 +431,7 @@ void Server::SendMovePlayer(u16 peer_id)
|
|||
if (!playersao)
|
||||
return;
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_MOVE_PLAYER, 3);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_MOVE_PLAYER, 3);
|
||||
PACK(TOCLIENT_MOVE_PLAYER_POS, playersao->getBasePosition());
|
||||
PACK(TOCLIENT_MOVE_PLAYER_PITCH, playersao->getPitch());
|
||||
PACK(TOCLIENT_MOVE_PLAYER_YAW, playersao->getYaw());
|
||||
|
@ -446,7 +447,7 @@ void Server::SendPunchPlayer(u16 peer_id, v3f speed)
|
|||
if (!player)
|
||||
return;
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_PUNCH_PLAYER, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_PUNCH_PLAYER, 1);
|
||||
PACK(TOCLIENT_PUNCH_PLAYER_SPEED, speed);
|
||||
// Send as reliable
|
||||
m_clients.send(peer_id, 0, buffer, true);
|
||||
|
@ -454,7 +455,7 @@ void Server::SendPunchPlayer(u16 peer_id, v3f speed)
|
|||
|
||||
void Server::SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_LOCAL_PLAYER_ANIMATIONS, 5);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_LOCAL_PLAYER_ANIMATIONS, 5);
|
||||
PACK(TOCLIENT_LOCAL_PLAYER_ANIMATIONS_IDLE, animation_frames[0]);
|
||||
PACK(TOCLIENT_LOCAL_PLAYER_ANIMATIONS_WALK, animation_frames[1]);
|
||||
PACK(TOCLIENT_LOCAL_PLAYER_ANIMATIONS_DIG, animation_frames[2]);
|
||||
|
@ -467,7 +468,7 @@ void Server::SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f
|
|||
|
||||
void Server::SendEyeOffset(u16 peer_id, v3f first, v3f third)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_EYE_OFFSET, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_EYE_OFFSET, 2);
|
||||
PACK(TOCLIENT_EYE_OFFSET_FIRST, first);
|
||||
PACK(TOCLIENT_EYE_OFFSET_THIRD, third);
|
||||
// Send as reliable
|
||||
|
@ -485,7 +486,7 @@ void Server::SendPlayerPrivileges(u16 peer_id)
|
|||
std::set<std::string> privs;
|
||||
m_script->getAuth(player->getName(), NULL, &privs);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_PRIVILEGES, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_PRIVILEGES, 1);
|
||||
PACK(TOCLIENT_PRIVILEGES_PRIVILEGES, privs);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -501,7 +502,7 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id)
|
|||
if(player->peer_id == PEER_ID_INEXISTENT)
|
||||
return;
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_INVENTORY_FORMSPEC, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_INVENTORY_FORMSPEC, 1);
|
||||
PACK(TOCLIENT_INVENTORY_FORMSPEC_DATA, FORMSPEC_VERSION_STRING + player->inventory_formspec);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -510,7 +511,7 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id)
|
|||
|
||||
void Server::SendActiveObjectMessages(u16 peer_id, const ActiveObjectMessages &datas, bool reliable)
|
||||
{
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_ACTIVE_OBJECT_MESSAGES, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_ACTIVE_OBJECT_MESSAGES, 1);
|
||||
PACK(TOCLIENT_ACTIVE_OBJECT_MESSAGES_MESSAGES, datas);
|
||||
|
||||
// Send as reliable
|
||||
|
@ -581,7 +582,7 @@ s32 Server::playSound(const SimpleSoundSpec &spec,
|
|||
i != dst_clients.end(); i++)
|
||||
psound.clients.insert(*i);
|
||||
// Create packet
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_PLAY_SOUND, 7);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_PLAY_SOUND, 7);
|
||||
PACK(TOCLIENT_PLAY_SOUND_ID, id);
|
||||
PACK(TOCLIENT_PLAY_SOUND_NAME, spec.name);
|
||||
PACK(TOCLIENT_PLAY_SOUND_GAIN, spec.gain * params.gain);
|
||||
|
@ -606,7 +607,7 @@ void Server::stopSound(s32 handle)
|
|||
return;
|
||||
ServerPlayingSound &psound = i->second;
|
||||
// Create packet
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_STOP_SOUND, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_STOP_SOUND, 1);
|
||||
PACK(TOCLIENT_STOP_SOUND_ID, handle);
|
||||
// Send
|
||||
for(auto i = psound.clients.begin();
|
||||
|
@ -626,7 +627,7 @@ void Server::sendRemoveNode(v3s16 p, u16 ignore_id,
|
|||
v3f p_f = intToFloat(p, BS);
|
||||
|
||||
// Create packet
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_REMOVENODE, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_REMOVENODE, 1);
|
||||
PACK(TOCLIENT_REMOVENODE_POS, p);
|
||||
|
||||
auto clients = m_clients.getClientIDs();
|
||||
|
@ -689,7 +690,7 @@ void Server::sendAddNode(v3s16 p, MapNode n, u16 ignore_id,
|
|||
if (client != 0)
|
||||
{
|
||||
// Create packet
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_ADDNODE, 3);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_ADDNODE, 3);
|
||||
PACK(TOCLIENT_ADDNODE_POS, p);
|
||||
PACK(TOCLIENT_ADDNODE_NODE, n);
|
||||
PACK(TOCLIENT_ADDNODE_REMOVE_METADATA, remove_metadata);
|
||||
|
@ -706,7 +707,7 @@ void Server::SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto
|
|||
|
||||
g_profiler->add("Connection: blocks sent", 1);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_BLOCKDATA, 8);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_BLOCKDATA, 8);
|
||||
PACK(TOCLIENT_BLOCKDATA_POS, block->getPos());
|
||||
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
|
@ -741,7 +742,7 @@ void Server::sendMediaAnnouncement(u16 peer_id)
|
|||
i != m_media.end(); i++)
|
||||
announce_list.push_back(std::make_pair(i->first, i->second.sha1_digest));
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_ANNOUNCE_MEDIA, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_ANNOUNCE_MEDIA, 2);
|
||||
PACK(TOCLIENT_ANNOUNCE_MEDIA_LIST, announce_list);
|
||||
PACK(TOCLIENT_ANNOUNCE_MEDIA_REMOTE_SERVER, g_settings->get("remote_media"));
|
||||
|
||||
|
@ -790,7 +791,7 @@ void Server::sendRequestedMedia(u16 peer_id,
|
|||
media_data.push_back(std::make_pair(name, contents));
|
||||
size += contents.size();
|
||||
if (size > 0xffff) {
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_MEDIA, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_MEDIA, 1);
|
||||
PACK(TOCLIENT_MEDIA_MEDIA, media_data);
|
||||
m_clients.send(peer_id, 2, buffer, true);
|
||||
media_data.clear();
|
||||
|
@ -799,7 +800,7 @@ void Server::sendRequestedMedia(u16 peer_id,
|
|||
}
|
||||
|
||||
if (!media_data.empty()) {
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_MEDIA, 1);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_MEDIA, 1);
|
||||
PACK(TOCLIENT_MEDIA_MEDIA, media_data);
|
||||
m_clients.send(peer_id, 2, buffer, true);
|
||||
}
|
||||
|
@ -816,7 +817,7 @@ void Server::sendDetachedInventory(const std::string &name, u16 peer_id)
|
|||
std::ostringstream os(std::ios_base::binary);
|
||||
inv->serialize(os);
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_DETACHED_INVENTORY, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_DETACHED_INVENTORY, 2);
|
||||
PACK(TOCLIENT_DETACHED_INVENTORY_NAME, name);
|
||||
PACK(TOCLIENT_DETACHED_INVENTORY_DATA, os.str());
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "util/pointer.h"
|
||||
#include "util/numeric.h"
|
||||
#include "networkprotocol.h"
|
||||
#include "../msgpack_fix.h"
|
||||
|
||||
class MsgpackPacketSafe;
|
||||
|
||||
|
@ -140,6 +141,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#include "fm_networkprotocol.h"
|
||||
#include "../util/msgpack_serialize.h"
|
||||
bool parse_msgpack_packet(char *data, u32 datasize, MsgpackPacket *packet, int *command, msgpack::unpacked &msg);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -963,7 +963,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
|
|||
|
||||
}
|
||||
|
||||
MSGPACK_PACKET_INIT(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 2);
|
||||
MSGPACK_PACKET_INIT((int)TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 2);
|
||||
PACK(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD_REMOVE, removed_objects_data);
|
||||
PACK(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD_ADD, added_objects_data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue