[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] Changes to eliot/game/coord.cpp [antoine-1]
From: |
eliot-dev |
Subject: |
[Eliot-dev] Changes to eliot/game/coord.cpp [antoine-1] |
Date: |
Sun, 23 Oct 2005 16:58:46 -0400 |
Index: eliot/game/coord.cpp
diff -u eliot/game/coord.cpp:1.2.2.1 eliot/game/coord.cpp:1.2.2.2
--- eliot/game/coord.cpp:1.2.2.1 Sun Oct 23 17:16:23 2005
+++ eliot/game/coord.cpp Sun Oct 23 20:58:20 2005
@@ -17,8 +17,6 @@
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/* $Id: coord.cpp,v 1.2.2.1 2005/10/23 17:16:23 afrab Exp $ */
-
/**
* \file coord.cpp
* \brief Eliot coordinate system
@@ -33,16 +31,16 @@
Coord::Coord()
{
- m_row = -1;
- m_col = -1;
- m_dir = HORIZONTAL;
+ m_row = -1;
+ m_col = -1;
+ m_dir = HORIZONTAL;
}
-Coord::Coord(std::string str)
+Coord::Coord(const std::string &str)
{
- m_row = -1;
- m_col = -1;
- m_dir = HORIZONTAL;
+ m_row = -1;
+ m_col = -1;
+ m_dir = HORIZONTAL;
set(str);
}
@@ -50,81 +48,72 @@
{
}
-Direction
-Coord::getDir() const
+Coord::Direction Coord::getDir() const
{
return m_dir;
}
-int
-Coord::getRow() const
+int Coord::getRow() const
{
return m_row;
}
-int
-Coord::getCol() const
+int Coord::getCol() const
{
return m_col;
}
-void
-Coord::setRow(int iRow)
+void Coord::setRow(int iRow)
{
m_row = iRow;
}
-
-void
-Coord::setCol(int iCol)
+
+void Coord::setCol(int iCol)
{
m_col = iCol;
}
-void
-Coord::setDir(Direction iDir)
+void Coord::setDir(Direction iDir)
{
m_dir = iDir;
}
-void
-Coord::operator=(const Coord &iOther)
+void Coord::operator=(const Coord &iOther)
{
m_dir = iOther.m_dir;
m_row = iOther.m_row;
m_col = iOther.m_col;
}
-void
-Coord::set(std::string str)
+void Coord::set(const std::string &str)
{
char l[4];
- int col,row;
+ int col;
if (sscanf(str.c_str(), "%1[a-oA-O]%2d", l, &col) == 2)
- {
- setDir(HORIZONTAL);
- }
+ {
+ setDir(HORIZONTAL);
+ }
else if (sscanf(str.c_str(), "%2d%1[a-oA-O]", &col, l) == 2)
- {
- setDir(VERTICAL);
- }
+ {
+ setDir(VERTICAL);
+ }
else
- {
- col = 1;
- l[0] = 'A';
- }
- row = toupper(*l) - 'A' + 1;
+ {
+ col = 1;
+ l[0] = 'A';
+ }
+ int row = toupper(*l) - 'A' + 1;
setCol(col);
setRow(row);
}
-std::string
-Coord::toString() const
+std::string Coord::toString() const
{
- std::string rs("");
+ std::string rs = "";
if (m_row == -1 || m_col == -1)
- return rs;
+ return rs;
if (getDir() == HORIZONTAL)
{
@@ -142,7 +131,7 @@
return rs;
}
-
+
/// Local Variables:
/// mode: hs-minor
/// c-basic-offset: 4