Subversion Repositories eduke32

Rev

Rev 2542 | Rev 2554 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2542 helixhorne 1
//
2
// Common non-engine code/data for EDuke32 and Mapster32
3
//
4
 
5
#include "compat.h"
2549 helixhorne 6
#include "scriptfile.h"
2542 helixhorne 7
 
8
#include "common.h"
9
 
10
 
11
struct strllist *CommandPaths, *CommandGrps;
12
 
13
void G_AddGroup(const char *buffer)
14
{
15
    char buf[BMAX_PATH];
16
 
17
    struct strllist *s = Bcalloc(1,sizeof(struct strllist));
18
 
19
    Bstrcpy(buf, buffer);
20
 
21
    if (Bstrchr(buf,'.') == 0)
22
        Bstrcat(buf,".grp");
23
 
24
    s->str = Bstrdup(buf);
25
 
26
    if (CommandGrps)
27
    {
28
        struct strllist *t;
29
        for (t = CommandGrps; t->next; t=t->next) ;
30
        t->next = s;
31
        return;
32
    }
33
    CommandGrps = s;
34
}
35
 
36
void G_AddPath(const char *buffer)
37
{
38
    struct strllist *s = Bcalloc(1,sizeof(struct strllist));
39
    s->str = Bstrdup(buffer);
40
 
41
    if (CommandPaths)
42
    {
43
        struct strllist *t;
44
        for (t = CommandPaths; t->next; t=t->next) ;
45
        t->next = s;
46
        return;
47
    }
48
    CommandPaths = s;
49
}
2549 helixhorne 50
 
51
//////////
52
 
53
int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens)
54
{
55
    char *tok;
56
    int32_t i;
57
 
58
    if (!sf) return T_ERROR;
59
    tok = scriptfile_gettoken(sf);
60
    if (!tok) return T_EOF;
61
 
62
    for (i=ntokens-1; i>=0; i--)
63
    {
64
        if (!Bstrcasecmp(tok, tl[i].text))
65
            return tl[i].tokenid;
66
    }
67
    return T_ERROR;
68
}