summaryrefslogtreecommitdiff
path: root/src/map/script.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-01-26 14:03:20 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-01-26 14:03:20 -0800
commit3d8b6671b394ef6c4c5df3065a6123a5d6cacb93 (patch)
treed4ece86a6b1fc63349c2a24eddcd76588886241d /src/map/script.cpp
parent34f0540da418b01dd4d49f6ecf72569d3cfecfdf (diff)
downloadtmwa-3d8b6671b394ef6c4c5df3065a6123a5d6cacb93.tar.gz
tmwa-3d8b6671b394ef6c4c5df3065a6123a5d6cacb93.tar.bz2
tmwa-3d8b6671b394ef6c4c5df3065a6123a5d6cacb93.tar.xz
tmwa-3d8b6671b394ef6c4c5df3065a6123a5d6cacb93.zip
Also do db/const.txt and data/resnametable.txtv14.1.27
Diffstat (limited to 'src/map/script.cpp')
-rw-r--r--src/map/script.cpp20
1 files changed, 10 insertions, 10 deletions
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<const ScriptBuffer> 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;