nameidmapping.cpp
itemdef.cpp
nodedef.cpp
- luaentity_common.cpp
+ object_properties.cpp
scriptapi.cpp
script.cpp
log.cpp
bool m_is_player;
bool m_is_local_player; // determined locally
// Property-ish things
- s16 m_hp_max;
- bool m_physical;
- float m_weight;
- core::aabbox3d<f32> m_collisionbox;
- std::string m_visual;
- v2f m_visual_size;
- core::array<std::string> m_textures;
- v2s16 m_spritediv;
- bool m_is_visible;
- bool m_makes_footstep_sound;
+ ObjectProperties m_prop;
//
scene::ISceneManager *m_smgr;
IrrlichtDevice *m_irr;
// Spritesheet/animation stuff
v2f m_tx_size;
v2s16 m_tx_basepos;
+ bool m_initial_tx_basepos_set;
bool m_tx_select_horiz_by_yawpitch;
int m_anim_frame;
int m_anim_num_frames;
m_is_player(false),
m_is_local_player(false),
//
- m_hp_max(1),
- m_physical(false),
- m_weight(5),
- m_collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5),
- m_visual("sprite"),
- m_visual_size(1,1),
- m_spritediv(1,1),
- m_is_visible(true),
- m_makes_footstep_sound(false),
- //
m_smgr(NULL),
m_irr(NULL),
m_selection_box(-BS/3.,-BS/3.,-BS/3., BS/3.,BS/3.,BS/3.),
m_hp(1),
m_tx_size(1,1),
m_tx_basepos(0,0),
+ m_initial_tx_basepos_set(false),
m_tx_select_horiz_by_yawpitch(false),
m_anim_frame(0),
m_anim_num_frames(1),
m_visuals_expired(false),
m_step_distance_counter(0)
{
- m_textures.push_back("unknown_object.png");
if(gamedef == NULL)
ClientActiveObject::registerType(getType(), create);
}
}
core::aabbox3d<f32>* getSelectionBox()
{
- if(!m_is_visible || m_is_local_player)
+ if(!m_prop.is_visible || m_is_local_player)
return NULL;
return &m_selection_box;
}
m_visuals_expired = false;
- if(!m_is_visible || m_is_local_player)
+ if(!m_prop.is_visible || m_is_local_player)
return;
//video::IVideoDriver* driver = smgr->getVideoDriver();
- if(m_visual == "sprite"){
+ if(m_prop.visual == "sprite"){
infostream<<"GenericCAO::addToScene(): single_sprite"<<std::endl;
m_spritenode = smgr->addBillboardSceneNode(
NULL, v2f(1, 1), v3f(0,0,0), -1);
m_spritenode->setMaterialFlag(video::EMF_FOG_ENABLE, true);
m_spritenode->setColor(video::SColor(255,0,0,0));
m_spritenode->setVisible(false); /* Set visible when brightness is known */
- m_spritenode->setSize(m_visual_size*BS);
+ m_spritenode->setSize(m_prop.visual_size*BS);
{
const float txs = 1.0 / 1;
const float tys = 1.0 / 1;
txs, tys, 0, 0);
}
}
- else if(m_visual == "upright_sprite")
+ else if(m_prop.visual == "upright_sprite")
{
scene::SMesh *mesh = new scene::SMesh();
- double dx = BS*m_visual_size.X/2;
- double dy = BS*m_visual_size.Y/2;
+ double dx = BS*m_prop.visual_size.X/2;
+ double dy = BS*m_prop.visual_size.Y/2;
{ // Front
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
video::SColor c(255,255,255,255);
// This is needed for changing the texture in the future
m_meshnode->setReadOnlyMaterials(true);
}
- else if(m_visual == "cube"){
+ else if(m_prop.visual == "cube"){
infostream<<"GenericCAO::addToScene(): cube"<<std::endl;
scene::IMesh *mesh = createCubeMesh(v3f(BS,BS,BS));
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
// Will be shown when we know the brightness
m_meshnode->setVisible(false);
} else {
- infostream<<"GenericCAO::addToScene(): \""<<m_visual
+ infostream<<"GenericCAO::addToScene(): \""<<m_prop.visual
<<"\" not supported"<<std::endl;
}
updateTextures("");
addToScene(m_smgr, m_gamedef->tsrc(), m_irr);
}
- if(m_physical){
- core::aabbox3d<f32> box = m_collisionbox;
+ if(m_prop.physical){
+ core::aabbox3d<f32> box = m_prop.collisionbox;
box.MinEdge *= BS;
box.MaxEdge *= BS;
collisionMoveResult moveresult;
m_step_distance_counter += moved;
if(m_step_distance_counter > 1.5*BS){
m_step_distance_counter = 0;
- if(!m_is_local_player && m_makes_footstep_sound){
+ if(!m_is_local_player && m_prop.makes_footstep_sound){
INodeDefManager *ndef = m_gamedef->ndef();
v3s16 p = floatToInt(getPosition()+v3f(0,-0.5*BS, 0), BS);
MapNode n = m_env->getMap().getNodeNoEx(p);
if(m_spritenode)
{
- if(m_visual == "sprite")
+ if(m_prop.visual == "sprite")
{
std::string texturestring = "unknown_block.png";
- if(m_textures.size() >= 1)
- texturestring = m_textures[0];
+ if(m_prop.textures.size() >= 1)
+ texturestring = m_prop.textures[0];
texturestring += mod;
m_spritenode->setMaterialTexture(0,
tsrc->getTextureRaw(texturestring));
}
if(m_meshnode)
{
- if(m_visual == "cube")
+ if(m_prop.visual == "cube")
{
for (u32 i = 0; i < 6; ++i)
{
std::string texturestring = "unknown_block.png";
- if(m_textures.size() > i)
- texturestring = m_textures[i];
+ if(m_prop.textures.size() > i)
+ texturestring = m_prop.textures[i];
texturestring += mod;
AtlasPointer ap = tsrc->getTexture(texturestring);
material.getTextureMatrix(0).setTextureScale(size.X, size.Y);
}
}
- else if(m_visual == "upright_sprite")
+ else if(m_prop.visual == "upright_sprite")
{
scene::IMesh *mesh = m_meshnode->getMesh();
{
std::string tname = "unknown_object.png";
- if(m_textures.size() >= 1)
- tname = m_textures[0];
+ if(m_prop.textures.size() >= 1)
+ tname = m_prop.textures[0];
tname += mod;
scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
buf->getMaterial().setTexture(0,
}
{
std::string tname = "unknown_object.png";
- if(m_textures.size() >= 2)
- tname = m_textures[1];
- else if(m_textures.size() >= 1)
- tname = m_textures[0];
+ if(m_prop.textures.size() >= 2)
+ tname = m_prop.textures[1];
+ else if(m_prop.textures.size() >= 1)
+ tname = m_prop.textures[0];
tname += mod;
scene::IMeshBuffer *buf = mesh->getMeshBuffer(1);
buf->getMaterial().setTexture(0,
u8 cmd = readU8(is);
if(cmd == GENERIC_CMD_SET_PROPERTIES)
{
- m_hp_max = readS16(is);
- m_physical = readU8(is);
- m_weight = readF1000(is);
- m_collisionbox.MinEdge = readV3F1000(is);
- m_collisionbox.MaxEdge = readV3F1000(is);
- m_visual = deSerializeString(is);
- m_visual_size = readV2F1000(is);
- m_textures.clear();
- u32 texture_count = readU16(is);
- for(u32 i=0; i<texture_count; i++){
- m_textures.push_back(deSerializeString(is));
- }
- m_spritediv = readV2S16(is);
- m_is_visible = readU8(is);
- m_makes_footstep_sound = readU8(is);
+ m_prop = gob_read_set_properties(is);
- m_selection_box = m_collisionbox;
+ m_selection_box = m_prop.collisionbox;
m_selection_box.MinEdge *= BS;
m_selection_box.MaxEdge *= BS;
- m_tx_size.X = 1.0 / m_spritediv.X;
- m_tx_size.Y = 1.0 / m_spritediv.Y;
+ m_tx_size.X = 1.0 / m_prop.spritediv.X;
+ m_tx_size.Y = 1.0 / m_prop.spritediv.Y;
+
+ if(!m_initial_tx_basepos_set){
+ m_initial_tx_basepos_set = true;
+ m_tx_basepos = m_prop.initial_sprite_basepos;
+ }
expireVisuals();
}
float update_interval = readF1000(is);
if(do_interpolate){
- if(!m_physical)
+ if(!m_prop.physical)
pos_translator.update(m_position, is_end_position, update_interval);
} else {
pos_translator.init(m_position);
punchitem,
time_from_last_punch);
- dstream<<"Directly did_punch="<<result.did_punch<<" result.damage="<<result.damage<<std::endl;
-
if(result.did_punch && result.damage != 0)
{
if(result.damage < m_hp){
// As there is no definition, make a smoke puff
ClientSimpleObject *simple = createSmokePuff(
m_smgr, m_env, m_position,
- m_visual_size * BS);
+ m_prop.visual_size * BS);
m_env->addSimpleObject(simple);
}
// TODO: Execute defined fast response
LuaEntitySAO
*/
-#include "luaentity_common.h"
-
// Prototype (registers item for deserialization)
LuaEntitySAO proto_LuaEntitySAO(NULL, v3f(0,0,0), "_prototype", "");
m_init_name(name),
m_init_state(state),
m_registered(false),
- m_prop(new LuaEntityProperties),
m_hp(-1),
m_velocity(0,0,0),
m_acceleration(0,0,0),
lua_State *L = m_env->getLua();
scriptapi_luaentity_rm(L, m_id);
}
- delete m_prop;
}
void LuaEntitySAO::addedToEnvironment()
if(m_registered){
// Get properties
- scriptapi_luaentity_get_properties(L, m_id, m_prop);
+ scriptapi_luaentity_get_properties(L, m_id, &m_prop);
// Initialize HP from properties
- m_hp = m_prop->hp_max;
+ m_hp = m_prop.hp_max;
}
// Activate entity, supplying serialized state
m_last_sent_position_timer += dtime;
- if(m_prop->physical){
- core::aabbox3d<f32> box = m_prop->collisionbox;
+ if(m_prop.physical){
+ core::aabbox3d<f32> box = m_prop.collisionbox;
box.MinEdge *= BS;
box.MaxEdge *= BS;
collisionMoveResult moveresult;
writeV3F1000(os, m_base_position);
writeF1000(os, m_yaw);
writeS16(os, m_hp);
- writeU8(os, 3); // number of messages stuffed in here
+ writeU8(os, 2); // number of messages stuffed in here
os<<serializeLongString(getPropertyPacket()); // message 1
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
- os<<serializeLongString(gob_cmd_set_sprite( // 3
- m_prop->initial_sprite_basepos,
- 1, 1.0, false
- ));
// return result
return os.str();
}
std::string LuaEntitySAO::getPropertyPacket()
{
- return gob_cmd_set_properties(
- m_prop->hp_max,
- m_prop->physical,
- m_prop->weight,
- m_prop->collisionbox,
- m_prop->visual,
- m_prop->visual_size,
- m_prop->textures,
- m_prop->spritediv,
- true, // is_visible
- false // makes_footstep_sound
- );
+ return gob_cmd_set_properties(m_prop);
}
void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
m_inventory = &m_player->inventory;
m_armor_groups["choppy"] = 2;
m_armor_groups["fleshy"] = 3;
+
+ m_prop.hp_max = PLAYER_MAX_HP;
+ m_prop.physical = false;
+ m_prop.weight = 75;
+ m_prop.collisionbox = core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
+ m_prop.visual = "upright_sprite";
+ m_prop.visual_size = v2f(1, 2);
+ m_prop.textures.clear();
+ m_prop.textures.push_back("player.png");
+ m_prop.textures.push_back("player_back.png");
+ m_prop.spritediv = v2s16(1,1);
+ m_prop.is_visible = (getHP() != 0);
+ m_prop.makes_footstep_sound = true;
}
PlayerSAO::~PlayerSAO()
std::string PlayerSAO::getPropertyPacket()
{
- core::array<std::string> textures;
- textures.push_back("player.png");
- textures.push_back("player_back.png");
- return gob_cmd_set_properties(
- PLAYER_MAX_HP,
- false,
- 75,
- core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.),
- "upright_sprite",
- v2f(1, 2),
- textures,
- v2s16(1,1),
- (getHP() != 0), // is_visible
- true // makes_footstep_sound
- );
+ m_prop.is_visible = (getHP() != 0);
+ return gob_cmd_set_properties(m_prop);
}
#include "content_object.h"
#include "itemgroup.h"
#include "player.h"
+#include "object_properties.h"
ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
const std::string itemstring);
LuaEntitySAO needs some internals exposed.
*/
-struct LuaEntityProperties;
-
class LuaEntitySAO : public ServerActiveObject
{
public:
std::string m_init_name;
std::string m_init_state;
bool m_registered;
- struct LuaEntityProperties *m_prop;
+ struct ObjectProperties m_prop;
s16 m_hp;
v3f m_velocity;
ItemGroupList m_armor_groups;
bool m_armor_groups_sent;
bool m_properties_sent;
+ struct ObjectProperties m_prop;
public:
// Some flags used by Server
#include "utility.h"
#include <sstream>
-std::string gob_cmd_set_properties(
- s16 hp_max,
- bool physical,
- float weight,
- core::aabbox3d<f32> collisionbox,
- std::string visual,
- v2f visual_size,
- core::array<std::string> textures,
- v2s16 spritediv,
- bool is_visible,
- bool makes_footstep_sound
-){
+std::string gob_cmd_set_properties(const ObjectProperties &prop)
+{
std::ostringstream os(std::ios::binary);
writeU8(os, GENERIC_CMD_SET_PROPERTIES);
- writeS16(os, hp_max);
- writeU8(os, physical);
- writeF1000(os, weight);
- writeV3F1000(os, collisionbox.MinEdge);
- writeV3F1000(os, collisionbox.MaxEdge);
- os<<serializeString(visual);
- writeV2F1000(os, visual_size);
- writeU16(os, textures.size());
- for(u32 i=0; i<textures.size(); i++){
- os<<serializeString(textures[i]);
+ writeS16(os, prop.hp_max);
+ writeU8(os, prop.physical);
+ writeF1000(os, prop.weight);
+ writeV3F1000(os, prop.collisionbox.MinEdge);
+ writeV3F1000(os, prop.collisionbox.MaxEdge);
+ os<<serializeString(prop.visual);
+ writeV2F1000(os, prop.visual_size);
+ writeU16(os, prop.textures.size());
+ for(u32 i=0; i<prop.textures.size(); i++){
+ os<<serializeString(prop.textures[i]);
}
- writeV2S16(os, spritediv);
- writeU8(os, is_visible);
- writeU8(os, makes_footstep_sound);
+ writeV2S16(os, prop.spritediv);
+ writeV2S16(os, prop.initial_sprite_basepos);
+ writeU8(os, prop.is_visible);
+ writeU8(os, prop.makes_footstep_sound);
return os.str();
}
+ObjectProperties gob_read_set_properties(std::istream &is)
+{
+ ObjectProperties prop;
+ prop.hp_max = readS16(is);
+ prop.physical = readU8(is);
+ prop.weight = readF1000(is);
+ prop.collisionbox.MinEdge = readV3F1000(is);
+ prop.collisionbox.MaxEdge = readV3F1000(is);
+ prop.visual = deSerializeString(is);
+ prop.visual_size = readV2F1000(is);
+ prop.textures.clear();
+ u32 texture_count = readU16(is);
+ for(u32 i=0; i<texture_count; i++){
+ prop.textures.push_back(deSerializeString(is));
+ }
+ prop.spritediv = readV2S16(is);
+ prop.initial_sprite_basepos = readV2S16(is);
+ prop.is_visible = readU8(is);
+ prop.makes_footstep_sound = readU8(is);
+ return prop;
+}
+
std::string gob_cmd_update_position(
v3f position,
v3f velocity,
#include <string>
#include "irrlichttypes.h"
+#include <iostream>
#define GENERIC_CMD_SET_PROPERTIES 0
#define GENERIC_CMD_UPDATE_POSITION 1
#define GENERIC_CMD_PUNCHED 4
#define GENERIC_CMD_UPDATE_ARMOR_GROUPS 5
-std::string gob_cmd_set_properties(
- s16 hp_max,
- bool physical,
- float weight,
- core::aabbox3d<f32> collisionbox,
- std::string visual,
- v2f visual_size,
- core::array<std::string> textures,
- v2s16 spritediv,
- bool is_visible,
- bool makes_footstep_sound
-);
+#include "object_properties.h"
+std::string gob_cmd_set_properties(const ObjectProperties &prop);
+ObjectProperties gob_read_set_properties(std::istream &is);
std::string gob_cmd_update_position(
v3f position,
+++ /dev/null
-/*
-Minetest-c55
-Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "luaentity_common.h"
-
-#include "utility.h"
-
-#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
-#define PP2(x) "("<<(x).X<<","<<(x).Y<<")"
-
-LuaEntityProperties::LuaEntityProperties():
- hp_max(1),
- physical(false),
- weight(5),
- collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5),
- visual("sprite"),
- visual_size(1,1),
- spritediv(1,1),
- initial_sprite_basepos(0,0)
-{
- textures.push_back("unknown_object.png");
-}
-
-std::string LuaEntityProperties::dump()
-{
- std::ostringstream os(std::ios::binary);
- os<<"hp_max="<<hp_max;
- os<<", physical="<<physical;
- os<<", weight="<<weight;
- os<<", collisionbox="<<PP(collisionbox.MinEdge)<<","<<PP(collisionbox.MaxEdge);
- os<<", visual="<<visual;
- os<<", visual_size="<<PP2(visual_size);
- os<<", textures=[";
- for(u32 i=0; i<textures.size(); i++){
- os<<"\""<<textures[i]<<"\" ";
- }
- os<<"]";
- os<<", spritediv="<<PP2(spritediv);
- os<<", initial_sprite_basepos="<<PP2(initial_sprite_basepos);
- return os.str();
-}
-
-void LuaEntityProperties::serialize(std::ostream &os)
-{
- writeU8(os, 1); // version
- writeS16(os, hp_max);
- writeU8(os, physical);
- writeF1000(os, weight);
- writeV3F1000(os, collisionbox.MinEdge);
- writeV3F1000(os, collisionbox.MaxEdge);
- os<<serializeString(visual);
- writeV2F1000(os, visual_size);
- writeU16(os, textures.size());
- for(u32 i=0; i<textures.size(); i++){
- os<<serializeString(textures[i]);
- }
- writeV2S16(os, spritediv);
- writeV2S16(os, initial_sprite_basepos);
-}
-
-void LuaEntityProperties::deSerialize(std::istream &is)
-{
- int version = readU8(is);
- if(version != 1) throw SerializationError(
- "unsupported LuaEntityProperties version");
- hp_max = readS16(is);
- physical = readU8(is);
- weight = readF1000(is);
- collisionbox.MinEdge = readV3F1000(is);
- collisionbox.MaxEdge = readV3F1000(is);
- visual = deSerializeString(is);
- visual_size = readV2F1000(is);
- textures.clear();
- u32 texture_count = readU16(is);
- for(u32 i=0; i<texture_count; i++){
- textures.push_back(deSerializeString(is));
- }
- spritediv = readV2S16(is);
- initial_sprite_basepos = readV2S16(is);
-}
-
-
#ifndef LUAENTITY_COMMON_HEADER
#define LUAENTITY_COMMON_HEADER
-#include <string>
-#include "irrlichttypes.h"
-#include <iostream>
-
-struct LuaEntityProperties
-{
- // Values are BS=1
- s16 hp_max;
- bool physical;
- float weight;
- core::aabbox3d<f32> collisionbox;
- std::string visual;
- v2f visual_size;
- core::array<std::string> textures;
- v2s16 spritediv;
- v2s16 initial_sprite_basepos;
-
- LuaEntityProperties();
- std::string dump();
- void serialize(std::ostream &os);
- void deSerialize(std::istream &is);
-};
-
#define LUAENTITY_CMD_UPDATE_POSITION 0
#define LUAENTITY_CMD_SET_TEXTURE_MOD 1
#define LUAENTITY_CMD_SET_SPRITE 2
--- /dev/null
+/*
+Minetest-c55
+Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "object_properties.h"
+#include "utility.h"
+
+#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
+#define PP2(x) "("<<(x).X<<","<<(x).Y<<")"
+
+ObjectProperties::ObjectProperties():
+ hp_max(1),
+ physical(false),
+ weight(5),
+ collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5),
+ visual("sprite"),
+ visual_size(1,1),
+ spritediv(1,1),
+ initial_sprite_basepos(0,0),
+ is_visible(true),
+ makes_footstep_sound(false)
+{
+ textures.push_back("unknown_object.png");
+}
+
+std::string ObjectProperties::dump()
+{
+ std::ostringstream os(std::ios::binary);
+ os<<"hp_max="<<hp_max;
+ os<<", physical="<<physical;
+ os<<", weight="<<weight;
+ os<<", collisionbox="<<PP(collisionbox.MinEdge)<<","<<PP(collisionbox.MaxEdge);
+ os<<", visual="<<visual;
+ os<<", visual_size="<<PP2(visual_size);
+ os<<", textures=[";
+ for(u32 i=0; i<textures.size(); i++){
+ os<<"\""<<textures[i]<<"\" ";
+ }
+ os<<"]";
+ os<<", spritediv="<<PP2(spritediv);
+ os<<", initial_sprite_basepos="<<PP2(initial_sprite_basepos);
+ os<<", is_visible"<<is_visible;
+ os<<", makes_footstep_sound="<<makes_footstep_sound;
+ return os.str();
+}
+
+void ObjectProperties::serialize(std::ostream &os)
+{
+ writeU8(os, 1); // version
+ writeS16(os, hp_max);
+ writeU8(os, physical);
+ writeF1000(os, weight);
+ writeV3F1000(os, collisionbox.MinEdge);
+ writeV3F1000(os, collisionbox.MaxEdge);
+ os<<serializeString(visual);
+ writeV2F1000(os, visual_size);
+ writeU16(os, textures.size());
+ for(u32 i=0; i<textures.size(); i++){
+ os<<serializeString(textures[i]);
+ }
+ writeV2S16(os, spritediv);
+ writeV2S16(os, initial_sprite_basepos);
+ writeU8(os, is_visible);
+ writeU8(os, makes_footstep_sound);
+}
+
+void ObjectProperties::deSerialize(std::istream &is)
+{
+ int version = readU8(is);
+ if(version != 1) throw SerializationError(
+ "unsupported ObjectProperties version");
+ hp_max = readS16(is);
+ physical = readU8(is);
+ weight = readF1000(is);
+ collisionbox.MinEdge = readV3F1000(is);
+ collisionbox.MaxEdge = readV3F1000(is);
+ visual = deSerializeString(is);
+ visual_size = readV2F1000(is);
+ textures.clear();
+ u32 texture_count = readU16(is);
+ for(u32 i=0; i<texture_count; i++){
+ textures.push_back(deSerializeString(is));
+ }
+ spritediv = readV2S16(is);
+ initial_sprite_basepos = readV2S16(is);
+ is_visible = readU8(is);
+ makes_footstep_sound = readU8(is);
+}
+
+
--- /dev/null
+/*
+Minetest-c55
+Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef OBJECT_PROPERTIES_HEADER
+#define OBJECT_PROPERTIES_HEADER
+
+#include <string>
+#include "irrlichttypes.h"
+#include <iostream>
+
+struct ObjectProperties
+{
+ // Values are BS=1
+ s16 hp_max;
+ bool physical;
+ float weight;
+ core::aabbox3d<f32> collisionbox;
+ std::string visual;
+ v2f visual_size;
+ core::array<std::string> textures;
+ v2s16 spritediv;
+ v2s16 initial_sprite_basepos;
+ bool is_visible;
+ bool makes_footstep_sound;
+
+ ObjectProperties();
+ std::string dump();
+ void serialize(std::ostream &os);
+ void deSerialize(std::istream &is);
+};
+
+#endif
+
#include "filesys.h"
#include "serverobject.h"
#include "script.h"
-//#include "luna.h"
-#include "luaentity_common.h"
+#include "object_properties.h"
#include "content_sao.h" // For LuaEntitySAO and PlayerSAO
#include "itemdef.h"
#include "nodedef.h"
}
void scriptapi_luaentity_get_properties(lua_State *L, u16 id,
- LuaEntityProperties *prop)
+ ObjectProperties *prop)
{
realitycheck(L);
assert(lua_checkstack(L, 20));
class ServerEnvironment;
class ServerActiveObject;
typedef struct lua_State lua_State;
-struct LuaEntityProperties;
+struct ObjectProperties;
struct ItemStack;
struct PointedThing;
//class IGameDef;
void scriptapi_luaentity_rm(lua_State *L, u16 id);
std::string scriptapi_luaentity_get_staticdata(lua_State *L, u16 id);
void scriptapi_luaentity_get_properties(lua_State *L, u16 id,
- LuaEntityProperties *prop);
+ ObjectProperties *prop);
void scriptapi_luaentity_step(lua_State *L, u16 id, float dtime);
void scriptapi_luaentity_punch(lua_State *L, u16 id,
ServerActiveObject *puncher, float time_from_last_punch,