Commit d8d4764f authored by Olek Wojnar's avatar Olek Wojnar

Imported Upstream version 1.3.23

parent 8a713b24
Original author and current maintainer is James Turner
(james@worldforge.org)
Original author is James Turner (james@worldforge.org)
Current maintainer is Erik Ogenvik (erik@ogenvik.org)
Numerous contributions by Ron Steinke including the Perl bindings, WFmath
conversion and bug reports by the dozen.
......@@ -18,4 +19,4 @@ Contributors :
Ron Steinke
Michael Koch
Simon Goodall
Erik Hjortsberg
Erik Ogenvik (née Hjortsberg)
commit e985d04
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2014-02-17
Note release.
NEWS
commit 79c4eff
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2014-01-23
Fixed incorrect variable name and references.
Eris/Entity.cpp
commit 608da35
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2014-01-23
Check for valid element types.
Invalid remote data should never cause exceptions.
Eris/Entity.cpp
commit a30ab7c
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2014-01-11
Fix possible segfault.
Eris/BaseConnection.cpp
commit d9f3f97
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2014-01-02
Don't check new pointer for nullptr.
Nowadays thats the task of the OS.
Eris/TerrainModObserver.cpp
commit dfe0130
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2014-01-02
Cleanup win32 stuff.
The official macro is _WIN32
Eris/Account.cpp
Eris/Avatar.cpp
Eris/BaseConnection.cpp
Eris/Connection.cpp
Eris/Entity.cpp
Eris/IGRouter.cpp
Eris/Lobby.cpp
Eris/Metaserver.cpp
Eris/Metaserver.h
Eris/Room.cpp
Eris/TypeInfo.cpp
Eris/TypeService.cpp
Eris/View.cpp
commit 7e4029d
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2013-11-24
Fix possible nullptr dereferencing.
Eris/TypeInfo.cpp
commit 2cbc2a9
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2013-11-24
assert for nullptr.
Eris/View.cpp
commit 4bee305
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2013-11-24
Remove code for old windows versions.
Currently we support WinXP SP3+ only.
Eris/PollDefault.cpp
commit 210e92f
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2013-11-24
Fix using uninitialized pointer.
C6001 Using uninitialized memory 'ent'.
line 321: 'ent' is not initialized
line 321:'ent' is used, but may not have been initialized
Eris/View.cpp
commit fce934d
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-11-17
Added function for extracting entity ids.
Since entity ids can either be sent as a string, or as a map with an
"$eid" entry, we need a unified method for extracting.
Eris/Avatar.cpp
Eris/Entity.cpp
Eris/Entity.h
commit 53a224c
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-11-17
Bump for next version.
configure.ac
commit cebe735
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Note release.
NEWS
commit 549b8d1
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Bring required Atlas in line with Ember.
configure.ac
commit f395061
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Update maintainer info.
AUTHORS
commit 0f61101
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Bump interface version.
As there are breaking changes.
configure.ac
commit 457d3d6
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Update Doxygen file.
Using the Doxygen update command.
eris.dox.in
commit ac5bb60
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Harmonize "docs" target within WF.
All other libraries and components use "docs" as the target for building
Doxygen docs. Eris should be similar.
Makefile.am
doc/HOWTO_-_Metaserver_Implementation.txt
doc/Testcases
doc/eris.tex
docs/HOWTO_-_Metaserver_Implementation.txt
docs/Testcases
docs/eris.tex
eris.dox.in
commit 78b28f4
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Put support files in "support".
Thus harmonizing the way support files are handled throughout the WF
components.
ChangeLog-CVS
Makefile.am
generate-ChangeLog.sh
scripts/run_coverage_tests.sh
support/ChangeLog-CVS
support/generate-ChangeLog.sh
support/run_coverage_tests.sh
commit a4933bd
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-23
Added script for generating ABI report.
.gitignore
support/generate_abi_report.sh
commit 3fe7f74
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-10-22
Squash compile warnings.
Eris/PollDefault.cpp
commit cf64a8d
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-09-01
Removed unnecessary virtual from method.
Eris/TypeInfo.h
commit 9db52d9
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-09-01
Fix compiler warnings.
Eris/Connection.cpp
Eris/Metaserver.cpp
Eris/View.cpp
commit b96f01d
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-08-30
Require Mercator 0.3.3.
The reason for this is that this is the first version where there are
guarantees that the rounding method used in all calculations is uniform,
both within a process and between various platforms. Previous versions
didn't guarantee this.
configure.ac
commit d8dc6c0
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-08-23
Expose the InitialSight View event.
This is useful for authoring tools in clients, as it's emitted when a
new entity has been created, after it's been initialized. "EntitySeen"
and "EntityCreated" both rely on a Sight op being sent, which might not
always be the case.
Eris/View.h
commit bd06e18
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-08-05
Handle the avatar entity being deleted.
When this happens we should deactivate the character, since it relies on
the entity being available in order to experience the world.
We need to devise a future system where an entity can be defeated
without being destroyed; this to handle the typical scenario in a
virtual world where the client isn't immediately disconnected when the
avatar entity is killed.
Eris/Avatar.cpp
Eris/Avatar.h
Eris/View.cpp
Eris/View.h
commit deb2a4e
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-07-26
Improve rounding handling.
Eris/iround.h
commit bddbca3
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2013-07-14
Use tcp socket for msvc on local connections.
The unix_socket_stream is not availible on msvc.
Eris/BaseConnection.cpp
commit 4f765d9
Author: Peter Szücs <peter.szucs.dev@gmail.com>
Date: 2013-07-14
Add missing header.
The std::function is in functional header,
but it's missing and causes compile errors.
Eris/BaseConnection.h
commit 5a88005
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-05-16
Added custom "sys" account entity.
A "sys" account behaves much like an "admin" account, but it's not
persisted on the server. This makes it suitable for using when
accessing a local server (through a socket for example).
Eris/BaseConnection.cpp
Eris/CustomEntities.cpp
Eris/CustomEntities.h
Eris/Makefile.am
commit 5b294b0
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-05-16
Allow for custom create char ops.
This allows for creation of "admin" and "sys" accounts, as well as any
other future account type.
Eris/Account.cpp
Eris/Account.h
commit e0d2928
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-05-13
Added support for connecting through socket.
Eris/BaseConnection.cpp
Eris/BaseConnection.h
Eris/Connection.cpp
Eris/Connection.h
test/Account_unittest.cpp
test/Connection_unittest.cpp
test/IGRouter_unittest.cpp
test/Metaserver_integrationtest.cpp
test/Metaserver_unittest.cpp
commit e0b6930
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-04-21
Bump development version.
configure.ac
commit 9bf72ae
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2013-04-21
Harmonize autogen.sh within project.
This version should work on all supported platforms, opting to using
autoreconf if available.
Makefile.am
autogen.sh
configure.ac
commit 466529e
Author: Erik Ogenvik <erik@ogenvik.org>
Date: 2012-12-03
Replace auto_ptr with unique_ptr.
As auto_ptr is deprecated with C++11.
Eris/Account.h
Eris/Connection.h
Eris/Metaserver.h
test/Account_unittest.cpp
test/IGRouter_unittest.cpp
test/Makefile.am
test/avatarTest.cpp
test/calendarTest.cpp
test/setupHelpers.h
test/stubServer.h
test/testCalendar.cpp
commit b83f31c
Author: Alistair Riddoch <alriddoch@googlemail.com>
Date: 2012-11-30
Switch to C++11
.gitignore
acinclude.m4
autogen.sh
configure.ac
m4/ax_cxx_compile_stdcxx_11.m4
m4/glib.m4
m4/pkg.m4
commit d57f18f
Author: Alistair Riddoch <alriddoch@googlemail.com>
Date: 2012-11-29
......@@ -2625,6 +3035,7 @@ Date: 2009-03-04
Add mercator dep to ERIS_REQUIRES so it correctly propagate into pkgconfig file.
configure.ac
2009-03-02 Al Riddoch <alriddoch@googlemail.com>
* configure.ac: Remove two defines which used to be required to
......
......@@ -22,8 +22,6 @@
#include <cassert>
#include <iostream>
#pragma warning(disable: 4068) //unknown pragma
using Atlas::Objects::Root;
using Atlas::Message::Element;
using namespace Atlas::Objects::Operation;
......@@ -125,28 +123,33 @@ Result Account::createAccount(const std::string &uname,
const std::string &fullName,
const std::string &pwd)
{
if (!m_con->isConnected()) return NOT_CONNECTED;
if (m_status != DISCONNECTED) return ALREADY_LOGGED_IN;
// store for re-logins
m_username = uname;
m_pass = pwd;
m_status = LOGGING_IN;
// okay, build and send the create(account) op
AtlasAccount account;
account->setPassword(pwd);
account->setName(fullName);
account->setUsername(uname);
return createAccount(account);
}
Result Account::createAccount(Atlas::Objects::Entity::Account accountOp)
{
if (!m_con->isConnected()) return NOT_CONNECTED;
if (m_status != DISCONNECTED) return ALREADY_LOGGED_IN;
m_status = LOGGING_IN;
Create c;
c->setSerialno(getNewSerialno());
c->setArgs1(account);
c->setArgs1(accountOp);
m_con->getResponder()->await(c->getSerialno(), this, &Account::loginResponse);
m_con->send(c);
// store for re-logins
m_username = uname;
m_pass = pwd;
m_timeout.reset(new Timeout(5000));
m_timeout->Expired.connect(sigc::mem_fun(this, &Account::handleLoginTimeout));
......
......@@ -81,6 +81,19 @@ public:
const std::string &fullName,
const std::string &pwd);
/* Create a new account on the server, if possible.
Server-side failures, such as an account already existing with the specified
username, will cause the 'LoginFailure' signal to be emitted with an error message
and a code. As for 'login', LoginSuccess wil be emitted if everything goes as plan.
This variant allows you to specify your own Account op, which is useful when you
want to create an account different from the standard one.
@param accountOp The account operation, which will be wrapped in a "Create" op.
*/
Result createAccount(Atlas::Objects::Entity::Account accountOp);
/// Request logout from the server.
/** Initiate a clean disconnection from the server. The LogoutComplete
signal will be emitted when the process completes. Calling this on an Account
......@@ -283,7 +296,7 @@ protected:
bool m_doingCharacterRefresh; ///< set if we're refreshing character data
ActiveCharacterMap m_activeCharacters;
std::auto_ptr<Timeout> m_timeout;
std::unique_ptr<Timeout> m_timeout;
/**
* @brief A map of available spawn points.
......
......@@ -22,8 +22,6 @@
#include <Atlas/Objects/Entity.h>
#include <Atlas/Objects/Anonymous.h>
#pragma warning(disable: 4068) //unknown pragma
using namespace Atlas::Objects::Operation;
using Atlas::Objects::Root;
using Atlas::Objects::Entity::Anonymous;
......@@ -46,6 +44,7 @@ Avatar::Avatar(Account& pl, const std::string& entId) :
m_isAdmin(false)
{
m_view = new View(this);
m_view->AvatarEntityDeleted.connect(sigc::mem_fun(this, &Avatar::onAvatarEntityDeleted));
m_entityAppearanceCon = m_view->Appearance.connect(sigc::mem_fun(this, &Avatar::onEntityAppear));
m_router = new IGRouter(this);
......@@ -361,6 +360,12 @@ void Avatar::onEntityAppear(Entity* ent)
}
}
void Avatar::onAvatarEntityDeleted()
{
//When the avatar entity is destroyed we should also deactivate the character.
m_account.deactivateCharacter(this);
}
void Avatar::onCharacterChildAdded(Entity* child)
{
InvAdded.emit(child);
......@@ -373,12 +378,13 @@ void Avatar::onCharacterChildRemoved(Entity* child)
void Avatar::onCharacterWield(const Atlas::Message::Element& val)
{
if (!val.isString()) {
std::string id;
if (!Entity::extractEntityId(val, id)) {
warning() << "got malformed wield value";
return;
}
m_wielded = EntityRef(m_view, val.asString());
m_wielded = EntityRef(m_view, id);
}
void Avatar::onTransferRequested(const TransferInfo &transfer)
......
......@@ -210,6 +210,11 @@ protected:
void onEntityAppear(Entity* ent);
void onCharacterChildAdded(Entity* child);
void onCharacterChildRemoved(Entity* child);
/**
* @brief Called when the avatar entity is deleted.
*/
void onAvatarEntityDeleted();
void onCharacterWield(const Atlas::Message::Element&);
void onWieldedChanged();
......
#include <skstream/skstream.h>
#include <skstream/skstream_unix.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -17,6 +18,7 @@
#include <Atlas/Net/Stream.h>
#include <Atlas/Objects/Encoder.h>
#include <Atlas/Objects/objectFactory.h>
#include "CustomEntities.h"
#include <sigc++/slot.h>
......@@ -24,14 +26,13 @@
#include <cassert>
#include <cstdio>
#ifdef __WIN32__
#ifdef _WIN32
#ifndef snprintf
#pragma warning(disable: 4996)
#define snprintf _snprintf
#endif
#endif // __WIN32__
#endif // _WIN32
static const int CONNECT_TIMEOUT = 5 * 1000;
static const int NEGOTIATE_TIMEOUT = 5 * 1000;
......@@ -64,6 +65,10 @@ BaseConnection::BaseConnection(const std::string &cnm,
Atlas::Objects::Operation::UNSEEN_NO = f->addFactory("unseen", &Atlas::Objects::generic_factory);
Atlas::Objects::Operation::ATTACK_NO = f->addFactory("attack", &Atlas::Objects::generic_factory);
}
if (!f->hasFactory("sys"))
{
Atlas::Objects::Entity::SYS_NO = f->addFactory("sys", &Atlas::Objects::factory<Atlas::Objects::Entity::SysData>);
}
}
BaseConnection::~BaseConnection()
......@@ -86,7 +91,10 @@ int BaseConnection::connect(const std::string &host, short port)
// start timeout
_stream = new tcp_socket_stream(host, port, true);
tcp_socket_stream* tcp_stream = new tcp_socket_stream(host, port, true);
_stream = tcp_stream;
_is_ready_func = [tcp_stream](){return tcp_stream->isReady();};
_open_next_func = [tcp_stream](){return tcp_stream->open_next();};
if (_stream->connect_pending()) {
_timeout = new Timeout(CONNECT_TIMEOUT);
......@@ -107,6 +115,47 @@ int BaseConnection::connect(const std::string &host, short port)
return 0;
}
int BaseConnection::connectLocal(const std::string &socket)
{
if (_stream != NULL) {
warning() << "in base connection :: connect, had existing stream, discarding it";
hardDisconnect(true);
}
_host = "local";
_port = 0;
//We can't use a non-blocking socket, so we need to fudge the way it works with negotiation later on.
#ifndef _MSC_VER
unix_socket_stream* socketStream = new unix_socket_stream(socket);
#else
tcp_socket_stream* socketStream = new tcp_socket_stream(socket,6767,false);
#endif
_stream = socketStream;
_is_ready_func = [socketStream](){return socketStream->isReady();};
_open_next_func = [](){return true;};
if (_stream->is_open()) {
//Since "nonblockingConnect()" asserts that a _timeout exists we need to create one here.
_timeout = new Timeout(NEGOTIATE_TIMEOUT);
_timeout->Expired.connect(sigc::mem_fun(this, &BaseConnection::onNegotiateTimeout));
Poll::instance().addStream(_stream, Poll::READ);
nonblockingConnect();
if (_status == NEGOTIATE) {
//We're not using a non-blocking socket, so we'll poll negotiation right here and now.
pollNegotiation();
}
} else {
setStatus(DISCONNECTED);
delete _stream;
_stream = 0;
}
return 0;
}
void BaseConnection::hardDisconnect(bool emit)
{
if (_status == DISCONNECTED) return;
......@@ -181,7 +230,7 @@ void BaseConnection::recv()
}
}
// another paranoid check
// another paranoid check (note that _stream might have been deleted through hardDisconnect())
if (_stream && (err = _stream->getLastError()) != 0) {
char msgBuf[128];
::snprintf(msgBuf, 128, "recv() got stream failure, error %d", _stream->getLastError());
......@@ -193,10 +242,10 @@ void BaseConnection::recv()
void BaseConnection::nonblockingConnect()
{
assert(_stream);
if (!_stream->isReady()) {
if (!_is_ready_func()) {
if (_stream->connect_pending()) {
debug() << "Stream not yet ready";
_stream->open_next();
_open_next_func();
} else {
handleFailure("Failed to connect to " + _host);
hardDisconnect(false);
......
......@@ -7,8 +7,10 @@
#include <sigc++/signal.h>
#include <string>
#include <memory>
#include <functional>
class tcp_socket_stream;
class stream_socket_stream;
namespace Atlas
{
......@@ -37,6 +39,11 @@ public:
the connection could not be opened. */
virtual int connect(const std::string &host, short port);
/**
* Try to connect to a local socket.
*/
virtual int connectLocal(const std::string &socket);
/// possible states for the connection
typedef enum {
INVALID_STATUS = 0, ///< indicates an illegal state
......@@ -123,7 +130,10 @@ protected:
Status _status; ///< current status of the connection
const std::string _id; ///< a unique identifier for this connection
tcp_socket_stream* _stream; ///< the underlying iostream channel
stream_socket_stream* _stream; ///< the underlying iostream channel
std::function<int(void)> _open_next_func; ///< a method for calling "open_next" on the stream, if such functionality is available
std::function<bool(void)> _is_ready_func; ///< a method for calling "is_ready" on the stream, if such functionality is available
std::string _clientName; ///< the client identified used during connection
/** the connection bridge (i.e something implementing objectArrived()) : this can be the derived
......
......@@ -26,8 +26,6 @@
#include <cassert>
#include <algorithm>
#pragma warning(disable: 4068) //unknown pragma