![]() |
Area Class ReferenceDatabase table Area.
More...
|
Public Member Functions | |
Area (Database &, long num) | |
Area (Database &, const std::string &name) | |
~Area () | |
bool | Exists () |
Check if the object already exists in database. | |
void | Save () |
Save the object in database. | |
int | GetWidth () |
int | GetHeight () |
long | GetNum () |
Get integer primary key from object. | |
void | SetWidth (int) |
void | SetHeight (int) |
void | SetName (const std::string &name) |
const std::string & | GetName () |
void | VerifyTerrain () |
void | GetAreaBorders (int ch_z, int &xmin, int &xmax, int &ymin, int &ymax) |
Static Public Member Functions | |
static db::Area * | GetArea (Database &, long num) |
static db::Area * | GetArea (Database &, const std::string &name) |
Private Attributes | |
db::Area * | m_area |
Static Private Attributes | |
static areas_t | m_areas |
Definition at line 34 of file Area.h.
Area::Area | ( | Database & | , | |
long | num | |||
) |
Definition at line 33 of file Area.cpp.
References Exists(), GetArea(), m_area, and VerifyTerrain().
00033 : Object(db) 00034 { 00035 m_area = Area::GetArea(db, num); 00036 if (Exists()) 00037 { 00038 VerifyTerrain(); 00039 } 00040 }
Area::Area | ( | Database & | , | |
const std::string & | name | |||
) |
Definition at line 43 of file Area.cpp.
References Exists(), GetArea(), m_area, and VerifyTerrain().
00043 : Object(db) 00044 { 00045 m_area = Area::GetArea(db, name); 00046 if (Exists()) 00047 { 00048 VerifyTerrain(); 00049 } 00050 }
bool Area::Exists | ( | ) | [virtual] |
Check if the object already exists in database.
Implements Object.
Definition at line 59 of file Area.cpp.
References m_area.
Referenced by Area(), Go::Execute(), and Create::OnLine().
void Area::Save | ( | ) | [virtual] |
Save the object in database.
Implements Object.
Definition at line 67 of file Area.cpp.
References m_area, and VerifyTerrain().
Referenced by Create::OnLine().
00068 { 00069 m_area -> save(); 00070 VerifyTerrain(); 00071 }
int Area::GetWidth | ( | ) |
Definition at line 74 of file Area.cpp.
References m_area.
Referenced by Chunk::Edge(), Chunk::Fill(), Chunk::Get(), Player::GetCoordX(), Look::getmap(), Chunk::Init(), Create::OnLine(), Chunk::Set(), and Player::VerifyPos().
00075 { 00076 return m_area -> width; 00077 }
int Area::GetHeight | ( | ) |
Definition at line 80 of file Area.cpp.
References m_area.
Referenced by Chunk::Edge(), Chunk::Fill(), Player::GetCoordY(), Look::getmap(), Chunk::Init(), Create::OnLine(), and Player::VerifyPos().
00081 { 00082 return m_area -> height; 00083 }
long Area::GetNum | ( | ) | [virtual] |
Get integer primary key from object.
Implements Object.
Definition at line 86 of file Area.cpp.
References m_area.
Referenced by Chunk::AddPortal(), Go::Execute(), Chunk::GetChunk(), Steps::GetStep(), Steps::GetSteps(), Terrain::GetTerrain(), Chunk::Init(), Chunk::RemoveObject(), Terrain::Terrain(), and Player::VerifyPos().
00087 { 00088 return m_area -> num; 00089 }
void Area::SetWidth | ( | int | ) |
Definition at line 92 of file Area.cpp.
References m_area.
Referenced by Create::OnLine().
00093 { 00094 m_area -> width = w; 00095 }
void Area::SetHeight | ( | int | ) |
Definition at line 98 of file Area.cpp.
References m_area.
Referenced by Create::OnLine().
00099 { 00100 m_area -> height = h; 00101 }
void Area::SetName | ( | const std::string & | name | ) |
const std::string & Area::GetName | ( | ) |
void Area::VerifyTerrain | ( | ) |
Definition at line 116 of file Area.cpp.
References Terrain::Exists(), Object::m_db, Terrain::Save(), Terrain::SetColor(), and Terrain::SetName().
Referenced by Area(), Create::OnLine(), and Save().
00117 { 00118 { 00119 Terrain t(m_db, *this, 'P'); 00120 if (!t.Exists()) 00121 { 00122 t.SetColor("&m"); 00123 t.SetName("Portal"); 00124 t.Save(); 00125 } 00126 } 00127 { 00128 Terrain t(m_db, *this, 'U'); 00129 if (!t.Exists()) 00130 { 00131 t.SetColor("&m"); 00132 t.SetName("Stairs up"); 00133 t.Save(); 00134 } 00135 } 00136 { 00137 Terrain t(m_db, *this, 'D'); 00138 if (!t.Exists()) 00139 { 00140 t.SetColor("&m"); 00141 t.SetName("Stairs down"); 00142 t.Save(); 00143 } 00144 } 00145 }
db::Area * Area::GetArea | ( | Database & | , | |
long | num | |||
) | [static] |
Definition at line 148 of file Area.cpp.
References m_areas.
Referenced by Area().
00149 { 00150 for (areas_t::iterator it = m_areas.begin(); it != m_areas.end(); it++) 00151 { 00152 db::Area *p = *it; 00153 if (p -> num == num) 00154 return p; 00155 } 00156 db::Area *p = new db::Area(db, num); 00157 m_areas.push_back(p); 00158 return p; 00159 }
db::Area * Area::GetArea | ( | Database & | , | |
const std::string & | name | |||
) | [static] |
Definition at line 162 of file Area.cpp.
References m_areas.
00163 { 00164 for (areas_t::iterator it = m_areas.begin(); it != m_areas.end(); it++) 00165 { 00166 db::Area *p = *it; 00167 if (p -> name == name) 00168 return p; 00169 } 00170 db::Area *p = new db::Area(db, name); 00171 p -> name = name; 00172 m_areas.push_back(p); 00173 return p; 00174 }
void Area::GetAreaBorders | ( | int | ch_z, | |
int & | xmin, | |||
int & | xmax, | |||
int & | ymin, | |||
int & | ymax | |||
) |
Definition at line 177 of file Area.cpp.
References m_area, and Object::m_db.
00178 { 00179 xmin = ymin = 1000000; 00180 xmax = ymax = 0; 00181 Query q(m_db); 00182 q.get_result("select * from chunk where area=" + Utility::l2string(m_area -> num) + 00183 " and z=" + Utility::l2string(ch_z) ); 00184 while (q.fetch_row()) 00185 { 00186 db::Chunk chunk(&m_db, &q); 00187 xmin = MIN(xmin, chunk.x); 00188 xmax = MAX(xmax, chunk.x); 00189 ymin = MIN(ymin, chunk.y); 00190 ymax = MAX(ymax, chunk.y); 00191 } 00192 q.free_result(); 00193 }
db::Area* Area::m_area [private] |
Definition at line 60 of file Area.h.
Referenced by Area(), Exists(), GetAreaBorders(), GetHeight(), GetName(), GetNum(), GetWidth(), Save(), SetHeight(), SetName(), and SetWidth().
areas_t Area::m_areas [static, private] |