1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #include "FieldImpls.h"
24 #include "TableImpls.h"
28 Exit::Exit(SavableManagerPtr exit
) :
39 value_type
Exit::getFromChunk() const
41 return m_exit
->getValue(db::TableImpls::Get()->EXITS
->FKCHUNKSFROM
)->getIntegerValue();
44 value_type
Exit::getToChunk() const
46 return m_exit
->getValue(db::TableImpls::Get()->EXITS
->FKCHUNKSTO
)->getIntegerValue();
49 Coordinate
Exit::getDirection() const
51 int x
= m_exit
->getValue(db::TableImpls::Get()->EXITS
->X
)->getIntegerValue();
52 int y
= m_exit
->getValue(db::TableImpls::Get()->EXITS
->Y
)->getIntegerValue();
53 int z
= m_exit
->getValue(db::TableImpls::Get()->EXITS
->Z
)->getIntegerValue();
55 Coordinate
result(x
, y
, z
);
59 void Exit::setFromChunk(value_type room
)
62 ValuePtr
value(new FieldValue(db::TableImpls::Get()->EXITS
->FKCHUNKSFROM
, room
));
63 m_exit
->setValue(value
);
66 void Exit::setToChunk(value_type room
)
69 ValuePtr
value(new FieldValue(db::TableImpls::Get()->EXITS
->FKCHUNKSTO
, room
));
70 m_exit
->setValue(value
);
73 void Exit::setDirection(const Coordinate
& direction
)
75 Assert(direction
.isDirection());
80 value
= FieldValuePtr(new FieldValue(db::TableImpls::Get()->EXITS
->X
, direction
.getXCoordinate()));
81 m_exit
->setValue(value
);
83 value
= FieldValuePtr(new FieldValue(db::TableImpls::Get()->EXITS
->Y
, direction
.getYCoordinate()));
84 m_exit
->setValue(value
);
86 value
= FieldValuePtr(new FieldValue(db::TableImpls::Get()->EXITS
->Z
, direction
.getZCoordinate()));
87 m_exit
->setValue(value
);
110 return m_exit
->exists();
113 SavableManagerPtr
Exit::getManager() const
118 TableImplPtr
Exit::getTable() const
120 return m_exit
->getTable();