cyphesis/tests/Peertest.cpp

1139 lines
24 KiB
C++
Raw Permalink Normal View History

2010-03-16 01:03:50 +00:00
// Cyphesis Online RPG Server and AI Engine
2010-03-18 01:51:46 +00:00
// Copyright (C) 2010 Alistair Riddoch
2010-03-16 01:03:50 +00:00
//
// 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
// $Id$
2011-02-15 09:30:46 +00:00
#ifdef NDEBUG
#undef NDEBUG
#endif
#ifndef DEBUG
#define DEBUG
#endif
2012-08-01 20:31:29 +01:00
#include "null_stream.h"
#include "CommClient_stub_impl.h"
#include "CommStreamClient_stub_impl.h"
2012-08-01 20:31:29 +01:00
2010-03-16 01:03:50 +00:00
#include "server/Peer.h"
2010-11-25 17:39:38 +00:00
#include "server/CommPeer.h"
#include "server/CommServer.h"
2012-11-23 16:11:21 +00:00
#include "rulesets/ExternalMind.h"
2010-11-25 17:12:08 +00:00
2010-11-25 12:16:46 +00:00
#include "common/BaseWorld.h"
2010-11-25 17:12:08 +00:00
#include "rulesets/Character.h"
2010-11-25 16:48:51 +00:00
2010-12-03 21:46:22 +00:00
#include <Atlas/Objects/Operation.h>
2010-03-16 01:03:50 +00:00
#include <Atlas/Objects/SmartPtr.h>
2012-08-01 20:31:29 +01:00
#include <skstream/skstream.h>
2010-03-16 01:03:50 +00:00
#include <cassert>
#include <string>
2012-08-01 20:31:29 +01:00
class TestCommClient : public CommClient<null_stream> {
public:
TestCommClient(CommServer & cs,
const std::string & n) : CommClient<null_stream>(cs, n) { }
};
2010-11-25 12:16:46 +00:00
class TestWorld : public BaseWorld {
public:
explicit TestWorld() : BaseWorld(*(LocatedEntity*)0) {
2010-11-25 12:16:46 +00:00
m_realTime = 100000;
}
2011-10-31 12:47:56 +01:00
virtual bool idle(const SystemTime &) { return false; }
virtual LocatedEntity * addEntity(LocatedEntity * ent) {
2010-11-25 12:16:46 +00:00
return 0;
}
LocatedEntity * test_addEntity(LocatedEntity * ent, long intId) {
2010-11-25 12:16:46 +00:00
m_eobjects[intId] = ent;
return 0;
}
2010-11-25 17:39:38 +00:00
void test_delEntity(long intId) {
m_eobjects.erase(intId);
}
virtual LocatedEntity * addNewEntity(const std::string &,
2010-11-25 12:16:46 +00:00
const Atlas::Objects::Entity::RootEntity &) {
return 0;
}
int createSpawnPoint(const Atlas::Message::MapType & data,
LocatedEntity *) { return 0; }
2010-11-25 12:16:46 +00:00
int getSpawnList(Atlas::Message::ListType & data) { return 0; }
LocatedEntity * spawnNewEntity(const std::string & name,
const std::string & type,
const Atlas::Objects::Entity::RootEntity & desc) {
2010-11-25 12:16:46 +00:00
return addNewEntity(type, desc);
}
virtual Task * newTask(const std::string &, LocatedEntity &) { return 0; }
2010-11-25 12:16:46 +00:00
virtual Task * activateTask(const std::string &, const std::string &,
LocatedEntity *, LocatedEntity &) { return 0; }
virtual ArithmeticScript * newArithmetic(const std::string &,
LocatedEntity *) {
2010-11-25 12:16:46 +00:00
return 0;
}
virtual void message(const Operation & op,
LocatedEntity & ent) {
2010-11-25 12:16:46 +00:00
// stub_baseworld_receieved_op = op->getClassNo();
}
virtual LocatedEntity * findByName(const std::string & name) { return 0; }
virtual LocatedEntity * findByType(const std::string & type) { return 0; }
virtual void addPerceptive(LocatedEntity *) { }
2010-11-25 12:16:46 +00:00
};
class TestPeer : public Peer {
public:
2012-08-01 20:31:29 +01:00
TestPeer(CommSocket & client, ServerRouting & svr,
const std::string & addr, const std::string & id, long iid)
2012-07-19 22:58:30 +01:00
: Peer(client, svr, addr, 6767, id, iid)
{
}
const std::string& getAccountType() const {
return m_accountType;
}
};
Atlas::Objects::Operation::RootOperation stub_CommClient_sent_op(0);
2010-11-25 12:16:46 +00:00
int main()
{
TestWorld world;
CommServer server;
2010-03-16 01:03:50 +00:00
{
2012-08-01 20:31:29 +01:00
Peer * p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-03-16 01:03:50 +00:00
delete p;
}
{
2012-08-01 20:31:29 +01:00
Peer * p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-03-16 01:03:50 +00:00
Atlas::Objects::Operation::RootOperation op;
OpVector res;
p->operation(op, res);
delete p;
}
2010-08-10 19:21:24 +05:30
{
// Test the setting of authentiaction states
2012-08-01 20:31:29 +01:00
Peer * p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-08-10 19:21:24 +05:30
assert(p->getAuthState() == PEER_INIT);
p->setAuthState(PEER_AUTHENTICATED);
assert(p->getAuthState() == PEER_AUTHENTICATED);
2010-08-19 02:11:06 +05:30
delete p;
2010-08-10 19:21:24 +05:30
}
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
Atlas::Objects::Operation::Info op;
OpVector res;
p->operation(op, res);
}
2010-11-25 16:11:07 +00:00
// Authenticating (no args)
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 16:11:07 +00:00
p->setAuthState(PEER_AUTHENTICATING);
Atlas::Objects::Operation::Info op;
OpVector res;
p->operation(op, res);
}
// Authenticating (empty arg)
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 16:11:07 +00:00
p->setAuthState(PEER_AUTHENTICATING);
Atlas::Objects::Operation::Info op;
Atlas::Objects::Root arg;
op->setArgs1(arg);
OpVector res;
p->operation(op, res);
}
// Authenticating (full arg)
{
2012-08-01 20:31:29 +01:00
TestPeer *p = new TestPeer(*(CommSocket*)0, *(ServerRouting*)0, "addr", "1", 1);
2010-11-25 16:11:07 +00:00
p->setAuthState(PEER_AUTHENTICATING);
Atlas::Objects::Operation::Info op;
Atlas::Objects::Root arg;
arg->setId("2");
std::list<std::string> parents;
parents.push_back("server");
arg->setParents(parents);
2010-11-25 16:11:07 +00:00
op->setArgs1(arg);
OpVector res;
p->operation(op, res);
assert(p->getAccountType() == "server");
2010-11-25 16:11:07 +00:00
}
// Authenticated (no args)
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 16:11:07 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Atlas::Objects::Operation::Info op;
OpVector res;
p->operation(op, res);
}
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 16:11:07 +00:00
Atlas::Objects::Operation::Error op;
OpVector res;
p->operation(op, res);
}
2010-11-25 16:48:51 +00:00
// Not authenticated
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 16:48:51 +00:00
Entity e("3", 3);
int ret = p->teleportEntity(&e);
assert(ret == -1);
}
// Authenticated
{
2012-08-01 20:31:29 +01:00
TestCommClient client(server, "");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(client, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 16:48:51 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Entity e("3", 3);
int ret = p->teleportEntity(&e);
assert(ret == 0);
assert(stub_CommClient_sent_op.isValid());
assert(stub_CommClient_sent_op->getArgs().size() == 1);
2010-11-25 16:48:51 +00:00
}
2010-11-25 17:12:08 +00:00
// Re-teleport same entity
{
2012-08-01 20:31:29 +01:00
TestCommClient client(server, "");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(client, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:12:08 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Entity e("3", 3);
int ret = p->teleportEntity(&e);
assert(ret == 0);
assert(stub_CommClient_sent_op.isValid());
assert(stub_CommClient_sent_op->getArgs().size() == 1);
2010-11-25 17:12:08 +00:00
ret = p->teleportEntity(&e);
assert(ret != 0);
}
// Character (no mind)
{
2012-08-01 20:31:29 +01:00
TestCommClient client(server, "");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(client, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:12:08 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Character e("3", 3);
int ret = p->teleportEntity(&e);
assert(ret == 0);
assert(stub_CommClient_sent_op.isValid());
assert(stub_CommClient_sent_op->getArgs().size() == 1);
2010-11-25 17:12:08 +00:00
}
// Character (externl mind, unconnected)
{
2012-08-01 20:31:29 +01:00
TestCommClient client(server, "");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(client, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:12:08 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Character e("3", 3);
e.m_externalMind = new ExternalMind(e);
int ret = p->teleportEntity(&e);
assert(ret == 0);
assert(stub_CommClient_sent_op.isValid());
assert(stub_CommClient_sent_op->getArgs().size() == 1);
2010-11-25 17:12:08 +00:00
}
// Character (externl mind, connected)
{
2012-08-01 20:31:29 +01:00
TestCommClient client(server, "");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(client, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:12:08 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Character e("3", 3);
ExternalMind * mind = new ExternalMind(e);
mind->linkUp((Link*)23);
2010-11-25 17:12:08 +00:00
e.m_externalMind = mind;
int ret = p->teleportEntity(&e);
assert(ret == 0);
assert(stub_CommClient_sent_op.isValid());
assert(stub_CommClient_sent_op->getArgs().size() == 2);
2010-11-25 17:12:08 +00:00
}
2010-11-25 17:39:38 +00:00
// No arg
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
Atlas::Objects::Operation::Info op;
OpVector res;
p->peerTeleportResponse(op, res);
}
// Empty arg, no refno
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
Atlas::Objects::Operation::Info op;
OpVector res;
Atlas::Objects::Root arg;
op->setArgs1(arg);
p->peerTeleportResponse(op, res);
}
// Empty arg, made up refno, not CommPeer
{
2012-08-01 20:31:29 +01:00
TestCommClient *peerConn = new TestCommClient(*(CommServer*)0, "name");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(*peerConn, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
Atlas::Objects::Operation::Info op;
OpVector res;
Atlas::Objects::Root arg;
op->setArgs1(arg);
op->setRefno(23);
p->peerTeleportResponse(op, res);
}
// Empty arg, made up refno
{
2011-10-30 01:04:54 +02:00
CommPeer *peerConn = new CommPeer(*(CommServer*)0, "name");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(*peerConn, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
Atlas::Objects::Operation::Info op;
OpVector res;
Atlas::Objects::Root arg;
op->setArgs1(arg);
op->setRefno(23);
p->peerTeleportResponse(op, res);
}
// Empty arg, refno that matches earlier teleport, not in world
{
CommPeer *peerConn = new CommPeer(server, "name");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(*peerConn, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Entity e("23", 23);
int ret = p->teleportEntity(&e);
assert(ret == 0);
Atlas::Objects::Operation::Info op;
OpVector res;
Atlas::Objects::Root arg;
op->setArgs1(arg);
op->setRefno(23);
p->peerTeleportResponse(op, res);
}
// Empty arg, refno that matches earlier teleport, in world
{
CommPeer *peerConn = new CommPeer(server, "name");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(*peerConn, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Entity e("23", 23);
int ret = p->teleportEntity(&e);
assert(ret == 0);
world.test_addEntity(&e, 23);
Atlas::Objects::Operation::Info op;
OpVector res;
Atlas::Objects::Root arg;
op->setArgs1(arg);
op->setRefno(23);
p->peerTeleportResponse(op, res);
world.test_delEntity(23);
}
// Empty arg, refno that matches earlier teleport, with mind
{
CommPeer *peerConn = new CommPeer(server, "name");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(*peerConn, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Character e("23", 23);
ExternalMind * mind = new ExternalMind(e);
mind->linkUp((Link*)23);
2010-11-25 17:39:38 +00:00
e.m_externalMind = mind;
int ret = p->teleportEntity(&e);
assert(ret == 0);
world.test_addEntity(&e, 23);
Atlas::Objects::Operation::Info op;
OpVector res;
Atlas::Objects::Root arg;
op->setArgs1(arg);
op->setRefno(23);
p->peerTeleportResponse(op, res);
world.test_delEntity(23);
}
// No teleports to clear
2010-11-25 16:11:07 +00:00
{
2012-08-01 20:31:29 +01:00
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 16:11:07 +00:00
p->cleanTeleports();
}
2010-11-25 17:39:38 +00:00
// One teleport to clear
{
2012-08-01 20:31:29 +01:00
TestCommClient client(server, "");
2012-07-19 22:58:30 +01:00
Peer *p = new Peer(client, *(ServerRouting*)0, "addr", 6767, "1", 1);
2010-11-25 17:39:38 +00:00
p->setAuthState(PEER_AUTHENTICATED);
Entity e("23", 23);
int ret = p->teleportEntity(&e);
assert(ret == 0);
p->cleanTeleports();
}
2010-03-16 01:03:50 +00:00
return 0;
}
2010-11-25 12:16:46 +00:00
// stubs
#include "server/CommServer.h"
#include "server/TeleportState.h"
#include "rulesets/Character.h"
#include "rulesets/Script.h"
#include "common/id.h"
#include "common/log.h"
#include "common/TypeNode.h"
#include <Atlas/Negotiate.h>
#include <cstdlib>
using Atlas::Message::MapType;
2010-11-25 14:29:44 +00:00
TeleportState::TeleportState(time_t time) : m_state(TELEPORT_NONE),
m_teleportTime(time)
2010-11-25 12:16:46 +00:00
{
}
void TeleportState::setRequested()
{
m_state = TELEPORT_REQUESTED;
}
void TeleportState::setCreated()
{
m_state = TELEPORT_CREATED;
}
void TeleportState::setKey(const std::string & key)
{
m_possessKey = key;
}
CommServer::CommServer() : m_congested(false)
{
}
CommServer::~CommServer()
{
}
2011-10-30 01:04:54 +02:00
CommPeer::CommPeer(CommServer & svr, const std::string & n) :
2012-08-01 20:31:29 +01:00
CommClient<tcp_socket_stream>(svr, n)
2010-11-25 17:39:38 +00:00
{
}
2010-11-25 12:16:46 +00:00
CommPeer::~CommPeer()
{
}
2010-12-13 08:06:08 +00:00
bool CommPeer::eof()
{
return false;
}
2010-11-25 12:16:46 +00:00
void CommPeer::idle(time_t t)
{
}
2012-08-01 20:31:29 +01:00
template class CommStreamClient<tcp_socket_stream>;
template class CommClient<tcp_socket_stream>;
2010-11-25 12:16:46 +00:00
CommSocket::CommSocket(CommServer & svr) : m_commServer(svr) { }
CommSocket::~CommSocket()
{
}
2012-08-01 20:31:29 +01:00
int CommSocket::flush()
2010-11-25 12:16:46 +00:00
{
2012-08-01 20:31:29 +01:00
return 0;
2010-11-25 12:16:46 +00:00
}
Idle::Idle(CommServer & svr) : m_idleManager(svr)
{
}
Idle::~Idle()
{
}
ExternalMind::ExternalMind(LocatedEntity & e) : Router(e.getId(), e.getIntId()),
m_external(0), m_entity(e)
2010-11-25 17:12:08 +00:00
{
}
2010-11-25 12:16:46 +00:00
ExternalMind::~ExternalMind()
{
}
void ExternalMind::externalOperation(const Operation &, Link &)
{
}
2010-11-25 12:16:46 +00:00
void ExternalMind::operation(const Operation & op, OpVector & res)
{
}
void ExternalMind::linkUp(Link * c)
2010-11-25 17:12:08 +00:00
{
m_external = c;
2010-11-25 17:12:08 +00:00
}
2010-11-25 12:16:46 +00:00
Character::Character(const std::string & id, long intId) :
2012-12-04 23:39:22 +00:00
Thing(id, intId),
2010-11-25 12:16:46 +00:00
m_movement(*(Movement*)0),
m_mind(0), m_externalMind(0)
2010-11-25 12:16:46 +00:00
{
}
Character::~Character()
{
}
void Character::operation(const Operation & op, OpVector &)
{
}
void Character::externalOperation(const Operation & op, Link &)
2010-11-25 12:16:46 +00:00
{
}
void Character::ImaginaryOperation(const Operation & op, OpVector &)
{
}
2012-07-02 20:05:18 -07:00
void Character::InfoOperation(const Operation & op, OpVector &)
{
}
2010-11-25 12:16:46 +00:00
void Character::TickOperation(const Operation & op, OpVector &)
{
}
void Character::TalkOperation(const Operation & op, OpVector &)
{
}
void Character::NourishOperation(const Operation & op, OpVector &)
{
}
void Character::UseOperation(const Operation & op, OpVector &)
{
}
void Character::WieldOperation(const Operation & op, OpVector &)
{
}
void Character::AttackOperation(const Operation & op, OpVector &)
{
}
void Character::ActuateOperation(const Operation & op, OpVector &)
{
}
void Character::mindActuateOperation(const Operation &, OpVector &)
{
}
void Character::mindAttackOperation(const Operation &, OpVector &)
{
}
void Character::mindCombineOperation(const Operation &, OpVector &)
{
}
void Character::mindCreateOperation(const Operation &, OpVector &)
{
}
void Character::mindDeleteOperation(const Operation &, OpVector &)
{
}
void Character::mindDivideOperation(const Operation &, OpVector &)
{
}
void Character::mindEatOperation(const Operation &, OpVector &)
{
}
void Character::mindGoalInfoOperation(const Operation &, OpVector &)
{
}
void Character::mindImaginaryOperation(const Operation &, OpVector &)
{
}
void Character::mindLookOperation(const Operation &, OpVector &)
{
}
void Character::mindMoveOperation(const Operation &, OpVector &)
{
}
void Character::mindSetOperation(const Operation &, OpVector &)
{
}
void Character::mindSetupOperation(const Operation &, OpVector &)
{
}
void Character::mindTalkOperation(const Operation &, OpVector &)
{
}
void Character::mindThoughtOperation(const Operation &, OpVector &)
{
}
void Character::mindTickOperation(const Operation &, OpVector &)
{
}
void Character::mindTouchOperation(const Operation &, OpVector &)
{
}
void Character::mindUpdateOperation(const Operation &, OpVector &)
{
}
void Character::mindUseOperation(const Operation &, OpVector &)
{
}
void Character::mindWieldOperation(const Operation &, OpVector &)
{
}
void Character::mindOtherOperation(const Operation &, OpVector &)
{
}
void Character::sendMind(const Operation & op, OpVector & res)
{
}
Thing::Thing(const std::string & id, long intId) :
2012-12-04 23:48:40 +00:00
Entity(id, intId)
2010-11-25 12:16:46 +00:00
{
}
Thing::~Thing()
{
}
void Thing::DeleteOperation(const Operation & op, OpVector & res)
{
}
void Thing::MoveOperation(const Operation & op, OpVector & res)
{
}
void Thing::SetOperation(const Operation & op, OpVector & res)
{
}
void Thing::LookOperation(const Operation & op, OpVector & res)
{
}
void Thing::CreateOperation(const Operation & op, OpVector & res)
{
}
void Thing::UpdateOperation(const Operation & op, OpVector & res)
{
}
Entity::Entity(const std::string & id, long intId) :
2013-01-14 09:59:54 +00:00
LocatedEntity(id, intId), m_motion(0)
2010-11-25 12:16:46 +00:00
{
}
Entity::~Entity()
{
}
void Entity::destroy()
{
destroyed.emit();
}
void Entity::ActuateOperation(const Operation &, OpVector &)
{
}
void Entity::AppearanceOperation(const Operation &, OpVector &)
{
}
void Entity::AttackOperation(const Operation &, OpVector &)
{
}
void Entity::CombineOperation(const Operation &, OpVector &)
{
}
void Entity::CreateOperation(const Operation &, OpVector &)
{
}
void Entity::DeleteOperation(const Operation &, OpVector &)
{
}
void Entity::DisappearanceOperation(const Operation &, OpVector &)
{
}
void Entity::DivideOperation(const Operation &, OpVector &)
{
}
void Entity::EatOperation(const Operation &, OpVector &)
{
}
2012-06-30 01:06:14 -07:00
void Entity::GetOperation(const Operation &, OpVector &)
{
}
void Entity::InfoOperation(const Operation &, OpVector &)
{
}
2010-11-25 12:16:46 +00:00
void Entity::ImaginaryOperation(const Operation &, OpVector &)
{
}
void Entity::LookOperation(const Operation &, OpVector &)
{
}
void Entity::MoveOperation(const Operation &, OpVector &)
{
}
void Entity::NourishOperation(const Operation &, OpVector &)
{
}
void Entity::SetOperation(const Operation &, OpVector &)
{
}
void Entity::SightOperation(const Operation &, OpVector &)
{
}
void Entity::SoundOperation(const Operation &, OpVector &)
{
}
void Entity::TalkOperation(const Operation &, OpVector &)
{
}
void Entity::TickOperation(const Operation &, OpVector &)
{
}
void Entity::TouchOperation(const Operation &, OpVector &)
{
}
void Entity::UpdateOperation(const Operation &, OpVector &)
{
}
void Entity::UseOperation(const Operation &, OpVector &)
{
}
void Entity::WieldOperation(const Operation &, OpVector &)
{
}
void Entity::externalOperation(const Operation & op, Link &)
2010-11-25 12:16:46 +00:00
{
}
void Entity::operation(const Operation & op, OpVector & res)
{
}
void Entity::addToMessage(Atlas::Message::MapType & omap) const
{
}
void Entity::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
}
2011-02-28 00:28:25 +00:00
PropertyBase * Entity::setAttr(const std::string & name,
const Atlas::Message::Element & attr)
2010-11-25 12:16:46 +00:00
{
2011-02-28 00:28:25 +00:00
return 0;
2010-11-25 12:16:46 +00:00
}
const PropertyBase * Entity::getProperty(const std::string & name) const
{
return 0;
}
PropertyBase * Entity::modProperty(const std::string & name)
{
return 0;
}
PropertyBase * Entity::setProperty(const std::string & name,
PropertyBase * prop)
{
return 0;
}
void Entity::installDelegate(int class_no, const std::string & delegate)
{
}
Domain * Entity::getMovementDomain()
{
return 0;
}
void Entity::sendWorld(const Operation & op)
{
}
2010-11-25 12:16:46 +00:00
void Entity::onContainered()
{
}
void Entity::onUpdated()
{
}
void Entity::callOperation(const Operation & op, OpVector & res)
{
}
LocatedEntity::LocatedEntity(const std::string & id, long intId) :
Router(id, intId),
m_refCount(0), m_seq(0),
2013-01-14 09:59:54 +00:00
m_script(0), m_type(0), m_flags(0), m_contains(0)
2010-11-25 12:16:46 +00:00
{
}
LocatedEntity::~LocatedEntity()
{
}
bool LocatedEntity::hasAttr(const std::string & name) const
{
return false;
}
2011-09-29 17:36:26 +01:00
int LocatedEntity::getAttr(const std::string & name,
Atlas::Message::Element & attr) const
2010-11-25 12:16:46 +00:00
{
2011-09-29 17:36:26 +01:00
return -1;
2010-11-25 12:16:46 +00:00
}
2011-09-29 17:36:26 +01:00
int LocatedEntity::getAttrType(const std::string & name,
Atlas::Message::Element & attr,
int type) const
2010-11-25 12:16:46 +00:00
{
2011-09-29 17:36:26 +01:00
return -1;
2010-11-25 12:16:46 +00:00
}
2011-02-28 00:28:25 +00:00
PropertyBase * LocatedEntity::setAttr(const std::string & name,
const Atlas::Message::Element & attr)
2010-11-25 12:16:46 +00:00
{
2011-02-28 00:28:25 +00:00
return 0;
2010-11-25 12:16:46 +00:00
}
const PropertyBase * LocatedEntity::getProperty(const std::string & name) const
{
return 0;
}
PropertyBase * LocatedEntity::modProperty(const std::string & name)
{
return 0;
}
PropertyBase * LocatedEntity::setProperty(const std::string & name,
PropertyBase * prop)
{
return 0;
}
void LocatedEntity::installDelegate(int, const std::string &)
{
}
void LocatedEntity::destroy()
{
}
Domain * LocatedEntity::getMovementDomain()
{
return 0;
}
void LocatedEntity::sendWorld(const Operation & op)
{
}
2010-11-25 12:16:46 +00:00
void LocatedEntity::onContainered()
{
}
void LocatedEntity::onUpdated()
{
}
void LocatedEntity::makeContainer()
{
if (m_contains == 0) {
m_contains = new LocatedEntitySet;
}
}
void LocatedEntity::merge(const MapType & ent)
{
}
2012-08-01 20:31:29 +01:00
Link::Link(CommSocket & socket, const std::string & id, long iid) :
Router(id, iid), m_encoder(0), m_commSocket(socket)
{
}
Link::~Link()
{
}
void Link::send(const Operation & op) const
{
stub_CommClient_sent_op = op;
2012-08-01 20:31:29 +01:00
}
void Link::disconnect()
{
}
2010-11-25 12:16:46 +00:00
Router::Router(const std::string & id, long intId) : m_id(id),
m_intId(intId)
{
}
Router::~Router()
{
}
void Router::addToMessage(Atlas::Message::MapType & omap) const
{
}
void Router::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
}
void Router::error(const Operation & op,
const std::string & errstring,
OpVector & res,
const std::string & to) const
{
}
Script::Script()
{
}
/// \brief Script destructor
Script::~Script()
{
}
bool Script::operation(const std::string & opname,
const Atlas::Objects::Operation::RootOperation & op,
OpVector & res)
{
return false;
}
void Script::hook(const std::string & function, LocatedEntity * entity)
{
}
void Location::addToMessage(MapType & omap) const
{
}
Location::Location() : m_loc(0)
{
}
Location::Location(LocatedEntity * rf, const Point3D & pos)
{
}
void Location::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
{
}
TypeNode::TypeNode(const std::string & name) : m_name(name), m_parent(0)
2010-11-25 12:16:46 +00:00
{
}
TypeNode::~TypeNode()
{
}
BaseWorld * BaseWorld::m_instance = 0;
BaseWorld::BaseWorld(LocatedEntity & gw) : m_gameWorld(gw)
2010-11-25 12:16:46 +00:00
{
m_instance = this;
}
BaseWorld::~BaseWorld()
{
m_instance = 0;
}
LocatedEntity * BaseWorld::getEntity(const std::string & id) const
2010-11-25 12:16:46 +00:00
{
long intId = integerId(id);
EntityDict::const_iterator I = m_eobjects.find(intId);
if (I != m_eobjects.end()) {
assert(I->second != 0);
return I->second;
} else {
return 0;
}
}
LocatedEntity * BaseWorld::getEntity(long id) const
2010-11-25 12:16:46 +00:00
{
EntityDict::const_iterator I = m_eobjects.find(id);
if (I != m_eobjects.end()) {
assert(I->second != 0);
return I->second;
} else {
return 0;
}
}
void log(LogLevel lvl, const std::string & msg)
{
}
2010-11-30 22:05:38 +00:00
void logEvent(LogEvent lev, const std::string & msg)
{
}
2010-11-25 12:16:46 +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;
}