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
52 * The -1 is to correct from the +1 from below
54 int x
= m_exit
->getValue(db::TableImpls::Get()->EXITS
->X
)->getIntegerValue()-1;
55 int y
= m_exit
->getValue(db::TableImpls::Get()->EXITS
->Y
)->getIntegerValue()-1;
56 int z
= m_exit
->getValue(db::TableImpls::Get()->EXITS
->Z
)->getIntegerValue()-1;
58 Coordinate
result(x
, y
, z
);
62 void Exit::setFromChunk(value_type room
)
65 ValuePtr
value(new FieldValue(db::TableImpls::Get()->EXITS
->FKCHUNKSFROM
, room
));
66 m_exit
->setValue(value
);
69 void Exit::setToChunk(value_type room
)
72 ValuePtr
value(new FieldValue(db::TableImpls::Get()->EXITS
->FKCHUNKSTO
, room
));
73 m_exit
->setValue(value
);
76 void Exit::setDirection(const Coordinate
& direction
)
78 Assert(direction
.isDirection());
84 * The +1 is to keep negative values from going into the database.
86 value
= FieldValuePtr(new FieldValue(db::TableImpls::Get()->EXITS
->X
, direction
.getXCoordinate()+1));
87 m_exit
->setValue(value
);
89 value
= FieldValuePtr(new FieldValue(db::TableImpls::Get()->EXITS
->Y
, direction
.getYCoordinate()+1));
90 m_exit
->setValue(value
);
92 value
= FieldValuePtr(new FieldValue(db::TableImpls::Get()->EXITS
->Z
, direction
.getZCoordinate()+1));
93 m_exit
->setValue(value
);
116 return m_exit
->exists();
119 SavableManagerPtr
Exit::getManager() const
124 TableImplPtr
Exit::getTable() const
126 return m_exit
->getTable();