summaryrefslogtreecommitdiff
path: root/src/map/script.hpp
blob: 4caf58e88e48b69bdd34279e3d6ca7c835864c25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef SCRIPT_HPP
#define SCRIPT_HPP

#include <cstdint>

#include <string>

#include "../common/db.hpp"

enum class ScriptCode : uint8_t;

struct script_data
{
    ScriptCode type;
    union
    {
        int num;
        const char *str;
        const ScriptCode *script;
    } u;
};

struct script_stack
{
    int sp, sp_max;
    struct script_data *stack_data;
};

// future improvements coming!
class ScriptState
{
public:
    struct script_stack *stack;
    int start, end;
    int pos, state;
    int rid, oid;
    const ScriptCode *script, *new_script;
    int defsp, new_pos, new_defsp;
};

const ScriptCode *parse_script(const char *, int);
typedef struct argrec
{
    const char *name;
    union _aru
    {
        int i;
        const char *s;

        _aru() = default;
        _aru(int n) : i(n) {}
        _aru(const char *z) : s(z) {}
    } v;
} argrec_t;
int run_script_l(const ScriptCode *, int, int, int, int, argrec_t *args);
int run_script(const ScriptCode *, int, int, int);

extern
Map<std::string, int> scriptlabel_db;
extern
DMap<std::string, const ScriptCode *> userfunc_db;

void script_config_read();
void do_init_script(void);
void do_final_script(void);

extern char mapreg_txt[256];

#endif // SCRIPT_HPP