mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
More alias shit
git-svn-id: https://svn.eduke32.com/eduke32@818 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d3e54859c2
commit
f6999157f7
3 changed files with 54 additions and 35 deletions
|
@ -13,6 +13,19 @@ typedef struct {
|
|||
const char *raw;
|
||||
} osdfuncparm_t;
|
||||
|
||||
typedef struct _symbol
|
||||
{
|
||||
const char *name;
|
||||
struct _symbol *next;
|
||||
|
||||
const char *help;
|
||||
int (*func)(const osdfuncparm_t *);
|
||||
} symbol_t;
|
||||
|
||||
extern symbol_t *symbols;
|
||||
|
||||
#define OSD_ALIAS 0x1337
|
||||
|
||||
#define OSDCMD_OK 0
|
||||
#define OSDCMD_SHOWHELP 1
|
||||
|
||||
|
|
|
@ -7,17 +7,7 @@
|
|||
#include "compat.h"
|
||||
#include "baselayer.h"
|
||||
|
||||
|
||||
typedef struct _symbol
|
||||
{
|
||||
const char *name;
|
||||
struct _symbol *next;
|
||||
|
||||
const char *help;
|
||||
int (*func)(const osdfuncparm_t *);
|
||||
} symbol_t;
|
||||
|
||||
static symbol_t *symbols = NULL;
|
||||
symbol_t *symbols = NULL;
|
||||
static symbol_t *addnewsymbol(const char *name);
|
||||
static symbol_t *findsymbol(const char *name, symbol_t *startingat);
|
||||
static symbol_t *findexactsymbol(const char *name);
|
||||
|
@ -27,7 +17,6 @@ static symbol_t *findexactsymbol(const char *name);
|
|||
static int _internal_osdfunc_listsymbols(const osdfuncparm_t *);
|
||||
static int _internal_osdfunc_help(const osdfuncparm_t *);
|
||||
static int _internal_osdfunc_alias(const osdfuncparm_t *);
|
||||
static int _internal_osdfunc_aliasfunc(const osdfuncparm_t *);
|
||||
// static int _internal_osdfunc_dumpbuildinfo(const osdfuncparm_t *);
|
||||
// static int _internal_osdfunc_setrendermode(const osdfuncparm_t *);
|
||||
|
||||
|
@ -223,30 +212,35 @@ static int _internal_osdfunc_alias(const osdfuncparm_t *parm)
|
|||
{
|
||||
OSD_Printf("Alias listing:\n");
|
||||
for (i=symbols; i!=NULL; i=i->next)
|
||||
if (i->func == (void *)_internal_osdfunc_aliasfunc)
|
||||
if (i->func == (void *)OSD_ALIAS)
|
||||
OSD_Printf(" %s\n", i->name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms < 2)
|
||||
for (i=symbols; i!=NULL; i=i->next)
|
||||
{
|
||||
for (i=symbols; i!=NULL; i=i->next)
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0],i->name))
|
||||
OSD_Printf("alias %s \"%s\"\n", i->name, i->help);
|
||||
return OSDCMD_OK;
|
||||
{
|
||||
if (i->func == (void *)OSD_ALIAS)
|
||||
OSD_Printf("alias %s \"%s\"\n", i->name, i->help);
|
||||
else OSD_Printf("%s is a function, not an alias\n",i->name);
|
||||
}
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
if (i != NULL && !Bstrcasecmp(parm->parms[0],i->name) && i->func != (void *)OSD_ALIAS)
|
||||
{
|
||||
OSD_Printf("Cannot override function \"%s\" with alias\n",i->name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
OSD_RegisterFunction(Bstrdup(parm->parms[0]),Bstrdup(parm->parms[1]),_internal_osdfunc_aliasfunc);
|
||||
OSD_RegisterFunction(Bstrdup(parm->parms[0]),Bstrdup(parm->parms[1]),(void *)OSD_ALIAS);
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int _internal_osdfunc_aliasfunc(const osdfuncparm_t *parm)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(parm);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int _internal_osdfunc_vars(const osdfuncparm_t *parm)
|
||||
{
|
||||
int showval = (parm->numparms < 1);
|
||||
|
@ -1198,15 +1192,18 @@ int OSD_Dispatch(const char *cmd)
|
|||
ofp.numparms = numparms;
|
||||
ofp.parms = (const char **)parms;
|
||||
ofp.raw = cmd;
|
||||
if (symb->func == _internal_osdfunc_aliasfunc)
|
||||
if (symb->func == (void *)OSD_ALIAS)
|
||||
OSD_Dispatch(symb->help);
|
||||
switch (symb->func(&ofp))
|
||||
else
|
||||
{
|
||||
case OSDCMD_OK:
|
||||
break;
|
||||
case OSDCMD_SHOWHELP:
|
||||
OSD_Printf("%s\n", symb->help);
|
||||
break;
|
||||
switch (symb->func(&ofp))
|
||||
{
|
||||
case OSDCMD_OK:
|
||||
break;
|
||||
case OSDCMD_SHOWHELP:
|
||||
OSD_Printf("%s\n", symb->help);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
state = wtp;
|
||||
|
@ -1268,8 +1265,11 @@ int OSD_RegisterFunction(const char *name, const char *help, int (*func)(const o
|
|||
symb = findexactsymbol(name);
|
||||
if (symb) // allow this now for reusing an alias name
|
||||
{
|
||||
// OSD_Printf("OSD_RegisterFunction(): \"%s\" is already defined\n", name);
|
||||
// return -1;
|
||||
if (symb->func != (void *)OSD_ALIAS)
|
||||
{
|
||||
OSD_Printf("OSD_RegisterFunction(): \"%s\" is already defined\n", name);
|
||||
return -1;
|
||||
}
|
||||
// Bfree(symb->help);
|
||||
symb->help = help;
|
||||
symb->func = func;
|
||||
|
|
|
@ -785,16 +785,22 @@ int32 CONFIG_ReadSetup(void)
|
|||
===================
|
||||
*/
|
||||
|
||||
void CONFIG_WriteBinds(void)
|
||||
void CONFIG_WriteBinds(void) // save binds and aliases to disk
|
||||
{
|
||||
int i;
|
||||
FILE *fp = fopen("binds.cfg", "wt");
|
||||
|
||||
if (fp)
|
||||
{
|
||||
symbol_t *symb;
|
||||
fprintf(fp,"// this file automatically generated by EDuke32\n// do not modify if you lack common sense\n");
|
||||
for (i=0;i<MAXBOUNDKEYS;i++)if (*boundkeys[i].name)
|
||||
fprintf(fp,"bind %s \"%s\"\n",boundkeys[i].key,boundkeys[i].name);
|
||||
fprintf(fp,"bind %s%s \"%s\"\n",boundkeys[i].key,boundkeys[i].repeat?"":" norepeat",boundkeys[i].name);
|
||||
|
||||
for (symb=symbols; symb!=NULL; symb=symb->next)
|
||||
if (symb->func == (void *)OSD_ALIAS)
|
||||
fprintf(fp,"alias %s \"%s\"\n", symb->name, symb->help);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue