Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-11-16 21:51:10 +0000
committerStijn Buys <ingar@osirion.org>2010-11-16 21:51:10 +0000
commit40e7cd6de7955021a8b7109cbf413e782ea95222 (patch)
tree4cbba8c8315b19cdc14e3c6c53d894ab9ee403e8 /src/model
parentb58da165c4ae841859ee7c600ec27f7207181a0e (diff)
add 'angles' key support for .map classes, added warning to depricated keys
Diffstat (limited to 'src/model')
-rw-r--r--src/model/mapfile.cc86
-rw-r--r--src/model/mapfile.h6
2 files changed, 88 insertions, 4 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 60fea03..1dbf0df 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -933,6 +933,11 @@ void MapFile::unknown_class() const
con_warn << name() << " unknown class '" << classname() << "' at line " << line() << std::endl;
}
+void MapFile::warn_depricated() const
+{
+ con_warn << name() << " depricated key '" << key() << "' for '" << classname() << "' at line " << line() << std::endl;
+}
+
Model * MapFile::load(std::string const &name)
{
// open the .map file
@@ -1022,6 +1027,7 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.in_class("func_rotate")) {
if (mapfile.got_key_float("angle", angle)) {
+
if (angle == ANGLEUP) {
mapfile.class_axis.change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
@@ -1029,14 +1035,32 @@ Model * MapFile::load(std::string const &name)
} else {
mapfile.class_axis.change_direction(angle);
}
+
+ } else if (mapfile.got_key("angles")) {
+
+ std::istringstream str(mapfile.value());
+ float yaw, pitch,roll = 0.0f;
+
+ if (str >> yaw >> pitch >> roll) {
+ mapfile.class_axis.clear();
+ mapfile.class_axis.change_direction(yaw);
+ mapfile.class_axis.change_pitch(pitch);
+ mapfile.class_axis.change_roll(roll);
+ } else {
+ mapfile.unknown_value();
+ }
+
} else if (mapfile.got_key_float("direction", angle)) {
mapfile.class_axis.change_direction(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_float("pitch", angle)) {
mapfile.class_axis.change_pitch(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_float("roll", angle)) {
mapfile.class_axis.change_roll(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_int("spawnflags", u)) {
mapfile.class_engine = spawnflag_isset(u, 4);
@@ -1154,6 +1178,7 @@ Model * MapFile::load(std::string const &name)
continue;
} else if (mapfile.got_key_float("angle", angle)) {
+
if (angle == ANGLEUP) {
tag_flare->get_axis().change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
@@ -1161,14 +1186,32 @@ Model * MapFile::load(std::string const &name)
} else {
tag_flare->get_axis().change_direction(angle);
}
+
+ } else if (mapfile.got_key("angles")) {
+
+ std::istringstream str(mapfile.value());
+ float yaw, pitch,roll = 0.0f;
+
+ if (str >> yaw >> pitch >> roll) {
+ tag_flare->get_axis().clear();
+ tag_flare->get_axis().change_direction(yaw);
+ tag_flare->get_axis().change_pitch(pitch);
+ tag_flare->get_axis().change_roll(roll);
+ } else {
+ mapfile.unknown_value();
+ }
+
} else if (mapfile.got_key_float("direction", angle)) {
tag_flare->get_axis().change_direction(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_float("pitch", angle)) {
tag_flare->get_axis().change_pitch(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_float("roll", angle)) {
tag_flare->get_axis().change_roll(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_string("cull", str)) {
@@ -1212,14 +1255,32 @@ Model * MapFile::load(std::string const &name)
} else {
tag_particles->get_axis().change_direction(angle);
}
+
+ } else if (mapfile.got_key("angles")) {
+
+ std::istringstream str(mapfile.value());
+ float yaw, pitch,roll = 0.0f;
+
+ if (str >> yaw >> pitch >> roll) {
+ tag_particles->get_axis().clear();
+ tag_particles->get_axis().change_direction(yaw);
+ tag_particles->get_axis().change_pitch(pitch);
+ tag_particles->get_axis().change_roll(roll);
+ } else {
+ mapfile.unknown_value();
+ }
+
} else if (mapfile.got_key_float("direction", angle)) {
tag_particles->get_axis().change_direction(angle);
-
+ mapfile.warn_depricated();
+
} else if (mapfile.got_key_float("pitch", angle)) {
tag_particles->get_axis().change_pitch(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_float("roll", angle)) {
tag_particles->get_axis().change_roll(angle);
+ mapfile.warn_depricated();
} else if (mapfile.got_key_int("spawnflags", u)) {
tag_particles->set_entity(spawnflag_isset(u, 2));
@@ -1293,7 +1354,6 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.classname().compare("misc_model") == 0) {
- // submodel attributes
if (mapfile.got_key_vector3f("origin", location)) {
tag_submodel->get_location().assign(location * SCALE);
continue;
@@ -1305,7 +1365,7 @@ Model * MapFile::load(std::string const &name)
}
tag_submodel->set_name(modelname);
continue;
-
+
} else if (mapfile.got_key_float("angle", angle)) {
if (angle == ANGLEUP) {
tag_submodel->get_axis().change_pitch(90.0f);
@@ -1315,6 +1375,20 @@ Model * MapFile::load(std::string const &name)
tag_submodel->get_axis().change_direction(angle);
}
+ } else if (mapfile.got_key("angles")) {
+
+ std::istringstream str(mapfile.value());
+ float yaw, pitch,roll = 0.0f;
+
+ if (str >> yaw >> pitch >> roll) {
+ tag_submodel->get_axis().clear();
+ tag_submodel->get_axis().change_direction(yaw);
+ tag_submodel->get_axis().change_pitch(pitch);
+ tag_submodel->get_axis().change_roll(roll);
+ } else {
+ mapfile.unknown_value();
+ }
+
} else if (mapfile.got_key_float("modelscale", s)) {
if (s) {
tag_submodel->set_scale(s);
@@ -1342,13 +1416,17 @@ Model * MapFile::load(std::string const &name)
continue;
} else if (mapfile.got_key_float("radius", r)) {
- tag_dock->set_radius(r * SCALE);
+ tag_dock->set_radius(r);
continue;
} else if (mapfile.got_key("angle")) {
// TODO
continue;
+ } else if (mapfile.got_key("angles")) {
+ // TODO
+ continue;
+
} else if (mapfile.got_key()) {
mapfile.unknown_key();
diff --git a/src/model/mapfile.h b/src/model/mapfile.h
index 4cea7f0..7ee47d3 100644
--- a/src/model/mapfile.h
+++ b/src/model/mapfile.h
@@ -141,11 +141,17 @@ private:
/// clear class bounding box
void clear_bbox();
+ /// print 'unkown class' warning message to the console
void unknown_class() const;
+ /// print 'unkown key' warning message to the console
void unknown_key() const;
+ /// print 'unkown value' warning message to the console
void unknown_value() const;
+
+ /// print 'depricated key' warning message to the console
+ void warn_depricated() const;
/// list of planes for the current brush
std::vector<Face *> planes;