2010-07-21 03:17:28 +05:30
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2001 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-04-20 23:24:16 +01:00
|
|
|
#ifndef SERVER_TELEPORT_STATE_H
|
|
|
|
|
#define SERVER_TELEPORT_STATE_H
|
2010-07-20 02:37:46 +05:30
|
|
|
|
2014-02-03 22:00:46 +01:00
|
|
|
#include <boost/date_time.hpp>
|
2014-01-31 22:00:32 +01:00
|
|
|
#include <string>
|
2010-08-20 14:35:28 +05:30
|
|
|
|
2010-07-20 02:37:46 +05:30
|
|
|
class TeleportState
|
|
|
|
|
{
|
2010-08-15 04:01:38 +05:30
|
|
|
protected:
|
|
|
|
|
/// \brief Specifies the possess key generated for this specific teleport
|
2010-07-28 19:32:14 +05:30
|
|
|
std::string m_possessKey;
|
2010-08-15 04:01:38 +05:30
|
|
|
enum {
|
|
|
|
|
TELEPORT_NONE, /// \brief Initial state
|
|
|
|
|
TELEPORT_REQUESTED, /// \brief Teleport has been requested
|
|
|
|
|
TELEPORT_CREATED /// \brief Teleport has succeeded
|
|
|
|
|
} m_state;
|
2010-07-20 02:37:46 +05:30
|
|
|
|
2014-02-03 22:00:46 +01:00
|
|
|
boost::posix_time::ptime m_teleportTime; /// \brief The time the teleport took place
|
2010-08-20 14:35:28 +05:30
|
|
|
|
2010-08-15 04:01:38 +05:30
|
|
|
public:
|
2014-02-03 22:00:46 +01:00
|
|
|
TeleportState(boost::posix_time::ptime time);
|
2010-07-20 02:37:46 +05:30
|
|
|
|
|
|
|
|
void setRequested();
|
|
|
|
|
void setCreated();
|
2010-11-25 00:43:25 +00:00
|
|
|
void setKey(const std::string & key);
|
2010-07-20 02:37:46 +05:30
|
|
|
|
2010-11-25 14:22:37 +00:00
|
|
|
bool isCreated() const;
|
|
|
|
|
bool isRequested() const;
|
2010-07-28 19:32:14 +05:30
|
|
|
|
2010-11-25 14:22:37 +00:00
|
|
|
bool isMind() const;
|
|
|
|
|
const std::string & getPossessKey() const;
|
2010-08-20 14:35:28 +05:30
|
|
|
|
2014-02-03 22:00:46 +01:00
|
|
|
boost::posix_time::ptime getCreateTime() const;
|
2010-07-20 02:37:46 +05:30
|
|
|
};
|
|
|
|
|
|
2010-11-25 14:24:17 +00:00
|
|
|
/// \brief Check if the teleported entity has been create on the remote end
|
|
|
|
|
///
|
|
|
|
|
/// @return Boolean whether entity has been created or not
|
|
|
|
|
inline bool TeleportState::isCreated() const
|
|
|
|
|
{
|
|
|
|
|
return (m_state == TELEPORT_CREATED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// \brief Check if the teleport state is 'currently requesting'
|
|
|
|
|
///
|
|
|
|
|
/// @return Whether the state is requesting or not
|
|
|
|
|
inline bool TeleportState::isRequested() const
|
|
|
|
|
{
|
|
|
|
|
return (m_state == TELEPORT_REQUESTED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// \brief Check if a teleported entity has an external mind
|
|
|
|
|
///
|
|
|
|
|
/// @return Whether the teleported entity has an external mind
|
|
|
|
|
inline bool TeleportState::isMind() const
|
|
|
|
|
{
|
2010-11-25 14:28:47 +00:00
|
|
|
return !m_possessKey.empty();
|
2010-11-25 14:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// \brief Get the possess key generated for this teleport
|
|
|
|
|
///
|
|
|
|
|
/// @return The randomly generated possess key for this teleport
|
|
|
|
|
inline const std::string & TeleportState::getPossessKey() const
|
|
|
|
|
{
|
|
|
|
|
return m_possessKey;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-03 22:00:46 +01:00
|
|
|
inline boost::posix_time::ptime TeleportState::getCreateTime() const
|
2010-11-25 14:24:17 +00:00
|
|
|
{
|
|
|
|
|
return m_teleportTime;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-20 23:24:16 +01:00
|
|
|
#endif // SERVER_TELEPORT_STATE_H
|