📄 zone.cpp
字号:
pPacket->setEffectID( pEffect->getSendEffectClass() ); pPacket->setDuration(65000); if (pPackets==NULL) pPackets = new list<Packet*>; pPackets->push_back( pPacket ); } pPackets = getRelicEffectPacket( pMonsterCorpse, Effect::EFFECT_CLASS_SLAYER_REGEN_ZONE, pPackets );// pPackets = getRelicEffectPacket( pMonsterCorpse, Effect::EFFECT_CLASS_VAMPIRE_REGEN_ZONE, pPackets );// pPackets = getRelicEffectPacket( pMonsterCorpse, Effect::EFFECT_CLASS_OUSTERS_REGEN_ZONE, pPackets );// pPackets = getRelicEffectPacket( pMonsterCorpse, Effect::EFFECT_CLASS_DEFAULT_REGEN_ZONE, pPackets ); pPackets = getRelicEffectPacket( pMonsterCorpse, Effect::EFFECT_CLASS_SLAYER_TRYING_1, pPackets ); pPackets = getRelicEffectPacket( pMonsterCorpse, Effect::EFFECT_CLASS_VAMPIRE_TRYING_1, pPackets ); pPackets = getRelicEffectPacket( pMonsterCorpse, Effect::EFFECT_CLASS_OUSTERS_TRYING_1, pPackets ); return pPackets;}//////////////////////////////////////////////////////////////////////////////// sendRelicEffect( MonsterCorpse* )//////////////////////////////////////////////////////////////////////////////// pMonsterCorpse俊 嘿篮 Effect甫 pPlayer俊霸 焊辰促.//////////////////////////////////////////////////////////////////////////////voidsendRelicEffect( MonsterCorpse* pMonsterCorpse, Player* pPlayer ){ list<Packet*>* pPackets = createRelicEffect( pMonsterCorpse ); if (pPackets!=NULL) { list<Packet*>::iterator itr = pPackets->begin(); for (; itr!=pPackets->end(); itr++) { Packet* pPacket = *itr; pPlayer->sendPacket( pPacket ); SAFE_DELETE(pPacket); } SAFE_DELETE(pPackets); }}//////////////////////////////////////////////////////////////////////////////// sendRelicEffect( MonsterCorpse* )//////////////////////////////////////////////////////////////////////////////// pMonsterCorpse俊 嘿篮 Effect甫 (x,y)俊 谎赴促.//////////////////////////////////////////////////////////////////////////////voidsendRelicEffect( MonsterCorpse* pMonsterCorpse, Zone* pZone, ZoneCoord_t x, ZoneCoord_t y){ list<Packet*>* pPackets = createRelicEffect( pMonsterCorpse ); if (pPackets!=NULL) { list<Packet*>::iterator itr = pPackets->begin(); for (; itr!=pPackets->end(); itr++) { Packet* pPacket = *itr; pZone->broadcastPacket(x, y, pPacket); SAFE_DELETE(pPacket); } SAFE_DELETE(pPackets); }}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////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_pMasterLairManager = NULL; m_pWarScheduler = NULL; m_pLevelWarManager = NULL;// m_pEventMonsterManager = new EventMonsterManager(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; m_bPayPlay = false; m_bPremiumZone = false; m_bPKZone = false; m_bNoPortalZone = false; m_bMasterLair = false; m_bCastle = false; m_bHolyLand = false; m_bHasRelicTable = false; getCurrentTime( m_LoadValueStartTime ); m_LoadValue = 0; m_bTimeStop = false; getCurrentTime( m_UpdateTimebandTime );#ifdef __USE_ENCRYPTER__ int serverID = g_pConfig->getPropertyInt( "ServerID" ); //m_EncryptCode = (uchar)( ( ( m_ZoneID >> 8 ) ^ m_ZoneID ) ^ ( ( serverID + 1 ) << 4 ) ); m_EncryptCode = EncryptCode( m_ZoneID, serverID );#endif}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Zone::Zone(ZoneID_t zoneID, ZoneCoord_t width, ZoneCoord_t height) throw (){ __BEGIN_TRY Assert(false); /* m_Mutex.setName("Zone"); m_MutexEffect.setName("ZoneEffect"); m_ZoneID = zoneID; m_pZoneGroup = NULL; m_Width = width; m_Height = height; getCurrentTime( m_LoadValueStartTime ); 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_pMasterLairManager = NULL; m_pWarScheduler = NULL; m_pEventMonsterManager = new EventMonsterManager(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_pMasterLairManager); SAFE_DELETE(m_pWarScheduler);// SAFE_DELETE(m_pEventMonsterManager); 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( this ); 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_CASTLE: case ZONE_RANDOM_MAP: m_DarkLevel = 0; m_LightLevel = 14; break; default: pDIInfo = g_pDarkLightInfoManager->getCurrentDarkLightInfo( this ); m_DarkLevel = pDIInfo->getDarkLevel(); m_LightLevel = pDIInfo->getLightLevel(); break; } switch ( m_ZoneID ) { case 1131: case 1132: case 1133: case 1134: { m_pLevelWarManager = new LevelWarManager( m_ZoneID-1130, this ); m_pLevelWarManager->init(); break; } default: break; } __END_CATCH}//////////////////////////////////////////////////////////////////////////////// 粮 颇老俊辑 粮 沥焊甫 佬绢辑 肺爹茄促.//////////////////////////////////////////////////////////////////////////////void Zone::load(bool bOutput) throw(Error){ __BEGIN_TRY __BEGIN_DEBUGtry { DWORD versionLen; WORD zoneID; WORD zoneGroupID; DWORD zonenameLen; BYTE zoneType; BYTE zoneLevel; DWORD descLen; char* pDesc = NULL; char* version = new char [128]; char* zonename = new char [128]; char* lwrFilename = new char[256]; ZoneInfo* pZoneInfo = g_pZoneInfoManager->getZoneInfo(m_ZoneID); Assert(pZoneInfo!=NULL); setPayPlay( pZoneInfo->isPayPlay() ); setPremiumZone( pZoneInfo->isPremiumZone() ); setPKZone( pZoneInfo->isPKZone() ); setNoPortalZone( pZoneInfo->isNoPortalZone() ); setMasterLair( pZoneInfo->isMasterLair() ); setHolyLand( pZoneInfo->isHolyLand() ); // Holy Land 老 版快 HolyLandManager 俊 眠啊 if ( isHolyLand() ) { g_pHolyLandManager->addHolyLand( this ); } if (g_pCastleInfoManager->getCastleInfo(m_ZoneID)!=NULL) { setCastle( true ); } else { setCastle( false ); } //filelog("zoneInfo.txt", "[%d] %d %d", (int)m_ZoneID, (int)isPayPlay(), (int)isPremiumZone()); // 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.c_str() << 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++) { m_pTiles[i] = new Tile [m_Height]; } // 冀磐甫 2瞒盔 硅凯肺 父甸绢 皋葛府甫 且寸茄促. m_SectorWidth = (int)ceil((float)m_Width/(float)SECTOR_SIZE); m_SectorHeight = (int)ceil((float)m_Height/(float)SECTOR_SIZE); m_pSectors = new (Sector*)[m_SectorWidth]; for (int x=0; x<m_SectorWidth; x++) { m_pSectors[x] = new Sector[m_SectorHeight]; } // 阿阿狼 鸥老俊促啊 冀磐 器牢磐甫 技泼茄促. for (int x=0; x<m_Width; x++) { for (int y=0; y<m_Height; y++) { int sx = x/SECTOR_SIZE; int sy = y/SECTOR_SIZE; Assert(sx < m_SectorWidth && sy < m_SectorHeight); m_pTiles[x][y].setSector(&m_pSectors[sx][sy]); } } // 冀磐尝府 楷搬阑 茄促. VSRect srect(0, 0, m_SectorWidth-1, m_SectorHeight-1); for (int x=0; x<m_SectorWidth; x++) { for (int y=0; y<m_SectorHeight; y++) { for (uint d=0; d<9; d++) { int sectorx = x + dirMoveMask[d].x; int sectory = y + dirMoveMask[d].y; if (srect.ptInRect(sectorx, sectory)) { m_pSectors[x][y].setNearbySector(d, &m_pSectors[sectorx][sectory]); } } } } // MonsterAI甫 困秦 粮狼 康开阑 备盒瘤绢初篮 荤阿屈阑 积己茄促. m_OuterRect.set(0, 0, m_Width-1, m_Height-1); if (m_Width > 64 && m_Height > 64) { m_InnerRect.set(15, 15, m_Width-15, m_Height-15); m_CoreRect.set(25, 25, m_Width-25, m_Height-25); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -