summaryrefslogtreecommitdiff
path: root/src/map/magic-interpreter-parser.ypp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-01-25 09:43:09 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-01-25 10:14:44 -0800
commit34f0540da418b01dd4d49f6ecf72569d3cfecfdf (patch)
treebf7c4623b0d794e4db8c72b0906bb40807d62ba8 /src/map/magic-interpreter-parser.ypp
parent9a4c3a44476f3306a8deed8a836e8fbc25ceb55f (diff)
downloadtmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.gz
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.bz2
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.xz
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.zip
Implement unified config parsing (mostly)
Diffstat (limited to 'src/map/magic-interpreter-parser.ypp')
-rw-r--r--src/map/magic-interpreter-parser.ypp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/map/magic-interpreter-parser.ypp b/src/map/magic-interpreter-parser.ypp
index d59519a..0e03afb 100644
--- a/src/map/magic-interpreter-parser.ypp
+++ b/src/map/magic-interpreter-parser.ypp
@@ -1381,16 +1381,17 @@ void INTERN_ASSERT(ZString name, int id)
{
int zid = intern_id(name);
if (zid != id)
+ {
FPRINTF(stderr,
"[magic-conf] INTERNAL ERROR: Builtin special var %s interned to %d, not %d as it should be!\n",
name, zid, id);
- error_flag = 1;
+ error_flag = 1;
+ }
}
extern FILE *magic_frontend_in;
-// must be called after itemdb initialisation
-int magic_init(const char *conffile)
+bool magic_init0()
{
error_flag = 0;
@@ -1404,18 +1405,24 @@ int magic_init(const char *conffile)
INTERN_ASSERT("script_target", VAR_SCRIPTTARGET);
INTERN_ASSERT("location", VAR_LOCATION);
- magic_frontend_in = fopen(conffile, "r");
+ return !error_flag;
+}
+
+// must be called after itemdb initialisation
+bool magic_init1(ZString conffile)
+{
+ magic_frontend_in = fopen(conffile.c_str(), "r");
if (!magic_frontend_in)
{
FPRINTF(stderr, "[magic-conf] Magic configuration file `%s' not found -> no magic.\n", conffile);
- return 0;
+ return false;
}
magic_frontend_parse();
PRINTF("[magic-conf] Magic initialised. %zu spells, %zu teleport anchors.\n",
magic_conf.spells_by_name.size(), magic_conf.anchors_by_name.size());
- return error_flag;
+ return !error_flag;
}
extern int magic_frontend_lineno;