summaryrefslogtreecommitdiff
path: root/src/map/script.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-01-08 15:39:16 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-01-08 15:39:16 -0800
commit3e42921c657bc93094f0c7d96855aae9b0be5a7e (patch)
treefe74fd1c1f8b370084091f1e26aef94ad427e7b0 /src/map/script.cpp
parent8b0d596d0bfce7666e59952a6949572ab826b43c (diff)
downloadtmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.tar.gz
tmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.tar.bz2
tmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.tar.xz
tmwa-3e42921c657bc93094f0c7d96855aae9b0be5a7e.zip
Improve warnings; fix const_db.txt bug.
Diffstat (limited to 'src/map/script.cpp')
-rw-r--r--src/map/script.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 5411e59..25db80b 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -851,14 +851,21 @@ void read_constdb(void)
if (line[0] == '/' && line[1] == '/')
continue;
- std::string name;
+ char *name = nullptr;
int val;
int type = 0; // if not provided
- if (SSCANF(line, "%m[A-Za-z0-9_] %x %x", &name, &val, &type) < 2)
- continue;
- for (char& c : name)
- c = tolower(c);
- int n = add_str(name.c_str());
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+ if (sscanf(line.c_str(), "%m[A-Za-z0-9_] %i %i", &name, &val, &type) < 2)
+ {
+ free(name);
+ continue;
+ }
+#pragma GCC diagnostic pop
+ for (char *p = name; *p; ++p)
+ *p = tolower(*p);
+ int n = add_str(name);
+ free(name);
str_data[n].type = type ? ScriptCode::PARAM : ScriptCode::INT;
str_data[n].val = val;
}