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

📄 zoneutil.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//////////////////////////////////////////////////////////////////////////////// Filename    : ZoneUtil.cpp// Written by  : excel96// Description : // 粮苞 包访等 漂沥茄 累诀甸阑 荐青窍绰 窃荐甸阑 粮 救俊 持栏聪鳖,// 粮 颇老捞 呈公 目瘤绰 版氢捞 乐绢辑, 粮 颇老 寇何肺 波辰 窃荐甸捞促.//////////////////////////////////////////////////////////////////////////////#include "ZoneUtil.h"#include "Assert.h"#include "DB.h"#include "Properties.h"#include "Item.h"#include "Relic.h"#include "Zone.h"#include "Slayer.h"#include "Vampire.h"#include "Monster.h"#include "Corpse.h"#include "Effect.h"#include "GamePlayer.h"#include "ZoneInfo.h"#include "ZoneInfoManager.h"#include "ZoneGroup.h"#include "ZoneGroupManager.h"#include "ZonePlayerManager.h"#include "IncomingPlayerManager.h"#include "PacketUtil.h"#include "CreatureUtil.h"#include "MonsterManager.h"#include "ResurrectLocationManager.h"#include "EffectObservingEye.h"#include "EffectGnomesWhisper.h"#include "MonsterSummonInfo.h"#include "MasterLairManager.h"#include "VariableManager.h"#include "EventTransport.h"#include "MonsterCorpse.h"#include "RelicUtil.h"#include "ZoneUtil.h"#include "CastleInfoManager.h"#include "TimeManager.h"#include "EffectPrecedence.h"#include "EffectManager.h"#include "StringPool.h"#include "PKZoneInfoManager.h"#include "VisionInfo.h"#include "LevelWarZoneInfoManager.h"#include "EffectDarknessForbidden.h"#include "ctf/FlagManager.h"#include "Gpackets/GCMoveOK.h"#include "Gpackets/GCAddBurrowingCreature.h"#include "Gpackets/GCAddVampireFromTransformation.h"#include "Gpackets/GCAddMonsterFromTransformation.h"#include "Gpackets/GCUntransformOK.h"#include "Gpackets/GCUntransformFail.h"#include "Gpackets/GCAddVampireFromBurrowing.h"#include "Gpackets/GCAddMonsterFromBurrowing.h"#include "Gpackets/GCMineExplosionOK1.h"#include "Gpackets/GCMineExplosionOK2.h"#include "Gpackets/GCAddInstalledMineToZone.h"#include "Gpackets/GCFastMove.h"#include "Gpackets/GCMove.h"#include "Gpackets/GCMoveOK.h"#include "Gpackets/GCMoveError.h"#include "Gpackets/GCAddMonster.h"#include "Gpackets/GCAddNewItemToZone.h"#include "Gpackets/GCDropItemToZone.h"#include "Gpackets/GCAddNPC.h"#include "Gpackets/GCAddSlayer.h"#include "Gpackets/GCAddVampire.h"#include "Gpackets/GCDeleteObject.h"#include "Gpackets/GCSetPosition.h"#include "Gpackets/GCUnburrowOK.h"#include "Gpackets/GCUnburrowFail.h"#include "Gpackets/GCRemoveEffect.h"#include "Gpackets/GCAddEffect.h"#include "Gpackets/GCSystemMessage.h"#include "Gpackets/GCDeleteInventoryItem.h"#include "Gpackets/GCGetOffMotorCycle.h"#include "item/Mine.h"#include "skill/EffectTrapInstalled.h"#include "skill/SummonGroundElemental.h"#include "SkillUtil.h"#include "SkillHandler.h"//#include "skill/EffectRevealer.h"string correctString( const string& str ){    __BEGIN_TRY    string correct = str;    unsigned int i = 0;    unsigned int size = str.size();    while( i < size )    {        if ( correct[i] == '\\' )        {            correct.replace( i, 1, "\\\\" );            i = i + 2;            size++;        }        else if ( correct[i] == '\'' )        {            correct.replace( i, 1, "\\'" );            i = i + 2;            size++;        }        else        {            i++;        }    }    return correct;    __END_CATCH}//////////////////////////////////////////////////////////////////////////////// 漂沥 农府媚甫 歹且 荐 乐绰 困摹甫 茫绰促.// // Zone*       pZone        : 粮俊 措茄 器牢磐// ZoneCoord_t cx           : 歹窍绊磊 窍绰 檬扁 困摹 x// ZoneCoord_t cy           : 歹窍绊磊 窍绰 檬扁 困摹 y// Creature::MoveMode MMode : 农府媚狼 公宏 葛靛//////////////////////////////////////////////////////////////////////////////TPOINT findSuitablePosition(Zone* pZone, ZoneCoord_t cx, ZoneCoord_t cy, Creature::MoveMode MMode) 	throw(){	__BEGIN_TRY	Assert(pZone != NULL);	int    x          = cx;	int    y          = cy;	int    sx         = 1;	int    sy         = 0;	int    maxCount   = 1;	int    count      = 1;	int    checkCount = 300;	TPOINT pt; 	do	{		if (x > 0 && y > 0 && x < pZone->getWidth() && y < pZone->getHeight()) 		{			Tile& rTile = pZone->getTile(x, y);			/*			if (rTile.isBlocked(MMode) == false && rTile.hasPortal() == false)			{				pt.x = x;				pt.y = y;				return pt;			}			*/			if (rTile.isBlocked(MMode) == false && rTile.hasPortal() == false)			{				pt.x = x;				pt.y = y;				return pt;			}			/*			if (rTile.isBlocked(MMode))			{				cout << "[" << checkCount << "] Block : (" << x << ", " << y << ")" << endl;			}			if (rTile.hasPortal())			{				cout << "[" << checkCount << "] Portal : (" << x << ", " << y << ")" << endl;			}			*/		}		x += sx;		y += sy;		if (--count==0)		{			if (sx==0) maxCount++;			int temp = sx;			sx = -sy;			sy = temp;			count = maxCount;		}	} while (--checkCount);	pt.x = -1;	pt.y = -1;	return pt;	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// 漂沥 酒捞袍阑 歹且 荐 乐绰 困摹甫 茫绰促.//// Zone*       pZone          : 粮俊 措茄 器牢磐// ZoneCoord_t cx             : 歹窍绊磊 窍绰 檬扁 困摹 x// ZoneCoord_t cy             : 歹窍绊磊 窍绰 檬扁 困摹 y// bool        bAllowCreature : 农府媚啊 粮犁窍绰 镑档 宝满篮啊?// bool        bAllowSafeZone : Safe Zone 档 宝满篮啊?//////////////////////////////////////////////////////////////////////////////TPOINT findSuitablePositionForItem(Zone* pZone, ZoneCoord_t cx, ZoneCoord_t cy, bool bAllowCreature, bool bAllowSafeZone, bool bForce ) 	throw(){	__BEGIN_TRY	Assert(pZone != NULL);	int    x          = cx;	int    y          = cy;	int    sx         = 1;	int    sy         = 0;	int    maxCount   = 1;	int    count      = 1;	int    checkCount = 300;	TPOINT pt; 	do	{		// 拳搁狼 版拌急俊 酒捞袍捞 甸绢啊绰 巴阑 规瘤窍扁 困窍咯		// 老沥 可悸阑 林绊 冻绢哆副 荐 乐绰瘤 眉农甫 茄促.		if (x > 2 && y > 2 && x < pZone->getWidth()-2 && y < pZone->getHeight()-2) 		{			Tile& rTile = pZone->getTile(x, y);			// GroundBlock捞 酒聪芭唱 (Block捞歹扼档)瘤惑 某腐磐啊 乐绰 版快 by sigi			if ((!rTile.isGroundBlocked() || rTile.hasWalkingCreature())				&& rTile.hasItem() == false && rTile.hasPortal() == false)				{				// Safe 粮俊 冻绢哆府搁 救登绰 酒捞袍牢 版快 眉农				if ( bAllowSafeZone || !(pZone->getZoneLevel( x, y ) & SAFE_ZONE) )				{					pt.x = x;					pt.y = y;					return pt;				}				// 葛磐荤捞努阑 积己且 锭, NPC 关俊 葛磐荤捞努捞 积己登绢辑				// 敲饭捞绢啊 葛磐荤捞努阑 努腐窍瘤 给窍绰 版快啊 乐促.				// 捞 巩力甫 秦搬窍扁 困秦, 鸥老俊 农府媚啊 粮犁窍绰瘤 眉农				// 捞芭电 历芭电 公炼扒 烹苞匙...捞惑茄 内靛匙.. 2003.03.12 by bezz//				if (bAllowCreature == false && rTile.hasCreature() == false)//				{//					pt.x = x;//					pt.y = y;//					return pt;//				}//				else//				{//					pt.x = x;//					pt.y = y;//					return pt;//				}			}			if ( bForce && rTile.hasItem() )			{				Item* pTileItem = rTile.getItem();				if ( pTileItem != NULL )				{					if ( pTileItem->getItemClass()!=Item::ITEM_CLASS_CORPSE )					{						pZone->deleteItem( pTileItem, x, y );						pTileItem->destroy();						SAFE_DELETE(pTileItem);						pt.x = x;						pt.y = y;						return pt;					}				}			}		}		x += sx;		y += sy;		if (--count==0)		{			if (sx==0) maxCount++;			int temp = sx;			sx = -sy;			sy = temp;			count = maxCount;		}	} while (--checkCount);	pt.x = -1;	pt.y = -1;	return pt;	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// 漂沥 捞棋飘甫 歹且 荐 乐绰 困摹甫 茫绰促.//// Zone*       pZone          : 粮俊 措茄 器牢磐// ZoneCoord_t cx             : 歹窍绊磊 窍绰 檬扁 困摹 x// ZoneCoord_t cy             : 歹窍绊磊 窍绰 檬扁 困摹 y// Effect::EffectClass EClass : 歹窍绊磊 窍绰 捞棋飘 努贰胶//////////////////////////////////////////////////////////////////////////////TPOINT findSuitablePositionForEffect(Zone* pZone, ZoneCoord_t cx, ZoneCoord_t cy, Effect::EffectClass EClass) 	throw(){	__BEGIN_TRY	Assert(pZone != NULL);	int    x          = cx;	int    y          = cy;	int    sx         = 1;	int    sy         = 0;	int    maxCount   = 1;	int    count      = 1;	int    checkCount = 300;	TPOINT pt; 	do	{		if (x > 0 && y > 0 && x < pZone->getWidth() && y < pZone->getHeight()) 		{			Tile& rTile = pZone->getTile(x, y);			// 捞棋飘甫 歹且 荐 乐绰 鸥老捞绢具 窍绊, 鞍篮 辆幅狼 捞棋飘 肚茄 绝绢具 茄促.			if (rTile.canAddEffect() && rTile.getEffect(EClass) == NULL)			{				bool bNearTileCheck = true;				// 林困 8鸥老俊 鞍篮 捞棋飘啊 绝绢具 茄促.				for (int i=0; i<8; i++)				{					int tileX = x + dirMoveMask[i].x;					int tileY = y + dirMoveMask[i].y;					if (pZone->getOuterRect()->ptInRect(tileX, tileY))					{						Tile& rTile2 = pZone->getTile(tileX, tileY);						if (rTile2.getEffect(EClass) != NULL)						{							bNearTileCheck = false;							break;						}					}				}				if (bNearTileCheck)				{					pt.x = x;					pt.y = y;					return pt;				}			}		}		x += sx;		y += sy;		if (--count == 0)		{			if (sx == 0) maxCount++;			int temp = sx;			sx = -sy;			sy = temp;			count = maxCount;		}	} while (--checkCount);	pt.x = -1;	pt.y = -1;	return pt;	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// 漂沥 困摹俊辑 瘤沥等 公宏葛靛狼 农府媚甫 眠啊且 荐 乐绰瘤 八荤茄促.//// Zone*              pZone : 粮俊 措茄 器牢磐// ZoneCoord_t        x     : 函脚窍绊磊 窍绰 谅钎 x// ZoneCoord_t        y     : 函脚窍绊磊 窍绰 谅钎 y// Creature::MoveMode MMode : 农府媚狼 公宏 葛靛//////////////////////////////////////////////////////////////////////////////bool canAddCreature(Zone* pZone, ZoneCoord_t x, ZoneCoord_t y, Creature::MoveMode MMode) 	throw(){	__BEGIN_TRY	Assert(pZone != NULL);	if (x > 0 && y > 0 && 		x < pZone->getWidth()-1 && y < pZone->getHeight()-1)	{

⌨️ 快捷键说明

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