diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-01-08 15:39:16 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-01-08 15:39:16 -0800 |
commit | 3e42921c657bc93094f0c7d96855aae9b0be5a7e (patch) | |
tree | fe74fd1c1f8b370084091f1e26aef94ad427e7b0 /src/map/script.cpp | |
parent | 8b0d596d0bfce7666e59952a6949572ab826b43c (diff) | |
download | tmwa-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.cpp | 19 |
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; } |