[1992] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Damian 'Mozork' Frick |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
[2146] | 28 | |
---|
| 29 | /** |
---|
| 30 | @file QuestItem.cc |
---|
| 31 | @brief |
---|
| 32 | Implementation of the QuestItem class. |
---|
| 33 | */ |
---|
[1992] | 34 | |
---|
[2105] | 35 | #include "OrxonoxStableHeaders.h" |
---|
| 36 | #include "QuestItem.h" |
---|
| 37 | |
---|
[1992] | 38 | #include "core/CoreIncludes.h" |
---|
| 39 | |
---|
[2095] | 40 | #include "QuestDescription.h" |
---|
[1992] | 41 | |
---|
| 42 | namespace orxonox { |
---|
[2092] | 43 | |
---|
[2146] | 44 | /** |
---|
| 45 | @brief |
---|
| 46 | Constructor. Registers and initializes the object. |
---|
| 47 | */ |
---|
[2092] | 48 | QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator) |
---|
[2021] | 49 | { |
---|
[2092] | 50 | RegisterObject(QuestItem); |
---|
| 51 | |
---|
[2068] | 52 | this->initialize(); |
---|
[2021] | 53 | } |
---|
[2146] | 54 | |
---|
| 55 | /** |
---|
| 56 | @brief |
---|
| 57 | Initializes the object. |
---|
| 58 | Should be called first in every constructor of this class. |
---|
| 59 | */ |
---|
| 60 | void QuestItem::initialize(void) |
---|
| 61 | { |
---|
| 62 | RegisterObject(QuestItem); |
---|
[2092] | 63 | |
---|
[2146] | 64 | this->id_ = ""; |
---|
| 65 | } |
---|
| 66 | |
---|
[1992] | 67 | /** |
---|
| 68 | @brief |
---|
| 69 | Destructor. |
---|
| 70 | */ |
---|
| 71 | QuestItem::~QuestItem() |
---|
| 72 | { |
---|
[2092] | 73 | |
---|
[1992] | 74 | } |
---|
[2092] | 75 | |
---|
[2146] | 76 | /** |
---|
| 77 | @brief |
---|
| 78 | Method for creating a QuestItem object through XML. |
---|
| 79 | */ |
---|
[2068] | 80 | void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 81 | { |
---|
| 82 | SUPER(QuestItem, XMLPort, xmlelement, mode); |
---|
[2092] | 83 | |
---|
[2068] | 84 | XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode); |
---|
| 85 | XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode); |
---|
| 86 | } |
---|
| 87 | |
---|
[1992] | 88 | /** |
---|
| 89 | @brief |
---|
[2146] | 90 | Sets the id of the QuestItem. |
---|
| 91 | The id must be of GUID form. See 'http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure' for more information. |
---|
| 92 | @param id |
---|
| 93 | The id to be set. |
---|
[1992] | 94 | */ |
---|
[2081] | 95 | void QuestItem::setId(const std::string & id) |
---|
| 96 | { |
---|
[2146] | 97 | if(!isId(id)) //!< Checks whether the id is a valid id. |
---|
[2081] | 98 | { |
---|
| 99 | COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; |
---|
| 100 | return; |
---|
| 101 | } |
---|
[2146] | 102 | |
---|
[2081] | 103 | this->id_ = id; |
---|
| 104 | } |
---|
[2092] | 105 | |
---|
[2068] | 106 | /** |
---|
| 107 | @brief |
---|
| 108 | Checks whether an input id is of the required form. |
---|
| 109 | @param id |
---|
[2093] | 110 | The id to be checked. |
---|
[2068] | 111 | @return |
---|
| 112 | Returns true if the string is likely to be of the required form. |
---|
| 113 | @todo |
---|
| 114 | Clarify form, more vigorous checks. |
---|
| 115 | */ |
---|
| 116 | bool QuestItem::isId(const std::string & id) |
---|
| 117 | { |
---|
| 118 | return id.size() >= 32; |
---|
| 119 | } |
---|
[1992] | 120 | |
---|
| 121 | } |
---|