📄 waypoint.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Filename : WayPoint.cpp// Written by : excel96// Description : // 浇饭捞绢侩 俺牢 器呕阑 困茄 傀捞器牢飘狼 笼钦阑 包府窍绰 努贰胶 葛碘//////////////////////////////////////////////////////////////////////////////#include "WayPoint.h"#include "Zone.h"#include "ZoneUtil.h"#include "Tile.h"#include "Assert.h"#include "DB.h"//////////////////////////////////////////////////////////////////////////////// class WayPoint member methods//////////////////////////////////////////////////////////////////////////////// constructorWayPoint::WayPoint(){ m_ZoneCoord.id = 0; m_ZoneCoord.x = 0; m_ZoneCoord.y = 0; m_Race = 0;}// destructorWayPoint::~WayPoint(){}// key generatorulonglong WayPoint::getKey(void) const { return getKey(m_ZoneCoord.id, m_ZoneCoord.x, m_ZoneCoord.y);}// static key generatorulonglong WayPoint::getKey(ZoneID_t id, ZoneCoord_t x, ZoneCoord_t y){ ulonglong ID = id; ulonglong X = x; ulonglong Y = y; ulonglong key = (ID << 32) | (X << 16) | Y; return key;}//////////////////////////////////////////////////////////////////////////////// class WaypointManager member methods//////////////////////////////////////////////////////////////////////////////// constructorWayPointManager::WayPointManager(){}// destructorWayPointManager::~WayPointManager(){ WayPointMap::iterator itr = begin(); for (; itr != end(); itr++) { WayPoint* pWayPoint = itr->second; SAFE_DELETE(pWayPoint); } clear();}// load waypoint data from databasevoid WayPointManager::load(void) throw(){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pResult = pStmt->executeQuery("SELECT ZoneID, X, Y, Race FROM WayPointInfo"); while (pResult->next()) { ZoneID_t ZID = pResult->getInt(1); ZoneCoord_t ZX = pResult->getInt(2); ZoneCoord_t ZY = pResult->getInt(3); Race_t Race = pResult->getInt(4); WayPoint* pWayPoint = new WayPoint; Assert(pWayPoint != NULL); pWayPoint->setZoneCoord(ZID, ZX, ZY); pWayPoint->setRace( Race ); addWayPoint(pWayPoint); // 酒快胶磐令 傀捞器牢飘绰 喉钒秦拎具 等促. if ( Race == RACE_OUSTERS ) { Zone* pZone = getZoneByZoneID(ZID); Tile& rTile = pZone->getTile( ZX, ZY ); rTile.setBlocked( Creature::MOVE_MODE_WALKING ); rTile.setBlocked( Creature::MOVE_MODE_BURROWING ); } } SAFE_DELETE(pStmt); } END_DB(pStmt); __END_CATCH}// if there's right waypoint, return true, else return falsebool WayPointManager::isValidWayPoint(ZoneID_t id, ZoneCoord_t x, ZoneCoord_t y, Race_t race) throw(){ __BEGIN_TRY ulonglong key = WayPoint::getKey(id, x, y); WayPointMap::const_iterator itr = find(key); if (itr != end() && itr->second->getRace() == race) return true; return false; __END_CATCH}// add waypoint data into waypoint mapvoid WayPointManager::addWayPoint(WayPoint* pWayPoint) throw(){ __BEGIN_TRY Assert(pWayPoint != NULL); ulonglong key = pWayPoint->getKey(); WayPointMap::const_iterator itr = find(key); if (itr != end()) { cerr << "WayPointManager::addWayPoint() : Duplicated WayPoint" << endl; cerr << "酒付 秋扁尔 措瘤沥飞辉捞尔 谅钎啊 般闷阑瘤档...せせせ.榴~" << endl; throw ("WayPointManager::addWayPoint() : Duplicated WayPoint"); } insert(WayPointMap::value_type(key, pWayPoint)); __END_CATCH}WayPointManager* g_pWayPointManager = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -