Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/template.cc')
-rw-r--r--src/game/base/template.cc68
1 files changed, 44 insertions, 24 deletions
diff --git a/src/game/base/template.cc b/src/game/base/template.cc
index f937e22..7327c31 100644
--- a/src/game/base/template.cc
+++ b/src/game/base/template.cc
@@ -33,6 +33,47 @@ void Template::list()
core::Info::list(template_infotype);
}
+bool Template::got_template_key(filesystem::IniFile &inifile, Template *entitytemplate)
+{
+ std::string strvalue;
+ math::Color colorvalue;
+ float floatvalue;
+
+ if (inifile.got_key_label("label", strvalue)) {
+ if (find(strvalue)) {
+ inifile.unknown_error("duplicate template '" + strvalue + "'");
+ }
+ entitytemplate->set_label(strvalue);
+ return true;
+
+ } else if (inifile.got_key_string("name", strvalue)) {
+ entitytemplate->set_name(strvalue);
+ return true;
+
+ } else if (inifile.got_key_string("model", strvalue)) {
+ entitytemplate->set_modelname(strvalue);
+ return true;
+
+ } else if (inifile.got_key_string("info", strvalue)) {
+ entitytemplate->add_text(strvalue);
+ return true;
+
+ } else if (inifile.got_key_color("color", colorvalue)) {
+ entitytemplate->set_color(colorvalue);
+ return true;
+
+ } else if (inifile.got_key_color("colorsecond", colorvalue)) {
+ entitytemplate->set_color_second(colorvalue);
+ return true;
+
+ } else if (inifile.got_key_float("radius", floatvalue)) {
+ entitytemplate->set_radius(floatvalue);
+ return true;
+ } else {
+ return false;
+ }
+}
+
bool Template::init()
{
// initialize template InfoType
@@ -52,10 +93,7 @@ bool Template::init()
size_t count = 0;
Template *entitytemplate = 0;
- std::string strvalue;
- math::Color colorvalue;
- float floatvalue;
-
+
while (inifile.getline()) {
if (inifile.got_section()) {
@@ -74,26 +112,8 @@ bool Template::init()
if (inifile.in_section("template")) {
- if (inifile.got_key_label("label", strvalue)) {
- entitytemplate->set_label(strvalue);
-
- } else if (inifile.got_key_string("name", strvalue)) {
- entitytemplate->set_name(strvalue);
-
- } else if (inifile.got_key_string("model", strvalue)) {
- entitytemplate->set_modelname(strvalue);
-
- } else if (inifile.got_key_string("info", strvalue)) {
- entitytemplate->add_text(strvalue);
-
- } else if (inifile.got_key_color("color", colorvalue)) {
- entitytemplate->set_color(colorvalue);
-
- } else if (inifile.got_key_color("colorsecond", colorvalue)) {
- entitytemplate->set_color_second(colorvalue);
-
- } else if (inifile.got_key_float("radius", floatvalue)) {
- entitytemplate->set_radius(floatvalue);
+ if (got_template_key(inifile, entitytemplate)) {
+ continue;
} else {
inifile.unkown_key();
}