⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parkingcenter.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////////////// Filename    : ParkingCenter.cpp// Written By  : Reiot// Description ://////////////////////////////////////////////////////////////////////////////#include "ParkingCenter.h"#include "Gpackets/GCDeleteObject.h"//////////////////////////////////////////////////////////////////////////////// class MotorcycleBox member methods//////////////////////////////////////////////////////////////////////////////MotorcycleBox::MotorcycleBox(Motorcycle* pMotorcycle, Zone* pZone, ZoneCoord_t X, ZoneCoord_t Y)	throw(){	__BEGIN_TRY	m_pMotorcycle = pMotorcycle;	m_pZone       = pZone;	m_X           = X;	m_Y           = Y;	m_bTransport  = false;	__END_CATCH}MotorcycleBox::~MotorcycleBox()	throw(){	__BEGIN_TRY	if (m_pMotorcycle != NULL) 	{		// m_pZone狼 悼扁拳 巩力肺 牢秦辑 荐沥沁促.		// by sigi. 2002.5.3		m_pZone->deleteMotorcycle(m_X, m_Y, m_pMotorcycle);		/*		Tile & tile = m_pZone->getTile(m_X, m_Y);		if (tile.hasItem()) 		{			m_pZone->deleteItem(m_pMotorcycle, m_X, m_Y);		} 		else 		{			//cerr << "弊 鸥老浚 坷配官捞啊 绝嚼聪促." << endl;		}		GCDeleteObject gcDeleteObject;		gcDeleteObject.setObjectID(m_pMotorcycle->getObjectID());		m_pZone->broadcastPacket(m_X, m_Y, &gcDeleteObject);		SAFE_DELETE(m_pMotorcycle);		*/	}	m_pZone = NULL;	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// class ParkingCenter member methods//////////////////////////////////////////////////////////////////////////////ParkingCenter::ParkingCenter()	throw(){	__BEGIN_TRY	m_Mutex.setName("ParkingCenter");	m_MutexRemove.setName("ParkingCenterRemove");	__END_CATCH}ParkingCenter::~ParkingCenter()	throw(){	__BEGIN_TRY	__ENTER_CRITICAL_SECTION(m_Mutex)	hash_map< ItemID_t , MotorcycleBox* >::iterator itr = m_Motorcycles.begin();	for (; itr != m_Motorcycles.end(); itr++)	{		MotorcycleBox* pBox = itr->second;		SAFE_DELETE(pBox);	}	m_Motorcycles.clear();	__LEAVE_CRITICAL_SECTION(m_Mutex)	__END_CATCH}void ParkingCenter::addMotorcycleBox (MotorcycleBox* pMotorcycleBox) 	throw (DuplicatedException , Error){	__BEGIN_TRY	__ENTER_CRITICAL_SECTION(m_Mutex)	Assert(pMotorcycleBox != NULL);	hash_map< ItemID_t , MotorcycleBox* >::iterator itr = m_Motorcycles.find(pMotorcycleBox->getItemID());	if (itr != m_Motorcycles.end())	{		throw DuplicatedException();	}	m_Motorcycles[ pMotorcycleBox->getItemID() ] = pMotorcycleBox;	__LEAVE_CRITICAL_SECTION(m_Mutex)	__END_CATCH}// hash_map俊辑 凯艰狼 TargetID俊 秦寸窍绰 坷配官捞甫 瘤快绰 窃荐捞促.// 咯扁辑 坷配官捞 傈眉甫 昏力窍霸 凳栏肺 粮俊辑 坷配官捞甫 瘤款促澜.// 弥辆利栏肺 捞 窃荐甫 阂矾具 且 巴捞促.void ParkingCenter::deleteMotorcycleBox (ItemID_t keyTargetID) 	throw (NoSuchElementException , Error){	__BEGIN_TRY	MotorcycleBox* pMotorcycleBox = NULL;	__ENTER_CRITICAL_SECTION(m_Mutex)	hash_map< ItemID_t , MotorcycleBox* >::iterator itr = m_Motorcycles.find(keyTargetID);	if (itr == m_Motorcycles.end())	{		//cerr << "ParkingCenter::deleteMotorcycleBox() : NoSuchElementException" << endl;		//throw NoSuchElementException();		m_Mutex.unlock();		return;	}	pMotorcycleBox = itr->second;	m_Motorcycles.erase(itr);	// 单靛遏 巩力肺 官肺 瘤快瘤 臼绰促.	//SAFE_DELETE(pMotorcycleBox);	__LEAVE_CRITICAL_SECTION(m_Mutex)	// 唱吝俊 heartbeat俊辑 瘤况霖促.	if (pMotorcycleBox!=NULL)	{		__ENTER_CRITICAL_SECTION(m_MutexRemove)		m_RemoveMotorcycles.push_back( pMotorcycleBox );		__LEAVE_CRITICAL_SECTION(m_MutexRemove)	}	__END_CATCH}// 漂沥 KeyID甫 啊柳 MotorcycleBox啊 乐绰瘤 犬牢茄促.bool ParkingCenter::hasMotorcycleBox (ItemID_t keyTargetID) 	throw (NoSuchElementException , Error){	__BEGIN_TRY	bool hasMotor = true;	__ENTER_CRITICAL_SECTION(m_Mutex)	hash_map< ItemID_t , MotorcycleBox* >::iterator itr = m_Motorcycles.find(keyTargetID);	if (itr == m_Motorcycles.end())	{		hasMotor = false;	}	__LEAVE_CRITICAL_SECTION(m_Mutex)	return hasMotor;	__END_CATCH}// 凯艰狼 TargetID肺 坷配官捞甫 茫酒辑 Return 秦林绰 窃荐捞促.MotorcycleBox* ParkingCenter::getMotorcycleBox (ItemID_t keyTargetID) const 	throw (NoSuchElementException , Error){	__BEGIN_TRY		MotorcycleBox* pTempBox = NULL;	try 	{		__ENTER_CRITICAL_SECTION(m_Mutex)		hash_map< ItemID_t , MotorcycleBox* >::const_iterator itr = m_Motorcycles.find(keyTargetID);		if (itr == m_Motorcycles.end())		{			//cerr << "ParkingCenter::getMotorcycleBox() : NoSuchElementException" << endl;			//throw NoSuchElementException();			m_Mutex.unlock();			return NULL;		}		pTempBox = itr->second;		__LEAVE_CRITICAL_SECTION(m_Mutex)		return pTempBox;	} 	catch (Throwable & t) 	{		//cerr << "酒流 茫瘤 臼疽芭唱, 凯艰啊 肋给等 坷配官捞 涝聪寸." << endl;		return NULL;	}	__END_CATCH}// 捞扒  ClientManager thread俊辑 倒酒埃促.void ParkingCenter::heartbeat()	throw (Error){	__BEGIN_TRY	__ENTER_CRITICAL_SECTION(m_MutexRemove)	list<MotorcycleBox*>::iterator itr = m_RemoveMotorcycles.begin();		for (; itr!=m_RemoveMotorcycles.end(); itr++)	{		MotorcycleBox* pMotorcycleBox = *itr;		SAFE_DELETE( pMotorcycleBox );	}	m_RemoveMotorcycles.clear();	__LEAVE_CRITICAL_SECTION(m_MutexRemove)	__END_CATCH}// global variable definitionParkingCenter* g_pParkingCenter = NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -