summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-02-21 22:02:34 +0300
committerAndrei Karas <akaras@inbox.ru>2012-02-21 22:02:34 +0300
commitdf1e9664e176377cb8f9501d1b828ee42cd8e8f8 (patch)
treeac0e6889d454c9cee9e687c0379bc17ea4140276
parent8d60ace7ad6c9dffabdd5ed71374d82360dc2d2e (diff)
downloadmanaverse-df1e9664e176377cb8f9501d1b828ee42cd8e8f8.tar.gz
manaverse-df1e9664e176377cb8f9501d1b828ee42cd8e8f8.tar.bz2
manaverse-df1e9664e176377cb8f9501d1b828ee42cd8e8f8.tar.xz
manaverse-df1e9664e176377cb8f9501d1b828ee42cd8e8f8.zip
Fix reading float default parameters.
-rw-r--r--src/configuration.cpp52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index c4f1cc360..1ff205195 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -217,6 +217,11 @@ int Configuration::getIntValue(const std::string &key) const
defaultValue = 0;
}
}
+ else if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ {
+ defaultValue = static_cast<int>(
+ (static_cast<FloatData*>(itdef->second))->getData());
+ }
}
else
{
@@ -321,11 +326,38 @@ float Configuration::getFloatValue(const std::string &key) const
{
DefaultsData::const_iterator itdef = mDefaultsData->find(key);
- if (itdef != mDefaultsData->end() && itdef->second
- && itdef->second->getType() == VariableData::DATA_FLOAT)
+ if (itdef != mDefaultsData->end() && itdef->second)
{
- defaultValue = static_cast<float>(
- (static_cast<FloatData*>(itdef->second))->getData());
+ if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ {
+ defaultValue = static_cast<float>(
+ (static_cast<FloatData*>(itdef->second))->getData());
+ }
+ else if (itdef->second->getType()
+ == VariableData::DATA_STRING)
+ {
+ defaultValue = atof((static_cast<StringData*>(
+ itdef->second))->getData().c_str());
+ }
+ else if (itdef->second->getType()
+ == VariableData::DATA_BOOL)
+ {
+ if ((static_cast<BoolData*>(
+ itdef->second))->getData())
+ {
+ defaultValue = 1;
+ }
+ else
+ {
+ defaultValue = 0;
+ }
+ }
+ else if (itdef->second->getType()
+ == VariableData::DATA_INT)
+ {
+ defaultValue = (static_cast<IntData*>(
+ itdef->second))->getData();
+ }
}
else
{
@@ -385,6 +417,18 @@ bool Configuration::getBoolValue(const std::string &key) const
defaultValue = false;
}
}
+ if (itdef->second->getType() == VariableData::DATA_FLOAT)
+ {
+ if (static_cast<int>((static_cast<FloatData*>(
+ itdef->second))->getData()) != 0)
+ {
+ defaultValue = true;
+ }
+ else
+ {
+ defaultValue = false;
+ }
+ }
}
else
{