📄 zone.cpp.backup
字号:
//////////////////////////////////////////////////////////////////////////////// FileName : Zone.cpp// WrittenBy :// Description ://////////////////////////////////////////////////////////////////////////////#include "Zone.h"#include <stdio.h>#include <string.h>#include "Assert.h"#include "LogClient.h"#include "ZoneGroup.h"#include "ZoneInfo.h"#include "ZoneInfoManager.h"#include "PCManager.h"#include "NPCManager.h"#include "MonsterManager.h"#include "EventMonsterManager.h"#include "CombatMonsterManager.h"#include "EffectManager.h"#include "EffectSchedule.h"#include "NPCInfo.h"#include "WeatherManager.h"#include "Creature.h"#include "Item.h"#include "ItemInfo.h"#include "DarkLightInfo.h"#include "DB.h"#include "Slayer.h"#include "Vampire.h"#include "Monster.h"#include "NPC.h"#include "Player.h"#include "Properties.h"#include "ZoneUtil.h"#include "PacketUtil.h"#include "Party.h"#include "TradeManager.h"#include "ParkingCenter.h"#include <fstream>#include <math.h>#include "EffectDarkness.h"#include "EffectVampirePortal.h"#include "SlayerCorpse.h"#include "VampireCorpse.h"#include "MonsterCorpse.h"#include "EffectDecayCorpse.h"#include "EffectDecayItem.h"//#include "EffectRevealer.h"#include "EffectDecayMotorcycle.h"#include "EffectCallMotorcycle.h"#include "EffectAddItem.h"#include "EffectDeleteItem.h"#include "EffectTransportItem.h"#include "EffectSanctuary.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/GCAddWolf.h"#include "Gpackets/GCAddBat.h"#include "Gpackets/GCAddSlayerCorpse.h"#include "Gpackets/GCAddVampireCorpse.h"#include "Gpackets/GCAddMonsterCorpse.h"#include "Gpackets/GCAddEffectToTile.h"#include "Gpackets/GCAddVampirePortal.h"#include "Gpackets/GCDeleteEffectFromTile.h"#include "Gpackets/GCMineExplosionOK1.h"#include "Gpackets/GCMineExplosionOK2.h"#include "Gpackets/GCAddInstalledMineToZone.h"#include "Gpackets/GCModifyInformation.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/GCKnockBack.h"#include "item/VampirePortalItem.h"#include "Profile.h"//#define __PROFILE_MOVEPCBROADCAST__int g_FastMoveSearchX[8][4] ={ { 0, 1, 1, 1 }, // LEFT { 0, 1, 0, 1 }, // LEFTDOWN { 0, 0, -1, 1 }, // DOWN { 0, -1, 0, -1 }, // RIGHTDOWN { 0, -1, -1, -1 }, // RIGHT { 0, -1, 0, -1 }, // RIGHTUP { 0, 0, -1, 1 }, // UP { 0, 1, 0, 1 }, // LEFTUP};int g_FastMoveSearchY[8][4] ={ { 0, 0, -1, 1 }, // LEFT { 0, -1, -1, 0 }, // LEFTDOWN { 0, -1, -1, -1 }, // DOWN { 0, -1, -1, 0 }, // RIGHTDOWN { 0, 0, -1, 1 }, // RIGHT { 0, 1, 1, 0 }, // RIGHTUP { 0, 1, 1, 1 }, // UP { 0, 1, 1, 0 }, // LEFTUP};voidstrlwr(char* str){ while (*str!='\0') { *str = tolower( *str ); str ++; }}//////////////////////////////////////////////////////////////////////////////// 老馆利牢 阁胶磐甸捞 利栏肺 牢侥窍蠢衬 付蠢衬 窍绰 窃荐//////////////////////////////////////////////////////////////////////////////bool isPotentialEnemy(Monster* pMonster, Creature* pCreature){ Assert(pCreature != NULL); // 泅犁肺辑绰 浇饭捞绢绰 公炼扒 利捞促. if (pCreature->isSlayer()) return true; if (pCreature->isVampire()) { Vampire* pVampire = dynamic_cast<Vampire*>(pCreature); // 阁胶磐狼 饭骇捞 轨颇捞绢狼 饭骇焊促 10饭骇 捞惑 臭阑 版快, // 利栏肺 牢侥茄促. if ((pVampire->getLevel() + 10) <= pMonster->getLevel()) { return true; } // 10饭骇 捞惑牢 轨颇捞绢绰 利捞促. if (pVampire->getLevel() > 10) { return true; } } return false;}//////////////////////////////////////////////////////////////////////////////// STL find_if 舅绊府硫阑 捞侩窍扁 困茄 厚背 努贰胶//////////////////////////////////////////////////////////////////////////////class isSameCreature {public: isSameCreature(Creature* pCreature) : m_Creature(pCreature) {} bool operator () (Creature* pCreature) throw () { return pCreature->getName() == m_Creature->getName(); } private : Creature* m_Creature;};////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Zone::Zone(ZoneID_t zoneID) throw (){ m_Mutex.setName("Zone"); m_MutexEffect.setName("ZoneEffect"); m_ZoneID = zoneID; m_pZoneGroup = NULL; m_Width = 0; m_Height = 0; m_pTiles = NULL; m_NPCCount = 0; m_MonsterCount = 0; m_pPCManager = new PCManager(); m_pNPCManager = new NPCManager(); m_pMonsterManager = new MonsterManager(this); m_pEventMonsterManager = new EventMonsterManager(this); m_pCombatMonsterManager = new CombatMonsterManager(this); // 辫版籍 m_pWeatherManager = new WeatherManager(this); m_pEffectManager = new EffectManager(); m_pLockedEffectManager = new EffectManager(); m_pVampirePortalManager = new EffectManager(); m_pEffectScheduleManager = new EffectScheduleManager(); m_pLocalPartyManager = new LocalPartyManager(); m_pPartyInviteInfoManager = new PartyInviteInfoManager(); m_pTradeManager = new TradeManager;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Zone::Zone(ZoneID_t zoneID, ZoneCoord_t width, ZoneCoord_t height) throw (){ __BEGIN_TRY m_Mutex.setName("Zone"); m_MutexEffect.setName("ZoneEffect"); m_ZoneID = zoneID; m_pZoneGroup = NULL; m_Width = width; m_Height = height; m_pTiles = NULL; Assert(m_ZoneID > 0); m_pTiles = new Tile* [ m_Width ]; for (uint i = 0 ; i < m_Width ; i++) m_pTiles[i] = new Tile [m_Height]; m_ppLevel = new (ZoneLevel_t*)[ m_Width ]; for (uint i = 0; i < m_Width ; i++) m_ppLevel[i] = new ZoneLevel_t[m_Height]; m_pPCManager = new PCManager(); m_pNPCManager = new NPCManager(); m_pMonsterManager = new MonsterManager(this); m_pEventMonsterManager = new EventMonsterManager(this); m_pCombatMonsterManager = new CombatMonsterManager(this); // 辫版籍 m_pWeatherManager = new WeatherManager(this); m_pEffectManager = new EffectManager(); m_pLockedEffectManager = new EffectManager(); m_pVampirePortalManager = new EffectManager(); m_pEffectScheduleManager = new EffectScheduleManager(); m_pLocalPartyManager = new LocalPartyManager(); m_pPartyInviteInfoManager = new PartyInviteInfoManager(); m_pTradeManager = new TradeManager; __END_CATCH}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Zone::~Zone () throw (){ __BEGIN_TRY if (m_pTiles != NULL) { for (uint i=0 ; i<m_Width; i++) SAFE_DELETE_ARRAY(m_pTiles[i]); SAFE_DELETE_ARRAY(m_pTiles); } if (m_ppLevel != NULL) { for (uint i=0; i<m_Width; i++) SAFE_DELETE_ARRAY(m_ppLevel[i]); SAFE_DELETE_ARRAY(m_ppLevel); } if (m_pSectors != NULL) { for (int i=0; i<m_SectorWidth; i++) SAFE_DELETE_ARRAY(m_pSectors[i]); SAFE_DELETE_ARRAY(m_pSectors); } SAFE_DELETE(m_pPCManager); SAFE_DELETE(m_pNPCManager); SAFE_DELETE(m_pMonsterManager); SAFE_DELETE(m_pEventMonsterManager); SAFE_DELETE(m_pCombatMonsterManager); // 辫版籍 SAFE_DELETE(m_pWeatherManager); SAFE_DELETE(m_pEffectManager); SAFE_DELETE(m_pLockedEffectManager); SAFE_DELETE(m_pVampirePortalManager); SAFE_DELETE(m_pEffectScheduleManager); SAFE_DELETE(m_pLocalPartyManager); SAFE_DELETE(m_pPartyInviteInfoManager); __END_CATCH}//////////////////////////////////////////////////////////////////////////////// initialize zone//////////////////////////////////////////////////////////////////////////////void Zone::init () throw(Error){ __BEGIN_TRY load(); m_pWeatherManager->init(); DarkLightInfo* pDIInfo = NULL; switch (m_ZoneType) { case ZONE_NORMAL_FIELD: pDIInfo = g_pDarkLightInfoManager->getCurrentDarkLightInfo(); m_DarkLevel = pDIInfo->getDarkLevel(); m_LightLevel = pDIInfo->getLightLevel(); break; case ZONE_NORMAL_DUNGEON: case ZONE_PC_VAMPIRE_LAIR: case ZONE_NPC_VAMPIRE_LAIR: m_DarkLevel = 15; m_LightLevel = 6; break; case ZONE_SLAYER_GUILD: case ZONE_RESERVED_SLAYER_GUILD: case ZONE_NPC_HOME: case ZONE_NPC_SHOP: case ZONE_RANDOM_MAP: m_DarkLevel = 0; m_LightLevel = 14; break; default: pDIInfo = g_pDarkLightInfoManager->getCurrentDarkLightInfo(); m_DarkLevel = pDIInfo->getDarkLevel(); m_LightLevel = pDIInfo->getLightLevel(); break; } __END_CATCH}//////////////////////////////////////////////////////////////////////////////// 粮 颇老俊辑 粮 沥焊甫 佬绢辑 肺爹茄促.//////////////////////////////////////////////////////////////////////////////void Zone::load(bool bOutput) throw(Error){ __BEGIN_TRY __BEGIN_DEBUGtry { DWORD versionLen; char version[128]; WORD zoneID; WORD zoneGroupID; DWORD zonenameLen; char zonename[128]; BYTE zoneType; BYTE zoneLevel; DWORD descLen; char* pDesc = NULL; char lwrFilename[256]; ZoneInfo* pZoneInfo = g_pZoneInfoManager->getZoneInfo(m_ZoneID); // SMP 沥焊 颇老阑 楷促. string SMPFilename = g_pConfig->getProperty("HomePath") + "/data/" + pZoneInfo->getSMPFilename(); ifstream SMP(SMPFilename.c_str(), ios::in | ios::binary | ios::nocreate); if (!SMP) { strcpy( lwrFilename, SMPFilename.c_str()); strlwr( lwrFilename ); SMP.open(lwrFilename, ios::in | ios::binary | ios::nocreate); //cout << "second chk : " << lwrFilename << endl; if (!SMP) { StringStream msg; msg << SMPFilename << " not exist or cannot open it"; cerr << msg.toString() << endl; throw FileNotExistException(msg.toString()); } } // read zone version SMP.read(&versionLen,szDWORD); SMP.read(version,versionLen); version[versionLen] = 0; // read zone id SMP.read(&zoneID,szWORD); // read zone group id (no use) SMP.read(&zoneGroupID,szWORD); // read zone name SMP.read(&zonenameLen,szDWORD); if (zonenameLen > 0) { SMP.read(zonename,zonenameLen); zonename[zonenameLen] = 0; } // read zone type & level SMP.read(&zoneType,szBYTE); SMP.read(&zoneLevel,szBYTE); // read zone description SMP.read(&descLen,szDWORD); if (descLen > 0) { pDesc = new char[descLen+1]; SMP.read(pDesc,descLen); pDesc[descLen] = 0; SAFE_DELETE_ARRAY(pDesc); // add '_ARRAY' moved to here.. by sigi 2002.5.2 } // read zone width & height SMP.read(&m_Width, szWORD); SMP.read(&m_Height ,szWORD); Assert(m_Width <= maxZoneWidth); Assert(m_Height <= maxZoneHeight); // 鸥老阑 2瞒盔硅凯肺 父甸绢 皋葛府甫 且寸茄促. m_pTiles = new Tile* [ m_Width ]; for (uint i = 0 ; i < m_Width ; i++) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -