BOOL CCollisionMap::BuildMapData(DWORD AreaIds[], int nSize) { UnitAny* pUnit = D2CLIENT_GetPlayerUnit (); if (m_map.IsCreated()) return TRUE; if(!pUnit) return FALSE; //Get the most left-top level for the base and the size of the entire wanted map Level* pBestLevel = GetLevel(AreaIds[0]); DWORD dwXSize = 0; DWORD dwYSize = 0; m_ptLevelOrigin.x = pBestLevel->dwPosX * 5; m_ptLevelOrigin.y = pBestLevel->dwPosY * 5; dwLevelId = AreaIds[0]; //Loop all the given areas for (int n = 0; n < nSize; n++) { //Get the level struct for given id Level* pLevel = GetLevel(AreaIds[n]); //Make sure we have pLevel if (!pLevel) continue; //Check if this level is even more top-left then the current one if((m_ptLevelOrigin.x / 5) > (int)pLevel->dwPosX) m_ptLevelOrigin.x = pLevel->dwPosX * 5; if((m_ptLevelOrigin.y / 5) > (int)pLevel->dwPosY) m_ptLevelOrigin.y = pLevel->dwPosY * 5; //Add the size of the levels. dwXSize += pLevel->dwSizeX * 5; dwYSize += pLevel->dwSizeY * 5; } if (!m_map.Create(dwXSize, dwYSize, (WORD)MAP_DATA_INVALID)) return FALSE; DwordArray aSkip; for (int n = 0; n < nSize; n++) { Level* pLevel = GetLevel(AreaIds[n]); if (!pLevel) continue; Search(pLevel->pRoom2First, pUnit, aSkip, AreaIds[n]); } FillGaps(); FillGaps(); return TRUE; }
bool FlatTriangleFanTree::FillDepth(const AFlatGeoPoint &origin, ReachFanParms &parms) { if (depth == parms.set_depth) { if (gaps_filled) return true; gaps_filled = true; if (parms.vertex_counter > REACH_MAX_VERTICES) return false; if (parms.fan_counter > REACH_MAX_FANS) return false; FillGaps(origin, parms); } else if (depth < parms.set_depth) { for (auto it = children.begin(), end = children.end(); it != end; ++it) if (!it->FillDepth(origin, parms)) return false; // stop searching } return true; }