//-------------------------------------------------------------------------------- void CHL7Message::TraceDump() { if(! GetIO()->IsDisplayed(IOMASK_9)) return; for(int i = 0; i < GetSegmentCount(); i++) GetIO()->Output(IOMASK_9|IOMASK_CONST, (CString) *GetSegment(i)); }
/** * Return length of path from start to finish */ float CNavPath::GetLength( void ) const { float length = 0.0f; for( int i=1; i<GetSegmentCount(); ++i ) { length += (m_path[i].pos - m_path[i-1].pos).Length(); } return length; }
/** * Return the node index closest to the given distance along the path without going over - returns (-1) if error */ int CNavPath::GetSegmentIndexAlongPath( float distAlong ) const { if (!IsValid()) return -1; if (distAlong <= 0.0f) { return 0; } float lengthSoFar = 0.0f; Vector dir; for( int i=1; i<GetSegmentCount(); ++i ) { lengthSoFar += (m_path[i].pos - m_path[i-1].pos).Length(); if (lengthSoFar > distAlong) { return i-1; } } return GetSegmentCount()-1; }
/** * Return point a given distance along the path - if distance is out of path bounds, point is clamped to start/end * @todo Be careful of returning "positions" along one-way drops, ladders, etc. */ bool CNavPath::GetPointAlongPath( float distAlong, Vector *pointOnPath ) const { if (!IsValid() || pointOnPath == NULL) return false; if (distAlong <= 0.0f) { *pointOnPath = m_path[0].pos; return true; } float lengthSoFar = 0.0f; float segmentLength; Vector dir; for( int i=1; i<GetSegmentCount(); ++i ) { dir = m_path[i].pos - m_path[i-1].pos; segmentLength = dir.Length(); if (segmentLength + lengthSoFar >= distAlong) { // desired point is on this segment of the path float delta = distAlong - lengthSoFar; float t = delta / segmentLength; *pointOnPath = m_path[i].pos + t * dir; return true; } lengthSoFar += segmentLength; } *pointOnPath = m_path[ GetSegmentCount()-1 ].pos; return true; }
HRESULT DacHeapWalker::InitHeapDataSvr(HeapData *&pHeaps, size_t &pCount) { // Scrape basic heap details int heaps = *g_gcDacGlobals->n_heaps; pCount = heaps; pHeaps = new (nothrow) HeapData[heaps]; if (pHeaps == NULL) return E_OUTOFMEMORY; for (int i = 0; i < heaps; ++i) { // Basic heap info. DPTR(dac_gc_heap) heap = HeapTableIndex(g_gcDacGlobals->g_heaps, i); dac_generation gen0 = *ServerGenerationTableIndex(heap, 0); dac_generation gen1 = *ServerGenerationTableIndex(heap, 1); dac_generation gen2 = *ServerGenerationTableIndex(heap, 2); dac_generation loh = *ServerGenerationTableIndex(heap, 3); pHeaps[i].YoungestGenPtr = (CORDB_ADDRESS)gen0.allocation_context.alloc_ptr; pHeaps[i].YoungestGenLimit = (CORDB_ADDRESS)gen0.allocation_context.alloc_limit; pHeaps[i].Gen0Start = (CORDB_ADDRESS)gen0.allocation_start; pHeaps[i].Gen0End = (CORDB_ADDRESS)heap->alloc_allocated; pHeaps[i].Gen1Start = (CORDB_ADDRESS)gen1.allocation_start; // Segments int count = GetSegmentCount(loh.start_segment); count += GetSegmentCount(gen2.start_segment); pHeaps[i].SegmentCount = count; pHeaps[i].Segments = new (nothrow) SegmentData[count]; if (pHeaps[i].Segments == NULL) return E_OUTOFMEMORY; // Small object heap segments DPTR(dac_heap_segment) seg = gen2.start_segment; int j = 0; for (; seg && (j < count); ++j) { pHeaps[i].Segments[j].Start = (CORDB_ADDRESS)seg->mem; if (seg.GetAddr() == heap->ephemeral_heap_segment.GetAddr()) { pHeaps[i].Segments[j].End = (CORDB_ADDRESS)heap->alloc_allocated; pHeaps[i].EphemeralSegment = j; pHeaps[i].Segments[j].Generation = 1; } else { pHeaps[i].Segments[j].End = (CORDB_ADDRESS)seg->allocated; pHeaps[i].Segments[j].Generation = 2; } seg = seg->next; } // Large object heap segments seg = loh.start_segment; for (; seg && (j < count); ++j) { pHeaps[i].Segments[j].Generation = 3; pHeaps[i].Segments[j].Start = (CORDB_ADDRESS)seg->mem; pHeaps[i].Segments[j].End = (CORDB_ADDRESS)seg->allocated; seg = seg->next; } } return S_OK; }