📄 zone.cpp.backup
字号:
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); } for (ZoneCoord_t y=0; y<m_Height; y++) { for (ZoneCoord_t x=0; x<m_Width; x++) { BYTE flag = 0; SMP.read(&flag, szBYTE); // 鉴辑措肺 瘤窍, 瘤惑, 傍吝 喉废 if (flag & 0x01) m_pTiles[x][y].setBlocked(Creature::MOVE_MODE_BURROWING); if (flag & 0x02) m_pTiles[x][y].setBlocked(Creature::MOVE_MODE_WALKING); if (flag & 0x04) m_pTiles[x][y].setBlocked(Creature::MOVE_MODE_FLYING); // 酒公巴档 绝绰 版快.. // 各 积己阑 困茄 谅钎沥焊甫 父甸绢敌促. if (flag==0 && m_InnerRect.ptInRect( x, y )) { m_MonsterRegenPositions.push_back( BPOINT( (BYTE)x, (BYTE)y ) ); } // 器呕 沥焊 if (flag & 0x80) { BYTE type; ZoneID_t targetZoneID; BYTE targetX, targetY; SMP.read(&type, szBYTE); if (type == PORTAL_NORMAL) { SMP.read(&targetZoneID, szZoneID); SMP.read(&targetX, szBYTE); SMP.read(&targetY, szBYTE); // 器呕阑 积己秦 霖促. NormalPortal* pNormalPortal = new NormalPortal(); pNormalPortal->setObjectType(PORTAL_NORMAL); pNormalPortal->setZoneID(targetZoneID); pNormalPortal->setX(targetX); pNormalPortal->setY(targetY); getObjectRegistry().registerObject(pNormalPortal); m_pTiles[x][y].addPortal(pNormalPortal); if (bOutput) { cout << "Normal(" << (int)x << "," << (int)y << "," << (int)targetZoneID << "," << (int)targetX << "," << (int)targetY << ")" << endl; } } else if (type == PORTAL_SLAYER) { SMP.read(&targetZoneID, szZoneID); SMP.read(&targetX, szBYTE); SMP.read(&targetY, szBYTE); // 器呕阑 积己秦 霖促. NormalPortal* pNormalPortal = new NormalPortal(); pNormalPortal->setObjectType(PORTAL_SLAYER); pNormalPortal->setZoneID(targetZoneID); pNormalPortal->setX(targetX); pNormalPortal->setY(targetY); getObjectRegistry().registerObject(pNormalPortal); m_pTiles[x][y].addPortal(pNormalPortal); if (bOutput) { cout << "Slayer(" << (int)x << "," << (int)y << "," << (int)targetZoneID << "," << (int)targetX << "," << (int)targetY << ")" << endl; } } else if (type == PORTAL_VAMPIRE) { SMP.read(&targetZoneID, szZoneID); SMP.read(&targetX, szBYTE); SMP.read(&targetY, szBYTE); // 器呕阑 积己秦 霖促. NormalPortal* pNormalPortal = new NormalPortal(); pNormalPortal->setObjectType(PORTAL_VAMPIRE); pNormalPortal->setZoneID(targetZoneID); pNormalPortal->setX(targetX); pNormalPortal->setY(targetY); getObjectRegistry().registerObject(pNormalPortal); m_pTiles[x][y].addPortal(pNormalPortal); if (bOutput) { cout << "Vampire(" << (int)x << "," << (int)y << "," << (int)targetZoneID << "," << (int)targetX << "," << (int)targetY << ")" << endl; } } else if (type == PORTAL_MULTI_TARGET) { BYTE size; SMP.read(&size, szBYTE); // 器呕阑 积己秦 霖促. MultiPortal* pMultiPortal = new MultiPortal(); for(int i = 0; i < size; i++) { SMP.read(&targetZoneID, szZoneID); SMP.read(&targetX, szBYTE); SMP.read(&targetY, szBYTE); pMultiPortal->setObjectType(PORTAL_SLAYER); // 鸥百 牢器甫 备己茄促. PortalTargetInfo* pPortalTargetInfo = new PortalTargetInfo(); pPortalTargetInfo->setZoneID(targetZoneID); pPortalTargetInfo->setX(targetX); pPortalTargetInfo->setY(targetY); pMultiPortal->setPortalTargetInfo(pPortalTargetInfo); } getObjectRegistry().registerObject(pMultiPortal); m_pTiles[x][y].addPortal(pMultiPortal); if (bOutput) { cout << "Multi(" << (int)x << "," << (int)y << "," << (int)targetZoneID << "," << (int)targetX << "," << (int)targetY << ")" << endl; } } else if ( type == PORTAL_GUILD ) { SMP.read(&targetZoneID, szZoneID); SMP.read(&targetX, szBYTE); SMP.read(&targetY, szBYTE); // 器呕阑 积己秦 霖促. GuildPortal* pGuildPortal = new GuildPortal(); pGuildPortal->setObjectType( PORTAL_GUILD ); pGuildPortal->setZoneID( targetZoneID ); pGuildPortal->setX( targetX ); pGuildPortal->setY( targetY ); getObjectRegistry().registerObject(pGuildPortal); m_pTiles[x][y].addPortal(pGuildPortal); if (bOutput) { cout << "Guild(" << (int)x << "," << (int)y << "," << (int)targetZoneID << "," << (int)targetX << "," << (int)targetY << ")" << endl; } } else if ( type == PORTAL_BATTLE ) { SMP.read(&targetZoneID, szZoneID); SMP.read(&targetX, szBYTE); SMP.read(&targetY, szBYTE); // 器呕阑 积己秦 霖促. NormalPortal* pNormalPortal = new NormalPortal(); pNormalPortal->setObjectType(PORTAL_SLAYER); pNormalPortal->setZoneID(targetZoneID); pNormalPortal->setX(targetX); pNormalPortal->setY(targetY); getObjectRegistry().registerObject(pNormalPortal); m_pTiles[x][y].addPortal(pNormalPortal); if (bOutput) { cout << "Slayer(" << (int)x << "," << (int)y << "," << (int)targetZoneID << "," << (int)targetX << "," << (int)targetY << ")" << endl; } } else { } } //if (flag & 0x80) } // for } // for SMP.close(); ///* if (m_MonsterRegenPositions.size()==0) { cout << "MonsterRegenPosition not exist" << endl; cout << "Width = " << m_Width << endl; cout << "Height = " << m_Height << endl; //Assert(m_MonsterRegenPositions.size()!=0); ZoneCoord_t outerMinX = m_Width/7; ZoneCoord_t outerMinY = m_Height/7; ZoneCoord_t outerMaxX = m_Width-outerMinX; ZoneCoord_t outerMaxY = m_Width-outerMinY; for (ZoneCoord_t y=outerMinY; y<outerMaxY; y++) { for (ZoneCoord_t x=outerMinX; x<outerMaxX; x++) { Tile& rTile = m_pTiles[x][y]; if (!rTile.hasPortal() && !rTile.isGroundBlocked() && !rTile.isAirBlocked() && !rTile.isUndergroundBlocked()) { m_MonsterRegenPositions.push_back( BPOINT( (BYTE)x, (BYTE)y ) ); } } } Assert(m_MonsterRegenPositions.size()!=0); } //*/ // Zone 沥焊甫 技泼茄促. m_ZoneType = pZoneInfo->getZoneType(); m_ZoneLevel = pZoneInfo->getZoneLevel(); // 皋葛府 且寸秦林绊... m_ppLevel = new (ZoneLevel_t*) [ m_Width ]; for (uint i = 0; i < m_Width; i++) m_ppLevel[i] = new ZoneLevel_t[m_Height]; // 粮 饭骇阑 叼弃飘 蔼栏肺 檬扁拳矫挪促. for (ZoneCoord_t x = 0; x < m_Width; x++) for (ZoneCoord_t y = 0; y < m_Height; y++) m_ppLevel[x][y] = m_ZoneLevel; // SSI 沥焊 颇老阑 楷促. string SSIFilename = g_pConfig->getProperty("HomePath") + "/data/" + pZoneInfo->getSSIFilename(); ifstream SSI(SSIFilename.c_str(), ios::in | ios::binary | ios::nocreate); if (!SSI) { strcpy( lwrFilename, SSIFilename.c_str()); strlwr( lwrFilename ); SSI.open(lwrFilename, ios::in | ios::binary | ios::nocreate); //cout << "second chk : " << lwrFilename << endl; if (!SSI) { StringStream msg; msg << SSIFilename << " not exist or cannot open it"; throw FileNotExistException(msg.toString()); } } int size = 0; SSI.read(&size, szint); BYTE left, top, right, bottom, level; for (int i=0; i<size; i++) { SSI.read(&level, szBYTE); SSI.read(&left, szBYTE); SSI.read(&top, szBYTE); SSI.read(&right, szBYTE); SSI.read(&bottom, szBYTE); if (bOutput) { cout << "LEVEL:" << (int)level << ",(" << (int)left << "," << (int)top << "," << (int)right << "," << (int)bottom << ")" << endl; } Assert(left <= right); Assert(top <= bottom); for (int bx=left; bx<=right; bx++) for (int by=top; by<=bottom; by++) m_ppLevel[bx][by] = level; } SSI.close(); // 飘府芭靛 器呕阑 肺靛茄促. loadTriggeredPortal(); // 阁胶磐 肺靛窍绊.... m_pMonsterManager->load();//#ifdef __XMAS_EVENT_CODE__ cout << "Begin Event Monster Loading..." << endl; m_pEventMonsterManager->load(); cout << "Event Monster Loading Completed..." << endl;//#endif cout << "Begin Combat Monster Loading..." << endl; m_pCombatMonsterManager->load(); cout << "Combat Monster Loading Completed..." << endl; // 酒捞袍 肺靛茄促. loadItem(); // NPC 甫 肺爹茄促. m_pNPCManager->load(m_ZoneID); // 胶橇扼捞飘 肮荐甫 檬扁拳茄促. initSpriteCount();} catch ( Throwable& t ){ cout << t.toString() << endl; Assert(false);} __END_DEBUG __END_CATCH}// g_pCombatSystemManager甫 烹秦辑 立辟void Zone::ActiveCombatMonster() throw(Error) { m_pCombatMonsterManager->activeMonster();}// g_pCombatSystemManager甫 烹秦辑 立辟void Zone::DeactiveCombatMonster() throw(Error) { m_pCombatMonsterManager->deactiveMonster();}//////////////////////////////////////////////////////////////////////////////// load items from database// * NOTE *// 泅犁 官蹿俊 冻绢柳 酒捞袍篮 辑滚啊 犁矫累登绢档 肺爹窍瘤 臼绰促.//////////////////////////////////////////////////////////////////////////////void Zone::loadItem () throw(Error){ __BEGIN_TRY /* // 酒捞袍 肺爹........... g_pItemLoaderManager->load(this); // 酒捞袍篮 促 朝妨滚啡瘤父...弊贰滴... // 酒捞袍 坷宏璃飘 酒捞叼甫 犁 且寸 罐绊 促矫 历厘茄促. for (int j = 0; j < m_Height; j++) { for (int i = 0; i < m_Width; i++) { if (m_pTiles[i][j].hasItem()) { Item* pItem = m_pTiles[i][j].getItem(); m_ObjectRegistry.registerObject(pItem); pItem->save("", STORAGE_ZONE, m_ZoneID, i, j); addToItemList(pItem); if (pItem->getItemClass() == Item::ITEM_CLASS_MOTORCYCLE) { Motorcycle* pMotorcycle = dynamic_cast<Motorcycle*>(pItem); MotorcycleBox* pMotorcycleBox = new MotorcycleBox(pMotorcycle, this, i, j); g_pParkingCenter->addMotorcycleBox(pMotorcycleBox); } } } } */ __END_CATCH}//////////////////////////////////////////////////////////////////////////////// 泅犁 粮俊 飘府芭靛 器呕阑 肺靛茄促.//////////////////////////////////////////////////////////////////////////////void Zone::loadTriggeredPortal () throw(Error){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pResult = pStmt->executeQuery("SELECT X1, Y1, X2, Y2 FROM ZoneTriggers WHERE ZoneID=%d", m_ZoneID); while (pResult->next()) { int left = pResult->getInt(1); int top = pResult->getInt(2); int right = pResult->getInt(3); int bottom = pResult->getInt(4); Assert(left <= right); Assert(top <= bottom); Assert(m_OuterRect.ptInRect(left, top)); Assert(m_OuterRect.ptInRect(right, bottom)); for (int x=left; x<=right; x++) { for (int y=top; y<=bottom; y++) { if (getTile(x,y).hasPortal()) { //cerr << "loadTriggeredPortal : 捞固 器呕捞 粮犁钦聪促." << endl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -