2013-01-27 01:34:58 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2013 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
#undef NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#define DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "TestBase.h"
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/AreaProperty.h"
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/Entity.h"
|
2013-01-27 01:34:58 +00:00
|
|
|
|
|
|
|
|
#include "common/TypeNode.h"
|
|
|
|
|
|
|
|
|
|
using Atlas::Message::ListType;
|
|
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
|
|
|
|
|
// Check what happens when two instance of a type both instantiate
|
|
|
|
|
// this property when there is a script. The underlying instance of
|
|
|
|
|
// Shape needs to be copied
|
|
|
|
|
class AreaPropertyintegration : public Cyphesis::TestBase
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
TypeNode * m_char_type;
|
|
|
|
|
PropertyBase * m_char_property;
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> m_char1;
|
|
|
|
|
Ref<Entity> m_char2;
|
2013-01-27 01:34:58 +00:00
|
|
|
public:
|
|
|
|
|
AreaPropertyintegration();
|
|
|
|
|
|
|
|
|
|
void setup();
|
|
|
|
|
void teardown();
|
|
|
|
|
|
|
|
|
|
void test_copy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AreaPropertyintegration::AreaPropertyintegration()
|
|
|
|
|
{
|
|
|
|
|
ADD_TEST(AreaPropertyintegration::test_copy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AreaPropertyintegration::setup()
|
|
|
|
|
{
|
|
|
|
|
m_char_type = new TypeNode("char_type");
|
|
|
|
|
|
|
|
|
|
m_char_property = new AreaProperty;
|
2018-04-25 12:21:44 +02:00
|
|
|
m_char_property->addFlags(flag_class);
|
2013-01-27 01:34:58 +00:00
|
|
|
m_char_property->set(
|
|
|
|
|
MapType{
|
|
|
|
|
std::make_pair("shape", MapType{
|
|
|
|
|
std::make_pair("type", "polygon"),
|
|
|
|
|
std::make_pair("points", ListType(3, ListType(2, 1.f)))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
);
|
2018-01-28 21:25:12 +01:00
|
|
|
m_char_type->injectProperty("char_type", m_char_property);
|
2013-01-27 01:34:58 +00:00
|
|
|
|
|
|
|
|
m_char1 = new Entity("1", 1);
|
|
|
|
|
m_char1->setType(m_char_type);
|
2018-08-05 20:47:09 +02:00
|
|
|
m_char_property->install(m_char1.get(), "char_prop");
|
|
|
|
|
m_char_property->apply(m_char1.get());
|
2016-07-19 20:44:03 +02:00
|
|
|
m_char1->propertyApplied("char_prop", *m_char_property);
|
2013-01-27 01:34:58 +00:00
|
|
|
|
|
|
|
|
m_char2 = new Entity("2", 2);
|
|
|
|
|
m_char2->setType(m_char_type);
|
2018-08-05 20:47:09 +02:00
|
|
|
m_char_property->install(m_char2.get(), "char_prop");
|
|
|
|
|
m_char_property->apply(m_char2.get());
|
2016-07-19 20:44:03 +02:00
|
|
|
m_char2->propertyApplied("char_prop", *m_char_property);
|
2013-01-27 01:34:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AreaPropertyintegration::teardown()
|
|
|
|
|
{
|
2018-08-05 14:31:04 +02:00
|
|
|
m_char1 = nullptr;
|
|
|
|
|
m_char2 = nullptr;
|
2013-01-27 01:34:58 +00:00
|
|
|
delete m_char_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AreaPropertyintegration::test_copy()
|
|
|
|
|
{
|
|
|
|
|
AreaProperty * pb =
|
|
|
|
|
m_char1->modPropertyClass<AreaProperty>("char_type");
|
|
|
|
|
|
|
|
|
|
ASSERT_NOT_EQUAL(pb, m_char_property);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
AreaPropertyintegration t;
|
|
|
|
|
|
|
|
|
|
return t.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stubs
|
|
|
|
|
|
|
|
|
|
#include "common/log.h"
|
|
|
|
|
|
2016-09-02 23:40:19 +02:00
|
|
|
const TerrainProperty * TerrainEffectorProperty::getTerrain(LocatedEntity * owner, LocatedEntity**)
|
2013-01-27 01:34:58 +00:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stubs
|
|
|
|
|
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/AtlasProperties.h"
|
|
|
|
|
#include "rules/Domain.h"
|
|
|
|
|
#include "rules/Script.h"
|
2013-01-27 01:34:58 +00:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/BaseWorld.h"
|
2013-01-27 01:34:58 +00:00
|
|
|
#include "common/log.h"
|
|
|
|
|
#include "common/PropertyManager.h"
|
|
|
|
|
#include "common/TypeNode.h"
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/DomainProperty.h"
|
2018-10-27 13:13:45 +02:00
|
|
|
#include "stubs/common/stubcustom.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/stubDomain.h"
|
|
|
|
|
#include "stubs/rules/simulation/stubDomainProperty.h"
|
2015-04-09 14:50:45 +02:00
|
|
|
#include "stubs/common/stubVariable.h"
|
|
|
|
|
#include "stubs/common/stubMonitors.h"
|
2017-08-02 10:03:58 +02:00
|
|
|
#include "stubs/common/stubProperty.h"
|
2018-10-27 13:13:45 +02:00
|
|
|
#include "stubs/common/stubLink.h"
|
|
|
|
|
#include "stubs/common/stubRouter.h"
|
2013-01-27 01:34:58 +00:00
|
|
|
|
2018-06-15 13:46:17 +02:00
|
|
|
#define STUB_TypeNode_TypeNode
|
|
|
|
|
TypeNode::TypeNode(const std::string & name) : m_name(name), m_parent(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define STUB_TypeNode_TypeNode_DTOR
|
|
|
|
|
TypeNode::~TypeNode()
|
|
|
|
|
{
|
|
|
|
|
PropertyDict::const_iterator I = m_defaults.begin();
|
|
|
|
|
PropertyDict::const_iterator Iend = m_defaults.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
delete I->second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define STUB_TypeNode_injectProperty
|
|
|
|
|
void TypeNode::injectProperty(const std::string& name,
|
|
|
|
|
PropertyBase* p)
|
|
|
|
|
{
|
|
|
|
|
m_defaults[name] = p;
|
|
|
|
|
}
|
|
|
|
|
#include "stubs/common/stubTypeNode.h"
|
|
|
|
|
|
2013-01-27 01:34:58 +00:00
|
|
|
|
|
|
|
|
void addToEntity(const Point3D & p, std::vector<double> & vd)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubBaseWorld.h"
|
2013-01-27 01:34:58 +00:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/stubScript.h"
|
|
|
|
|
#include "stubs/rules/stubLocation.h"
|
2013-01-27 01:34:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
IdProperty::IdProperty(const std::string & data) : PropertyBase(per_ephem),
|
|
|
|
|
m_data(data)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int IdProperty::get(Atlas::Message::Element & e) const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IdProperty::set(const Atlas::Message::Element & e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IdProperty::add(const std::string & key,
|
|
|
|
|
Atlas::Message::MapType & ent) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IdProperty::add(const std::string & key,
|
|
|
|
|
const Atlas::Objects::Entity::RootEntity & ent) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IdProperty * IdProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContainsProperty::ContainsProperty(LocatedEntitySet & data) :
|
|
|
|
|
PropertyBase(per_ephem), m_data(data)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ContainsProperty::get(Atlas::Message::Element & e) const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContainsProperty::set(const Atlas::Message::Element & e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContainsProperty::add(const std::string & s,
|
|
|
|
|
const Atlas::Objects::Entity::RootEntity & ent) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContainsProperty * ContainsProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-25 20:09:14 +02:00
|
|
|
#include "stubs/common/stubPropertyManager.h"
|
2013-02-22 09:57:10 +00:00
|
|
|
|
2013-01-27 01:34:58 +00:00
|
|
|
long integerId(const std::string & id)
|
|
|
|
|
{
|
|
|
|
|
long intId = strtol(id.c_str(), 0, 10);
|
|
|
|
|
if (intId == 0 && id != "0") {
|
|
|
|
|
intId = -1L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return intId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void log(LogLevel lvl, const std::string & msg)
|
|
|
|
|
{
|
|
|
|
|
}
|