2013-01-10 23:22:41 +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-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/Entity.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/DecaysProperty.h"
|
2013-01-10 23:22:41 +00:00
|
|
|
|
|
|
|
|
#include "common/OperationRouter.h"
|
2013-02-13 00:45:36 +00:00
|
|
|
#include "common/PropertyFactory_impl.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/BaseWorld.h"
|
2013-01-10 23:22:41 +00:00
|
|
|
|
|
|
|
|
#include <Atlas/Objects/Operation.h>
|
|
|
|
|
|
|
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
using Atlas::Objects::Operation::Delete;
|
|
|
|
|
|
2018-07-24 21:18:50 +02:00
|
|
|
#include "TestWorld.h"
|
2013-11-15 22:55:17 +01:00
|
|
|
|
2013-01-10 23:22:41 +00:00
|
|
|
class DecaysPropertyintegration : public Cyphesis::TestBase
|
|
|
|
|
{
|
|
|
|
|
private:
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> m_world;
|
|
|
|
|
Ref<Entity> m_entity;
|
2013-01-10 23:22:41 +00:00
|
|
|
PropertyBase * m_property;
|
|
|
|
|
public:
|
|
|
|
|
DecaysPropertyintegration();
|
|
|
|
|
|
|
|
|
|
void setup();
|
|
|
|
|
void teardown();
|
|
|
|
|
|
|
|
|
|
void test_handler();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DecaysPropertyintegration::DecaysPropertyintegration()
|
|
|
|
|
{
|
|
|
|
|
ADD_TEST(DecaysPropertyintegration::test_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DecaysPropertyintegration::setup()
|
|
|
|
|
{
|
|
|
|
|
m_world = new Entity("0", 0);
|
2018-08-05 14:31:04 +02:00
|
|
|
new TestWorld(m_world);
|
2013-01-10 23:22:41 +00:00
|
|
|
|
|
|
|
|
m_entity = new Entity("1", 1);
|
2018-08-17 22:04:07 +02:00
|
|
|
m_entity->m_location.m_parent = m_world;
|
2013-01-10 23:22:41 +00:00
|
|
|
|
2013-02-13 00:45:36 +00:00
|
|
|
PropertyFactory<DecaysProperty> decays_property_factory;
|
2013-01-10 23:22:41 +00:00
|
|
|
|
|
|
|
|
m_property = decays_property_factory.newProperty();
|
2018-08-05 20:47:09 +02:00
|
|
|
m_property->install(m_entity.get(), "decays");
|
2013-01-10 23:22:41 +00:00
|
|
|
m_entity->setProperty("decays", m_property);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DecaysPropertyintegration::teardown()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DecaysPropertyintegration::test_handler()
|
|
|
|
|
{
|
|
|
|
|
Delete d;
|
|
|
|
|
|
|
|
|
|
OpVector res;
|
|
|
|
|
m_entity->operation(d, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
const Operation & reply = res.front();
|
|
|
|
|
ASSERT_EQUAL(reply->getClassNo(), Atlas::Objects::Operation::CREATE_NO);
|
|
|
|
|
ASSERT_EQUAL(reply->getTo(), m_world->getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
DecaysPropertyintegration t;
|
|
|
|
|
|
|
|
|
|
return t.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stubs
|
|
|
|
|
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/AtlasProperties.h"
|
|
|
|
|
#include "rules/Domain.h"
|
|
|
|
|
#include "rules/Script.h"
|
2013-01-10 23:22:41 +00:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/BaseWorld.h"
|
2013-01-10 23:22:41 +00:00
|
|
|
#include "common/id.h"
|
|
|
|
|
#include "common/PropertyManager.h"
|
|
|
|
|
|
|
|
|
|
#include "physics/Vector3D.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"
|
2013-01-10 23:22:41 +00:00
|
|
|
|
|
|
|
|
void addToEntity(const Point3D & p, std::vector<double> & vd)
|
|
|
|
|
{
|
|
|
|
|
vd.resize(3);
|
|
|
|
|
vd[0] = p[0];
|
|
|
|
|
vd[1] = p[1];
|
|
|
|
|
vd[2] = p[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-07-25 00:16:09 +02:00
|
|
|
#ifndef STUB_BaseWorld_getEntity
|
|
|
|
|
#define STUB_BaseWorld_getEntity
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> BaseWorld::getEntity(const std::string & id) const
|
2013-01-10 23:22:41 +00:00
|
|
|
{
|
2018-07-25 00:16:09 +02:00
|
|
|
return getEntity(integerId(id));
|
2013-01-10 23:22:41 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> BaseWorld::getEntity(long id) const
|
2013-01-10 23:22:41 +00:00
|
|
|
{
|
2018-07-25 00:16:09 +02:00
|
|
|
auto I = m_eobjects.find(id);
|
2013-01-10 23:22:41 +00:00
|
|
|
if (I != m_eobjects.end()) {
|
2018-07-25 00:16:09 +02:00
|
|
|
assert(I->second);
|
2013-01-10 23:22:41 +00:00
|
|
|
return I->second;
|
|
|
|
|
} else {
|
2018-07-25 00:16:09 +02:00
|
|
|
return nullptr;
|
2013-01-10 23:22:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-07-25 00:16:09 +02:00
|
|
|
#endif //STUB_BaseWorld_getEntity
|
2013-01-10 23:22:41 +00:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubBaseWorld.h"
|
2013-01-10 23:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/stubScript.h"
|
|
|
|
|
#include "stubs/rules/stubLocation.h"
|
|
|
|
|
#include "stubs/rules/stubAtlasProperties.h"
|
2018-10-27 13:13:45 +02:00
|
|
|
#include "stubs/common/stubLink.h"
|
|
|
|
|
#include "stubs/common/stubRouter.h"
|
2018-04-25 20:09:14 +02:00
|
|
|
#include "stubs/common/stubPropertyManager.h"
|
2013-01-10 23:22:41 +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;
|
|
|
|
|
}
|
2013-09-03 14:01:36 +02:00
|
|
|
|
|
|
|
|
void log(LogLevel lvl, const std::string & msg)
|
|
|
|
|
{
|
|
|
|
|
}
|