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/grfio.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/map/grfio.cpp') diff --git a/src/map/grfio.cpp b/src/map/grfio.cpp index c5a55f5..ff73c90 100644 --- a/src/map/grfio.cpp +++ b/src/map/grfio.cpp @@ -23,16 +23,18 @@ #include "../poison.hpp" static -std::map load_resnametable() +std::map resnametable; + +bool load_resnametable(ZString filename) { - io::ReadFile in("data/resnametable.txt"); + io::ReadFile in(filename); if (!in.is_open()) { - fprintf(stderr, "Missing data/resnametable.txt"); - abort(); + FPRINTF(stderr, "Missing %s\n", filename); + return false; } - std::map out; + bool rv = true; FString line; while (in.getline(line)) { @@ -40,19 +42,20 @@ std::map load_resnametable() FString value; if (!extract(line, record<'#'>(&key, &value))) + { + PRINTF("Bad resnametable line: %s\n", line); + rv = false; continue; - out[key] = value; + } + resnametable[key] = value; } - return out; + return rv; } /// Change *.gat to *.wlk static FString grfio_resnametable(MapName rname) { - static - std::map resnametable = load_resnametable(); - return resnametable.at(rname); } -- cgit v1.2.3-60-g2f50