diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp index fee8b98cf..174d1d000 100755 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristics.cpp @@ -518,14 +518,14 @@ float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const return result; } -InterpolationArray&& AbstractCharacteristics::getTurnRadius() const +InterpolationArray AbstractCharacteristics::getTurnRadius() const { InterpolationArray result; bool is_set = false; process(TURN_RADIUS, &result, &is_set); if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_RADIUS).c_str()); - return std::move(result); + return result; } float AbstractCharacteristics::getTurnTimeResetSteer() const @@ -538,14 +538,14 @@ float AbstractCharacteristics::getTurnTimeResetSteer() const return result; } -InterpolationArray&& AbstractCharacteristics::getTurnTimeFullSteer() const +InterpolationArray AbstractCharacteristics::getTurnTimeFullSteer() const { InterpolationArray result; bool is_set = false; process(TURN_TIME_FULL_STEER, &result, &is_set); if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_TIME_FULL_STEER).c_str()); - return std::move(result); + return result; } float AbstractCharacteristics::getEnginePower() const @@ -598,24 +598,24 @@ float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const return result; } -std::vector&& AbstractCharacteristics::getGearSwitchRatio() const +std::vector AbstractCharacteristics::getGearSwitchRatio() const { std::vector result; bool is_set = false; process(GEAR_SWITCH_RATIO, &result, &is_set); if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_SWITCH_RATIO).c_str()); - return std::move(result); + return result; } -std::vector&& AbstractCharacteristics::getGearPowerIncrease() const +std::vector AbstractCharacteristics::getGearPowerIncrease() const { std::vector result; bool is_set = false; process(GEAR_POWER_INCREASE, &result, &is_set); if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_POWER_INCREASE).c_str()); - return std::move(result); + return result; } float AbstractCharacteristics::getMass() const @@ -658,14 +658,14 @@ float AbstractCharacteristics::getWheelsRadius() const return result; } -std::vector&& AbstractCharacteristics::getWheelsPosition() const +std::vector AbstractCharacteristics::getWheelsPosition() const { std::vector result; bool is_set = false; process(WHEELS_POSITION, &result, &is_set); if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_POSITION).c_str()); - return std::move(result); + return result; } float AbstractCharacteristics::getCameraDistance() const @@ -1018,24 +1018,24 @@ float AbstractCharacteristics::getPlungerInFaceTime() const return result; } -std::vector&& AbstractCharacteristics::getStartupTime() const +std::vector AbstractCharacteristics::getStartupTime() const { std::vector result; bool is_set = false; process(STARTUP_TIME, &result, &is_set); if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_TIME).c_str()); - return std::move(result); + return result; } -std::vector&& AbstractCharacteristics::getStartupBoost() const +std::vector AbstractCharacteristics::getStartupBoost() const { std::vector result; bool is_set = false; process(STARTUP_BOOST, &result, &is_set); if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_BOOST).c_str()); - return std::move(result); + return result; } float AbstractCharacteristics::getRescueDuration() const diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp index 1e2b0ab73..fecff5da8 100755 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -205,12 +205,16 @@ public: virtual const SkiddingProperties* getSkiddingProperties() const; /** - * TODO + * The process function is the core of this characteristics system. + * Any computation of the properties should happen here and modify the + * values of the value-pointer (be sure to use the right type!) and the + * is_set parameter when the value was set by the call (and wasn't set + * before). * * \param type The characteristic that should be modified. * \param value The current value and result at the same time. * \param is_set If the current value was already set (so it can be used - * for computations. + * for computations). */ virtual void process(CharacteristicType type, Value value, bool *is_set) const; @@ -231,9 +235,9 @@ public: float getStabilityTrackConnectionAccel() const; float getStabilitySmoothFlyingImpulse() const; - InterpolationArray&& getTurnRadius() const; + InterpolationArray getTurnRadius() const; float getTurnTimeResetSteer() const; - InterpolationArray&& getTurnTimeFullSteer() const; + InterpolationArray getTurnTimeFullSteer() const; float getEnginePower() const; float getEngineMaxSpeed() const; @@ -241,15 +245,15 @@ public: float getEngineBrakeTimeIncrease() const; float getEngineMaxSpeedReverseRatio() const; - std::vector&& getGearSwitchRatio() const; - std::vector&& getGearPowerIncrease() const; + std::vector getGearSwitchRatio() const; + std::vector getGearPowerIncrease() const; float getMass() const; float getWheelsDampingRelaxation() const; float getWheelsDampingCompression() const; float getWheelsRadius() const; - std::vector&& getWheelsPosition() const; + std::vector getWheelsPosition() const; float getCameraDistance() const; float getCameraForwardUpAngle() const; @@ -295,8 +299,8 @@ public: float getPlungerFadeOutTime() const; float getPlungerInFaceTime() const; - std::vector&& getStartupTime() const; - std::vector&& getStartupBoost() const; + std::vector getStartupTime() const; + std::vector getStartupBoost() const; float getRescueDuration() const; float getRescueVertOffset() const; diff --git a/src/karts/xml_characteristics.cpp b/src/karts/xml_characteristics.cpp index 8e73cc330..56acc149b 100644 --- a/src/karts/xml_characteristics.cpp +++ b/src/karts/xml_characteristics.cpp @@ -101,8 +101,8 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ for (std::vector::const_iterator it = processors.begin(); it != processors.end(); it++) { - std::vector pair = StringUtils::split(*it,':'); - if (!pair.size() == 2) + std::vector pair = StringUtils::split(*it, ':'); + if (pair.size() != 2) Log::error("XmlCharacteristics::process", "Can't process %s: Wrong format", getName(type).c_str()); else @@ -140,7 +140,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ it != processors.end(); it++) { std::vector pair = StringUtils::split(*it,':'); - if (!pair.size() == 2) + if (pair.size() != 2) Log::error("XmlCharacteristics::process", "Can't process %s: Wrong format", getName(type).c_str()); else @@ -229,6 +229,9 @@ void XmlCharacteristics::processFloat(const std::string &processor, float *value *value += val; else if (operations[index - 1] == "-") *value -= val; + else + Log::fatal("XmlCharacteristics::processFloat", + "Unknown operator (%s)", operations[index - 1].c_str()); } *is_set = true; } diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index df2245fa9..fb1054c78 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -24,7 +24,7 @@ import sys # Input data -#FIXME is wheelPosition needed?? +#FIXME is wheelPosition needed? characteristics = """Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray) @@ -54,9 +54,6 @@ class GroupMember: self.typeC = typeC self.typeStr = typeStr - def shouldMove(self): - return self.typeC != "float" - """E.g. power(std::vector/floatVector) or speed(InterpolationArray) The default type is float""" @@ -163,10 +160,7 @@ def main(): for m in g.members: nameTitle = joinSubName(g, m, True) nameUnderscore = joinSubName(g, m, False) - if m.shouldMove(): - typeC = m.typeC + "&&" - else: - typeC = m.typeC + typeC = m.typeC print(" {0} get{1}() const;". format(typeC, nameTitle, nameUnderscore)) @@ -175,12 +169,8 @@ def main(): for m in g.members: nameTitle = joinSubName(g, m, True) nameUnderscore = joinSubName(g, m, False) - if m.shouldMove(): - typeC = m.typeC + "&&" - result = "std::move(result)" - else: - typeC = m.typeC - result = "result" + typeC = m.typeC + result = "result" print("""{3} AbstractCharacteristics::get{1}() const {{