]> git.lizzy.rs Git - dragonfireclient.git/blob - src/server/serveractiveobject.cpp
Fix revoke debug privs not reliably turn off stuff (#11409)
[dragonfireclient.git] / src / server / serveractiveobject.cpp
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #include "serveractiveobject.h"
21 #include <fstream>
22 #include "inventory.h"
23 #include "constants.h" // BS
24 #include "log.h"
25
26 ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
27         ActiveObject(0),
28         m_env(env),
29         m_base_position(pos)
30 {
31 }
32
33 float ServerActiveObject::getMinimumSavedMovement()
34 {
35         return 2.0*BS;
36 }
37
38 ItemStack ServerActiveObject::getWieldedItem(ItemStack *selected, ItemStack *hand) const
39 {
40         *selected = ItemStack();
41         if (hand)
42                 *hand = ItemStack();
43
44         return ItemStack();
45 }
46
47 bool ServerActiveObject::setWieldedItem(const ItemStack &item)
48 {
49         return false;
50 }
51
52 std::string ServerActiveObject::generateUpdateInfantCommand(u16 infant_id, u16 protocol_version)
53 {
54         std::ostringstream os(std::ios::binary);
55         // command
56         writeU8(os, AO_CMD_SPAWN_INFANT);
57         // parameters
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));
65         }
66         return os.str();
67 }
68
69 void ServerActiveObject::dumpAOMessagesToQueue(std::queue<ActiveObjectMessage> &queue)
70 {
71         while (!m_messages_out.empty()) {
72                 queue.push(std::move(m_messages_out.front()));
73                 m_messages_out.pop();
74         }
75 }
76
77 void ServerActiveObject::markForRemoval()
78 {
79         if (!m_pending_removal) {
80                 onMarkedForRemoval();
81                 m_pending_removal = true;
82         }
83 }
84
85 void ServerActiveObject::markForDeactivation()
86 {
87         if (!m_pending_deactivation) {
88                 onMarkedForDeactivation();
89                 m_pending_deactivation = true;
90         }
91 }