From 3d8b6671b394ef6c4c5df3065a6123a5d6cacb93 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 26 Jan 2014 14:03:20 -0800 Subject: Also do db/const.txt and data/resnametable.txt --- src/map/script.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/map/script.cpp') diff --git a/src/map/script.cpp b/src/map/script.cpp index 51f228f..279e541 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -689,20 +689,16 @@ void add_builtin_functions(void) } } -/*========================================== - * 定数データベースの読み込み - *------------------------------------------ - */ -static -void read_constdb(void) +bool read_constdb(ZString filename) { - io::ReadFile in("db/const.txt"); + io::ReadFile in(filename); if (!in.is_open()) { - PRINTF("can't read db/const.txt\n"); - return; + PRINTF("can't read %s\n", filename); + return false; } + bool rv = true; FString line; while (in.getline(line)) { @@ -714,11 +710,16 @@ void read_constdb(void) int type = 0; // if not provided // TODO get rid of SSCANF - this is the last serious use if (SSCANF(line, "%m[A-Za-z0-9_] %i %i", &name, &val, &type) < 2) + { + PRINTF("Bad const line: %s\n", line); + rv = false; continue; + } str_data_t *n = add_strp(name); n->type = type ? ByteCode::PARAM_ : ByteCode::INT; n->val = val; } + return rv; } std::unique_ptr parse_script(ZString src, int line) @@ -739,7 +740,6 @@ void ScriptBuffer::parse_script(ZString src, int line) if (first) { add_builtin_functions(); - read_constdb(); } first = 0; LABEL_NEXTLINE_.type = ByteCode::NOP; -- cgit v1.2.3-70-g09d2