Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2014-12-25 15:58:24 +0000
committerStijn Buys <ingar@osirion.org>2014-12-25 15:58:24 +0000
commit8f393ff70e60172c632efc81694433568df2862b (patch)
treeac87596d59ccf27dff0896c97e410643d21185bf /src/core/parser.cc
parent8f28c82e2fb26b453a2cfe976e48f74d97d6388a (diff)
Added a core::Level type, added a level attribute to core::Entity and core::Info, updated core::Player to use the new type.
Diffstat (limited to 'src/core/parser.cc')
-rw-r--r--src/core/parser.cc138
1 files changed, 96 insertions, 42 deletions
diff --git a/src/core/parser.cc b/src/core/parser.cc
index a260c19..4e471aa 100644
--- a/src/core/parser.cc
+++ b/src/core/parser.cc
@@ -17,9 +17,11 @@ Info *get_entity_info(Entity *entity)
{
Info *info = Info::find(entity->info());
- if (!info) {
+ if (!info)
+ {
std::string labelstr;
- if (entity->zone()) {
+ if (entity->zone())
+ {
labelstr.append(entity->zone()->label());
labelstr += ':';
}
@@ -34,7 +36,9 @@ Info *get_entity_info(Entity *entity)
bool Parser::got_entity_key(filesystem::IniFile &inifile, Entity *entity)
{
if (!entity)
+ {
return false;
+ }
math::Vector3f v;
math::Color color;
@@ -47,138 +51,188 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, Entity *entity)
bool blnval;
- if (inifile.got_key_string("shape", shapename)) {
-
- if (shapename.compare("axis") == 0) {
+ if (inifile.got_key_string("shape", shapename))
+ {
+ if (shapename.compare("axis") == 0)
+ {
entity->set_shape(core::Entity::Axis);
return true;
- } else if (shapename.compare("cube") == 0) {
+ } else if (shapename.compare("cube") == 0)
+ {
entity->set_shape(core::Entity::Cube);
return true;
- } else if (shapename.compare("diamond") == 0) {
+ } else if (shapename.compare("diamond") == 0)
+ {
entity->set_shape(core::Entity::Diamond);
return true;
- } else if (shapename.compare("sphere") == 0) {
+ } else if (shapename.compare("sphere") == 0)
+ {
entity->set_shape(core::Entity::Sphere);
return true;
- } else {
+ } else
+ {
con_warn << inifile.name() << " unknown shape '" << shapename << "' at line " << inifile.line() << std::endl;
return false;
}
- } else if (inifile.got_key_string("info", strval)) {
+ } else if (inifile.got_key_string("info", strval))
+ {
Info *info = get_entity_info(entity);
info->add_text(strval);
return true;
- } else if (inifile.got_key_string("infoname", strval)) {
+ } else if (inifile.got_key_string("infoname", strval))
+ {
Info *info = get_entity_info(entity);
info->set_name(strval);
return true;
- } else if (inifile.got_key_label("label", strval)) {
+ } else if (inifile.got_key_label("label", strval))
+ {
entity->set_label(strval);
return true;
- } else if (inifile.got_key_string("name", strval)) {
+ } else if (inifile.got_key_string("name", strval))
+ {
entity->set_name(strval);
return true;
+
+ } else if (inifile.got_key("level"))
+ {
+ Level level;
+ std::istringstream str(inifile.value());
+ if (str >> level)
+ {
+ entity->set_level(level);
+ } else
+ {
+ inifile.unknown_value();
+ }
- } else if (inifile.got_key_string("model", strval)) {
+ } else if (inifile.got_key_string("model", strval))
+ {
entity->set_modelname(strval);
return true;
- } else if (inifile.got_key_bool("showonmap", blnval)) {
+ } else if (inifile.got_key_bool("showonmap", blnval))
+ {
if (blnval)
+ {
entity->set_flag(Entity::ShowOnMap);
- else
+ } else
+ {
entity->unset_flag(Entity::ShowOnMap);
+ }
return true;
- } else if (inifile.got_key_bool("nonsolid", blnval)) {
+ } else if (inifile.got_key_bool("nonsolid", blnval))
+ {
if (blnval)
+ {
entity->set_flag(Entity::NonSolid);
- else
+ } else
+ {
entity->unset_flag(Entity::NonSolid);
+ }
return true;
- } else if (inifile.got_key_float("angle", yaw)) {
-
- if (yaw == model::ANGLEUP) {
+ } else if (inifile.got_key_float("angle", yaw))
+ {
+ if (yaw == model::ANGLEUP)
+ {
entity->get_axis().change_pitch(-90.0f);
- } else if (yaw == model::ANGLEDOWN) {
+ } else if (yaw == model::ANGLEDOWN)
+ {
entity->get_axis().change_pitch(90.0f);
- } else {
+ } else
+ {
entity->get_axis().change_direction(yaw);
}
return true;
- } else if (inifile.got_key("angles")) {
-
+ } else if (inifile.got_key("angles"))
+ {
std::istringstream str(inifile.value());
- if (str >> pitch >> yaw >> roll) {
+ if (str >> pitch >> yaw >> roll)
+ {
entity->get_axis().assign(yaw, pitch, roll);
- } else {
+ } else
+ {
inifile.unknown_value();
}
return true;
- } else if (inifile.got_key_angle("yaw", yaw)) {
+ } else if (inifile.got_key_angle("yaw", yaw))
+ {
entity->get_axis().change_direction(yaw);
return true;
- } else if (inifile.got_key_angle("pitch", pitch)) {
+ } else if (inifile.got_key_angle("pitch", pitch))
+ {
entity->get_axis().change_pitch(-pitch);
return true;
- } else if (inifile.got_key_angle("roll", roll)) {
+ } else if (inifile.got_key_angle("roll", roll))
+ {
entity->get_axis().change_roll(-roll);
return true;
- } else if (inifile.got_key_angle("radius", f)) {
+ } else if (inifile.got_key_angle("radius", f))
+ {
entity->set_radius(f);
return true;
- } else if (inifile.got_key_vector3f("location", v)) {
+ } else if (inifile.got_key_vector3f("location", v))
+ {
entity->get_location().assign(v);
return true;
- } else if (inifile.got_key_color("colorsecond", color)) {
+ } else if (inifile.got_key_color("colorsecond", color))
+ {
entity->get_color_second().assign(color);
return true;
- } else if (inifile.got_key_color("color", color)) {
+ } else if (inifile.got_key_color("color", color))
+ {
entity->get_color().assign(color);
return true;
}
// special globe keys
- if (entity->type() == Entity::Globe) {
+ if (entity->type() == Entity::Globe)
+ {
EntityGlobe *globe = static_cast<EntityGlobe *>(entity);
- if (inifile.got_key_string("texture", strval)) {
+ if (inifile.got_key_string("texture", strval))
+ {
globe->set_texturename(strval);
return true;
- } else if (inifile.got_key_string("corona", strval)) {
+ } else if (inifile.got_key_string("corona", strval))
+ {
globe->set_coronaname(strval);
return true;
- } else if (inifile.got_key_string("rings", strval)) {
+ } else if (inifile.got_key_string("rings", strval))
+ {
globe->set_ringsname(strval);
return true;
- } else if (inifile.got_key_float("rotationspeed", f)) {
+ } else if (inifile.got_key_float("rotationspeed", f))
+ {
globe->set_rotationspeed(f);
return true;
- } else if (inifile.got_key_bool("bright", blnval)) {
- if (blnval) {
+ } else if (inifile.got_key_bool("bright", blnval))
+ {
+ if (blnval)
+ {
globe->set_flag(core::Entity::Bright);
- } else {
+ } else
+ {
globe->unset_flag(core::Entity::Bright);
}
return true;