From af5c44f97acf333a3c24467f6ccc7a83aea4a2fb Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 27 Dec 2008 12:42:25 +0000 Subject: improved map loader error messages --- src/model/map.cc | 31 ++++++++++++++++++++++--------- src/model/map.h | 7 +++++++ 2 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src/model') diff --git a/src/model/map.cc b/src/model/map.cc index 549abff..955410f 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -802,6 +802,21 @@ void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type) model->add_group(group); } +void Map::unknown_value() const +{ + con_warn << name() << " unknown value '" << value() << "' for '" << classname() << ":" << key() << "' at line " << line() << std::endl; +} + +void Map::unknown_key() const +{ + con_warn << name() << " unknown key '" << classname() << ":" << key() << "' at line " << line() << std::endl; +} + +void Map::unknown_class() const +{ + con_warn << name() << " unknown class '" << classname() << "' at line " << line() << std::endl; +} + Model * Map::load(std::string const &name) { // open the .map file @@ -849,7 +864,7 @@ Model * Map::load(std::string const &name) continue; } else if (mapfile.got_key()) { - con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; + mapfile.unknown_key(); } @@ -899,7 +914,7 @@ Model * Map::load(std::string const &name) continue; } else if (mapfile.got_key()) { - con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; + mapfile.unknown_key(); } } else if (mapfile.got_classend()) { @@ -944,7 +959,7 @@ Model * Map::load(std::string const &name) continue; } else if (mapfile.got_key()) { - con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; + mapfile.unknown_key(); } @@ -969,7 +984,7 @@ Model * Map::load(std::string const &name) continue; } else if (mapfile.got_key()) { - con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; + mapfile.unknown_key(); } @@ -1042,7 +1057,7 @@ Model * Map::load(std::string const &name) flare->flare_axis.change_roll(angle); } else if (mapfile.got_key()) { - con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; + mapfile.unknown_key(); } } else if (mapfile.got_classname("fx_particles")) { @@ -1084,12 +1099,10 @@ Model * Map::load(std::string const &name) particles->particles_radius *= LIGHTSCALE; */ } else if (mapfile.got_key()) { - con_warn << "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; + mapfile.unknown_key(); } - } else if (mapfile.got_classname()) { - - con_warn << "Unkown class " << mapfile.classname() << std::endl; + mapfile.unknown_class(); } } diff --git a/src/model/map.h b/src/model/map.h index 86bada6..b46be7c 100644 --- a/src/model/map.h +++ b/src/model/map.h @@ -142,9 +142,16 @@ private: /// clear class bounding box void clear_bbox(); + + void unknown_class() const; + + void unknown_key() const; + + void unknown_value() const; /// list of planes for the current brush std::vector planes; + std::string classname_current; std::string key_current; -- cgit v1.2.3