2009-05-06 13:33:22 +01:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2009 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
|
|
|
|
|
|
|
|
|
|
|
2011-02-15 09:30:46 +00:00
|
|
|
#ifdef NDEBUG
|
|
|
|
|
#undef NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#define DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-05-06 13:33:22 +01:00
|
|
|
#include "PropertyCoverage.h"
|
2009-05-06 15:16:07 +01:00
|
|
|
#include "TestWorld.h"
|
2009-05-06 13:33:22 +01:00
|
|
|
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/Entity.h"
|
2009-05-06 13:33:22 +01:00
|
|
|
|
2010-04-08 23:57:49 +01:00
|
|
|
#include "common/log.h"
|
|
|
|
|
|
2009-05-06 13:33:22 +01:00
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
|
|
|
|
#include <Atlas/Objects/SmartPtr.h>
|
2010-10-20 22:51:42 +01:00
|
|
|
#include <Atlas/Objects/RootOperation.h>
|
2009-05-06 13:33:22 +01:00
|
|
|
|
|
|
|
|
using Atlas::Message::Element;
|
|
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
using Atlas::Message::ListType;
|
|
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
|
|
|
|
|
2021-05-18 22:09:57 +02:00
|
|
|
PropertyCoverage::PropertyCoverage(PropertyBase& pb) :
|
2010-09-12 23:55:03 +01:00
|
|
|
m_prop(pb),
|
|
|
|
|
m_tlve(new Entity("0", 0)),
|
2018-08-05 14:31:04 +02:00
|
|
|
m_wrld(new TestWorld(m_tlve)),
|
2010-09-12 23:55:03 +01:00
|
|
|
m_ent(new Entity("1", 1))
|
2009-05-06 13:33:22 +01:00
|
|
|
{
|
2021-06-18 22:44:30 +02:00
|
|
|
m_ent->m_parent = m_tlve.get();
|
|
|
|
|
//m_ent->m_location.m_pos = Point3D(1,0,0);
|
2009-05-06 13:33:22 +01:00
|
|
|
|
2019-11-17 18:43:43 +01:00
|
|
|
m_tlve->m_contains.reset(new LocatedEntitySet);
|
2010-09-12 23:55:03 +01:00
|
|
|
m_tlve->m_contains->insert(m_ent);
|
2009-05-06 13:33:22 +01:00
|
|
|
|
|
|
|
|
m_testData.push_back(23);
|
|
|
|
|
m_testData.push_back(23.);
|
|
|
|
|
m_testData.push_back("twenty_three");
|
|
|
|
|
m_testData.push_back(ListType(1, 23));
|
|
|
|
|
m_testData.push_back(ListType(1, 23.));
|
|
|
|
|
m_testData.push_back(ListType(1, "twenty_three"));
|
|
|
|
|
|
|
|
|
|
MapType map;
|
|
|
|
|
map["one"] = 23;
|
|
|
|
|
map["two"] = 23.;
|
|
|
|
|
map["three"] = "twenty_three";
|
|
|
|
|
map["four"] = ListType(1, 23);
|
|
|
|
|
map["five"] = ListType(1, 23.);
|
|
|
|
|
map["six"] = ListType(1, "twenty_three");
|
|
|
|
|
|
|
|
|
|
m_testData.push_back(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyCoverage::~PropertyCoverage()
|
|
|
|
|
{
|
2021-06-18 22:44:30 +02:00
|
|
|
m_ent->m_parent = nullptr;
|
2021-05-18 22:09:57 +02:00
|
|
|
m_ent.reset();
|
|
|
|
|
m_tlve.reset();
|
2010-09-12 23:55:03 +01:00
|
|
|
delete m_wrld;
|
2009-05-06 13:33:22 +01:00
|
|
|
}
|
|
|
|
|
|
2013-01-07 23:03:25 +00:00
|
|
|
void PropertyCoverage::interfaceCoverage()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-06 13:33:22 +01:00
|
|
|
void PropertyCoverage::basicCoverage()
|
|
|
|
|
{
|
|
|
|
|
Element val;
|
|
|
|
|
|
|
|
|
|
// assert(pb->flags() == 4);
|
|
|
|
|
|
2021-05-18 22:09:57 +02:00
|
|
|
m_prop.get(val);
|
2009-05-06 18:04:52 +01:00
|
|
|
|
2009-05-06 13:33:22 +01:00
|
|
|
// FIXME cover all types inc. map
|
|
|
|
|
ListType::const_iterator I = m_testData.begin();
|
|
|
|
|
ListType::const_iterator Iend = m_testData.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
2021-05-18 22:09:57 +02:00
|
|
|
m_prop.set(*I);
|
2009-05-06 13:33:22 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-18 22:09:57 +02:00
|
|
|
m_prop.get(val);
|
2009-05-06 13:33:22 +01:00
|
|
|
|
2021-05-31 00:05:25 +02:00
|
|
|
m_prop.install(*m_ent, "test_prop");
|
2009-05-06 18:25:16 +01:00
|
|
|
|
|
|
|
|
I = m_testData.begin();
|
|
|
|
|
for (; I != Iend; ++I) {
|
2021-05-18 22:09:57 +02:00
|
|
|
m_prop.set(*I);
|
2021-05-31 00:05:25 +02:00
|
|
|
m_prop.apply(*m_ent);
|
2021-05-18 22:09:57 +02:00
|
|
|
m_ent->propertyApplied("test_prop", m_prop);
|
2009-05-06 18:25:16 +01:00
|
|
|
}
|
|
|
|
|
|
2009-05-06 13:33:22 +01:00
|
|
|
MapType map;
|
2021-05-18 22:09:57 +02:00
|
|
|
m_prop.add("test_name", map);
|
2009-05-06 13:33:22 +01:00
|
|
|
Anonymous ent;
|
2021-05-18 22:09:57 +02:00
|
|
|
m_prop.add("test_name", ent);
|
2013-01-07 23:03:25 +00:00
|
|
|
|
|
|
|
|
interfaceCoverage();
|
2009-05-06 13:33:22 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-01 23:22:28 +02:00
|
|
|
Ref<Entity> PropertyCoverage::createCharacterEntity()
|
2009-06-30 15:57:44 +04:00
|
|
|
{
|
2021-06-18 22:44:30 +02:00
|
|
|
m_ent->m_parent = 0;
|
2010-09-12 23:55:03 +01:00
|
|
|
m_tlve->m_contains->clear();
|
2009-06-30 15:57:44 +04:00
|
|
|
|
2021-05-18 22:09:57 +02:00
|
|
|
Ref<Entity> chr(new Entity("2", 2));
|
2010-09-12 23:55:03 +01:00
|
|
|
m_ent = chr;
|
2021-06-18 22:44:30 +02:00
|
|
|
m_ent->m_parent = m_tlve.get();
|
|
|
|
|
//m_ent->m_location.m_pos = Point3D(1,0,0);
|
2010-09-12 23:55:03 +01:00
|
|
|
m_tlve->m_contains->insert(m_ent);
|
2009-06-30 15:57:44 +04:00
|
|
|
|
|
|
|
|
return chr;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-06 13:33:22 +01:00
|
|
|
void PropertyCoverage::testDataAppend(const Element & o)
|
|
|
|
|
{
|
|
|
|
|
m_testData.push_back(o);
|
|
|
|
|
}
|
2010-04-08 23:57:49 +01:00
|
|
|
|
|
|
|
|
// stubs
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubThing.h"
|
2010-04-08 23:57:49 +01:00
|
|
|
|
|
|
|
|
|
2018-02-26 12:05:10 +01:00
|
|
|
#define STUB_Entity_destroy
|
2010-04-08 23:57:49 +01:00
|
|
|
void Entity::destroy()
|
|
|
|
|
{
|
|
|
|
|
destroyed.emit();
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 11:16:45 +01:00
|
|
|
#define STUB_LocatedEntity_getProperty
|
|
|
|
|
const PropertyBase * LocatedEntity::getProperty(const std::string & name) const
|
2010-04-08 23:57:49 +01:00
|
|
|
{
|
2020-01-01 20:07:42 +01:00
|
|
|
auto I = m_properties.find(name);
|
2010-09-13 01:21:41 +01:00
|
|
|
if (I != m_properties.end()) {
|
2020-01-01 20:07:42 +01:00
|
|
|
return I->second.property.get();
|
2010-09-13 01:21:41 +01:00
|
|
|
}
|
2010-04-08 23:57:49 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubEntity.h"
|
2013-01-17 10:17:07 +00:00
|
|
|
|
2016-06-22 20:53:43 +02:00
|
|
|
|
2017-07-01 19:36:11 +02:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/stubLocatedEntity.h"
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "stubs/common/stubRouter.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubBaseWorld.h"
|
|
|
|
|
#include "stubs/rules/stubLocation.h"
|
2020-01-04 20:20:30 +01:00
|
|
|
#include "stubs/common/stublog.h"
|