Skip to content

Commit

Permalink
Fixed few asserts detected with debug CRT
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed May 30, 2021
1 parent 26077bd commit 47ba334
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
43 changes: 23 additions & 20 deletions src/Layers/xrRender/dxStatGraphRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void dxStatGraphRender::OnRender(CStatGraph& owner)
{
switch (it->style)
{
case CStatGraph::stBar: RenderBars(owner, &pv_Tri, &(it->elements)); break;
case CStatGraph::stBar: RenderBars(owner, &pv_Tri, it->elements); break;
};
};
dwCount = u32(pv_Tri - pv_Tri_start);
Expand All @@ -93,8 +93,8 @@ void dxStatGraphRender::OnRender(CStatGraph& owner)
{
switch (it->style)
{
case CStatGraph::stCurve: RenderLines(owner, &pv_Line, &(it->elements)); break;
case CStatGraph::stBarLine: RenderBarLines(owner, &pv_Line, &(it->elements)); break;
case CStatGraph::stCurve: RenderLines(owner, &pv_Line, it->elements); break;
case CStatGraph::stBarLine: RenderBarLines(owner, &pv_Line, it->elements); break;
};
};

Expand All @@ -112,7 +112,7 @@ void dxStatGraphRender::OnRender(CStatGraph& owner)
pv_Line_start = (FVF::L*)RCache.Vertex.Lock(LineElem, hGeomLine->vb_stride, dwOffsetLine);
pv_Line = pv_Line_start;

RenderMarkers(owner, &pv_Line, &(owner.m_Markers));
RenderMarkers(owner, &pv_Line, owner.m_Markers);

dwCount = u32(pv_Line - pv_Line_start);
RCache.Vertex.Unlock(dwCount, hGeomLine->vb_stride);
Expand Down Expand Up @@ -219,7 +219,7 @@ void dxStatGraphRender::RenderBack(CStatGraph& owner)
RCache.Render(D3DPT_LINELIST, dwOffset, dwCount / 2);
}

void dxStatGraphRender::RenderBars(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq* pelements)
void dxStatGraphRender::RenderBars(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq& pelements)
{
float elem_offs = float(owner.rb.x - owner.lt.x) / owner.max_item_count;
float elem_factor = float(owner.rb.y - owner.lt.y) / float(owner.mx - owner.mn);
Expand All @@ -228,9 +228,9 @@ void dxStatGraphRender::RenderBars(CStatGraph& owner, FVF::L** ppv, CStatGraph::
float column_width = elem_offs;
if (column_width > 1)
column_width--;
for (auto it = pelements->begin(); it != pelements->end(); ++it)
for (auto it = pelements.begin(); it != pelements.end(); ++it)
{
float X = float(it - pelements->begin()) * elem_offs + owner.lt.x;
float X = float(it - pelements.begin()) * elem_offs + owner.lt.x;
float Y0 = base_y;
float Y1 = base_y - it->data * elem_factor;

Expand Down Expand Up @@ -259,42 +259,46 @@ void dxStatGraphRender::RenderBars(CStatGraph& owner, FVF::L** ppv, CStatGraph::
};
}

void dxStatGraphRender::RenderLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq* pelements) const
void dxStatGraphRender::RenderLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq& pelements) const
{
if (pelements.size() <= 1)
return;

float elem_offs = float(owner.rb.x - owner.lt.x) / owner.max_item_count;
float elem_factor = float(owner.rb.y - owner.lt.y) / float(owner.mx - owner.mn);
float base_y = float(owner.rb.y) + (owner.mn * elem_factor);

for (auto it = pelements->begin() + 1; it != pelements->end() && it != pelements->end() + 1;
++it)
for (auto it = pelements.begin() + 1; it != pelements.end(); ++it)
{
auto it_prev = it - 1;
float X0 = float(it_prev - pelements->begin()) * elem_offs + owner.lt.x;
float X0 = float(it_prev - pelements.begin()) * elem_offs + owner.lt.x;
float Y0 = base_y - it_prev->data * elem_factor;
(*ppv)->set(X0, Y0, it->color);
(*ppv)++;
float X1 = float(it - pelements->begin()) * elem_offs + owner.lt.x;
float X1 = float(it - pelements.begin()) * elem_offs + owner.lt.x;
float Y1 = base_y - it->data * elem_factor;
(*ppv)->set(X1, Y1, it->color);
(*ppv)++;
}
};

void dxStatGraphRender::RenderBarLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq* pelements) const
void dxStatGraphRender::RenderBarLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq& pelements) const
{
if (pelements.size() <= 1)
return;

float elem_offs = float(owner.rb.x - owner.lt.x) / owner.max_item_count;
float elem_factor = float(owner.rb.y - owner.lt.y) / float(owner.mx - owner.mn);
float base_y = float(owner.rb.y) + (owner.mn * elem_factor);

for (auto it = pelements->begin() + 1; it != pelements->end() && it != pelements->end() + 1;
++it)
for (auto it = pelements.begin() + 1; it != pelements.end(); ++it)
{
auto it_prev = it - 1;
float X0 = float(it_prev - pelements->begin()) * elem_offs + owner.lt.x + elem_offs;
float X0 = float(it_prev - pelements.begin()) * elem_offs + owner.lt.x + elem_offs;
float Y0 = base_y - it_prev->data * elem_factor;
(*ppv)->set(X0, Y0, it->color);
(*ppv)++;
float X1 = float(it - pelements->begin()) * elem_offs + owner.lt.x;
float X1 = float(it - pelements.begin()) * elem_offs + owner.lt.x;
float Y1 = base_y - it->data * elem_factor;
(*ppv)->set(X1, Y1, it->color);
(*ppv)++;
Expand All @@ -306,15 +310,14 @@ void dxStatGraphRender::RenderBarLines(CStatGraph& owner, FVF::L** ppv, CStatGra
}
};

void dxStatGraphRender::RenderMarkers(CStatGraph& owner, FVF::L** ppv, CStatGraph::MarkersDeq* pmarkers)
void dxStatGraphRender::RenderMarkers(CStatGraph& owner, FVF::L** ppv, CStatGraph::MarkersDeq& pmarkers)
{
float elem_offs = float(owner.rb.x - owner.lt.x) / owner.max_item_count;
float elem_factor = float(owner.rb.y - owner.lt.y) / float(owner.mx - owner.mn);
float base_y = float(owner.rb.y) + (owner.mn * elem_factor);

for (auto it = pmarkers->begin(); it != pmarkers->end() && it != pmarkers->end() + 1; ++it)
for (CStatGraph::SMarker& CurMarker : pmarkers)
{
CStatGraph::SMarker& CurMarker = *it;
float X0 = 0, Y0 = 0, X1 = 0, Y1 = 0;
switch (CurMarker.m_eStyle)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Layers/xrRender/dxStatGraphRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class dxStatGraphRender : public IStatGraphRender

private:
void RenderBack(CStatGraph& owner);
static void RenderBars(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq* pelements);
void RenderBarLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq* pelements) const;
void RenderLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq* pelements) const;
static void RenderMarkers(CStatGraph& owner, FVF::L** ppv, CStatGraph::MarkersDeq* pmarkers);
static void RenderBars(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq& pelements);
void RenderBarLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq& pelements) const;
void RenderLines(CStatGraph& owner, FVF::L** ppv, CStatGraph::ElementsDeq& pelements) const;
static void RenderMarkers(CStatGraph& owner, FVF::L** ppv, CStatGraph::MarkersDeq& pmarkers);

private:
ref_geom hGeomTri;
Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/Containers/FixedMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ class xr_fixed_map

void get_any_p(xr_vector<value_type*, xr_allocator<value_type*>>& D)
{
if (empty())
return;
D.resize(size());
value_type** _it = &D.front();
value_type* _end = end();
Expand Down

0 comments on commit 47ba334

Please sign in to comment.