From 17b775959ce577ddab79f256325d70f4d95ac3c0 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 19 Apr 2015 00:57:55 +0200 Subject: [PATCH] Change reference to pointer --- src/karts/abstract_characteristics.cpp | 194 +++++++++++-------------- src/karts/abstract_characteristics.hpp | 2 +- src/karts/cached_characteristics.cpp | 10 +- src/karts/cached_characteristics.hpp | 2 +- src/karts/combined_characteristics.cpp | 2 +- src/karts/combined_characteristics.hpp | 2 +- src/karts/xml_characteristics.cpp | 5 +- src/karts/xml_characteristics.hpp | 4 +- tools/create_kart_properties.py | 58 +++----- 9 files changed, 119 insertions(+), 160 deletions(-) diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp index c2d03744f..8dd0cde7f 100755 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristics.cpp @@ -32,7 +32,7 @@ const SkiddingProperties* AbstractCharacteristics::getSkiddingProperties() const return nullptr; } -void AbstractCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const +void AbstractCharacteristics::process(CharacteristicType type, Value value, bool *isSet) const { Log::warn("AbstractCharacteristics", "This type does not do anything"); } @@ -228,7 +228,7 @@ float AbstractCharacteristics::getSuspensionStiffness() const { float result; bool isSet = false; - process(SUSPENSION_STIFFNESS, &result, isSet); + process(SUSPENSION_STIFFNESS, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_STIFFNESS"); return result; @@ -238,7 +238,7 @@ float AbstractCharacteristics::getSuspensionRest() const { float result; bool isSet = false; - process(SUSPENSION_REST, &result, isSet); + process(SUSPENSION_REST, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_REST"); return result; @@ -248,7 +248,7 @@ float AbstractCharacteristics::getSuspensionTravelCm() const { float result; bool isSet = false; - process(SUSPENSION_TRAVEL_CM, &result, isSet); + process(SUSPENSION_TRAVEL_CM, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_TRAVEL_CM"); return result; @@ -258,7 +258,7 @@ float AbstractCharacteristics::getSuspensionExpSpringResponse() const { float result; bool isSet = false; - process(SUSPENSION_EXP_SPRING_RESPONSE, &result, isSet); + process(SUSPENSION_EXP_SPRING_RESPONSE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_EXP_SPRING_RESPONSE"); return result; @@ -268,18 +268,17 @@ float AbstractCharacteristics::getSuspensionMaxForce() const { float result; bool isSet = false; - process(SUSPENSION_MAX_FORCE, &result, isSet); + process(SUSPENSION_MAX_FORCE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_MAX_FORCE"); return result; } - float AbstractCharacteristics::getStabilityRollInfluence() const { float result; bool isSet = false; - process(STABILITY_ROLL_INFLUENCE, &result, isSet); + process(STABILITY_ROLL_INFLUENCE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_ROLL_INFLUENCE"); return result; @@ -289,7 +288,7 @@ float AbstractCharacteristics::getStabilityChassisLinearDamping() const { float result; bool isSet = false; - process(STABILITY_CHASSIS_LINEAR_DAMPING, &result, isSet); + process(STABILITY_CHASSIS_LINEAR_DAMPING, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_CHASSIS_LINEAR_DAMPING"); return result; @@ -299,7 +298,7 @@ float AbstractCharacteristics::getStabilityChassisAngularDamping() const { float result; bool isSet = false; - process(STABILITY_CHASSIS_ANGULAR_DAMPING, &result, isSet); + process(STABILITY_CHASSIS_ANGULAR_DAMPING, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_CHASSIS_ANGULAR_DAMPING"); return result; @@ -309,7 +308,7 @@ float AbstractCharacteristics::getStabilityDownwardImpulseFactor() const { float result; bool isSet = false; - process(STABILITY_DOWNWARD_IMPULSE_FACTOR, &result, isSet); + process(STABILITY_DOWNWARD_IMPULSE_FACTOR, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_DOWNWARD_IMPULSE_FACTOR"); return result; @@ -319,7 +318,7 @@ float AbstractCharacteristics::getStabilityTrackConnectionAccel() const { float result; bool isSet = false; - process(STABILITY_TRACK_CONNECTION_ACCEL, &result, isSet); + process(STABILITY_TRACK_CONNECTION_ACCEL, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_TRACK_CONNECTION_ACCEL"); return result; @@ -329,18 +328,17 @@ float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const { float result; bool isSet = false; - process(STABILITY_SMOOTH_FLYING_IMPULSE, &result, isSet); + process(STABILITY_SMOOTH_FLYING_IMPULSE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_SMOOTH_FLYING_IMPULSE"); return result; } - InterpolationArray&& AbstractCharacteristics::getTurnRadius() const { InterpolationArray result; bool isSet = false; - process(TURN_RADIUS, &result, isSet); + process(TURN_RADIUS, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_RADIUS"); return std::move(result); @@ -350,7 +348,7 @@ float AbstractCharacteristics::getTurnTimeResetSteer() const { float result; bool isSet = false; - process(TURN_TIME_RESET_STEER, &result, isSet); + process(TURN_TIME_RESET_STEER, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_TIME_RESET_STEER"); return result; @@ -360,18 +358,17 @@ InterpolationArray&& AbstractCharacteristics::getTurnTimeFullSteer() const { InterpolationArray result; bool isSet = false; - process(TURN_TIME_FULL_STEER, &result, isSet); + process(TURN_TIME_FULL_STEER, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_TIME_FULL_STEER"); return std::move(result); } - float AbstractCharacteristics::getEnginePower() const { float result; bool isSet = false; - process(ENGINE_POWER, &result, isSet); + process(ENGINE_POWER, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_POWER"); return result; @@ -381,7 +378,7 @@ float AbstractCharacteristics::getEngineMaxSpeed() const { float result; bool isSet = false; - process(ENGINE_MAX_SPEED, &result, isSet); + process(ENGINE_MAX_SPEED, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_MAX_SPEED"); return result; @@ -391,7 +388,7 @@ float AbstractCharacteristics::getEngineBrakeFactor() const { float result; bool isSet = false; - process(ENGINE_BRAKE_FACTOR, &result, isSet); + process(ENGINE_BRAKE_FACTOR, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_BRAKE_FACTOR"); return result; @@ -401,7 +398,7 @@ float AbstractCharacteristics::getEngineBrakeTimeIncrease() const { float result; bool isSet = false; - process(ENGINE_BRAKE_TIME_INCREASE, &result, isSet); + process(ENGINE_BRAKE_TIME_INCREASE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_BRAKE_TIME_INCREASE"); return result; @@ -411,18 +408,17 @@ float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const { float result; bool isSet = false; - process(ENGINE_MAX_SPEED_REVERSE_RATIO, &result, isSet); + process(ENGINE_MAX_SPEED_REVERSE_RATIO, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_MAX_SPEED_REVERSE_RATIO"); return result; } - std::vector&& AbstractCharacteristics::getGearSwitchRatio() const { std::vector result; bool isSet = false; - process(GEAR_SWITCH_RATIO, &result, isSet); + process(GEAR_SWITCH_RATIO, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic GEAR_SWITCH_RATIO"); return std::move(result); @@ -432,29 +428,27 @@ std::vector&& AbstractCharacteristics::getGearPowerIncrease() const { std::vector result; bool isSet = false; - process(GEAR_POWER_INCREASE, &result, isSet); + process(GEAR_POWER_INCREASE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic GEAR_POWER_INCREASE"); return std::move(result); } - float AbstractCharacteristics::getMass() const { float result; bool isSet = false; - process(MASS, &result, isSet); + process(MASS, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic MASS"); return result; } - float AbstractCharacteristics::getWheelsDampingRelaxation() const { float result; bool isSet = false; - process(WHEELS_DAMPING_RELAXATION, &result, isSet); + process(WHEELS_DAMPING_RELAXATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_DAMPING_RELAXATION"); return result; @@ -464,7 +458,7 @@ float AbstractCharacteristics::getWheelsDampingCompression() const { float result; bool isSet = false; - process(WHEELS_DAMPING_COMPRESSION, &result, isSet); + process(WHEELS_DAMPING_COMPRESSION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_DAMPING_COMPRESSION"); return result; @@ -474,7 +468,7 @@ float AbstractCharacteristics::getWheelsRadius() const { float result; bool isSet = false; - process(WHEELS_RADIUS, &result, isSet); + process(WHEELS_RADIUS, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_RADIUS"); return result; @@ -484,18 +478,17 @@ std::vector&& AbstractCharacteristics::getWheelsPosition() const { std::vector result; bool isSet = false; - process(WHEELS_POSITION, &result, isSet); + process(WHEELS_POSITION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_POSITION"); return std::move(result); } - float AbstractCharacteristics::getCameraDistance() const { float result; bool isSet = false; - process(CAMERA_DISTANCE, &result, isSet); + process(CAMERA_DISTANCE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_DISTANCE"); return result; @@ -505,7 +498,7 @@ float AbstractCharacteristics::getCameraForwardUpAngle() const { float result; bool isSet = false; - process(CAMERA_FORWARD_UP_ANGLE, &result, isSet); + process(CAMERA_FORWARD_UP_ANGLE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_FORWARD_UP_ANGLE"); return result; @@ -515,29 +508,27 @@ float AbstractCharacteristics::getCameraBackwardUpAngle() const { float result; bool isSet = false; - process(CAMERA_BACKWARD_UP_ANGLE, &result, isSet); + process(CAMERA_BACKWARD_UP_ANGLE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_BACKWARD_UP_ANGLE"); return result; } - float AbstractCharacteristics::getJumpAnimationTime() const { float result; bool isSet = false; - process(JUMP_ANIMATION_TIME, &result, isSet); + process(JUMP_ANIMATION_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic JUMP_ANIMATION_TIME"); return result; } - float AbstractCharacteristics::getLeanMax() const { float result; bool isSet = false; - process(LEAN_MAX, &result, isSet); + process(LEAN_MAX, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic LEAN_MAX"); return result; @@ -547,18 +538,17 @@ float AbstractCharacteristics::getLeanSpeed() const { float result; bool isSet = false; - process(LEAN_SPEED, &result, isSet); + process(LEAN_SPEED, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic LEAN_SPEED"); return result; } - float AbstractCharacteristics::getAnvilDuration() const { float result; bool isSet = false; - process(ANVIL_DURATION, &result, isSet); + process(ANVIL_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_DURATION"); return result; @@ -568,7 +558,7 @@ float AbstractCharacteristics::getAnvilWeight() const { float result; bool isSet = false; - process(ANVIL_WEIGHT, &result, isSet); + process(ANVIL_WEIGHT, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_WEIGHT"); return result; @@ -578,18 +568,17 @@ float AbstractCharacteristics::getAnvilSpeedFactor() const { float result; bool isSet = false; - process(ANVIL_SPEED_FACTOR, &result, isSet); + process(ANVIL_SPEED_FACTOR, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_SPEED_FACTOR"); return result; } - float AbstractCharacteristics::getParachuteFriction() const { float result; bool isSet = false; - process(PARACHUTE_FRICTION, &result, isSet); + process(PARACHUTE_FRICTION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_FRICTION"); return result; @@ -599,7 +588,7 @@ float AbstractCharacteristics::getParachuteDuration() const { float result; bool isSet = false; - process(PARACHUTE_DURATION, &result, isSet); + process(PARACHUTE_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_DURATION"); return result; @@ -609,7 +598,7 @@ float AbstractCharacteristics::getParachuteDurationOther() const { float result; bool isSet = false; - process(PARACHUTE_DURATION_OTHER, &result, isSet); + process(PARACHUTE_DURATION_OTHER, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_DURATION_OTHER"); return result; @@ -619,7 +608,7 @@ float AbstractCharacteristics::getParachuteLboundFranction() const { float result; bool isSet = false; - process(PARACHUTE_LBOUND_FRANCTION, &result, isSet); + process(PARACHUTE_LBOUND_FRANCTION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_LBOUND_FRANCTION"); return result; @@ -629,7 +618,7 @@ float AbstractCharacteristics::getParachuteUboundFranction() const { float result; bool isSet = false; - process(PARACHUTE_UBOUND_FRANCTION, &result, isSet); + process(PARACHUTE_UBOUND_FRANCTION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_UBOUND_FRANCTION"); return result; @@ -639,18 +628,17 @@ float AbstractCharacteristics::getParachuteMaxSpeed() const { float result; bool isSet = false; - process(PARACHUTE_MAX_SPEED, &result, isSet); + process(PARACHUTE_MAX_SPEED, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_MAX_SPEED"); return result; } - float AbstractCharacteristics::getBubblegumDuration() const { float result; bool isSet = false; - process(BUBBLEGUM_DURATION, &result, isSet); + process(BUBBLEGUM_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_DURATION"); return result; @@ -660,7 +648,7 @@ float AbstractCharacteristics::getBubblegumSpeedFraction() const { float result; bool isSet = false; - process(BUBBLEGUM_SPEED_FRACTION, &result, isSet); + process(BUBBLEGUM_SPEED_FRACTION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_SPEED_FRACTION"); return result; @@ -670,7 +658,7 @@ float AbstractCharacteristics::getBubblegumTorque() const { float result; bool isSet = false; - process(BUBBLEGUM_TORQUE, &result, isSet); + process(BUBBLEGUM_TORQUE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_TORQUE"); return result; @@ -680,7 +668,7 @@ float AbstractCharacteristics::getBubblegumFadeInTime() const { float result; bool isSet = false; - process(BUBBLEGUM_FADE_IN_TIME, &result, isSet); + process(BUBBLEGUM_FADE_IN_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_FADE_IN_TIME"); return result; @@ -690,18 +678,17 @@ float AbstractCharacteristics::getBubblegumShieldDuration() const { float result; bool isSet = false; - process(BUBBLEGUM_SHIELD_DURATION, &result, isSet); + process(BUBBLEGUM_SHIELD_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_SHIELD_DURATION"); return result; } - float AbstractCharacteristics::getZipperDuration() const { float result; bool isSet = false; - process(ZIPPER_DURATION, &result, isSet); + process(ZIPPER_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_DURATION"); return result; @@ -711,7 +698,7 @@ float AbstractCharacteristics::getZipperForce() const { float result; bool isSet = false; - process(ZIPPER_FORCE, &result, isSet); + process(ZIPPER_FORCE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_FORCE"); return result; @@ -721,7 +708,7 @@ float AbstractCharacteristics::getZipperSpeedGain() const { float result; bool isSet = false; - process(ZIPPER_SPEED_GAIN, &result, isSet); + process(ZIPPER_SPEED_GAIN, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_SPEED_GAIN"); return result; @@ -731,7 +718,7 @@ float AbstractCharacteristics::getZipperSpeedIncrease() const { float result; bool isSet = false; - process(ZIPPER_SPEED_INCREASE, &result, isSet); + process(ZIPPER_SPEED_INCREASE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_SPEED_INCREASE"); return result; @@ -741,18 +728,17 @@ float AbstractCharacteristics::getZipperFadeOutTime() const { float result; bool isSet = false; - process(ZIPPER_FADE_OUT_TIME, &result, isSet); + process(ZIPPER_FADE_OUT_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_FADE_OUT_TIME"); return result; } - float AbstractCharacteristics::getSwatterDuration() const { float result; bool isSet = false; - process(SWATTER_DURATION, &result, isSet); + process(SWATTER_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_DURATION"); return result; @@ -762,7 +748,7 @@ float AbstractCharacteristics::getSwatterDistance() const { float result; bool isSet = false; - process(SWATTER_DISTANCE, &result, isSet); + process(SWATTER_DISTANCE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_DISTANCE"); return result; @@ -772,7 +758,7 @@ float AbstractCharacteristics::getSwatterSquashDuration() const { float result; bool isSet = false; - process(SWATTER_SQUASH_DURATION, &result, isSet); + process(SWATTER_SQUASH_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_SQUASH_DURATION"); return result; @@ -782,18 +768,17 @@ float AbstractCharacteristics::getSwatterSquashSlowdown() const { float result; bool isSet = false; - process(SWATTER_SQUASH_SLOWDOWN, &result, isSet); + process(SWATTER_SQUASH_SLOWDOWN, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_SQUASH_SLOWDOWN"); return result; } - float AbstractCharacteristics::getPlungerMaxLength() const { float result; bool isSet = false; - process(PLUNGER_MAX_LENGTH, &result, isSet); + process(PLUNGER_MAX_LENGTH, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_MAX_LENGTH"); return result; @@ -803,7 +788,7 @@ float AbstractCharacteristics::getPlungerForce() const { float result; bool isSet = false; - process(PLUNGER_FORCE, &result, isSet); + process(PLUNGER_FORCE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_FORCE"); return result; @@ -813,7 +798,7 @@ float AbstractCharacteristics::getPlungerDuration() const { float result; bool isSet = false; - process(PLUNGER_DURATION, &result, isSet); + process(PLUNGER_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_DURATION"); return result; @@ -823,7 +808,7 @@ float AbstractCharacteristics::getPlungerSpeedIncrease() const { float result; bool isSet = false; - process(PLUNGER_SPEED_INCREASE, &result, isSet); + process(PLUNGER_SPEED_INCREASE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_SPEED_INCREASE"); return result; @@ -833,7 +818,7 @@ float AbstractCharacteristics::getPlungerFadeOutTime() const { float result; bool isSet = false; - process(PLUNGER_FADE_OUT_TIME, &result, isSet); + process(PLUNGER_FADE_OUT_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_FADE_OUT_TIME"); return result; @@ -843,18 +828,17 @@ float AbstractCharacteristics::getPlungerInFaceTime() const { float result; bool isSet = false; - process(PLUNGER_IN_FACE_TIME, &result, isSet); + process(PLUNGER_IN_FACE_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_IN_FACE_TIME"); return result; } - std::vector&& AbstractCharacteristics::getStartupTime() const { std::vector result; bool isSet = false; - process(STARTUP_TIME, &result, isSet); + process(STARTUP_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STARTUP_TIME"); return std::move(result); @@ -864,18 +848,17 @@ std::vector&& AbstractCharacteristics::getStartupBoost() const { std::vector result; bool isSet = false; - process(STARTUP_BOOST, &result, isSet); + process(STARTUP_BOOST, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic STARTUP_BOOST"); return std::move(result); } - float AbstractCharacteristics::getRescueDuration() const { float result; bool isSet = false; - process(RESCUE_DURATION, &result, isSet); + process(RESCUE_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_DURATION"); return result; @@ -885,7 +868,7 @@ float AbstractCharacteristics::getRescueVertOffset() const { float result; bool isSet = false; - process(RESCUE_VERT_OFFSET, &result, isSet); + process(RESCUE_VERT_OFFSET, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_VERT_OFFSET"); return result; @@ -895,18 +878,17 @@ float AbstractCharacteristics::getRescueHeight() const { float result; bool isSet = false; - process(RESCUE_HEIGHT, &result, isSet); + process(RESCUE_HEIGHT, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_HEIGHT"); return result; } - float AbstractCharacteristics::getExplosionDuration() const { float result; bool isSet = false; - process(EXPLOSION_DURATION, &result, isSet); + process(EXPLOSION_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_DURATION"); return result; @@ -916,7 +898,7 @@ float AbstractCharacteristics::getExplosionRadius() const { float result; bool isSet = false; - process(EXPLOSION_RADIUS, &result, isSet); + process(EXPLOSION_RADIUS, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_RADIUS"); return result; @@ -926,18 +908,17 @@ float AbstractCharacteristics::getExplosionInvulnerabilityTime() const { float result; bool isSet = false; - process(EXPLOSION_INVULNERABILITY_TIME, &result, isSet); + process(EXPLOSION_INVULNERABILITY_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_INVULNERABILITY_TIME"); return result; } - float AbstractCharacteristics::getNitroDuration() const { float result; bool isSet = false; - process(NITRO_DURATION, &result, isSet); + process(NITRO_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_DURATION"); return result; @@ -947,7 +928,7 @@ float AbstractCharacteristics::getNitroEngineForce() const { float result; bool isSet = false; - process(NITRO_ENGINE_FORCE, &result, isSet); + process(NITRO_ENGINE_FORCE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_ENGINE_FORCE"); return result; @@ -957,7 +938,7 @@ float AbstractCharacteristics::getNitroConsumption() const { float result; bool isSet = false; - process(NITRO_CONSUMPTION, &result, isSet); + process(NITRO_CONSUMPTION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_CONSUMPTION"); return result; @@ -967,7 +948,7 @@ float AbstractCharacteristics::getNitroSmallContainer() const { float result; bool isSet = false; - process(NITRO_SMALL_CONTAINER, &result, isSet); + process(NITRO_SMALL_CONTAINER, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_SMALL_CONTAINER"); return result; @@ -977,7 +958,7 @@ float AbstractCharacteristics::getNitroBigContainer() const { float result; bool isSet = false; - process(NITRO_BIG_CONTAINER, &result, isSet); + process(NITRO_BIG_CONTAINER, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_BIG_CONTAINER"); return result; @@ -987,7 +968,7 @@ float AbstractCharacteristics::getNitroMaxSpeedIncrease() const { float result; bool isSet = false; - process(NITRO_MAX_SPEED_INCREASE, &result, isSet); + process(NITRO_MAX_SPEED_INCREASE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_MAX_SPEED_INCREASE"); return result; @@ -997,7 +978,7 @@ float AbstractCharacteristics::getNitroFadeOutTime() const { float result; bool isSet = false; - process(NITRO_FADE_OUT_TIME, &result, isSet); + process(NITRO_FADE_OUT_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_FADE_OUT_TIME"); return result; @@ -1007,18 +988,17 @@ float AbstractCharacteristics::getNitroMax() const { float result; bool isSet = false; - process(NITRO_MAX, &result, isSet); + process(NITRO_MAX, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_MAX"); return result; } - float AbstractCharacteristics::getSlipstreamDuration() const { float result; bool isSet = false; - process(SLIPSTREAM_DURATION, &result, isSet); + process(SLIPSTREAM_DURATION, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_DURATION"); return result; @@ -1028,7 +1008,7 @@ float AbstractCharacteristics::getSlipstreamLength() const { float result; bool isSet = false; - process(SLIPSTREAM_LENGTH, &result, isSet); + process(SLIPSTREAM_LENGTH, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_LENGTH"); return result; @@ -1038,7 +1018,7 @@ float AbstractCharacteristics::getSlipstreamWidth() const { float result; bool isSet = false; - process(SLIPSTREAM_WIDTH, &result, isSet); + process(SLIPSTREAM_WIDTH, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_WIDTH"); return result; @@ -1048,7 +1028,7 @@ float AbstractCharacteristics::getSlipstreamCollectTime() const { float result; bool isSet = false; - process(SLIPSTREAM_COLLECT_TIME, &result, isSet); + process(SLIPSTREAM_COLLECT_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_COLLECT_TIME"); return result; @@ -1058,7 +1038,7 @@ float AbstractCharacteristics::getSlipstreamUseTime() const { float result; bool isSet = false; - process(SLIPSTREAM_USE_TIME, &result, isSet); + process(SLIPSTREAM_USE_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_USE_TIME"); return result; @@ -1068,7 +1048,7 @@ float AbstractCharacteristics::getSlipstreamAddPower() const { float result; bool isSet = false; - process(SLIPSTREAM_ADD_POWER, &result, isSet); + process(SLIPSTREAM_ADD_POWER, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_ADD_POWER"); return result; @@ -1078,7 +1058,7 @@ float AbstractCharacteristics::getSlipstreamMinSpeed() const { float result; bool isSet = false; - process(SLIPSTREAM_MIN_SPEED, &result, isSet); + process(SLIPSTREAM_MIN_SPEED, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_MIN_SPEED"); return result; @@ -1088,7 +1068,7 @@ float AbstractCharacteristics::getSlipstreamMaxSpeedIncrease() const { float result; bool isSet = false; - process(SLIPSTREAM_MAX_SPEED_INCREASE, &result, isSet); + process(SLIPSTREAM_MAX_SPEED_INCREASE, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_MAX_SPEED_INCREASE"); return result; @@ -1098,7 +1078,7 @@ float AbstractCharacteristics::getSlipstreamFadeOutTime() const { float result; bool isSet = false; - process(SLIPSTREAM_FADE_OUT_TIME, &result, isSet); + process(SLIPSTREAM_FADE_OUT_TIME, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_FADE_OUT_TIME"); return result; diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp index 755c1878f..cd4ac015d 100755 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -211,7 +211,7 @@ public: * \param isSet If the current value was already set (so it can be used * for computations. */ - virtual void process(CharacteristicType type, Value value, bool &isSet) const; + virtual void process(CharacteristicType type, Value value, bool *isSet) const; static ValueType getType(CharacteristicType type); diff --git a/src/karts/cached_characteristics.cpp b/src/karts/cached_characteristics.cpp index 1a3dd4d1f..c66b33166 100644 --- a/src/karts/cached_characteristics.cpp +++ b/src/karts/cached_characteristics.cpp @@ -65,7 +65,7 @@ void CachedCharacteristics::updateSource() { float value; float *ptr = static_cast(v.content); - m_origin->process(static_cast(i), &value, isSet); + m_origin->process(static_cast(i), &value, &isSet); if (isSet) { if (!ptr) @@ -90,7 +90,7 @@ void CachedCharacteristics::updateSource() { std::vector value; std::vector *ptr = static_cast*>(v.content); - m_origin->process(static_cast(i), &value, isSet); + m_origin->process(static_cast(i), &value, &isSet); if (isSet) { if (!ptr) @@ -116,7 +116,7 @@ void CachedCharacteristics::updateSource() { InterpolationArray value; InterpolationArray *ptr = static_cast(v.content); - m_origin->process(static_cast(i), &value, isSet); + m_origin->process(static_cast(i), &value, &isSet); if (isSet) { if (!ptr) @@ -147,7 +147,7 @@ const SkiddingProperties* CachedCharacteristics::getSkiddingProperties() const return m_origin->getSkiddingProperties(); } -void CachedCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const +void CachedCharacteristics::process(CharacteristicType type, Value value, bool *isSet) const { void *v = m_values[type].content; if (v) @@ -164,7 +164,7 @@ void CachedCharacteristics::process(CharacteristicType type, Value value, bool & *value.ia = *static_cast(v); break; } - isSet = true; + *isSet = true; } } diff --git a/src/karts/cached_characteristics.hpp b/src/karts/cached_characteristics.hpp index dafcb5fce..5d9cfa5a9 100644 --- a/src/karts/cached_characteristics.hpp +++ b/src/karts/cached_characteristics.hpp @@ -48,7 +48,7 @@ public: void updateSource(); virtual const SkiddingProperties* getSkiddingProperties() const; - virtual void process(CharacteristicType type, Value value, bool &isSet) const; + virtual void process(CharacteristicType type, Value value, bool *isSet) const; }; #endif diff --git a/src/karts/combined_characteristics.cpp b/src/karts/combined_characteristics.cpp index adbe0db11..ad74878e1 100644 --- a/src/karts/combined_characteristics.cpp +++ b/src/karts/combined_characteristics.cpp @@ -34,7 +34,7 @@ const SkiddingProperties* CombinedCharacteristics::getSkiddingProperties() const return nullptr; } -void CombinedCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const +void CombinedCharacteristics::process(CharacteristicType type, Value value, bool *isSet) const { for (const AbstractCharacteristics *characteristic : m_childs) characteristic->process(type, value, isSet); diff --git a/src/karts/combined_characteristics.hpp b/src/karts/combined_characteristics.hpp index 35d0455a1..5daefc3f3 100644 --- a/src/karts/combined_characteristics.hpp +++ b/src/karts/combined_characteristics.hpp @@ -30,7 +30,7 @@ public: void addCharacteristic(const AbstractCharacteristics *characteristic); virtual const SkiddingProperties* getSkiddingProperties() const; - virtual void process(CharacteristicType type, Value value, bool &isSet) const; + virtual void process(CharacteristicType type, Value value, bool *isSet) const; }; #endif diff --git a/src/karts/xml_characteristics.cpp b/src/karts/xml_characteristics.cpp index afa4ee31a..333a951f3 100644 --- a/src/karts/xml_characteristics.cpp +++ b/src/karts/xml_characteristics.cpp @@ -33,11 +33,12 @@ const SkiddingProperties* XmlCharacteristics::getSkiddingProperties() const return m_skidding; } -void XmlCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const +void XmlCharacteristics::process(CharacteristicType type, Value value, bool *isSet) const { switch (getType(type)) { case TYPE_FLOAT: + processFloat(m_values[type], value.f, isSet); break; case TYPE_FLOAT_VECTOR: break; @@ -46,7 +47,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool &isS } } -float XmlCharacteristics::processFloat(float value, std::string processor) +void XmlCharacteristics::processFloat(const std::string &processor, float *value, bool *isSet) { } diff --git a/src/karts/xml_characteristics.hpp b/src/karts/xml_characteristics.hpp index 49721951c..592d94879 100644 --- a/src/karts/xml_characteristics.hpp +++ b/src/karts/xml_characteristics.hpp @@ -36,12 +36,12 @@ public: XmlCharacteristics(const XMLNode *node = nullptr); virtual const SkiddingProperties* getSkiddingProperties() const; - virtual void process(CharacteristicType type, Value value, bool &isSet) const; + virtual void process(CharacteristicType type, Value value, bool *isSet) const; void load(const XMLNode *node); private: - static float processFloat(float value, std::string processor); + static void processFloat(const std::string &processor, float *value, bool *isSet); }; #endif diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 59f3aa827..3da7cb71c 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -186,7 +186,7 @@ def main(): {{ {0} result; bool isSet = false; - process({2}, &result, isSet); + process({2}, &result, &isSet); if (!isSet) Log::fatal("AbstractCharacteristics", "Can't get characteristic {2}"); return {4}; @@ -212,45 +212,23 @@ def main(): else: print("Unknown task") - # Commented out code - """print("Variables ****************************************") - for g in groups: - print() - print(" // {0}".format(g.baseName.title())) - for n in g.subNames: - print(" float m_{0};".format(joinSubName(g, n, False))) - - print() - print() - print("Constructor ****************************************") - lineLength = 4; - line = " " - for g in groups: - for n in g.subNames: - name = "m_{0} = ".format(joinSubName(g, n, False)) - l = len(name) - if lineLength + l > 80 and lineLength > 4: - print(line) - line = " " + name - lineLength = l + 4 - else: - line += name - lineLength += l - if lineLength > 4: - line += "1;" - print(line) - - print() - print() - print("Setters ****************************************") - for g in groups: - print() - for n in g.subNames: - nameTitle = joinSubName(g, n, True) - nameUnderscore = joinSubName(g, n, False) - print(" void set{0}(float value){2} {{ m_{1}{3} = value; }}". - format(nameTitle, nameUnderscore, " " * (nameLengthTitle - len(nameTitle)), - " " * (nameLengthUnderscore - len(nameUnderscore))))""" + #print("Constructor ****************************************") + #lineLength = 4; + #line = " " + #for g in groups: + # for n in g.subNames: + # name = "m_{0} = ".format(joinSubName(g, n, False)) + # l = len(name) + # if lineLength + l > 80 and lineLength > 4: + # print(line) + # line = " " + name + # lineLength = l + 4 + # else: + # line += name + # lineLength += l + #if lineLength > 4: + # line += "1;" + # print(line) if __name__ == '__main__': main()