3 Copyright (C) 2012 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 "genericobject.h"
22 #include "util/serialize.h"
24 std::string gob_cmd_set_properties(const ObjectProperties &prop)
26 std::ostringstream os(std::ios::binary);
27 writeU8(os, GENERIC_CMD_SET_PROPERTIES);
32 ObjectProperties gob_read_set_properties(std::istream &is)
34 ObjectProperties prop;
39 std::string gob_cmd_update_position(
48 std::ostringstream os(std::ios::binary);
50 writeU8(os, GENERIC_CMD_UPDATE_POSITION);
52 writeV3F1000(os, position);
54 writeV3F1000(os, velocity);
56 writeV3F1000(os, acceleration);
60 writeU8(os, do_interpolate);
61 // is_end_position (for interpolation)
62 writeU8(os, is_movement_end);
63 // update_interval (for interpolation)
64 writeF1000(os, update_interval);
68 std::string gob_cmd_set_texture_mod(const std::string &mod)
70 std::ostringstream os(std::ios::binary);
72 writeU8(os, GENERIC_CMD_SET_TEXTURE_MOD);
74 os<<serializeString(mod);
78 std::string gob_cmd_set_sprite(
82 bool select_horiz_by_yawpitch
84 std::ostringstream os(std::ios::binary);
86 writeU8(os, GENERIC_CMD_SET_SPRITE);
89 writeU16(os, num_frames);
90 writeF1000(os, framelength);
91 writeU8(os, select_horiz_by_yawpitch);
95 std::string gob_cmd_set_animations(v2f frames, float frame_speed, float frame_blend)
97 std::ostringstream os(std::ios::binary);
99 writeU8(os, GENERIC_CMD_SET_ANIMATIONS);
101 writeV2F1000(os, frames);
102 writeF1000(os, frame_speed);
103 writeF1000(os, frame_blend);
107 std::string gob_cmd_set_bone_posrot(std::string bone, v3f position, v3f rotation)
109 std::ostringstream os(std::ios::binary);
111 writeU8(os, GENERIC_CMD_SET_BONE_POSROT);
113 os<<serializeString(bone);
114 writeV3F1000(os, position);
115 writeV3F1000(os, rotation);
119 std::string gob_cmd_set_attachment(int parent_id, std::string bone, v3f position, v3f rotation)
121 std::ostringstream os(std::ios::binary);
123 writeU8(os, GENERIC_CMD_SET_ATTACHMENT);
125 writeS16(os, parent_id);
126 os<<serializeString(bone);
127 writeV3F1000(os, position);
128 writeV3F1000(os, rotation);
132 std::string gob_cmd_punched(s16 damage, s16 result_hp)
134 std::ostringstream os(std::ios::binary);
136 writeU8(os, GENERIC_CMD_PUNCHED);
138 writeS16(os, damage);
140 writeS16(os, result_hp);
144 std::string gob_cmd_update_armor_groups(const ItemGroupList &armor_groups)
146 std::ostringstream os(std::ios::binary);
147 writeU8(os, GENERIC_CMD_UPDATE_ARMOR_GROUPS);
148 writeU16(os, armor_groups.size());
149 for(ItemGroupList::const_iterator i = armor_groups.begin();
150 i != armor_groups.end(); i++){
151 os<<serializeString(i->first);
152 writeS16(os, i->second);