mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
[qw] Add progs memory display to server status bar
This makes it easy to check for memory leaks before they crash the server.
This commit is contained in:
parent
1be220559a
commit
6d6440457a
2 changed files with 27 additions and 1 deletions
|
@ -608,7 +608,7 @@ SV_Progs_Init_Cvars (void)
|
|||
sv_progs = Cvar_Get ("sv_progs", "", CVAR_NONE, NULL,
|
||||
"Override the default game progs.");
|
||||
sv_progs_zone = Cvar_Get ("sv_progs_zone", "256", CVAR_NONE, NULL,
|
||||
"size of the zone for progs in kb");
|
||||
"size of the zone for progs in kB");
|
||||
sv_progs_ext = Cvar_Get ("sv_progs_ext", "qf", CVAR_NONE, NULL,
|
||||
"extention mapping to use: "
|
||||
"none, id, qf, qwe, ktpro, cpqw");
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "sv_console.h"
|
||||
|
||||
#include "qw/include/server.h"
|
||||
#include "qw/include/sv_progs.h"
|
||||
#include "qw/include/sv_recorder.h"
|
||||
|
||||
static void
|
||||
|
@ -80,6 +81,26 @@ draw_rec (view_t *view)
|
|||
*d++ = *s;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_mem (view_t *view)
|
||||
{
|
||||
sv_view_t *sv_view = view->data;
|
||||
sv_sbar_t *sb = sv_view->obj;
|
||||
const char *str;
|
||||
const char *s;
|
||||
char *d;
|
||||
size_t used, size;
|
||||
byte mask = 0;
|
||||
|
||||
Z_MemInfo (sv_pr_state.zone, &used, &size);
|
||||
str = va (0, "[mem: %4zd / %-4zd]", used / 1024, size / 1024);
|
||||
if (used / (size / 256) >= 192) {
|
||||
mask = 0x80;
|
||||
}
|
||||
for (s = str, d = sb->text + view->xrel; *s; s++)
|
||||
*d++ = *s | mask;
|
||||
}
|
||||
|
||||
void
|
||||
SV_Sbar_Init (void)
|
||||
{
|
||||
|
@ -99,4 +120,9 @@ SV_Sbar_Init (void)
|
|||
view->draw = draw_rec;
|
||||
view->data = status->data;
|
||||
view_add (status, view);
|
||||
|
||||
view = view_new (19, 0, 18, 1, grav_northwest);
|
||||
view->draw = draw_mem;
|
||||
view->data = status->data;
|
||||
view_add (status, view);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue