mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-05 20:41:06 +00:00
e7f091cd90
Alongside, these make into into the header: - the 'tokenlist' type (a typedef'd struct) - the T_EOF and T_ERROR enumeration values git-svn-id: https://svn.eduke32.com/eduke32@2549 1a8010ca-5511-0410-912e-c29ae57300e0
68 lines
1.2 KiB
C
68 lines
1.2 KiB
C
//
|
|
// Common non-engine code/data for EDuke32 and Mapster32
|
|
//
|
|
|
|
#include "compat.h"
|
|
#include "scriptfile.h"
|
|
|
|
#include "common.h"
|
|
|
|
|
|
struct strllist *CommandPaths, *CommandGrps;
|
|
|
|
void G_AddGroup(const char *buffer)
|
|
{
|
|
char buf[BMAX_PATH];
|
|
|
|
struct strllist *s = Bcalloc(1,sizeof(struct strllist));
|
|
|
|
Bstrcpy(buf, buffer);
|
|
|
|
if (Bstrchr(buf,'.') == 0)
|
|
Bstrcat(buf,".grp");
|
|
|
|
s->str = Bstrdup(buf);
|
|
|
|
if (CommandGrps)
|
|
{
|
|
struct strllist *t;
|
|
for (t = CommandGrps; t->next; t=t->next) ;
|
|
t->next = s;
|
|
return;
|
|
}
|
|
CommandGrps = s;
|
|
}
|
|
|
|
void G_AddPath(const char *buffer)
|
|
{
|
|
struct strllist *s = Bcalloc(1,sizeof(struct strllist));
|
|
s->str = Bstrdup(buffer);
|
|
|
|
if (CommandPaths)
|
|
{
|
|
struct strllist *t;
|
|
for (t = CommandPaths; t->next; t=t->next) ;
|
|
t->next = s;
|
|
return;
|
|
}
|
|
CommandPaths = s;
|
|
}
|
|
|
|
//////////
|
|
|
|
int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens)
|
|
{
|
|
char *tok;
|
|
int32_t i;
|
|
|
|
if (!sf) return T_ERROR;
|
|
tok = scriptfile_gettoken(sf);
|
|
if (!tok) return T_EOF;
|
|
|
|
for (i=ntokens-1; i>=0; i--)
|
|
{
|
|
if (!Bstrcasecmp(tok, tl[i].text))
|
|
return tl[i].tokenid;
|
|
}
|
|
return T_ERROR;
|
|
}
|