3988: improved the debug graphs. r=def- a=ChillerDragon

Closes https://github.com/teeworlds/teeworlds/issues/1058

(cherry picked from commit bf61d41c49)

No hard feelings from my side about the clamp. I am just hunting down em diffs to the upstream. But `@heinrich5991` seemed a bit concerned [back in 2013](https://github.com/teeworlds/teeworlds/issues/1058#issuecomment-12178577)

Old:
![screenshot_2021-08-04_10-12-54](https://user-images.githubusercontent.com/20344300/128148556-e818d45d-a455-4021-89a3-6f61cf187c93.png)


New:
![screenshot_2021-08-04_10-15-08](https://user-images.githubusercontent.com/20344300/128148516-b5a5fc79-2db8-4379-9d20-1a39c4d6285a.png)


## Checklist

- [X] Tested the change ingame
- [X] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [X] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: oy <Tom_Adams@web.de>
This commit is contained in:
bors[bot] 2021-08-04 08:29:58 +00:00 committed by GitHub
commit 4a77882fcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -81,15 +81,15 @@ static const ColorRGBA ClientNetworkErrPrintColor{1.0f, 0.25f, 0.25f, 1.0f};
void CGraph::Init(float Min, float Max)
{
m_Min = Min;
m_Max = Max;
m_MinRange = m_Min = Min;
m_MaxRange = m_Max = Max;
m_Index = 0;
}
void CGraph::ScaleMax()
{
int i = 0;
m_Max = 0;
m_Max = m_MaxRange;
for(i = 0; i < MAX_VALUES; i++)
{
if(m_aValues[i] > m_Max)
@ -100,7 +100,7 @@ void CGraph::ScaleMax()
void CGraph::ScaleMin()
{
int i = 0;
m_Min = m_Max;
m_Min = m_MinRange;
for(i = 0; i < MAX_VALUES; i++)
{
if(m_aValues[i] < m_Min)
@ -1089,7 +1089,11 @@ void CClient::DebugRender()
m_FpsGraph.ScaleMax();
m_FpsGraph.ScaleMin();
m_FpsGraph.Render(Graphics(), m_DebugFont, x, sp * 5, w, h, "FPS");
m_InputtimeMarginGraph.ScaleMin();
m_InputtimeMarginGraph.ScaleMax();
m_InputtimeMarginGraph.Render(Graphics(), m_DebugFont, x, sp * 5 + h + sp, w, h, "Prediction Margin");
m_GametimeMarginGraph.ScaleMin();
m_GametimeMarginGraph.ScaleMax();
m_GametimeMarginGraph.Render(Graphics(), m_DebugFont, x, sp * 5 + h + sp + h + sp, w, h, "Gametime Margin");
}
}
@ -3123,7 +3127,7 @@ void CClient::Run()
*/
//
m_FpsGraph.Init(0.0f, 200.0f);
m_FpsGraph.Init(0.0f, 120.0f);
// never start with the editor
g_Config.m_ClEditor = 0;

View file

@ -41,6 +41,7 @@ public:
};
float m_Min, m_Max;
float m_MinRange, m_MaxRange;
float m_aValues[MAX_VALUES];
float m_aColors[MAX_VALUES][3];
int m_Index;