3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "serveractiveobject.h"
22 #include "inventory.h"
23 #include "constants.h" // BS
26 ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
33 float ServerActiveObject::getMinimumSavedMovement()
38 ItemStack ServerActiveObject::getWieldedItem(ItemStack *selected, ItemStack *hand) const
40 *selected = ItemStack();
47 bool ServerActiveObject::setWieldedItem(const ItemStack &item)
52 std::string ServerActiveObject::generateUpdateInfantCommand(u16 infant_id, u16 protocol_version)
54 std::ostringstream os(std::ios::binary);
56 writeU8(os, AO_CMD_SPAWN_INFANT);
58 writeU16(os, infant_id);
59 writeU8(os, getSendType());
60 if (protocol_version < 38) {
61 // Clients since 4aa9a66 so no longer need this data
62 // Version 38 is the first bump after that commit.
63 // See also: ClientEnvironment::addActiveObject
64 os << serializeString32(getClientInitializationData(protocol_version));
69 void ServerActiveObject::dumpAOMessagesToQueue(std::queue<ActiveObjectMessage> &queue)
71 while (!m_messages_out.empty()) {
72 queue.push(std::move(m_messages_out.front()));
77 void ServerActiveObject::markForRemoval()
79 if (!m_pending_removal) {
81 m_pending_removal = true;
85 void ServerActiveObject::markForDeactivation()
87 if (!m_pending_deactivation) {
88 onMarkedForDeactivation();
89 m_pending_deactivation = true;