Try to follow coding style guidelines more
This commit is contained in:
parent
5e6e85ab79
commit
4a9bc60e93
@ -27,18 +27,22 @@ AbstractCharacteristic::AbstractCharacteristic()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const SkiddingProperties* AbstractCharacteristic::getSkiddingProperties() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
} // getSkiddingProperties
|
||||
|
||||
void AbstractCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const
|
||||
// ----------------------------------------------------------------------------
|
||||
void AbstractCharacteristic::process(CharacteristicType type, Value value,
|
||||
bool *is_set) const
|
||||
{
|
||||
Log::warn("AbstractCharacteristic", "This type does not do anything");
|
||||
}
|
||||
} // process
|
||||
|
||||
|
||||
AbstractCharacteristic::ValueType AbstractCharacteristic::getType(CharacteristicType type)
|
||||
// ----------------------------------------------------------------------------
|
||||
AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
|
||||
CharacteristicType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -220,11 +224,12 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(Characteristic
|
||||
return TYPE_FLOAT;
|
||||
|
||||
/* <characteristics-end getProp1> */
|
||||
}
|
||||
} // switch (type)
|
||||
Log::fatal("AbstractCharacteristic::getType", "Unknown type");
|
||||
return TYPE_FLOAT;
|
||||
}
|
||||
} // getType
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string AbstractCharacteristic::getName(CharacteristicType type)
|
||||
{
|
||||
switch (type)
|
||||
@ -406,11 +411,12 @@ std::string AbstractCharacteristic::getName(CharacteristicType type)
|
||||
return "SLIPSTREAM_FADE_OUT_TIME";
|
||||
|
||||
/* <characteristics-end getProp2> */
|
||||
}
|
||||
} // switch (type)
|
||||
Log::error("AbstractCharacteristic::getName", "Unknown type");
|
||||
return "Unknown type";
|
||||
}
|
||||
} // getName
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Script-generated content generated by tools/create_kart_properties.py getter
|
||||
// Please don't change the following tag. It will be automatically detected
|
||||
// by the script and replace the contained content.
|
||||
|
@ -27,6 +27,7 @@ CachedCharacteristic::CachedCharacteristic(const AbstractCharacteristic *origin)
|
||||
updateSource();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CachedCharacteristic::~CachedCharacteristic()
|
||||
{
|
||||
// Delete all not-null values
|
||||
@ -50,8 +51,9 @@ CachedCharacteristic::~CachedCharacteristic()
|
||||
v.content = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ~CachedCharacteristic
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CachedCharacteristic::updateSource()
|
||||
{
|
||||
for (int i = 0; i < CHARACTERISTIC_COUNT; i++)
|
||||
@ -137,17 +139,19 @@ void CachedCharacteristic::updateSource()
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // switch (type)
|
||||
} // foreach characteristic
|
||||
} // updateSource
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const SkiddingProperties* CachedCharacteristic::getSkiddingProperties() const
|
||||
{
|
||||
return m_origin->getSkiddingProperties();
|
||||
}
|
||||
} // getSkiddingProperties
|
||||
|
||||
void CachedCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const
|
||||
// ----------------------------------------------------------------------------
|
||||
void CachedCharacteristic::process(CharacteristicType type, Value value,
|
||||
bool *is_set) const
|
||||
{
|
||||
void *v = m_values[type].content;
|
||||
if (v)
|
||||
@ -166,5 +170,5 @@ void CachedCharacteristic::process(CharacteristicType type, Value value, bool *i
|
||||
}
|
||||
*is_set = true;
|
||||
}
|
||||
}
|
||||
} // process
|
||||
|
||||
|
@ -18,11 +18,13 @@
|
||||
|
||||
#include "karts/combined_characteristic.hpp"
|
||||
|
||||
void CombinedCharacteristic::addCharacteristic(const AbstractCharacteristic *characteristic)
|
||||
void CombinedCharacteristic::addCharacteristic(
|
||||
const AbstractCharacteristic *characteristic)
|
||||
{
|
||||
m_childs.push_back(characteristic);
|
||||
}
|
||||
} // addCharacteristic
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const SkiddingProperties* CombinedCharacteristic::getSkiddingProperties() const
|
||||
{
|
||||
for (const AbstractCharacteristic *characteristic : m_childs)
|
||||
@ -32,11 +34,13 @@ const SkiddingProperties* CombinedCharacteristic::getSkiddingProperties() const
|
||||
return skid;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
} // getSkiddingProperties
|
||||
|
||||
void CombinedCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const
|
||||
// ----------------------------------------------------------------------------
|
||||
void CombinedCharacteristic::process(CharacteristicType type, Value value,
|
||||
bool *is_set) const
|
||||
{
|
||||
for (const AbstractCharacteristic *characteristic : m_childs)
|
||||
characteristic->process(type, value, is_set);
|
||||
}
|
||||
} // process
|
||||
|
||||
|
@ -29,9 +29,11 @@ XmlCharacteristic::XmlCharacteristic(const XMLNode *node) :
|
||||
{
|
||||
if (node)
|
||||
load(node);
|
||||
}
|
||||
} // XmlCharacteristic constructor
|
||||
|
||||
void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const
|
||||
// ----------------------------------------------------------------------------
|
||||
void XmlCharacteristic::process(CharacteristicType type, Value value,
|
||||
bool *is_set) const
|
||||
{
|
||||
if (m_values[type].empty())
|
||||
// That value was not changed in this configuration
|
||||
@ -133,12 +135,14 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s
|
||||
float val;
|
||||
processFloat(pair[1], &val, is_set);
|
||||
value.ia->setY(i, val);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (!*is_set)
|
||||
{
|
||||
Log::error("XmlCharacteristic::process", "Can't process %s",
|
||||
pair[1].c_str());
|
||||
Log::error("XmlCharacteristic::process",
|
||||
"Can't process %s",
|
||||
pair[1].c_str());
|
||||
value.fv->clear();
|
||||
break;
|
||||
}
|
||||
@ -154,7 +158,8 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
// It's not yet set, so we will the current content
|
||||
shouldReplace = true;
|
||||
|
||||
@ -193,11 +198,14 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log::fatal("XmlCharacteristic::process", "Unknown type for %s", getName(type).c_str());
|
||||
Log::fatal("XmlCharacteristic::process", "Unknown type for %s",
|
||||
getName(type).c_str());
|
||||
}
|
||||
}
|
||||
} // process
|
||||
|
||||
void XmlCharacteristic::processFloat(const std::string &processor, float *value, bool *is_set)
|
||||
// ----------------------------------------------------------------------------
|
||||
void XmlCharacteristic::processFloat(const std::string &processor, float *value,
|
||||
bool *is_set)
|
||||
{
|
||||
// Split the string by operators
|
||||
static const std::string operators = "*/+-";
|
||||
@ -267,9 +275,11 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value,
|
||||
"Unknown operator (%s)", operations[index - 1].c_str());
|
||||
}
|
||||
*is_set = true;
|
||||
}
|
||||
} // processFloat
|
||||
|
||||
void XmlCharacteristic::processBool(const std::string &processor, bool *value, bool *is_set)
|
||||
// ----------------------------------------------------------------------------
|
||||
void XmlCharacteristic::processBool(const std::string &processor, bool *value,
|
||||
bool *is_set)
|
||||
{
|
||||
if (processor == "true")
|
||||
{
|
||||
@ -282,9 +292,11 @@ void XmlCharacteristic::processBool(const std::string &processor, bool *value, b
|
||||
*is_set = true;
|
||||
}
|
||||
else
|
||||
Log::error("XmlCharacteristic::processBool", "Can't parse %s: Not a bool", processor.c_str());
|
||||
}
|
||||
Log::error("XmlCharacteristic::processBool", "Can't parse %s: Not a bool",
|
||||
processor.c_str());
|
||||
} // processBool
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void XmlCharacteristic::load(const XMLNode *node)
|
||||
{
|
||||
// Script-generated content generated by tools/create_kart_properties.py getXml
|
||||
@ -462,5 +474,5 @@ void XmlCharacteristic::load(const XMLNode *node)
|
||||
|
||||
|
||||
/* <characteristics-end getXml> */
|
||||
}
|
||||
} // load
|
||||
|
||||
|
@ -183,15 +183,17 @@ Operations:
|
||||
typeC = m.typeC
|
||||
result = "result"
|
||||
|
||||
print("""{3} AbstractCharacteristic::get{1}() const
|
||||
print("""// ----------------------------------------------------------------------------
|
||||
{3} AbstractCharacteristic::get{1}() const
|
||||
{{
|
||||
{0} result;
|
||||
bool is_set = false;
|
||||
process({2}, &result, &is_set);
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName({2}).c_str());
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName({2}).c_str());
|
||||
return {4};
|
||||
}}
|
||||
}} // get{1}
|
||||
""".format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result))
|
||||
elif task == "getProp1":
|
||||
for g in groups:
|
||||
@ -214,7 +216,8 @@ Operations:
|
||||
for m in g.members:
|
||||
nameUnderscore = joinSubName(g, m, False)
|
||||
nameMinus = "-".join(toList(m.name))
|
||||
print(" sub_node->get(\"{0}\", &m_values[{1}]);".
|
||||
print(""" sub_node->get(\"{0}\",
|
||||
&m_values[{1}]);""".
|
||||
format(nameMinus, nameUnderscore.upper()))
|
||||
print(" }\n")
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user