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

📄 zone.cpp.backup

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 BACKUP
📖 第 1 页 / 共 5 页
字号:
						//cerr << "ZONEID:" << m_ZoneID << ",X:" << x << "Y:" << y << endl;						getTile(x,y).deletePortal();					}					// 器呕阑 积己窍绊, 殿废茄促.					TriggeredPortal* pPortal = new TriggeredPortal();					getObjectRegistry().registerObject(pPortal);					// 器呕 郴侩阑 肺靛茄促.					pPortal->setObjectType(PORTAL_NORMAL);					pPortal->load(m_ZoneID, left, top, right, bottom);										// 鸥老俊促 器呕阑 嘿牢促.					getTile(x, y).addPortal(pPortal);				}			}		}		SAFE_DELETE(pStmt);	}	END_DB(pStmt);	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// 捞 粮俊辑 唱鸥唱绰 NPC客 阁胶磐狼 胶橇扼捞飘肮荐甫 拌魂秦敌促.//////////////////////////////////////////////////////////////////////////////void Zone::initSpriteCount () 	throw(Error){	__BEGIN_TRY	m_NPCCount = 0;	m_MonsterCount = 0;	// NPC 胶橇扼捞飘 鸥涝狼 肮荐甫 拌魂茄促.	hash_map<ObjectID_t, Creature*> NPCMap = m_pNPCManager->getCreatures();	for (hash_map<ObjectID_t, Creature*>::const_iterator i = NPCMap.begin(); i != NPCMap.end(); i++)	{		NPC* pNPC = dynamic_cast<NPC*>(i->second);		bool bAdd = true;				for (int j=0; j<m_NPCCount; j++) // 泅犁 乐绰 阁胶磐 鸥涝 吝俊辑 		{			if (pNPC->getSpriteType() == m_NPCTypes[j])			{				bAdd = false;				break;			}		}		if (bAdd)		{			m_NPCTypes[m_NPCCount] = pNPC->getSpriteType();			m_NPCCount++;		}	}	// 阁胶磐 胶橇扼捞飘 鸥涝狼 肮荐甫 拌魂茄促.	hash_map<SpriteType_t, MonsterCounter*> MONSTER = m_pMonsterManager->getMonsters();	for (hash_map<SpriteType_t, MonsterCounter*>::const_iterator i = MONSTER.begin(); i != MONSTER.end(); i++)	{		Assert ( m_MonsterCount < maxMonsterPerZone );	// by sigi		m_MonsterTypes[m_MonsterCount] = i->first;		m_MonsterCount++;	}	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// 鸥老俊 瘤沥等 粮 饭骇阑 府畔茄促.//////////////////////////////////////////////////////////////////////////////ZoneLevel_t Zone::getZoneLevel(ZoneCoord_t x, ZoneCoord_t y) const 	throw(OutOfBoundException){	__BEGIN_TRY	Assert(x < m_Width && y < m_Height);	return m_ppLevel[x][y];	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// getTile//////////////////////////////////////////////////////////////////////////////const Tile & Zone::getTile(ZoneCoord_t x, ZoneCoord_t y) const     throw(OutOfBoundException){	__BEGIN_TRY	Assert(x < m_Width && y < m_Height);	return m_pTiles[x][y];		__END_CATCH}Tile & Zone::getTile(ZoneCoord_t x, ZoneCoord_t y)     throw(OutOfBoundException){	__BEGIN_TRY	Assert(x < m_Width && y < m_Height);	return m_pTiles[x][y];		__END_CATCH}//////////////////////////////////////////////////////////////////////////////// getSector//////////////////////////////////////////////////////////////////////////////Sector* Zone::getSector(ZoneCoord_t x, ZoneCoord_t y)     throw(OutOfBoundException){	__BEGIN_TRY	Assert(x < m_Width && y < m_Height);	int sx = x/SECTOR_SIZE;	int sy = y/SECTOR_SIZE;	Assert(sx < m_SectorWidth && y < m_SectorHeight);	return &(m_pSectors[sx][sy]);	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// 扁夯利栏肺 Zone 狼 贸府绰 mutex 甫 荤侩窍瘤 臼绰促.// 恐衬窍搁, ZoneGroupThread狼 窜老 贸府甫 罐扁 锭巩捞促. 弊繁单, 货肺 粮俊 // PC甫 眠啊窍绰 巴篮 IPM俊辑 捞风绢瘤霸 登骨肺, 捞繁 楷蜡肺 mutex 糕滚甫// 眠啊秦具 窍哥, 酒贰 皋家靛俊 locking 阑 吧绢拎具 茄促.//////////////////////////////////////////////////////////////////////////////void Zone::pushPC(Creature* pCreature)	throw(Error){	__BEGIN_TRY 	Assert(pCreature != NULL);	__ENTER_CRITICAL_SECTION(m_Mutex)	m_PCListQueue.push_back(pCreature);	//m_PCQueue.push(pCreature);		__LEAVE_CRITICAL_SECTION(m_Mutex)	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// P(cx,cy)俊 乐绰 PC甫 dir 规氢栏肺 捞悼矫难 Q(nx,ny)肺 颗变促.// 弊府绊唱辑, 林函狼 PC甸俊霸 捞悼 沥焊甫 宏肺靛某胶飘茄促. //// *CAUTION*// PC啊 酒囱 农府贸(NPC,Monster)狼 捞悼篮 moveCreature甫 荤侩茄促.//////////////////////////////////////////////////////////////////////////////void Zone::movePC(Creature* pCreature, ZoneCoord_t cx, ZoneCoord_t cy, Dir_t dir)	throw(ProtocolException, Error){	__BEGIN_TRY	Assert(pCreature->isPC());	Player* pPlayer = pCreature->getPlayer();	Assert(pPlayer != NULL);	if (dir >= DIR_MAX || !isAbleToMove(pCreature))	{		GCMoveError 	gcMoveError(pCreature->getX(), pCreature->getY());		pPlayer->sendPacket(&gcMoveError);		return;	}	const int threshold = 6;	////////////////////////////////////////////////////////////	// 老窜 农府贸啊 痢橇甫 窍妨绰 扒瘤甫 眉农茄促.	// 父距 距埃 痢橇沁阑 版快, GCMoveError 菩哦阑 傈价茄促.	// 	// OX, OY : 敲饭捞绢狼 泅犁 谅钎	// CX, CY : 鸥百 谅钎	//	// max(0, OX - threshold) <= CX <= min(OX + threshold, ZONEWIDTH-1)	// max(0, OY - threshold) <= CY <= min(OY + threshold, ZONEHEIGHT-1)	// 甫 父练秦具 沥惑利牢 捞悼捞促.	////////////////////////////////////////////////////////////	if (pCreature->getX() != cx || pCreature->getY() != cy) 	{		if (cx >= max(0           , pCreature->getX() - threshold) && 			cx <= min(m_Width - 1 , pCreature->getX() + threshold) && 			cy >= max(0           , pCreature->getY() - threshold) && 			cy <= min(m_Height - 1, pCreature->getY() + threshold)) 		{			// 倾侩啊瓷茄 坷瞒 裹困郴俊辑狼 痢橇绰 弊成 公矫秦霖促.			/*// 林籍贸府 by sigi - 救 焊郴绰霸 嘎绰 淀.. 			GCMoveError gcMoveError;			gcMoveError.setX(cx);			gcMoveError.setY(cy);			pCreature->getPlayer()->sendPacket(&gcMoveError);			*/			return;		} 		else 		{			// 倾侩啊瓷茄 坷瞒 裹困甫 逞绢汲 版快 立加阑 瞒窜茄促.			//StringStream msg;			//msg << pCreature->getName() << " try to jump from (" 			//	<< (int)pCreature->getX() << "," << (int)pCreature->getY()			//	<< ") to (" << (int)cx << "," << (int)cy << ")";			GCMoveError 	gcMoveError(cx, cy); 			pPlayer->sendPacket(&gcMoveError);			return;		}	}	// 促澜 谅钎甫 拌魂茄促.	int nx = cx;	int ny = cy;	//////////////////////////////////////////////////////////////////////////////	// *CAUTION*	// 版拌瘤痢俊辑 版拌狼 寇胞栏肺 框流捞绰 菩哦捞 朝酒客辑绰 救等促.	// ex> (0,10)俊辑 LEFT 捞悼篮 朝酒棵 荐 绝促. (10,0)俊辑 UP 捞悼档 付蛮啊瘤捞促.	//////////////////////////////////////////////////////////////////////////////	nx = nx + dirMoveMask[dir].x;	ny = ny + dirMoveMask[dir].y;	VSRect rect(0, 0, m_Width-1, m_Height-1);	if (!rect.ptInRect(nx, ny)) throw InvalidProtocolException("invalid coordination");	////////////////////////////////////////////////////////////	// 捞悼且 镑捞 block 登绢乐促搁, GCMoveError 甫 傈价茄促.	// (PC客 鞍篮 困摹啊 block 登绢具 茄促.)	////////////////////////////////////////////////////////////	Tile& newTile = m_pTiles[nx][ny];	if (newTile.isBlocked(pCreature->getMoveMode())		// Sanctuary 捞棋飘啊 吧妨乐促搁 给 埃促.        || newTile.hasEffect() && newTile.getEffect(Effect::EFFECT_CLASS_SANCTUARY))	{		GCMoveError 	gcMoveError(cx, cy); 		pPlayer->sendPacket(&gcMoveError);	} 	else	{ 		// 快急 农府贸狼 谅钎甫 函版茄促.		pCreature->setXYDir(nx, ny, dir);		try 		{			// 捞傈 鸥老俊辑 农府贸甫 昏力茄促.			m_pTiles[cx][cy].deleteCreature(pCreature->getObjectID());				// 货 鸥老俊 农府贸甫 眠啊茄促.			if (!newTile.addCreature(pCreature))			{				// Portal阑 activate 矫挪 版快捞促. by sigi. 2002.5.6				return;			}			try {				checkMine(this, pCreature, nx, ny);			} catch ( Throwable & t ) {				filelog("CheckMineBug.txt", "%s : %s", "movePC", t.toString().c_str());			}			// 努扼捞攫飘俊霸 GCMoveOK 甫 傈价且锭, (nx,ny)绰 档馒 谅钎咯具 窍哥,			// dir 篮 官扼焊绰(捞悼且) 规氢捞绢具 茄促. 弊巴捞 泅犁狼 沥氓!			GCMoveOK gcMoveOK(nx,ny,dir);			pPlayer->sendPacket(&gcMoveOK);				// 磊悼栏肺 GCMove/GCAddSlayer/GCAddVampire 菩哦阑 宏肺靛某胶飘茄促.			#ifdef __PROFILE_MOVEPCBROADCAST__				beginProfileEx("Zone::movePCBroadcast");				movePCBroadcast(pCreature, cx, cy, nx, ny);				endProfileEx("Zone::movePCBroadcast");			#else				movePCBroadcast(pCreature, cx, cy, nx, ny);			#endif		} 		catch (NoSuchElementException & nsee) 		{			throw Error("捞傈 鸥老俊 农府贸啊 粮犁窍瘤 臼嚼聪促.");		} 		catch (DuplicatedException & de) 		{			throw Error("货 鸥老俊 农府贸啊 捞固 粮犁钦聪促.");		} 		catch (PortalException&) 		{		}		catch (Error& e)		{			filelog("assertTile.txt", "Zone::movePC : %s", e.toString().c_str());			throw;		}	}	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// PC啊 酒囱 农府贸(NPC,Monster)甫 框流老 锭 捞 皋家靛甫 荤侩茄促.//// *CAUTION*//// 捞锭, (nx,ny,dir)篮 农府贸啊 档崔且 促澜 谅钎客 官扼焊绰 规氢阑 唱鸥辰促.// 弊府绊, 捞 谅钎俊 酒公 巴档 绝促绰 八刘捞 刚历 捞风绢廉具 茄促. (辨茫扁 风凭)//////////////////////////////////////////////////////////////////////////////void Zone::moveCreature(Creature* pCreature, ZoneCoord_t nx, ZoneCoord_t ny, Dir_t dir)	throw(ProtocolException, Error){	__BEGIN_TRY	ZoneCoord_t cx = pCreature->getX();	ZoneCoord_t cy = pCreature->getY();	// 捞傈 鸥老俊辑 农府贸甫 昏力窍绊, 促澜 鸥老俊 农府贸甫 眠啊茄促. 	try 	{		// 捞傈 鸥老俊辑 农府贸甫 昏力茄促.		m_pTiles[cx][cy].deleteCreature(pCreature->getObjectID());		// 档馒 鸥老俊 农府贸甫 眠啊茄促.		m_pTiles[nx][ny].addCreature(pCreature);		try {			checkMine(this, pCreature, nx, ny);		} catch ( Throwable & t ) {			filelog("CheckMineBug.txt", "%s : %s", "moveCreature", t.toString().c_str());		}	} 	catch (NoSuchElementException & nsee) 	{		throw Error("捞傈 鸥老俊 农府贸啊 粮犁窍瘤 臼嚼聪促.");	}	catch (DuplicatedException & de) 	{		throw Error("货 鸥老俊 农府贸啊 捞固 粮犁钦聪促.");	}	catch (Error& e)	{		filelog("assertTile.txt", "Zone::moveCreature : %s", e.toString().c_str());		throw;	}// 农府贸狼 谅钎客 规氢阑 汲沥茄促.pCreature->setXYDir(nx, ny, dir);	// 舅酒辑 GCMove 尔 GCAddMonster/GCAddNPC 甫 宏肺靛某胶飘茄促.	moveCreatureBroadcast(pCreature, cx, cy, nx, ny);	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// add PC//// PC 甫 粮俊 弥檬肺 眠啊茄促. PC 林函狼 促弗 PC甸俊霸 货 农府贸狼 免泅阑 舅妨林绊,// 林函阑 胶牡秦辑 按眉甸狼 沥焊甫 罐酒柯促.//////////////////////////////////////////////////////////////////////////////void Zone::addPC(Creature* pCreature, ZoneCoord_t cx, ZoneCoord_t cy, Dir_t dir)	throw(EmptyTileNotExistException, Error){	__BEGIN_TRY	__BEGIN_DEBUG	Assert(pCreature != NULL);	Assert(pCreature->isPC());	TPOINT pt = findSuitablePosition(this, cx, cy, pCreature->getMoveMode());	if (pt.x != -1) 	{ 		// 瘤沥等 谅钎甫 努扼捞攫飘肺 傈价茄促.		GCSetPosition gcSetPosition;		gcSetPosition.setX(pt.x);		gcSetPosition.setY(pt.y);		gcSetPosition.setDir(dir);			pCreature->getPlayer()->sendPacket(&gcSetPosition);		// 农府贸狼 谅钎客 规氢阑 瘤沥茄促.		pCreature->setXYDir(pt.x, pt.y, dir);		// 利例茄 舘老阑 茫疽栏搁, 农府贸甫 角力肺 		// PC概聪历客 鸥老俊 阿阿 笼绢持绰促.		m_pTiles[pt.x][pt.y].addCreature(pCreature);		//checkMine(this, pCreature, pt.x, pt.y);	// 咯扁辑档 mine阑 气惯矫难具 窍唱..?			m_pPCManager->addCreature(pCreature);			if (pCreature->isSlayer()) 		{			((Slayer*)pCreature)->sendRealWearingInfo();			((Slayer*)pCreature)->sendSlayerSkillInfo();		} 		else 		{			((Vampire*)pCreature)->sendRealWearingInfo();			((Vampire*)pCreature)->sendVampireSkillInfo();		}		GCModifyInformation gcModifyInformation;		if (pCreature->isSlayer())		{			Slayer* pNewSlayer = dynamic_cast<Slayer*>(pCreature);			Assert(pNewSlayer != NULL);			Player* pPlayer = pNewSlayer->getPlayer();			Assert(pPlayer != NULL);			gcModifyInformation.addShortData(MODIFY_DEFENSE,    pNewSlayer->getDefense());			gcModifyInformation.addShortData(MODIFY_PROTECTION, pNewSlayer->getProtection());			gcModifyInformation.addShortData(MODIFY_TOHIT,      pNewSlayer->getToHit());			gcModifyInformation.addShortData(MODIFY_MIN_DAMAGE, pNewSlayer->getDamage(ATTR_CURRENT));			gcModifyInformation.addShortData(MODIFY_MAX_DAMAGE, pNewSlayer->getDamage(ATTR_MAX));			pPlayer->sendPacket(&gcModifyInformation);		}		else if (pCreature->isVampire())		{			Vampire* pNewVampire = dynamic_cast<Vampire*>(pCreature);			Assert(pNewVampire != NULL);			Player* pPlayer = pNewVampire->getPlayer();			Assert(pPlayer != NULL);			gcModifyInformation.addShortData(MODIFY_DEFENSE,    pNewVampire->getDefense());			gcModifyInformation.addShortData(MODIFY_PROTECTION, pNewVampire->getProtection());			gcModifyInformation.addShortData(MODIFY_TOHIT,      pNewVampire->getToHit());			gcModifyInformation.addShortData(MODIFY_MIN_DAMAGE, pNewVampire->getDamage(ATTR_CURRENT));			gcModifyInformation.addShortData(MODIFY_MAX_DAMAGE, pNewVampire->getDamage(ATTR_MAX));			pPlayer->sendPacket(&gcModifyInformation);		}

⌨️ 快捷键说明

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