summaryrefslogtreecommitdiff
path: root/src/map/grfio.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/grfio.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/grfio.cpp')
-rw-r--r--src/map/grfio.cpp23
1 files changed, 13 insertions, 10 deletions
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<MapName, FString> load_resnametable()
+std::map<MapName, FString> 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<MapName, FString> out;
+ bool rv = true;
FString line;
while (in.getline(line))
{
@@ -40,19 +42,20 @@ std::map<MapName, FString> 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<MapName, FString> resnametable = load_resnametable();
-
return resnametable.at(rname);
}