mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
Very minor OSD cleanups, no functional changes. I was planning on doing more with this but decided to do something else instead, so I want it out of my tree without losing it. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@5280 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4fe25690e7
commit
f784eca65b
1 changed files with 75 additions and 107 deletions
|
@ -76,8 +76,6 @@ int32_t m32_osd_tryscript=0; // whether to try executing m32script on unkown co
|
||||||
|
|
||||||
int32_t OSD_RegisterCvar(const cvar_t *cvar)
|
int32_t OSD_RegisterCvar(const cvar_t *cvar)
|
||||||
{
|
{
|
||||||
const char *cp;
|
|
||||||
|
|
||||||
if (!osd)
|
if (!osd)
|
||||||
OSD_Init();
|
OSD_Init();
|
||||||
|
|
||||||
|
@ -88,7 +86,7 @@ int32_t OSD_RegisterCvar(const cvar_t *cvar)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for illegal characters in name
|
// check for illegal characters in name
|
||||||
for (cp = cvar->name; *cp; cp++)
|
for (const char *cp = cvar->name; *cp; cp++)
|
||||||
{
|
{
|
||||||
if ((cp == cvar->name) && (*cp >= '0') && (*cp <= '9'))
|
if ((cp == cvar->name) && (*cp >= '0') && (*cp <= '9'))
|
||||||
{
|
{
|
||||||
|
@ -202,8 +200,7 @@ const char *OSD_StripColors(char *out, const char *in)
|
||||||
int32_t OSD_Exec(const char *szScript)
|
int32_t OSD_Exec(const char *szScript)
|
||||||
{
|
{
|
||||||
int32_t i, len, err = 0;
|
int32_t i, len, err = 0;
|
||||||
char *buf = NULL, *cp;
|
char *buf = NULL;
|
||||||
|
|
||||||
|
|
||||||
if ((i = kopen4load(szScript, 0)) == -1) err = 1;
|
if ((i = kopen4load(szScript, 0)) == -1) err = 1;
|
||||||
if (!err && (len = kfilelength(i)) <= 0) err = 2; // blank file
|
if (!err && (len = kfilelength(i)) <= 0) err = 2; // blank file
|
||||||
|
@ -224,7 +221,7 @@ int32_t OSD_Exec(const char *szScript)
|
||||||
osd->execdepth++;
|
osd->execdepth++;
|
||||||
|
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
cp = strtok(buf, "\r\n");
|
char *cp = strtok(buf, "\r\n");
|
||||||
|
|
||||||
while (cp != NULL)
|
while (cp != NULL)
|
||||||
{
|
{
|
||||||
|
@ -299,9 +296,8 @@ void OSD_SetTextMode(int32_t mode)
|
||||||
{
|
{
|
||||||
osd->draw.mode = (mode != 0);
|
osd->draw.mode = (mode != 0);
|
||||||
|
|
||||||
if (osd->draw.mode && drawosdchar != _internal_drawosdchar)
|
if ((osd->draw.mode && drawosdchar != _internal_drawosdchar) ||
|
||||||
swaposdptrs();
|
(!osd->draw.mode && drawosdchar == _internal_drawosdchar))
|
||||||
else if (!osd->draw.mode && drawosdchar == _internal_drawosdchar)
|
|
||||||
swaposdptrs();
|
swaposdptrs();
|
||||||
|
|
||||||
if (in3dmode())
|
if (in3dmode())
|
||||||
|
@ -310,16 +306,16 @@ void OSD_SetTextMode(int32_t mode)
|
||||||
|
|
||||||
static int32_t _internal_osdfunc_exec(const osdfuncparm_t *parm)
|
static int32_t _internal_osdfunc_exec(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
|
if (parm->numparms != 1)
|
||||||
|
return OSDCMD_SHOWHELP;
|
||||||
|
|
||||||
char fn[BMAX_PATH];
|
char fn[BMAX_PATH];
|
||||||
|
|
||||||
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
|
||||||
Bstrcpy(fn,parm->parms[0]);
|
Bstrcpy(fn,parm->parms[0]);
|
||||||
|
|
||||||
if (OSD_Exec(fn))
|
if (OSD_Exec(fn))
|
||||||
{
|
|
||||||
OSD_Printf(OSD_ERROR "exec: file \"%s\" not found.\n", fn);
|
OSD_Printf(OSD_ERROR "exec: file \"%s\" not found.\n", fn);
|
||||||
return OSDCMD_OK;
|
|
||||||
}
|
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,12 +328,7 @@ static int32_t _internal_osdfunc_echo(const osdfuncparm_t *parm)
|
||||||
|
|
||||||
static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm)
|
static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
uint32_t crc = 0, length;
|
|
||||||
int32_t i,j;
|
int32_t i,j;
|
||||||
char buf[256];
|
|
||||||
void *xxh;
|
|
||||||
uint32_t xxhash;
|
|
||||||
int32_t crctime, xxhtime;
|
|
||||||
|
|
||||||
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
||||||
|
|
||||||
|
@ -347,9 +338,10 @@ static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm)
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = kfilelength(i);
|
char buf[256];
|
||||||
|
uint32_t length = kfilelength(i);
|
||||||
crctime = getticks();
|
int32_t crctime = getticks();
|
||||||
|
uint32_t crc = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
j = kread(i,buf,256);
|
j = kread(i,buf,256);
|
||||||
|
@ -360,15 +352,15 @@ static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm)
|
||||||
|
|
||||||
klseek(i, 0, BSEEK_SET);
|
klseek(i, 0, BSEEK_SET);
|
||||||
|
|
||||||
xxhtime = getticks();
|
int32_t xxhtime = getticks();
|
||||||
xxh = XXH32_init(0x1337);
|
void *xxh = XXH32_init(0x1337);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
j = kread(i, buf, 256);
|
j = kread(i, buf, 256);
|
||||||
XXH32_update(xxh, (uint8_t *) buf, j);
|
XXH32_update(xxh, (uint8_t *) buf, j);
|
||||||
}
|
}
|
||||||
while (j == 256);
|
while (j == 256);
|
||||||
xxhash = XXH32_digest(xxh);
|
uint32_t xxhash = XXH32_digest(xxh);
|
||||||
xxhtime = getticks() - xxhtime;
|
xxhtime = getticks() - xxhtime;
|
||||||
|
|
||||||
kclose(i);
|
kclose(i);
|
||||||
|
@ -386,12 +378,10 @@ static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm)
|
||||||
|
|
||||||
static void _internal_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal)
|
static void _internal_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal)
|
||||||
{
|
{
|
||||||
char st[2] = { 0,0 };
|
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(shade);
|
UNREFERENCED_PARAMETER(shade);
|
||||||
UNREFERENCED_PARAMETER(pal);
|
UNREFERENCED_PARAMETER(pal);
|
||||||
|
|
||||||
st[0] = ch;
|
char st[2] = { ch, 0 };
|
||||||
|
|
||||||
printext256(4+(x<<3),4+(y<<3), white, -1, st, 0);
|
printext256(4+(x<<3),4+(y<<3), white, -1, st, 0);
|
||||||
}
|
}
|
||||||
|
@ -632,13 +622,13 @@ static int32_t _internal_osdfunc_clear(const osdfuncparm_t *parm)
|
||||||
|
|
||||||
static int32_t _internal_osdfunc_history(const osdfuncparm_t *parm)
|
static int32_t _internal_osdfunc_history(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
int32_t i, j = 0;
|
int32_t j = 0;
|
||||||
osdhist_t *h = &osd->history;
|
osdhist_t *h = &osd->history;
|
||||||
UNREFERENCED_PARAMETER(parm);
|
UNREFERENCED_PARAMETER(parm);
|
||||||
|
|
||||||
OSD_Printf(OSDTEXT_RED "Command history:\n");
|
OSD_Printf(OSDTEXT_RED "Command history:\n");
|
||||||
|
|
||||||
for (i=osd->history.maxlines-1; i>=0; i--)
|
for (int32_t i=osd->history.maxlines-1; i>=0; i--)
|
||||||
if (h->buf[i])
|
if (h->buf[i])
|
||||||
OSD_Printf("%4d \"%s\"\n", h->total - h->lines + (++j), h->buf[i]);
|
OSD_Printf("%4d \"%s\"\n", h->total - h->lines + (++j), h->buf[i]);
|
||||||
|
|
||||||
|
@ -653,13 +643,10 @@ static int32_t _internal_osdfunc_history(const osdfuncparm_t *parm)
|
||||||
//
|
//
|
||||||
void OSD_Cleanup(void)
|
void OSD_Cleanup(void)
|
||||||
{
|
{
|
||||||
symbol_t *s;
|
|
||||||
int32_t i;
|
|
||||||
|
|
||||||
hash_free(&h_osd);
|
hash_free(&h_osd);
|
||||||
hash_free(&h_cvars);
|
hash_free(&h_cvars);
|
||||||
|
|
||||||
for (; symbols; symbols=s)
|
for (symbol_t *s; symbols; symbols=s)
|
||||||
{
|
{
|
||||||
s=symbols->next;
|
s=symbols->next;
|
||||||
Bfree(symbols);
|
Bfree(symbols);
|
||||||
|
@ -669,7 +656,7 @@ void OSD_Cleanup(void)
|
||||||
DO_FREE_AND_NULL(osd->cvars);
|
DO_FREE_AND_NULL(osd->cvars);
|
||||||
DO_FREE_AND_NULL(osd->editor.buf);
|
DO_FREE_AND_NULL(osd->editor.buf);
|
||||||
DO_FREE_AND_NULL(osd->editor.tmp);
|
DO_FREE_AND_NULL(osd->editor.tmp);
|
||||||
for (i=0; i<OSDMAXHISTORYDEPTH; i++)
|
for (int i=0; i<OSDMAXHISTORYDEPTH; i++)
|
||||||
DO_FREE_AND_NULL(osd->history.buf[i]);
|
DO_FREE_AND_NULL(osd->history.buf[i]);
|
||||||
DO_FREE_AND_NULL(osd->text.buf);
|
DO_FREE_AND_NULL(osd->text.buf);
|
||||||
DO_FREE_AND_NULL(osd->text.fmt);
|
DO_FREE_AND_NULL(osd->text.fmt);
|
||||||
|
@ -681,39 +668,32 @@ static int32_t osdcmd_cvar_set_osd(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
int32_t r = osdcmd_cvar_set(parm);
|
int32_t r = osdcmd_cvar_set(parm);
|
||||||
|
|
||||||
if (r == OSDCMD_OK)
|
if (r != OSDCMD_OK)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (!Bstrcasecmp(parm->name, "osdrows"))
|
||||||
{
|
{
|
||||||
if (!Bstrcasecmp(parm->name, "osdrows"))
|
if (osd->draw.rows > osdmaxrows)
|
||||||
{
|
osd->draw.rows = osdmaxrows;
|
||||||
if (osd->draw.rows > osdmaxrows) osd->draw.rows = osdmaxrows;
|
if (osdrowscur != -1)
|
||||||
if (osdrowscur!=-1) osdrowscur = osd->draw.rows;
|
osdrowscur = osd->draw.rows;
|
||||||
return r;
|
|
||||||
}
|
|
||||||
else if (!Bstrcasecmp(parm->name, "osdtextmode"))
|
|
||||||
{
|
|
||||||
OSD_SetTextMode(osd->draw.mode);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
else if (!Bstrcasecmp(parm->name, "osdhistorydepth"))
|
|
||||||
{
|
|
||||||
int32_t i;
|
|
||||||
|
|
||||||
for (i=OSDMAXHISTORYDEPTH-1; i>=osd->history.maxlines; i--)
|
|
||||||
DO_FREE_AND_NULL(osd->history.buf[i]);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return r;
|
else if (!Bstrcasecmp(parm->name, "osdtextmode"))
|
||||||
|
OSD_SetTextMode(osd->draw.mode);
|
||||||
|
else if (!Bstrcasecmp(parm->name, "osdhistorydepth"))
|
||||||
|
{
|
||||||
|
for (int i = OSDMAXHISTORYDEPTH - 1; i >= osd->history.maxlines; i--)
|
||||||
|
DO_FREE_AND_NULL(osd->history.buf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t _internal_osdfunc_toggle(const osdfuncparm_t *parm)
|
static int32_t _internal_osdfunc_toggle(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
int32_t i;
|
|
||||||
|
|
||||||
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
||||||
|
|
||||||
i = hash_find(&h_cvars, parm->parms[0]);
|
intptr_t i = hash_find(&h_cvars, parm->parms[0]);
|
||||||
|
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
for (i = osd->numcvars-1; i >= 0; i--)
|
for (i = osd->numcvars-1; i >= 0; i--)
|
||||||
|
@ -734,8 +714,6 @@ static int32_t _internal_osdfunc_toggle(const osdfuncparm_t *parm)
|
||||||
//
|
//
|
||||||
void OSD_Init(void)
|
void OSD_Init(void)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
osd = (osdmain_t *)Bcalloc(1, sizeof(osdmain_t));
|
osd = (osdmain_t *)Bcalloc(1, sizeof(osdmain_t));
|
||||||
|
|
||||||
mutex_init(&osd->mutex);
|
mutex_init(&osd->mutex);
|
||||||
|
@ -762,29 +740,27 @@ void OSD_Init(void)
|
||||||
hash_init(&h_osd);
|
hash_init(&h_osd);
|
||||||
hash_init(&h_cvars);
|
hash_init(&h_cvars);
|
||||||
|
|
||||||
|
cvar_t cvars_osd [] =
|
||||||
{
|
{
|
||||||
cvar_t cvars_osd [] =
|
{ "osdeditpal", "sets the palette of the OSD input text", (void *) &osd->draw.editpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
|
||||||
{
|
{ "osdpromptpal", "sets the palette of the OSD prompt", (void *) &osd->draw.promptpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
|
||||||
{ "osdeditpal", "sets the palette of the OSD input text", (void *) &osd->draw.editpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
|
{ "osdtextpal", "sets the palette of the OSD text", (void *) &osd->draw.textpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
|
||||||
{ "osdpromptpal", "sets the palette of the OSD prompt", (void *) &osd->draw.promptpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
|
{ "osdeditshade", "sets the shade of the OSD input text", (void *) &osd->draw.editshade, CVAR_INT, 0, 7 },
|
||||||
{ "osdtextpal", "sets the palette of the OSD text", (void *) &osd->draw.textpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
|
{ "osdtextshade", "sets the shade of the OSD text", (void *) &osd->draw.textshade, CVAR_INT, 0, 7 },
|
||||||
{ "osdeditshade", "sets the shade of the OSD input text", (void *) &osd->draw.editshade, CVAR_INT, 0, 7 },
|
{ "osdpromptshade", "sets the shade of the OSD prompt", (void *) &osd->draw.promptshade, CVAR_INT, INT8_MIN, INT8_MAX },
|
||||||
{ "osdtextshade", "sets the shade of the OSD text", (void *) &osd->draw.textshade, CVAR_INT, 0, 7 },
|
{ "osdrows", "sets the number of visible lines of the OSD", (void *) &osd->draw.rows, CVAR_INT|CVAR_FUNCPTR, 1, MAXPALOOKUPS-1 },
|
||||||
{ "osdpromptshade", "sets the shade of the OSD prompt", (void *) &osd->draw.promptshade, CVAR_INT, INT8_MIN, INT8_MAX },
|
{ "osdtextmode", "set OSD text mode (0:graphical, 1:fast)", (void *) &osd->draw.mode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
|
||||||
{ "osdrows", "sets the number of visible lines of the OSD", (void *) &osd->draw.rows, CVAR_INT|CVAR_FUNCPTR, 1, MAXPALOOKUPS-1 },
|
{ "osdlogcutoff", "sets the maximal line count of the log file", (void *) &osd->log.cutoff, CVAR_INT, 0, 262144 },
|
||||||
{ "osdtextmode", "set OSD text mode (0:graphical, 1:fast)", (void *) &osd->draw.mode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
|
{ "osdhistorydepth", "sets the history depth, in lines", (void *) &osd->history.maxlines, CVAR_INT|CVAR_FUNCPTR, OSDMINHISTORYDEPTH, OSDMAXHISTORYDEPTH },
|
||||||
{ "osdlogcutoff", "sets the maximal line count of the log file", (void *) &osd->log.cutoff, CVAR_INT, 0, 262144 },
|
};
|
||||||
{ "osdhistorydepth", "sets the history depth, in lines", (void *) &osd->history.maxlines, CVAR_INT|CVAR_FUNCPTR, OSDMINHISTORYDEPTH, OSDMAXHISTORYDEPTH },
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i=0; i<ARRAY_SIZE(cvars_osd); i++)
|
for (unsigned i=0; i<ARRAY_SIZE(cvars_osd); i++)
|
||||||
{
|
{
|
||||||
if (OSD_RegisterCvar(&cvars_osd[i]))
|
if (OSD_RegisterCvar(&cvars_osd[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
OSD_RegisterFunction(cvars_osd[i].name, cvars_osd[i].desc,
|
OSD_RegisterFunction(cvars_osd[i].name, cvars_osd[i].desc,
|
||||||
cvars_osd[i].type & CVAR_FUNCPTR ? osdcmd_cvar_set_osd : osdcmd_cvar_set);
|
cvars_osd[i].type & CVAR_FUNCPTR ? osdcmd_cvar_set_osd : osdcmd_cvar_set);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias);
|
OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias);
|
||||||
|
@ -807,12 +783,6 @@ void OSD_Init(void)
|
||||||
//
|
//
|
||||||
void OSD_SetLogFile(const char *fn)
|
void OSD_SetLogFile(const char *fn)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGINGAIDS
|
|
||||||
const int bufmode = _IONBF;
|
|
||||||
#else
|
|
||||||
const int bufmode = _IOLBF;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MAYBE_FCLOSE_AND_NULL(osdlog);
|
MAYBE_FCLOSE_AND_NULL(osdlog);
|
||||||
osdlogfn = NULL;
|
osdlogfn = NULL;
|
||||||
|
|
||||||
|
@ -823,6 +793,11 @@ void OSD_SetLogFile(const char *fn)
|
||||||
|
|
||||||
if (osdlog)
|
if (osdlog)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
const int bufmode = _IONBF;
|
||||||
|
#else
|
||||||
|
const int bufmode = _IOLBF;
|
||||||
|
#endif
|
||||||
setvbuf(osdlog, (char *)NULL, bufmode, BUFSIZ);
|
setvbuf(osdlog, (char *)NULL, bufmode, BUFSIZ);
|
||||||
osdlogfn = fn;
|
osdlogfn = fn;
|
||||||
}
|
}
|
||||||
|
@ -2032,11 +2007,12 @@ static symbol_t *findsymbol(const char *name, symbol_t *startingat)
|
||||||
//
|
//
|
||||||
static symbol_t *findexactsymbol(const char *name)
|
static symbol_t *findexactsymbol(const char *name)
|
||||||
{
|
{
|
||||||
int32_t i;
|
|
||||||
char *lname = Xstrdup(name);
|
|
||||||
if (!symbols) return NULL;
|
if (!symbols) return NULL;
|
||||||
|
|
||||||
i = hash_find(&h_osd,lname);
|
char *lname = Xstrdup(name);
|
||||||
|
|
||||||
|
intptr_t i = hash_find(&h_osd,lname);
|
||||||
|
|
||||||
if (i > -1)
|
if (i > -1)
|
||||||
{
|
{
|
||||||
// if ((symbol_t *)osdsymbptrs[i]->func == OSD_UNALIASED)
|
// if ((symbol_t *)osdsymbptrs[i]->func == OSD_UNALIASED)
|
||||||
|
@ -2050,17 +2026,13 @@ static symbol_t *findexactsymbol(const char *name)
|
||||||
i = hash_find(&h_osd,lname);
|
i = hash_find(&h_osd,lname);
|
||||||
Bfree(lname);
|
Bfree(lname);
|
||||||
|
|
||||||
if (i > -1)
|
return (i > -1) ? osd->symbptrs[i] : NULL;
|
||||||
return osd->symbptrs[i];
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
int32_t showval = (parm->numparms == 0);
|
int32_t showval = (parm->numparms == 0);
|
||||||
int32_t i;
|
intptr_t i = hash_find(&h_cvars, parm->name);
|
||||||
|
|
||||||
i = hash_find(&h_cvars, parm->name);
|
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
for (i = osd->numcvars-1; i >= 0; i--)
|
for (i = osd->numcvars-1; i >= 0; i--)
|
||||||
|
@ -2079,14 +2051,14 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
case CVAR_FLOAT:
|
case CVAR_FLOAT:
|
||||||
{
|
{
|
||||||
float val;
|
|
||||||
if (showval)
|
if (showval)
|
||||||
{
|
{
|
||||||
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(float *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
|
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(float *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
sscanf(parm->parms[0], "%f", &val);
|
float val;
|
||||||
|
Bsscanf(parm->parms[0], "%f", &val);
|
||||||
|
|
||||||
if (val < osd->cvars[i].c.min || val > osd->cvars[i].c.max)
|
if (val < osd->cvars[i].c.min || val > osd->cvars[i].c.max)
|
||||||
{
|
{
|
||||||
|
@ -2100,14 +2072,14 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
break;
|
break;
|
||||||
case CVAR_DOUBLE:
|
case CVAR_DOUBLE:
|
||||||
{
|
{
|
||||||
double val;
|
|
||||||
if (showval)
|
if (showval)
|
||||||
{
|
{
|
||||||
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(double *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
|
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(double *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
sscanf(parm->parms[0], "%lf", &val);
|
double val;
|
||||||
|
Bsscanf(parm->parms[0], "%lf", &val);
|
||||||
|
|
||||||
if (val < osd->cvars[i].c.min || val > osd->cvars[i].c.max)
|
if (val < osd->cvars[i].c.min || val > osd->cvars[i].c.max)
|
||||||
{
|
{
|
||||||
|
@ -2123,14 +2095,13 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
case CVAR_UINT:
|
case CVAR_UINT:
|
||||||
case CVAR_BOOL:
|
case CVAR_BOOL:
|
||||||
{
|
{
|
||||||
int32_t val;
|
|
||||||
if (showval)
|
if (showval)
|
||||||
{
|
{
|
||||||
OSD_Printf((osd->cvars[i].c.type & CVAR_UINT) ? "\"%s\" is \"%u\"\n%s: %s\n" : "\"%s\" is \"%d\"\n%s: %s\n",osd->cvars[i].c.name,*(int32_t *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
|
OSD_Printf((osd->cvars[i].c.type & CVAR_UINT) ? "\"%s\" is \"%u\"\n%s: %s\n" : "\"%s\" is \"%d\"\n%s: %s\n",osd->cvars[i].c.name,*(int32_t *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = Batoi(parm->parms[0]);
|
int32_t val = Batoi(parm->parms[0]);
|
||||||
if (osd->cvars[i].c.type & CVAR_BOOL) val = val != 0;
|
if (osd->cvars[i].c.type & CVAR_BOOL) val = val != 0;
|
||||||
|
|
||||||
if (val < osd->cvars[i].c.min || ((osd->cvars[i].c.type & CVAR_UINT) ? ((unsigned) val > (unsigned) osd->cvars[i].c.max) : (val > osd->cvars[i].c.max)))
|
if (val < osd->cvars[i].c.min || ((osd->cvars[i].c.type & CVAR_UINT) ? ((unsigned) val > (unsigned) osd->cvars[i].c.max) : (val > osd->cvars[i].c.max)))
|
||||||
|
@ -2191,20 +2162,17 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
|
|
||||||
void OSD_WriteAliases(FILE *fp)
|
void OSD_WriteAliases(FILE *fp)
|
||||||
{
|
{
|
||||||
symbol_t *symb;
|
for (symbol_t *symb=symbols; symb!=NULL; symb=symb->next)
|
||||||
for (symb=symbols; symb!=NULL; symb=symb->next)
|
|
||||||
if (symb->func == (void *)OSD_ALIAS)
|
if (symb->func == (void *)OSD_ALIAS)
|
||||||
Bfprintf(fp, "alias \"%s\" \"%s\"\n", symb->name, symb->help);
|
Bfprintf(fp, "alias \"%s\" \"%s\"\n", symb->name, symb->help);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSD_WriteCvars(FILE *fp)
|
void OSD_WriteCvars(FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i=0; i<osd->numcvars; i++)
|
for (unsigned i=0; i<osd->numcvars; i++)
|
||||||
{
|
{
|
||||||
if (!(osd->cvars[i].c.type & CVAR_NOSAVE) && OSD_CvarModified(&osd->cvars[i]))
|
if (!(osd->cvars[i].c.type & CVAR_NOSAVE) && OSD_CvarModified(&osd->cvars[i]))
|
||||||
switch (osd->cvars[i].c.type&(CVAR_FLOAT|CVAR_DOUBLE|CVAR_INT|CVAR_UINT|CVAR_BOOL|CVAR_STRING))
|
switch (osd->cvars[i].c.type&(CVAR_FLOAT|CVAR_DOUBLE|CVAR_INT|CVAR_UINT|CVAR_BOOL|CVAR_STRING))
|
||||||
|
|
Loading…
Reference in a new issue