From fc8a726156df67321dc49ded45e0ad65945b90a3 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 10 Apr 2015 18:20:16 +0200 Subject: [PATCH 01/55] Add config file for kart characteristics --- data/kart_characteristics.xml | 290 ++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 data/kart_characteristics.xml diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml new file mode 100644 index 000000000..7dfcb1614 --- /dev/null +++ b/data/kart_characteristics.xml @@ -0,0 +1,290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5dec3c4602ea638a50841379d4bcab713d0cfe9a Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 10 Apr 2015 21:47:36 +0200 Subject: [PATCH 02/55] Add characteristics --- sources.cmake | 4 +- src/karts/abstract_characteristics.cpp | 19 +++ src/karts/abstract_characteristics.hpp | 203 +++++++++++++++++++++++++ 3 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 src/karts/abstract_characteristics.cpp create mode 100644 src/karts/abstract_characteristics.hpp diff --git a/sources.cmake b/sources.cmake index 117eebbea..d4f28ae4d 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,5 +1,5 @@ -# Modify this file to change the last-modified date when you add/remove a file. -# This will then trigger a new cmake run automatically. +# Modify this file to change the last-modified date when you add/remove a file. +# This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp new file mode 100644 index 000000000..9472e81df --- /dev/null +++ b/src/karts/abstract_characteristics.cpp @@ -0,0 +1,19 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "karts/abstract_characteristics.hpp" diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp new file mode 100644 index 000000000..17e401477 --- /dev/null +++ b/src/karts/abstract_characteristics.hpp @@ -0,0 +1,203 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_ABSTRACT_CHARACTERISTICS_HPP +#define HEADER_ABSTRACT_CHARACTERISTICS_HPP + +#include "utils/interpolation_array.hpp" +#include "utils/vec3.hpp" + +#include + +/** + * Characteristics are the properties of a kart that influence + * gameplay mechanics. + * The biggest parts are: + * - Physics + * - Visuals + * - Items + * - and miscellaneous properties like nitro and startup boost. + * + * The documentation of these properties can be found in + * the kart_characteristics.xml file. + */ +class AbstractCharacteristics +{ +private: + /* ---------- Physics ---------- */ + + // Suspension + float m_suspension_stiffness; + float m_suspension_rest; + float m_suspension_travel_cm; + float m_suspension_exp_spring_response; + float m_suspension_max_force; + + // Stability + float m_stability_roll_influence; + float m_stability_chassis_linear_damping; + float m_stability_chassis_angular_damping; + float m_stability_downward_impulse_factor; + float m_stability_track_connection_accel; + float m_stability_smooth_flying_impulse; + + // Turn + std::vector m_turn_radius; + InterpolationArray m_turn_time_full_steer; + float m_turn_time_reset_steer; + + // Engine + std::vector m_engine_power; + std::vector m_engine_max_speed; + float m_brake_factor; + float m_break_time_increase; + float m_max_speed_reverse_ratio; + + // Gear + std::vector m_gear_switch_ratio; + std::vector m_gear_power_increase; + + // Mass + float m_mass; + + // Wheels + float m_damping_relaxation; + float m_damping_compression; + float m_wheel_radius; + Vec3 m_wheel_position[4]; + + + /* ---------- Visuals ---------- */ + + // Skid + float m_skid_increase; + float m_skid_decrease; + float m_skid_max; + float m_skid_time_till_max; + float m_skid_visual; + float m_skid_visual_time; + float m_skid_revert_visual_time; + float m_skid_min_speed; + std::vector m_skid_time_till_bonus; + std::vector m_skid_bonus_speed; + std::vector m_skid_bonus_time; + std::vector m_skid_bonus_force; + float m_skid_physical_jump_time; + float m_skid_graphical_jump_time; + float m_skid_post_skid_rotate_factor; + float m_skid_reduce_turn_min; + float m_skid_reduce_turn_max; + + // Camera + float m_camera_distance; + float m_camera_forward_up_angle; + float m_camera_backward_up_angle; + + // Jump + float m_jump_animation_time; + + // Lean + float m_lean_max; + float m_lean_speed; + + + /* ---------- Items ---------- */ + + // Anvil + float m_anvil_time; + float m_anvil_weight; + float m_anvil_speed_factor; + + // Parachute + float m_parachute_friction; + float m_parachute_time; + float m_parachute_time_other; + float m_parachute_lbound_fraction; + float m_parachute_ubound_fraction; + float m_parachute_max_speed; + + // Bubblegum + float m_bubblegum_time; + float m_bubblegum_speed_fraction; + float m_bubblegum_torque; + float m_bubblegum_fade_in_time; + float m_bubblegum_shield_time; + + // Zipper + float m_zipper_time; + float m_zipper_force; + float m_zipper_speed_gain; + float m_zipper_max_speed_increase; + float m_zipper_fade_out_time; + + // Swatter + float m_swatter_duration; + float m_swatter_distance; + float m_swatter_squash_duration; + float m_swatter_squash_slowdown; + + // Plunger + float m_plunger_band_max_length; + float m_plunger_band_force; + float m_plunger_band_duration; + float m_plunger_band_speed_increase; + float m_plunger_band_fade_out_time; + std::vector m_plunger_in_face_time; + + + /* ---------- Miscellaneous ---------- */ + + // Startup + std::vector m_startup_time; + std::vector m_startup_boost; + + // Rescue + float m_rescue_vert_offset; + float m_rescue_time; + float m_rescue_height; + + // Explosion + float m_explosion_time; + float m_explosion_radius; + float m_explosion_invulnerability_time; + + // Nitro + float m_nitro_engine_force; + float m_nitro_consumption; + float m_nitro_small_container; + float m_nitro_big_container; + float m_nitro_max_speed_increase; + float m_nitro_duration; + float m_nitro_fade_out_time; + float m_nitro_max; + + // Slipstream + float m_slipstream_length; + float m_slipstream_width; + float m_slipstream_collect_time; + float m_slipstream_use_time; + float m_slipstream_add_power; + float m_slipstream_min_speed; + float m_slipstream_max_speed_increase; + float m_slipstream_duration; + float m_slipstream_fade_out_time; + +public: +}; + +#endif From 483993d2d87e5624685e3dcf5289269e1af2fe9e Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 10 Apr 2015 22:58:04 +0200 Subject: [PATCH 03/55] Start with getters --- data/kart_characteristics.xml | 138 +++++----- src/karts/abstract_characteristics.cpp | 5 + src/karts/abstract_characteristics.hpp | 355 ++++++++++++++++--------- 3 files changed, 301 insertions(+), 197 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index 7dfcb1614..b2d080003 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -7,7 +7,9 @@ rest: Length of suspension when at rest. travel-cm: maximum movement of suspension - in cm!! exp-string-response: dampen the suspension spring reaction - exponentially. + exponentially. See + http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\&p=25236&hilit=vehicle#p25236 + for details. max-force: Maximum suspension force --> @@ -163,7 +165,69 @@ - + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp index 9472e81df..f383cb40d 100644 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristics.cpp @@ -17,3 +17,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "karts/abstract_characteristics.hpp" + +AbstractCharacteristics::AbstractCharacteristics() +{ + // Set default value +} \ No newline at end of file diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp index 17e401477..b29c6c2f1 100644 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -24,6 +24,8 @@ #include +class SkiddingProperties; + /** * Characteristics are the properties of a kart that influence * gameplay mechanics. @@ -39,165 +41,260 @@ class AbstractCharacteristics { private: - /* ---------- Physics ---------- */ + /* ---------- Physics ---------- */ - // Suspension - float m_suspension_stiffness; - float m_suspension_rest; - float m_suspension_travel_cm; - float m_suspension_exp_spring_response; - float m_suspension_max_force; + // Suspension + float m_suspension_stiffness; + float m_suspension_rest; + float m_suspension_travel_cm; + float m_suspension_exp_spring_response; + float m_suspension_max_force; - // Stability - float m_stability_roll_influence; - float m_stability_chassis_linear_damping; - float m_stability_chassis_angular_damping; - float m_stability_downward_impulse_factor; - float m_stability_track_connection_accel; - float m_stability_smooth_flying_impulse; + // Stability + float m_stability_roll_influence; + float m_stability_chassis_linear_damping; + float m_stability_chassis_angular_damping; + float m_stability_downward_impulse_factor; + float m_stability_track_connection_accel; + float m_stability_smooth_flying_impulse; - // Turn - std::vector m_turn_radius; - InterpolationArray m_turn_time_full_steer; - float m_turn_time_reset_steer; + // Turn + InterpolationArray m_turn_radius; + InterpolationArray m_turn_time_full_steer; + float m_turn_time_reset_steer; - // Engine - std::vector m_engine_power; - std::vector m_engine_max_speed; - float m_brake_factor; - float m_break_time_increase; - float m_max_speed_reverse_ratio; + // Engine + float m_engine_power; + float m_engine_max_speed; + float m_brake_factor; + float m_brake_time_increase; + float m_max_speed_reverse_ratio; - // Gear - std::vector m_gear_switch_ratio; - std::vector m_gear_power_increase; + // Gear + std::vector m_gear_switch_ratio; + std::vector m_gear_power_increase; - // Mass - float m_mass; + // Mass + float m_mass; - // Wheels - float m_damping_relaxation; - float m_damping_compression; - float m_wheel_radius; - Vec3 m_wheel_position[4]; + // Wheels + float m_damping_relaxation; + float m_damping_compression; + float m_wheel_radius; + std::vector m_wheel_position; - /* ---------- Visuals ---------- */ + /* ---------- Visuals ---------- */ - // Skid - float m_skid_increase; - float m_skid_decrease; - float m_skid_max; - float m_skid_time_till_max; - float m_skid_visual; - float m_skid_visual_time; - float m_skid_revert_visual_time; - float m_skid_min_speed; - std::vector m_skid_time_till_bonus; - std::vector m_skid_bonus_speed; - std::vector m_skid_bonus_time; - std::vector m_skid_bonus_force; - float m_skid_physical_jump_time; - float m_skid_graphical_jump_time; - float m_skid_post_skid_rotate_factor; - float m_skid_reduce_turn_min; - float m_skid_reduce_turn_max; + // Skid + SkiddingProperties *m_skidding; - // Camera - float m_camera_distance; - float m_camera_forward_up_angle; - float m_camera_backward_up_angle; + // Camera + float m_camera_distance; + float m_camera_forward_up_angle; + float m_camera_backward_up_angle; - // Jump - float m_jump_animation_time; + // Jump + float m_jump_animation_time; - // Lean - float m_lean_max; - float m_lean_speed; + // Lean + float m_lean_max; + float m_lean_speed; - /* ---------- Items ---------- */ + /* ---------- Items ---------- */ - // Anvil - float m_anvil_time; - float m_anvil_weight; - float m_anvil_speed_factor; + // Anvil + float m_anvil_duration; + float m_anvil_weight; + float m_anvil_speed_factor; - // Parachute - float m_parachute_friction; - float m_parachute_time; - float m_parachute_time_other; - float m_parachute_lbound_fraction; - float m_parachute_ubound_fraction; - float m_parachute_max_speed; + // Parachute + float m_parachute_friction; + float m_parachute_duration; + float m_parachute_duration_other; + float m_parachute_lbound_fraction; + float m_parachute_ubound_fraction; + float m_parachute_max_speed; - // Bubblegum - float m_bubblegum_time; - float m_bubblegum_speed_fraction; - float m_bubblegum_torque; - float m_bubblegum_fade_in_time; - float m_bubblegum_shield_time; + // Bubblegum + float m_bubblegum_duration; + float m_bubblegum_speed_fraction; + float m_bubblegum_torque; + float m_bubblegum_fade_in_time; + float m_bubblegum_shield_duration; - // Zipper - float m_zipper_time; - float m_zipper_force; - float m_zipper_speed_gain; - float m_zipper_max_speed_increase; - float m_zipper_fade_out_time; + // Zipper + float m_zipper_duration; + float m_zipper_force; + float m_zipper_speed_gain; + float m_zipper_max_speed_increase; + float m_zipper_fade_out_time; - // Swatter - float m_swatter_duration; - float m_swatter_distance; - float m_swatter_squash_duration; - float m_swatter_squash_slowdown; + // Swatter + float m_swatter_duration; + float m_swatter_distance; + float m_swatter_squash_duration; + float m_swatter_squash_slowdown; - // Plunger - float m_plunger_band_max_length; - float m_plunger_band_force; - float m_plunger_band_duration; - float m_plunger_band_speed_increase; - float m_plunger_band_fade_out_time; - std::vector m_plunger_in_face_time; + // Plunger + float m_plunger_band_max_length; + float m_plunger_band_force; + float m_plunger_band_duration; + float m_plunger_band_speed_increase; + float m_plunger_band_fade_out_time; + float m_plunger_in_face_time; - /* ---------- Miscellaneous ---------- */ + /* ---------- Miscellaneous ---------- */ - // Startup - std::vector m_startup_time; - std::vector m_startup_boost; + // Startup + std::vector m_startup_time; + std::vector m_startup_boost; - // Rescue - float m_rescue_vert_offset; - float m_rescue_time; - float m_rescue_height; + // Rescue + float m_rescue_vert_offset; + float m_rescue_duration; + float m_rescue_height; - // Explosion - float m_explosion_time; - float m_explosion_radius; - float m_explosion_invulnerability_time; + // Explosion + float m_explosion_duration; + float m_explosion_radius; + float m_explosion_invulnerability_time; - // Nitro - float m_nitro_engine_force; - float m_nitro_consumption; - float m_nitro_small_container; - float m_nitro_big_container; - float m_nitro_max_speed_increase; - float m_nitro_duration; - float m_nitro_fade_out_time; - float m_nitro_max; + // Nitro + float m_nitro_engine_force; + float m_nitro_consumption; + float m_nitro_small_container; + float m_nitro_big_container; + float m_nitro_max_speed_increase; + float m_nitro_duration; + float m_nitro_fade_out_time; + float m_nitro_max; - // Slipstream - float m_slipstream_length; - float m_slipstream_width; - float m_slipstream_collect_time; - float m_slipstream_use_time; - float m_slipstream_add_power; - float m_slipstream_min_speed; - float m_slipstream_max_speed_increase; - float m_slipstream_duration; - float m_slipstream_fade_out_time; + // Slipstream + float m_slipstream_length; + float m_slipstream_width; + float m_slipstream_collect_time; + float m_slipstream_use_time; + float m_slipstream_add_power; + float m_slipstream_min_speed; + float m_slipstream_max_speed_increase; + float m_slipstream_duration; + float m_slipstream_fade_out_time; public: + AbstractCharacteristics(); + + float getSuspensionStiffness() const { return m_suspension_stiffness; } + float getSuspensionRest() const { return m_suspension_rest; } + float getSuspensionTravelCM() const { return m_suspension_travel_cm; } + float getSuspensionExpSpringResponse() const { return m_suspension_exp_spring_response; } + float getSuspensionMaxForce() const { return m_suspension_max_force; } + + float getStabilityRollInfluence() const { return m_stability_roll_influence; } + float getStabilityChassisLinearDamping() const { return m_stability_chassis_linear_damping; } + float getStabilityChassisAngularDamping() const { return m_stability_chassis_angular_damping; } + float getStabilityDownwardImpulseFactor() const { return m_stability_downward_impulse_factor; } + float getStabilityTrackConnectionAccel() const { return m_stability_track_connection_accel; } + float getStabilitySmoothFlyingImpulse() const { return m_stability_smooth_flying_impulse; } + + float getTurnRadius(float steer) const { return m_turn_radius.get(steer); } + float getTurnTimeFullSteer(float steer) const { return m_turn_time_full_steer.get(steer); } + float getTurnTimeResetSteer() const { return m_turn_time_reset_steer; } + + float getEnginePower() const { return m_engine_power; } + float getEngineMaxSpeed() const { return m_engine_max_speed; } + float getBreakFactor() const { return m_brake_factor; } + float getBrakeTimeIncrease() const { return m_brake_time_increase; } + float getMaxSpeedReverseRatio() const; + + float getGearSwitchRatio(int gear) const; + float getGearPowerIncrease(int gear) const; + + float getMass() const; + + float getDampingRelaxation() const; + float getDampingCompression() const; + float getWheelRadius() const; + Vec3 getWheelPosition(int wheel) const; + + SkiddingProperties* getSkiddingProperties() const; + + float getCameraDistance() const; + float getCameraForwardUpAngle() const; + float getCameraBackwardUpAngle() const; + + float getJumpAnimationTime() const; + + float getLeanMax() const; + float getLeanSpeed() const; + + float getAnvilDuration() const; + float getAnvilWeight() const; + float getAnvilSpeedFactor() const; + + float getParachuteFriction() const; + float getParachuteDuration() const; + float getParachuteDurationOther() const; + float getParachuteLBoundFraction() const; + float getParachuteUBoundFranction() const; + float getParachuteMaxSpeed() const; + + float getBubblegumDuration() const; + float getBubblegumSpeedFraction() const; + float getBubblegumTorque() const; + float getBubblegumFadeInTime() const; + float getBubblegumShieldDuration() const; + + float getZipperDuration() const; + float getZipperForce() const; + float getZipperSpeedGain() const; + float getZipperMaxSpeedIncrease() const; + float getZipperFadeOutTime() const; + float getSwatterDuration() const; + float getSwatterDistance() const; + float getSwatterSquashDuration() const; + float getSwatterSquashSlowdown() const; + + float getPlungerBandMaxLength() const; + float getPlungerBandForce() const; + float getPlungerBandDuration() const; + float getPlungerBandSpeedIncrease() const; + float getPlungerBandFadeOutTime() const; + float getPlungerInFaceTime() const; + + float getStartupBoost(float time) const; + + float getRescueVertOffset() const; + float getRescueDuration() const; + float getRescueHeight() const; + + float getExplosionDuration() const; + float getExplosionRadius() const; + float getExplosionInvulnerabilityTime() const; + + float getNitroEngineForce() const; + float getNitroConsumption() const; + float getNitroSmallContainer() const; + float getNitroBigContainer() const; + float getNitroMaxSpeedIncrease() const; + float getNitroDuration() const; + float getNitroFadeOutTime() const; + float getNitroMax() const; + + float getSlipstreamLength() const; + float getSlipstreamWidth() const; + float getSlipstreamCollectTime() const; + float getSlipstreamUseTime() const; + float getSlipstreamAddPower() const; + float getSlipstreamMinSpeed() const; + float getSlipstreamMaxSpeedIncrease() const; + float getSlipstreamDuration() const; + float getSlipstreamFadeOutTime() const; + +protected: + void setSuspensionStiffness(float value); }; #endif From 3414f7cb91452b03861efda38215a35efa345ade Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sat, 11 Apr 2015 02:44:38 +0200 Subject: [PATCH 04/55] Add script to create characteristics file --- tools/create_kart_properties.py | 159 ++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 tools/create_kart_properties.py diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py new file mode 100644 index 000000000..3b3a8e583 --- /dev/null +++ b/tools/create_kart_properties.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python3 +# +# SuperTuxKart - a fun racing game with go-kart +# Copyright (C) 2006-2015 SuperTuxKart-Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This script takes the list from abstract_characteristics.hpp and creates the code +# An empty line is expected to end the input + +class Group: + def __init__(self, baseName): + self.baseName = baseName + self.subNames = [] + + def addName(self, name): + self.subNames.append(name) + +"""Creates a list of words from a titlecase string""" +def toList(name): + result = [] + cur = "" + for c in name: + if c.isupper() and len(cur) != 0: + result.append(cur) + cur = "" + cur += c.lower() + if len(cur) != 0: + result.append(cur) + return result + +"""titleCase: true = result is titlecase + false = result has underscores""" +def joinSubName(g, subName, titleCase): + words = toList(g.baseName) + toList(subName) + first = True + if titleCase: + words = map(lambda w: w.title(), words) + return "".join(words) + else: + return "_".join(words) + +def main(): + # All variables are saved here in titlecase + groups = [] + # Read in lines + while True: + line = input() + if len(line) == 0: + break + + # Search base name + pos = line.find(":") + if pos != -1: + group = Group(line[:pos].strip()) + # Find all subnames + while True: + pos2 = line.find(",", pos + 1) + # Are we already at the end? + if pos2 == -1: + part = line[pos + 1:].strip() + else: + part = line[pos + 1:pos2].strip() + + if len(part) != 0: + group.addName(part) + + # Find the next one + pos, pos2 = pos2, pos + + # We are at the end, so stop searching + if pos == -1: + break + groups.append(group) + else: + # There is not base name, so use the whole line as one word + group = Group(line.strip()) + group.addName("") + groups.append(group) + + # Find longest name to align the function bodies + nameLengthTitle = 0 + nameLengthUnderscore = 0 + for g in groups: + for n in g.subNames: + l = len(joinSubName(g, n, True)) + if l > nameLengthTitle: + nameLengthTitle = l + l = len(joinSubName(g, n, False)) + if l > nameLengthUnderscore: + nameLengthUnderscore = l + + # Print the results + 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("Getters ****************************************") + + for g in groups: + print() + for n in g.subNames: + nameTitle = joinSubName(g, n, True) + nameUnderscore = joinSubName(g, n, False) + print(" float get{0}(){2} const {{ return m_{1};{3} }}". + format(nameTitle, nameUnderscore, " " * (nameLengthTitle - len(nameTitle)), + " " * (nameLengthUnderscore - len(nameUnderscore)))) + + 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)))) + +if __name__ == '__main__': + main() From a3f94f6b67a07d39f14bb8b57bfe0ae5b3b8fdc1 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sat, 11 Apr 2015 02:59:22 +0200 Subject: [PATCH 05/55] Update abstract characteristics with script generated content --- src/karts/abstract_characteristics.cpp | 32 +- src/karts/abstract_characteristics.hpp | 392 +++++++++++++++++-------- 2 files changed, 294 insertions(+), 130 deletions(-) diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp index f383cb40d..bc5165331 100644 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristics.cpp @@ -20,5 +20,35 @@ AbstractCharacteristics::AbstractCharacteristics() { - // Set default value + // Set all variables to their default value (1) + m_suspension_stiffness = m_suspension_rest = m_suspension_travel_cm = + m_suspension_exp_spring_response = m_suspension_max_force = + m_stability_roll_influence = m_stability_chassis_linear_damping = + m_stability_chassis_angular_damping = m_stability_downward_impulse_factor = + m_stability_track_connection_accel = m_stability_smooth_flying_impulse = + m_turn_time_reset_steer = m_engine_power = m_engine_max_speed = + m_engine_brake_factor = m_engine_brake_time_increase = + m_engine_max_speed_reverse_ratio = m_mass = m_wheels_damping_relaxation = + m_wheels_damping_compression = m_wheels_wheel_radius = m_camera_distance = + m_camera_forward_up_angle = m_camera_backward_up_angle = + m_jump_animation_time = m_lean_max = m_lean_speed = m_anvil_duration = + m_anvil_weight = m_anvil_speed_factor = m_parachute_friction = + m_parachute_duration = m_parachute_duration_other = + m_parachute_lbound_franction = m_parachute_ubound_franction = + m_parachute_max_speed = m_bubblegum_duration = m_bubblegum_speed_fraction = + m_bubblegum_torque = m_bubblegum_fade_in_time = + m_bubblegum_shield_duration = m_zipper_duration = m_zipper_force = + m_zipper_speed_gain = m_zipper_speed_increase = m_zipper_fade_out_time = + m_swatter_duration = m_swatter_distance = m_swatter_squash_duration = + m_swatter_squash_slowdown = m_plunger_max_length = m_plunger_force = + m_plunger_duration = m_plunger_speed_increase = m_plunger_fade_out_time = + m_plunger_in_face_time = m_rescue_duration = m_rescue_vert_offset = + m_rescue_height = m_explosion_duration = m_explosion_radius = + m_explosion_invulnerability_time = m_nitro_duration = + m_nitro_engine_force = m_nitro_consumption = m_nitro_small_container = + m_nitro_big_container = m_nitro_max_speed_increase = + m_nitro_fade_out_time = m_nitro_max = m_slipstream_duration = + m_slipstream_length = m_slipstream_width = m_slipstream_collect_time = + m_slipstream_use_time = m_slipstream_add_power = m_slipstream_min_speed = + m_slipstream_max_speed_increase = m_slipstream_fade_out_time = 1; } \ No newline at end of file diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp index b29c6c2f1..0377fdaaa 100644 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -41,7 +41,29 @@ class SkiddingProperties; class AbstractCharacteristics { private: - /* ---------- Physics ---------- */ + /* Characteristics that are saved as float. Use the following lines as input + Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce + Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse + Turn: timeResetSteer + Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio + Mass + Wheels: dampingRelaxation, dampingCompression, wheelRadius + Camera: distance, forwardUpAngle, backwardUpAngle + Jump: animationTime + Lean: max, speed + Anvil: duration, weight, speedFactor + Parachute: friction, duration, durationOther, lboundFranction, uboundFranction, maxSpeed + Bubblegum: duration, speedFraction, torque, fadeInTime, shieldDuration + Zipper: duration, force, speedGain, speedIncrease, fadeOutTime + Swatter: duration, distance, squashDuration, squashSlowdown + Plunger: maxLength, force, duration, speedIncrease, fadeOutTime, inFaceTime + Rescue: duration, vertOffset, height + Explosion: duration, radius, invulnerabilityTime + Nitro: duration, engineForce, consumption, smallContainer, bigContainer, maxSpeedIncrease, fadeOutTime, max + Slipstream: duration, length, width, collectTime, useTime, addPower, minSpeed, maxSpeedIncrease, fadeOutTime + */ + + /* ---------- Variables generated by the script ---------- */ // Suspension float m_suspension_stiffness; @@ -59,35 +81,22 @@ private: float m_stability_smooth_flying_impulse; // Turn - InterpolationArray m_turn_radius; - InterpolationArray m_turn_time_full_steer; float m_turn_time_reset_steer; // Engine float m_engine_power; float m_engine_max_speed; - float m_brake_factor; - float m_brake_time_increase; - float m_max_speed_reverse_ratio; - - // Gear - std::vector m_gear_switch_ratio; - std::vector m_gear_power_increase; + float m_engine_brake_factor; + float m_engine_brake_time_increase; + float m_engine_max_speed_reverse_ratio; // Mass float m_mass; // Wheels - float m_damping_relaxation; - float m_damping_compression; - float m_wheel_radius; - std::vector m_wheel_position; - - - /* ---------- Visuals ---------- */ - - // Skid - SkiddingProperties *m_skidding; + float m_wheels_damping_relaxation; + float m_wheels_damping_compression; + float m_wheels_wheel_radius; // Camera float m_camera_distance; @@ -101,9 +110,6 @@ private: float m_lean_max; float m_lean_speed; - - /* ---------- Items ---------- */ - // Anvil float m_anvil_duration; float m_anvil_weight; @@ -113,8 +119,8 @@ private: float m_parachute_friction; float m_parachute_duration; float m_parachute_duration_other; - float m_parachute_lbound_fraction; - float m_parachute_ubound_fraction; + float m_parachute_lbound_franction; + float m_parachute_ubound_franction; float m_parachute_max_speed; // Bubblegum @@ -128,7 +134,7 @@ private: float m_zipper_duration; float m_zipper_force; float m_zipper_speed_gain; - float m_zipper_max_speed_increase; + float m_zipper_speed_increase; float m_zipper_fade_out_time; // Swatter @@ -138,23 +144,16 @@ private: float m_swatter_squash_slowdown; // Plunger - float m_plunger_band_max_length; - float m_plunger_band_force; - float m_plunger_band_duration; - float m_plunger_band_speed_increase; - float m_plunger_band_fade_out_time; + float m_plunger_max_length; + float m_plunger_force; + float m_plunger_duration; + float m_plunger_speed_increase; + float m_plunger_fade_out_time; float m_plunger_in_face_time; - - /* ---------- Miscellaneous ---------- */ - - // Startup - std::vector m_startup_time; - std::vector m_startup_boost; - // Rescue - float m_rescue_vert_offset; float m_rescue_duration; + float m_rescue_vert_offset; float m_rescue_height; // Explosion @@ -163,16 +162,17 @@ private: float m_explosion_invulnerability_time; // Nitro + float m_nitro_duration; float m_nitro_engine_force; float m_nitro_consumption; float m_nitro_small_container; float m_nitro_big_container; float m_nitro_max_speed_increase; - float m_nitro_duration; float m_nitro_fade_out_time; float m_nitro_max; // Slipstream + float m_slipstream_duration; float m_slipstream_length; float m_slipstream_width; float m_slipstream_collect_time; @@ -180,121 +180,255 @@ private: float m_slipstream_add_power; float m_slipstream_min_speed; float m_slipstream_max_speed_increase; - float m_slipstream_duration; float m_slipstream_fade_out_time; + /* ---------- Variables added by hand ---------- */ + + // Turn + InterpolationArray m_turn_radius; + InterpolationArray m_turn_time_full_steer; + + // Gear + std::vector m_gear_switch_ratio; + std::vector m_gear_power_increase; + + // Wheels + std::vector m_wheel_position; + + // Skid + SkiddingProperties *m_skidding; + + + /* ---------- Miscellaneous ---------- */ + + // Startup + std::vector m_startup_time; + std::vector m_startup_boost; + public: AbstractCharacteristics(); - float getSuspensionStiffness() const { return m_suspension_stiffness; } - float getSuspensionRest() const { return m_suspension_rest; } - float getSuspensionTravelCM() const { return m_suspension_travel_cm; } - float getSuspensionExpSpringResponse() const { return m_suspension_exp_spring_response; } - float getSuspensionMaxForce() const { return m_suspension_max_force; } + /* ---------- Getters generated by the script ---------- */ - float getStabilityRollInfluence() const { return m_stability_roll_influence; } - float getStabilityChassisLinearDamping() const { return m_stability_chassis_linear_damping; } - float getStabilityChassisAngularDamping() const { return m_stability_chassis_angular_damping; } - float getStabilityDownwardImpulseFactor() const { return m_stability_downward_impulse_factor; } - float getStabilityTrackConnectionAccel() const { return m_stability_track_connection_accel; } - float getStabilitySmoothFlyingImpulse() const { return m_stability_smooth_flying_impulse; } + float getSuspensionStiffness() const { return m_suspension_stiffness; } + float getSuspensionRest() const { return m_suspension_rest; } + float getSuspensionTravelCm() const { return m_suspension_travel_cm; } + float getSuspensionExpSpringResponse() const { return m_suspension_exp_spring_response; } + float getSuspensionMaxForce() const { return m_suspension_max_force; } - float getTurnRadius(float steer) const { return m_turn_radius.get(steer); } - float getTurnTimeFullSteer(float steer) const { return m_turn_time_full_steer.get(steer); } - float getTurnTimeResetSteer() const { return m_turn_time_reset_steer; } + float getStabilityRollInfluence() const { return m_stability_roll_influence; } + float getStabilityChassisLinearDamping() const { return m_stability_chassis_linear_damping; } + float getStabilityChassisAngularDamping() const { return m_stability_chassis_angular_damping; } + float getStabilityDownwardImpulseFactor() const { return m_stability_downward_impulse_factor; } + float getStabilityTrackConnectionAccel() const { return m_stability_track_connection_accel; } + float getStabilitySmoothFlyingImpulse() const { return m_stability_smooth_flying_impulse; } - float getEnginePower() const { return m_engine_power; } - float getEngineMaxSpeed() const { return m_engine_max_speed; } - float getBreakFactor() const { return m_brake_factor; } - float getBrakeTimeIncrease() const { return m_brake_time_increase; } - float getMaxSpeedReverseRatio() const; + float getTurnTimeResetSteer() const { return m_turn_time_reset_steer; } - float getGearSwitchRatio(int gear) const; - float getGearPowerIncrease(int gear) const; - - float getMass() const; + float getEnginePower() const { return m_engine_power; } + float getEngineMaxSpeed() const { return m_engine_max_speed; } + float getEngineBrakeFactor() const { return m_engine_brake_factor; } + float getEngineBrakeTimeIncrease() const { return m_engine_brake_time_increase; } + float getEngineMaxSpeedReverseRatio() const { return m_engine_max_speed_reverse_ratio; } - float getDampingRelaxation() const; - float getDampingCompression() const; - float getWheelRadius() const; - Vec3 getWheelPosition(int wheel) const; + float getMass() const { return m_mass; } - SkiddingProperties* getSkiddingProperties() const; + float getWheelsDampingRelaxation() const { return m_wheels_damping_relaxation; } + float getWheelsDampingCompression() const { return m_wheels_damping_compression; } + float getWheelsWheelRadius() const { return m_wheels_wheel_radius; } - float getCameraDistance() const; - float getCameraForwardUpAngle() const; - float getCameraBackwardUpAngle() const; + float getCameraDistance() const { return m_camera_distance; } + float getCameraForwardUpAngle() const { return m_camera_forward_up_angle; } + float getCameraBackwardUpAngle() const { return m_camera_backward_up_angle; } - float getJumpAnimationTime() const; + float getJumpAnimationTime() const { return m_jump_animation_time; } - float getLeanMax() const; - float getLeanSpeed() const; + float getLeanMax() const { return m_lean_max; } + float getLeanSpeed() const { return m_lean_speed; } - float getAnvilDuration() const; - float getAnvilWeight() const; - float getAnvilSpeedFactor() const; + float getAnvilDuration() const { return m_anvil_duration; } + float getAnvilWeight() const { return m_anvil_weight; } + float getAnvilSpeedFactor() const { return m_anvil_speed_factor; } - float getParachuteFriction() const; - float getParachuteDuration() const; - float getParachuteDurationOther() const; - float getParachuteLBoundFraction() const; - float getParachuteUBoundFranction() const; - float getParachuteMaxSpeed() const; + float getParachuteFriction() const { return m_parachute_friction; } + float getParachuteDuration() const { return m_parachute_duration; } + float getParachuteDurationOther() const { return m_parachute_duration_other; } + float getParachuteLboundFranction() const { return m_parachute_lbound_franction; } + float getParachuteUboundFranction() const { return m_parachute_ubound_franction; } + float getParachuteMaxSpeed() const { return m_parachute_max_speed; } - float getBubblegumDuration() const; - float getBubblegumSpeedFraction() const; - float getBubblegumTorque() const; - float getBubblegumFadeInTime() const; - float getBubblegumShieldDuration() const; + float getBubblegumDuration() const { return m_bubblegum_duration; } + float getBubblegumSpeedFraction() const { return m_bubblegum_speed_fraction; } + float getBubblegumTorque() const { return m_bubblegum_torque; } + float getBubblegumFadeInTime() const { return m_bubblegum_fade_in_time; } + float getBubblegumShieldDuration() const { return m_bubblegum_shield_duration; } - float getZipperDuration() const; - float getZipperForce() const; - float getZipperSpeedGain() const; - float getZipperMaxSpeedIncrease() const; - float getZipperFadeOutTime() const; - float getSwatterDuration() const; - float getSwatterDistance() const; - float getSwatterSquashDuration() const; - float getSwatterSquashSlowdown() const; + float getZipperDuration() const { return m_zipper_duration; } + float getZipperForce() const { return m_zipper_force; } + float getZipperSpeedGain() const { return m_zipper_speed_gain; } + float getZipperSpeedIncrease() const { return m_zipper_speed_increase; } + float getZipperFadeOutTime() const { return m_zipper_fade_out_time; } - float getPlungerBandMaxLength() const; - float getPlungerBandForce() const; - float getPlungerBandDuration() const; - float getPlungerBandSpeedIncrease() const; - float getPlungerBandFadeOutTime() const; - float getPlungerInFaceTime() const; + float getSwatterDuration() const { return m_swatter_duration; } + float getSwatterDistance() const { return m_swatter_distance; } + float getSwatterSquashDuration() const { return m_swatter_squash_duration; } + float getSwatterSquashSlowdown() const { return m_swatter_squash_slowdown; } - float getStartupBoost(float time) const; + float getPlungerMaxLength() const { return m_plunger_max_length; } + float getPlungerForce() const { return m_plunger_force; } + float getPlungerDuration() const { return m_plunger_duration; } + float getPlungerSpeedIncrease() const { return m_plunger_speed_increase; } + float getPlungerFadeOutTime() const { return m_plunger_fade_out_time; } + float getPlungerInFaceTime() const { return m_plunger_in_face_time; } - float getRescueVertOffset() const; - float getRescueDuration() const; - float getRescueHeight() const; + float getRescueDuration() const { return m_rescue_duration; } + float getRescueVertOffset() const { return m_rescue_vert_offset; } + float getRescueHeight() const { return m_rescue_height; } - float getExplosionDuration() const; - float getExplosionRadius() const; - float getExplosionInvulnerabilityTime() const; + float getExplosionDuration() const { return m_explosion_duration; } + float getExplosionRadius() const { return m_explosion_radius; } + float getExplosionInvulnerabilityTime() const { return m_explosion_invulnerability_time; } - float getNitroEngineForce() const; - float getNitroConsumption() const; - float getNitroSmallContainer() const; - float getNitroBigContainer() const; - float getNitroMaxSpeedIncrease() const; - float getNitroDuration() const; - float getNitroFadeOutTime() const; - float getNitroMax() const; + float getNitroDuration() const { return m_nitro_duration; } + float getNitroEngineForce() const { return m_nitro_engine_force; } + float getNitroConsumption() const { return m_nitro_consumption; } + float getNitroSmallContainer() const { return m_nitro_small_container; } + float getNitroBigContainer() const { return m_nitro_big_container; } + float getNitroMaxSpeedIncrease() const { return m_nitro_max_speed_increase; } + float getNitroFadeOutTime() const { return m_nitro_fade_out_time; } + float getNitroMax() const { return m_nitro_max; } - float getSlipstreamLength() const; - float getSlipstreamWidth() const; - float getSlipstreamCollectTime() const; - float getSlipstreamUseTime() const; - float getSlipstreamAddPower() const; - float getSlipstreamMinSpeed() const; - float getSlipstreamMaxSpeedIncrease() const; - float getSlipstreamDuration() const; - float getSlipstreamFadeOutTime() const; + float getSlipstreamDuration() const { return m_slipstream_duration; } + float getSlipstreamLength() const { return m_slipstream_length; } + float getSlipstreamWidth() const { return m_slipstream_width; } + float getSlipstreamCollectTime() const { return m_slipstream_collect_time; } + float getSlipstreamUseTime() const { return m_slipstream_use_time; } + float getSlipstreamAddPower() const { return m_slipstream_add_power; } + float getSlipstreamMinSpeed() const { return m_slipstream_min_speed; } + float getSlipstreamMaxSpeedIncrease() const { return m_slipstream_max_speed_increase; } + float getSlipstreamFadeOutTime() const { return m_slipstream_fade_out_time; } + + /* ---------- Getters added by hand ---------- */ + + float getTurnRadius(float steer) const { return m_turn_radius.get(steer); } + float getTurnTimeFullSteer(float steer) const { return m_turn_time_full_steer.get(steer); } + + float getGearSwitchRatio(int gear) const { return m_gear_switch_ratio[gear]; } + float getGearPowerIncrease(int gear) const { return m_gear_power_increase[gear]; } + + Vec3 getWheelPosition(int wheel) const { return m_wheel_position[wheel]; } + + SkiddingProperties* getSkiddingProperties() const { return m_skidding; } protected: - void setSuspensionStiffness(float value); + + /* ---------- Setters generated by the script ---------- */ + + void setSuspensionStiffness(float value) { m_suspension_stiffness = value; } + void setSuspensionRest(float value) { m_suspension_rest = value; } + void setSuspensionTravelCm(float value) { m_suspension_travel_cm = value; } + void setSuspensionExpSpringResponse(float value) { m_suspension_exp_spring_response = value; } + void setSuspensionMaxForce(float value) { m_suspension_max_force = value; } + + void setStabilityRollInfluence(float value) { m_stability_roll_influence = value; } + void setStabilityChassisLinearDamping(float value) { m_stability_chassis_linear_damping = value; } + void setStabilityChassisAngularDamping(float value) { m_stability_chassis_angular_damping = value; } + void setStabilityDownwardImpulseFactor(float value) { m_stability_downward_impulse_factor = value; } + void setStabilityTrackConnectionAccel(float value) { m_stability_track_connection_accel = value; } + void setStabilitySmoothFlyingImpulse(float value) { m_stability_smooth_flying_impulse = value; } + + void setTurnTimeResetSteer(float value) { m_turn_time_reset_steer = value; } + + void setEnginePower(float value) { m_engine_power = value; } + void setEngineMaxSpeed(float value) { m_engine_max_speed = value; } + void setEngineBrakeFactor(float value) { m_engine_brake_factor = value; } + void setEngineBrakeTimeIncrease(float value) { m_engine_brake_time_increase = value; } + void setEngineMaxSpeedReverseRatio(float value) { m_engine_max_speed_reverse_ratio = value; } + + void setMass(float value) { m_mass = value; } + + void setWheelsDampingRelaxation(float value) { m_wheels_damping_relaxation = value; } + void setWheelsDampingCompression(float value) { m_wheels_damping_compression = value; } + void setWheelsWheelRadius(float value) { m_wheels_wheel_radius = value; } + + void setCameraDistance(float value) { m_camera_distance = value; } + void setCameraForwardUpAngle(float value) { m_camera_forward_up_angle = value; } + void setCameraBackwardUpAngle(float value) { m_camera_backward_up_angle = value; } + + void setJumpAnimationTime(float value) { m_jump_animation_time = value; } + + void setLeanMax(float value) { m_lean_max = value; } + void setLeanSpeed(float value) { m_lean_speed = value; } + + void setAnvilDuration(float value) { m_anvil_duration = value; } + void setAnvilWeight(float value) { m_anvil_weight = value; } + void setAnvilSpeedFactor(float value) { m_anvil_speed_factor = value; } + + void setParachuteFriction(float value) { m_parachute_friction = value; } + void setParachuteDuration(float value) { m_parachute_duration = value; } + void setParachuteDurationOther(float value) { m_parachute_duration_other = value; } + void setParachuteLboundFranction(float value) { m_parachute_lbound_franction = value; } + void setParachuteUboundFranction(float value) { m_parachute_ubound_franction = value; } + void setParachuteMaxSpeed(float value) { m_parachute_max_speed = value; } + + void setBubblegumDuration(float value) { m_bubblegum_duration = value; } + void setBubblegumSpeedFraction(float value) { m_bubblegum_speed_fraction = value; } + void setBubblegumTorque(float value) { m_bubblegum_torque = value; } + void setBubblegumFadeInTime(float value) { m_bubblegum_fade_in_time = value; } + void setBubblegumShieldDuration(float value) { m_bubblegum_shield_duration = value; } + + void setZipperDuration(float value) { m_zipper_duration = value; } + void setZipperForce(float value) { m_zipper_force = value; } + void setZipperSpeedGain(float value) { m_zipper_speed_gain = value; } + void setZipperSpeedIncrease(float value) { m_zipper_speed_increase = value; } + void setZipperFadeOutTime(float value) { m_zipper_fade_out_time = value; } + + void setSwatterDuration(float value) { m_swatter_duration = value; } + void setSwatterDistance(float value) { m_swatter_distance = value; } + void setSwatterSquashDuration(float value) { m_swatter_squash_duration = value; } + void setSwatterSquashSlowdown(float value) { m_swatter_squash_slowdown = value; } + + void setPlungerMaxLength(float value) { m_plunger_max_length = value; } + void setPlungerForce(float value) { m_plunger_force = value; } + void setPlungerDuration(float value) { m_plunger_duration = value; } + void setPlungerSpeedIncrease(float value) { m_plunger_speed_increase = value; } + void setPlungerFadeOutTime(float value) { m_plunger_fade_out_time = value; } + void setPlungerInFaceTime(float value) { m_plunger_in_face_time = value; } + + void setRescueDuration(float value) { m_rescue_duration = value; } + void setRescueVertOffset(float value) { m_rescue_vert_offset = value; } + void setRescueHeight(float value) { m_rescue_height = value; } + + void setExplosionDuration(float value) { m_explosion_duration = value; } + void setExplosionRadius(float value) { m_explosion_radius = value; } + void setExplosionInvulnerabilityTime(float value) { m_explosion_invulnerability_time = value; } + + void setNitroDuration(float value) { m_nitro_duration = value; } + void setNitroEngineForce(float value) { m_nitro_engine_force = value; } + void setNitroConsumption(float value) { m_nitro_consumption = value; } + void setNitroSmallContainer(float value) { m_nitro_small_container = value; } + void setNitroBigContainer(float value) { m_nitro_big_container = value; } + void setNitroMaxSpeedIncrease(float value) { m_nitro_max_speed_increase = value; } + void setNitroFadeOutTime(float value) { m_nitro_fade_out_time = value; } + void setNitroMax(float value) { m_nitro_max = value; } + + void setSlipstreamDuration(float value) { m_slipstream_duration = value; } + void setSlipstreamLength(float value) { m_slipstream_length = value; } + void setSlipstreamWidth(float value) { m_slipstream_width = value; } + void setSlipstreamCollectTime(float value) { m_slipstream_collect_time = value; } + void setSlipstreamUseTime(float value) { m_slipstream_use_time = value; } + void setSlipstreamAddPower(float value) { m_slipstream_add_power = value; } + void setSlipstreamMinSpeed(float value) { m_slipstream_min_speed = value; } + void setSlipstreamMaxSpeedIncrease(float value) { m_slipstream_max_speed_increase = value; } + void setSlipstreamFadeOutTime(float value) { m_slipstream_fade_out_time = value; } + + /* ---------- Setters added by hand ---------- */ + + void setGearSwitchRatio(int gear, float value) { m_gear_switch_ratio[gear] = value; } + void setGearPowerIncrease(int gear, float value) { m_gear_power_increase[gear] = value; } + + void setWheelPosition(int wheel, Vec3 value) { m_wheel_position[wheel] = value; } + }; #endif From 78b4634363199cdaf3783786a4db7d156beaab5b Mon Sep 17 00:00:00 2001 From: Flakebi Date: Mon, 13 Apr 2015 11:10:18 +0200 Subject: [PATCH 06/55] Work --- src/karts/abstract_characteristics.cpp | 71 ++-- src/karts/abstract_characteristics.hpp | 475 +++++++------------------ tools/create_kart_properties.py | 9 +- 3 files changed, 173 insertions(+), 382 deletions(-) mode change 100644 => 100755 src/karts/abstract_characteristics.cpp mode change 100644 => 100755 src/karts/abstract_characteristics.hpp mode change 100644 => 100755 tools/create_kart_properties.py diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp old mode 100644 new mode 100755 index bc5165331..11d543133 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristics.cpp @@ -18,37 +18,44 @@ #include "karts/abstract_characteristics.hpp" +#include "utils/log.hpp" + +#include + AbstractCharacteristics::AbstractCharacteristics() { - // Set all variables to their default value (1) - m_suspension_stiffness = m_suspension_rest = m_suspension_travel_cm = - m_suspension_exp_spring_response = m_suspension_max_force = - m_stability_roll_influence = m_stability_chassis_linear_damping = - m_stability_chassis_angular_damping = m_stability_downward_impulse_factor = - m_stability_track_connection_accel = m_stability_smooth_flying_impulse = - m_turn_time_reset_steer = m_engine_power = m_engine_max_speed = - m_engine_brake_factor = m_engine_brake_time_increase = - m_engine_max_speed_reverse_ratio = m_mass = m_wheels_damping_relaxation = - m_wheels_damping_compression = m_wheels_wheel_radius = m_camera_distance = - m_camera_forward_up_angle = m_camera_backward_up_angle = - m_jump_animation_time = m_lean_max = m_lean_speed = m_anvil_duration = - m_anvil_weight = m_anvil_speed_factor = m_parachute_friction = - m_parachute_duration = m_parachute_duration_other = - m_parachute_lbound_franction = m_parachute_ubound_franction = - m_parachute_max_speed = m_bubblegum_duration = m_bubblegum_speed_fraction = - m_bubblegum_torque = m_bubblegum_fade_in_time = - m_bubblegum_shield_duration = m_zipper_duration = m_zipper_force = - m_zipper_speed_gain = m_zipper_speed_increase = m_zipper_fade_out_time = - m_swatter_duration = m_swatter_distance = m_swatter_squash_duration = - m_swatter_squash_slowdown = m_plunger_max_length = m_plunger_force = - m_plunger_duration = m_plunger_speed_increase = m_plunger_fade_out_time = - m_plunger_in_face_time = m_rescue_duration = m_rescue_vert_offset = - m_rescue_height = m_explosion_duration = m_explosion_radius = - m_explosion_invulnerability_time = m_nitro_duration = - m_nitro_engine_force = m_nitro_consumption = m_nitro_small_container = - m_nitro_big_container = m_nitro_max_speed_increase = - m_nitro_fade_out_time = m_nitro_max = m_slipstream_duration = - m_slipstream_length = m_slipstream_width = m_slipstream_collect_time = - m_slipstream_use_time = m_slipstream_add_power = m_slipstream_min_speed = - m_slipstream_max_speed_increase = m_slipstream_fade_out_time = 1; -} \ No newline at end of file +} + +float AbstractCharacteristics::processFloat(CharacteristicType type, float value) const +{ + return getFloat(type); +} + +std::vector AbstractCharacteristics::processFloatVector(CharacteristicType type, const std::vector &value) const +{ + return getFloatVector(type); +} + +InterpolationArray AbstractCharacteristics::processInterpolationArray(CharacteristicType type, const InterpolationArray &value) const +{ + return getInterpolationArray(type); +} + +float AbstractCharacteristics::getFloat(CharacteristicType type) const +{ + Log::fatal("AbstractCharacteristics", "This type does not support getFloat"); + return NAN; +} + +std::vector AbstractCharacteristics::getFloatVector(CharacteristicType type) const +{ + Log::fatal("AbstractCharacteristics", "This type does not support getFloatVector"); + return std::vector(); +} + +InterpolationArray AbstractCharacteristics::getInterpolationArray(CharacteristicType type) const +{ + Log::fatal("AbstractCharacteristics", "This type does not support getInterpolationArray"); + return InterpolationArray(); +} + diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp old mode 100644 new mode 100755 index 0377fdaaa..de1042143 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -40,14 +40,15 @@ class SkiddingProperties; */ class AbstractCharacteristics { -private: - /* Characteristics that are saved as float. Use the following lines as input + /* The following lines are the input for a script that generates code for this class Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse - Turn: timeResetSteer + Turn: radius, timeFullSteer, timeResetSteer Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio + Gear: switchRatio, powerIncrease Mass Wheels: dampingRelaxation, dampingCompression, wheelRadius + Skidding Camera: distance, forwardUpAngle, backwardUpAngle Jump: animationTime Lean: max, speed @@ -57,135 +58,121 @@ private: Zipper: duration, force, speedGain, speedIncrease, fadeOutTime Swatter: duration, distance, squashDuration, squashSlowdown Plunger: maxLength, force, duration, speedIncrease, fadeOutTime, inFaceTime + Startup: time, boost Rescue: duration, vertOffset, height Explosion: duration, radius, invulnerabilityTime Nitro: duration, engineForce, consumption, smallContainer, bigContainer, maxSpeedIncrease, fadeOutTime, max Slipstream: duration, length, width, collectTime, useTime, addPower, minSpeed, maxSpeedIncrease, fadeOutTime */ - /* ---------- Variables generated by the script ---------- */ - - // Suspension - float m_suspension_stiffness; - float m_suspension_rest; - float m_suspension_travel_cm; - float m_suspension_exp_spring_response; - float m_suspension_max_force; - - // Stability - float m_stability_roll_influence; - float m_stability_chassis_linear_damping; - float m_stability_chassis_angular_damping; - float m_stability_downward_impulse_factor; - float m_stability_track_connection_accel; - float m_stability_smooth_flying_impulse; +public: + enum CharacteristicType + { + // Suspension + SUSPENSION_STIFFNESS, + SUSPENSION_REST, + SUSPENSION_TRAVEL_CM, + SUSPENSION_EXP_SPRING_RESPONSE, + SUSPENSION_MAX_FORCE, + // Stability + STABILITY_ROLL_INFLUENCE, + STABILITY_CHASSIS_LINEAR_DAMPING, + STABILITY_CHASSIS_ANGULAR_DAMPING, + STABILITY_DOWNWARD_IMPULSE_FACTOR, + STABILITY_TRACK_CONNECTION_ACCEL, + STABILITY_SMOOTH_FLYING_IMPULSE, + // Turn + TURN_TIME_RESET_STEER, + // Engine + ENGINE_POWER, + ENGINE_MAX_SPEED, + ENGINE_BRAKE_FACTOR, + ENGINE_BRAKE_TIME_INCREASE, + ENGINE_MAX_SPEED_REVERSE_RATIO, + // Mass + MASS, + // Wheels + WHEELS_DAMPING_RELAXATION, + WHEELS_DAMPING_COMPRESSION, + WHEELS_WHEEL_RADIUS, + // Camera + CAMERA_DISTANCE, + CAMERA_FORWARD_UP_ANGLE, + CAMERA_BACKWARD_UP_ANGLE, + // Jump + JUMP_ANIMATION_TIME, + // Lean + LEAN_MAX, + LEAN_SPEED, + // Anvil + ANVIL_DURATION, + ANVIL_WEIGHT, + ANVIL_SPEED_FACTOR, + // Parachute + PARACHUTE_FRICTION, + PARACHUTE_DURATION, + PARACHUTE_DURATION_OTHER, + PARACHUTE_LBOUND_FRANCTION, + PARACHUTE_UBOUND_FRANCTION, + PARACHUTE_MAX_SPEED, + // Bubblegum + BUBBLEGUM_DURATION, + BUBBLEGUM_SPEED_FRACTION, + BUBBLEGUM_TORQUE, + BUBBLEGUM_FADE_IN_TIME, + BUBBLEGUM_SHIELD_DURATION, + // Zipper + ZIPPER_DURATION, + ZIPPER_FORCE, + ZIPPER_SPEED_GAIN, + ZIPPER_SPEED_INCREASE, + ZIPPER_FADE_OUT_TIME, + // Swatter + SWATTER_DURATION, + SWATTER_DISTANCE, + SWATTER_SQUASH_DURATION, + SWATTER_SQUASH_SLOWDOWN, + // Plunger + PLUNGER_MAX_LENGTH, + PLUNGER_FORCE, + PLUNGER_DURATION, + PLUNGER_SPEED_INCREASE, + PLUNGER_FADE_OUT_TIME, + PLUNGER_IN_FACE_TIME, + // Rescue + RESCUE_DURATION, + RESCUE_VERT_OFFSET, + RESCUE_HEIGHT, + // Explosion + EXPLOSION_DURATION, + EXPLOSION_RADIUS, + EXPLOSION_INVULNERABILITY_TIME, + // Nitro + NITRO_DURATION, + NITRO_ENGINE_FORCE, + NITRO_CONSUMPTION, + NITRO_SMALL_CONTAINER, + NITRO_BIG_CONTAINER, + NITRO_MAX_SPEED_INCREASE, + NITRO_FADE_OUT_TIME, + NITRO_MAX, + // Slipstream + SLIPSTREAM_DURATION, + SLIPSTREAM_LENGTH, + SLIPSTREAM_WIDTH, + SLIPSTREAM_COLLECT_TIME, + SLIPSTREAM_USE_TIME, + SLIPSTREAM_ADD_POWER, + SLIPSTREAM_MIN_SPEED, + SLIPSTREAM_MAX_SPEED_INCREASE, + SLIPSTREAM_FADE_OUT_TIME, + // Count + CHARACTERISTIC_COUNT + }; +private: // Turn - float m_turn_time_reset_steer; - - // Engine - float m_engine_power; - float m_engine_max_speed; - float m_engine_brake_factor; - float m_engine_brake_time_increase; - float m_engine_max_speed_reverse_ratio; - - // Mass - float m_mass; - - // Wheels - float m_wheels_damping_relaxation; - float m_wheels_damping_compression; - float m_wheels_wheel_radius; - - // Camera - float m_camera_distance; - float m_camera_forward_up_angle; - float m_camera_backward_up_angle; - - // Jump - float m_jump_animation_time; - - // Lean - float m_lean_max; - float m_lean_speed; - - // Anvil - float m_anvil_duration; - float m_anvil_weight; - float m_anvil_speed_factor; - - // Parachute - float m_parachute_friction; - float m_parachute_duration; - float m_parachute_duration_other; - float m_parachute_lbound_franction; - float m_parachute_ubound_franction; - float m_parachute_max_speed; - - // Bubblegum - float m_bubblegum_duration; - float m_bubblegum_speed_fraction; - float m_bubblegum_torque; - float m_bubblegum_fade_in_time; - float m_bubblegum_shield_duration; - - // Zipper - float m_zipper_duration; - float m_zipper_force; - float m_zipper_speed_gain; - float m_zipper_speed_increase; - float m_zipper_fade_out_time; - - // Swatter - float m_swatter_duration; - float m_swatter_distance; - float m_swatter_squash_duration; - float m_swatter_squash_slowdown; - - // Plunger - float m_plunger_max_length; - float m_plunger_force; - float m_plunger_duration; - float m_plunger_speed_increase; - float m_plunger_fade_out_time; - float m_plunger_in_face_time; - - // Rescue - float m_rescue_duration; - float m_rescue_vert_offset; - float m_rescue_height; - - // Explosion - float m_explosion_duration; - float m_explosion_radius; - float m_explosion_invulnerability_time; - - // Nitro - float m_nitro_duration; - float m_nitro_engine_force; - float m_nitro_consumption; - float m_nitro_small_container; - float m_nitro_big_container; - float m_nitro_max_speed_increase; - float m_nitro_fade_out_time; - float m_nitro_max; - - // Slipstream - float m_slipstream_duration; - float m_slipstream_length; - float m_slipstream_width; - float m_slipstream_collect_time; - float m_slipstream_use_time; - float m_slipstream_add_power; - float m_slipstream_min_speed; - float m_slipstream_max_speed_increase; - float m_slipstream_fade_out_time; - - /* ---------- Variables added by hand ---------- */ - - // Turn - InterpolationArray m_turn_radius; + /*InterpolationArray m_turn_radius; InterpolationArray m_turn_time_full_steer; // Gear @@ -193,242 +180,32 @@ private: std::vector m_gear_power_increase; // Wheels - std::vector m_wheel_position; + std::vector m_wheel_position;*/ // Skid - SkiddingProperties *m_skidding; - - - /* ---------- Miscellaneous ---------- */ + /** The skididing properties for this kart, as a separate object in order + * to reduce dependencies (and therefore compile time) when changing + * any skidding property. */ + /*SkiddingProperties *m_skidding; // Startup std::vector m_startup_time; - std::vector m_startup_boost; + std::vector m_startup_boost;*/ public: AbstractCharacteristics(); - /* ---------- Getters generated by the script ---------- */ + virtual const SkiddingProperties* getSkiddingProperties() const; - float getSuspensionStiffness() const { return m_suspension_stiffness; } - float getSuspensionRest() const { return m_suspension_rest; } - float getSuspensionTravelCm() const { return m_suspension_travel_cm; } - float getSuspensionExpSpringResponse() const { return m_suspension_exp_spring_response; } - float getSuspensionMaxForce() const { return m_suspension_max_force; } + virtual float processFloat(CharacteristicType type, float value) const; + virtual std::vector processFloatVector(CharacteristicType type, + const std::vector &value) const; + virtual InterpolationArray processInterpolationArray(CharacteristicType type, + const InterpolationArray &value) const; - float getStabilityRollInfluence() const { return m_stability_roll_influence; } - float getStabilityChassisLinearDamping() const { return m_stability_chassis_linear_damping; } - float getStabilityChassisAngularDamping() const { return m_stability_chassis_angular_damping; } - float getStabilityDownwardImpulseFactor() const { return m_stability_downward_impulse_factor; } - float getStabilityTrackConnectionAccel() const { return m_stability_track_connection_accel; } - float getStabilitySmoothFlyingImpulse() const { return m_stability_smooth_flying_impulse; } - - float getTurnTimeResetSteer() const { return m_turn_time_reset_steer; } - - float getEnginePower() const { return m_engine_power; } - float getEngineMaxSpeed() const { return m_engine_max_speed; } - float getEngineBrakeFactor() const { return m_engine_brake_factor; } - float getEngineBrakeTimeIncrease() const { return m_engine_brake_time_increase; } - float getEngineMaxSpeedReverseRatio() const { return m_engine_max_speed_reverse_ratio; } - - float getMass() const { return m_mass; } - - float getWheelsDampingRelaxation() const { return m_wheels_damping_relaxation; } - float getWheelsDampingCompression() const { return m_wheels_damping_compression; } - float getWheelsWheelRadius() const { return m_wheels_wheel_radius; } - - float getCameraDistance() const { return m_camera_distance; } - float getCameraForwardUpAngle() const { return m_camera_forward_up_angle; } - float getCameraBackwardUpAngle() const { return m_camera_backward_up_angle; } - - float getJumpAnimationTime() const { return m_jump_animation_time; } - - float getLeanMax() const { return m_lean_max; } - float getLeanSpeed() const { return m_lean_speed; } - - float getAnvilDuration() const { return m_anvil_duration; } - float getAnvilWeight() const { return m_anvil_weight; } - float getAnvilSpeedFactor() const { return m_anvil_speed_factor; } - - float getParachuteFriction() const { return m_parachute_friction; } - float getParachuteDuration() const { return m_parachute_duration; } - float getParachuteDurationOther() const { return m_parachute_duration_other; } - float getParachuteLboundFranction() const { return m_parachute_lbound_franction; } - float getParachuteUboundFranction() const { return m_parachute_ubound_franction; } - float getParachuteMaxSpeed() const { return m_parachute_max_speed; } - - float getBubblegumDuration() const { return m_bubblegum_duration; } - float getBubblegumSpeedFraction() const { return m_bubblegum_speed_fraction; } - float getBubblegumTorque() const { return m_bubblegum_torque; } - float getBubblegumFadeInTime() const { return m_bubblegum_fade_in_time; } - float getBubblegumShieldDuration() const { return m_bubblegum_shield_duration; } - - float getZipperDuration() const { return m_zipper_duration; } - float getZipperForce() const { return m_zipper_force; } - float getZipperSpeedGain() const { return m_zipper_speed_gain; } - float getZipperSpeedIncrease() const { return m_zipper_speed_increase; } - float getZipperFadeOutTime() const { return m_zipper_fade_out_time; } - - float getSwatterDuration() const { return m_swatter_duration; } - float getSwatterDistance() const { return m_swatter_distance; } - float getSwatterSquashDuration() const { return m_swatter_squash_duration; } - float getSwatterSquashSlowdown() const { return m_swatter_squash_slowdown; } - - float getPlungerMaxLength() const { return m_plunger_max_length; } - float getPlungerForce() const { return m_plunger_force; } - float getPlungerDuration() const { return m_plunger_duration; } - float getPlungerSpeedIncrease() const { return m_plunger_speed_increase; } - float getPlungerFadeOutTime() const { return m_plunger_fade_out_time; } - float getPlungerInFaceTime() const { return m_plunger_in_face_time; } - - float getRescueDuration() const { return m_rescue_duration; } - float getRescueVertOffset() const { return m_rescue_vert_offset; } - float getRescueHeight() const { return m_rescue_height; } - - float getExplosionDuration() const { return m_explosion_duration; } - float getExplosionRadius() const { return m_explosion_radius; } - float getExplosionInvulnerabilityTime() const { return m_explosion_invulnerability_time; } - - float getNitroDuration() const { return m_nitro_duration; } - float getNitroEngineForce() const { return m_nitro_engine_force; } - float getNitroConsumption() const { return m_nitro_consumption; } - float getNitroSmallContainer() const { return m_nitro_small_container; } - float getNitroBigContainer() const { return m_nitro_big_container; } - float getNitroMaxSpeedIncrease() const { return m_nitro_max_speed_increase; } - float getNitroFadeOutTime() const { return m_nitro_fade_out_time; } - float getNitroMax() const { return m_nitro_max; } - - float getSlipstreamDuration() const { return m_slipstream_duration; } - float getSlipstreamLength() const { return m_slipstream_length; } - float getSlipstreamWidth() const { return m_slipstream_width; } - float getSlipstreamCollectTime() const { return m_slipstream_collect_time; } - float getSlipstreamUseTime() const { return m_slipstream_use_time; } - float getSlipstreamAddPower() const { return m_slipstream_add_power; } - float getSlipstreamMinSpeed() const { return m_slipstream_min_speed; } - float getSlipstreamMaxSpeedIncrease() const { return m_slipstream_max_speed_increase; } - float getSlipstreamFadeOutTime() const { return m_slipstream_fade_out_time; } - - /* ---------- Getters added by hand ---------- */ - - float getTurnRadius(float steer) const { return m_turn_radius.get(steer); } - float getTurnTimeFullSteer(float steer) const { return m_turn_time_full_steer.get(steer); } - - float getGearSwitchRatio(int gear) const { return m_gear_switch_ratio[gear]; } - float getGearPowerIncrease(int gear) const { return m_gear_power_increase[gear]; } - - Vec3 getWheelPosition(int wheel) const { return m_wheel_position[wheel]; } - - SkiddingProperties* getSkiddingProperties() const { return m_skidding; } - -protected: - - /* ---------- Setters generated by the script ---------- */ - - void setSuspensionStiffness(float value) { m_suspension_stiffness = value; } - void setSuspensionRest(float value) { m_suspension_rest = value; } - void setSuspensionTravelCm(float value) { m_suspension_travel_cm = value; } - void setSuspensionExpSpringResponse(float value) { m_suspension_exp_spring_response = value; } - void setSuspensionMaxForce(float value) { m_suspension_max_force = value; } - - void setStabilityRollInfluence(float value) { m_stability_roll_influence = value; } - void setStabilityChassisLinearDamping(float value) { m_stability_chassis_linear_damping = value; } - void setStabilityChassisAngularDamping(float value) { m_stability_chassis_angular_damping = value; } - void setStabilityDownwardImpulseFactor(float value) { m_stability_downward_impulse_factor = value; } - void setStabilityTrackConnectionAccel(float value) { m_stability_track_connection_accel = value; } - void setStabilitySmoothFlyingImpulse(float value) { m_stability_smooth_flying_impulse = value; } - - void setTurnTimeResetSteer(float value) { m_turn_time_reset_steer = value; } - - void setEnginePower(float value) { m_engine_power = value; } - void setEngineMaxSpeed(float value) { m_engine_max_speed = value; } - void setEngineBrakeFactor(float value) { m_engine_brake_factor = value; } - void setEngineBrakeTimeIncrease(float value) { m_engine_brake_time_increase = value; } - void setEngineMaxSpeedReverseRatio(float value) { m_engine_max_speed_reverse_ratio = value; } - - void setMass(float value) { m_mass = value; } - - void setWheelsDampingRelaxation(float value) { m_wheels_damping_relaxation = value; } - void setWheelsDampingCompression(float value) { m_wheels_damping_compression = value; } - void setWheelsWheelRadius(float value) { m_wheels_wheel_radius = value; } - - void setCameraDistance(float value) { m_camera_distance = value; } - void setCameraForwardUpAngle(float value) { m_camera_forward_up_angle = value; } - void setCameraBackwardUpAngle(float value) { m_camera_backward_up_angle = value; } - - void setJumpAnimationTime(float value) { m_jump_animation_time = value; } - - void setLeanMax(float value) { m_lean_max = value; } - void setLeanSpeed(float value) { m_lean_speed = value; } - - void setAnvilDuration(float value) { m_anvil_duration = value; } - void setAnvilWeight(float value) { m_anvil_weight = value; } - void setAnvilSpeedFactor(float value) { m_anvil_speed_factor = value; } - - void setParachuteFriction(float value) { m_parachute_friction = value; } - void setParachuteDuration(float value) { m_parachute_duration = value; } - void setParachuteDurationOther(float value) { m_parachute_duration_other = value; } - void setParachuteLboundFranction(float value) { m_parachute_lbound_franction = value; } - void setParachuteUboundFranction(float value) { m_parachute_ubound_franction = value; } - void setParachuteMaxSpeed(float value) { m_parachute_max_speed = value; } - - void setBubblegumDuration(float value) { m_bubblegum_duration = value; } - void setBubblegumSpeedFraction(float value) { m_bubblegum_speed_fraction = value; } - void setBubblegumTorque(float value) { m_bubblegum_torque = value; } - void setBubblegumFadeInTime(float value) { m_bubblegum_fade_in_time = value; } - void setBubblegumShieldDuration(float value) { m_bubblegum_shield_duration = value; } - - void setZipperDuration(float value) { m_zipper_duration = value; } - void setZipperForce(float value) { m_zipper_force = value; } - void setZipperSpeedGain(float value) { m_zipper_speed_gain = value; } - void setZipperSpeedIncrease(float value) { m_zipper_speed_increase = value; } - void setZipperFadeOutTime(float value) { m_zipper_fade_out_time = value; } - - void setSwatterDuration(float value) { m_swatter_duration = value; } - void setSwatterDistance(float value) { m_swatter_distance = value; } - void setSwatterSquashDuration(float value) { m_swatter_squash_duration = value; } - void setSwatterSquashSlowdown(float value) { m_swatter_squash_slowdown = value; } - - void setPlungerMaxLength(float value) { m_plunger_max_length = value; } - void setPlungerForce(float value) { m_plunger_force = value; } - void setPlungerDuration(float value) { m_plunger_duration = value; } - void setPlungerSpeedIncrease(float value) { m_plunger_speed_increase = value; } - void setPlungerFadeOutTime(float value) { m_plunger_fade_out_time = value; } - void setPlungerInFaceTime(float value) { m_plunger_in_face_time = value; } - - void setRescueDuration(float value) { m_rescue_duration = value; } - void setRescueVertOffset(float value) { m_rescue_vert_offset = value; } - void setRescueHeight(float value) { m_rescue_height = value; } - - void setExplosionDuration(float value) { m_explosion_duration = value; } - void setExplosionRadius(float value) { m_explosion_radius = value; } - void setExplosionInvulnerabilityTime(float value) { m_explosion_invulnerability_time = value; } - - void setNitroDuration(float value) { m_nitro_duration = value; } - void setNitroEngineForce(float value) { m_nitro_engine_force = value; } - void setNitroConsumption(float value) { m_nitro_consumption = value; } - void setNitroSmallContainer(float value) { m_nitro_small_container = value; } - void setNitroBigContainer(float value) { m_nitro_big_container = value; } - void setNitroMaxSpeedIncrease(float value) { m_nitro_max_speed_increase = value; } - void setNitroFadeOutTime(float value) { m_nitro_fade_out_time = value; } - void setNitroMax(float value) { m_nitro_max = value; } - - void setSlipstreamDuration(float value) { m_slipstream_duration = value; } - void setSlipstreamLength(float value) { m_slipstream_length = value; } - void setSlipstreamWidth(float value) { m_slipstream_width = value; } - void setSlipstreamCollectTime(float value) { m_slipstream_collect_time = value; } - void setSlipstreamUseTime(float value) { m_slipstream_use_time = value; } - void setSlipstreamAddPower(float value) { m_slipstream_add_power = value; } - void setSlipstreamMinSpeed(float value) { m_slipstream_min_speed = value; } - void setSlipstreamMaxSpeedIncrease(float value) { m_slipstream_max_speed_increase = value; } - void setSlipstreamFadeOutTime(float value) { m_slipstream_fade_out_time = value; } - - /* ---------- Setters added by hand ---------- */ - - void setGearSwitchRatio(int gear, float value) { m_gear_switch_ratio[gear] = value; } - void setGearPowerIncrease(int gear, float value) { m_gear_power_increase[gear] = value; } - - void setWheelPosition(int wheel, Vec3 value) { m_wheel_position[wheel] = value; } - + virtual float getFloat(CharacteristicType type) const; + virtual std::vector getFloatVector(CharacteristicType type) const; + virtual InterpolationArray getInterpolationArray(CharacteristicType type) const; }; #endif diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py old mode 100644 new mode 100755 index 3b3a8e583..9d6dedddb --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -104,6 +104,13 @@ def main(): # Print the results print("Variables ****************************************") + for g in groups: + print(" // {0}".format(g.baseName.title())) + for n in g.subNames: + print(" {0},".format(joinSubName(g, n, False).upper())) + + # Commented out code + """print("Variables ****************************************") for g in groups: print() print(" // {0}".format(g.baseName.title())) @@ -153,7 +160,7 @@ def main(): 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)))) + " " * (nameLengthUnderscore - len(nameUnderscore))))""" if __name__ == '__main__': main() From 2b9a7a2016a74733b30839f3886eea4ef62b8afc Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 15 Apr 2015 09:01:23 +0200 Subject: [PATCH 07/55] More work --- src/karts/abstract_characteristics.hpp | 126 ++----------------------- tools/create_kart_properties.py | 119 ++++++++++++----------- 2 files changed, 73 insertions(+), 172 deletions(-) diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp index de1042143..c19146c1d 100755 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -40,14 +40,15 @@ class SkiddingProperties; */ class AbstractCharacteristics { + //FIXME is wheelPosition needed?? /* The following lines are the input for a script that generates code for this class Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse - Turn: radius, timeFullSteer, timeResetSteer + Turn: radius(InterpolationArray), timeFullSteer, timeResetSteer, timeFullSteer(InterpolationArray) Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio - Gear: switchRatio, powerIncrease + Gear: switchRatio(std::vector/floatVector), powerIncrease(std::vector/floatVector) Mass - Wheels: dampingRelaxation, dampingCompression, wheelRadius + Wheels: dampingRelaxation, dampingCompression, radius, position(std::vector/floatVector) Skidding Camera: distance, forwardUpAngle, backwardUpAngle Jump: animationTime @@ -58,7 +59,7 @@ class AbstractCharacteristics Zipper: duration, force, speedGain, speedIncrease, fadeOutTime Swatter: duration, distance, squashDuration, squashSlowdown Plunger: maxLength, force, duration, speedIncrease, fadeOutTime, inFaceTime - Startup: time, boost + Startup: time(std::vector/floatVector), boost(std::vector/floatVector) Rescue: duration, vertOffset, height Explosion: duration, radius, invulnerabilityTime Nitro: duration, engineForce, consumption, smallContainer, bigContainer, maxSpeedIncrease, fadeOutTime, max @@ -68,129 +69,16 @@ class AbstractCharacteristics public: enum CharacteristicType { - // Suspension - SUSPENSION_STIFFNESS, - SUSPENSION_REST, - SUSPENSION_TRAVEL_CM, - SUSPENSION_EXP_SPRING_RESPONSE, - SUSPENSION_MAX_FORCE, - // Stability - STABILITY_ROLL_INFLUENCE, - STABILITY_CHASSIS_LINEAR_DAMPING, - STABILITY_CHASSIS_ANGULAR_DAMPING, - STABILITY_DOWNWARD_IMPULSE_FACTOR, - STABILITY_TRACK_CONNECTION_ACCEL, - STABILITY_SMOOTH_FLYING_IMPULSE, - // Turn - TURN_TIME_RESET_STEER, - // Engine - ENGINE_POWER, - ENGINE_MAX_SPEED, - ENGINE_BRAKE_FACTOR, - ENGINE_BRAKE_TIME_INCREASE, - ENGINE_MAX_SPEED_REVERSE_RATIO, - // Mass - MASS, - // Wheels - WHEELS_DAMPING_RELAXATION, - WHEELS_DAMPING_COMPRESSION, - WHEELS_WHEEL_RADIUS, - // Camera - CAMERA_DISTANCE, - CAMERA_FORWARD_UP_ANGLE, - CAMERA_BACKWARD_UP_ANGLE, - // Jump - JUMP_ANIMATION_TIME, - // Lean - LEAN_MAX, - LEAN_SPEED, - // Anvil - ANVIL_DURATION, - ANVIL_WEIGHT, - ANVIL_SPEED_FACTOR, - // Parachute - PARACHUTE_FRICTION, - PARACHUTE_DURATION, - PARACHUTE_DURATION_OTHER, - PARACHUTE_LBOUND_FRANCTION, - PARACHUTE_UBOUND_FRANCTION, - PARACHUTE_MAX_SPEED, - // Bubblegum - BUBBLEGUM_DURATION, - BUBBLEGUM_SPEED_FRACTION, - BUBBLEGUM_TORQUE, - BUBBLEGUM_FADE_IN_TIME, - BUBBLEGUM_SHIELD_DURATION, - // Zipper - ZIPPER_DURATION, - ZIPPER_FORCE, - ZIPPER_SPEED_GAIN, - ZIPPER_SPEED_INCREASE, - ZIPPER_FADE_OUT_TIME, - // Swatter - SWATTER_DURATION, - SWATTER_DISTANCE, - SWATTER_SQUASH_DURATION, - SWATTER_SQUASH_SLOWDOWN, - // Plunger - PLUNGER_MAX_LENGTH, - PLUNGER_FORCE, - PLUNGER_DURATION, - PLUNGER_SPEED_INCREASE, - PLUNGER_FADE_OUT_TIME, - PLUNGER_IN_FACE_TIME, - // Rescue - RESCUE_DURATION, - RESCUE_VERT_OFFSET, - RESCUE_HEIGHT, - // Explosion - EXPLOSION_DURATION, - EXPLOSION_RADIUS, - EXPLOSION_INVULNERABILITY_TIME, - // Nitro - NITRO_DURATION, - NITRO_ENGINE_FORCE, - NITRO_CONSUMPTION, - NITRO_SMALL_CONTAINER, - NITRO_BIG_CONTAINER, - NITRO_MAX_SPEED_INCREASE, - NITRO_FADE_OUT_TIME, - NITRO_MAX, - // Slipstream - SLIPSTREAM_DURATION, - SLIPSTREAM_LENGTH, - SLIPSTREAM_WIDTH, - SLIPSTREAM_COLLECT_TIME, - SLIPSTREAM_USE_TIME, - SLIPSTREAM_ADD_POWER, - SLIPSTREAM_MIN_SPEED, - SLIPSTREAM_MAX_SPEED_INCREASE, - SLIPSTREAM_FADE_OUT_TIME, + // Script-generated content // Count CHARACTERISTIC_COUNT }; private: - // Turn - /*InterpolationArray m_turn_radius; - InterpolationArray m_turn_time_full_steer; - - // Gear - std::vector m_gear_switch_ratio; - std::vector m_gear_power_increase; - - // Wheels - std::vector m_wheel_position;*/ - - // Skid /** The skididing properties for this kart, as a separate object in order * to reduce dependencies (and therefore compile time) when changing * any skidding property. */ - /*SkiddingProperties *m_skidding; - - // Startup - std::vector m_startup_time; - std::vector m_startup_boost;*/ + //SkiddingProperties *m_skidding; public: AbstractCharacteristics(); diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 9d6dedddb..0006eac0a 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -20,13 +20,54 @@ # This script takes the list from abstract_characteristics.hpp and creates the code # An empty line is expected to end the input +class GroupMember: + def __init__(self, name, typeC, typeStr): + self.name = name + self.typeC = typeC + self.typeStr = typeStr + + """E.g. power(std::vector/floatVector) + or speed(InterpolationArray) + The default type is float""" + def parse(content): + typeC = "float" + typeStr = typeC + name = content.strip() + pos = content.find("(") + end = content.find(")", pos) + if pos != -1 and end != -1: + name = content[:pos].strip() + pos2 = content.find("/", pos, end) + if pos2 != -1: + typeC = content[pos + 1:pos2].strip() + typeStr = content[pos2 + 1:end].strip() + else: + typeC = content[pos + 1:end].strip() + typeStr = typeC + + return GroupMember(name, typeC, typeStr) + class Group: def __init__(self, baseName): self.baseName = baseName - self.subNames = [] + self.members = [] - def addName(self, name): - self.subNames.append(name) + def addMember(self, content): + self.members.append(GroupMember.parse(content)) + + """E.g. engine: power, gears(std::vector/Gears) + or mass(float) or only mass""" + def parse(content): + pos = content.find(":") + if pos == -1: + group = Group("") + group.addMember(content) + return group + else: + group = Group(content[:pos].strip()) + for m in content[pos + 1:].split(","): + group.addMember(m) + return group """Creates a list of words from a titlecase string""" def toList(name): @@ -43,8 +84,8 @@ def toList(name): """titleCase: true = result is titlecase false = result has underscores""" -def joinSubName(g, subName, titleCase): - words = toList(g.baseName) + toList(subName) +def joinSubName(group, member, titleCase): + words = toList(group.baseName) + toList(member.name) first = True if titleCase: words = map(lambda w: w.title(), words) @@ -60,54 +101,39 @@ def main(): line = input() if len(line) == 0: break - - # Search base name - pos = line.find(":") - if pos != -1: - group = Group(line[:pos].strip()) - # Find all subnames - while True: - pos2 = line.find(",", pos + 1) - # Are we already at the end? - if pos2 == -1: - part = line[pos + 1:].strip() - else: - part = line[pos + 1:pos2].strip() - - if len(part) != 0: - group.addName(part) - - # Find the next one - pos, pos2 = pos2, pos - - # We are at the end, so stop searching - if pos == -1: - break - groups.append(group) - else: - # There is not base name, so use the whole line as one word - group = Group(line.strip()) - group.addName("") - groups.append(group) + groups.append(Group.parse(line)) # Find longest name to align the function bodies nameLengthTitle = 0 nameLengthUnderscore = 0 for g in groups: - for n in g.subNames: - l = len(joinSubName(g, n, True)) + for m in g.members: + l = len(joinSubName(g, m, True)) if l > nameLengthTitle: nameLengthTitle = l - l = len(joinSubName(g, n, False)) + l = len(joinSubName(g, m, False)) if l > nameLengthUnderscore: nameLengthUnderscore = l # Print the results - print("Variables ****************************************") + print("Enum ****************************************") for g in groups: + print() print(" // {0}".format(g.baseName.title())) - for n in g.subNames: - print(" {0},".format(joinSubName(g, n, False).upper())) + for m in g.members: + print(" {0},".format(joinSubName(g, m, False).upper())) + + print() + print() + print("Getters ****************************************") + + for g in groups: + print() + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False) + print(" {0} get{1}() const {{ return m_{2}; }}". + format(m.typeC, nameTitle, nameUnderscore)) # Commented out code """print("Variables ****************************************") @@ -137,19 +163,6 @@ def main(): line += "1;" print(line) - print() - print() - print("Getters ****************************************") - - for g in groups: - print() - for n in g.subNames: - nameTitle = joinSubName(g, n, True) - nameUnderscore = joinSubName(g, n, False) - print(" float get{0}(){2} const {{ return m_{1};{3} }}". - format(nameTitle, nameUnderscore, " " * (nameLengthTitle - len(nameTitle)), - " " * (nameLengthUnderscore - len(nameUnderscore)))) - print() print() print("Setters ****************************************") From ddb850b149fb56416f575911c40170f22339acb2 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Thu, 16 Apr 2015 17:50:17 +0200 Subject: [PATCH 08/55] Add new files --- src/karts/abstract_characteristics.cpp | 1075 +++++++++++++++++++++++- src/karts/abstract_characteristics.hpp | 303 ++++++- src/karts/cached_characteristics.cpp | 170 ++++ src/karts/cached_characteristics.hpp | 55 ++ src/karts/combined_characteristics.cpp | 42 + src/karts/combined_characteristics.hpp | 37 + src/karts/xml_characteristics.cpp | 45 + src/karts/xml_characteristics.hpp | 43 + tools/create_kart_properties.py | 142 +++- 9 files changed, 1823 insertions(+), 89 deletions(-) create mode 100644 src/karts/cached_characteristics.cpp create mode 100644 src/karts/cached_characteristics.hpp create mode 100644 src/karts/combined_characteristics.cpp create mode 100644 src/karts/combined_characteristics.hpp create mode 100644 src/karts/xml_characteristics.cpp create mode 100644 src/karts/xml_characteristics.hpp diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp index 11d543133..c2d03744f 100755 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristics.cpp @@ -19,6 +19,7 @@ #include "karts/abstract_characteristics.hpp" #include "utils/log.hpp" +#include "utils/interpolation_array.hpp" #include @@ -26,36 +27,1080 @@ AbstractCharacteristics::AbstractCharacteristics() { } -float AbstractCharacteristics::processFloat(CharacteristicType type, float value) const +const SkiddingProperties* AbstractCharacteristics::getSkiddingProperties() const { - return getFloat(type); + return nullptr; } -std::vector AbstractCharacteristics::processFloatVector(CharacteristicType type, const std::vector &value) const +void AbstractCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const { - return getFloatVector(type); + Log::warn("AbstractCharacteristics", "This type does not do anything"); } -InterpolationArray AbstractCharacteristics::processInterpolationArray(CharacteristicType type, const InterpolationArray &value) const + +AbstractCharacteristics::ValueType AbstractCharacteristics::getType(CharacteristicType type) { - return getInterpolationArray(type); + switch (type) + { + case CHARACTERISTIC_COUNT: + Log::fatal("AbstractCharacteristics::getType", "Can't get type of COUNT"); + break; + // Script-generated content + case SUSPENSION_STIFFNESS: + return TYPE_FLOAT; + case SUSPENSION_REST: + return TYPE_FLOAT; + case SUSPENSION_TRAVEL_CM: + return TYPE_FLOAT; + case SUSPENSION_EXP_SPRING_RESPONSE: + return TYPE_FLOAT; + case SUSPENSION_MAX_FORCE: + return TYPE_FLOAT; + case STABILITY_ROLL_INFLUENCE: + return TYPE_FLOAT; + case STABILITY_CHASSIS_LINEAR_DAMPING: + return TYPE_FLOAT; + case STABILITY_CHASSIS_ANGULAR_DAMPING: + return TYPE_FLOAT; + case STABILITY_DOWNWARD_IMPULSE_FACTOR: + return TYPE_FLOAT; + case STABILITY_TRACK_CONNECTION_ACCEL: + return TYPE_FLOAT; + case STABILITY_SMOOTH_FLYING_IMPULSE: + return TYPE_FLOAT; + case TURN_RADIUS: + return TYPE_INTERPOLATION_ARRAY; + case TURN_TIME_RESET_STEER: + return TYPE_FLOAT; + case TURN_TIME_FULL_STEER: + return TYPE_INTERPOLATION_ARRAY; + case ENGINE_POWER: + return TYPE_FLOAT; + case ENGINE_MAX_SPEED: + return TYPE_FLOAT; + case ENGINE_BRAKE_FACTOR: + return TYPE_FLOAT; + case ENGINE_BRAKE_TIME_INCREASE: + return TYPE_FLOAT; + case ENGINE_MAX_SPEED_REVERSE_RATIO: + return TYPE_FLOAT; + case GEAR_SWITCH_RATIO: + return TYPE_FLOAT_VECTOR; + case GEAR_POWER_INCREASE: + return TYPE_FLOAT_VECTOR; + case MASS: + return TYPE_FLOAT; + case WHEELS_DAMPING_RELAXATION: + return TYPE_FLOAT; + case WHEELS_DAMPING_COMPRESSION: + return TYPE_FLOAT; + case WHEELS_RADIUS: + return TYPE_FLOAT; + case WHEELS_POSITION: + return TYPE_FLOAT_VECTOR; + case CAMERA_DISTANCE: + return TYPE_FLOAT; + case CAMERA_FORWARD_UP_ANGLE: + return TYPE_FLOAT; + case CAMERA_BACKWARD_UP_ANGLE: + return TYPE_FLOAT; + case JUMP_ANIMATION_TIME: + return TYPE_FLOAT; + case LEAN_MAX: + return TYPE_FLOAT; + case LEAN_SPEED: + return TYPE_FLOAT; + case ANVIL_DURATION: + return TYPE_FLOAT; + case ANVIL_WEIGHT: + return TYPE_FLOAT; + case ANVIL_SPEED_FACTOR: + return TYPE_FLOAT; + case PARACHUTE_FRICTION: + return TYPE_FLOAT; + case PARACHUTE_DURATION: + return TYPE_FLOAT; + case PARACHUTE_DURATION_OTHER: + return TYPE_FLOAT; + case PARACHUTE_LBOUND_FRANCTION: + return TYPE_FLOAT; + case PARACHUTE_UBOUND_FRANCTION: + return TYPE_FLOAT; + case PARACHUTE_MAX_SPEED: + return TYPE_FLOAT; + case BUBBLEGUM_DURATION: + return TYPE_FLOAT; + case BUBBLEGUM_SPEED_FRACTION: + return TYPE_FLOAT; + case BUBBLEGUM_TORQUE: + return TYPE_FLOAT; + case BUBBLEGUM_FADE_IN_TIME: + return TYPE_FLOAT; + case BUBBLEGUM_SHIELD_DURATION: + return TYPE_FLOAT; + case ZIPPER_DURATION: + return TYPE_FLOAT; + case ZIPPER_FORCE: + return TYPE_FLOAT; + case ZIPPER_SPEED_GAIN: + return TYPE_FLOAT; + case ZIPPER_SPEED_INCREASE: + return TYPE_FLOAT; + case ZIPPER_FADE_OUT_TIME: + return TYPE_FLOAT; + case SWATTER_DURATION: + return TYPE_FLOAT; + case SWATTER_DISTANCE: + return TYPE_FLOAT; + case SWATTER_SQUASH_DURATION: + return TYPE_FLOAT; + case SWATTER_SQUASH_SLOWDOWN: + return TYPE_FLOAT; + case PLUNGER_MAX_LENGTH: + return TYPE_FLOAT; + case PLUNGER_FORCE: + return TYPE_FLOAT; + case PLUNGER_DURATION: + return TYPE_FLOAT; + case PLUNGER_SPEED_INCREASE: + return TYPE_FLOAT; + case PLUNGER_FADE_OUT_TIME: + return TYPE_FLOAT; + case PLUNGER_IN_FACE_TIME: + return TYPE_FLOAT; + case STARTUP_TIME: + return TYPE_FLOAT_VECTOR; + case STARTUP_BOOST: + return TYPE_FLOAT_VECTOR; + case RESCUE_DURATION: + return TYPE_FLOAT; + case RESCUE_VERT_OFFSET: + return TYPE_FLOAT; + case RESCUE_HEIGHT: + return TYPE_FLOAT; + case EXPLOSION_DURATION: + return TYPE_FLOAT; + case EXPLOSION_RADIUS: + return TYPE_FLOAT; + case EXPLOSION_INVULNERABILITY_TIME: + return TYPE_FLOAT; + case NITRO_DURATION: + return TYPE_FLOAT; + case NITRO_ENGINE_FORCE: + return TYPE_FLOAT; + case NITRO_CONSUMPTION: + return TYPE_FLOAT; + case NITRO_SMALL_CONTAINER: + return TYPE_FLOAT; + case NITRO_BIG_CONTAINER: + return TYPE_FLOAT; + case NITRO_MAX_SPEED_INCREASE: + return TYPE_FLOAT; + case NITRO_FADE_OUT_TIME: + return TYPE_FLOAT; + case NITRO_MAX: + return TYPE_FLOAT; + case SLIPSTREAM_DURATION: + return TYPE_FLOAT; + case SLIPSTREAM_LENGTH: + return TYPE_FLOAT; + case SLIPSTREAM_WIDTH: + return TYPE_FLOAT; + case SLIPSTREAM_COLLECT_TIME: + return TYPE_FLOAT; + case SLIPSTREAM_USE_TIME: + return TYPE_FLOAT; + case SLIPSTREAM_ADD_POWER: + return TYPE_FLOAT; + case SLIPSTREAM_MIN_SPEED: + return TYPE_FLOAT; + case SLIPSTREAM_MAX_SPEED_INCREASE: + return TYPE_FLOAT; + case SLIPSTREAM_FADE_OUT_TIME: + return TYPE_FLOAT; + } + Log::fatal("AbstractCharacteristics::getType", "Unknown type"); + return TYPE_FLOAT; } -float AbstractCharacteristics::getFloat(CharacteristicType type) const +// Script-generated getter +float AbstractCharacteristics::getSuspensionStiffness() const { - Log::fatal("AbstractCharacteristics", "This type does not support getFloat"); - return NAN; + float result; + bool isSet = false; + process(SUSPENSION_STIFFNESS, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_STIFFNESS"); + return result; } -std::vector AbstractCharacteristics::getFloatVector(CharacteristicType type) const +float AbstractCharacteristics::getSuspensionRest() const { - Log::fatal("AbstractCharacteristics", "This type does not support getFloatVector"); - return std::vector(); + float result; + bool isSet = false; + process(SUSPENSION_REST, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_REST"); + return result; } -InterpolationArray AbstractCharacteristics::getInterpolationArray(CharacteristicType type) const +float AbstractCharacteristics::getSuspensionTravelCm() const { - Log::fatal("AbstractCharacteristics", "This type does not support getInterpolationArray"); - return InterpolationArray(); + float result; + bool isSet = false; + process(SUSPENSION_TRAVEL_CM, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_TRAVEL_CM"); + return result; +} + +float AbstractCharacteristics::getSuspensionExpSpringResponse() const +{ + float result; + bool isSet = false; + process(SUSPENSION_EXP_SPRING_RESPONSE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_EXP_SPRING_RESPONSE"); + return result; +} + +float AbstractCharacteristics::getSuspensionMaxForce() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_ROLL_INFLUENCE"); + return result; +} + +float AbstractCharacteristics::getStabilityChassisLinearDamping() const +{ + float result; + bool isSet = false; + process(STABILITY_CHASSIS_LINEAR_DAMPING, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_CHASSIS_LINEAR_DAMPING"); + return result; +} + +float AbstractCharacteristics::getStabilityChassisAngularDamping() const +{ + float result; + bool isSet = false; + process(STABILITY_CHASSIS_ANGULAR_DAMPING, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_CHASSIS_ANGULAR_DAMPING"); + return result; +} + +float AbstractCharacteristics::getStabilityDownwardImpulseFactor() const +{ + float result; + bool isSet = false; + process(STABILITY_DOWNWARD_IMPULSE_FACTOR, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_DOWNWARD_IMPULSE_FACTOR"); + return result; +} + +float AbstractCharacteristics::getStabilityTrackConnectionAccel() const +{ + float result; + bool isSet = false; + process(STABILITY_TRACK_CONNECTION_ACCEL, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_TRACK_CONNECTION_ACCEL"); + return result; +} + +float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_RADIUS"); + return std::move(result); +} + +float AbstractCharacteristics::getTurnTimeResetSteer() const +{ + float result; + bool isSet = false; + process(TURN_TIME_RESET_STEER, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_TIME_RESET_STEER"); + return result; +} + +InterpolationArray&& AbstractCharacteristics::getTurnTimeFullSteer() const +{ + InterpolationArray result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_POWER"); + return result; +} + +float AbstractCharacteristics::getEngineMaxSpeed() const +{ + float result; + bool isSet = false; + process(ENGINE_MAX_SPEED, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_MAX_SPEED"); + return result; +} + +float AbstractCharacteristics::getEngineBrakeFactor() const +{ + float result; + bool isSet = false; + process(ENGINE_BRAKE_FACTOR, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_BRAKE_FACTOR"); + return result; +} + +float AbstractCharacteristics::getEngineBrakeTimeIncrease() const +{ + float result; + bool isSet = false; + process(ENGINE_BRAKE_TIME_INCREASE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_BRAKE_TIME_INCREASE"); + return result; +} + +float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic GEAR_SWITCH_RATIO"); + return std::move(result); +} + +std::vector&& AbstractCharacteristics::getGearPowerIncrease() const +{ + std::vector result; + bool isSet = false; + 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); + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_DAMPING_RELAXATION"); + return result; +} + +float AbstractCharacteristics::getWheelsDampingCompression() const +{ + float result; + bool isSet = false; + process(WHEELS_DAMPING_COMPRESSION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_DAMPING_COMPRESSION"); + return result; +} + +float AbstractCharacteristics::getWheelsRadius() const +{ + float result; + bool isSet = false; + process(WHEELS_RADIUS, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_RADIUS"); + return result; +} + +std::vector&& AbstractCharacteristics::getWheelsPosition() const +{ + std::vector result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_DISTANCE"); + return result; +} + +float AbstractCharacteristics::getCameraForwardUpAngle() const +{ + float result; + bool isSet = false; + process(CAMERA_FORWARD_UP_ANGLE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_FORWARD_UP_ANGLE"); + return result; +} + +float AbstractCharacteristics::getCameraBackwardUpAngle() const +{ + float result; + bool isSet = false; + 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); + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic LEAN_MAX"); + return result; +} + +float AbstractCharacteristics::getLeanSpeed() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_DURATION"); + return result; +} + +float AbstractCharacteristics::getAnvilWeight() const +{ + float result; + bool isSet = false; + process(ANVIL_WEIGHT, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_WEIGHT"); + return result; +} + +float AbstractCharacteristics::getAnvilSpeedFactor() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_FRICTION"); + return result; +} + +float AbstractCharacteristics::getParachuteDuration() const +{ + float result; + bool isSet = false; + process(PARACHUTE_DURATION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_DURATION"); + return result; +} + +float AbstractCharacteristics::getParachuteDurationOther() const +{ + float result; + bool isSet = false; + process(PARACHUTE_DURATION_OTHER, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_DURATION_OTHER"); + return result; +} + +float AbstractCharacteristics::getParachuteLboundFranction() const +{ + float result; + bool isSet = false; + process(PARACHUTE_LBOUND_FRANCTION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_LBOUND_FRANCTION"); + return result; +} + +float AbstractCharacteristics::getParachuteUboundFranction() const +{ + float result; + bool isSet = false; + process(PARACHUTE_UBOUND_FRANCTION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_UBOUND_FRANCTION"); + return result; +} + +float AbstractCharacteristics::getParachuteMaxSpeed() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_DURATION"); + return result; +} + +float AbstractCharacteristics::getBubblegumSpeedFraction() const +{ + float result; + bool isSet = false; + process(BUBBLEGUM_SPEED_FRACTION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_SPEED_FRACTION"); + return result; +} + +float AbstractCharacteristics::getBubblegumTorque() const +{ + float result; + bool isSet = false; + process(BUBBLEGUM_TORQUE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_TORQUE"); + return result; +} + +float AbstractCharacteristics::getBubblegumFadeInTime() const +{ + float result; + bool isSet = false; + process(BUBBLEGUM_FADE_IN_TIME, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_FADE_IN_TIME"); + return result; +} + +float AbstractCharacteristics::getBubblegumShieldDuration() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_DURATION"); + return result; +} + +float AbstractCharacteristics::getZipperForce() const +{ + float result; + bool isSet = false; + process(ZIPPER_FORCE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_FORCE"); + return result; +} + +float AbstractCharacteristics::getZipperSpeedGain() const +{ + float result; + bool isSet = false; + process(ZIPPER_SPEED_GAIN, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_SPEED_GAIN"); + return result; +} + +float AbstractCharacteristics::getZipperSpeedIncrease() const +{ + float result; + bool isSet = false; + process(ZIPPER_SPEED_INCREASE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_SPEED_INCREASE"); + return result; +} + +float AbstractCharacteristics::getZipperFadeOutTime() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_DURATION"); + return result; +} + +float AbstractCharacteristics::getSwatterDistance() const +{ + float result; + bool isSet = false; + process(SWATTER_DISTANCE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_DISTANCE"); + return result; +} + +float AbstractCharacteristics::getSwatterSquashDuration() const +{ + float result; + bool isSet = false; + process(SWATTER_SQUASH_DURATION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_SQUASH_DURATION"); + return result; +} + +float AbstractCharacteristics::getSwatterSquashSlowdown() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_MAX_LENGTH"); + return result; +} + +float AbstractCharacteristics::getPlungerForce() const +{ + float result; + bool isSet = false; + process(PLUNGER_FORCE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_FORCE"); + return result; +} + +float AbstractCharacteristics::getPlungerDuration() const +{ + float result; + bool isSet = false; + process(PLUNGER_DURATION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_DURATION"); + return result; +} + +float AbstractCharacteristics::getPlungerSpeedIncrease() const +{ + float result; + bool isSet = false; + process(PLUNGER_SPEED_INCREASE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_SPEED_INCREASE"); + return result; +} + +float AbstractCharacteristics::getPlungerFadeOutTime() const +{ + float result; + bool isSet = false; + process(PLUNGER_FADE_OUT_TIME, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_FADE_OUT_TIME"); + return result; +} + +float AbstractCharacteristics::getPlungerInFaceTime() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic STARTUP_TIME"); + return std::move(result); +} + +std::vector&& AbstractCharacteristics::getStartupBoost() const +{ + std::vector result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_DURATION"); + return result; +} + +float AbstractCharacteristics::getRescueVertOffset() const +{ + float result; + bool isSet = false; + process(RESCUE_VERT_OFFSET, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_VERT_OFFSET"); + return result; +} + +float AbstractCharacteristics::getRescueHeight() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_DURATION"); + return result; +} + +float AbstractCharacteristics::getExplosionRadius() const +{ + float result; + bool isSet = false; + process(EXPLOSION_RADIUS, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_RADIUS"); + return result; +} + +float AbstractCharacteristics::getExplosionInvulnerabilityTime() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_DURATION"); + return result; +} + +float AbstractCharacteristics::getNitroEngineForce() const +{ + float result; + bool isSet = false; + process(NITRO_ENGINE_FORCE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_ENGINE_FORCE"); + return result; +} + +float AbstractCharacteristics::getNitroConsumption() const +{ + float result; + bool isSet = false; + process(NITRO_CONSUMPTION, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_CONSUMPTION"); + return result; +} + +float AbstractCharacteristics::getNitroSmallContainer() const +{ + float result; + bool isSet = false; + process(NITRO_SMALL_CONTAINER, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_SMALL_CONTAINER"); + return result; +} + +float AbstractCharacteristics::getNitroBigContainer() const +{ + float result; + bool isSet = false; + process(NITRO_BIG_CONTAINER, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_BIG_CONTAINER"); + return result; +} + +float AbstractCharacteristics::getNitroMaxSpeedIncrease() const +{ + float result; + bool isSet = false; + process(NITRO_MAX_SPEED_INCREASE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_MAX_SPEED_INCREASE"); + return result; +} + +float AbstractCharacteristics::getNitroFadeOutTime() const +{ + float result; + bool isSet = false; + process(NITRO_FADE_OUT_TIME, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_FADE_OUT_TIME"); + return result; +} + +float AbstractCharacteristics::getNitroMax() const +{ + float result; + bool isSet = false; + 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); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_DURATION"); + return result; +} + +float AbstractCharacteristics::getSlipstreamLength() const +{ + float result; + bool isSet = false; + process(SLIPSTREAM_LENGTH, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_LENGTH"); + return result; +} + +float AbstractCharacteristics::getSlipstreamWidth() const +{ + float result; + bool isSet = false; + process(SLIPSTREAM_WIDTH, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_WIDTH"); + return result; +} + +float AbstractCharacteristics::getSlipstreamCollectTime() const +{ + float result; + bool isSet = false; + process(SLIPSTREAM_COLLECT_TIME, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_COLLECT_TIME"); + return result; +} + +float AbstractCharacteristics::getSlipstreamUseTime() const +{ + float result; + bool isSet = false; + process(SLIPSTREAM_USE_TIME, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_USE_TIME"); + return result; +} + +float AbstractCharacteristics::getSlipstreamAddPower() const +{ + float result; + bool isSet = false; + process(SLIPSTREAM_ADD_POWER, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_ADD_POWER"); + return result; +} + +float AbstractCharacteristics::getSlipstreamMinSpeed() const +{ + float result; + bool isSet = false; + process(SLIPSTREAM_MIN_SPEED, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_MIN_SPEED"); + return result; +} + +float AbstractCharacteristics::getSlipstreamMaxSpeedIncrease() const +{ + float result; + bool isSet = false; + process(SLIPSTREAM_MAX_SPEED_INCREASE, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_MAX_SPEED_INCREASE"); + return result; +} + +float AbstractCharacteristics::getSlipstreamFadeOutTime() const +{ + float result; + bool isSet = false; + 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 c19146c1d..755c1878f 100755 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -19,12 +19,10 @@ #ifndef HEADER_ABSTRACT_CHARACTERISTICS_HPP #define HEADER_ABSTRACT_CHARACTERISTICS_HPP -#include "utils/interpolation_array.hpp" -#include "utils/vec3.hpp" - #include class SkiddingProperties; +class InterpolationArray; /** * Characteristics are the properties of a kart that influence @@ -40,36 +38,156 @@ class SkiddingProperties; */ class AbstractCharacteristics { - //FIXME is wheelPosition needed?? - /* The following lines are the input for a script that generates code for this class - Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce - Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse - Turn: radius(InterpolationArray), timeFullSteer, timeResetSteer, timeFullSteer(InterpolationArray) - Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio - Gear: switchRatio(std::vector/floatVector), powerIncrease(std::vector/floatVector) - Mass - Wheels: dampingRelaxation, dampingCompression, radius, position(std::vector/floatVector) - Skidding - Camera: distance, forwardUpAngle, backwardUpAngle - Jump: animationTime - Lean: max, speed - Anvil: duration, weight, speedFactor - Parachute: friction, duration, durationOther, lboundFranction, uboundFranction, maxSpeed - Bubblegum: duration, speedFraction, torque, fadeInTime, shieldDuration - Zipper: duration, force, speedGain, speedIncrease, fadeOutTime - Swatter: duration, distance, squashDuration, squashSlowdown - Plunger: maxLength, force, duration, speedIncrease, fadeOutTime, inFaceTime - Startup: time(std::vector/floatVector), boost(std::vector/floatVector) - Rescue: duration, vertOffset, height - Explosion: duration, radius, invulnerabilityTime - Nitro: duration, engineForce, consumption, smallContainer, bigContainer, maxSpeedIncrease, fadeOutTime, max - Slipstream: duration, length, width, collectTime, useTime, addPower, minSpeed, maxSpeedIncrease, fadeOutTime - */ - public: + union Value + { + float *f; + std::vector *fv; + InterpolationArray *ia; + + Value(float *f) : f(f) {} + Value(std::vector *fv) : fv(fv) {} + Value(InterpolationArray *ia) : ia(ia) {} + }; + + enum ValueType + { + TYPE_FLOAT, + TYPE_FLOAT_VECTOR, + TYPE_INTERPOLATION_ARRAY + }; + enum CharacteristicType { // Script-generated content + // Suspension + SUSPENSION_STIFFNESS, + SUSPENSION_REST, + SUSPENSION_TRAVEL_CM, + SUSPENSION_EXP_SPRING_RESPONSE, + SUSPENSION_MAX_FORCE, + + // Stability + STABILITY_ROLL_INFLUENCE, + STABILITY_CHASSIS_LINEAR_DAMPING, + STABILITY_CHASSIS_ANGULAR_DAMPING, + STABILITY_DOWNWARD_IMPULSE_FACTOR, + STABILITY_TRACK_CONNECTION_ACCEL, + STABILITY_SMOOTH_FLYING_IMPULSE, + + // Turn + TURN_RADIUS, + TURN_TIME_FULL_STEER, + TURN_TIME_RESET_STEER, + + // Engine + ENGINE_POWER, + ENGINE_MAX_SPEED, + ENGINE_BRAKE_FACTOR, + ENGINE_BRAKE_TIME_INCREASE, + ENGINE_MAX_SPEED_REVERSE_RATIO, + + // Gear + GEAR_SWITCH_RATIO, + GEAR_POWER_INCREASE, + + // Mass + MASS, + + // Wheels + WHEELS_DAMPING_RELAXATION, + WHEELS_DAMPING_COMPRESSION, + WHEELS_RADIUS, + WHEELS_POSITION, + + // Camera + CAMERA_DISTANCE, + CAMERA_FORWARD_UP_ANGLE, + CAMERA_BACKWARD_UP_ANGLE, + + // Jump + JUMP_ANIMATION_TIME, + + // Lean + LEAN_MAX, + LEAN_SPEED, + + // Anvil + ANVIL_DURATION, + ANVIL_WEIGHT, + ANVIL_SPEED_FACTOR, + + // Parachute + PARACHUTE_FRICTION, + PARACHUTE_DURATION, + PARACHUTE_DURATION_OTHER, + PARACHUTE_LBOUND_FRANCTION, + PARACHUTE_UBOUND_FRANCTION, + PARACHUTE_MAX_SPEED, + + // Bubblegum + BUBBLEGUM_DURATION, + BUBBLEGUM_SPEED_FRACTION, + BUBBLEGUM_TORQUE, + BUBBLEGUM_FADE_IN_TIME, + BUBBLEGUM_SHIELD_DURATION, + + // Zipper + ZIPPER_DURATION, + ZIPPER_FORCE, + ZIPPER_SPEED_GAIN, + ZIPPER_SPEED_INCREASE, + ZIPPER_FADE_OUT_TIME, + + // Swatter + SWATTER_DURATION, + SWATTER_DISTANCE, + SWATTER_SQUASH_DURATION, + SWATTER_SQUASH_SLOWDOWN, + + // Plunger + PLUNGER_MAX_LENGTH, + PLUNGER_FORCE, + PLUNGER_DURATION, + PLUNGER_SPEED_INCREASE, + PLUNGER_FADE_OUT_TIME, + PLUNGER_IN_FACE_TIME, + + // Startup + STARTUP_TIME, + STARTUP_BOOST, + + // Rescue + RESCUE_DURATION, + RESCUE_VERT_OFFSET, + RESCUE_HEIGHT, + + // Explosion + EXPLOSION_DURATION, + EXPLOSION_RADIUS, + EXPLOSION_INVULNERABILITY_TIME, + + // Nitro + NITRO_DURATION, + NITRO_ENGINE_FORCE, + NITRO_CONSUMPTION, + NITRO_SMALL_CONTAINER, + NITRO_BIG_CONTAINER, + NITRO_MAX_SPEED_INCREASE, + NITRO_FADE_OUT_TIME, + NITRO_MAX, + + // Slipstream + SLIPSTREAM_DURATION, + SLIPSTREAM_LENGTH, + SLIPSTREAM_WIDTH, + SLIPSTREAM_COLLECT_TIME, + SLIPSTREAM_USE_TIME, + SLIPSTREAM_ADD_POWER, + SLIPSTREAM_MIN_SPEED, + SLIPSTREAM_MAX_SPEED_INCREASE, + SLIPSTREAM_FADE_OUT_TIME, + // Count CHARACTERISTIC_COUNT @@ -85,15 +203,126 @@ public: virtual const SkiddingProperties* getSkiddingProperties() const; - virtual float processFloat(CharacteristicType type, float value) const; - virtual std::vector processFloatVector(CharacteristicType type, - const std::vector &value) const; - virtual InterpolationArray processInterpolationArray(CharacteristicType type, - const InterpolationArray &value) const; + /** + * TODO + * + * \param type The characteristic that should be modified. + * \param value The current value and result at the same time. + * \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 float getFloat(CharacteristicType type) const; - virtual std::vector getFloatVector(CharacteristicType type) const; - virtual InterpolationArray getInterpolationArray(CharacteristicType type) const; + static ValueType getType(CharacteristicType type); + + // Script-generated content + float getSuspensionStiffness() const; + float getSuspensionRest() const; + float getSuspensionTravelCm() const; + float getSuspensionExpSpringResponse() const; + float getSuspensionMaxForce() const; + + float getStabilityRollInfluence() const; + float getStabilityChassisLinearDamping() const; + float getStabilityChassisAngularDamping() const; + float getStabilityDownwardImpulseFactor() const; + float getStabilityTrackConnectionAccel() const; + float getStabilitySmoothFlyingImpulse() const; + + InterpolationArray&& getTurnRadius() const; + float getTurnTimeResetSteer() const; + InterpolationArray&& getTurnTimeFullSteer() const; + + float getEnginePower() const; + float getEngineMaxSpeed() const; + float getEngineBrakeFactor() const; + float getEngineBrakeTimeIncrease() const; + float getEngineMaxSpeedReverseRatio() 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; + + float getCameraDistance() const; + float getCameraForwardUpAngle() const; + float getCameraBackwardUpAngle() const; + + float getJumpAnimationTime() const; + + float getLeanMax() const; + float getLeanSpeed() const; + + float getAnvilDuration() const; + float getAnvilWeight() const; + float getAnvilSpeedFactor() const; + + float getParachuteFriction() const; + float getParachuteDuration() const; + float getParachuteDurationOther() const; + float getParachuteLboundFranction() const; + float getParachuteUboundFranction() const; + float getParachuteMaxSpeed() const; + + float getBubblegumDuration() const; + float getBubblegumSpeedFraction() const; + float getBubblegumTorque() const; + float getBubblegumFadeInTime() const; + float getBubblegumShieldDuration() const; + + float getZipperDuration() const; + float getZipperForce() const; + float getZipperSpeedGain() const; + float getZipperSpeedIncrease() const; + float getZipperFadeOutTime() const; + + float getSwatterDuration() const; + float getSwatterDistance() const; + float getSwatterSquashDuration() const; + float getSwatterSquashSlowdown() const; + + float getPlungerMaxLength() const; + float getPlungerForce() const; + float getPlungerDuration() const; + float getPlungerSpeedIncrease() const; + float getPlungerFadeOutTime() const; + float getPlungerInFaceTime() const; + + std::vector&& getStartupTime() const; + std::vector&& getStartupBoost() const; + + float getRescueDuration() const; + float getRescueVertOffset() const; + float getRescueHeight() const; + + float getExplosionDuration() const; + float getExplosionRadius() const; + float getExplosionInvulnerabilityTime() const; + + float getNitroDuration() const; + float getNitroEngineForce() const; + float getNitroConsumption() const; + float getNitroSmallContainer() const; + float getNitroBigContainer() const; + float getNitroMaxSpeedIncrease() const; + float getNitroFadeOutTime() const; + float getNitroMax() const; + + float getSlipstreamDuration() const; + float getSlipstreamLength() const; + float getSlipstreamWidth() const; + float getSlipstreamCollectTime() const; + float getSlipstreamUseTime() const; + float getSlipstreamAddPower() const; + float getSlipstreamMinSpeed() const; + float getSlipstreamMaxSpeedIncrease() const; + float getSlipstreamFadeOutTime() const; }; #endif + diff --git a/src/karts/cached_characteristics.cpp b/src/karts/cached_characteristics.cpp new file mode 100644 index 000000000..1a3dd4d1f --- /dev/null +++ b/src/karts/cached_characteristics.cpp @@ -0,0 +1,170 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "karts/cached_characteristics.hpp" + +#include "utils/interpolation_array.hpp" + +CachedCharacteristics::CachedCharacteristics(const AbstractCharacteristics *origin) : + m_values(CHARACTERISTIC_COUNT), + m_origin(origin) +{ + updateSource(); +} + +CachedCharacteristics::~CachedCharacteristics() +{ + // Delete all not-null values + for (int i = 0; i < CHARACTERISTIC_COUNT; i++) + { + SaveValue &v = m_values[i]; + if (v.content) + { + switch (getType(static_cast(i))) + { + case TYPE_FLOAT: + delete static_cast(v.content); + break; + case TYPE_FLOAT_VECTOR: + delete static_cast*>(v.content); + break; + case TYPE_INTERPOLATION_ARRAY: + delete static_cast(v.content); + break; + } + v.content = nullptr; + } + } +} + +void CachedCharacteristics::updateSource() +{ + for (int i = 0; i < CHARACTERISTIC_COUNT; i++) + { + SaveValue &v = m_values[i]; + + bool isSet = false; + switch (getType(static_cast(i))) + { + case TYPE_FLOAT: + { + float value; + float *ptr = static_cast(v.content); + m_origin->process(static_cast(i), &value, isSet); + if (isSet) + { + if (!ptr) + { + float *newPtr = new float(); + v.content = newPtr; + ptr = newPtr; + } + *ptr = value; + } + else + { + if (ptr) + { + delete ptr; + v.content = nullptr; + } + } + break; + } + case TYPE_FLOAT_VECTOR: + { + std::vector value; + std::vector *ptr = static_cast*>(v.content); + m_origin->process(static_cast(i), &value, isSet); + if (isSet) + { + if (!ptr) + { + std::vector *newPtr = new std::vector(); + v.content = newPtr; + ptr = newPtr; + } + *ptr = value; + } + else + { + if (ptr) + { + delete ptr; + v.content = nullptr; + } + } + break; + } + break; + case TYPE_INTERPOLATION_ARRAY: + { + InterpolationArray value; + InterpolationArray *ptr = static_cast(v.content); + m_origin->process(static_cast(i), &value, isSet); + if (isSet) + { + if (!ptr) + { + InterpolationArray *newPtr = new InterpolationArray(); + v.content = newPtr; + ptr = newPtr; + } + *ptr = value; + } + else + { + if (ptr) + { + delete ptr; + v.content = nullptr; + } + } + break; + } + break; + } + } +} + +const SkiddingProperties* CachedCharacteristics::getSkiddingProperties() const +{ + return m_origin->getSkiddingProperties(); +} + +void CachedCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const +{ + void *v = m_values[type].content; + if (v) + { + switch (getType(type)) + { + case TYPE_FLOAT: + *value.f = *static_cast(v); + break; + case TYPE_FLOAT_VECTOR: + *value.fv = *static_cast*>(v); + break; + case TYPE_INTERPOLATION_ARRAY: + *value.ia = *static_cast(v); + break; + } + isSet = true; + } +} + diff --git a/src/karts/cached_characteristics.hpp b/src/karts/cached_characteristics.hpp new file mode 100644 index 000000000..dafcb5fce --- /dev/null +++ b/src/karts/cached_characteristics.hpp @@ -0,0 +1,55 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_CACHED_CHARACTERISTICS_HPP +#define HEADER_CACHED_CHARACTERISTICS_HPP + +#include "karts/abstract_characteristics.hpp" + +class CachedCharacteristics : public AbstractCharacteristics +{ +private: + /** Used to store a value. */ + struct SaveValue + { + void *content; + + SaveValue() : content(nullptr) {} + SaveValue(void *content) : content(content) {} + }; + + /** All values for a characteristic. A nullptr means it is not set. */ + std::vector m_values; + + /** The characteristics that hold the original values. */ + const AbstractCharacteristics *m_origin; + +public: + CachedCharacteristics(const AbstractCharacteristics *origin); + CachedCharacteristics(const CachedCharacteristics &characteristics) = delete; + virtual ~CachedCharacteristics(); + + /** Fetches all cached values from the original source. */ + void updateSource(); + + virtual const SkiddingProperties* getSkiddingProperties() 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 new file mode 100644 index 000000000..adbe0db11 --- /dev/null +++ b/src/karts/combined_characteristics.cpp @@ -0,0 +1,42 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "karts/combined_characteristics.hpp" + +void CombinedCharacteristics::addCharacteristic(const AbstractCharacteristics *characteristic) +{ + m_childs.push_back(characteristic); +} + +const SkiddingProperties* CombinedCharacteristics::getSkiddingProperties() const +{ + for (const AbstractCharacteristics *characteristic : m_childs) + { + const SkiddingProperties *skid = characteristic->getSkiddingProperties(); + if (skid) + return skid; + } + return nullptr; +} + +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 new file mode 100644 index 000000000..35d0455a1 --- /dev/null +++ b/src/karts/combined_characteristics.hpp @@ -0,0 +1,37 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_COMBINDED_CHARACTERISTICS_HPP +#define HEADER_COMBINDED_CHARACTERISTICS_HPP + +#include "karts/abstract_characteristics.hpp" + +class CombinedCharacteristics : public AbstractCharacteristics +{ +private: + std::vector m_childs; + +public: + void addCharacteristic(const AbstractCharacteristics *characteristic); + + virtual const SkiddingProperties* getSkiddingProperties() 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 new file mode 100644 index 000000000..9648467dd --- /dev/null +++ b/src/karts/xml_characteristics.cpp @@ -0,0 +1,45 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "karts/xml_characteristics.hpp" + +#include "io/xml_node.hpp" + +XmlCharacteristics::XmlCharacteristics(const std::string &filename) : + m_values(CHARACTERISTIC_COUNT), + m_skidding(nullptr) +{ + if (!filename.empty()) + load(filename); +} + +const SkiddingProperties* XmlCharacteristics::getSkiddingProperties() const +{ + return m_skidding; +} + +void XmlCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const +{ + //TODO +} + +void XmlCharacteristics::load(const std::string &filename) +{ + const XMLNode* root = new XMLNode(filename); +} + diff --git a/src/karts/xml_characteristics.hpp b/src/karts/xml_characteristics.hpp new file mode 100644 index 000000000..c13da504b --- /dev/null +++ b/src/karts/xml_characteristics.hpp @@ -0,0 +1,43 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006-2015 SuperTuxKart-Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_XML_CHARACTERISTICS_HPP +#define HEADER_XML_CHARACTERISTICS_HPP + +#include "karts/abstract_characteristics.hpp" + +#include + +class XmlCharacteristics : public AbstractCharacteristics +{ +private: + /** The computation that was read from an xml file */ + std::vector m_values; + SkiddingProperties *m_skidding; + +public: + XmlCharacteristics(const std::string &filename = ""); + + virtual const SkiddingProperties* getSkiddingProperties() const; + virtual void process(CharacteristicType type, Value value, bool &isSet) const; + + void load(const std::string &filename); +}; + +#endif + diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 0006eac0a..327d7dc64 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -17,8 +17,36 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# This script takes the list from abstract_characteristics.hpp and creates the code -# An empty line is expected to end the input +# This script creates the output for the AbstractCharacteristics +# It takes an argument that specifies what the output of the script should be. +# Possibilities are enum, defs, getter and getType + +import sys + +# Input data +#FIXME is wheelPosition needed?? +characteristics = """Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce +Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse +Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray) +Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio +Gear: switchRatio(std::vector/floatVector), powerIncrease(std::vector/floatVector) +Mass +Wheels: dampingRelaxation, dampingCompression, radius, position(std::vector/floatVector) +Camera: distance, forwardUpAngle, backwardUpAngle +Jump: animationTime +Lean: max, speed +Anvil: duration, weight, speedFactor +Parachute: friction, duration, durationOther, lboundFranction, uboundFranction, maxSpeed +Bubblegum: duration, speedFraction, torque, fadeInTime, shieldDuration +Zipper: duration, force, speedGain, speedIncrease, fadeOutTime +Swatter: duration, distance, squashDuration, squashSlowdown +Plunger: maxLength, force, duration, speedIncrease, fadeOutTime, inFaceTime +Startup: time(std::vector/floatVector), boost(std::vector/floatVector) +Rescue: duration, vertOffset, height +Explosion: duration, radius, invulnerabilityTime +Nitro: duration, engineForce, consumption, smallContainer, bigContainer, maxSpeedIncrease, fadeOutTime, max +Slipstream: duration, length, width, collectTime, useTime, addPower, minSpeed, maxSpeedIncrease, fadeOutTime""" + class GroupMember: def __init__(self, name, typeC, typeStr): @@ -26,6 +54,9 @@ 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""" @@ -55,6 +86,11 @@ class Group: def addMember(self, content): self.members.append(GroupMember.parse(content)) + def getBaseName(self): + if len(self.baseName) == 0 and len(self.members) > 0: + return self.members[0].name + return self.baseName + """E.g. engine: power, gears(std::vector/Gears) or mass(float) or only mass""" def parse(content): @@ -88,52 +124,83 @@ def joinSubName(group, member, titleCase): words = toList(group.baseName) + toList(member.name) first = True if titleCase: - words = map(lambda w: w.title(), words) + words = [w.title() for w in words] return "".join(words) else: return "_".join(words) def main(): - # All variables are saved here in titlecase - groups = [] - # Read in lines - while True: - line = input() - if len(line) == 0: - break - groups.append(Group.parse(line)) + # Find out what to do + if len(sys.argv) == 1: + print("Please specify what you want to know [enum/defs/getter/getType]") + return + task = sys.argv[1] + + groups = [Group.parse(line) for line in characteristics.split("\n")] # Find longest name to align the function bodies - nameLengthTitle = 0 - nameLengthUnderscore = 0 - for g in groups: - for m in g.members: - l = len(joinSubName(g, m, True)) - if l > nameLengthTitle: - nameLengthTitle = l - l = len(joinSubName(g, m, False)) - if l > nameLengthUnderscore: - nameLengthUnderscore = l + #nameLengthTitle = 0 + #nameLengthUnderscore = 0 + #for g in groups: + # for m in g.members: + # l = len(joinSubName(g, m, True)) + # if l > nameLengthTitle: + # nameLengthTitle = l + # l = len(joinSubName(g, m, False)) + # if l > nameLengthUnderscore: + # nameLengthUnderscore = l # Print the results - print("Enum ****************************************") - for g in groups: - print() - print(" // {0}".format(g.baseName.title())) - for m in g.members: - print(" {0},".format(joinSubName(g, m, False).upper())) + if task == "enum": + for g in groups: + print() + print(" // {0}".format(g.getBaseName().title())) + for m in g.members: + print(" {0},".format(joinSubName(g, m, False).upper())) + elif task == "defs": + for g in groups: + print() + 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 - print() - print() - print("Getters ****************************************") + print(" {0} get{1}() const;". + format(typeC, nameTitle, nameUnderscore)) + elif task == "getter": + for g in groups: + 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" - for g in groups: - print() - for m in g.members: - nameTitle = joinSubName(g, m, True) - nameUnderscore = joinSubName(g, m, False) - print(" {0} get{1}() const {{ return m_{2}; }}". - format(m.typeC, nameTitle, nameUnderscore)) + print("""{3} AbstractCharacteristics::get{1}() const +{{ + {0} result; + bool isSet = false; + process({2}, &result, isSet); + if (!isSet) + Log::fatal("AbstractCharacteristics", "Can't get characteristic {2}"); + return {4}; +}} +""".format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result)) + elif task == "getType": + for g in groups: + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False) + print(""" case {0}:\n return TYPE_{1};""". + format(nameUnderscore.upper(), "_".join(toList(m.typeStr)).upper())) + else: + print("Unknown task") # Commented out code """print("Variables ****************************************") @@ -177,3 +244,4 @@ def main(): if __name__ == '__main__': main() + From c1ed8790ef33536769f9e0cec4681d2c38836c7c Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 19 Apr 2015 00:11:39 +0200 Subject: [PATCH 09/55] Add xml reading --- src/karts/xml_characteristics.cpp | 194 +++++++++++++++++++++++++++++- src/karts/xml_characteristics.hpp | 9 +- tools/create_kart_properties.py | 34 ++++-- 3 files changed, 217 insertions(+), 20 deletions(-) diff --git a/src/karts/xml_characteristics.cpp b/src/karts/xml_characteristics.cpp index 9648467dd..afa4ee31a 100644 --- a/src/karts/xml_characteristics.cpp +++ b/src/karts/xml_characteristics.cpp @@ -20,12 +20,12 @@ #include "io/xml_node.hpp" -XmlCharacteristics::XmlCharacteristics(const std::string &filename) : +XmlCharacteristics::XmlCharacteristics(const XMLNode *node) : m_values(CHARACTERISTIC_COUNT), m_skidding(nullptr) { - if (!filename.empty()) - load(filename); + if (node) + load(node); } const SkiddingProperties* XmlCharacteristics::getSkiddingProperties() const @@ -35,11 +35,193 @@ const SkiddingProperties* XmlCharacteristics::getSkiddingProperties() const void XmlCharacteristics::process(CharacteristicType type, Value value, bool &isSet) const { - //TODO + switch (getType(type)) + { + case TYPE_FLOAT: + break; + case TYPE_FLOAT_VECTOR: + break; + case TYPE_INTERPOLATION_ARRAY: + break; + } } -void XmlCharacteristics::load(const std::string &filename) +float XmlCharacteristics::processFloat(float value, std::string processor) { - const XMLNode* root = new XMLNode(filename); + +} + +void XmlCharacteristics::load(const XMLNode *node) +{ + // Script-generated content + if (const XMLNode *sub_node = node->getNode("Suspension")) + { + sub_node->get("stiffness", &m_values[SUSPENSION_STIFFNESS]); + sub_node->get("rest", &m_values[SUSPENSION_REST]); + sub_node->get("travel-cm", &m_values[SUSPENSION_TRAVEL_CM]); + sub_node->get("exp-spring-response", &m_values[SUSPENSION_EXP_SPRING_RESPONSE]); + sub_node->get("max-force", &m_values[SUSPENSION_MAX_FORCE]); + } + + if (const XMLNode *sub_node = node->getNode("Stability")) + { + sub_node->get("roll-influence", &m_values[STABILITY_ROLL_INFLUENCE]); + sub_node->get("chassis-linear-damping", &m_values[STABILITY_CHASSIS_LINEAR_DAMPING]); + sub_node->get("chassis-angular-damping", &m_values[STABILITY_CHASSIS_ANGULAR_DAMPING]); + sub_node->get("downward-impulse-factor", &m_values[STABILITY_DOWNWARD_IMPULSE_FACTOR]); + sub_node->get("track-connection-accel", &m_values[STABILITY_TRACK_CONNECTION_ACCEL]); + sub_node->get("smooth-flying-impulse", &m_values[STABILITY_SMOOTH_FLYING_IMPULSE]); + } + + if (const XMLNode *sub_node = node->getNode("Turn")) + { + sub_node->get("radius", &m_values[TURN_RADIUS]); + sub_node->get("time-reset-steer", &m_values[TURN_TIME_RESET_STEER]); + sub_node->get("time-full-steer", &m_values[TURN_TIME_FULL_STEER]); + } + + if (const XMLNode *sub_node = node->getNode("Engine")) + { + sub_node->get("power", &m_values[ENGINE_POWER]); + sub_node->get("max-speed", &m_values[ENGINE_MAX_SPEED]); + sub_node->get("brake-factor", &m_values[ENGINE_BRAKE_FACTOR]); + sub_node->get("brake-time-increase", &m_values[ENGINE_BRAKE_TIME_INCREASE]); + sub_node->get("max-speed-reverse-ratio", &m_values[ENGINE_MAX_SPEED_REVERSE_RATIO]); + } + + if (const XMLNode *sub_node = node->getNode("Gear")) + { + sub_node->get("switch-ratio", &m_values[GEAR_SWITCH_RATIO]); + sub_node->get("power-increase", &m_values[GEAR_POWER_INCREASE]); + } + + if (const XMLNode *sub_node = node->getNode("")) + { + sub_node->get("mass", &m_values[MASS]); + } + + if (const XMLNode *sub_node = node->getNode("Wheels")) + { + sub_node->get("damping-relaxation", &m_values[WHEELS_DAMPING_RELAXATION]); + sub_node->get("damping-compression", &m_values[WHEELS_DAMPING_COMPRESSION]); + sub_node->get("radius", &m_values[WHEELS_RADIUS]); + sub_node->get("position", &m_values[WHEELS_POSITION]); + } + + if (const XMLNode *sub_node = node->getNode("Camera")) + { + sub_node->get("distance", &m_values[CAMERA_DISTANCE]); + sub_node->get("forward-up-angle", &m_values[CAMERA_FORWARD_UP_ANGLE]); + sub_node->get("backward-up-angle", &m_values[CAMERA_BACKWARD_UP_ANGLE]); + } + + if (const XMLNode *sub_node = node->getNode("Jump")) + { + sub_node->get("animation-time", &m_values[JUMP_ANIMATION_TIME]); + } + + if (const XMLNode *sub_node = node->getNode("Lean")) + { + sub_node->get("max", &m_values[LEAN_MAX]); + sub_node->get("speed", &m_values[LEAN_SPEED]); + } + + if (const XMLNode *sub_node = node->getNode("Anvil")) + { + sub_node->get("duration", &m_values[ANVIL_DURATION]); + sub_node->get("weight", &m_values[ANVIL_WEIGHT]); + sub_node->get("speed-factor", &m_values[ANVIL_SPEED_FACTOR]); + } + + if (const XMLNode *sub_node = node->getNode("Parachute")) + { + sub_node->get("friction", &m_values[PARACHUTE_FRICTION]); + sub_node->get("duration", &m_values[PARACHUTE_DURATION]); + sub_node->get("duration-other", &m_values[PARACHUTE_DURATION_OTHER]); + sub_node->get("lbound-franction", &m_values[PARACHUTE_LBOUND_FRANCTION]); + sub_node->get("ubound-franction", &m_values[PARACHUTE_UBOUND_FRANCTION]); + sub_node->get("max-speed", &m_values[PARACHUTE_MAX_SPEED]); + } + + if (const XMLNode *sub_node = node->getNode("Bubblegum")) + { + sub_node->get("duration", &m_values[BUBBLEGUM_DURATION]); + sub_node->get("speed-fraction", &m_values[BUBBLEGUM_SPEED_FRACTION]); + sub_node->get("torque", &m_values[BUBBLEGUM_TORQUE]); + sub_node->get("fade-in-time", &m_values[BUBBLEGUM_FADE_IN_TIME]); + sub_node->get("shield-duration", &m_values[BUBBLEGUM_SHIELD_DURATION]); + } + + if (const XMLNode *sub_node = node->getNode("Zipper")) + { + sub_node->get("duration", &m_values[ZIPPER_DURATION]); + sub_node->get("force", &m_values[ZIPPER_FORCE]); + sub_node->get("speed-gain", &m_values[ZIPPER_SPEED_GAIN]); + sub_node->get("speed-increase", &m_values[ZIPPER_SPEED_INCREASE]); + sub_node->get("fade-out-time", &m_values[ZIPPER_FADE_OUT_TIME]); + } + + if (const XMLNode *sub_node = node->getNode("Swatter")) + { + sub_node->get("duration", &m_values[SWATTER_DURATION]); + sub_node->get("distance", &m_values[SWATTER_DISTANCE]); + sub_node->get("squash-duration", &m_values[SWATTER_SQUASH_DURATION]); + sub_node->get("squash-slowdown", &m_values[SWATTER_SQUASH_SLOWDOWN]); + } + + if (const XMLNode *sub_node = node->getNode("Plunger")) + { + sub_node->get("max-length", &m_values[PLUNGER_MAX_LENGTH]); + sub_node->get("force", &m_values[PLUNGER_FORCE]); + sub_node->get("duration", &m_values[PLUNGER_DURATION]); + sub_node->get("speed-increase", &m_values[PLUNGER_SPEED_INCREASE]); + sub_node->get("fade-out-time", &m_values[PLUNGER_FADE_OUT_TIME]); + sub_node->get("in-face-time", &m_values[PLUNGER_IN_FACE_TIME]); + } + + if (const XMLNode *sub_node = node->getNode("Startup")) + { + sub_node->get("time", &m_values[STARTUP_TIME]); + sub_node->get("boost", &m_values[STARTUP_BOOST]); + } + + if (const XMLNode *sub_node = node->getNode("Rescue")) + { + sub_node->get("duration", &m_values[RESCUE_DURATION]); + sub_node->get("vert-offset", &m_values[RESCUE_VERT_OFFSET]); + sub_node->get("height", &m_values[RESCUE_HEIGHT]); + } + + if (const XMLNode *sub_node = node->getNode("Explosion")) + { + sub_node->get("duration", &m_values[EXPLOSION_DURATION]); + sub_node->get("radius", &m_values[EXPLOSION_RADIUS]); + sub_node->get("invulnerability-time", &m_values[EXPLOSION_INVULNERABILITY_TIME]); + } + + if (const XMLNode *sub_node = node->getNode("Nitro")) + { + sub_node->get("duration", &m_values[NITRO_DURATION]); + sub_node->get("engine-force", &m_values[NITRO_ENGINE_FORCE]); + sub_node->get("consumption", &m_values[NITRO_CONSUMPTION]); + sub_node->get("small-container", &m_values[NITRO_SMALL_CONTAINER]); + sub_node->get("big-container", &m_values[NITRO_BIG_CONTAINER]); + sub_node->get("max-speed-increase", &m_values[NITRO_MAX_SPEED_INCREASE]); + sub_node->get("fade-out-time", &m_values[NITRO_FADE_OUT_TIME]); + sub_node->get("max", &m_values[NITRO_MAX]); + } + + if (const XMLNode *sub_node = node->getNode("Slipstream")) + { + sub_node->get("duration", &m_values[SLIPSTREAM_DURATION]); + sub_node->get("length", &m_values[SLIPSTREAM_LENGTH]); + sub_node->get("width", &m_values[SLIPSTREAM_WIDTH]); + sub_node->get("collect-time", &m_values[SLIPSTREAM_COLLECT_TIME]); + sub_node->get("use-time", &m_values[SLIPSTREAM_USE_TIME]); + sub_node->get("add-power", &m_values[SLIPSTREAM_ADD_POWER]); + sub_node->get("min-speed", &m_values[SLIPSTREAM_MIN_SPEED]); + sub_node->get("max-speed-increase", &m_values[SLIPSTREAM_MAX_SPEED_INCREASE]); + sub_node->get("fade-out-time", &m_values[SLIPSTREAM_FADE_OUT_TIME]); + } } diff --git a/src/karts/xml_characteristics.hpp b/src/karts/xml_characteristics.hpp index c13da504b..49721951c 100644 --- a/src/karts/xml_characteristics.hpp +++ b/src/karts/xml_characteristics.hpp @@ -23,6 +23,8 @@ #include +class XMLNode; + class XmlCharacteristics : public AbstractCharacteristics { private: @@ -31,12 +33,15 @@ private: SkiddingProperties *m_skidding; public: - XmlCharacteristics(const std::string &filename = ""); + XmlCharacteristics(const XMLNode *node = nullptr); virtual const SkiddingProperties* getSkiddingProperties() const; virtual void process(CharacteristicType type, Value value, bool &isSet) const; - void load(const std::string &filename); + void load(const XMLNode *node); + +private: + static float processFloat(float value, std::string processor); }; #endif diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 327d7dc64..59f3aa827 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -19,7 +19,7 @@ # This script creates the output for the AbstractCharacteristics # It takes an argument that specifies what the output of the script should be. -# Possibilities are enum, defs, getter and getType +# The output options can be seen by running this script without arguments. import sys @@ -132,23 +132,23 @@ def joinSubName(group, member, titleCase): def main(): # Find out what to do if len(sys.argv) == 1: - print("Please specify what you want to know [enum/defs/getter/getType]") + print("Please specify what you want to know [enum/defs/getter/getType/getXml]") return task = sys.argv[1] groups = [Group.parse(line) for line in characteristics.split("\n")] # Find longest name to align the function bodies - #nameLengthTitle = 0 - #nameLengthUnderscore = 0 - #for g in groups: - # for m in g.members: - # l = len(joinSubName(g, m, True)) - # if l > nameLengthTitle: - # nameLengthTitle = l - # l = len(joinSubName(g, m, False)) - # if l > nameLengthUnderscore: - # nameLengthUnderscore = l + nameLengthTitle = 0 + nameLengthUnderscore = 0 + for g in groups: + for m in g.members: + l = len(joinSubName(g, m, True)) + if l > nameLengthTitle: + nameLengthTitle = l + l = len(joinSubName(g, m, False)) + if l > nameLengthUnderscore: + nameLengthUnderscore = l # Print the results if task == "enum": @@ -199,6 +199,16 @@ def main(): nameUnderscore = joinSubName(g, m, False) print(""" case {0}:\n return TYPE_{1};""". format(nameUnderscore.upper(), "_".join(toList(m.typeStr)).upper())) + elif task == "getXml": + for g in groups: + print(" if (const XMLNode *sub_node = node->getNode(\"{0}\"))\n {{". + format(g.baseName)) + for m in g.members: + nameUnderscore = joinSubName(g, m, False) + nameMinus = "-".join(toList(m.name)) + print(" sub_node->get(\"{0}\", &m_values[{1}]);". + format(nameMinus, nameUnderscore.upper())) + print(" }\n") else: print("Unknown task") From 17b775959ce577ddab79f256325d70f4d95ac3c0 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 19 Apr 2015 00:57:55 +0200 Subject: [PATCH 10/55] 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() From 35aeeea6c68beff2ab471b0ac6d82bf7df0f9bb6 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 19 Apr 2015 01:44:54 +0200 Subject: [PATCH 11/55] Add getName for enum --- src/karts/abstract_characteristics.cpp | 356 +++++++++++++++++++------ src/karts/abstract_characteristics.hpp | 2 + tools/create_kart_properties.py | 15 +- 3 files changed, 283 insertions(+), 90 deletions(-) diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp index 8dd0cde7f..0026355d7 100755 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristics.cpp @@ -223,6 +223,190 @@ AbstractCharacteristics::ValueType AbstractCharacteristics::getType(Characterist return TYPE_FLOAT; } +std::string AbstractCharacteristics::getName(CharacteristicType type) +{ + switch (type) + { + case CHARACTERISTIC_COUNT: + return "CHARACTERISTIC_COUNT"; + // Script-generated content + case SUSPENSION_STIFFNESS: + return "SUSPENSION_STIFFNESS"; + case SUSPENSION_REST: + return "SUSPENSION_REST"; + case SUSPENSION_TRAVEL_CM: + return "SUSPENSION_TRAVEL_CM"; + case SUSPENSION_EXP_SPRING_RESPONSE: + return "SUSPENSION_EXP_SPRING_RESPONSE"; + case SUSPENSION_MAX_FORCE: + return "SUSPENSION_MAX_FORCE"; + case STABILITY_ROLL_INFLUENCE: + return "STABILITY_ROLL_INFLUENCE"; + case STABILITY_CHASSIS_LINEAR_DAMPING: + return "STABILITY_CHASSIS_LINEAR_DAMPING"; + case STABILITY_CHASSIS_ANGULAR_DAMPING: + return "STABILITY_CHASSIS_ANGULAR_DAMPING"; + case STABILITY_DOWNWARD_IMPULSE_FACTOR: + return "STABILITY_DOWNWARD_IMPULSE_FACTOR"; + case STABILITY_TRACK_CONNECTION_ACCEL: + return "STABILITY_TRACK_CONNECTION_ACCEL"; + case STABILITY_SMOOTH_FLYING_IMPULSE: + return "STABILITY_SMOOTH_FLYING_IMPULSE"; + case TURN_RADIUS: + return "TURN_RADIUS"; + case TURN_TIME_RESET_STEER: + return "TURN_TIME_RESET_STEER"; + case TURN_TIME_FULL_STEER: + return "TURN_TIME_FULL_STEER"; + case ENGINE_POWER: + return "ENGINE_POWER"; + case ENGINE_MAX_SPEED: + return "ENGINE_MAX_SPEED"; + case ENGINE_BRAKE_FACTOR: + return "ENGINE_BRAKE_FACTOR"; + case ENGINE_BRAKE_TIME_INCREASE: + return "ENGINE_BRAKE_TIME_INCREASE"; + case ENGINE_MAX_SPEED_REVERSE_RATIO: + return "ENGINE_MAX_SPEED_REVERSE_RATIO"; + case GEAR_SWITCH_RATIO: + return "GEAR_SWITCH_RATIO"; + case GEAR_POWER_INCREASE: + return "GEAR_POWER_INCREASE"; + case MASS: + return "MASS"; + case WHEELS_DAMPING_RELAXATION: + return "WHEELS_DAMPING_RELAXATION"; + case WHEELS_DAMPING_COMPRESSION: + return "WHEELS_DAMPING_COMPRESSION"; + case WHEELS_RADIUS: + return "WHEELS_RADIUS"; + case WHEELS_POSITION: + return "WHEELS_POSITION"; + case CAMERA_DISTANCE: + return "CAMERA_DISTANCE"; + case CAMERA_FORWARD_UP_ANGLE: + return "CAMERA_FORWARD_UP_ANGLE"; + case CAMERA_BACKWARD_UP_ANGLE: + return "CAMERA_BACKWARD_UP_ANGLE"; + case JUMP_ANIMATION_TIME: + return "JUMP_ANIMATION_TIME"; + case LEAN_MAX: + return "LEAN_MAX"; + case LEAN_SPEED: + return "LEAN_SPEED"; + case ANVIL_DURATION: + return "ANVIL_DURATION"; + case ANVIL_WEIGHT: + return "ANVIL_WEIGHT"; + case ANVIL_SPEED_FACTOR: + return "ANVIL_SPEED_FACTOR"; + case PARACHUTE_FRICTION: + return "PARACHUTE_FRICTION"; + case PARACHUTE_DURATION: + return "PARACHUTE_DURATION"; + case PARACHUTE_DURATION_OTHER: + return "PARACHUTE_DURATION_OTHER"; + case PARACHUTE_LBOUND_FRANCTION: + return "PARACHUTE_LBOUND_FRANCTION"; + case PARACHUTE_UBOUND_FRANCTION: + return "PARACHUTE_UBOUND_FRANCTION"; + case PARACHUTE_MAX_SPEED: + return "PARACHUTE_MAX_SPEED"; + case BUBBLEGUM_DURATION: + return "BUBBLEGUM_DURATION"; + case BUBBLEGUM_SPEED_FRACTION: + return "BUBBLEGUM_SPEED_FRACTION"; + case BUBBLEGUM_TORQUE: + return "BUBBLEGUM_TORQUE"; + case BUBBLEGUM_FADE_IN_TIME: + return "BUBBLEGUM_FADE_IN_TIME"; + case BUBBLEGUM_SHIELD_DURATION: + return "BUBBLEGUM_SHIELD_DURATION"; + case ZIPPER_DURATION: + return "ZIPPER_DURATION"; + case ZIPPER_FORCE: + return "ZIPPER_FORCE"; + case ZIPPER_SPEED_GAIN: + return "ZIPPER_SPEED_GAIN"; + case ZIPPER_SPEED_INCREASE: + return "ZIPPER_SPEED_INCREASE"; + case ZIPPER_FADE_OUT_TIME: + return "ZIPPER_FADE_OUT_TIME"; + case SWATTER_DURATION: + return "SWATTER_DURATION"; + case SWATTER_DISTANCE: + return "SWATTER_DISTANCE"; + case SWATTER_SQUASH_DURATION: + return "SWATTER_SQUASH_DURATION"; + case SWATTER_SQUASH_SLOWDOWN: + return "SWATTER_SQUASH_SLOWDOWN"; + case PLUNGER_MAX_LENGTH: + return "PLUNGER_MAX_LENGTH"; + case PLUNGER_FORCE: + return "PLUNGER_FORCE"; + case PLUNGER_DURATION: + return "PLUNGER_DURATION"; + case PLUNGER_SPEED_INCREASE: + return "PLUNGER_SPEED_INCREASE"; + case PLUNGER_FADE_OUT_TIME: + return "PLUNGER_FADE_OUT_TIME"; + case PLUNGER_IN_FACE_TIME: + return "PLUNGER_IN_FACE_TIME"; + case STARTUP_TIME: + return "STARTUP_TIME"; + case STARTUP_BOOST: + return "STARTUP_BOOST"; + case RESCUE_DURATION: + return "RESCUE_DURATION"; + case RESCUE_VERT_OFFSET: + return "RESCUE_VERT_OFFSET"; + case RESCUE_HEIGHT: + return "RESCUE_HEIGHT"; + case EXPLOSION_DURATION: + return "EXPLOSION_DURATION"; + case EXPLOSION_RADIUS: + return "EXPLOSION_RADIUS"; + case EXPLOSION_INVULNERABILITY_TIME: + return "EXPLOSION_INVULNERABILITY_TIME"; + case NITRO_DURATION: + return "NITRO_DURATION"; + case NITRO_ENGINE_FORCE: + return "NITRO_ENGINE_FORCE"; + case NITRO_CONSUMPTION: + return "NITRO_CONSUMPTION"; + case NITRO_SMALL_CONTAINER: + return "NITRO_SMALL_CONTAINER"; + case NITRO_BIG_CONTAINER: + return "NITRO_BIG_CONTAINER"; + case NITRO_MAX_SPEED_INCREASE: + return "NITRO_MAX_SPEED_INCREASE"; + case NITRO_FADE_OUT_TIME: + return "NITRO_FADE_OUT_TIME"; + case NITRO_MAX: + return "NITRO_MAX"; + case SLIPSTREAM_DURATION: + return "SLIPSTREAM_DURATION"; + case SLIPSTREAM_LENGTH: + return "SLIPSTREAM_LENGTH"; + case SLIPSTREAM_WIDTH: + return "SLIPSTREAM_WIDTH"; + case SLIPSTREAM_COLLECT_TIME: + return "SLIPSTREAM_COLLECT_TIME"; + case SLIPSTREAM_USE_TIME: + return "SLIPSTREAM_USE_TIME"; + case SLIPSTREAM_ADD_POWER: + return "SLIPSTREAM_ADD_POWER"; + case SLIPSTREAM_MIN_SPEED: + return "SLIPSTREAM_MIN_SPEED"; + case SLIPSTREAM_MAX_SPEED_INCREASE: + return "SLIPSTREAM_MAX_SPEED_INCREASE"; + case SLIPSTREAM_FADE_OUT_TIME: + return "SLIPSTREAM_FADE_OUT_TIME"; + } + Log::error("AbstractCharacteristics::getName", "Unknown type"); + return "Unknown type"; +} + // Script-generated getter float AbstractCharacteristics::getSuspensionStiffness() const { @@ -230,7 +414,7 @@ float AbstractCharacteristics::getSuspensionStiffness() const bool isSet = false; process(SUSPENSION_STIFFNESS, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_STIFFNESS"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_STIFFNESS).c_str()); return result; } @@ -240,7 +424,7 @@ float AbstractCharacteristics::getSuspensionRest() const bool isSet = false; process(SUSPENSION_REST, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_REST"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_REST).c_str()); return result; } @@ -250,7 +434,7 @@ float AbstractCharacteristics::getSuspensionTravelCm() const bool isSet = false; process(SUSPENSION_TRAVEL_CM, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_TRAVEL_CM"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_TRAVEL_CM).c_str()); return result; } @@ -260,7 +444,7 @@ float AbstractCharacteristics::getSuspensionExpSpringResponse() const bool isSet = false; process(SUSPENSION_EXP_SPRING_RESPONSE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_EXP_SPRING_RESPONSE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_EXP_SPRING_RESPONSE).c_str()); return result; } @@ -270,7 +454,7 @@ float AbstractCharacteristics::getSuspensionMaxForce() const bool isSet = false; process(SUSPENSION_MAX_FORCE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SUSPENSION_MAX_FORCE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_MAX_FORCE).c_str()); return result; } @@ -280,7 +464,7 @@ float AbstractCharacteristics::getStabilityRollInfluence() const bool isSet = false; process(STABILITY_ROLL_INFLUENCE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_ROLL_INFLUENCE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_ROLL_INFLUENCE).c_str()); return result; } @@ -290,7 +474,7 @@ float AbstractCharacteristics::getStabilityChassisLinearDamping() const bool isSet = false; process(STABILITY_CHASSIS_LINEAR_DAMPING, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_CHASSIS_LINEAR_DAMPING"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_CHASSIS_LINEAR_DAMPING).c_str()); return result; } @@ -300,7 +484,7 @@ float AbstractCharacteristics::getStabilityChassisAngularDamping() const bool isSet = false; process(STABILITY_CHASSIS_ANGULAR_DAMPING, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_CHASSIS_ANGULAR_DAMPING"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_CHASSIS_ANGULAR_DAMPING).c_str()); return result; } @@ -310,7 +494,7 @@ float AbstractCharacteristics::getStabilityDownwardImpulseFactor() const bool isSet = false; process(STABILITY_DOWNWARD_IMPULSE_FACTOR, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_DOWNWARD_IMPULSE_FACTOR"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_DOWNWARD_IMPULSE_FACTOR).c_str()); return result; } @@ -320,7 +504,7 @@ float AbstractCharacteristics::getStabilityTrackConnectionAccel() const bool isSet = false; process(STABILITY_TRACK_CONNECTION_ACCEL, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_TRACK_CONNECTION_ACCEL"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_TRACK_CONNECTION_ACCEL).c_str()); return result; } @@ -330,7 +514,7 @@ float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const bool isSet = false; process(STABILITY_SMOOTH_FLYING_IMPULSE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STABILITY_SMOOTH_FLYING_IMPULSE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_SMOOTH_FLYING_IMPULSE).c_str()); return result; } @@ -340,7 +524,7 @@ InterpolationArray&& AbstractCharacteristics::getTurnRadius() const bool isSet = false; process(TURN_RADIUS, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_RADIUS"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_RADIUS).c_str()); return std::move(result); } @@ -350,7 +534,7 @@ float AbstractCharacteristics::getTurnTimeResetSteer() const bool isSet = false; process(TURN_TIME_RESET_STEER, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_TIME_RESET_STEER"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_TIME_RESET_STEER).c_str()); return result; } @@ -360,7 +544,7 @@ InterpolationArray&& AbstractCharacteristics::getTurnTimeFullSteer() const bool isSet = false; process(TURN_TIME_FULL_STEER, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic TURN_TIME_FULL_STEER"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_TIME_FULL_STEER).c_str()); return std::move(result); } @@ -370,7 +554,7 @@ float AbstractCharacteristics::getEnginePower() const bool isSet = false; process(ENGINE_POWER, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_POWER"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_POWER).c_str()); return result; } @@ -380,7 +564,7 @@ float AbstractCharacteristics::getEngineMaxSpeed() const bool isSet = false; process(ENGINE_MAX_SPEED, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_MAX_SPEED"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED).c_str()); return result; } @@ -390,7 +574,7 @@ float AbstractCharacteristics::getEngineBrakeFactor() const bool isSet = false; process(ENGINE_BRAKE_FACTOR, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_BRAKE_FACTOR"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_BRAKE_FACTOR).c_str()); return result; } @@ -400,7 +584,7 @@ float AbstractCharacteristics::getEngineBrakeTimeIncrease() const bool isSet = false; process(ENGINE_BRAKE_TIME_INCREASE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_BRAKE_TIME_INCREASE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_BRAKE_TIME_INCREASE).c_str()); return result; } @@ -410,7 +594,7 @@ float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const bool isSet = false; process(ENGINE_MAX_SPEED_REVERSE_RATIO, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ENGINE_MAX_SPEED_REVERSE_RATIO"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED_REVERSE_RATIO).c_str()); return result; } @@ -420,7 +604,7 @@ std::vector&& AbstractCharacteristics::getGearSwitchRatio() const bool isSet = false; process(GEAR_SWITCH_RATIO, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic GEAR_SWITCH_RATIO"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_SWITCH_RATIO).c_str()); return std::move(result); } @@ -430,7 +614,7 @@ std::vector&& AbstractCharacteristics::getGearPowerIncrease() const bool isSet = false; process(GEAR_POWER_INCREASE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic GEAR_POWER_INCREASE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_POWER_INCREASE).c_str()); return std::move(result); } @@ -440,7 +624,7 @@ float AbstractCharacteristics::getMass() const bool isSet = false; process(MASS, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic MASS"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(MASS).c_str()); return result; } @@ -450,7 +634,7 @@ float AbstractCharacteristics::getWheelsDampingRelaxation() const bool isSet = false; process(WHEELS_DAMPING_RELAXATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_DAMPING_RELAXATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_DAMPING_RELAXATION).c_str()); return result; } @@ -460,7 +644,7 @@ float AbstractCharacteristics::getWheelsDampingCompression() const bool isSet = false; process(WHEELS_DAMPING_COMPRESSION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_DAMPING_COMPRESSION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_DAMPING_COMPRESSION).c_str()); return result; } @@ -470,7 +654,7 @@ float AbstractCharacteristics::getWheelsRadius() const bool isSet = false; process(WHEELS_RADIUS, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_RADIUS"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_RADIUS).c_str()); return result; } @@ -480,7 +664,7 @@ std::vector&& AbstractCharacteristics::getWheelsPosition() const bool isSet = false; process(WHEELS_POSITION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic WHEELS_POSITION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_POSITION).c_str()); return std::move(result); } @@ -490,7 +674,7 @@ float AbstractCharacteristics::getCameraDistance() const bool isSet = false; process(CAMERA_DISTANCE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_DISTANCE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_DISTANCE).c_str()); return result; } @@ -500,7 +684,7 @@ float AbstractCharacteristics::getCameraForwardUpAngle() const bool isSet = false; process(CAMERA_FORWARD_UP_ANGLE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_FORWARD_UP_ANGLE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_FORWARD_UP_ANGLE).c_str()); return result; } @@ -510,7 +694,7 @@ float AbstractCharacteristics::getCameraBackwardUpAngle() const bool isSet = false; process(CAMERA_BACKWARD_UP_ANGLE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic CAMERA_BACKWARD_UP_ANGLE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_BACKWARD_UP_ANGLE).c_str()); return result; } @@ -520,7 +704,7 @@ float AbstractCharacteristics::getJumpAnimationTime() const bool isSet = false; process(JUMP_ANIMATION_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic JUMP_ANIMATION_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(JUMP_ANIMATION_TIME).c_str()); return result; } @@ -530,7 +714,7 @@ float AbstractCharacteristics::getLeanMax() const bool isSet = false; process(LEAN_MAX, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic LEAN_MAX"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(LEAN_MAX).c_str()); return result; } @@ -540,7 +724,7 @@ float AbstractCharacteristics::getLeanSpeed() const bool isSet = false; process(LEAN_SPEED, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic LEAN_SPEED"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(LEAN_SPEED).c_str()); return result; } @@ -550,7 +734,7 @@ float AbstractCharacteristics::getAnvilDuration() const bool isSet = false; process(ANVIL_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_DURATION).c_str()); return result; } @@ -560,7 +744,7 @@ float AbstractCharacteristics::getAnvilWeight() const bool isSet = false; process(ANVIL_WEIGHT, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_WEIGHT"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_WEIGHT).c_str()); return result; } @@ -570,7 +754,7 @@ float AbstractCharacteristics::getAnvilSpeedFactor() const bool isSet = false; process(ANVIL_SPEED_FACTOR, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ANVIL_SPEED_FACTOR"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_SPEED_FACTOR).c_str()); return result; } @@ -580,7 +764,7 @@ float AbstractCharacteristics::getParachuteFriction() const bool isSet = false; process(PARACHUTE_FRICTION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_FRICTION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_FRICTION).c_str()); return result; } @@ -590,7 +774,7 @@ float AbstractCharacteristics::getParachuteDuration() const bool isSet = false; process(PARACHUTE_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_DURATION).c_str()); return result; } @@ -600,7 +784,7 @@ float AbstractCharacteristics::getParachuteDurationOther() const bool isSet = false; process(PARACHUTE_DURATION_OTHER, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_DURATION_OTHER"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_DURATION_OTHER).c_str()); return result; } @@ -610,7 +794,7 @@ float AbstractCharacteristics::getParachuteLboundFranction() const bool isSet = false; process(PARACHUTE_LBOUND_FRANCTION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_LBOUND_FRANCTION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_LBOUND_FRANCTION).c_str()); return result; } @@ -620,7 +804,7 @@ float AbstractCharacteristics::getParachuteUboundFranction() const bool isSet = false; process(PARACHUTE_UBOUND_FRANCTION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_UBOUND_FRANCTION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_UBOUND_FRANCTION).c_str()); return result; } @@ -630,7 +814,7 @@ float AbstractCharacteristics::getParachuteMaxSpeed() const bool isSet = false; process(PARACHUTE_MAX_SPEED, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PARACHUTE_MAX_SPEED"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_MAX_SPEED).c_str()); return result; } @@ -640,7 +824,7 @@ float AbstractCharacteristics::getBubblegumDuration() const bool isSet = false; process(BUBBLEGUM_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_DURATION).c_str()); return result; } @@ -650,7 +834,7 @@ float AbstractCharacteristics::getBubblegumSpeedFraction() const bool isSet = false; process(BUBBLEGUM_SPEED_FRACTION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_SPEED_FRACTION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_SPEED_FRACTION).c_str()); return result; } @@ -660,7 +844,7 @@ float AbstractCharacteristics::getBubblegumTorque() const bool isSet = false; process(BUBBLEGUM_TORQUE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_TORQUE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_TORQUE).c_str()); return result; } @@ -670,7 +854,7 @@ float AbstractCharacteristics::getBubblegumFadeInTime() const bool isSet = false; process(BUBBLEGUM_FADE_IN_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_FADE_IN_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_FADE_IN_TIME).c_str()); return result; } @@ -680,7 +864,7 @@ float AbstractCharacteristics::getBubblegumShieldDuration() const bool isSet = false; process(BUBBLEGUM_SHIELD_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic BUBBLEGUM_SHIELD_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_SHIELD_DURATION).c_str()); return result; } @@ -690,7 +874,7 @@ float AbstractCharacteristics::getZipperDuration() const bool isSet = false; process(ZIPPER_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_DURATION).c_str()); return result; } @@ -700,7 +884,7 @@ float AbstractCharacteristics::getZipperForce() const bool isSet = false; process(ZIPPER_FORCE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_FORCE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_FORCE).c_str()); return result; } @@ -710,7 +894,7 @@ float AbstractCharacteristics::getZipperSpeedGain() const bool isSet = false; process(ZIPPER_SPEED_GAIN, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_SPEED_GAIN"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_SPEED_GAIN).c_str()); return result; } @@ -720,7 +904,7 @@ float AbstractCharacteristics::getZipperSpeedIncrease() const bool isSet = false; process(ZIPPER_SPEED_INCREASE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_SPEED_INCREASE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_SPEED_INCREASE).c_str()); return result; } @@ -730,7 +914,7 @@ float AbstractCharacteristics::getZipperFadeOutTime() const bool isSet = false; process(ZIPPER_FADE_OUT_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic ZIPPER_FADE_OUT_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_FADE_OUT_TIME).c_str()); return result; } @@ -740,7 +924,7 @@ float AbstractCharacteristics::getSwatterDuration() const bool isSet = false; process(SWATTER_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_DURATION).c_str()); return result; } @@ -750,7 +934,7 @@ float AbstractCharacteristics::getSwatterDistance() const bool isSet = false; process(SWATTER_DISTANCE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_DISTANCE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_DISTANCE).c_str()); return result; } @@ -760,7 +944,7 @@ float AbstractCharacteristics::getSwatterSquashDuration() const bool isSet = false; process(SWATTER_SQUASH_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_SQUASH_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_SQUASH_DURATION).c_str()); return result; } @@ -770,7 +954,7 @@ float AbstractCharacteristics::getSwatterSquashSlowdown() const bool isSet = false; process(SWATTER_SQUASH_SLOWDOWN, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SWATTER_SQUASH_SLOWDOWN"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_SQUASH_SLOWDOWN).c_str()); return result; } @@ -780,7 +964,7 @@ float AbstractCharacteristics::getPlungerMaxLength() const bool isSet = false; process(PLUNGER_MAX_LENGTH, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_MAX_LENGTH"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_MAX_LENGTH).c_str()); return result; } @@ -790,7 +974,7 @@ float AbstractCharacteristics::getPlungerForce() const bool isSet = false; process(PLUNGER_FORCE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_FORCE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_FORCE).c_str()); return result; } @@ -800,7 +984,7 @@ float AbstractCharacteristics::getPlungerDuration() const bool isSet = false; process(PLUNGER_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_DURATION).c_str()); return result; } @@ -810,7 +994,7 @@ float AbstractCharacteristics::getPlungerSpeedIncrease() const bool isSet = false; process(PLUNGER_SPEED_INCREASE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_SPEED_INCREASE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_SPEED_INCREASE).c_str()); return result; } @@ -820,7 +1004,7 @@ float AbstractCharacteristics::getPlungerFadeOutTime() const bool isSet = false; process(PLUNGER_FADE_OUT_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_FADE_OUT_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_FADE_OUT_TIME).c_str()); return result; } @@ -830,7 +1014,7 @@ float AbstractCharacteristics::getPlungerInFaceTime() const bool isSet = false; process(PLUNGER_IN_FACE_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic PLUNGER_IN_FACE_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_IN_FACE_TIME).c_str()); return result; } @@ -840,7 +1024,7 @@ std::vector&& AbstractCharacteristics::getStartupTime() const bool isSet = false; process(STARTUP_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STARTUP_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_TIME).c_str()); return std::move(result); } @@ -850,7 +1034,7 @@ std::vector&& AbstractCharacteristics::getStartupBoost() const bool isSet = false; process(STARTUP_BOOST, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic STARTUP_BOOST"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_BOOST).c_str()); return std::move(result); } @@ -860,7 +1044,7 @@ float AbstractCharacteristics::getRescueDuration() const bool isSet = false; process(RESCUE_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_DURATION).c_str()); return result; } @@ -870,7 +1054,7 @@ float AbstractCharacteristics::getRescueVertOffset() const bool isSet = false; process(RESCUE_VERT_OFFSET, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_VERT_OFFSET"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_VERT_OFFSET).c_str()); return result; } @@ -880,7 +1064,7 @@ float AbstractCharacteristics::getRescueHeight() const bool isSet = false; process(RESCUE_HEIGHT, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic RESCUE_HEIGHT"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_HEIGHT).c_str()); return result; } @@ -890,7 +1074,7 @@ float AbstractCharacteristics::getExplosionDuration() const bool isSet = false; process(EXPLOSION_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_DURATION).c_str()); return result; } @@ -900,7 +1084,7 @@ float AbstractCharacteristics::getExplosionRadius() const bool isSet = false; process(EXPLOSION_RADIUS, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_RADIUS"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_RADIUS).c_str()); return result; } @@ -910,7 +1094,7 @@ float AbstractCharacteristics::getExplosionInvulnerabilityTime() const bool isSet = false; process(EXPLOSION_INVULNERABILITY_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic EXPLOSION_INVULNERABILITY_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_INVULNERABILITY_TIME).c_str()); return result; } @@ -920,7 +1104,7 @@ float AbstractCharacteristics::getNitroDuration() const bool isSet = false; process(NITRO_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_DURATION).c_str()); return result; } @@ -930,7 +1114,7 @@ float AbstractCharacteristics::getNitroEngineForce() const bool isSet = false; process(NITRO_ENGINE_FORCE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_ENGINE_FORCE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_ENGINE_FORCE).c_str()); return result; } @@ -940,7 +1124,7 @@ float AbstractCharacteristics::getNitroConsumption() const bool isSet = false; process(NITRO_CONSUMPTION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_CONSUMPTION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_CONSUMPTION).c_str()); return result; } @@ -950,7 +1134,7 @@ float AbstractCharacteristics::getNitroSmallContainer() const bool isSet = false; process(NITRO_SMALL_CONTAINER, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_SMALL_CONTAINER"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_SMALL_CONTAINER).c_str()); return result; } @@ -960,7 +1144,7 @@ float AbstractCharacteristics::getNitroBigContainer() const bool isSet = false; process(NITRO_BIG_CONTAINER, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_BIG_CONTAINER"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_BIG_CONTAINER).c_str()); return result; } @@ -970,7 +1154,7 @@ float AbstractCharacteristics::getNitroMaxSpeedIncrease() const bool isSet = false; process(NITRO_MAX_SPEED_INCREASE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_MAX_SPEED_INCREASE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_MAX_SPEED_INCREASE).c_str()); return result; } @@ -980,7 +1164,7 @@ float AbstractCharacteristics::getNitroFadeOutTime() const bool isSet = false; process(NITRO_FADE_OUT_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_FADE_OUT_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_FADE_OUT_TIME).c_str()); return result; } @@ -990,7 +1174,7 @@ float AbstractCharacteristics::getNitroMax() const bool isSet = false; process(NITRO_MAX, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic NITRO_MAX"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_MAX).c_str()); return result; } @@ -1000,7 +1184,7 @@ float AbstractCharacteristics::getSlipstreamDuration() const bool isSet = false; process(SLIPSTREAM_DURATION, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_DURATION"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_DURATION).c_str()); return result; } @@ -1010,7 +1194,7 @@ float AbstractCharacteristics::getSlipstreamLength() const bool isSet = false; process(SLIPSTREAM_LENGTH, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_LENGTH"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_LENGTH).c_str()); return result; } @@ -1020,7 +1204,7 @@ float AbstractCharacteristics::getSlipstreamWidth() const bool isSet = false; process(SLIPSTREAM_WIDTH, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_WIDTH"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_WIDTH).c_str()); return result; } @@ -1030,7 +1214,7 @@ float AbstractCharacteristics::getSlipstreamCollectTime() const bool isSet = false; process(SLIPSTREAM_COLLECT_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_COLLECT_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_COLLECT_TIME).c_str()); return result; } @@ -1040,7 +1224,7 @@ float AbstractCharacteristics::getSlipstreamUseTime() const bool isSet = false; process(SLIPSTREAM_USE_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_USE_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_USE_TIME).c_str()); return result; } @@ -1050,7 +1234,7 @@ float AbstractCharacteristics::getSlipstreamAddPower() const bool isSet = false; process(SLIPSTREAM_ADD_POWER, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_ADD_POWER"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_ADD_POWER).c_str()); return result; } @@ -1060,7 +1244,7 @@ float AbstractCharacteristics::getSlipstreamMinSpeed() const bool isSet = false; process(SLIPSTREAM_MIN_SPEED, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_MIN_SPEED"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_MIN_SPEED).c_str()); return result; } @@ -1070,7 +1254,7 @@ float AbstractCharacteristics::getSlipstreamMaxSpeedIncrease() const bool isSet = false; process(SLIPSTREAM_MAX_SPEED_INCREASE, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_MAX_SPEED_INCREASE"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_MAX_SPEED_INCREASE).c_str()); return result; } @@ -1080,7 +1264,7 @@ float AbstractCharacteristics::getSlipstreamFadeOutTime() const bool isSet = false; process(SLIPSTREAM_FADE_OUT_TIME, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic SLIPSTREAM_FADE_OUT_TIME"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_FADE_OUT_TIME).c_str()); return result; } diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp index cd4ac015d..8c018185a 100755 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -19,6 +19,7 @@ #ifndef HEADER_ABSTRACT_CHARACTERISTICS_HPP #define HEADER_ABSTRACT_CHARACTERISTICS_HPP +#include #include class SkiddingProperties; @@ -214,6 +215,7 @@ public: virtual void process(CharacteristicType type, Value value, bool *isSet) const; static ValueType getType(CharacteristicType type); + static std::string getName(CharacteristicType type); // Script-generated content float getSuspensionStiffness() const; diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 3da7cb71c..6839a41a2 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -132,7 +132,7 @@ def joinSubName(group, member, titleCase): def main(): # Find out what to do if len(sys.argv) == 1: - print("Please specify what you want to know [enum/defs/getter/getType/getXml]") + print("Please specify what you want to know [enum/defs/getter/getProp/getXml]") return task = sys.argv[1] @@ -188,17 +188,24 @@ def main(): bool isSet = false; process({2}, &result, &isSet); if (!isSet) - Log::fatal("AbstractCharacteristics", "Can't get characteristic {2}"); + Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName({2}).c_str()); return {4}; }} """.format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result)) - elif task == "getType": + elif task == "getProp": for g in groups: for m in g.members: nameTitle = joinSubName(g, m, True) nameUnderscore = joinSubName(g, m, False) - print(""" case {0}:\n return TYPE_{1};""". + print(" case {0}:\n return TYPE_{1};". format(nameUnderscore.upper(), "_".join(toList(m.typeStr)).upper())) + print("\n\n-------------------- END --------------------\n") + for g in groups: + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False).upper() + print(" case {0}:\n return \"{0}\";". + format(nameUnderscore)) elif task == "getXml": for g in groups: print(" if (const XMLNode *sub_node = node->getNode(\"{0}\"))\n {{". From cedd816ca1b9ac8c4be71085fc6ff66ee6fe8c5d Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 19 Apr 2015 02:51:26 +0200 Subject: [PATCH 12/55] Extend InterpolationArray --- src/utils/interpolation_array.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/interpolation_array.hpp b/src/utils/interpolation_array.hpp index e4f0b7893..c66286eae 100644 --- a/src/utils/interpolation_array.hpp +++ b/src/utils/interpolation_array.hpp @@ -43,6 +43,14 @@ private: public: InterpolationArray() {}; + /** Removes all saved values from this object. */ + void clear() + { + m_x.clear(); + m_y.clear(); + m_delta.clear(); + } + /** Adds the value pair x/y to the list of all points. It is tested * that the x values are added in order. * \param x, y The pair to add. From c22d5c8e6e778f26ee3eb9c738441bd503bbed5a Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 19 Apr 2015 02:56:15 +0200 Subject: [PATCH 13/55] Add more to xml reading --- src/karts/abstract_characteristics.cpp | 518 ++++++++++++------------- src/karts/abstract_characteristics.hpp | 4 +- src/karts/cached_characteristics.cpp | 18 +- src/karts/cached_characteristics.hpp | 2 +- src/karts/combined_characteristics.cpp | 4 +- src/karts/combined_characteristics.hpp | 2 +- src/karts/xml_characteristics.cpp | 130 ++++++- src/karts/xml_characteristics.hpp | 4 +- tools/create_kart_properties.py | 6 +- 9 files changed, 406 insertions(+), 282 deletions(-) diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristics.cpp index 0026355d7..fee8b98cf 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 *is_set) const { Log::warn("AbstractCharacteristics", "This type does not do anything"); } @@ -411,9 +411,9 @@ std::string AbstractCharacteristics::getName(CharacteristicType type) float AbstractCharacteristics::getSuspensionStiffness() const { float result; - bool isSet = false; - process(SUSPENSION_STIFFNESS, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SUSPENSION_STIFFNESS, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_STIFFNESS).c_str()); return result; } @@ -421,9 +421,9 @@ float AbstractCharacteristics::getSuspensionStiffness() const float AbstractCharacteristics::getSuspensionRest() const { float result; - bool isSet = false; - process(SUSPENSION_REST, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SUSPENSION_REST, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_REST).c_str()); return result; } @@ -431,9 +431,9 @@ float AbstractCharacteristics::getSuspensionRest() const float AbstractCharacteristics::getSuspensionTravelCm() const { float result; - bool isSet = false; - process(SUSPENSION_TRAVEL_CM, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SUSPENSION_TRAVEL_CM, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_TRAVEL_CM).c_str()); return result; } @@ -441,9 +441,9 @@ float AbstractCharacteristics::getSuspensionTravelCm() const float AbstractCharacteristics::getSuspensionExpSpringResponse() const { float result; - bool isSet = false; - process(SUSPENSION_EXP_SPRING_RESPONSE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SUSPENSION_EXP_SPRING_RESPONSE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_EXP_SPRING_RESPONSE).c_str()); return result; } @@ -451,9 +451,9 @@ float AbstractCharacteristics::getSuspensionExpSpringResponse() const float AbstractCharacteristics::getSuspensionMaxForce() const { float result; - bool isSet = false; - process(SUSPENSION_MAX_FORCE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SUSPENSION_MAX_FORCE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_MAX_FORCE).c_str()); return result; } @@ -461,9 +461,9 @@ float AbstractCharacteristics::getSuspensionMaxForce() const float AbstractCharacteristics::getStabilityRollInfluence() const { float result; - bool isSet = false; - process(STABILITY_ROLL_INFLUENCE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(STABILITY_ROLL_INFLUENCE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_ROLL_INFLUENCE).c_str()); return result; } @@ -471,9 +471,9 @@ float AbstractCharacteristics::getStabilityRollInfluence() const float AbstractCharacteristics::getStabilityChassisLinearDamping() const { float result; - bool isSet = false; - process(STABILITY_CHASSIS_LINEAR_DAMPING, &result, &isSet); - if (!isSet) + bool is_set = false; + process(STABILITY_CHASSIS_LINEAR_DAMPING, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_CHASSIS_LINEAR_DAMPING).c_str()); return result; } @@ -481,9 +481,9 @@ float AbstractCharacteristics::getStabilityChassisLinearDamping() const float AbstractCharacteristics::getStabilityChassisAngularDamping() const { float result; - bool isSet = false; - process(STABILITY_CHASSIS_ANGULAR_DAMPING, &result, &isSet); - if (!isSet) + bool is_set = false; + process(STABILITY_CHASSIS_ANGULAR_DAMPING, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_CHASSIS_ANGULAR_DAMPING).c_str()); return result; } @@ -491,9 +491,9 @@ float AbstractCharacteristics::getStabilityChassisAngularDamping() const float AbstractCharacteristics::getStabilityDownwardImpulseFactor() const { float result; - bool isSet = false; - process(STABILITY_DOWNWARD_IMPULSE_FACTOR, &result, &isSet); - if (!isSet) + bool is_set = false; + process(STABILITY_DOWNWARD_IMPULSE_FACTOR, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_DOWNWARD_IMPULSE_FACTOR).c_str()); return result; } @@ -501,9 +501,9 @@ float AbstractCharacteristics::getStabilityDownwardImpulseFactor() const float AbstractCharacteristics::getStabilityTrackConnectionAccel() const { float result; - bool isSet = false; - process(STABILITY_TRACK_CONNECTION_ACCEL, &result, &isSet); - if (!isSet) + bool is_set = false; + process(STABILITY_TRACK_CONNECTION_ACCEL, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_TRACK_CONNECTION_ACCEL).c_str()); return result; } @@ -511,9 +511,9 @@ float AbstractCharacteristics::getStabilityTrackConnectionAccel() const float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const { float result; - bool isSet = false; - process(STABILITY_SMOOTH_FLYING_IMPULSE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(STABILITY_SMOOTH_FLYING_IMPULSE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_SMOOTH_FLYING_IMPULSE).c_str()); return result; } @@ -521,9 +521,9 @@ float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const InterpolationArray&& AbstractCharacteristics::getTurnRadius() const { InterpolationArray result; - bool isSet = false; - process(TURN_RADIUS, &result, &isSet); - if (!isSet) + 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); } @@ -531,9 +531,9 @@ InterpolationArray&& AbstractCharacteristics::getTurnRadius() const float AbstractCharacteristics::getTurnTimeResetSteer() const { float result; - bool isSet = false; - process(TURN_TIME_RESET_STEER, &result, &isSet); - if (!isSet) + bool is_set = false; + process(TURN_TIME_RESET_STEER, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_TIME_RESET_STEER).c_str()); return result; } @@ -541,9 +541,9 @@ float AbstractCharacteristics::getTurnTimeResetSteer() const InterpolationArray&& AbstractCharacteristics::getTurnTimeFullSteer() const { InterpolationArray result; - bool isSet = false; - process(TURN_TIME_FULL_STEER, &result, &isSet); - if (!isSet) + 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); } @@ -551,9 +551,9 @@ InterpolationArray&& AbstractCharacteristics::getTurnTimeFullSteer() const float AbstractCharacteristics::getEnginePower() const { float result; - bool isSet = false; - process(ENGINE_POWER, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ENGINE_POWER, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_POWER).c_str()); return result; } @@ -561,9 +561,9 @@ float AbstractCharacteristics::getEnginePower() const float AbstractCharacteristics::getEngineMaxSpeed() const { float result; - bool isSet = false; - process(ENGINE_MAX_SPEED, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ENGINE_MAX_SPEED, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED).c_str()); return result; } @@ -571,9 +571,9 @@ float AbstractCharacteristics::getEngineMaxSpeed() const float AbstractCharacteristics::getEngineBrakeFactor() const { float result; - bool isSet = false; - process(ENGINE_BRAKE_FACTOR, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ENGINE_BRAKE_FACTOR, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_BRAKE_FACTOR).c_str()); return result; } @@ -581,9 +581,9 @@ float AbstractCharacteristics::getEngineBrakeFactor() const float AbstractCharacteristics::getEngineBrakeTimeIncrease() const { float result; - bool isSet = false; - process(ENGINE_BRAKE_TIME_INCREASE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ENGINE_BRAKE_TIME_INCREASE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_BRAKE_TIME_INCREASE).c_str()); return result; } @@ -591,9 +591,9 @@ float AbstractCharacteristics::getEngineBrakeTimeIncrease() const float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const { float result; - bool isSet = false; - process(ENGINE_MAX_SPEED_REVERSE_RATIO, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ENGINE_MAX_SPEED_REVERSE_RATIO, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED_REVERSE_RATIO).c_str()); return result; } @@ -601,9 +601,9 @@ float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const std::vector&& AbstractCharacteristics::getGearSwitchRatio() const { std::vector result; - bool isSet = false; - process(GEAR_SWITCH_RATIO, &result, &isSet); - if (!isSet) + 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); } @@ -611,9 +611,9 @@ std::vector&& AbstractCharacteristics::getGearSwitchRatio() const std::vector&& AbstractCharacteristics::getGearPowerIncrease() const { std::vector result; - bool isSet = false; - process(GEAR_POWER_INCREASE, &result, &isSet); - if (!isSet) + 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); } @@ -621,9 +621,9 @@ std::vector&& AbstractCharacteristics::getGearPowerIncrease() const float AbstractCharacteristics::getMass() const { float result; - bool isSet = false; - process(MASS, &result, &isSet); - if (!isSet) + bool is_set = false; + process(MASS, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(MASS).c_str()); return result; } @@ -631,9 +631,9 @@ float AbstractCharacteristics::getMass() const float AbstractCharacteristics::getWheelsDampingRelaxation() const { float result; - bool isSet = false; - process(WHEELS_DAMPING_RELAXATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(WHEELS_DAMPING_RELAXATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_DAMPING_RELAXATION).c_str()); return result; } @@ -641,9 +641,9 @@ float AbstractCharacteristics::getWheelsDampingRelaxation() const float AbstractCharacteristics::getWheelsDampingCompression() const { float result; - bool isSet = false; - process(WHEELS_DAMPING_COMPRESSION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(WHEELS_DAMPING_COMPRESSION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_DAMPING_COMPRESSION).c_str()); return result; } @@ -651,9 +651,9 @@ float AbstractCharacteristics::getWheelsDampingCompression() const float AbstractCharacteristics::getWheelsRadius() const { float result; - bool isSet = false; - process(WHEELS_RADIUS, &result, &isSet); - if (!isSet) + bool is_set = false; + process(WHEELS_RADIUS, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_RADIUS).c_str()); return result; } @@ -661,9 +661,9 @@ float AbstractCharacteristics::getWheelsRadius() const std::vector&& AbstractCharacteristics::getWheelsPosition() const { std::vector result; - bool isSet = false; - process(WHEELS_POSITION, &result, &isSet); - if (!isSet) + 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); } @@ -671,9 +671,9 @@ std::vector&& AbstractCharacteristics::getWheelsPosition() const float AbstractCharacteristics::getCameraDistance() const { float result; - bool isSet = false; - process(CAMERA_DISTANCE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(CAMERA_DISTANCE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_DISTANCE).c_str()); return result; } @@ -681,9 +681,9 @@ float AbstractCharacteristics::getCameraDistance() const float AbstractCharacteristics::getCameraForwardUpAngle() const { float result; - bool isSet = false; - process(CAMERA_FORWARD_UP_ANGLE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(CAMERA_FORWARD_UP_ANGLE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_FORWARD_UP_ANGLE).c_str()); return result; } @@ -691,9 +691,9 @@ float AbstractCharacteristics::getCameraForwardUpAngle() const float AbstractCharacteristics::getCameraBackwardUpAngle() const { float result; - bool isSet = false; - process(CAMERA_BACKWARD_UP_ANGLE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(CAMERA_BACKWARD_UP_ANGLE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_BACKWARD_UP_ANGLE).c_str()); return result; } @@ -701,9 +701,9 @@ float AbstractCharacteristics::getCameraBackwardUpAngle() const float AbstractCharacteristics::getJumpAnimationTime() const { float result; - bool isSet = false; - process(JUMP_ANIMATION_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(JUMP_ANIMATION_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(JUMP_ANIMATION_TIME).c_str()); return result; } @@ -711,9 +711,9 @@ float AbstractCharacteristics::getJumpAnimationTime() const float AbstractCharacteristics::getLeanMax() const { float result; - bool isSet = false; - process(LEAN_MAX, &result, &isSet); - if (!isSet) + bool is_set = false; + process(LEAN_MAX, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(LEAN_MAX).c_str()); return result; } @@ -721,9 +721,9 @@ float AbstractCharacteristics::getLeanMax() const float AbstractCharacteristics::getLeanSpeed() const { float result; - bool isSet = false; - process(LEAN_SPEED, &result, &isSet); - if (!isSet) + bool is_set = false; + process(LEAN_SPEED, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(LEAN_SPEED).c_str()); return result; } @@ -731,9 +731,9 @@ float AbstractCharacteristics::getLeanSpeed() const float AbstractCharacteristics::getAnvilDuration() const { float result; - bool isSet = false; - process(ANVIL_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ANVIL_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_DURATION).c_str()); return result; } @@ -741,9 +741,9 @@ float AbstractCharacteristics::getAnvilDuration() const float AbstractCharacteristics::getAnvilWeight() const { float result; - bool isSet = false; - process(ANVIL_WEIGHT, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ANVIL_WEIGHT, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_WEIGHT).c_str()); return result; } @@ -751,9 +751,9 @@ float AbstractCharacteristics::getAnvilWeight() const float AbstractCharacteristics::getAnvilSpeedFactor() const { float result; - bool isSet = false; - process(ANVIL_SPEED_FACTOR, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ANVIL_SPEED_FACTOR, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_SPEED_FACTOR).c_str()); return result; } @@ -761,9 +761,9 @@ float AbstractCharacteristics::getAnvilSpeedFactor() const float AbstractCharacteristics::getParachuteFriction() const { float result; - bool isSet = false; - process(PARACHUTE_FRICTION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PARACHUTE_FRICTION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_FRICTION).c_str()); return result; } @@ -771,9 +771,9 @@ float AbstractCharacteristics::getParachuteFriction() const float AbstractCharacteristics::getParachuteDuration() const { float result; - bool isSet = false; - process(PARACHUTE_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PARACHUTE_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_DURATION).c_str()); return result; } @@ -781,9 +781,9 @@ float AbstractCharacteristics::getParachuteDuration() const float AbstractCharacteristics::getParachuteDurationOther() const { float result; - bool isSet = false; - process(PARACHUTE_DURATION_OTHER, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PARACHUTE_DURATION_OTHER, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_DURATION_OTHER).c_str()); return result; } @@ -791,9 +791,9 @@ float AbstractCharacteristics::getParachuteDurationOther() const float AbstractCharacteristics::getParachuteLboundFranction() const { float result; - bool isSet = false; - process(PARACHUTE_LBOUND_FRANCTION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PARACHUTE_LBOUND_FRANCTION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_LBOUND_FRANCTION).c_str()); return result; } @@ -801,9 +801,9 @@ float AbstractCharacteristics::getParachuteLboundFranction() const float AbstractCharacteristics::getParachuteUboundFranction() const { float result; - bool isSet = false; - process(PARACHUTE_UBOUND_FRANCTION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PARACHUTE_UBOUND_FRANCTION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_UBOUND_FRANCTION).c_str()); return result; } @@ -811,9 +811,9 @@ float AbstractCharacteristics::getParachuteUboundFranction() const float AbstractCharacteristics::getParachuteMaxSpeed() const { float result; - bool isSet = false; - process(PARACHUTE_MAX_SPEED, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PARACHUTE_MAX_SPEED, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_MAX_SPEED).c_str()); return result; } @@ -821,9 +821,9 @@ float AbstractCharacteristics::getParachuteMaxSpeed() const float AbstractCharacteristics::getBubblegumDuration() const { float result; - bool isSet = false; - process(BUBBLEGUM_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(BUBBLEGUM_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_DURATION).c_str()); return result; } @@ -831,9 +831,9 @@ float AbstractCharacteristics::getBubblegumDuration() const float AbstractCharacteristics::getBubblegumSpeedFraction() const { float result; - bool isSet = false; - process(BUBBLEGUM_SPEED_FRACTION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(BUBBLEGUM_SPEED_FRACTION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_SPEED_FRACTION).c_str()); return result; } @@ -841,9 +841,9 @@ float AbstractCharacteristics::getBubblegumSpeedFraction() const float AbstractCharacteristics::getBubblegumTorque() const { float result; - bool isSet = false; - process(BUBBLEGUM_TORQUE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(BUBBLEGUM_TORQUE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_TORQUE).c_str()); return result; } @@ -851,9 +851,9 @@ float AbstractCharacteristics::getBubblegumTorque() const float AbstractCharacteristics::getBubblegumFadeInTime() const { float result; - bool isSet = false; - process(BUBBLEGUM_FADE_IN_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(BUBBLEGUM_FADE_IN_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_FADE_IN_TIME).c_str()); return result; } @@ -861,9 +861,9 @@ float AbstractCharacteristics::getBubblegumFadeInTime() const float AbstractCharacteristics::getBubblegumShieldDuration() const { float result; - bool isSet = false; - process(BUBBLEGUM_SHIELD_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(BUBBLEGUM_SHIELD_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_SHIELD_DURATION).c_str()); return result; } @@ -871,9 +871,9 @@ float AbstractCharacteristics::getBubblegumShieldDuration() const float AbstractCharacteristics::getZipperDuration() const { float result; - bool isSet = false; - process(ZIPPER_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ZIPPER_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_DURATION).c_str()); return result; } @@ -881,9 +881,9 @@ float AbstractCharacteristics::getZipperDuration() const float AbstractCharacteristics::getZipperForce() const { float result; - bool isSet = false; - process(ZIPPER_FORCE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ZIPPER_FORCE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_FORCE).c_str()); return result; } @@ -891,9 +891,9 @@ float AbstractCharacteristics::getZipperForce() const float AbstractCharacteristics::getZipperSpeedGain() const { float result; - bool isSet = false; - process(ZIPPER_SPEED_GAIN, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ZIPPER_SPEED_GAIN, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_SPEED_GAIN).c_str()); return result; } @@ -901,9 +901,9 @@ float AbstractCharacteristics::getZipperSpeedGain() const float AbstractCharacteristics::getZipperSpeedIncrease() const { float result; - bool isSet = false; - process(ZIPPER_SPEED_INCREASE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ZIPPER_SPEED_INCREASE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_SPEED_INCREASE).c_str()); return result; } @@ -911,9 +911,9 @@ float AbstractCharacteristics::getZipperSpeedIncrease() const float AbstractCharacteristics::getZipperFadeOutTime() const { float result; - bool isSet = false; - process(ZIPPER_FADE_OUT_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(ZIPPER_FADE_OUT_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_FADE_OUT_TIME).c_str()); return result; } @@ -921,9 +921,9 @@ float AbstractCharacteristics::getZipperFadeOutTime() const float AbstractCharacteristics::getSwatterDuration() const { float result; - bool isSet = false; - process(SWATTER_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SWATTER_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_DURATION).c_str()); return result; } @@ -931,9 +931,9 @@ float AbstractCharacteristics::getSwatterDuration() const float AbstractCharacteristics::getSwatterDistance() const { float result; - bool isSet = false; - process(SWATTER_DISTANCE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SWATTER_DISTANCE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_DISTANCE).c_str()); return result; } @@ -941,9 +941,9 @@ float AbstractCharacteristics::getSwatterDistance() const float AbstractCharacteristics::getSwatterSquashDuration() const { float result; - bool isSet = false; - process(SWATTER_SQUASH_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SWATTER_SQUASH_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_SQUASH_DURATION).c_str()); return result; } @@ -951,9 +951,9 @@ float AbstractCharacteristics::getSwatterSquashDuration() const float AbstractCharacteristics::getSwatterSquashSlowdown() const { float result; - bool isSet = false; - process(SWATTER_SQUASH_SLOWDOWN, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SWATTER_SQUASH_SLOWDOWN, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_SQUASH_SLOWDOWN).c_str()); return result; } @@ -961,9 +961,9 @@ float AbstractCharacteristics::getSwatterSquashSlowdown() const float AbstractCharacteristics::getPlungerMaxLength() const { float result; - bool isSet = false; - process(PLUNGER_MAX_LENGTH, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PLUNGER_MAX_LENGTH, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_MAX_LENGTH).c_str()); return result; } @@ -971,9 +971,9 @@ float AbstractCharacteristics::getPlungerMaxLength() const float AbstractCharacteristics::getPlungerForce() const { float result; - bool isSet = false; - process(PLUNGER_FORCE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PLUNGER_FORCE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_FORCE).c_str()); return result; } @@ -981,9 +981,9 @@ float AbstractCharacteristics::getPlungerForce() const float AbstractCharacteristics::getPlungerDuration() const { float result; - bool isSet = false; - process(PLUNGER_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PLUNGER_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_DURATION).c_str()); return result; } @@ -991,9 +991,9 @@ float AbstractCharacteristics::getPlungerDuration() const float AbstractCharacteristics::getPlungerSpeedIncrease() const { float result; - bool isSet = false; - process(PLUNGER_SPEED_INCREASE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PLUNGER_SPEED_INCREASE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_SPEED_INCREASE).c_str()); return result; } @@ -1001,9 +1001,9 @@ float AbstractCharacteristics::getPlungerSpeedIncrease() const float AbstractCharacteristics::getPlungerFadeOutTime() const { float result; - bool isSet = false; - process(PLUNGER_FADE_OUT_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PLUNGER_FADE_OUT_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_FADE_OUT_TIME).c_str()); return result; } @@ -1011,9 +1011,9 @@ float AbstractCharacteristics::getPlungerFadeOutTime() const float AbstractCharacteristics::getPlungerInFaceTime() const { float result; - bool isSet = false; - process(PLUNGER_IN_FACE_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(PLUNGER_IN_FACE_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_IN_FACE_TIME).c_str()); return result; } @@ -1021,9 +1021,9 @@ float AbstractCharacteristics::getPlungerInFaceTime() const std::vector&& AbstractCharacteristics::getStartupTime() const { std::vector result; - bool isSet = false; - process(STARTUP_TIME, &result, &isSet); - if (!isSet) + 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); } @@ -1031,9 +1031,9 @@ std::vector&& AbstractCharacteristics::getStartupTime() const std::vector&& AbstractCharacteristics::getStartupBoost() const { std::vector result; - bool isSet = false; - process(STARTUP_BOOST, &result, &isSet); - if (!isSet) + 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); } @@ -1041,9 +1041,9 @@ std::vector&& AbstractCharacteristics::getStartupBoost() const float AbstractCharacteristics::getRescueDuration() const { float result; - bool isSet = false; - process(RESCUE_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(RESCUE_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_DURATION).c_str()); return result; } @@ -1051,9 +1051,9 @@ float AbstractCharacteristics::getRescueDuration() const float AbstractCharacteristics::getRescueVertOffset() const { float result; - bool isSet = false; - process(RESCUE_VERT_OFFSET, &result, &isSet); - if (!isSet) + bool is_set = false; + process(RESCUE_VERT_OFFSET, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_VERT_OFFSET).c_str()); return result; } @@ -1061,9 +1061,9 @@ float AbstractCharacteristics::getRescueVertOffset() const float AbstractCharacteristics::getRescueHeight() const { float result; - bool isSet = false; - process(RESCUE_HEIGHT, &result, &isSet); - if (!isSet) + bool is_set = false; + process(RESCUE_HEIGHT, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_HEIGHT).c_str()); return result; } @@ -1071,9 +1071,9 @@ float AbstractCharacteristics::getRescueHeight() const float AbstractCharacteristics::getExplosionDuration() const { float result; - bool isSet = false; - process(EXPLOSION_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(EXPLOSION_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_DURATION).c_str()); return result; } @@ -1081,9 +1081,9 @@ float AbstractCharacteristics::getExplosionDuration() const float AbstractCharacteristics::getExplosionRadius() const { float result; - bool isSet = false; - process(EXPLOSION_RADIUS, &result, &isSet); - if (!isSet) + bool is_set = false; + process(EXPLOSION_RADIUS, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_RADIUS).c_str()); return result; } @@ -1091,9 +1091,9 @@ float AbstractCharacteristics::getExplosionRadius() const float AbstractCharacteristics::getExplosionInvulnerabilityTime() const { float result; - bool isSet = false; - process(EXPLOSION_INVULNERABILITY_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(EXPLOSION_INVULNERABILITY_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_INVULNERABILITY_TIME).c_str()); return result; } @@ -1101,9 +1101,9 @@ float AbstractCharacteristics::getExplosionInvulnerabilityTime() const float AbstractCharacteristics::getNitroDuration() const { float result; - bool isSet = false; - process(NITRO_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_DURATION).c_str()); return result; } @@ -1111,9 +1111,9 @@ float AbstractCharacteristics::getNitroDuration() const float AbstractCharacteristics::getNitroEngineForce() const { float result; - bool isSet = false; - process(NITRO_ENGINE_FORCE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_ENGINE_FORCE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_ENGINE_FORCE).c_str()); return result; } @@ -1121,9 +1121,9 @@ float AbstractCharacteristics::getNitroEngineForce() const float AbstractCharacteristics::getNitroConsumption() const { float result; - bool isSet = false; - process(NITRO_CONSUMPTION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_CONSUMPTION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_CONSUMPTION).c_str()); return result; } @@ -1131,9 +1131,9 @@ float AbstractCharacteristics::getNitroConsumption() const float AbstractCharacteristics::getNitroSmallContainer() const { float result; - bool isSet = false; - process(NITRO_SMALL_CONTAINER, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_SMALL_CONTAINER, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_SMALL_CONTAINER).c_str()); return result; } @@ -1141,9 +1141,9 @@ float AbstractCharacteristics::getNitroSmallContainer() const float AbstractCharacteristics::getNitroBigContainer() const { float result; - bool isSet = false; - process(NITRO_BIG_CONTAINER, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_BIG_CONTAINER, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_BIG_CONTAINER).c_str()); return result; } @@ -1151,9 +1151,9 @@ float AbstractCharacteristics::getNitroBigContainer() const float AbstractCharacteristics::getNitroMaxSpeedIncrease() const { float result; - bool isSet = false; - process(NITRO_MAX_SPEED_INCREASE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_MAX_SPEED_INCREASE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_MAX_SPEED_INCREASE).c_str()); return result; } @@ -1161,9 +1161,9 @@ float AbstractCharacteristics::getNitroMaxSpeedIncrease() const float AbstractCharacteristics::getNitroFadeOutTime() const { float result; - bool isSet = false; - process(NITRO_FADE_OUT_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_FADE_OUT_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_FADE_OUT_TIME).c_str()); return result; } @@ -1171,9 +1171,9 @@ float AbstractCharacteristics::getNitroFadeOutTime() const float AbstractCharacteristics::getNitroMax() const { float result; - bool isSet = false; - process(NITRO_MAX, &result, &isSet); - if (!isSet) + bool is_set = false; + process(NITRO_MAX, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_MAX).c_str()); return result; } @@ -1181,9 +1181,9 @@ float AbstractCharacteristics::getNitroMax() const float AbstractCharacteristics::getSlipstreamDuration() const { float result; - bool isSet = false; - process(SLIPSTREAM_DURATION, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_DURATION, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_DURATION).c_str()); return result; } @@ -1191,9 +1191,9 @@ float AbstractCharacteristics::getSlipstreamDuration() const float AbstractCharacteristics::getSlipstreamLength() const { float result; - bool isSet = false; - process(SLIPSTREAM_LENGTH, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_LENGTH, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_LENGTH).c_str()); return result; } @@ -1201,9 +1201,9 @@ float AbstractCharacteristics::getSlipstreamLength() const float AbstractCharacteristics::getSlipstreamWidth() const { float result; - bool isSet = false; - process(SLIPSTREAM_WIDTH, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_WIDTH, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_WIDTH).c_str()); return result; } @@ -1211,9 +1211,9 @@ float AbstractCharacteristics::getSlipstreamWidth() const float AbstractCharacteristics::getSlipstreamCollectTime() const { float result; - bool isSet = false; - process(SLIPSTREAM_COLLECT_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_COLLECT_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_COLLECT_TIME).c_str()); return result; } @@ -1221,9 +1221,9 @@ float AbstractCharacteristics::getSlipstreamCollectTime() const float AbstractCharacteristics::getSlipstreamUseTime() const { float result; - bool isSet = false; - process(SLIPSTREAM_USE_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_USE_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_USE_TIME).c_str()); return result; } @@ -1231,9 +1231,9 @@ float AbstractCharacteristics::getSlipstreamUseTime() const float AbstractCharacteristics::getSlipstreamAddPower() const { float result; - bool isSet = false; - process(SLIPSTREAM_ADD_POWER, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_ADD_POWER, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_ADD_POWER).c_str()); return result; } @@ -1241,9 +1241,9 @@ float AbstractCharacteristics::getSlipstreamAddPower() const float AbstractCharacteristics::getSlipstreamMinSpeed() const { float result; - bool isSet = false; - process(SLIPSTREAM_MIN_SPEED, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_MIN_SPEED, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_MIN_SPEED).c_str()); return result; } @@ -1251,9 +1251,9 @@ float AbstractCharacteristics::getSlipstreamMinSpeed() const float AbstractCharacteristics::getSlipstreamMaxSpeedIncrease() const { float result; - bool isSet = false; - process(SLIPSTREAM_MAX_SPEED_INCREASE, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_MAX_SPEED_INCREASE, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_MAX_SPEED_INCREASE).c_str()); return result; } @@ -1261,9 +1261,9 @@ float AbstractCharacteristics::getSlipstreamMaxSpeedIncrease() const float AbstractCharacteristics::getSlipstreamFadeOutTime() const { float result; - bool isSet = false; - process(SLIPSTREAM_FADE_OUT_TIME, &result, &isSet); - if (!isSet) + bool is_set = false; + process(SLIPSTREAM_FADE_OUT_TIME, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_FADE_OUT_TIME).c_str()); return result; } diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristics.hpp index 8c018185a..1e2b0ab73 100755 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristics.hpp @@ -209,10 +209,10 @@ public: * * \param type The characteristic that should be modified. * \param value The current value and result at the same time. - * \param isSet If the current value was already set (so it can be used + * \param is_set 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 *is_set) const; static ValueType getType(CharacteristicType type); static std::string getName(CharacteristicType type); diff --git a/src/karts/cached_characteristics.cpp b/src/karts/cached_characteristics.cpp index c66b33166..6e616e872 100644 --- a/src/karts/cached_characteristics.cpp +++ b/src/karts/cached_characteristics.cpp @@ -58,15 +58,15 @@ void CachedCharacteristics::updateSource() { SaveValue &v = m_values[i]; - bool isSet = false; + bool is_set = false; switch (getType(static_cast(i))) { case TYPE_FLOAT: { float value; float *ptr = static_cast(v.content); - m_origin->process(static_cast(i), &value, &isSet); - if (isSet) + m_origin->process(static_cast(i), &value, &is_set); + if (is_set) { if (!ptr) { @@ -90,8 +90,8 @@ void CachedCharacteristics::updateSource() { std::vector value; std::vector *ptr = static_cast*>(v.content); - m_origin->process(static_cast(i), &value, &isSet); - if (isSet) + m_origin->process(static_cast(i), &value, &is_set); + if (is_set) { if (!ptr) { @@ -116,8 +116,8 @@ void CachedCharacteristics::updateSource() { InterpolationArray value; InterpolationArray *ptr = static_cast(v.content); - m_origin->process(static_cast(i), &value, &isSet); - if (isSet) + m_origin->process(static_cast(i), &value, &is_set); + if (is_set) { 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 *is_set) 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; + *is_set = true; } } diff --git a/src/karts/cached_characteristics.hpp b/src/karts/cached_characteristics.hpp index 5d9cfa5a9..41965a031 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 *is_set) const; }; #endif diff --git a/src/karts/combined_characteristics.cpp b/src/karts/combined_characteristics.cpp index ad74878e1..01689c14c 100644 --- a/src/karts/combined_characteristics.cpp +++ b/src/karts/combined_characteristics.cpp @@ -34,9 +34,9 @@ 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 *is_set) const { for (const AbstractCharacteristics *characteristic : m_childs) - characteristic->process(type, value, isSet); + characteristic->process(type, value, is_set); } diff --git a/src/karts/combined_characteristics.hpp b/src/karts/combined_characteristics.hpp index 5daefc3f3..03cf6d464 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 *is_set) const; }; #endif diff --git a/src/karts/xml_characteristics.cpp b/src/karts/xml_characteristics.cpp index 333a951f3..c041e776f 100644 --- a/src/karts/xml_characteristics.cpp +++ b/src/karts/xml_characteristics.cpp @@ -18,6 +18,10 @@ #include "karts/xml_characteristics.hpp" +#include "utils/interpolation_array.hpp" +#include "utils/log.hpp" +#include "utils/string_utils.hpp" + #include "io/xml_node.hpp" XmlCharacteristics::XmlCharacteristics(const XMLNode *node) : @@ -33,21 +37,141 @@ 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 *is_set) const { switch (getType(type)) { case TYPE_FLOAT: - processFloat(m_values[type], value.f, isSet); + processFloat(m_values[type], value.f, is_set); break; case TYPE_FLOAT_VECTOR: + { + const std::vector processors = + StringUtils::split(m_values[type], ' '); + if (*is_set) + { + if (processors.size() != value.fv->size()) + { + Log::error("XmlCharacteristics::process", + "FloatVectors have different sizes for %s", + getName(type).c_str()); + break; + } + std::vector::iterator fit = value.fv->begin(); + for (std::vector::const_iterator it = processors.begin(); + it != processors.end(); it++, fit++) + processFloat(*it, &*fit, is_set); + } + else + { + value.fv->resize(processors.size()); + std::vector::iterator fit = value.fv->begin(); + for (std::vector::const_iterator it = processors.begin(); + it != processors.end(); it++, fit++) + { + *is_set = false; + processFloat(*it, &*fit, is_set); + + if (!*is_set) + { + Log::error("XmlCharacteristics::process", "Can't process %s", + getName(type).c_str()); + value.fv->clear(); + break; + } + } + } break; + } case TYPE_INTERPOLATION_ARRAY: + { + const std::vector processors = + StringUtils::split(m_values[type], ' '); + if (*is_set) + { + if (processors.size() != value.fv->size()) + { + Log::error("XmlCharacteristics::process", + "InterpolationArrays have different sizes for %s", + getName(type).c_str()); + break; + } + else + { + for (std::vector::const_iterator it = processors.begin(); + it != processors.end(); it++) + { + 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 + { + float x; + if (!StringUtils::fromString(pair[0], x)) + Log::error("XmlCharacteristics::process", + "Can't process %s: Not a float", getName(type).c_str()); + else + { + // Search the index of this x value + bool found = false; + for (unsigned int i = 0; i < value.ia->size(); i++) + { + if (value.ia->getX(i) == x) + { + float val; + processFloat(pair[1], &val, is_set); + value.ia->setY(i, val); + break; + } + } + if (!found) + Log::error("XmlCharacteristics::process", + "Can't find the %f in %s", x, + getName(type).c_str()); + } + } + } + } + } + else + { + for (std::vector::const_iterator it = processors.begin(); + it != processors.end(); it++) + { + 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 + { + float x; + if (!StringUtils::fromString(pair[0], x)) + Log::error("XmlCharacteristics::process", + "Can't process %s: Not a float", getName(type).c_str()); + else + { + float val; + *is_set = false; + processFloat(pair[1], &val, is_set); + if (!*is_set) + { + Log::error("XmlCharacteristics::process", "Can't process %s", + getName(type).c_str()); + value.ia->clear(); + break; + } + value.ia->push_back(x, val); + } + } + } + } break; } + } } -void XmlCharacteristics::processFloat(const std::string &processor, float *value, bool *isSet) +void XmlCharacteristics::processFloat(const std::string &processor, float *value, bool *is_set) { } diff --git a/src/karts/xml_characteristics.hpp b/src/karts/xml_characteristics.hpp index 592d94879..3c709305f 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 *is_set) const; void load(const XMLNode *node); private: - static void processFloat(const std::string &processor, float *value, bool *isSet); + static void processFloat(const std::string &processor, float *value, bool *is_set); }; #endif diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 6839a41a2..df2245fa9 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -185,9 +185,9 @@ def main(): print("""{3} AbstractCharacteristics::get{1}() const {{ {0} result; - bool isSet = false; - process({2}, &result, &isSet); - if (!isSet) + bool is_set = false; + process({2}, &result, &is_set); + if (!is_set) Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName({2}).c_str()); return {4}; }} From 2272002d5c80040eb42e0b4c920136878458a15c Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 19 Apr 2015 03:18:43 +0200 Subject: [PATCH 14/55] Implement processFloat --- src/karts/xml_characteristics.cpp | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/karts/xml_characteristics.cpp b/src/karts/xml_characteristics.cpp index c041e776f..8e73cc330 100644 --- a/src/karts/xml_characteristics.cpp +++ b/src/karts/xml_characteristics.cpp @@ -173,7 +173,64 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ void XmlCharacteristics::processFloat(const std::string &processor, float *value, bool *is_set) { + // Split the string by operators + static const std::string operators = "*/+-"; + std::vector parts; + std::vector operations; + std::size_t pos = 0; + std::size_t pos2; + while ((pos2 = processor.find_first_of(operators, pos)) != std::string::npos) + { + parts.push_back(processor.substr(pos, pos2)); + operations.push_back(processor.substr(pos2, pos2 + 1)); + pos = pos2 + 1; + } + parts.push_back(processor.substr(pos)); + if (parts.empty()) + { + Log::error("XmlCharacteristics::processFloat", "no content to process"); + return; + } + + // Compute the result + float x = *value; + std::size_t index = 0; + // If nothing preceeds the first operator, insert x + if (parts[index].empty()) + { + if (!*is_set) + { + Log::error("XmlCharacteristics::processFloat", "x is unknown"); + return; + } + else + { + *value = x; + index++; + } + } + for (; index < parts.size(); index++) + { + float val; + if (parts[index] == "x" || parts[index] == "X") + val = x; + else if (!StringUtils::fromString(parts[index], val)) + { + Log::fatal("XmlCharacteristics::processFloat", + "Can't process %s: Not a float", parts[index].c_str()); + return; + } + if (operations[index - 1] == "*") + *value *= val; + else if (operations[index - 1] == "/") + *value /= val; + else if (operations[index - 1] == "+") + *value += val; + else if (operations[index - 1] == "-") + *value -= val; + } + *is_set = true; } void XmlCharacteristics::load(const XMLNode *node) From cb797c3145a6d4224a3b97e1066706aedffe96a1 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 8 Jul 2015 22:07:46 +0200 Subject: [PATCH 15/55] Remove unnecessary move and add a bit documentation --- src/karts/abstract_characteristics.cpp | 28 +++++++++++++------------- src/karts/abstract_characteristics.hpp | 22 +++++++++++--------- src/karts/xml_characteristics.cpp | 9 ++++++--- tools/create_kart_properties.py | 18 ++++------------- 4 files changed, 37 insertions(+), 40 deletions(-) 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 {{ From a305b357a30e6aaac4a4b8fca6697401ab8e3e07 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 10 Jul 2015 00:36:50 +0200 Subject: [PATCH 16/55] Change characteristics to characteristic and add player characteristics --- data/kart_characteristics.xml | 546 +++++++++--------- ...istics.cpp => abstract_characteristic.cpp} | 364 ++++++------ ...istics.hpp => abstract_characteristic.hpp} | 7 +- src/karts/abstract_kart.hpp | 3 + ...eristics.cpp => cached_characteristic.cpp} | 12 +- ...eristics.hpp => cached_characteristic.hpp} | 12 +- ...istics.cpp => combined_characteristic.cpp} | 12 +- ...istics.hpp => combined_characteristic.hpp} | 8 +- src/karts/kart_properties_manager.cpp | 1 + src/karts/kart_properties_manager.hpp | 7 + src/karts/xml_characteristics.cpp | 36 +- src/karts/xml_characteristics.hpp | 6 +- tools/create_kart_properties.py | 4 +- 13 files changed, 526 insertions(+), 492 deletions(-) rename src/karts/{abstract_characteristics.cpp => abstract_characteristic.cpp} (60%) rename src/karts/{abstract_characteristics.hpp => abstract_characteristic.hpp} (97%) rename src/karts/{cached_characteristics.cpp => cached_characteristic.cpp} (92%) rename src/karts/{cached_characteristics.hpp => cached_characteristic.hpp} (82%) rename src/karts/{combined_characteristics.cpp => combined_characteristic.cpp} (70%) rename src/karts/{combined_characteristics.hpp => combined_characteristic.hpp} (82%) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index b2d080003..4039ffb17 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -1,292 +1,312 @@ - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - + + + + + + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/karts/abstract_characteristics.cpp b/src/karts/abstract_characteristic.cpp similarity index 60% rename from src/karts/abstract_characteristics.cpp rename to src/karts/abstract_characteristic.cpp index 174d1d000..2995f948a 100755 --- a/src/karts/abstract_characteristics.cpp +++ b/src/karts/abstract_characteristic.cpp @@ -16,34 +16,34 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "karts/abstract_characteristics.hpp" +#include "karts/abstract_characteristic.hpp" #include "utils/log.hpp" #include "utils/interpolation_array.hpp" #include -AbstractCharacteristics::AbstractCharacteristics() +AbstractCharacteristic::AbstractCharacteristic() { } -const SkiddingProperties* AbstractCharacteristics::getSkiddingProperties() const +const SkiddingProperties* AbstractCharacteristic::getSkiddingProperties() const { return nullptr; } -void AbstractCharacteristics::process(CharacteristicType type, Value value, bool *is_set) const +void AbstractCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const { - Log::warn("AbstractCharacteristics", "This type does not do anything"); + Log::warn("AbstractCharacteristic", "This type does not do anything"); } -AbstractCharacteristics::ValueType AbstractCharacteristics::getType(CharacteristicType type) +AbstractCharacteristic::ValueType AbstractCharacteristic::getType(CharacteristicType type) { switch (type) { case CHARACTERISTIC_COUNT: - Log::fatal("AbstractCharacteristics::getType", "Can't get type of COUNT"); + Log::fatal("AbstractCharacteristic::getType", "Can't get type of COUNT"); break; // Script-generated content case SUSPENSION_STIFFNESS: @@ -219,11 +219,11 @@ AbstractCharacteristics::ValueType AbstractCharacteristics::getType(Characterist case SLIPSTREAM_FADE_OUT_TIME: return TYPE_FLOAT; } - Log::fatal("AbstractCharacteristics::getType", "Unknown type"); + Log::fatal("AbstractCharacteristic::getType", "Unknown type"); return TYPE_FLOAT; } -std::string AbstractCharacteristics::getName(CharacteristicType type) +std::string AbstractCharacteristic::getName(CharacteristicType type) { switch (type) { @@ -403,868 +403,868 @@ std::string AbstractCharacteristics::getName(CharacteristicType type) case SLIPSTREAM_FADE_OUT_TIME: return "SLIPSTREAM_FADE_OUT_TIME"; } - Log::error("AbstractCharacteristics::getName", "Unknown type"); + Log::error("AbstractCharacteristic::getName", "Unknown type"); return "Unknown type"; } // Script-generated getter -float AbstractCharacteristics::getSuspensionStiffness() const +float AbstractCharacteristic::getSuspensionStiffness() const { float result; bool is_set = false; process(SUSPENSION_STIFFNESS, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_STIFFNESS).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SUSPENSION_STIFFNESS).c_str()); return result; } -float AbstractCharacteristics::getSuspensionRest() const +float AbstractCharacteristic::getSuspensionRest() const { float result; bool is_set = false; process(SUSPENSION_REST, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_REST).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SUSPENSION_REST).c_str()); return result; } -float AbstractCharacteristics::getSuspensionTravelCm() const +float AbstractCharacteristic::getSuspensionTravelCm() const { float result; bool is_set = false; process(SUSPENSION_TRAVEL_CM, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_TRAVEL_CM).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SUSPENSION_TRAVEL_CM).c_str()); return result; } -float AbstractCharacteristics::getSuspensionExpSpringResponse() const +float AbstractCharacteristic::getSuspensionExpSpringResponse() const { float result; bool is_set = false; process(SUSPENSION_EXP_SPRING_RESPONSE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_EXP_SPRING_RESPONSE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SUSPENSION_EXP_SPRING_RESPONSE).c_str()); return result; } -float AbstractCharacteristics::getSuspensionMaxForce() const +float AbstractCharacteristic::getSuspensionMaxForce() const { float result; bool is_set = false; process(SUSPENSION_MAX_FORCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SUSPENSION_MAX_FORCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SUSPENSION_MAX_FORCE).c_str()); return result; } -float AbstractCharacteristics::getStabilityRollInfluence() const +float AbstractCharacteristic::getStabilityRollInfluence() const { float result; bool is_set = false; process(STABILITY_ROLL_INFLUENCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_ROLL_INFLUENCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STABILITY_ROLL_INFLUENCE).c_str()); return result; } -float AbstractCharacteristics::getStabilityChassisLinearDamping() const +float AbstractCharacteristic::getStabilityChassisLinearDamping() const { float result; bool is_set = false; process(STABILITY_CHASSIS_LINEAR_DAMPING, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_CHASSIS_LINEAR_DAMPING).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STABILITY_CHASSIS_LINEAR_DAMPING).c_str()); return result; } -float AbstractCharacteristics::getStabilityChassisAngularDamping() const +float AbstractCharacteristic::getStabilityChassisAngularDamping() const { float result; bool is_set = false; process(STABILITY_CHASSIS_ANGULAR_DAMPING, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_CHASSIS_ANGULAR_DAMPING).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STABILITY_CHASSIS_ANGULAR_DAMPING).c_str()); return result; } -float AbstractCharacteristics::getStabilityDownwardImpulseFactor() const +float AbstractCharacteristic::getStabilityDownwardImpulseFactor() const { float result; bool is_set = false; process(STABILITY_DOWNWARD_IMPULSE_FACTOR, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_DOWNWARD_IMPULSE_FACTOR).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STABILITY_DOWNWARD_IMPULSE_FACTOR).c_str()); return result; } -float AbstractCharacteristics::getStabilityTrackConnectionAccel() const +float AbstractCharacteristic::getStabilityTrackConnectionAccel() const { float result; bool is_set = false; process(STABILITY_TRACK_CONNECTION_ACCEL, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_TRACK_CONNECTION_ACCEL).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STABILITY_TRACK_CONNECTION_ACCEL).c_str()); return result; } -float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const +float AbstractCharacteristic::getStabilitySmoothFlyingImpulse() const { float result; bool is_set = false; process(STABILITY_SMOOTH_FLYING_IMPULSE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STABILITY_SMOOTH_FLYING_IMPULSE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STABILITY_SMOOTH_FLYING_IMPULSE).c_str()); return result; } -InterpolationArray AbstractCharacteristics::getTurnRadius() const +InterpolationArray AbstractCharacteristic::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()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(TURN_RADIUS).c_str()); return result; } -float AbstractCharacteristics::getTurnTimeResetSteer() const +float AbstractCharacteristic::getTurnTimeResetSteer() const { float result; bool is_set = false; process(TURN_TIME_RESET_STEER, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_TIME_RESET_STEER).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(TURN_TIME_RESET_STEER).c_str()); return result; } -InterpolationArray AbstractCharacteristics::getTurnTimeFullSteer() const +InterpolationArray AbstractCharacteristic::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()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(TURN_TIME_FULL_STEER).c_str()); return result; } -float AbstractCharacteristics::getEnginePower() const +float AbstractCharacteristic::getEnginePower() const { float result; bool is_set = false; process(ENGINE_POWER, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_POWER).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ENGINE_POWER).c_str()); return result; } -float AbstractCharacteristics::getEngineMaxSpeed() const +float AbstractCharacteristic::getEngineMaxSpeed() const { float result; bool is_set = false; process(ENGINE_MAX_SPEED, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED).c_str()); return result; } -float AbstractCharacteristics::getEngineBrakeFactor() const +float AbstractCharacteristic::getEngineBrakeFactor() const { float result; bool is_set = false; process(ENGINE_BRAKE_FACTOR, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_BRAKE_FACTOR).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ENGINE_BRAKE_FACTOR).c_str()); return result; } -float AbstractCharacteristics::getEngineBrakeTimeIncrease() const +float AbstractCharacteristic::getEngineBrakeTimeIncrease() const { float result; bool is_set = false; process(ENGINE_BRAKE_TIME_INCREASE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_BRAKE_TIME_INCREASE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ENGINE_BRAKE_TIME_INCREASE).c_str()); return result; } -float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const +float AbstractCharacteristic::getEngineMaxSpeedReverseRatio() const { float result; bool is_set = false; process(ENGINE_MAX_SPEED_REVERSE_RATIO, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED_REVERSE_RATIO).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ENGINE_MAX_SPEED_REVERSE_RATIO).c_str()); return result; } -std::vector AbstractCharacteristics::getGearSwitchRatio() const +std::vector AbstractCharacteristic::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()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(GEAR_SWITCH_RATIO).c_str()); return result; } -std::vector AbstractCharacteristics::getGearPowerIncrease() const +std::vector AbstractCharacteristic::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()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(GEAR_POWER_INCREASE).c_str()); return result; } -float AbstractCharacteristics::getMass() const +float AbstractCharacteristic::getMass() const { float result; bool is_set = false; process(MASS, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(MASS).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(MASS).c_str()); return result; } -float AbstractCharacteristics::getWheelsDampingRelaxation() const +float AbstractCharacteristic::getWheelsDampingRelaxation() const { float result; bool is_set = false; process(WHEELS_DAMPING_RELAXATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_DAMPING_RELAXATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(WHEELS_DAMPING_RELAXATION).c_str()); return result; } -float AbstractCharacteristics::getWheelsDampingCompression() const +float AbstractCharacteristic::getWheelsDampingCompression() const { float result; bool is_set = false; process(WHEELS_DAMPING_COMPRESSION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_DAMPING_COMPRESSION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(WHEELS_DAMPING_COMPRESSION).c_str()); return result; } -float AbstractCharacteristics::getWheelsRadius() const +float AbstractCharacteristic::getWheelsRadius() const { float result; bool is_set = false; process(WHEELS_RADIUS, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_RADIUS).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(WHEELS_RADIUS).c_str()); return result; } -std::vector AbstractCharacteristics::getWheelsPosition() const +std::vector AbstractCharacteristic::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()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(WHEELS_POSITION).c_str()); return result; } -float AbstractCharacteristics::getCameraDistance() const +float AbstractCharacteristic::getCameraDistance() const { float result; bool is_set = false; process(CAMERA_DISTANCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_DISTANCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(CAMERA_DISTANCE).c_str()); return result; } -float AbstractCharacteristics::getCameraForwardUpAngle() const +float AbstractCharacteristic::getCameraForwardUpAngle() const { float result; bool is_set = false; process(CAMERA_FORWARD_UP_ANGLE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_FORWARD_UP_ANGLE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(CAMERA_FORWARD_UP_ANGLE).c_str()); return result; } -float AbstractCharacteristics::getCameraBackwardUpAngle() const +float AbstractCharacteristic::getCameraBackwardUpAngle() const { float result; bool is_set = false; process(CAMERA_BACKWARD_UP_ANGLE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(CAMERA_BACKWARD_UP_ANGLE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(CAMERA_BACKWARD_UP_ANGLE).c_str()); return result; } -float AbstractCharacteristics::getJumpAnimationTime() const +float AbstractCharacteristic::getJumpAnimationTime() const { float result; bool is_set = false; process(JUMP_ANIMATION_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(JUMP_ANIMATION_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(JUMP_ANIMATION_TIME).c_str()); return result; } -float AbstractCharacteristics::getLeanMax() const +float AbstractCharacteristic::getLeanMax() const { float result; bool is_set = false; process(LEAN_MAX, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(LEAN_MAX).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(LEAN_MAX).c_str()); return result; } -float AbstractCharacteristics::getLeanSpeed() const +float AbstractCharacteristic::getLeanSpeed() const { float result; bool is_set = false; process(LEAN_SPEED, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(LEAN_SPEED).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(LEAN_SPEED).c_str()); return result; } -float AbstractCharacteristics::getAnvilDuration() const +float AbstractCharacteristic::getAnvilDuration() const { float result; bool is_set = false; process(ANVIL_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ANVIL_DURATION).c_str()); return result; } -float AbstractCharacteristics::getAnvilWeight() const +float AbstractCharacteristic::getAnvilWeight() const { float result; bool is_set = false; process(ANVIL_WEIGHT, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_WEIGHT).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ANVIL_WEIGHT).c_str()); return result; } -float AbstractCharacteristics::getAnvilSpeedFactor() const +float AbstractCharacteristic::getAnvilSpeedFactor() const { float result; bool is_set = false; process(ANVIL_SPEED_FACTOR, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ANVIL_SPEED_FACTOR).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ANVIL_SPEED_FACTOR).c_str()); return result; } -float AbstractCharacteristics::getParachuteFriction() const +float AbstractCharacteristic::getParachuteFriction() const { float result; bool is_set = false; process(PARACHUTE_FRICTION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_FRICTION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PARACHUTE_FRICTION).c_str()); return result; } -float AbstractCharacteristics::getParachuteDuration() const +float AbstractCharacteristic::getParachuteDuration() const { float result; bool is_set = false; process(PARACHUTE_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PARACHUTE_DURATION).c_str()); return result; } -float AbstractCharacteristics::getParachuteDurationOther() const +float AbstractCharacteristic::getParachuteDurationOther() const { float result; bool is_set = false; process(PARACHUTE_DURATION_OTHER, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_DURATION_OTHER).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PARACHUTE_DURATION_OTHER).c_str()); return result; } -float AbstractCharacteristics::getParachuteLboundFranction() const +float AbstractCharacteristic::getParachuteLboundFranction() const { float result; bool is_set = false; process(PARACHUTE_LBOUND_FRANCTION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_LBOUND_FRANCTION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PARACHUTE_LBOUND_FRANCTION).c_str()); return result; } -float AbstractCharacteristics::getParachuteUboundFranction() const +float AbstractCharacteristic::getParachuteUboundFranction() const { float result; bool is_set = false; process(PARACHUTE_UBOUND_FRANCTION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_UBOUND_FRANCTION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PARACHUTE_UBOUND_FRANCTION).c_str()); return result; } -float AbstractCharacteristics::getParachuteMaxSpeed() const +float AbstractCharacteristic::getParachuteMaxSpeed() const { float result; bool is_set = false; process(PARACHUTE_MAX_SPEED, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PARACHUTE_MAX_SPEED).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PARACHUTE_MAX_SPEED).c_str()); return result; } -float AbstractCharacteristics::getBubblegumDuration() const +float AbstractCharacteristic::getBubblegumDuration() const { float result; bool is_set = false; process(BUBBLEGUM_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(BUBBLEGUM_DURATION).c_str()); return result; } -float AbstractCharacteristics::getBubblegumSpeedFraction() const +float AbstractCharacteristic::getBubblegumSpeedFraction() const { float result; bool is_set = false; process(BUBBLEGUM_SPEED_FRACTION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_SPEED_FRACTION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(BUBBLEGUM_SPEED_FRACTION).c_str()); return result; } -float AbstractCharacteristics::getBubblegumTorque() const +float AbstractCharacteristic::getBubblegumTorque() const { float result; bool is_set = false; process(BUBBLEGUM_TORQUE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_TORQUE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(BUBBLEGUM_TORQUE).c_str()); return result; } -float AbstractCharacteristics::getBubblegumFadeInTime() const +float AbstractCharacteristic::getBubblegumFadeInTime() const { float result; bool is_set = false; process(BUBBLEGUM_FADE_IN_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_FADE_IN_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(BUBBLEGUM_FADE_IN_TIME).c_str()); return result; } -float AbstractCharacteristics::getBubblegumShieldDuration() const +float AbstractCharacteristic::getBubblegumShieldDuration() const { float result; bool is_set = false; process(BUBBLEGUM_SHIELD_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(BUBBLEGUM_SHIELD_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(BUBBLEGUM_SHIELD_DURATION).c_str()); return result; } -float AbstractCharacteristics::getZipperDuration() const +float AbstractCharacteristic::getZipperDuration() const { float result; bool is_set = false; process(ZIPPER_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ZIPPER_DURATION).c_str()); return result; } -float AbstractCharacteristics::getZipperForce() const +float AbstractCharacteristic::getZipperForce() const { float result; bool is_set = false; process(ZIPPER_FORCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_FORCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ZIPPER_FORCE).c_str()); return result; } -float AbstractCharacteristics::getZipperSpeedGain() const +float AbstractCharacteristic::getZipperSpeedGain() const { float result; bool is_set = false; process(ZIPPER_SPEED_GAIN, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_SPEED_GAIN).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ZIPPER_SPEED_GAIN).c_str()); return result; } -float AbstractCharacteristics::getZipperSpeedIncrease() const +float AbstractCharacteristic::getZipperSpeedIncrease() const { float result; bool is_set = false; process(ZIPPER_SPEED_INCREASE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_SPEED_INCREASE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ZIPPER_SPEED_INCREASE).c_str()); return result; } -float AbstractCharacteristics::getZipperFadeOutTime() const +float AbstractCharacteristic::getZipperFadeOutTime() const { float result; bool is_set = false; process(ZIPPER_FADE_OUT_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(ZIPPER_FADE_OUT_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ZIPPER_FADE_OUT_TIME).c_str()); return result; } -float AbstractCharacteristics::getSwatterDuration() const +float AbstractCharacteristic::getSwatterDuration() const { float result; bool is_set = false; process(SWATTER_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SWATTER_DURATION).c_str()); return result; } -float AbstractCharacteristics::getSwatterDistance() const +float AbstractCharacteristic::getSwatterDistance() const { float result; bool is_set = false; process(SWATTER_DISTANCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_DISTANCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SWATTER_DISTANCE).c_str()); return result; } -float AbstractCharacteristics::getSwatterSquashDuration() const +float AbstractCharacteristic::getSwatterSquashDuration() const { float result; bool is_set = false; process(SWATTER_SQUASH_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_SQUASH_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SWATTER_SQUASH_DURATION).c_str()); return result; } -float AbstractCharacteristics::getSwatterSquashSlowdown() const +float AbstractCharacteristic::getSwatterSquashSlowdown() const { float result; bool is_set = false; process(SWATTER_SQUASH_SLOWDOWN, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SWATTER_SQUASH_SLOWDOWN).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SWATTER_SQUASH_SLOWDOWN).c_str()); return result; } -float AbstractCharacteristics::getPlungerMaxLength() const +float AbstractCharacteristic::getPlungerMaxLength() const { float result; bool is_set = false; process(PLUNGER_MAX_LENGTH, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_MAX_LENGTH).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_MAX_LENGTH).c_str()); return result; } -float AbstractCharacteristics::getPlungerForce() const +float AbstractCharacteristic::getPlungerForce() const { float result; bool is_set = false; process(PLUNGER_FORCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_FORCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_FORCE).c_str()); return result; } -float AbstractCharacteristics::getPlungerDuration() const +float AbstractCharacteristic::getPlungerDuration() const { float result; bool is_set = false; process(PLUNGER_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_DURATION).c_str()); return result; } -float AbstractCharacteristics::getPlungerSpeedIncrease() const +float AbstractCharacteristic::getPlungerSpeedIncrease() const { float result; bool is_set = false; process(PLUNGER_SPEED_INCREASE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_SPEED_INCREASE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_SPEED_INCREASE).c_str()); return result; } -float AbstractCharacteristics::getPlungerFadeOutTime() const +float AbstractCharacteristic::getPlungerFadeOutTime() const { float result; bool is_set = false; process(PLUNGER_FADE_OUT_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_FADE_OUT_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_FADE_OUT_TIME).c_str()); return result; } -float AbstractCharacteristics::getPlungerInFaceTime() const +float AbstractCharacteristic::getPlungerInFaceTime() const { float result; bool is_set = false; process(PLUNGER_IN_FACE_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(PLUNGER_IN_FACE_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_IN_FACE_TIME).c_str()); return result; } -std::vector AbstractCharacteristics::getStartupTime() const +std::vector AbstractCharacteristic::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()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STARTUP_TIME).c_str()); return result; } -std::vector AbstractCharacteristics::getStartupBoost() const +std::vector AbstractCharacteristic::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()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(STARTUP_BOOST).c_str()); return result; } -float AbstractCharacteristics::getRescueDuration() const +float AbstractCharacteristic::getRescueDuration() const { float result; bool is_set = false; process(RESCUE_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(RESCUE_DURATION).c_str()); return result; } -float AbstractCharacteristics::getRescueVertOffset() const +float AbstractCharacteristic::getRescueVertOffset() const { float result; bool is_set = false; process(RESCUE_VERT_OFFSET, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_VERT_OFFSET).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(RESCUE_VERT_OFFSET).c_str()); return result; } -float AbstractCharacteristics::getRescueHeight() const +float AbstractCharacteristic::getRescueHeight() const { float result; bool is_set = false; process(RESCUE_HEIGHT, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(RESCUE_HEIGHT).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(RESCUE_HEIGHT).c_str()); return result; } -float AbstractCharacteristics::getExplosionDuration() const +float AbstractCharacteristic::getExplosionDuration() const { float result; bool is_set = false; process(EXPLOSION_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(EXPLOSION_DURATION).c_str()); return result; } -float AbstractCharacteristics::getExplosionRadius() const +float AbstractCharacteristic::getExplosionRadius() const { float result; bool is_set = false; process(EXPLOSION_RADIUS, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_RADIUS).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(EXPLOSION_RADIUS).c_str()); return result; } -float AbstractCharacteristics::getExplosionInvulnerabilityTime() const +float AbstractCharacteristic::getExplosionInvulnerabilityTime() const { float result; bool is_set = false; process(EXPLOSION_INVULNERABILITY_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(EXPLOSION_INVULNERABILITY_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(EXPLOSION_INVULNERABILITY_TIME).c_str()); return result; } -float AbstractCharacteristics::getNitroDuration() const +float AbstractCharacteristic::getNitroDuration() const { float result; bool is_set = false; process(NITRO_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_DURATION).c_str()); return result; } -float AbstractCharacteristics::getNitroEngineForce() const +float AbstractCharacteristic::getNitroEngineForce() const { float result; bool is_set = false; process(NITRO_ENGINE_FORCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_ENGINE_FORCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_ENGINE_FORCE).c_str()); return result; } -float AbstractCharacteristics::getNitroConsumption() const +float AbstractCharacteristic::getNitroConsumption() const { float result; bool is_set = false; process(NITRO_CONSUMPTION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_CONSUMPTION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_CONSUMPTION).c_str()); return result; } -float AbstractCharacteristics::getNitroSmallContainer() const +float AbstractCharacteristic::getNitroSmallContainer() const { float result; bool is_set = false; process(NITRO_SMALL_CONTAINER, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_SMALL_CONTAINER).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_SMALL_CONTAINER).c_str()); return result; } -float AbstractCharacteristics::getNitroBigContainer() const +float AbstractCharacteristic::getNitroBigContainer() const { float result; bool is_set = false; process(NITRO_BIG_CONTAINER, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_BIG_CONTAINER).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_BIG_CONTAINER).c_str()); return result; } -float AbstractCharacteristics::getNitroMaxSpeedIncrease() const +float AbstractCharacteristic::getNitroMaxSpeedIncrease() const { float result; bool is_set = false; process(NITRO_MAX_SPEED_INCREASE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_MAX_SPEED_INCREASE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_MAX_SPEED_INCREASE).c_str()); return result; } -float AbstractCharacteristics::getNitroFadeOutTime() const +float AbstractCharacteristic::getNitroFadeOutTime() const { float result; bool is_set = false; process(NITRO_FADE_OUT_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_FADE_OUT_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_FADE_OUT_TIME).c_str()); return result; } -float AbstractCharacteristics::getNitroMax() const +float AbstractCharacteristic::getNitroMax() const { float result; bool is_set = false; process(NITRO_MAX, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(NITRO_MAX).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(NITRO_MAX).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamDuration() const +float AbstractCharacteristic::getSlipstreamDuration() const { float result; bool is_set = false; process(SLIPSTREAM_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_DURATION).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamLength() const +float AbstractCharacteristic::getSlipstreamLength() const { float result; bool is_set = false; process(SLIPSTREAM_LENGTH, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_LENGTH).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_LENGTH).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamWidth() const +float AbstractCharacteristic::getSlipstreamWidth() const { float result; bool is_set = false; process(SLIPSTREAM_WIDTH, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_WIDTH).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_WIDTH).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamCollectTime() const +float AbstractCharacteristic::getSlipstreamCollectTime() const { float result; bool is_set = false; process(SLIPSTREAM_COLLECT_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_COLLECT_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_COLLECT_TIME).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamUseTime() const +float AbstractCharacteristic::getSlipstreamUseTime() const { float result; bool is_set = false; process(SLIPSTREAM_USE_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_USE_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_USE_TIME).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamAddPower() const +float AbstractCharacteristic::getSlipstreamAddPower() const { float result; bool is_set = false; process(SLIPSTREAM_ADD_POWER, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_ADD_POWER).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_ADD_POWER).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamMinSpeed() const +float AbstractCharacteristic::getSlipstreamMinSpeed() const { float result; bool is_set = false; process(SLIPSTREAM_MIN_SPEED, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_MIN_SPEED).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_MIN_SPEED).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamMaxSpeedIncrease() const +float AbstractCharacteristic::getSlipstreamMaxSpeedIncrease() const { float result; bool is_set = false; process(SLIPSTREAM_MAX_SPEED_INCREASE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_MAX_SPEED_INCREASE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_MAX_SPEED_INCREASE).c_str()); return result; } -float AbstractCharacteristics::getSlipstreamFadeOutTime() const +float AbstractCharacteristic::getSlipstreamFadeOutTime() const { float result; bool is_set = false; process(SLIPSTREAM_FADE_OUT_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(SLIPSTREAM_FADE_OUT_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SLIPSTREAM_FADE_OUT_TIME).c_str()); return result; } diff --git a/src/karts/abstract_characteristics.hpp b/src/karts/abstract_characteristic.hpp similarity index 97% rename from src/karts/abstract_characteristics.hpp rename to src/karts/abstract_characteristic.hpp index fecff5da8..8146d7eba 100755 --- a/src/karts/abstract_characteristics.hpp +++ b/src/karts/abstract_characteristic.hpp @@ -36,8 +36,11 @@ class InterpolationArray; * * The documentation of these properties can be found in * the kart_characteristics.xml file. + * Large parts of this file are generated by tools/create_kart_properties.py. + * Please don't change the generated code here, instead change the script, + * regenerate the code and overwrite the whole generated part with the result. */ -class AbstractCharacteristics +class AbstractCharacteristic { public: union Value @@ -200,7 +203,7 @@ private: //SkiddingProperties *m_skidding; public: - AbstractCharacteristics(); + AbstractCharacteristic(); virtual const SkiddingProperties* getSkiddingProperties() const; diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index 565d8f3bd..d088f40f7 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -33,6 +33,7 @@ namespace irr } } +class AbstractCharacteristics; class AbstractKartAnimation; class Attachment; class btKart; @@ -74,6 +75,8 @@ protected: /** The per-player difficulty. */ const PlayerDifficulty *m_difficulty; + /** The combined properties of the kart and the player. */ + const AbstractCharacteristics *m_characteristics; /** This stores a copy of the kart model. It has to be a copy * since otherwise incosistencies can happen if the same kart diff --git a/src/karts/cached_characteristics.cpp b/src/karts/cached_characteristic.cpp similarity index 92% rename from src/karts/cached_characteristics.cpp rename to src/karts/cached_characteristic.cpp index 6e616e872..418db0bf1 100644 --- a/src/karts/cached_characteristics.cpp +++ b/src/karts/cached_characteristic.cpp @@ -16,18 +16,18 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "karts/cached_characteristics.hpp" +#include "karts/cached_characteristic.hpp" #include "utils/interpolation_array.hpp" -CachedCharacteristics::CachedCharacteristics(const AbstractCharacteristics *origin) : +CachedCharacteristic::CachedCharacteristic(const AbstractCharacteristic *origin) : m_values(CHARACTERISTIC_COUNT), m_origin(origin) { updateSource(); } -CachedCharacteristics::~CachedCharacteristics() +CachedCharacteristic::~CachedCharacteristic() { // Delete all not-null values for (int i = 0; i < CHARACTERISTIC_COUNT; i++) @@ -52,7 +52,7 @@ CachedCharacteristics::~CachedCharacteristics() } } -void CachedCharacteristics::updateSource() +void CachedCharacteristic::updateSource() { for (int i = 0; i < CHARACTERISTIC_COUNT; i++) { @@ -142,12 +142,12 @@ void CachedCharacteristics::updateSource() } } -const SkiddingProperties* CachedCharacteristics::getSkiddingProperties() const +const SkiddingProperties* CachedCharacteristic::getSkiddingProperties() const { return m_origin->getSkiddingProperties(); } -void CachedCharacteristics::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) diff --git a/src/karts/cached_characteristics.hpp b/src/karts/cached_characteristic.hpp similarity index 82% rename from src/karts/cached_characteristics.hpp rename to src/karts/cached_characteristic.hpp index 41965a031..411b8531d 100644 --- a/src/karts/cached_characteristics.hpp +++ b/src/karts/cached_characteristic.hpp @@ -19,9 +19,9 @@ #ifndef HEADER_CACHED_CHARACTERISTICS_HPP #define HEADER_CACHED_CHARACTERISTICS_HPP -#include "karts/abstract_characteristics.hpp" +#include "karts/abstract_characteristic.hpp" -class CachedCharacteristics : public AbstractCharacteristics +class CachedCharacteristic : public AbstractCharacteristic { private: /** Used to store a value. */ @@ -37,12 +37,12 @@ private: std::vector m_values; /** The characteristics that hold the original values. */ - const AbstractCharacteristics *m_origin; + const AbstractCharacteristic *m_origin; public: - CachedCharacteristics(const AbstractCharacteristics *origin); - CachedCharacteristics(const CachedCharacteristics &characteristics) = delete; - virtual ~CachedCharacteristics(); + CachedCharacteristic(const AbstractCharacteristic *origin); + CachedCharacteristic(const CachedCharacteristic &characteristics) = delete; + virtual ~CachedCharacteristic(); /** Fetches all cached values from the original source. */ void updateSource(); diff --git a/src/karts/combined_characteristics.cpp b/src/karts/combined_characteristic.cpp similarity index 70% rename from src/karts/combined_characteristics.cpp rename to src/karts/combined_characteristic.cpp index 01689c14c..4b760c2c7 100644 --- a/src/karts/combined_characteristics.cpp +++ b/src/karts/combined_characteristic.cpp @@ -16,16 +16,16 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "karts/combined_characteristics.hpp" +#include "karts/combined_characteristic.hpp" -void CombinedCharacteristics::addCharacteristic(const AbstractCharacteristics *characteristic) +void CombinedCharacteristic::addCharacteristic(const AbstractCharacteristic *characteristic) { m_childs.push_back(characteristic); } -const SkiddingProperties* CombinedCharacteristics::getSkiddingProperties() const +const SkiddingProperties* CombinedCharacteristic::getSkiddingProperties() const { - for (const AbstractCharacteristics *characteristic : m_childs) + for (const AbstractCharacteristic *characteristic : m_childs) { const SkiddingProperties *skid = characteristic->getSkiddingProperties(); if (skid) @@ -34,9 +34,9 @@ const SkiddingProperties* CombinedCharacteristics::getSkiddingProperties() const return nullptr; } -void CombinedCharacteristics::process(CharacteristicType type, Value value, bool *is_set) const +void CombinedCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const { - for (const AbstractCharacteristics *characteristic : m_childs) + for (const AbstractCharacteristic *characteristic : m_childs) characteristic->process(type, value, is_set); } diff --git a/src/karts/combined_characteristics.hpp b/src/karts/combined_characteristic.hpp similarity index 82% rename from src/karts/combined_characteristics.hpp rename to src/karts/combined_characteristic.hpp index 03cf6d464..9ddbb0246 100644 --- a/src/karts/combined_characteristics.hpp +++ b/src/karts/combined_characteristic.hpp @@ -19,15 +19,15 @@ #ifndef HEADER_COMBINDED_CHARACTERISTICS_HPP #define HEADER_COMBINDED_CHARACTERISTICS_HPP -#include "karts/abstract_characteristics.hpp" +#include "karts/abstract_characteristic.hpp" -class CombinedCharacteristics : public AbstractCharacteristics +class CombinedCharacteristic : public AbstractCharacteristic { private: - std::vector m_childs; + std::vector m_childs; public: - void addCharacteristic(const AbstractCharacteristics *characteristic); + void addCharacteristic(const AbstractCharacteristic *characteristic); virtual const SkiddingProperties* getSkiddingProperties() const; virtual void process(CharacteristicType type, Value value, bool *is_set) const; diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index f8d2554d7..6961a7f97 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -27,6 +27,7 @@ #include "graphics/irr_driver.hpp" #include "guiengine/engine.hpp" #include "io/file_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/kart_properties.hpp" #include "utils/log.hpp" #include "utils/string_utils.hpp" diff --git a/src/karts/kart_properties_manager.hpp b/src/karts/kart_properties_manager.hpp index bcaedf8e6..b02281bea 100644 --- a/src/karts/kart_properties_manager.hpp +++ b/src/karts/kart_properties_manager.hpp @@ -22,12 +22,14 @@ #include "utils/ptr_vector.hpp" #include +#include #include "network/remote_kart_info.hpp" #include "utils/no_copy.hpp" #define ALL_KART_GROUPS_ID "all" +class AbstractCharacteristic; class KartProperties; /** @@ -58,6 +60,11 @@ private: * all clients or not. */ std::vector m_kart_available; + std::unique_ptr m_base_characteristic; + std::vector > m_kart_type_characteristics; + std::vector > m_kart_characteristics; + std::vector > m_player_characteristics; + protected: typedef PtrVector KartPropertiesVector; diff --git a/src/karts/xml_characteristics.cpp b/src/karts/xml_characteristics.cpp index 56acc149b..fa6252236 100644 --- a/src/karts/xml_characteristics.cpp +++ b/src/karts/xml_characteristics.cpp @@ -24,7 +24,7 @@ #include "io/xml_node.hpp" -XmlCharacteristics::XmlCharacteristics(const XMLNode *node) : +XmlCharacteristic::XmlCharacteristic(const XMLNode *node) : m_values(CHARACTERISTIC_COUNT), m_skidding(nullptr) { @@ -32,12 +32,12 @@ XmlCharacteristics::XmlCharacteristics(const XMLNode *node) : load(node); } -const SkiddingProperties* XmlCharacteristics::getSkiddingProperties() const +const SkiddingProperties* XmlCharacteristic::getSkiddingProperties() const { return m_skidding; } -void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_set) const +void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const { switch (getType(type)) { @@ -52,7 +52,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ { if (processors.size() != value.fv->size()) { - Log::error("XmlCharacteristics::process", + Log::error("XmlCharacteristic::process", "FloatVectors have different sizes for %s", getName(type).c_str()); break; @@ -74,7 +74,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ if (!*is_set) { - Log::error("XmlCharacteristics::process", "Can't process %s", + Log::error("XmlCharacteristic::process", "Can't process %s", getName(type).c_str()); value.fv->clear(); break; @@ -91,7 +91,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ { if (processors.size() != value.fv->size()) { - Log::error("XmlCharacteristics::process", + Log::error("XmlCharacteristic::process", "InterpolationArrays have different sizes for %s", getName(type).c_str()); break; @@ -103,13 +103,13 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ { std::vector pair = StringUtils::split(*it, ':'); if (pair.size() != 2) - Log::error("XmlCharacteristics::process", + Log::error("XmlCharacteristic::process", "Can't process %s: Wrong format", getName(type).c_str()); else { float x; if (!StringUtils::fromString(pair[0], x)) - Log::error("XmlCharacteristics::process", + Log::error("XmlCharacteristic::process", "Can't process %s: Not a float", getName(type).c_str()); else { @@ -126,7 +126,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ } } if (!found) - Log::error("XmlCharacteristics::process", + Log::error("XmlCharacteristic::process", "Can't find the %f in %s", x, getName(type).c_str()); } @@ -141,13 +141,13 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ { std::vector pair = StringUtils::split(*it,':'); if (pair.size() != 2) - Log::error("XmlCharacteristics::process", + Log::error("XmlCharacteristic::process", "Can't process %s: Wrong format", getName(type).c_str()); else { float x; if (!StringUtils::fromString(pair[0], x)) - Log::error("XmlCharacteristics::process", + Log::error("XmlCharacteristic::process", "Can't process %s: Not a float", getName(type).c_str()); else { @@ -156,7 +156,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ processFloat(pair[1], &val, is_set); if (!*is_set) { - Log::error("XmlCharacteristics::process", "Can't process %s", + Log::error("XmlCharacteristic::process", "Can't process %s", getName(type).c_str()); value.ia->clear(); break; @@ -171,7 +171,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_ } } -void XmlCharacteristics::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 = "*/+-"; @@ -189,7 +189,7 @@ void XmlCharacteristics::processFloat(const std::string &processor, float *value if (parts.empty()) { - Log::error("XmlCharacteristics::processFloat", "no content to process"); + Log::error("XmlCharacteristic::processFloat", "no content to process"); return; } @@ -201,7 +201,7 @@ void XmlCharacteristics::processFloat(const std::string &processor, float *value { if (!*is_set) { - Log::error("XmlCharacteristics::processFloat", "x is unknown"); + Log::error("XmlCharacteristic::processFloat", "x is unknown"); return; } else @@ -217,7 +217,7 @@ void XmlCharacteristics::processFloat(const std::string &processor, float *value val = x; else if (!StringUtils::fromString(parts[index], val)) { - Log::fatal("XmlCharacteristics::processFloat", + Log::fatal("XmlCharacteristic::processFloat", "Can't process %s: Not a float", parts[index].c_str()); return; } @@ -230,13 +230,13 @@ void XmlCharacteristics::processFloat(const std::string &processor, float *value else if (operations[index - 1] == "-") *value -= val; else - Log::fatal("XmlCharacteristics::processFloat", + Log::fatal("XmlCharacteristic::processFloat", "Unknown operator (%s)", operations[index - 1].c_str()); } *is_set = true; } -void XmlCharacteristics::load(const XMLNode *node) +void XmlCharacteristic::load(const XMLNode *node) { // Script-generated content if (const XMLNode *sub_node = node->getNode("Suspension")) diff --git a/src/karts/xml_characteristics.hpp b/src/karts/xml_characteristics.hpp index 3c709305f..faa9ee270 100644 --- a/src/karts/xml_characteristics.hpp +++ b/src/karts/xml_characteristics.hpp @@ -19,13 +19,13 @@ #ifndef HEADER_XML_CHARACTERISTICS_HPP #define HEADER_XML_CHARACTERISTICS_HPP -#include "karts/abstract_characteristics.hpp" +#include "karts/abstract_characteristic.hpp" #include class XMLNode; -class XmlCharacteristics : public AbstractCharacteristics +class XmlCharacteristic : public AbstractCharacteristic { private: /** The computation that was read from an xml file */ @@ -33,7 +33,7 @@ private: SkiddingProperties *m_skidding; public: - XmlCharacteristics(const XMLNode *node = nullptr); + XmlCharacteristic(const XMLNode *node = nullptr); virtual const SkiddingProperties* getSkiddingProperties() const; virtual void process(CharacteristicType type, Value value, bool *is_set) const; diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index fb1054c78..7e04239ca 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -172,13 +172,13 @@ def main(): typeC = m.typeC result = "result" - print("""{3} AbstractCharacteristics::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("AbstractCharacteristics", "Can't get characteristic %s", getName({2}).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName({2}).c_str()); return {4}; }} """.format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result)) From 0ecc76090b4109ec2cc25b768a98870b24810722 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 10 Jul 2015 01:13:04 +0200 Subject: [PATCH 17/55] Add kart types --- data/kart_characteristics.xml | 71 ++++++++++++++++++++++++--- src/karts/kart_properties.cpp | 4 ++ src/karts/kart_properties.hpp | 5 ++ src/karts/kart_properties_manager.hpp | 1 - 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index 4039ffb17..e51e5b2d2 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -9,8 +9,8 @@ travel-cm: maximum movement of suspension - in cm!! exp-string-response: dampen the suspension spring reaction exponentially. See - http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\&p=25236&hilit=vehicle#p25236 - for details. + http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\&p=25236&hilit=vehicle#p25236 + for details. max-force: Maximum suspension force --> @@ -65,12 +65,12 @@ pressed, the harder the kart will brake. max-speed-reverse-ratio is the percentage of max speed for reverse gear. --> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 2d2198faa..c294fa000 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -25,6 +25,7 @@ #include "graphics/irr_driver.hpp" #include "graphics/material_manager.hpp" #include "io/file_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/controller/ai_properties.hpp" #include "karts/kart_model.hpp" #include "karts/skidding_properties.hpp" @@ -58,6 +59,7 @@ KartProperties::KartProperties(const std::string &filename) m_shadow_scale = 1.0f; m_shadow_x_offset = 0.0f; m_shadow_z_offset = 0.0f; + m_characteristic = NULL; m_groups.clear(); m_custom_sfx_id.resize(SFXManager::NUM_CUSTOMS); @@ -136,6 +138,8 @@ KartProperties::~KartProperties() delete m_kart_model; if(m_skidding_properties) delete m_skidding_properties; + if (m_characteristic) + delete m_characteristic; for(unsigned int i=0; i m_base_characteristic; std::vector > m_kart_type_characteristics; - std::vector > m_kart_characteristics; std::vector > m_player_characteristics; protected: From eb19bf571e7839d8e39e68f2318b69d1021173fd Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sat, 11 Jul 2015 15:38:52 +0200 Subject: [PATCH 18/55] Load and combine characteristics --- data/kart_characteristics.xml | 36 +++++-- src/config/stk_config.cpp | 1 + src/karts/abstract_characteristic.hpp | 3 +- src/karts/abstract_kart.cpp | 20 ++++ src/karts/abstract_kart.hpp | 12 ++- src/karts/kart.cpp | 4 +- src/karts/kart_properties.cpp | 19 +++- src/karts/kart_properties.hpp | 17 +++- src/karts/kart_properties_manager.cpp | 99 +++++++++++++++++-- src/karts/kart_properties_manager.hpp | 21 +++- src/karts/player_difficulty.cpp | 3 +- src/karts/player_difficulty.hpp | 4 +- ...acteristics.cpp => xml_characteristic.cpp} | 79 ++++++++------- ...acteristics.hpp => xml_characteristic.hpp} | 2 - src/main.cpp | 5 + tools/create_kart_properties.py | 2 +- 16 files changed, 259 insertions(+), 68 deletions(-) rename src/karts/{xml_characteristics.cpp => xml_characteristic.cpp} (89%) rename src/karts/{xml_characteristics.hpp => xml_characteristic.hpp} (93%) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index e51e5b2d2..a1273f4c0 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -1,4 +1,11 @@ + @@ -58,23 +65,24 @@ time-reset-steer="0.1" /> - @@ -292,6 +300,22 @@ duration="1" fade-out-time="2" /> + + + + + + + + + + + + + + + + getNode(i); m_player_difficulties[i] = new PlayerDifficulty(); m_player_difficulties[i]->getAllData(type); + m_player_difficulties[i]->setDifficulty((PerPlayerDifficulty) i); } } // getAllData diff --git a/src/karts/abstract_characteristic.hpp b/src/karts/abstract_characteristic.hpp index 8146d7eba..ffc235ce6 100755 --- a/src/karts/abstract_characteristic.hpp +++ b/src/karts/abstract_characteristic.hpp @@ -200,10 +200,11 @@ private: /** The skididing properties for this kart, as a separate object in order * to reduce dependencies (and therefore compile time) when changing * any skidding property. */ - //SkiddingProperties *m_skidding; + //TODO SkiddingProperties *m_skidding; public: AbstractCharacteristic(); + virtual ~AbstractCharacteristic() {} virtual const SkiddingProperties* getSkiddingProperties() const; diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index a88741718..d636ad293 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -20,6 +20,7 @@ #include "karts/abstract_kart.hpp" #include "items/powerup.hpp" +#include "karts/combined_characteristic.hpp" #include "karts/abstract_kart_animation.hpp" #include "karts/kart_model.hpp" #include "karts/kart_properties.hpp" @@ -57,6 +58,19 @@ AbstractKart::AbstractKart(const std::string& ident, m_kart_length = m_kart_model->getLength(); m_kart_highest_point = m_kart_model->getHighestPoint(); m_wheel_graphics_position = m_kart_model->getWheelsGraphicsPosition(); + + // Combine the characteristics for this player + m_characteristic.reset(new CombinedCharacteristic()); + m_characteristic->addCharacteristic(kart_properties_manager-> + getBaseCharacteristic()); + m_characteristic->addCharacteristic(kart_properties_manager-> + getDifficultyCharacteristic(race_manager->getDifficultyAsString( + race_manager->getDifficulty()))); + m_characteristic->addCharacteristic(kart_properties_manager-> + getKartTypeCharacteristic(m_kart_properties->getKartType())); + m_characteristic->addCharacteristic(kart_properties_manager-> + getPlayerCharacteristic(m_difficulty->getIdent())); + m_characteristic->addCharacteristic(m_kart_properties->getCharacteristic()); } // AbstractKart // ---------------------------------------------------------------------------- @@ -78,6 +92,12 @@ void AbstractKart::reset() } } // reset +// ---------------------------------------------------------------------------- +const AbstractCharacteristic* AbstractKart::getCharacteristic() const +{ + return &(*m_characteristic); +} + // ---------------------------------------------------------------------------- /** Returns a name to be displayed for this kart. */ core::stringw AbstractKart::getName() const diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index d088f40f7..ec58dbbd8 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -19,6 +19,8 @@ #ifndef HEADER_ABSTRACT_KART_HPP #define HEADER_ABSTRACT_KART_HPP +#include + #include "items/powerup_manager.hpp" #include "karts/moveable.hpp" #include "karts/controller/kart_control.hpp" @@ -33,11 +35,12 @@ namespace irr } } -class AbstractCharacteristics; +class AbstractCharacteristic; class AbstractKartAnimation; class Attachment; class btKart; class btQuaternion; +class CombinedCharacteristic; class Controller; class Item; class KartModel; @@ -75,8 +78,8 @@ protected: /** The per-player difficulty. */ const PlayerDifficulty *m_difficulty; - /** The combined properties of the kart and the player. */ - const AbstractCharacteristics *m_characteristics; + /** The combined properties of the kart, the player, etc. */ + std::unique_ptr m_characteristic; /** This stores a copy of the kart model. It has to be a copy * since otherwise incosistencies can happen if the same kart @@ -127,6 +130,9 @@ public: // ------------------------------------------------------------------------ /** Sets the kart properties. */ void setKartProperties(const KartProperties *kp) { m_kart_properties=kp; } + // ------------------------------------------------------------------------ + /** Returns the characteristics of this kart. */ + const AbstractCharacteristic* getCharacteristic() const; // ======================================================================== // Access to the per-player difficulty. diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 4919af563..f7f18e9bd 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -38,6 +38,7 @@ #include "graphics/stk_text_billboard.hpp" #include "graphics/stars.hpp" #include "guiengine/scalable_font.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/explosion_animation.hpp" #include "karts/kart_gfx.hpp" #include "karts/rescue_animation.hpp" @@ -1753,8 +1754,7 @@ void Kart::updateNitro(float dt) m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO, m_kart_properties->getNitroMaxSpeedIncrease() * m_difficulty->getNitroMaxSpeedIncrease(), - m_kart_properties->getNitroEngineForce() * - m_difficulty->getNitroEngineForce(), + getCharacteristic()->getNitroEngineForce(), m_kart_properties->getNitroDuration() * m_difficulty->getNitroDuration(), m_kart_properties->getNitroFadeOutTime() * diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index c294fa000..a04e74007 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -25,10 +25,12 @@ #include "graphics/irr_driver.hpp" #include "graphics/material_manager.hpp" #include "io/file_manager.hpp" -#include "karts/abstract_characteristic.hpp" +#include "karts/combined_characteristic.hpp" #include "karts/controller/ai_properties.hpp" #include "karts/kart_model.hpp" +#include "karts/kart_properties_manager.hpp" #include "karts/skidding_properties.hpp" +#include "karts/xml_characteristic.hpp" #include "modes/world.hpp" #include "io/xml_node.hpp" #include "utils/constants.hpp" @@ -162,6 +164,13 @@ void KartProperties::copyFrom(const KartProperties *source) assert(m_skidding_properties); *m_skidding_properties = *source->m_skidding_properties; + if (source->m_characteristic) + { + m_characteristic = new XmlCharacteristic(); + assert(m_characteristic); + *m_characteristic = *source->m_characteristic; + } + for(unsigned int i=0; i nodes; + root->getNodes("characteristic", nodes); + bool found = false; + std::string name; + for (std::vector::const_iterator baseNode = nodes.cbegin(); + baseNode != nodes.cend(); baseNode++) + { + (*baseNode)->get("name", &name); + if (name == "base") + { + found = true; + m_base_characteristic.reset(new XmlCharacteristic(*baseNode)); + break; + } + } + if (!found) + Log::fatal("KartPropertiesManager", "Base characteristics not found"); + + // Load difficulties + nodes.clear(); + root->getNode("difficulties")->getNodes("characteristic", nodes); + for (std::vector::const_iterator type = nodes.cbegin(); + type != nodes.cend(); type++) + { + (*type)->get("name", &name); + m_difficulty_characteristics.emplace(name, + std::unique_ptr(new XmlCharacteristic(*type))); + } + // Load kart type characteristics + nodes.clear(); + root->getNode("kart-types")->getNodes("characteristic", nodes); + for (std::vector::const_iterator type = nodes.cbegin(); + type != nodes.cend(); type++) + { + (*type)->get("name", &name); + m_kart_type_characteristics.emplace(name, + std::unique_ptr(new XmlCharacteristic(*type))); + } + // Load player difficulties + nodes.clear(); + root->getNode("player-characteristics")->getNodes("characteristic", nodes); + for (std::vector::const_iterator type = nodes.cbegin(); + type != nodes.cend(); type++) + { + (*type)->get("name", &name); + m_player_characteristics.emplace(name, + std::unique_ptr(new XmlCharacteristic(*type))); + } +} + +//----------------------------------------------------------------------------- +/** Loads a single kart and (if not disabled) the corresponding 3d model. * \param filename Full path to the kart config file. */ bool KartPropertiesManager::loadKart(const std::string &dir) { - std::string config_filename=dir+"/kart.xml"; + std::string config_filename = dir + "/kart.xml"; if(!file_manager->fileExists(config_filename)) return false; @@ -192,7 +249,7 @@ bool KartPropertiesManager::loadKart(const std::string &dir) } catch (std::runtime_error& err) { - Log::error("[Kart_Properties_Manager]","Giving up loading '%s': %s", + Log::error("[KartPropertiesManager]", "Giving up loading '%s': %s", config_filename.c_str(), err.what()); return false; } @@ -202,7 +259,7 @@ bool KartPropertiesManager::loadKart(const std::string &dir) if (kart_properties->getVersion() < stk_config->m_min_kart_version || kart_properties->getVersion() > stk_config->m_max_kart_version) { - Log::warn("[Kart_Properties_Manager]", "Warning: kart '%s' is not " + Log::warn("[KartPropertiesManager]", "Warning: kart '%s' is not " "supported by this binary, ignored.", kart_properties->getIdent().c_str()); delete kart_properties; @@ -222,7 +279,7 @@ bool KartPropertiesManager::loadKart(const std::string &dir) } m_all_kart_dirs.push_back(dir); return true; -} // loadKartData +} // loadKart //----------------------------------------------------------------------------- /** Sets the name of a mesh to use as a hat for all karts. @@ -236,6 +293,36 @@ void KartPropertiesManager::setHatMeshName(const std::string &hat_name) } } // setHatMeshName +//----------------------------------------------------------------------------- +const AbstractCharacteristic* KartPropertiesManager::getDifficultyCharacteristic(const std::string &type) const +{ + std::map >::const_iterator + it = m_difficulty_characteristics.find(type); + if (it == m_difficulty_characteristics.cend()) + return nullptr; + return &(*it->second); +} // getDifficultyCharacteristic + +//----------------------------------------------------------------------------- +const AbstractCharacteristic* KartPropertiesManager::getKartTypeCharacteristic(const std::string &type) const +{ + std::map >::const_iterator + it = m_kart_type_characteristics.find(type); + if (it == m_kart_type_characteristics.cend()) + return nullptr; + return &(*it->second); +} // getKartTypeCharacteristic + +//----------------------------------------------------------------------------- +const AbstractCharacteristic* KartPropertiesManager::getPlayerCharacteristic(const std::string &type) const +{ + std::map >::const_iterator + it = m_player_characteristics.find(type); + if (it == m_player_characteristics.cend()) + return nullptr; + return &(*it->second); +} // getPlayerCharacteristic + //----------------------------------------------------------------------------- /** Returns index of the kart properties with the given ident. * \return Index of kart (between 0 and number of karts - 1). diff --git a/src/karts/kart_properties_manager.hpp b/src/karts/kart_properties_manager.hpp index 60b8f9254..12f1fb497 100644 --- a/src/karts/kart_properties_manager.hpp +++ b/src/karts/kart_properties_manager.hpp @@ -31,6 +31,7 @@ class AbstractCharacteristic; class KartProperties; +class XMLNode; /** * \ingroup karts @@ -60,9 +61,10 @@ private: * all clients or not. */ std::vector m_kart_available; - std::unique_ptr m_base_characteristic; - std::vector > m_kart_type_characteristics; - std::vector > m_player_characteristics; + std::unique_ptr m_base_characteristic; + std::map > m_difficulty_characteristics; + std::map > m_kart_type_characteristics; + std::map > m_player_characteristics; protected: @@ -80,6 +82,7 @@ public: int getKartByGroup(const std::string& group, int i) const; + void loadCharacteristics (const XMLNode *root); bool loadKart (const std::string &dir); void loadAllKarts (bool loading_icon = true); void unloadAllKarts (); @@ -95,6 +98,18 @@ public: std::vector *ai_list); void setHatMeshName(const std::string &hat_name); // ------------------------------------------------------------------------ + /** Get the characteristic that holds the base values. */ + const AbstractCharacteristic* getBaseCharacteristic() const { return &(*m_base_characteristic); } + // ------------------------------------------------------------------------ + /** Get a characteristic that holds the values for a certain difficulty. */ + const AbstractCharacteristic* getDifficultyCharacteristic(const std::string &type) const; + // ------------------------------------------------------------------------ + /** Get a characteristic that holds the values for a kart type. */ + const AbstractCharacteristic* getKartTypeCharacteristic(const std::string &type) const; + // ------------------------------------------------------------------------ + /** Get a characteristic that holds the values for a player difficulty. */ + const AbstractCharacteristic* getPlayerCharacteristic(const std::string &type) const; + // ------------------------------------------------------------------------ /** Returns a list of all groups. */ const std::vector& getAllGroups() const {return m_all_groups;} // ------------------------------------------------------------------------ diff --git a/src/karts/player_difficulty.cpp b/src/karts/player_difficulty.cpp index d674b7e41..8a84b3eff 100644 --- a/src/karts/player_difficulty.cpp +++ b/src/karts/player_difficulty.cpp @@ -28,7 +28,8 @@ /** * The constructor initialises all values with default values. */ -PlayerDifficulty::PlayerDifficulty(const std::string &filename) +PlayerDifficulty::PlayerDifficulty(const std::string &filename) : + m_difficulty(PLAYER_DIFFICULTY_NORMAL) { // Set all other values to undefined, so that it can later be tested // if everything is defined properly. diff --git a/src/karts/player_difficulty.hpp b/src/karts/player_difficulty.hpp index 00d8b5b50..db45337d7 100644 --- a/src/karts/player_difficulty.hpp +++ b/src/karts/player_difficulty.hpp @@ -161,8 +161,10 @@ private: public: PlayerDifficulty (const std::string &filename=""); ~PlayerDifficulty (); + void setDifficulty (PerPlayerDifficulty difficulty) { m_difficulty = difficulty; } + PerPlayerDifficulty getDifficulty() const { return m_difficulty; } void getAllData (const XMLNode * root); - std::string getIdent() const; + std::string getIdent () const; float getStartupBoost () const; // ------------------------------------------------------------------------ diff --git a/src/karts/xml_characteristics.cpp b/src/karts/xml_characteristic.cpp similarity index 89% rename from src/karts/xml_characteristics.cpp rename to src/karts/xml_characteristic.cpp index fa6252236..e133e23ab 100644 --- a/src/karts/xml_characteristics.cpp +++ b/src/karts/xml_characteristic.cpp @@ -16,7 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "karts/xml_characteristics.hpp" +#include "karts/xml_characteristic.hpp" #include "utils/interpolation_array.hpp" #include "utils/log.hpp" @@ -25,18 +25,12 @@ #include "io/xml_node.hpp" XmlCharacteristic::XmlCharacteristic(const XMLNode *node) : - m_values(CHARACTERISTIC_COUNT), - m_skidding(nullptr) + m_values(CHARACTERISTIC_COUNT) { if (node) load(node); } -const SkiddingProperties* XmlCharacteristic::getSkiddingProperties() const -{ - return m_skidding; -} - void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const { switch (getType(type)) @@ -173,6 +167,10 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s void XmlCharacteristic::processFloat(const std::string &processor, float *value, bool *is_set) { + if (processor.empty()) + // That value was not changed in this configuration + return; + // Split the string by operators static const std::string operators = "*/+-"; std::vector parts; @@ -187,12 +185,6 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value, } parts.push_back(processor.substr(pos)); - if (parts.empty()) - { - Log::error("XmlCharacteristic::processFloat", "no content to process"); - return; - } - // Compute the result float x = *value; std::size_t index = 0; @@ -204,12 +196,25 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value, Log::error("XmlCharacteristic::processFloat", "x is unknown"); return; } + // - is a special case: We don't take e.g. "-5" as relative, it + // describes a negative number + else if (operations[index] == "-") + *value = 0; else - { *value = x; - index++; - } } + else + { + float val; + if (!StringUtils::fromString(parts[index], val)) + { + Log::fatal("XmlCharacteristic::processFloat", + "Can't parse %s: Not a float", parts[index].c_str()); + return; + } + *value = val; + } + index++; for (; index < parts.size(); index++) { float val; @@ -239,7 +244,7 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value, void XmlCharacteristic::load(const XMLNode *node) { // Script-generated content - if (const XMLNode *sub_node = node->getNode("Suspension")) + if (const XMLNode *sub_node = node->getNode("suspension")) { sub_node->get("stiffness", &m_values[SUSPENSION_STIFFNESS]); sub_node->get("rest", &m_values[SUSPENSION_REST]); @@ -248,7 +253,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("max-force", &m_values[SUSPENSION_MAX_FORCE]); } - if (const XMLNode *sub_node = node->getNode("Stability")) + if (const XMLNode *sub_node = node->getNode("stability")) { sub_node->get("roll-influence", &m_values[STABILITY_ROLL_INFLUENCE]); sub_node->get("chassis-linear-damping", &m_values[STABILITY_CHASSIS_LINEAR_DAMPING]); @@ -258,14 +263,14 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("smooth-flying-impulse", &m_values[STABILITY_SMOOTH_FLYING_IMPULSE]); } - if (const XMLNode *sub_node = node->getNode("Turn")) + if (const XMLNode *sub_node = node->getNode("turn")) { sub_node->get("radius", &m_values[TURN_RADIUS]); sub_node->get("time-reset-steer", &m_values[TURN_TIME_RESET_STEER]); sub_node->get("time-full-steer", &m_values[TURN_TIME_FULL_STEER]); } - if (const XMLNode *sub_node = node->getNode("Engine")) + if (const XMLNode *sub_node = node->getNode("engine")) { sub_node->get("power", &m_values[ENGINE_POWER]); sub_node->get("max-speed", &m_values[ENGINE_MAX_SPEED]); @@ -274,7 +279,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("max-speed-reverse-ratio", &m_values[ENGINE_MAX_SPEED_REVERSE_RATIO]); } - if (const XMLNode *sub_node = node->getNode("Gear")) + if (const XMLNode *sub_node = node->getNode("gear")) { sub_node->get("switch-ratio", &m_values[GEAR_SWITCH_RATIO]); sub_node->get("power-increase", &m_values[GEAR_POWER_INCREASE]); @@ -285,7 +290,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("mass", &m_values[MASS]); } - if (const XMLNode *sub_node = node->getNode("Wheels")) + if (const XMLNode *sub_node = node->getNode("wheels")) { sub_node->get("damping-relaxation", &m_values[WHEELS_DAMPING_RELAXATION]); sub_node->get("damping-compression", &m_values[WHEELS_DAMPING_COMPRESSION]); @@ -293,32 +298,32 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("position", &m_values[WHEELS_POSITION]); } - if (const XMLNode *sub_node = node->getNode("Camera")) + if (const XMLNode *sub_node = node->getNode("camera")) { sub_node->get("distance", &m_values[CAMERA_DISTANCE]); sub_node->get("forward-up-angle", &m_values[CAMERA_FORWARD_UP_ANGLE]); sub_node->get("backward-up-angle", &m_values[CAMERA_BACKWARD_UP_ANGLE]); } - if (const XMLNode *sub_node = node->getNode("Jump")) + if (const XMLNode *sub_node = node->getNode("jump")) { sub_node->get("animation-time", &m_values[JUMP_ANIMATION_TIME]); } - if (const XMLNode *sub_node = node->getNode("Lean")) + if (const XMLNode *sub_node = node->getNode("lean")) { sub_node->get("max", &m_values[LEAN_MAX]); sub_node->get("speed", &m_values[LEAN_SPEED]); } - if (const XMLNode *sub_node = node->getNode("Anvil")) + if (const XMLNode *sub_node = node->getNode("anvil")) { sub_node->get("duration", &m_values[ANVIL_DURATION]); sub_node->get("weight", &m_values[ANVIL_WEIGHT]); sub_node->get("speed-factor", &m_values[ANVIL_SPEED_FACTOR]); } - if (const XMLNode *sub_node = node->getNode("Parachute")) + if (const XMLNode *sub_node = node->getNode("parachute")) { sub_node->get("friction", &m_values[PARACHUTE_FRICTION]); sub_node->get("duration", &m_values[PARACHUTE_DURATION]); @@ -328,7 +333,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("max-speed", &m_values[PARACHUTE_MAX_SPEED]); } - if (const XMLNode *sub_node = node->getNode("Bubblegum")) + if (const XMLNode *sub_node = node->getNode("bubblegum")) { sub_node->get("duration", &m_values[BUBBLEGUM_DURATION]); sub_node->get("speed-fraction", &m_values[BUBBLEGUM_SPEED_FRACTION]); @@ -337,7 +342,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("shield-duration", &m_values[BUBBLEGUM_SHIELD_DURATION]); } - if (const XMLNode *sub_node = node->getNode("Zipper")) + if (const XMLNode *sub_node = node->getNode("zipper")) { sub_node->get("duration", &m_values[ZIPPER_DURATION]); sub_node->get("force", &m_values[ZIPPER_FORCE]); @@ -346,7 +351,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("fade-out-time", &m_values[ZIPPER_FADE_OUT_TIME]); } - if (const XMLNode *sub_node = node->getNode("Swatter")) + if (const XMLNode *sub_node = node->getNode("swatter")) { sub_node->get("duration", &m_values[SWATTER_DURATION]); sub_node->get("distance", &m_values[SWATTER_DISTANCE]); @@ -354,7 +359,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("squash-slowdown", &m_values[SWATTER_SQUASH_SLOWDOWN]); } - if (const XMLNode *sub_node = node->getNode("Plunger")) + if (const XMLNode *sub_node = node->getNode("plunger")) { sub_node->get("max-length", &m_values[PLUNGER_MAX_LENGTH]); sub_node->get("force", &m_values[PLUNGER_FORCE]); @@ -364,27 +369,27 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("in-face-time", &m_values[PLUNGER_IN_FACE_TIME]); } - if (const XMLNode *sub_node = node->getNode("Startup")) + if (const XMLNode *sub_node = node->getNode("startup")) { sub_node->get("time", &m_values[STARTUP_TIME]); sub_node->get("boost", &m_values[STARTUP_BOOST]); } - if (const XMLNode *sub_node = node->getNode("Rescue")) + if (const XMLNode *sub_node = node->getNode("rescue")) { sub_node->get("duration", &m_values[RESCUE_DURATION]); sub_node->get("vert-offset", &m_values[RESCUE_VERT_OFFSET]); sub_node->get("height", &m_values[RESCUE_HEIGHT]); } - if (const XMLNode *sub_node = node->getNode("Explosion")) + if (const XMLNode *sub_node = node->getNode("explosion")) { sub_node->get("duration", &m_values[EXPLOSION_DURATION]); sub_node->get("radius", &m_values[EXPLOSION_RADIUS]); sub_node->get("invulnerability-time", &m_values[EXPLOSION_INVULNERABILITY_TIME]); } - if (const XMLNode *sub_node = node->getNode("Nitro")) + if (const XMLNode *sub_node = node->getNode("nitro")) { sub_node->get("duration", &m_values[NITRO_DURATION]); sub_node->get("engine-force", &m_values[NITRO_ENGINE_FORCE]); @@ -396,7 +401,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("max", &m_values[NITRO_MAX]); } - if (const XMLNode *sub_node = node->getNode("Slipstream")) + if (const XMLNode *sub_node = node->getNode("slipstream")) { sub_node->get("duration", &m_values[SLIPSTREAM_DURATION]); sub_node->get("length", &m_values[SLIPSTREAM_LENGTH]); diff --git a/src/karts/xml_characteristics.hpp b/src/karts/xml_characteristic.hpp similarity index 93% rename from src/karts/xml_characteristics.hpp rename to src/karts/xml_characteristic.hpp index faa9ee270..5084e5ab0 100644 --- a/src/karts/xml_characteristics.hpp +++ b/src/karts/xml_characteristic.hpp @@ -30,12 +30,10 @@ class XmlCharacteristic : public AbstractCharacteristic private: /** The computation that was read from an xml file */ std::vector m_values; - SkiddingProperties *m_skidding; public: XmlCharacteristic(const XMLNode *node = nullptr); - virtual const SkiddingProperties* getSkiddingProperties() const; virtual void process(CharacteristicType type, Value value, bool *is_set) const; void load(const XMLNode *node); diff --git a/src/main.cpp b/src/main.cpp index 1eff57a3c..224556feb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1156,6 +1156,11 @@ void initRest() track_manager->addTrackSearchDir( file_manager->getAddonsFile("tracks/")); + { + XMLNode characteristicsNode(file_manager->getAsset("kart_characteristics.xml")); + kart_properties_manager->loadCharacteristics(&characteristicsNode); + } + track_manager->loadTrackList(); music_manager->addMusicToTracks(); diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 7e04239ca..e2ea705a9 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -199,7 +199,7 @@ def main(): elif task == "getXml": for g in groups: print(" if (const XMLNode *sub_node = node->getNode(\"{0}\"))\n {{". - format(g.baseName)) + format(g.baseName.lower())) for m in g.members: nameUnderscore = joinSubName(g, m, False) nameMinus = "-".join(toList(m.name)) From 1ceab872b1e2e493370b696838704b3bff82e69f Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sat, 11 Jul 2015 16:16:40 +0200 Subject: [PATCH 19/55] Remove PlayerDifficulty class --- src/config/stk_config.cpp | 10 - src/config/stk_config.hpp | 7 - src/graphics/slip_stream.cpp | 36 ++-- src/items/attachment.cpp | 3 +- src/items/plunger.cpp | 3 +- src/items/powerup.cpp | 3 +- src/items/rubber_band.cpp | 12 +- src/items/swatter.cpp | 3 +- src/karts/abstract_kart.cpp | 5 +- src/karts/abstract_kart.hpp | 9 +- src/karts/explosion_animation.cpp | 6 +- src/karts/ghost_kart.cpp | 3 +- src/karts/kart.cpp | 94 +++----- src/karts/kart.hpp | 3 +- src/karts/kart_gfx.cpp | 3 +- src/karts/kart_properties.cpp | 11 + src/karts/kart_properties.hpp | 3 + src/karts/kart_with_stats.cpp | 2 +- src/karts/kart_with_stats.hpp | 2 +- src/karts/max_speed.cpp | 6 +- src/karts/player_difficulty.cpp | 200 ----------------- src/karts/player_difficulty.hpp | 347 ------------------------------ src/karts/rescue_animation.cpp | 3 +- src/modes/profile_world.cpp | 2 +- src/modes/profile_world.hpp | 2 +- src/modes/soccer_world.cpp | 2 +- src/modes/soccer_world.hpp | 2 +- src/modes/world.cpp | 6 +- src/modes/world.hpp | 2 +- src/physics/physics.cpp | 8 +- 30 files changed, 95 insertions(+), 703 deletions(-) delete mode 100644 src/karts/player_difficulty.cpp delete mode 100644 src/karts/player_difficulty.hpp diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index fca3157de..85e6632f0 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -27,7 +27,6 @@ #include "io/xml_node.hpp" #include "items/item.hpp" #include "karts/kart_properties.hpp" -#include "karts/player_difficulty.hpp" #include "utils/log.hpp" STKConfig* stk_config=0; @@ -396,15 +395,6 @@ void STKConfig::getAllData(const XMLNode * root) m_kart_properties[type->getName()]->copyFrom(m_default_kart_properties); m_kart_properties[type->getName()]->getAllData(type); } - - child_node = node->getNode("difficulties"); - for (unsigned int i = 0; i < child_node->getNumNodes(); ++i) - { - const XMLNode* type = child_node->getNode(i); - m_player_difficulties[i] = new PlayerDifficulty(); - m_player_difficulties[i]->getAllData(type); - m_player_difficulties[i]->setDifficulty((PerPlayerDifficulty) i); - } } // getAllData // ---------------------------------------------------------------------------- diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index f4a5e9514..272c1f39a 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -34,7 +34,6 @@ #include class KartProperties; -class PlayerDifficulty; class MusicInformation; class XMLNode; @@ -51,8 +50,6 @@ protected: /** Default kart properties. */ KartProperties *m_default_kart_properties; std::map m_kart_properties; - /** Per-player difficulties. */ - PlayerDifficulty* m_player_difficulties[PLAYER_DIFFICULTY_COUNT]; public: /** What to do if a kart already has a powerup when it hits a bonus box: @@ -187,10 +184,6 @@ public: { return *m_kart_properties.at(type); } // getKartProperties - - // ------------------------------------------------------------------------ - const PlayerDifficulty * getPlayerDifficulty(PerPlayerDifficulty difficulty) - { return m_player_difficulties[difficulty]; } } ; // STKConfig diff --git a/src/graphics/slip_stream.cpp b/src/graphics/slip_stream.cpp index 1cb52b9da..1062e72bb 100644 --- a/src/graphics/slip_stream.cpp +++ b/src/graphics/slip_stream.cpp @@ -67,11 +67,9 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart) setTextureMatrix(&(m_node->getMaterial(0).getTextureMatrix(0))); m_slipstream_time = 0.0f; - float length = m_kart->getKartProperties()->getSlipstreamLength() * - m_kart->getPlayerDifficulty()->getSlipstreamLength(); + float length = m_kart->getKartProperties()->getSlipstreamLength(); float kw = m_kart->getKartWidth(); - float ew = m_kart->getKartProperties()->getSlipstreamWidth() * - m_kart->getPlayerDifficulty()->getSlipstreamWidth(); + float ew = m_kart->getKartProperties()->getSlipstreamWidth(); float kl = m_kart->getKartLength(); Vec3 p[4]; @@ -314,8 +312,7 @@ void SlipStream::setIntensity(float f, const AbstractKart *kart) bool SlipStream::isSlipstreamReady() const { return m_slipstream_time> - m_kart->getKartProperties()->getSlipstreamCollectTime() * - m_kart->getPlayerDifficulty()->getSlipstreamCollectTime(); + m_kart->getKartProperties()->getSlipstreamCollectTime(); } // isSlipstreamReady //----------------------------------------------------------------------------- @@ -331,14 +328,10 @@ void SlipStream::updateSlipstreamPower() setIntensity(2.0f, NULL); const KartProperties *kp=m_kart->getKartProperties(); m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, - kp->getSlipstreamMaxSpeedIncrease() * - m_kart->getPlayerDifficulty()->getSlipstreamMaxSpeedIncrease(), - kp->getSlipstreamAddPower() * - m_kart->getPlayerDifficulty()->getSlipstreamAddPower(), - kp->getSlipstreamDuration() * - m_kart->getPlayerDifficulty()->getSlipstreamDuration(), - kp->getSlipstreamFadeOutTime() * - m_kart->getPlayerDifficulty()->getSlipstreamFadeOutTime()); + kp->getSlipstreamMaxSpeedIncrease(), + kp->getSlipstreamAddPower(), + kp->getSlipstreamDuration(), + kp->getSlipstreamFadeOutTime()); } } // upateSlipstreamPower @@ -394,8 +387,7 @@ void SlipStream::update(float dt) // not moving. This is useful for debugging the graphics of SS-ing. //#define DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING - if(m_kart->getSpeed()getKartProperties()->getSlipstreamMinSpeed() * - m_kart->getPlayerDifficulty()->getSlipstreamMinSpeed()) + if(m_kart->getSpeed()getKartProperties()->getSlipstreamMinSpeed()) { setIntensity(0, NULL); m_slipstream_mode = SS_NONE; @@ -437,8 +429,7 @@ void SlipStream::update(float dt) // give karts different slipstream properties. #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING if(m_target_kart->getSpeed() < - m_kart->getKartProperties()->getSlipstreamMinSpeed() * - m_kart->getPlayerDifficulty()->getSlipstreamMinSpeed()) + m_kart->getKartProperties()->getSlipstreamMinSpeed()) { if(UserConfigParams::m_slipstream_debug && m_kart->getController()->isPlayerController()) @@ -452,8 +443,7 @@ void SlipStream::update(float dt) // slipstream length+0.5*kart_length()+0.5*target_kart_length // away from the other kart Vec3 delta = m_kart->getXYZ() - m_target_kart->getXYZ(); - float l = m_kart->getKartProperties()->getSlipstreamLength() * - m_kart->getPlayerDifficulty()->getSlipstreamLength() + float l = m_kart->getKartProperties()->getSlipstreamLength() + 0.5f*( m_target_kart->getKartLength() +m_kart->getKartLength() ); if(delta.length2_2d() > l*l) @@ -494,8 +484,7 @@ void SlipStream::update(float dt) m_slipstream_mode = SS_USE; m_kart->handleZipper(); m_slipstream_time = - m_kart->getKartProperties()->getSlipstreamCollectTime() * - m_kart->getPlayerDifficulty()->getSlipstreamCollectTime(); + m_kart->getKartProperties()->getSlipstreamCollectTime(); return; } } @@ -516,8 +505,7 @@ void SlipStream::update(float dt) setIntensity(m_slipstream_time, m_target_kart); m_slipstream_mode = SS_COLLECT; - if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime() * - m_kart->getPlayerDifficulty()->getSlipstreamCollectTime()) + if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime()) { setIntensity(1.0f, m_target_kart); } diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index b1eb41199..0d355e9a5 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -266,8 +266,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) // same banana again once the explosion animation is finished, giving // the kart the same penalty twice. float f = std::max(item->getDisableTime(), - m_kart->getKartProperties()->getExplosionTime() * - m_kart->getPlayerDifficulty()->getExplosionTime() + 2.0f); + m_kart->getKartProperties()->getExplosionTime() + 2.0f); item->setDisableTime(f); break; } diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 778edc473..da47d0701 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -178,8 +178,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj) } else { - m_keep_alive = m_owner->getKartProperties()->getRubberBandDuration() * - m_owner->getPlayerDifficulty()->getRubberBandDuration(); + m_keep_alive = m_owner->getKartProperties()->getRubberBandDuration(); // Make this object invisible by placing it faaar down. Not that if this // objects is simply removed from the scene graph, it might be auto-deleted diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index b354b7aff..aa39b5553 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -222,8 +222,7 @@ void Powerup::use() case PowerupManager::POWERUP_SWATTER: m_owner->getAttachment() ->set(Attachment::ATTACH_SWATTER, - m_owner->getKartProperties()->getSwatterDuration() * - m_owner->getPlayerDifficulty()->getSwatterDuration()); + m_owner->getKartProperties()->getSwatterDuration()); break; case PowerupManager::POWERUP_BUBBLEGUM: diff --git a/src/items/rubber_band.cpp b/src/items/rubber_band.cpp index 0c000012b..f276d4c46 100644 --- a/src/items/rubber_band.cpp +++ b/src/items/rubber_band.cpp @@ -149,8 +149,7 @@ void RubberBand::update(float dt) // Check for rubber band snapping // ------------------------------ float l = (m_end_position-k).length2(); - float max_len = m_owner->getKartProperties()->getRubberBandMaxLength() * - m_owner->getPlayerDifficulty()->getRubberBandMaxLength(); + float max_len = m_owner->getKartProperties()->getRubberBandMaxLength(); if(l>max_len*max_len) { // Rubber band snaps @@ -163,8 +162,7 @@ void RubberBand::update(float dt) // ---------------------------- if(m_attached_state!=RB_TO_PLUNGER) { - float force = m_owner->getKartProperties()->getRubberBandForce() * - m_owner->getPlayerDifficulty()->getRubberBandForce(); + float force = m_owner->getKartProperties()->getRubberBandForce(); Vec3 diff = m_end_position-k; // detach rubber band if kart gets very close to hit point @@ -180,12 +178,10 @@ void RubberBand::update(float dt) diff.normalize(); // diff can't be zero here m_owner->getBody()->applyCentralForce(diff*force); m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER, - m_owner->getKartProperties()->getRubberBandSpeedIncrease() * - m_owner->getPlayerDifficulty()->getRubberBandSpeedIncrease(), + m_owner->getKartProperties()->getRubberBandSpeedIncrease(), /*engine_force*/ 0.0f, /*duration*/0.1f, - m_owner->getKartProperties()->getRubberBandFadeOutTime() * - m_owner->getPlayerDifficulty()->getRubberBandFadeOutTime()); + m_owner->getKartProperties()->getRubberBandFadeOutTime()); if(m_attached_state==RB_TO_KART) m_hit_kart->getBody()->applyCentralForce(diff*(-force)); } diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index 326b47cbd..7cad9953d 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -293,8 +293,7 @@ void Swatter::squashThingsAround() if(dist2 >= min_dist2) continue; // too far away, ignore this kart - kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(), - kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown()); + kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown()); //Handle achievement if the swatter is used by the current player const StateManager::ActivePlayer *const ap = m_kart->getController() diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index d636ad293..4e803c00e 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -36,7 +36,7 @@ AbstractKart::AbstractKart(const std::string& ident, int world_kart_id, int position, const btTransform& init_transform, - const PlayerDifficulty *difficulty) + PerPlayerDifficulty difficulty) : Moveable() { m_world_kart_id = world_kart_id; @@ -69,7 +69,8 @@ AbstractKart::AbstractKart(const std::string& ident, m_characteristic->addCharacteristic(kart_properties_manager-> getKartTypeCharacteristic(m_kart_properties->getKartType())); m_characteristic->addCharacteristic(kart_properties_manager-> - getPlayerCharacteristic(m_difficulty->getIdent())); + getPlayerCharacteristic(KartProperties::getPerPlayerDifficultyAsString( + m_difficulty))); m_characteristic->addCharacteristic(m_kart_properties->getCharacteristic()); } // AbstractKart diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index ec58dbbd8..780b739a4 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -24,7 +24,6 @@ #include "items/powerup_manager.hpp" #include "karts/moveable.hpp" #include "karts/controller/kart_control.hpp" -#include "karts/player_difficulty.hpp" #include "race/race_manager.hpp" namespace irr @@ -77,7 +76,7 @@ protected: const KartProperties *m_kart_properties; /** The per-player difficulty. */ - const PlayerDifficulty *m_difficulty; + PerPlayerDifficulty m_difficulty; /** The combined properties of the kart, the player, etc. */ std::unique_ptr m_characteristic; @@ -101,7 +100,7 @@ public: AbstractKart(const std::string& ident, int world_kart_id, int position, const btTransform& init_transform, - const PlayerDifficulty *difficulty); + PerPlayerDifficulty difficulty); virtual ~AbstractKart(); virtual core::stringw getName() const; virtual void reset(); @@ -138,11 +137,11 @@ public: // Access to the per-player difficulty. // ------------------------------------------------------------------------ /** Returns the per-player difficulty of this kart. */ - const PlayerDifficulty* getPlayerDifficulty() const + const PerPlayerDifficulty getPerPlayerDifficulty() const { return m_difficulty; } // ------------------------------------------------------------------------ /** Sets the per-player difficulty. */ - void setPlayerDifficulty(const PlayerDifficulty *pd) { m_difficulty=pd; } + void setPerPlayerDifficulty(const PerPlayerDifficulty d) { m_difficulty=d; } // ------------------------------------------------------------------------ /** Returns a unique identifier for this kart (name of the directory the diff --git a/src/karts/explosion_animation.cpp b/src/karts/explosion_animation.cpp index 81799dd8d..78963f30a 100644 --- a/src/karts/explosion_animation.cpp +++ b/src/karts/explosion_animation.cpp @@ -78,8 +78,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart, m_xyz = m_kart->getXYZ(); m_orig_y = m_xyz.getY(); m_kart->playCustomSFX(SFXManager::CUSTOM_EXPLODE); - m_timer = m_kart->getKartProperties()->getExplosionTime() * - m_kart->getPlayerDifficulty()->getExplosionTime(); + m_timer = m_kart->getKartProperties()->getExplosionTime(); // Non-direct hits will be only affected half as much. if(!direct_hit) m_timer*=0.5f; @@ -106,8 +105,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart, m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f ); // Set invulnerable time, and graphical effects - float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime() * - m_kart->getPlayerDifficulty()->getExplosionInvulnerabilityTime(); + float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime(); m_kart->setInvulnerableTime(t); if ( UserConfigParams::m_graphical_effects ) { diff --git a/src/karts/ghost_kart.cpp b/src/karts/ghost_kart.cpp index 099116399..885e3dd73 100644 --- a/src/karts/ghost_kart.cpp +++ b/src/karts/ghost_kart.cpp @@ -24,8 +24,7 @@ GhostKart::GhostKart(const std::string& ident) : Kart(ident, /*world kart id*/99999, - /*position*/-1, btTransform(), stk_config->getPlayerDifficulty( - PLAYER_DIFFICULTY_NORMAL)) + /*position*/-1, btTransform(), PLAYER_DIFFICULTY_NORMAL) { m_current_transform = 0; m_next_event = 0; diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index f7f18e9bd..4cd7ba076 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -95,7 +95,7 @@ */ Kart::Kart (const std::string& ident, unsigned int world_kart_id, int position, const btTransform& init_transform, - const PlayerDifficulty *difficulty) + PerPlayerDifficulty difficulty) : AbstractKart(ident, world_kart_id, position, init_transform, difficulty) @@ -537,8 +537,7 @@ void Kart::blockViewWithPlunger() { // Avoid that a plunger extends the plunger time if(m_view_blocked_by_plunger<=0 && !isShielded()) - m_view_blocked_by_plunger = - m_kart_properties->getPlungerInFaceTime() * m_difficulty->getPlungerInFaceTime(); + m_view_blocked_by_plunger = m_kart_properties->getPlungerInFaceTime(); if(isShielded()) { decreaseShieldTime(); @@ -923,16 +922,13 @@ void Kart::collectedItem(Item *item, int add_info) item->getEmitter()->getIdent() == "nolok"); // slow down - m_bubblegum_time = m_kart_properties->getBubblegumTime() * m_difficulty->getBubblegumTime(); + m_bubblegum_time = m_kart_properties->getBubblegumTime(); m_bubblegum_torque = ((rand()%2) ? m_kart_properties->getBubblegumTorque() - : -m_kart_properties->getBubblegumTorque()) * - m_difficulty->getBubblegumTorque(); + : -m_kart_properties->getBubblegumTorque()); m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE, - m_kart_properties->getBubblegumSpeedFraction() * - m_difficulty->getBubblegumSpeedFraction(), - m_kart_properties->getBubblegumFadeInTime() * - m_difficulty->getBubblegumFadeInTime(), + m_kart_properties->getBubblegumSpeedFraction() , + m_kart_properties->getBubblegumFadeInTime(), m_bubblegum_time); m_goo_sound->setPosition(getXYZ()); m_goo_sound->play(); @@ -959,21 +955,17 @@ float Kart::getActualWheelForce() const std::vector& gear_ratio=m_kart_properties->getGearSwitchRatio(); for(unsigned int i=0; igetMaxSpeed() * - m_difficulty->getMaxSpeed() * gear_ratio[i]) + if(m_speed <= m_kart_properties->getMaxSpeed() * gear_ratio[i]) { - assert(!isnan(m_kart_properties->getMaxPower() * - m_difficulty->getMaxPower())); + assert(!isnan(m_kart_properties->getMaxPower())); assert(!isnan(m_kart_properties->getGearPowerIncrease()[i])); - return m_kart_properties->getMaxPower() * - m_difficulty->getMaxPower() - *m_kart_properties->getGearPowerIncrease()[i] - +add_force; + return m_kart_properties->getMaxPower() + * m_kart_properties->getGearPowerIncrease()[i] + + add_force; } } - assert(!isnan(m_kart_properties->getMaxPower() * m_difficulty->getMaxPower())); - return m_kart_properties->getMaxPower() * m_difficulty->getMaxPower() - +add_force * 2; + assert(!isnan(m_kart_properties->getMaxPower())); + return m_kart_properties->getMaxPower() + add_force * 2; } // getActualWheelForce @@ -1677,33 +1669,23 @@ void Kart::handleZipper(const Material *material, bool play_sound) material->getZipperParameter(&max_speed_increase, &duration, &speed_gain, &fade_out_time, &engine_force); if(max_speed_increase<0) - max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease() * - m_difficulty->getZipperMaxSpeedIncrease(); + max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease(); if(duration<0) - duration = m_kart_properties->getZipperTime() * - m_difficulty->getZipperTime(); + duration = m_kart_properties->getZipperTime(); if(speed_gain<0) - speed_gain = m_kart_properties->getZipperSpeedGain() * - m_difficulty->getZipperSpeedGain(); + speed_gain = m_kart_properties->getZipperSpeedGain(); if(fade_out_time<0) - fade_out_time = m_kart_properties->getZipperFadeOutTime() * - m_difficulty->getZipperFadeOutTime(); + fade_out_time = m_kart_properties->getZipperFadeOutTime(); if(engine_force<0) - engine_force = m_kart_properties->getZipperForce() * - m_difficulty->getZipperForce(); + engine_force = m_kart_properties->getZipperForce(); } else { - max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease() * - m_difficulty->getZipperMaxSpeedIncrease(); - duration = m_kart_properties->getZipperTime() * - m_difficulty->getZipperTime(); - speed_gain = m_kart_properties->getZipperSpeedGain() * - m_difficulty->getZipperSpeedGain(); - fade_out_time = m_kart_properties->getZipperFadeOutTime() * - m_difficulty->getZipperFadeOutTime(); - engine_force = m_kart_properties->getZipperForce() * - m_difficulty->getZipperForce(); + max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease(); + duration = m_kart_properties->getZipperTime(); + speed_gain = m_kart_properties->getZipperSpeedGain(); + fade_out_time = m_kart_properties->getZipperFadeOutTime(); + engine_force = m_kart_properties->getZipperForce(); } // Ignore a zipper that's activated while braking if(m_controls.m_brake || m_speed<0) return; @@ -1741,8 +1723,7 @@ void Kart::updateNitro(float dt) { return; } - m_collected_energy -= dt * m_kart_properties->getNitroConsumption() * - m_difficulty->getNitroConsumption(); + m_collected_energy -= dt * m_kart_properties->getNitroConsumption(); if (m_collected_energy < 0) { m_collected_energy = 0; @@ -1752,13 +1733,10 @@ void Kart::updateNitro(float dt) if (increase_speed) { m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO, - m_kart_properties->getNitroMaxSpeedIncrease() * - m_difficulty->getNitroMaxSpeedIncrease(), + m_kart_properties->getNitroMaxSpeedIncrease(), getCharacteristic()->getNitroEngineForce(), - m_kart_properties->getNitroDuration() * - m_difficulty->getNitroDuration(), - m_kart_properties->getNitroFadeOutTime() * - m_difficulty->getNitroFadeOutTime()); + m_kart_properties->getNitroDuration(), + m_kart_properties->getNitroFadeOutTime()); } } // updateNitro @@ -2063,8 +2041,7 @@ void Kart::updatePhysics(float dt) if(!m_has_started && m_controls.m_accel) { m_has_started = true; - float f = m_kart_properties->getStartupBoost() * - m_difficulty->getStartupBoost(); + float f = m_kart_properties->getStartupBoost(); m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER, 0.9f*f, f, /*engine_force*/200.0f, @@ -2262,10 +2239,8 @@ void Kart::updateEnginePowerAndBrakes(float dt) m_brake_time += dt; // Apply the brakes - include the time dependent brake increase float f = 1 + m_brake_time - * m_kart_properties->getBrakeTimeIncrease() * - m_difficulty->getBrakeTimeIncrease(); - m_vehicle->setAllBrakes(m_kart_properties->getBrakeFactor() * - m_difficulty->getBrakeFactor() * f); + * m_kart_properties->getBrakeTimeIncrease(); + m_vehicle->setAllBrakes(m_kart_properties->getBrakeFactor() * f); } else // m_speed < 0 { @@ -2273,8 +2248,7 @@ void Kart::updateEnginePowerAndBrakes(float dt) // going backward, apply reverse gear ratio (unless he goes // too fast backwards) if ( -m_speed < m_max_speed->getCurrentMaxSpeed() - *m_kart_properties->getMaxSpeedReverseRatio() * - m_difficulty->getMaxSpeedReverseRatio()) + *m_kart_properties->getMaxSpeedReverseRatio()) { // The backwards acceleration is artificially increased to // allow players to get "unstuck" quicker if they hit e.g. @@ -2535,8 +2509,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, { // fabs(speed) is important, otherwise the negative number will // become a huge unsigned number in the particle scene node! - nitro_frac = fabsf(getSpeed())/(m_kart_properties->getMaxSpeed() * - m_difficulty->getMaxSpeed() ); + nitro_frac = fabsf(getSpeed())/(m_kart_properties->getMaxSpeed()); // The speed of the kart can be higher (due to powerups) than // the normal maximum speed of the kart. if(nitro_frac>1.0f) nitro_frac = 1.0f; @@ -2551,8 +2524,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, // leaning might get less if a kart gets a special that increases // its maximum speed, but not the current speed (by much). On the // other hand, that ratio can often be greater than 1. - float speed_frac = m_speed / m_kart_properties->getMaxSpeed() * - m_difficulty->getMaxSpeed(); + float speed_frac = m_speed / m_kart_properties->getMaxSpeed(); if(speed_frac>1.0f) speed_frac = 1.0f; else if (speed_frac < 0.0f) // no leaning when backwards driving diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 4411e618e..a08046595 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -31,7 +31,6 @@ #include "items/powerup.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" -#include "karts/player_difficulty.hpp" #include "tracks/terrain_info.hpp" #include "utils/no_copy.hpp" @@ -237,7 +236,7 @@ private: public: Kart(const std::string& ident, unsigned int world_kart_id, int position, const btTransform& init_transform, - const PlayerDifficulty *difficulty); + PerPlayerDifficulty difficulty); virtual ~Kart(); virtual void init(RaceManager::KartType type); virtual void kartIsInRestNow(); diff --git a/src/karts/kart_gfx.cpp b/src/karts/kart_gfx.cpp index ae62b1073..2bbe6b134 100644 --- a/src/karts/kart_gfx.cpp +++ b/src/karts/kart_gfx.cpp @@ -321,8 +321,7 @@ void KartGFX::updateTerrain(const ParticleKind *pk) if (skidding > 1.0f && on_ground) rate = fabsf(m_kart->getControls().m_steer) > 0.8 ? skidding - 1 : 0; else if (speed >= 0.5f && on_ground) - rate = speed/m_kart->getKartProperties()->getMaxSpeed() * - m_kart->getPlayerDifficulty()->getMaxSpeed(); + rate = speed/m_kart->getKartProperties()->getMaxSpeed(); else { pe->setCreationRateAbsolute(0); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index a04e74007..017200979 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -45,6 +45,17 @@ float KartProperties::UNDEFINED = -99.9f; +std::string KartProperties::getPerPlayerDifficultyAsString(PerPlayerDifficulty d) +{ + switch(d) + { + case PLAYER_DIFFICULTY_NORMAL: return "normal"; break; + case PLAYER_DIFFICULTY_HANDICAP: return "handicap"; break; + default: assert(false); + } + return ""; +} + /** The constructor initialises all values with invalid values. It can later * then be checked (for STKConfig) that all values are indeed defined. * Otherwise the defaults are taken from STKConfig (and since they are all diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index 062738307..c7aec3bb6 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -412,6 +412,9 @@ private: public: + /** Returns the string representation of a per-player difficulty. */ + static std::string getPerPlayerDifficultyAsString(PerPlayerDifficulty d); + KartProperties (const std::string &filename=""); ~KartProperties (); void copyFrom (const KartProperties *source); diff --git a/src/karts/kart_with_stats.cpp b/src/karts/kart_with_stats.cpp index 22f9a39b4..15851c9b7 100644 --- a/src/karts/kart_with_stats.cpp +++ b/src/karts/kart_with_stats.cpp @@ -26,7 +26,7 @@ KartWithStats::KartWithStats(const std::string& ident, unsigned int world_kart_id, int position, const btTransform& init_transform, - const PlayerDifficulty *difficulty) + PerPlayerDifficulty difficulty) : Kart(ident, world_kart_id, position, init_transform, difficulty) { diff --git a/src/karts/kart_with_stats.hpp b/src/karts/kart_with_stats.hpp index a85870a84..906d174a6 100644 --- a/src/karts/kart_with_stats.hpp +++ b/src/karts/kart_with_stats.hpp @@ -75,7 +75,7 @@ public: unsigned int world_kart_id, int position, const btTransform& init_transform, - const PlayerDifficulty *difficulty); + PerPlayerDifficulty difficulty); virtual void update(float dt); virtual void reset(); virtual void collectedItem(Item *item, int add_info); diff --git a/src/karts/max_speed.cpp b/src/karts/max_speed.cpp index c044f77d4..df105360f 100644 --- a/src/karts/max_speed.cpp +++ b/src/karts/max_speed.cpp @@ -62,8 +62,7 @@ MaxSpeed::MaxSpeed(AbstractKart *kart) */ void MaxSpeed::reset() { - m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed() * - m_kart->getPlayerDifficulty()->getMaxSpeed(); + m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed(); m_min_speed = -1.0f; for(unsigned int i=MS_DECREASE_MIN; igetKartProperties()->getMaxSpeed() * - m_kart->getPlayerDifficulty()->getMaxSpeed(); + m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed(); // Then add the speed increase from each category // ---------------------------------------------- diff --git a/src/karts/player_difficulty.cpp b/src/karts/player_difficulty.cpp deleted file mode 100644 index 8a84b3eff..000000000 --- a/src/karts/player_difficulty.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2006-2015 SuperTuxKart-Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "karts/player_difficulty.hpp" - -#include "config/stk_config.hpp" -#include "io/xml_node.hpp" -#include "karts/skidding_properties.hpp" -#include "race/race_manager.hpp" -#include "modes/world.hpp" -#include "utils/log.hpp" - -/** - * The constructor initialises all values with default values. - */ -PlayerDifficulty::PlayerDifficulty(const std::string &filename) : - m_difficulty(PLAYER_DIFFICULTY_NORMAL) -{ - // Set all other values to undefined, so that it can later be tested - // if everything is defined properly. - m_mass = m_brake_factor = m_brake_time_increase = m_rescue_time = - m_explosion_time = m_explosion_invulnerability_time = m_zipper_time = - m_zipper_fade_out_time = m_zipper_force = m_zipper_speed_gain = - m_zipper_max_speed_increase = m_rubber_band_max_length = - m_rubber_band_force = m_rubber_band_duration = - m_rubber_band_speed_increase = m_rubber_band_fade_out_time = - m_nitro_consumption = m_nitro_max_speed_increase = - m_nitro_engine_force = m_nitro_duration = m_nitro_fade_out_time = - m_bubblegum_time = m_bubblegum_torque = m_bubblegum_speed_fraction = - m_bubblegum_fade_in_time = m_swatter_duration = m_squash_duration = - m_squash_slowdown = m_max_speed_reverse_ratio = m_slipstream_length = - m_slipstream_width = m_slipstream_collect_time = - m_slipstream_use_time = m_slipstream_add_power = - m_slipstream_min_speed = m_slipstream_max_speed_increase = - m_slipstream_duration = m_slipstream_fade_out_time = 1; - - m_startup_times.resize(RaceManager::DIFFICULTY_COUNT, 1); - m_startup_boost.resize(RaceManager::DIFFICULTY_COUNT, 1); - - // The default constructor for stk_config uses filename="" - if (filename != "") - load(filename, "normal"); -} // PlayerDifficulty - -//----------------------------------------------------------------------------- -/** Destructor, dereferences the kart model. */ -PlayerDifficulty::~PlayerDifficulty() -{ -} // ~PlayerDifficulty - -//----------------------------------------------------------------------------- -/** */ -std::string PlayerDifficulty::getIdent() const -{ - switch(m_difficulty) - { - case PLAYER_DIFFICULTY_NORMAL: return "normal"; break; - case PLAYER_DIFFICULTY_HANDICAP: return "handicap"; break; - default: assert(false); - } - return ""; -} - -//----------------------------------------------------------------------------- -/** Loads the difficulty properties from a file. - * \param filename Filename to load. - * \param node Name of the xml node to load the data from - */ -void PlayerDifficulty::load(const std::string &filename, const std::string &node) -{ - const XMLNode* root = new XMLNode(filename); - getAllData(root->getNode(node)); - if(root) - delete root; -} // load - -//----------------------------------------------------------------------------- -/** Actually reads in the data from the xml file. - * \param root Root of the xml tree. - */ -void PlayerDifficulty::getAllData(const XMLNode * root) -{ - if(const XMLNode *mass_node = root->getNode("mass")) - mass_node->get("value", &m_mass); - - if(const XMLNode *engine_node = root->getNode("engine")) - { - engine_node->get("brake-factor", &m_brake_factor); - engine_node->get("brake-time-increase", &m_brake_time_increase); - engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio); - engine_node->get("power", &m_engine_power); - engine_node->get("max-speed", &m_max_speed); - } - - if(const XMLNode *nitro_node = root->getNode("nitro")) - { - nitro_node->get("consumption", &m_nitro_consumption ); - nitro_node->get("max-speed-increase", &m_nitro_max_speed_increase); - nitro_node->get("engine-force", &m_nitro_engine_force ); - nitro_node->get("duration", &m_nitro_duration ); - nitro_node->get("fade-out-time", &m_nitro_fade_out_time ); - } - - if(const XMLNode *bubble_node = root->getNode("bubblegum")) - { - bubble_node->get("time", &m_bubblegum_time ); - bubble_node->get("speed-fraction", &m_bubblegum_speed_fraction); - bubble_node->get("torque", &m_bubblegum_torque ); - bubble_node->get("fade-in-time", &m_bubblegum_fade_in_time ); - } - - if(const XMLNode *rescue_node = root->getNode("rescue")) - rescue_node->get("time", &m_rescue_time); - - if(const XMLNode *explosion_node = root->getNode("explosion")) - { - explosion_node->get("time", &m_explosion_time); - explosion_node->get("invulnerability-time", - &m_explosion_invulnerability_time); - } - - if(const XMLNode *slipstream_node = root->getNode("slipstream")) - { - slipstream_node->get("length", &m_slipstream_length ); - slipstream_node->get("width", &m_slipstream_width ); - slipstream_node->get("collect-time", &m_slipstream_collect_time ); - slipstream_node->get("use-time", &m_slipstream_use_time ); - slipstream_node->get("add-power", &m_slipstream_add_power ); - slipstream_node->get("min-speed", &m_slipstream_min_speed ); - slipstream_node->get("max-speed-increase", - &m_slipstream_max_speed_increase); - slipstream_node->get("duration", &m_slipstream_duration ); - slipstream_node->get("fade-out-time", &m_slipstream_fade_out_time ); - } - - if(const XMLNode *plunger_node= root->getNode("plunger")) - { - plunger_node->get("band-max-length", &m_rubber_band_max_length ); - plunger_node->get("band-force", &m_rubber_band_force ); - plunger_node->get("band-duration", &m_rubber_band_duration ); - plunger_node->get("band-speed-increase",&m_rubber_band_speed_increase); - plunger_node->get("band-fade-out-time", &m_rubber_band_fade_out_time ); - plunger_node->get("in-face-time", &m_plunger_in_face_duration); - } - - if(const XMLNode *zipper_node= root->getNode("zipper")) - { - zipper_node->get("time", &m_zipper_time ); - zipper_node->get("fade-out-time", &m_zipper_fade_out_time ); - zipper_node->get("force", &m_zipper_force ); - zipper_node->get("speed-gain", &m_zipper_speed_gain ); - zipper_node->get("max-speed-increase", &m_zipper_max_speed_increase); - } - - if(const XMLNode *swatter_node= root->getNode("swatter")) - { - swatter_node->get("duration", &m_swatter_duration ); - swatter_node->get("squash-duration", &m_squash_duration ); - swatter_node->get("squash-slowdown", &m_squash_slowdown ); - } - - if(const XMLNode *startup_node= root->getNode("startup")) - { - startup_node->get("time", &m_startup_times); - startup_node->get("boost", &m_startup_boost); - } -} // getAllData - -// ---------------------------------------------------------------------------- -/** Called the first time a kart accelerates after 'ready-set-go'. It searches - * through m_startup_times to find the appropriate slot, and returns the - * speed-boost from the corresponding entry in m_startup_boost. - * If the kart started too slow (i.e. slower than the longest time in - * m_startup_times, it returns 0. - */ -float PlayerDifficulty::getStartupBoost() const -{ - float t = World::getWorld()->getTime(); - for(unsigned int i=0; i -#include - - -class XMLNode; - -/** - * \brief This class stores values that modify the properties of a kart. - * This includes physical properties like speed and the effect of items. - * The values stored in this class get multiplied with the current - * properties of the kart. If all values here are set to 1, nothing changes. - * - * \ingroup karts - */ -class PlayerDifficulty -{ -private: - /** Actual difficulty */ - PerPlayerDifficulty m_difficulty; - - // ----------------- - /** Weight of kart. */ - float m_mass; - - /** Maximum force from engine for each difficulty. */ - float m_engine_power; - - /** Braking factor * engine_power braking force. */ - float m_brake_factor; - - /** Brake_time * m_brake_time_increase will increase the break time - * over time. */ - float m_brake_time_increase; - - /** Time a kart is moved upwards after when it is rescued. */ - float m_rescue_time; - - /** Time an animated explosion is shown. Longer = more delay for kart. */ - float m_explosion_time; - - /** How long a kart is invulnerable after it is hit by an explosion. */ - float m_explosion_invulnerability_time; - - /** Duration a zipper is active. */ - float m_zipper_time; - - /** Fade out time for a zipper. */ - float m_zipper_fade_out_time; - - /** Additional force added to the acceleration. */ - float m_zipper_force; - - /** Initial one time speed gain. */ - float m_zipper_speed_gain; - - /** Absolute increase of the kart's maximum speed (in m/s). */ - float m_zipper_max_speed_increase; - - /** Max. length of plunger rubber band. */ - float m_rubber_band_max_length; - /** Force of an attached rubber band. */ - /** Duration a rubber band works. */ - float m_rubber_band_force; - /** How long the rubber band will fly. */ - float m_rubber_band_duration; - /** Increase of maximum speed of the kart when the rubber band pulls. */ - float m_rubber_band_speed_increase; - /** Fade out time when the rubber band is removed. */ - float m_rubber_band_fade_out_time; - /**Duration of plunger in face depending on difficulty. */ - float m_plunger_in_face_duration; - /** Nitro consumption. */ - float m_nitro_consumption; - /* How much the speed of a kart might exceed its maximum speed (in m/s). */ - float m_nitro_max_speed_increase; - /** Additional engine force to affect the kart. */ - float m_nitro_engine_force; - /** How long the increased nitro max speed will be valid after - * the kart stops using nitro (and the fade-out-time starts). */ - float m_nitro_duration; - /** Duration during which the increased maximum speed - * due to nitro fades out. */ - float m_nitro_fade_out_time; - /** Bubble gum diration. */ - float m_bubblegum_time; - /** Torque to add when a bubble gum was hit in order to make the kart go - * sideways a bit. */ - float m_bubblegum_torque; - /** Fraction of top speed that can be reached maximum after hitting a - * bubble gum. */ - float m_bubblegum_speed_fraction; - /** How long to fade in the slowdown for a bubble gum. */ - float m_bubblegum_fade_in_time; - /** How long the swatter lasts. */ - float m_swatter_duration; - /** How long a kart will remain squashed. */ - float m_squash_duration; - /** The slowdown to apply while a kart is squashed. The new maxspeed - * is max_speed*m_squash_slowdown. */ - float m_squash_slowdown; - - /** The maximum speed at each difficulty. */ - float m_max_speed; - - float m_max_speed_reverse_ratio; - - /** How far behind a kart slipstreaming is effective. */ - float m_slipstream_length; - /** How wide the slipstream area is at the end. */ - float m_slipstream_width; - /** Time after which sstream gives a bonus. */ - float m_slipstream_collect_time; - /** Time slip-stream bonus is effective. */ - float m_slipstream_use_time; - /** Additional power due to sstreaming. */ - float m_slipstream_add_power; - /** Minimum speed for slipstream to take effect. */ - float m_slipstream_min_speed; - /** How much the speed of the kart might exceed its - * normal maximum speed. */ - float m_slipstream_max_speed_increase; - /** How long the higher speed lasts after slipstream stopped working. */ - float m_slipstream_duration; - /** How long the slip stream speed increase will gradually be reduced. */ - float m_slipstream_fade_out_time; - - /** If the kart starts within the specified time at index I after 'go', - * it receives the speed boost from m_startup_boost[I]. */ - std::vector m_startup_times; - - /** The startup boost is the kart starts fast enough. */ - std::vector m_startup_boost; - - - void load (const std::string &filename, - const std::string &node); - - -public: - PlayerDifficulty (const std::string &filename=""); - ~PlayerDifficulty (); - void setDifficulty (PerPlayerDifficulty difficulty) { m_difficulty = difficulty; } - PerPlayerDifficulty getDifficulty() const { return m_difficulty; } - void getAllData (const XMLNode * root); - std::string getIdent () const; - float getStartupBoost () const; - - // ------------------------------------------------------------------------ - /** Returns the maximum engine power depending on difficulty. */ - float getMaxPower () const {return m_engine_power; } - - // ------------------------------------------------------------------------ - /** Get braking information. */ - float getBrakeFactor () const {return m_brake_factor; } - - // ------------------------------------------------------------------------ - /** Returns the additional brake factor which depends on time. */ - float getBrakeTimeIncrease() const { return m_brake_time_increase; } - - // ------------------------------------------------------------------------ - /** Get maximum reverse speed ratio. */ - float getMaxSpeedReverseRatio () const - {return m_max_speed_reverse_ratio; } - - // ------------------------------------------------------------------------ - /** Returns the maximum speed dependent on the difficult level. */ - float getMaxSpeed () const { return m_max_speed; } - - // ------------------------------------------------------------------------ - /** Returns the nitro consumption. */ - float getNitroConsumption () const {return m_nitro_consumption; } - - // ------------------------------------------------------------------------ - /** Returns the increase of maximum speed due to nitro. */ - float getNitroMaxSpeedIncrease () const - {return m_nitro_max_speed_increase; } - - // ------------------------------------------------------------------------ - float getNitroEngineForce () const {return m_nitro_engine_force; } - // ------------------------------------------------------------------------ - /** Returns how long the increased nitro max speed will be valid after - * the kart stops using nitro (and the fade-out-time starts). */ - float getNitroDuration () const {return m_nitro_duration; } - - // ------------------------------------------------------------------------ - /** Returns the duration during which the increased maximum speed - * due to nitro fades out. */ - float getNitroFadeOutTime () const {return m_nitro_fade_out_time; } - // ------------------------------------------------------------------------ - /** Returns how long a bubble gum is active. */ - float getBubblegumTime() const { return m_bubblegum_time; } - // ------------------------------------------------------------------------ - /** Returns the torque to add when a bubble gum was hit . */ - float getBubblegumTorque() const { return m_bubblegum_torque; } - // ------------------------------------------------------------------------ - /** Returns the fraction of top speed that can be reached maximum after - * hitting a bubble gum. */ - float getBubblegumSpeedFraction() const {return m_bubblegum_speed_fraction;} - // ------------------------------------------------------------------------ - /** Returns how long to fade in the slowdown for a bubble gum. */ - float getBubblegumFadeInTime() const { return m_bubblegum_fade_in_time; } - - // ------------------------------------------------------------------------ - /** Returns the time a kart is rised during a rescue. */ - float getRescueTime () const {return m_rescue_time; } - - // ------------------------------------------------------------------------ - /** Returns the time an explosion animation is shown. */ - float getExplosionTime () const {return m_explosion_time; } - - // ------------------------------------------------------------------------ - /** Returns how long a kart is invulnerable after being hit by an - explosion. */ - float getExplosionInvulnerabilityTime() const - { return m_explosion_invulnerability_time; } - - // ------------------------------------------------------------------------ - /** Returns the maximum length of a rubber band before it breaks. */ - float getRubberBandMaxLength () const {return m_rubber_band_max_length;} - - // ------------------------------------------------------------------------ - /** Returns force a rubber band has when attached to a kart. */ - float getRubberBandForce () const {return m_rubber_band_force; } - - // ------------------------------------------------------------------------ - /** Returns the duration a rubber band is active for. */ - float getRubberBandDuration () const {return m_rubber_band_duration; } - - // ------------------------------------------------------------------------ - /** Returns the increase of maximum speed while a rubber band is - * pulling. */ - float getRubberBandSpeedIncrease() const - { - return m_rubber_band_speed_increase; - } - - // ------------------------------------------------------------------------ - /** Return the fade out time once a rubber band is removed. */ - float getRubberBandFadeOutTime() const - { - return m_rubber_band_fade_out_time; - } - - // ------------------------------------------------------------------------ - /** Returns duration of a plunger in your face. */ - float getPlungerInFaceTime () const {return m_plunger_in_face_duration;} - - // ------------------------------------------------------------------------ - /** Returns the time a zipper is active. */ - float getZipperTime () const {return m_zipper_time; } - - // ------------------------------------------------------------------------ - /** Returns the time a zipper is active. */ - float getZipperFadeOutTime () const {return m_zipper_fade_out_time; } - - // ------------------------------------------------------------------------ - /** Returns the additional force added applied to the kart. */ - float getZipperForce () const { return m_zipper_force; } - - // ------------------------------------------------------------------------ - /** Returns the initial zipper speed gain. */ - float getZipperSpeedGain () const { return m_zipper_speed_gain; } - - // ------------------------------------------------------------------------ - /** Returns the increase of the maximum speed of the kart - * if a zipper is active. */ - float getZipperMaxSpeedIncrease () const - { return m_zipper_max_speed_increase;} - - // ------------------------------------------------------------------------ - /** Returns how far behind a kart slipstreaming works. */ - float getSlipstreamLength () const {return m_slipstream_length; } - - // ------------------------------------------------------------------------ - /** Returns how wide the slipstream area is at the end. */ - float getSlipstreamWidth () const {return m_slipstream_width; } - - // ------------------------------------------------------------------------ - /** Returns time after which slipstream has maximum effect. */ - float getSlipstreamCollectTime () const - {return m_slipstream_collect_time; } - - // ------------------------------------------------------------------------ - /** Returns time after which slipstream has maximum effect. */ - float getSlipstreamUseTime () const {return m_slipstream_use_time; } - - // ------------------------------------------------------------------------ - /** Returns additional power due to slipstreaming. */ - float getSlipstreamAddPower () const {return m_slipstream_add_power; } - - // ------------------------------------------------------------------------ - /** Returns the minimum slipstream speed. */ - float getSlipstreamMinSpeed () const {return m_slipstream_min_speed; } - - // ------------------------------------------------------------------------ - /** Returns the increase of the maximum speed of a kart - * due to slipstream. */ - float getSlipstreamMaxSpeedIncrease() const - { return m_slipstream_max_speed_increase; } - // ------------------------------------------------------------------------ - /** Returns how long the higher speed lasts after slipstream - * stopped working. */ - float getSlipstreamDuration () const { return m_slipstream_duration; } - - // ------------------------------------------------------------------------ - /** Returns how long the slip stream speed increase will gradually - * be reduced. */ - float getSlipstreamFadeOutTime () const - { return m_slipstream_fade_out_time; } - - // ------------------------------------------------------------------------ - /** Returns how long a swatter will stay attached/ready to be used. */ - float getSwatterDuration() const { return m_swatter_duration; } - - // ------------------------------------------------------------------------ - /** Returns how long a kart remains squashed. */ - float getSquashDuration() const {return m_squash_duration; } - - // ------------------------------------------------------------------------ - /** Returns the slowdown of a kart that is squashed. */ - float getSquashSlowdown() const {return m_squash_slowdown; } -}; // KartProperties - -#endif - diff --git a/src/karts/rescue_animation.cpp b/src/karts/rescue_animation.cpp index c88273a80..caaae1d01 100644 --- a/src/karts/rescue_animation.cpp +++ b/src/karts/rescue_animation.cpp @@ -39,8 +39,7 @@ RescueAnimation::RescueAnimation(AbstractKart *kart, bool is_auto_rescue) { m_referee = new Referee(*m_kart); m_kart->getNode()->addChild(m_referee->getSceneNode()); - m_timer = m_kart->getKartProperties()->getRescueTime() * - m_kart->getPlayerDifficulty()->getRescueTime(); + m_timer = m_kart->getKartProperties()->getRescueTime(); m_velocity = m_kart->getKartProperties()->getRescueHeight() / m_timer; m_xyz = m_kart->getXYZ(); diff --git a/src/modes/profile_world.cpp b/src/modes/profile_world.cpp index 0fef5edc7..f0287c060 100644 --- a/src/modes/profile_world.cpp +++ b/src/modes/profile_world.cpp @@ -106,7 +106,7 @@ void ProfileWorld::setProfileModeLaps(int laps) AbstractKart *ProfileWorld::createKart(const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType type, - const PlayerDifficulty *difficulty) + PerPlayerDifficulty difficulty) { btTransform init_pos = m_track->getStartTransform(index); diff --git a/src/modes/profile_world.hpp b/src/modes/profile_world.hpp index 6a0977ebc..014ab392c 100644 --- a/src/modes/profile_world.hpp +++ b/src/modes/profile_world.hpp @@ -75,7 +75,7 @@ protected: virtual AbstractKart *createKart(const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType type, - const PlayerDifficulty *difficulty); + PerPlayerDifficulty difficulty); public: ProfileWorld(); diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index dcba80e8c..79a495622 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -467,7 +467,7 @@ int SoccerWorld::getTeamLeader(unsigned int team) AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType kart_type, - const PlayerDifficulty *difficulty) + PerPlayerDifficulty difficulty) { int posIndex = index; int position = index+1; diff --git a/src/modes/soccer_world.hpp b/src/modes/soccer_world.hpp index d33f1dd74..783740771 100644 --- a/src/modes/soccer_world.hpp +++ b/src/modes/soccer_world.hpp @@ -107,7 +107,7 @@ protected: virtual AbstractKart *createKart(const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType type, - const PlayerDifficulty *difficulty); + PerPlayerDifficulty difficulty); }; // SoccerWorld diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 8c88faced..2d788150d 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -183,12 +183,10 @@ void World::init() : race_manager->getKartIdent(i); int local_player_id = race_manager->getKartLocalPlayerId(i); int global_player_id = race_manager->getKartGlobalPlayerId(i); - const PlayerDifficulty *player_difficulty = - stk_config->getPlayerDifficulty(race_manager->getPlayerDifficulty(i)); AbstractKart* newkart = createKart(kart_ident, i, local_player_id, global_player_id, race_manager->getKartType(i), - player_difficulty); + race_manager->getPlayerDifficulty(i)); m_karts.push_back(newkart); m_track->adjustForFog(newkart->getNode()); @@ -301,7 +299,7 @@ void World::createRaceGUI() AbstractKart *World::createKart(const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType kart_type, - const PlayerDifficulty *difficulty) + PerPlayerDifficulty difficulty) { int position = index+1; btTransform init_pos = m_track->getStartTransform(index); diff --git a/src/modes/world.hpp b/src/modes/world.hpp index fef41591b..cb990cbe6 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -126,7 +126,7 @@ protected: virtual AbstractKart *createKart(const std::string &kart_ident, int index, int local_player_id, int global_player_id, RaceManager::KartType type, - const PlayerDifficulty *difficulty); + PerPlayerDifficulty difficulty); /** Pointer to the track. The track is managed by world. */ Track* m_track; diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 10e21d5e8..357a36943 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -219,8 +219,8 @@ void Physics::update(float dt) else if (obj->isFlattenKartObject()) { const KartProperties* kp = kart->getKartProperties(); - kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(), - kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown()); + kart->setSquash(kp->getSquashDuration(), + kp->getSquashSlowdown()); } else if(obj->isSoccerBall() && race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) @@ -249,8 +249,8 @@ void Physics::update(float dt) { AbstractKart *kart = p->getUserPointer(1)->getPointerKart(); const KartProperties* kp = kart->getKartProperties(); - kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(), - kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown()); + kart->setSquash(kp->getSquashDuration(), + kp->getSquashSlowdown()); } continue; From 9fc6f84545f14ce85063c3dc3b025af978021f1a Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sat, 11 Jul 2015 19:17:24 +0200 Subject: [PATCH 20/55] Switch from properties to characteristics --- data/kart_characteristics.xml | 7 +- src/graphics/camera.cpp | 19 +- src/graphics/slip_stream.cpp | 29 +- src/guiengine/widgets/kart_stats_widget.cpp | 14 +- src/items/attachment.cpp | 3 +- src/items/plunger.cpp | 3 +- src/items/powerup.cpp | 3 +- src/items/rubber_band.cpp | 9 +- src/items/swatter.cpp | 13 +- src/karts/abstract_characteristic.cpp | 82 +-- src/karts/abstract_characteristic.hpp | 31 +- src/karts/cannon_animation.cpp | 3 +- .../controller/network_player_controller.cpp | 3 +- src/karts/controller/player_controller.cpp | 7 +- src/karts/controller/skidding_ai.cpp | 13 +- src/karts/explosion_animation.cpp | 7 +- src/karts/kart.cpp | 150 +++-- src/karts/kart.hpp | 7 +- src/karts/kart_gfx.cpp | 3 +- src/karts/kart_properties.cpp | 387 ++----------- src/karts/kart_properties.hpp | 532 +----------------- src/karts/max_speed.cpp | 5 +- src/karts/rescue_animation.cpp | 5 +- src/karts/xml_characteristic.cpp | 49 +- src/karts/xml_characteristic.hpp | 1 + src/modes/soccer_world.cpp | 3 +- src/physics/btKart.cpp | 9 +- src/physics/physics.cpp | 19 +- src/states_screens/kart_selection.cpp | 10 +- src/states_screens/race_gui.cpp | 5 +- src/states_screens/race_gui_overworld.cpp | 5 +- src/tracks/track.cpp | 5 +- tools/create_kart_properties.py | 25 +- 33 files changed, 364 insertions(+), 1102 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index a1273f4c0..64449e202 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -61,7 +61,7 @@ 0.5 * 0.25 + 0.5 * 0.15 = 0.2 ... which is overall the same time we had previously. --> + in-face-time="4" /> @@ -304,14 +304,17 @@ + + + diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 88253d630..66dcd4041 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -25,6 +25,7 @@ #include "config/user_config.hpp" #include "graphics/irr_driver.hpp" #include "io/xml_node.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/explosion_animation.hpp" #include "karts/kart.hpp" @@ -67,7 +68,7 @@ Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL) setupCamera(); if (kart != NULL) { - m_distance = kart->getKartProperties()->getCameraDistance(); + m_distance = kart->getCharacteristic()->getCameraDistance(); setKart(kart); } else @@ -378,9 +379,9 @@ void Camera::smoothMoveCamera(float dt) core::vector3df current_position = m_camera->getPosition(); // Smoothly interpolate towards the position and target - const KartProperties *kp = m_kart->getKartProperties(); - float max_increase_with_zipper = kp->getZipperMaxSpeedIncrease(); - float max_speed_without_zipper = kp->getMaxSpeed(); + const AbstractCharacteristic *ch = m_kart->getCharacteristic(); + float max_increase_with_zipper = ch->getZipperMaxSpeedIncrease(); + float max_speed_without_zipper = ch->getEngineMaxSpeed(); float current_speed = m_kart->getSpeed(); const Skidding *ks = m_kart->getSkidding(); @@ -452,7 +453,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, float *sideway, float *distance, bool *smoothing) { - const KartProperties *kp = m_kart->getKartProperties(); + const AbstractCharacteristic *ch = m_kart->getCharacteristic(); switch(m_mode) { @@ -475,7 +476,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, else { *above_kart = 0.75f; - *cam_angle = kp->getCameraForwardUpAngle(); + *cam_angle = ch->getCameraForwardUpAngle(); *distance = -m_distance; } float steering = m_kart->getSteerPercent() @@ -490,7 +491,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, case CM_REVERSE: // Same as CM_NORMAL except it looks backwards { *above_kart = 0.75f; - *cam_angle = kp->getCameraBackwardUpAngle(); + *cam_angle = ch->getCameraBackwardUpAngle(); *sideway = 0; *distance = 2.0f*m_distance; *smoothing = false; @@ -822,8 +823,8 @@ void Camera::handleEndCamera(float dt) } case EndCameraInformation::EC_AHEAD_OF_KART: { - const KartProperties *kp=m_kart->getKartProperties(); - float cam_angle = kp->getCameraBackwardUpAngle(); + const AbstractCharacteristic *ch = m_kart->getCharacteristic(); + float cam_angle = ch->getCameraBackwardUpAngle(); positionCamera(dt, /*above_kart*/0.75f, cam_angle, /*side_way*/0, diff --git a/src/graphics/slip_stream.cpp b/src/graphics/slip_stream.cpp index 1062e72bb..5f0fb37e5 100644 --- a/src/graphics/slip_stream.cpp +++ b/src/graphics/slip_stream.cpp @@ -25,8 +25,9 @@ #include "graphics/material_manager.hpp" #include "graphics/stk_mesh_scene_node.hpp" #include "io/file_manager.hpp" -#include "karts/controller/controller.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" +#include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" #include "karts/max_speed.hpp" #include "modes/world.hpp" @@ -67,9 +68,9 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart) setTextureMatrix(&(m_node->getMaterial(0).getTextureMatrix(0))); m_slipstream_time = 0.0f; - float length = m_kart->getKartProperties()->getSlipstreamLength(); + float length = m_kart->getCharacteristic()->getSlipstreamLength(); float kw = m_kart->getKartWidth(); - float ew = m_kart->getKartProperties()->getSlipstreamWidth(); + float ew = m_kart->getCharacteristic()->getSlipstreamWidth(); float kl = m_kart->getKartLength(); Vec3 p[4]; @@ -312,7 +313,7 @@ void SlipStream::setIntensity(float f, const AbstractKart *kart) bool SlipStream::isSlipstreamReady() const { return m_slipstream_time> - m_kart->getKartProperties()->getSlipstreamCollectTime(); + m_kart->getCharacteristic()->getSlipstreamCollectTime(); } // isSlipstreamReady //----------------------------------------------------------------------------- @@ -326,12 +327,12 @@ void SlipStream::updateSlipstreamPower() if(m_slipstream_mode==SS_USE) { setIntensity(2.0f, NULL); - const KartProperties *kp=m_kart->getKartProperties(); + const AbstractCharacteristic *ch=m_kart->getCharacteristic(); m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, - kp->getSlipstreamMaxSpeedIncrease(), - kp->getSlipstreamAddPower(), - kp->getSlipstreamDuration(), - kp->getSlipstreamFadeOutTime()); + ch->getSlipstreamMaxSpeedIncrease(), + ch->getSlipstreamAddPower(), + ch->getSlipstreamDuration(), + ch->getSlipstreamFadeOutTime()); } } // upateSlipstreamPower @@ -387,7 +388,7 @@ void SlipStream::update(float dt) // not moving. This is useful for debugging the graphics of SS-ing. //#define DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING - if(m_kart->getSpeed()getKartProperties()->getSlipstreamMinSpeed()) + if(m_kart->getSpeed() < m_kart->getCharacteristic()->getSlipstreamMinSpeed()) { setIntensity(0, NULL); m_slipstream_mode = SS_NONE; @@ -429,7 +430,7 @@ void SlipStream::update(float dt) // give karts different slipstream properties. #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING if(m_target_kart->getSpeed() < - m_kart->getKartProperties()->getSlipstreamMinSpeed()) + m_kart->getCharacteristic()->getSlipstreamMinSpeed()) { if(UserConfigParams::m_slipstream_debug && m_kart->getController()->isPlayerController()) @@ -443,7 +444,7 @@ void SlipStream::update(float dt) // slipstream length+0.5*kart_length()+0.5*target_kart_length // away from the other kart Vec3 delta = m_kart->getXYZ() - m_target_kart->getXYZ(); - float l = m_kart->getKartProperties()->getSlipstreamLength() + float l = m_kart->getCharacteristic()->getSlipstreamLength() + 0.5f*( m_target_kart->getKartLength() +m_kart->getKartLength() ); if(delta.length2_2d() > l*l) @@ -484,7 +485,7 @@ void SlipStream::update(float dt) m_slipstream_mode = SS_USE; m_kart->handleZipper(); m_slipstream_time = - m_kart->getKartProperties()->getSlipstreamCollectTime(); + m_kart->getCharacteristic()->getSlipstreamCollectTime(); return; } } @@ -505,7 +506,7 @@ void SlipStream::update(float dt) setIntensity(m_slipstream_time, m_target_kart); m_slipstream_mode = SS_COLLECT; - if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime()) + if(m_slipstream_time>m_kart->getCharacteristic()->getSlipstreamCollectTime()) { setIntensity(1.0f, m_target_kart); } diff --git a/src/guiengine/widgets/kart_stats_widget.cpp b/src/guiengine/widgets/kart_stats_widget.cpp index 6de73a0d1..abe4bfaff 100644 --- a/src/guiengine/widgets/kart_stats_widget.cpp +++ b/src/guiengine/widgets/kart_stats_widget.cpp @@ -15,21 +15,19 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include "config/user_config.hpp" #include "guiengine/engine.hpp" #include "guiengine/widgets/kart_stats_widget.hpp" -#include "utils/string_utils.hpp" -#include +#include "karts/abstract_characteristic.hpp" #include "karts/kart_properties.hpp" #include "karts/kart_properties_manager.hpp" - #include "utils/log.hpp" #include "utils/string_utils.hpp" -#include "config/user_config.hpp" - #include #include #include +#include using namespace GUIEngine; using namespace irr::core; @@ -81,15 +79,15 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id, m_children.push_back(skill_bar); } - m_skills[SKILL_MASS]->setValue((int)(props->getMass()/5)); + m_skills[SKILL_MASS]->setValue((int)(props->getCombinedCharacteristic()->getMass()/5)); m_skills[SKILL_MASS]->setLabel(_("WEIGHT")); m_skills[SKILL_MASS]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_mass", m_player_id); - m_skills[SKILL_SPEED]->setValue((int)((props->getAbsMaxSpeed()-20)*9)); + m_skills[SKILL_SPEED]->setValue((int)((props->getCombinedCharacteristic()->getEngineMaxSpeed()-20)*9)); m_skills[SKILL_SPEED]->setLabel(_("SPEED")); m_skills[SKILL_SPEED]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_speed", m_player_id); - m_skills[SKILL_POWER]->setValue((int)(props->getAvgPower())); + m_skills[SKILL_POWER]->setValue((int)(props->getCombinedCharacteristic()->getEnginePower())); m_skills[SKILL_POWER]->setLabel(_("POWER")); m_skills[SKILL_POWER]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_power", m_player_id); diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index 0d355e9a5..95f7d6140 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -30,6 +30,7 @@ #include "items/item_manager.hpp" #include "items/projectile_manager.hpp" #include "items/swatter.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/explosion_animation.hpp" @@ -266,7 +267,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) // same banana again once the explosion animation is finished, giving // the kart the same penalty twice. float f = std::max(item->getDisableTime(), - m_kart->getKartProperties()->getExplosionTime() + 2.0f); + m_kart->getCharacteristic()->getExplosionDuration() + 2.0f); item->setDisableTime(f); break; } diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index da47d0701..54d09c334 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -25,6 +25,7 @@ #include "io/xml_node.hpp" #include "items/rubber_band.hpp" #include "items/projectile_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" @@ -178,7 +179,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj) } else { - m_keep_alive = m_owner->getKartProperties()->getRubberBandDuration(); + m_keep_alive = m_owner->getCharacteristic()->getPlungerBandDuration(); // Make this object invisible by placing it faaar down. Not that if this // objects is simply removed from the scene graph, it might be auto-deleted diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index aa39b5553..745ff4fae 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -28,6 +28,7 @@ #include "items/item_manager.hpp" #include "items/projectile_manager.hpp" #include "items/rubber_ball.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" @@ -222,7 +223,7 @@ void Powerup::use() case PowerupManager::POWERUP_SWATTER: m_owner->getAttachment() ->set(Attachment::ATTACH_SWATTER, - m_owner->getKartProperties()->getSwatterDuration()); + m_owner->getCharacteristic()->getSwatterDuration()); break; case PowerupManager::POWERUP_BUBBLEGUM: diff --git a/src/items/rubber_band.cpp b/src/items/rubber_band.cpp index f276d4c46..bfa1303e8 100644 --- a/src/items/rubber_band.cpp +++ b/src/items/rubber_band.cpp @@ -26,6 +26,7 @@ #include "graphics/stk_mesh_scene_node.hpp" #include "items/plunger.hpp" #include "items/projectile_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "karts/max_speed.hpp" @@ -149,7 +150,7 @@ void RubberBand::update(float dt) // Check for rubber band snapping // ------------------------------ float l = (m_end_position-k).length2(); - float max_len = m_owner->getKartProperties()->getRubberBandMaxLength(); + float max_len = m_owner->getCharacteristic()->getPlungerBandMaxLength(); if(l>max_len*max_len) { // Rubber band snaps @@ -162,7 +163,7 @@ void RubberBand::update(float dt) // ---------------------------- if(m_attached_state!=RB_TO_PLUNGER) { - float force = m_owner->getKartProperties()->getRubberBandForce(); + float force = m_owner->getCharacteristic()->getPlungerBandForce(); Vec3 diff = m_end_position-k; // detach rubber band if kart gets very close to hit point @@ -178,10 +179,10 @@ void RubberBand::update(float dt) diff.normalize(); // diff can't be zero here m_owner->getBody()->applyCentralForce(diff*force); m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER, - m_owner->getKartProperties()->getRubberBandSpeedIncrease(), + m_owner->getCharacteristic()->getPlungerBandSpeedIncrease(), /*engine_force*/ 0.0f, /*duration*/0.1f, - m_owner->getKartProperties()->getRubberBandFadeOutTime()); + m_owner->getCharacteristic()->getPlungerBandFadeOutTime()); if(m_attached_state==RB_TO_KART) m_hit_kart->getBody()->applyCentralForce(diff*(-force)); } diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index 7cad9953d..4b96e37c8 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -34,6 +34,7 @@ #include "io/file_manager.hpp" #include "items/attachment.hpp" #include "items/projectile_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/controller/controller.hpp" #include "karts/explosion_animation.hpp" #include "karts/kart_properties.hpp" @@ -156,7 +157,7 @@ bool Swatter::updateAndTestFinished(float dt) (m_target->getXYZ()- Vec3(m_scene_node->getAbsolutePosition())) .length2(); float min_dist2 - = m_kart->getKartProperties()->getSwatterDistance2(); + = m_kart->getCharacteristic()->getSwatterDistance(); if(dist_to_target2 < min_dist2) { // Start squashing @@ -264,10 +265,10 @@ void Swatter::pointToTarget() */ void Swatter::squashThingsAround() { - const KartProperties* kp = m_kart->getKartProperties(); + const AbstractCharacteristic *ch = m_kart->getCharacteristic(); // Square of the minimum distance - float min_dist2 = kp->getSwatterDistance2(); - const World* world = World::getWorld(); + float min_dist2 = ch->getSwatterDistance(); + const World* world = World::getWorld(); // Get the node corresponding to the joint at the center of the swatter // (by swatter, I mean the thing hold in the hand, not the whole thing) @@ -279,7 +280,7 @@ void Swatter::squashThingsAround() m_swat_sound->play(); // Squash karts around - for(unsigned int i=0; igetNumKarts(); i++) + for(unsigned int i = 0; i < world->getNumKarts(); i++) { AbstractKart *kart = world->getKart(i); // TODO: isSwatterReady() @@ -293,7 +294,7 @@ void Swatter::squashThingsAround() if(dist2 >= min_dist2) continue; // too far away, ignore this kart - kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown()); + kart->setSquash(ch->getSwatterSquashDuration(), ch->getSwatterSquashSlowdown()); //Handle achievement if the swatter is used by the current player const StateManager::ActivePlayer *const ap = m_kart->getController() diff --git a/src/karts/abstract_characteristic.cpp b/src/karts/abstract_characteristic.cpp index 2995f948a..6d5f9bc80 100755 --- a/src/karts/abstract_characteristic.cpp +++ b/src/karts/abstract_characteristic.cpp @@ -45,7 +45,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(Characteristic case CHARACTERISTIC_COUNT: Log::fatal("AbstractCharacteristic::getType", "Can't get type of COUNT"); break; - // Script-generated content + // Script-generated content get-prop first part case SUSPENSION_STIFFNESS: return TYPE_FLOAT; case SUSPENSION_REST: @@ -53,7 +53,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(Characteristic case SUSPENSION_TRAVEL_CM: return TYPE_FLOAT; case SUSPENSION_EXP_SPRING_RESPONSE: - return TYPE_FLOAT; + return TYPE_BOOL; case SUSPENSION_MAX_FORCE: return TYPE_FLOAT; case STABILITY_ROLL_INFLUENCE: @@ -144,7 +144,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(Characteristic return TYPE_FLOAT; case ZIPPER_SPEED_GAIN: return TYPE_FLOAT; - case ZIPPER_SPEED_INCREASE: + case ZIPPER_MAX_SPEED_INCREASE: return TYPE_FLOAT; case ZIPPER_FADE_OUT_TIME: return TYPE_FLOAT; @@ -156,15 +156,15 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(Characteristic return TYPE_FLOAT; case SWATTER_SQUASH_SLOWDOWN: return TYPE_FLOAT; - case PLUNGER_MAX_LENGTH: + case PLUNGER_BAND_MAX_LENGTH: return TYPE_FLOAT; - case PLUNGER_FORCE: + case PLUNGER_BAND_FORCE: return TYPE_FLOAT; - case PLUNGER_DURATION: + case PLUNGER_BAND_DURATION: return TYPE_FLOAT; - case PLUNGER_SPEED_INCREASE: + case PLUNGER_BAND_SPEED_INCREASE: return TYPE_FLOAT; - case PLUNGER_FADE_OUT_TIME: + case PLUNGER_BAND_FADE_OUT_TIME: return TYPE_FLOAT; case PLUNGER_IN_FACE_TIME: return TYPE_FLOAT; @@ -229,7 +229,7 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) { case CHARACTERISTIC_COUNT: return "CHARACTERISTIC_COUNT"; - // Script-generated content + // Script-generated content get-prop second part case SUSPENSION_STIFFNESS: return "SUSPENSION_STIFFNESS"; case SUSPENSION_REST: @@ -328,8 +328,8 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) return "ZIPPER_FORCE"; case ZIPPER_SPEED_GAIN: return "ZIPPER_SPEED_GAIN"; - case ZIPPER_SPEED_INCREASE: - return "ZIPPER_SPEED_INCREASE"; + case ZIPPER_MAX_SPEED_INCREASE: + return "ZIPPER_MAX_SPEED_INCREASE"; case ZIPPER_FADE_OUT_TIME: return "ZIPPER_FADE_OUT_TIME"; case SWATTER_DURATION: @@ -340,16 +340,16 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) return "SWATTER_SQUASH_DURATION"; case SWATTER_SQUASH_SLOWDOWN: return "SWATTER_SQUASH_SLOWDOWN"; - case PLUNGER_MAX_LENGTH: - return "PLUNGER_MAX_LENGTH"; - case PLUNGER_FORCE: - return "PLUNGER_FORCE"; - case PLUNGER_DURATION: - return "PLUNGER_DURATION"; - case PLUNGER_SPEED_INCREASE: - return "PLUNGER_SPEED_INCREASE"; - case PLUNGER_FADE_OUT_TIME: - return "PLUNGER_FADE_OUT_TIME"; + case PLUNGER_BAND_MAX_LENGTH: + return "PLUNGER_BAND_MAX_LENGTH"; + case PLUNGER_BAND_FORCE: + return "PLUNGER_BAND_FORCE"; + case PLUNGER_BAND_DURATION: + return "PLUNGER_BAND_DURATION"; + case PLUNGER_BAND_SPEED_INCREASE: + return "PLUNGER_BAND_SPEED_INCREASE"; + case PLUNGER_BAND_FADE_OUT_TIME: + return "PLUNGER_BAND_FADE_OUT_TIME"; case PLUNGER_IN_FACE_TIME: return "PLUNGER_IN_FACE_TIME"; case STARTUP_TIME: @@ -438,9 +438,9 @@ float AbstractCharacteristic::getSuspensionTravelCm() const return result; } -float AbstractCharacteristic::getSuspensionExpSpringResponse() const +bool AbstractCharacteristic::getSuspensionExpSpringResponse() const { - float result; + bool result; bool is_set = false; process(SUSPENSION_EXP_SPRING_RESPONSE, &result, &is_set); if (!is_set) @@ -898,13 +898,13 @@ float AbstractCharacteristic::getZipperSpeedGain() const return result; } -float AbstractCharacteristic::getZipperSpeedIncrease() const +float AbstractCharacteristic::getZipperMaxSpeedIncrease() const { float result; bool is_set = false; - process(ZIPPER_SPEED_INCREASE, &result, &is_set); + process(ZIPPER_MAX_SPEED_INCREASE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ZIPPER_SPEED_INCREASE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(ZIPPER_MAX_SPEED_INCREASE).c_str()); return result; } @@ -958,53 +958,53 @@ float AbstractCharacteristic::getSwatterSquashSlowdown() const return result; } -float AbstractCharacteristic::getPlungerMaxLength() const +float AbstractCharacteristic::getPlungerBandMaxLength() const { float result; bool is_set = false; - process(PLUNGER_MAX_LENGTH, &result, &is_set); + process(PLUNGER_BAND_MAX_LENGTH, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_MAX_LENGTH).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_BAND_MAX_LENGTH).c_str()); return result; } -float AbstractCharacteristic::getPlungerForce() const +float AbstractCharacteristic::getPlungerBandForce() const { float result; bool is_set = false; - process(PLUNGER_FORCE, &result, &is_set); + process(PLUNGER_BAND_FORCE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_FORCE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_BAND_FORCE).c_str()); return result; } -float AbstractCharacteristic::getPlungerDuration() const +float AbstractCharacteristic::getPlungerBandDuration() const { float result; bool is_set = false; - process(PLUNGER_DURATION, &result, &is_set); + process(PLUNGER_BAND_DURATION, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_DURATION).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_BAND_DURATION).c_str()); return result; } -float AbstractCharacteristic::getPlungerSpeedIncrease() const +float AbstractCharacteristic::getPlungerBandSpeedIncrease() const { float result; bool is_set = false; - process(PLUNGER_SPEED_INCREASE, &result, &is_set); + process(PLUNGER_BAND_SPEED_INCREASE, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_SPEED_INCREASE).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_BAND_SPEED_INCREASE).c_str()); return result; } -float AbstractCharacteristic::getPlungerFadeOutTime() const +float AbstractCharacteristic::getPlungerBandFadeOutTime() const { float result; bool is_set = false; - process(PLUNGER_FADE_OUT_TIME, &result, &is_set); + process(PLUNGER_BAND_FADE_OUT_TIME, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_FADE_OUT_TIME).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(PLUNGER_BAND_FADE_OUT_TIME).c_str()); return result; } diff --git a/src/karts/abstract_characteristic.hpp b/src/karts/abstract_characteristic.hpp index ffc235ce6..7b88f8a88 100755 --- a/src/karts/abstract_characteristic.hpp +++ b/src/karts/abstract_characteristic.hpp @@ -46,10 +46,12 @@ public: union Value { float *f; + bool *b; std::vector *fv; InterpolationArray *ia; Value(float *f) : f(f) {} + Value(bool *b) : b(b) {} Value(std::vector *fv) : fv(fv) {} Value(InterpolationArray *ia) : ia(ia) {} }; @@ -57,6 +59,7 @@ public: enum ValueType { TYPE_FLOAT, + TYPE_BOOL, TYPE_FLOAT_VECTOR, TYPE_INTERPOLATION_ARRAY }; @@ -81,8 +84,8 @@ public: // Turn TURN_RADIUS, - TURN_TIME_FULL_STEER, TURN_TIME_RESET_STEER, + TURN_TIME_FULL_STEER, // Engine ENGINE_POWER, @@ -140,7 +143,7 @@ public: ZIPPER_DURATION, ZIPPER_FORCE, ZIPPER_SPEED_GAIN, - ZIPPER_SPEED_INCREASE, + ZIPPER_MAX_SPEED_INCREASE, ZIPPER_FADE_OUT_TIME, // Swatter @@ -150,11 +153,11 @@ public: SWATTER_SQUASH_SLOWDOWN, // Plunger - PLUNGER_MAX_LENGTH, - PLUNGER_FORCE, - PLUNGER_DURATION, - PLUNGER_SPEED_INCREASE, - PLUNGER_FADE_OUT_TIME, + PLUNGER_BAND_MAX_LENGTH, + PLUNGER_BAND_FORCE, + PLUNGER_BAND_DURATION, + PLUNGER_BAND_SPEED_INCREASE, + PLUNGER_BAND_FADE_OUT_TIME, PLUNGER_IN_FACE_TIME, // Startup @@ -229,7 +232,7 @@ public: float getSuspensionStiffness() const; float getSuspensionRest() const; float getSuspensionTravelCm() const; - float getSuspensionExpSpringResponse() const; + bool getSuspensionExpSpringResponse() const; float getSuspensionMaxForce() const; float getStabilityRollInfluence() const; @@ -288,7 +291,7 @@ public: float getZipperDuration() const; float getZipperForce() const; float getZipperSpeedGain() const; - float getZipperSpeedIncrease() const; + float getZipperMaxSpeedIncrease() const; float getZipperFadeOutTime() const; float getSwatterDuration() const; @@ -296,11 +299,11 @@ public: float getSwatterSquashDuration() const; float getSwatterSquashSlowdown() const; - float getPlungerMaxLength() const; - float getPlungerForce() const; - float getPlungerDuration() const; - float getPlungerSpeedIncrease() const; - float getPlungerFadeOutTime() const; + float getPlungerBandMaxLength() const; + float getPlungerBandForce() const; + float getPlungerBandDuration() const; + float getPlungerBandSpeedIncrease() const; + float getPlungerBandFadeOutTime() const; float getPlungerInFaceTime() const; std::vector getStartupTime() const; diff --git a/src/karts/cannon_animation.cpp b/src/karts/cannon_animation.cpp index e89478af6..411c52f14 100644 --- a/src/karts/cannon_animation.cpp +++ b/src/karts/cannon_animation.cpp @@ -21,6 +21,7 @@ #include "animations/animation_base.hpp" #include "animations/ipo.hpp" #include "animations/three_d_animation.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/world.hpp" @@ -69,7 +70,7 @@ CannonAnimation::~CannonAnimation() m_kart->getHeading() )); m_kart->getBody()->setCenterOfMassTransform(pos); - Vec3 v(0, 0, m_kart->getKartProperties()->getMaxSpeed()); + Vec3 v(0, 0, m_kart->getCharacteristic()->getEngineMaxSpeed()); m_kart->setVelocity(pos.getBasis()*v); } // ~CannonAnimation diff --git a/src/karts/controller/network_player_controller.cpp b/src/karts/controller/network_player_controller.cpp index b7616c5c3..f28fd96ee 100644 --- a/src/karts/controller/network_player_controller.cpp +++ b/src/karts/controller/network_player_controller.cpp @@ -7,6 +7,7 @@ #include "items/attachment.hpp" #include "items/item.hpp" #include "items/powerup.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "karts/skidding.hpp" @@ -197,7 +198,7 @@ void NetworkPlayerController::steer(float dt, int steer_val) // change speed is used. const float STEER_CHANGE = ( (steer_val<=0 && m_controls->m_steer<0) || (steer_val>=0 && m_controls->m_steer>0) ) - ? dt/m_kart->getKartProperties()->getTimeResetSteer() + ? dt/m_kart->getCharacteristic()->getTurnTimeResetSteer() : dt/m_kart->getTimeFullSteer(fabsf(m_controls->m_steer)); if (steer_val < 0) { diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index f45a47857..d87d80f28 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -29,6 +29,7 @@ #include "items/attachment.hpp" #include "items/item.hpp" #include "items/powerup.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "karts/skidding.hpp" @@ -254,7 +255,7 @@ void PlayerController::steer(float dt, int steer_val) // change speed is used. const float STEER_CHANGE = ( (steer_val<=0 && m_controls->m_steer<0) || (steer_val>=0 && m_controls->m_steer>0) ) - ? dt/m_kart->getKartProperties()->getTimeResetSteer() + ? dt/m_kart->getCharacteristic()->getTurnTimeResetSteer() : dt/m_kart->getTimeFullSteer(fabsf(m_controls->m_steer)); if (steer_val < 0) { @@ -464,8 +465,8 @@ void PlayerController::handleZipper(bool play_sound) */ void PlayerController::collectedItem(const Item &item, int add_info, float old_energy) { - if (old_energy < m_kart->getKartProperties()->getNitroMax() && - m_kart->getEnergy() == m_kart->getKartProperties()->getNitroMax()) + if (old_energy < m_kart->getCharacteristic()->getNitroMax() && + m_kart->getEnergy() == m_kart->getCharacteristic()->getNitroMax()) { m_full_sound->play(); } diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 74f40a84d..8ae3e03de 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -45,6 +45,7 @@ #include "items/item_manager.hpp" #include "items/powerup.hpp" #include "items/projectile_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/kart_control.hpp" #include "karts/controller/ai_properties.hpp" @@ -1065,8 +1066,8 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, case Item::ITEM_NITRO_BIG: // Only collect nitro, if it can actually be stored. if(m_kart->getEnergy() + - m_kart->getKartProperties()->getNitroBigContainer() - > m_kart->getKartProperties()->getNitroMax()) + m_kart->getCharacteristic()->getNitroBigContainer() + > m_kart->getCharacteristic()->getNitroMax()) return; // fall through: if we have enough space to store a big // container, we can also store a small container, and @@ -1074,8 +1075,8 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, case Item::ITEM_NITRO_SMALL: avoid = false; // Only collect nitro, if it can actually be stored. if (m_kart->getEnergy() + - m_kart->getKartProperties()->getNitroSmallContainer() - > m_kart->getKartProperties()->getNitroMax()) + m_kart->getCharacteristic()->getNitroSmallContainer() + > m_kart->getCharacteristic()->getNitroMax()) return; case Item::ITEM_BONUS_BOX: break; @@ -1105,7 +1106,7 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, // be if the kart would need to turn sharper, therefore stops // skidding, and will get the bonus speed. bool high_speed = (m_kart->getCurrentMaxSpeed() > - m_kart->getKartProperties()->getMaxSpeed() ) || + m_kart->getCharacteristic()->getEngineMaxSpeed() ) || m_kart->getSkidding()->getSkidBonusReady(); float max_angle = high_speed ? m_ai_properties->m_max_item_angle_high_speed @@ -1390,7 +1391,7 @@ void SkiddingAI::handleItems(const float dt) case PowerupManager::POWERUP_SWATTER: { // Squared distance for which the swatter works - float d2 = m_kart->getKartProperties()->getSwatterDistance2(); + float d2 = m_kart->getCharacteristic()->getSwatterDistance(); // if the kart has a shield, do not break it by using a swatter. if(m_kart->getShieldTime() > min_bubble_time) break; diff --git a/src/karts/explosion_animation.cpp b/src/karts/explosion_animation.cpp index 78963f30a..dc054e59e 100644 --- a/src/karts/explosion_animation.cpp +++ b/src/karts/explosion_animation.cpp @@ -22,6 +22,7 @@ #include "graphics/callbacks.hpp" #include "graphics/camera.hpp" #include "items/attachment.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/world.hpp" @@ -40,7 +41,7 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart, { if(kart->isInvulnerable()) return NULL; - float r = kart->getKartProperties()->getExplosionRadius(); + float r = kart->getCharacteristic()->getExplosionRadius(); // Ignore explosion that are too far away. if(!direct_hit && pos.distance2(kart->getXYZ())>r*r) return NULL; @@ -78,7 +79,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart, m_xyz = m_kart->getXYZ(); m_orig_y = m_xyz.getY(); m_kart->playCustomSFX(SFXManager::CUSTOM_EXPLODE); - m_timer = m_kart->getKartProperties()->getExplosionTime(); + m_timer = m_kart->getCharacteristic()->getExplosionDuration(); // Non-direct hits will be only affected half as much. if(!direct_hit) m_timer*=0.5f; @@ -105,7 +106,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart, m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f ); // Set invulnerable time, and graphical effects - float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime(); + float t = m_kart->getCharacteristic()->getExplosionInvulnerabilityTime(); m_kart->setInvulnerableTime(t); if ( UserConfigParams::m_graphical_effects ) { diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 4cd7ba076..12df080ba 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -39,6 +39,7 @@ #include "graphics/stars.hpp" #include "guiengine/scalable_font.hpp" #include "karts/abstract_characteristic.hpp" +#include "karts/combined_characteristic.hpp" #include "karts/explosion_animation.hpp" #include "karts/kart_gfx.hpp" #include "karts/rescue_animation.hpp" @@ -363,8 +364,8 @@ void Kart::reset() // In case that the kart was in the air, in which case its // linear damping is 0 if(m_body) - m_body->setDamping(m_kart_properties->getChassisLinearDamping(), - m_kart_properties->getChassisAngularDamping() ); + m_body->setDamping(m_characteristic->getStabilityChassisLinearDamping(), + m_characteristic->getStabilityChassisAngularDamping() ); if(m_terrain_sound) { @@ -537,7 +538,7 @@ void Kart::blockViewWithPlunger() { // Avoid that a plunger extends the plunger time if(m_view_blocked_by_plunger<=0 && !isShielded()) - m_view_blocked_by_plunger = m_kart_properties->getPlungerInFaceTime(); + m_view_blocked_by_plunger = m_characteristic->getPlungerInFaceTime(); if(isShielded()) { decreaseShieldTime(); @@ -568,6 +569,12 @@ btTransform Kart::getAlignedTransform(const float custom_pitch) return trans; } // getAlignedTransform +// ---------------------------------------------------------------------------- +float Kart::getTimeFullSteer(float steer) const +{ + return m_characteristic->getTurnTimeFullSteer().get(steer); +} // getTimeFullSteer + // ---------------------------------------------------------------------------- /** Creates the physical representation of this kart. Atm it uses the actual * extention of the kart model to determine the size of the collision body. @@ -618,7 +625,7 @@ void Kart::createPhysics() // All wheel positions are relative to the center of // the collision shape. wheel_pos[index].setX(x*0.5f*kart_width); - float radius = getKartProperties()->getWheelRadius(); + float radius = m_characteristic->getWheelsRadius(); // The y position of the wheels (i.e. the points where // the suspension is attached to) is just at the // bottom of the kart. That is half the kart height @@ -653,7 +660,7 @@ void Kart::createPhysics() // Set mass and inertia // -------------------- - float mass = m_kart_properties->getMass(); + float mass = m_characteristic->getMass(); // Position the chassis // -------------------- @@ -662,8 +669,8 @@ void Kart::createPhysics() createBody(mass, trans, &m_kart_chassis, m_kart_properties->getRestitution()); m_user_pointer.set(this); - m_body->setDamping(m_kart_properties->getChassisLinearDamping(), - m_kart_properties->getChassisAngularDamping() ); + m_body->setDamping(m_characteristic->getStabilityChassisLinearDamping(), + m_characteristic->getStabilityChassisAngularDamping() ); // Reset velocities // ---------------- @@ -683,17 +690,17 @@ void Kart::createPhysics() // Add wheels // ---------- - float wheel_radius = m_kart_properties->getWheelRadius(); - float suspension_rest = m_kart_properties->getSuspensionRest(); + float wheel_radius = m_characteristic->getWheelsRadius(); + float suspension_rest = m_characteristic->getSuspensionRest(); btVector3 wheel_direction(0.0f, -1.0f, 0.0f); btVector3 wheel_axle(-1.0f, 0.0f, 0.0f); btKart::btVehicleTuning tuning; tuning.m_maxSuspensionTravelCm = - m_kart_properties->getSuspensionTravelCM(); + m_characteristic->getSuspensionTravelCm(); tuning.m_maxSuspensionForce = - m_kart_properties->getMaxSuspensionForce(); + m_characteristic->getSuspensionMaxForce(); const Vec3 &cs = getKartProperties()->getGravityCenterShift(); for(unsigned int i=0; i<4; i++) @@ -703,11 +710,11 @@ void Kart::createPhysics() wheel_pos[i]+cs, wheel_direction, wheel_axle, suspension_rest, wheel_radius, tuning, is_front_wheel); - wheel.m_suspensionStiffness = m_kart_properties->getSuspensionStiffness(); - wheel.m_wheelsDampingRelaxation = m_kart_properties->getWheelDampingRelaxation(); - wheel.m_wheelsDampingCompression = m_kart_properties->getWheelDampingCompression(); + wheel.m_suspensionStiffness = m_characteristic->getSuspensionStiffness(); + wheel.m_wheelsDampingRelaxation = m_characteristic->getWheelsDampingRelaxation(); + wheel.m_wheelsDampingCompression = m_characteristic->getWheelsDampingCompression(); wheel.m_frictionSlip = m_kart_properties->getFrictionSlip(); - wheel.m_rollInfluence = m_kart_properties->getRollInfluence(); + wheel.m_rollInfluence = m_characteristic->getStabilityRollInfluence(); } // Obviously these allocs have to be properly managed/freed btTransform t; @@ -793,7 +800,7 @@ void Kart::adjustSpeed(float f) */ void Kart::updateWeight() { - float mass = m_kart_properties->getMass() + m_attachment->weightAdjust(); + float mass = m_characteristic->getMass() + m_attachment->weightAdjust(); btVector3 inertia; m_kart_chassis.calculateLocalInertia(mass, inertia); @@ -907,10 +914,10 @@ void Kart::collectedItem(Item *item, int add_info) m_attachment->hitBanana(item, add_info); break; case Item::ITEM_NITRO_SMALL: - m_collected_energy += m_kart_properties->getNitroSmallContainer(); + m_collected_energy += m_characteristic->getNitroSmallContainer(); break; case Item::ITEM_NITRO_BIG: - m_collected_energy += m_kart_properties->getNitroBigContainer(); + m_collected_energy += m_characteristic->getNitroBigContainer(); break; case Item::ITEM_BONUS_BOX : { @@ -922,13 +929,13 @@ void Kart::collectedItem(Item *item, int add_info) item->getEmitter()->getIdent() == "nolok"); // slow down - m_bubblegum_time = m_kart_properties->getBubblegumTime(); + m_bubblegum_time = m_characteristic->getBubblegumDuration(); m_bubblegum_torque = ((rand()%2) - ? m_kart_properties->getBubblegumTorque() - : -m_kart_properties->getBubblegumTorque()); + ? m_characteristic->getBubblegumTorque() + : -m_characteristic->getBubblegumTorque()); m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE, - m_kart_properties->getBubblegumSpeedFraction() , - m_kart_properties->getBubblegumFadeInTime(), + m_characteristic->getBubblegumSpeedFraction() , + m_characteristic->getBubblegumFadeInTime(), m_bubblegum_time); m_goo_sound->setPosition(getXYZ()); m_goo_sound->play(); @@ -938,12 +945,31 @@ void Kart::collectedItem(Item *item, int add_info) default : break; } // switch TYPE - if ( m_collected_energy > m_kart_properties->getNitroMax()) - m_collected_energy = m_kart_properties->getNitroMax(); + if ( m_collected_energy > m_characteristic->getNitroMax()) + m_collected_energy = m_characteristic->getNitroMax(); m_controller->collectedItem(*item, add_info, old_energy); } // collectedItem +//----------------------------------------------------------------------------- +/** Called the first time a kart accelerates after 'ready-set-go'. It searches + * through the startup times to find the appropriate slot, and returns the + * speed-boost from the corresponding entry. + * If the kart started too slow (i.e. slower than the longest time in the + * startup times list), it returns 0. + */ +float Kart::getStartupBoost() const +{ + float t = World::getWorld()->getTime(); + std::vector startup_times = m_characteristic->getStartupTime(); + for (unsigned int i = 0; i < startup_times.size(); i++) + { + if (t <= startup_times[i]) + return m_characteristic->getStartupBoost()[i]; + } + return 0; +} // getStartupBoost + //----------------------------------------------------------------------------- /** Simulates gears by adjusting the force of the engine. It also takes the * effect of the zipper into account. @@ -952,20 +978,20 @@ float Kart::getActualWheelForce() { float add_force = m_max_speed->getCurrentAdditionalEngineForce(); assert(!isnan(add_force)); - const std::vector& gear_ratio=m_kart_properties->getGearSwitchRatio(); + const std::vector& gear_ratio=m_characteristic->getGearSwitchRatio(); for(unsigned int i=0; igetMaxSpeed() * gear_ratio[i]) + if(m_speed <= m_characteristic->getEngineMaxSpeed() * gear_ratio[i]) { - assert(!isnan(m_kart_properties->getMaxPower())); - assert(!isnan(m_kart_properties->getGearPowerIncrease()[i])); - return m_kart_properties->getMaxPower() - * m_kart_properties->getGearPowerIncrease()[i] + assert(!isnan(m_characteristic->getEnginePower())); + assert(!isnan(m_characteristic->getGearPowerIncrease()[i])); + return m_characteristic->getEnginePower() + * m_characteristic->getGearPowerIncrease()[i] + add_force; } } - assert(!isnan(m_kart_properties->getMaxPower())); - return m_kart_properties->getMaxPower() + add_force * 2; + assert(!isnan(m_characteristic->getEnginePower())); + return m_characteristic->getEnginePower() + add_force * 2; } // getActualWheelForce @@ -1165,16 +1191,16 @@ void Kart::update(float dt) // When the kart is jumping, linear damping reduces the falling speed // of a kart so much that it can appear to be in slow motion. So // disable linear damping if a kart is in the air - m_body->setDamping(0, m_kart_properties->getChassisAngularDamping()); + m_body->setDamping(0, m_characteristic->getStabilityChassisAngularDamping()); } else { - m_body->setDamping(m_kart_properties->getChassisLinearDamping(), - m_kart_properties->getChassisAngularDamping()); + m_body->setDamping(m_characteristic->getStabilityChassisLinearDamping(), + m_characteristic->getStabilityChassisAngularDamping()); } //m_wheel_rotation gives the rotation around the X-axis - m_wheel_rotation_dt = m_speed*dt / m_kart_properties->getWheelRadius(); + m_wheel_rotation_dt = m_speed*dt / m_characteristic->getWheelsRadius(); m_wheel_rotation += m_wheel_rotation_dt; m_wheel_rotation = fmodf(m_wheel_rotation, 2*M_PI); @@ -1363,7 +1389,7 @@ void Kart::update(float dt) // Jump if either the jump is estimated to be long enough, or // the texture has the jump property set. - if (t > getKartProperties()->getJumpAnimationTime() || + if (t > m_characteristic->getJumpAnimationTime() || last_m->isJumpTexture()) { m_kart_model->setAnimation(KartModel::AF_JUMP_START); @@ -1669,23 +1695,23 @@ void Kart::handleZipper(const Material *material, bool play_sound) material->getZipperParameter(&max_speed_increase, &duration, &speed_gain, &fade_out_time, &engine_force); if(max_speed_increase<0) - max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease(); + max_speed_increase = m_characteristic->getZipperMaxSpeedIncrease(); if(duration<0) - duration = m_kart_properties->getZipperTime(); + duration = m_characteristic->getZipperDuration(); if(speed_gain<0) - speed_gain = m_kart_properties->getZipperSpeedGain(); + speed_gain = m_characteristic->getZipperSpeedGain(); if(fade_out_time<0) - fade_out_time = m_kart_properties->getZipperFadeOutTime(); + fade_out_time = m_characteristic->getZipperFadeOutTime(); if(engine_force<0) - engine_force = m_kart_properties->getZipperForce(); + engine_force = m_characteristic->getZipperForce(); } else { - max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease(); - duration = m_kart_properties->getZipperTime(); - speed_gain = m_kart_properties->getZipperSpeedGain(); - fade_out_time = m_kart_properties->getZipperFadeOutTime(); - engine_force = m_kart_properties->getZipperForce(); + max_speed_increase = m_characteristic->getZipperMaxSpeedIncrease(); + duration = m_characteristic->getZipperDuration(); + speed_gain = m_characteristic->getZipperSpeedGain(); + fade_out_time = m_characteristic->getZipperFadeOutTime(); + engine_force = m_characteristic->getZipperForce(); } // Ignore a zipper that's activated while braking if(m_controls.m_brake || m_speed<0) return; @@ -1723,7 +1749,7 @@ void Kart::updateNitro(float dt) { return; } - m_collected_energy -= dt * m_kart_properties->getNitroConsumption(); + m_collected_energy -= dt * m_characteristic->getNitroConsumption(); if (m_collected_energy < 0) { m_collected_energy = 0; @@ -1733,10 +1759,10 @@ void Kart::updateNitro(float dt) if (increase_speed) { m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO, - m_kart_properties->getNitroMaxSpeedIncrease(), - getCharacteristic()->getNitroEngineForce(), - m_kart_properties->getNitroDuration(), - m_kart_properties->getNitroFadeOutTime()); + m_characteristic->getNitroMaxSpeedIncrease(), + m_characteristic->getNitroEngineForce(), + m_characteristic->getNitroDuration(), + m_characteristic->getNitroFadeOutTime()); } } // updateNitro @@ -2041,7 +2067,7 @@ void Kart::updatePhysics(float dt) if(!m_has_started && m_controls.m_accel) { m_has_started = true; - float f = m_kart_properties->getStartupBoost(); + float f = getStartupBoost(); m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER, 0.9f*f, f, /*engine_force*/200.0f, @@ -2109,11 +2135,11 @@ void Kart::updatePhysics(float dt) // Only apply if near ground instead of purely based on speed avoiding // the "parachute on top" look. const Vec3 &v = m_body->getLinearVelocity(); - if(/*isNearGround() &&*/ v.getY() < - m_kart_properties->getSuspensionTravelCM()*0.01f*60) + if(/*isNearGround() &&*/ v.getY() < - m_characteristic->getSuspensionTravelCm()*0.01f*60) { Vec3 v_clamped = v; // clamp the speed to 99% of the maxium falling speed. - v_clamped.setY(-m_kart_properties->getSuspensionTravelCM()*0.01f*60 * 0.99f); + v_clamped.setY(-m_characteristic->getSuspensionTravelCm()*0.01f*60 * 0.99f); //m_body->setLinearVelocity(v_clamped); } @@ -2239,8 +2265,8 @@ void Kart::updateEnginePowerAndBrakes(float dt) m_brake_time += dt; // Apply the brakes - include the time dependent brake increase float f = 1 + m_brake_time - * m_kart_properties->getBrakeTimeIncrease(); - m_vehicle->setAllBrakes(m_kart_properties->getBrakeFactor() * f); + * m_characteristic->getEngineBrakeTimeIncrease(); + m_vehicle->setAllBrakes(m_characteristic->getEngineBrakeFactor() * f); } else // m_speed < 0 { @@ -2248,7 +2274,7 @@ void Kart::updateEnginePowerAndBrakes(float dt) // going backward, apply reverse gear ratio (unless he goes // too fast backwards) if ( -m_speed < m_max_speed->getCurrentMaxSpeed() - *m_kart_properties->getMaxSpeedReverseRatio()) + *m_characteristic->getEngineMaxSpeedReverseRatio()) { // The backwards acceleration is artificially increased to // allow players to get "unstuck" quicker if they hit e.g. @@ -2509,7 +2535,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, { // fabs(speed) is important, otherwise the negative number will // become a huge unsigned number in the particle scene node! - nitro_frac = fabsf(getSpeed())/(m_kart_properties->getMaxSpeed()); + nitro_frac = fabsf(getSpeed()) / (m_characteristic->getEngineMaxSpeed()); // The speed of the kart can be higher (due to powerups) than // the normal maximum speed of the kart. if(nitro_frac>1.0f) nitro_frac = 1.0f; @@ -2524,7 +2550,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, // leaning might get less if a kart gets a special that increases // its maximum speed, but not the current speed (by much). On the // other hand, that ratio can often be greater than 1. - float speed_frac = m_speed / m_kart_properties->getMaxSpeed(); + float speed_frac = m_speed / m_characteristic->getEngineMaxSpeed(); if(speed_frac>1.0f) speed_frac = 1.0f; else if (speed_frac < 0.0f) // no leaning when backwards driving @@ -2580,7 +2606,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, float lean_height = tan(fabsf(m_current_lean)) * getKartWidth()*0.5f; float heading = m_skidding->getVisualSkidRotation(); - float xx = fabsf(m_speed)* getKartProperties()->getDownwardImpulseFactor()*0.0006f; + float xx = fabsf(m_speed) * m_characteristic->getStabilityDownwardImpulseFactor() * 0.0006f; Vec3 center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset() + lean_height +m_graphical_y_offset+xx, 0); diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index a08046595..6d8bce9b4 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -259,6 +259,8 @@ public: float fade_in_time); virtual float getSpeedIncreaseTimeLeft(unsigned int category) const; virtual void collectedItem(Item *item, int random_attachment); + virtual float getStartupBoost() const; + virtual const Material *getMaterial() const; virtual const Material *getLastMaterial() const; /** Returns the pitch of the terrain depending on the heading. */ @@ -339,10 +341,7 @@ public: /** Returns the time till full steering is reached for this kart. * \param steer Current steer value (must be >=0), on which the time till * full steer depends. */ - virtual float getTimeFullSteer(float steer) const - { - return m_kart_properties->getTimeFullSteer(steer); - } // getTimeFullSteer + virtual float getTimeFullSteer(float steer) const; // ------------------------------------------------------------------------ /** Returns the maximum steering angle for this kart, which depends on the * speed. */ diff --git a/src/karts/kart_gfx.cpp b/src/karts/kart_gfx.cpp index 2bbe6b134..1e9dcf5e7 100644 --- a/src/karts/kart_gfx.cpp +++ b/src/karts/kart_gfx.cpp @@ -24,6 +24,7 @@ #include "graphics/particle_emitter.hpp" #include "graphics/particle_kind.hpp" #include "graphics/particle_kind_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart.hpp" @@ -321,7 +322,7 @@ void KartGFX::updateTerrain(const ParticleKind *pk) if (skidding > 1.0f && on_ground) rate = fabsf(m_kart->getControls().m_steer) > 0.8 ? skidding - 1 : 0; else if (speed >= 0.5f && on_ground) - rate = speed/m_kart->getKartProperties()->getMaxSpeed(); + rate = speed/m_kart->getCharacteristic()->getEngineMaxSpeed(); else { pe->setCreationRateAbsolute(0); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 017200979..0b4887318 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -73,53 +73,21 @@ KartProperties::KartProperties(const std::string &filename) m_shadow_x_offset = 0.0f; m_shadow_z_offset = 0.0f; m_characteristic = NULL; + m_combined_characteristic = NULL; m_groups.clear(); m_custom_sfx_id.resize(SFXManager::NUM_CUSTOMS); // Set all other values to undefined, so that it can later be tested // if everything is defined properly. - m_mass = m_brake_factor = m_brake_time_increase = - m_time_reset_steer = m_nitro_consumption = m_nitro_engine_force = - m_nitro_small_container = m_nitro_big_container = m_nitro_max = - m_nitro_max_speed_increase = m_nitro_duration = m_nitro_fade_out_time = - m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_base = - m_wheel_damping_compression = m_friction_slip = m_roll_influence = - m_wheel_radius = m_chassis_linear_damping = m_max_suspension_force = - m_chassis_angular_damping = m_suspension_rest = - m_max_speed_reverse_ratio = m_rescue_vert_offset = - m_collision_terrain_impulse = m_collision_impulse = m_restitution = - m_collision_impulse_time = m_suspension_travel_cm = - m_track_connection_accel = m_rubber_band_max_length = - m_rubber_band_force = m_rubber_band_duration = - m_rubber_band_speed_increase = m_rubber_band_fade_out_time = - m_zipper_time = m_zipper_force = m_zipper_speed_gain = - m_zipper_max_speed_increase = m_zipper_fade_out_time = - m_slipstream_length = m_slipstream_width = m_slipstream_collect_time = - m_slipstream_use_time = m_slipstream_add_power = - m_slipstream_min_speed = m_slipstream_max_speed_increase = - m_slipstream_duration = m_slipstream_fade_out_time = - m_camera_distance = m_camera_forward_up_angle = - m_camera_backward_up_angle = m_explosion_invulnerability_time = - m_rescue_time = m_rescue_height = m_explosion_time = - m_explosion_radius = m_max_lean = m_lean_speed = - m_swatter_distance2 = m_swatter_duration = m_squash_slowdown = - m_squash_duration = m_downward_impulse_factor = - m_bubblegum_fade_in_time = m_bubblegum_speed_fraction = - m_bubblegum_time = m_bubblegum_torque = m_jump_animation_time = - m_smooth_flying_impulse = m_physical_wheel_position = - m_graphical_y_offset = - UNDEFINED; - - m_engine_power.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED); - m_max_speed.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED); - m_plunger_in_face_duration.resize(RaceManager::DIFFICULTY_COUNT, - UNDEFINED); + m_wheel_base = m_friction_slip = m_collision_terrain_impulse = + m_collision_impulse = m_restitution = m_collision_impulse_time = + m_max_lean = m_lean_speed = m_physical_wheel_position = + m_graphical_y_offset = UNDEFINED; m_terrain_impulse_type = IMPULSE_NONE; m_gravity_center_shift = Vec3(UNDEFINED); m_bevel_factor = Vec3(UNDEFINED); - m_exp_spring_response = false; m_prevent_chassis_in_terrain = false; m_version = 0; m_color = video::SColor(255, 0, 0, 0); @@ -153,6 +121,8 @@ KartProperties::~KartProperties() delete m_skidding_properties; if (m_characteristic) delete m_characteristic; + if (m_combined_characteristic) + delete m_combined_characteristic; for(unsigned int i=0; im_characteristic; + // Combine the characteristics for this object. We can't copy it because + // this object has other pointers (to m_characteristic). + combineCharacteristics(); } for(unsigned int i=0; igetLength() - 2*m_wheel_radius); + // turn angle at certain speeds) is shortened by 2 * wheel_radius + m_wheel_base = fabsf(m_kart_model->getLength() - 2 * + m_combined_characteristic->getWheelsRadius()); // Now convert the turn radius into turn angle: for(unsigned int i=0; iaddCharacteristic(kart_properties_manager-> + getBaseCharacteristic()); + m_combined_characteristic->addCharacteristic(m_characteristic); +} // combineCharacteristics + //----------------------------------------------------------------------------- /** Actually reads in the data from the xml file. * \param root Root of the xml tree. @@ -378,22 +364,6 @@ void KartProperties::getAllData(const XMLNode * root) m_ai_properties[RaceManager::DIFFICULTY_BEST]->load(best); } - if(const XMLNode *suspension_node = root->getNode("suspension")) - { - suspension_node->get("stiffness", &m_suspension_stiffness); - suspension_node->get("rest", &m_suspension_rest ); - suspension_node->get("travel-cm", &m_suspension_travel_cm); - suspension_node->get("exp-spring-response", &m_exp_spring_response ); - suspension_node->get("max-force", &m_max_suspension_force); - } - - if(const XMLNode *wheels_node = root->getNode("wheels")) - { - wheels_node->get("damping-relaxation", &m_wheel_damping_relaxation ); - wheels_node->get("damping-compression", &m_wheel_damping_compression); - wheels_node->get("radius", &m_wheel_radius ); - } - if(const XMLNode *speed_weighted_objects_node = root->getNode("speed-weighted-objects")) { m_speed_weighted_object_properties.loadFromXMLNode(speed_weighted_objects_node); @@ -402,21 +372,6 @@ void KartProperties::getAllData(const XMLNode * root) if(const XMLNode *friction_node = root->getNode("friction")) friction_node->get("slip", &m_friction_slip); - if(const XMLNode *stability_node = root->getNode("stability")) - { - stability_node->get("roll-influence", - &m_roll_influence ); - stability_node->get("chassis-linear-damping", - &m_chassis_linear_damping ); - stability_node->get("chassis-angular-damping", - &m_chassis_angular_damping); - stability_node->get("downward-impulse-factor", - &m_downward_impulse_factor); - stability_node->get("track-connection-accel", - &m_track_connection_accel ); - stability_node->get("smooth-flying-impulse", &m_smooth_flying_impulse); - } - if(const XMLNode *collision_node = root->getNode("collision")) { collision_node->get("impulse", &m_collision_impulse ); @@ -442,25 +397,18 @@ void KartProperties::getAllData(const XMLNode * root) } } + if(const XMLNode *turn_node = root->getNode("turn")) + { + turn_node->get("turn-radius", &m_turn_angle_at_speed ); + // For now store the turn radius in turn angle, the correct + // value can only be determined later in ::load + } + //TODO: wheel front right and wheel front left is not loaded, yet is //TODO: listed as an attribute in the xml file after wheel-radius //TODO: same goes for their rear equivalents - if(const XMLNode *jump_node= root->getNode("jump")) - { - jump_node->get("animation-time", &m_jump_animation_time); - } - - if(const XMLNode *camera_node= root->getNode("camera")) - { - camera_node->get("distance", &m_camera_distance); - camera_node->get("forward-up-angle", &m_camera_forward_up_angle); - m_camera_forward_up_angle *= DEGREE_TO_RAD; - camera_node->get("backward-up-angle", &m_camera_backward_up_angle); - m_camera_backward_up_angle *= DEGREE_TO_RAD; - } - if(const XMLNode *sounds_node= root->getNode("sounds")) { std::string s; @@ -506,138 +454,12 @@ void KartProperties::getAllData(const XMLNode * root) #endif } // if sounds-node exist - if(const XMLNode *nitro_node = root->getNode("nitro")) - { - nitro_node->get("consumption", &m_nitro_consumption ); - nitro_node->get("small-container", &m_nitro_small_container ); - nitro_node->get("big-container", &m_nitro_big_container ); - nitro_node->get("max-speed-increase", &m_nitro_max_speed_increase); - nitro_node->get("engine-force", &m_nitro_engine_force ); - nitro_node->get("duration", &m_nitro_duration ); - nitro_node->get("fade-out-time", &m_nitro_fade_out_time ); - nitro_node->get("max", &m_nitro_max ); - nitro_node->get("min-consumption-time", &m_nitro_min_consumption ); - } - - if(const XMLNode *bubble_node = root->getNode("bubblegum")) - { - bubble_node->get("time", &m_bubblegum_time ); - bubble_node->get("speed-fraction", &m_bubblegum_speed_fraction); - bubble_node->get("fade-in-time", &m_bubblegum_fade_in_time ); - bubble_node->get("torque", &m_bubblegum_torque ); - } - - if(const XMLNode *rescue_node = root->getNode("rescue")) - { - rescue_node->get("vert-offset", &m_rescue_vert_offset); - rescue_node->get("time", &m_rescue_time ); - rescue_node->get("height", &m_rescue_height ); - } - - if(const XMLNode *explosion_node = root->getNode("explosion")) - { - explosion_node->get("time", &m_explosion_time ); - explosion_node->get("radius", &m_explosion_radius); - explosion_node->get("invulnerability-time", - &m_explosion_invulnerability_time); - } - if(const XMLNode *skid_node = root->getNode("skid")) { m_skidding_properties->load(skid_node); } - if(const XMLNode *slipstream_node = root->getNode("slipstream")) - { - slipstream_node->get("length", &m_slipstream_length ); - slipstream_node->get("width", &m_slipstream_width ); - slipstream_node->get("collect-time", &m_slipstream_collect_time ); - slipstream_node->get("use-time", &m_slipstream_use_time ); - slipstream_node->get("add-power", &m_slipstream_add_power ); - slipstream_node->get("min-speed", &m_slipstream_min_speed ); - slipstream_node->get("max-speed-increase", - &m_slipstream_max_speed_increase); - slipstream_node->get("duration", &m_slipstream_duration ); - slipstream_node->get("fade-out-time",&m_slipstream_fade_out_time ); - } - - if(const XMLNode *turn_node = root->getNode("turn")) - { - turn_node->get("time-full-steer", &m_time_full_steer ); - turn_node->get("time-reset-steer", &m_time_reset_steer ); - turn_node->get("turn-radius", &m_turn_angle_at_speed ); - // For now store the turn radius in turn angle, the correct - // value can only be determined later in ::load - } - - if(const XMLNode *engine_node = root->getNode("engine")) - { - engine_node->get("brake-factor", &m_brake_factor); - engine_node->get("brake-time-increase", &m_brake_time_increase); - engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio); - engine_node->get("power", &m_engine_power); - if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT) - { - Log::fatal("[KartProperties]", - "Incorrect engine-power specifications for kart '%s'", - getIdent().c_str()); - } - engine_node->get("max-speed", &m_max_speed); - if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT) - { - Log::fatal("[KartProperties]", - "Incorrect max-speed specifications for kart '%s'", - getIdent().c_str()); - } - } // if getNode("engine") - - if(const XMLNode *gear_node = root->getNode("gear")) - { - gear_node->get("switch-ratio", &m_gear_switch_ratio ); - gear_node->get("power-increase", &m_gear_power_increase); - } - - if(const XMLNode *mass_node = root->getNode("mass")) - mass_node->get("value", &m_mass); - - if(const XMLNode *plunger_node= root->getNode("plunger")) - { - plunger_node->get("band-max-length", &m_rubber_band_max_length ); - plunger_node->get("band-force", &m_rubber_band_force ); - plunger_node->get("band-duration", &m_rubber_band_duration ); - plunger_node->get("band-speed-increase",&m_rubber_band_speed_increase); - plunger_node->get("band-fade-out-time", &m_rubber_band_fade_out_time ); - plunger_node->get("in-face-time", &m_plunger_in_face_duration); - if(m_plunger_in_face_duration.size()!=RaceManager::DIFFICULTY_COUNT) - { - Log::fatal("KartProperties", - "Invalid plunger in-face-time specification."); - } - } - - if(const XMLNode *zipper_node= root->getNode("zipper")) - { - zipper_node->get("time", &m_zipper_time ); - zipper_node->get("fade-out-time", &m_zipper_fade_out_time ); - zipper_node->get("force", &m_zipper_force ); - zipper_node->get("speed-gain", &m_zipper_speed_gain ); - zipper_node->get("max-speed-increase", &m_zipper_max_speed_increase); - } - - if(const XMLNode *swatter_node= root->getNode("swatter")) - { - swatter_node->get("duration", &m_swatter_duration ); - swatter_node->get("squash-duration", &m_squash_duration ); - swatter_node->get("squash-slowdown", &m_squash_slowdown ); - if(swatter_node->get("distance", &m_swatter_distance2) ) - { - // Avoid squaring if distance is not defined, so that - // distance2 remains UNDEFINED (which is a negative value) - m_swatter_distance2 *= m_swatter_distance2; - } - } - if(const XMLNode *lean_node= root->getNode("lean")) { lean_node->get("max", &m_max_lean ); @@ -646,12 +468,6 @@ void KartProperties::getAllData(const XMLNode * root) m_lean_speed *= DEGREE_TO_RAD; } - if(const XMLNode *startup_node= root->getNode("startup")) - { - startup_node->get("time", &m_startup_times); - startup_node->get("boost", &m_startup_boost); - } - if(const XMLNode *graphics_node = root->getNode("graphics")) { graphics_node->get("y-offset", &m_graphical_y_offset); @@ -671,122 +487,22 @@ void KartProperties::getAllData(const XMLNode * root) */ void KartProperties::checkAllSet(const std::string &filename) { - if(m_gear_switch_ratio.size()==0) - { - Log::fatal("[KartProperties]", - "Missing default value for 'gear-switch-ratio' in '%s'.", - filename.c_str()); - } - if(m_gear_power_increase.size()==0) - { - Log::fatal("[KartProperties]", - "Missing default value for 'gear-power-increase' in '%s'.", - filename.c_str()); - } - if(m_gear_switch_ratio.size()!=m_gear_power_increase.size()) { - Log::error("KartProperties", - "Number of entries for 'gear-switch-ratio' and " - "'gear-power-increase"); - Log::fatal("KartProperties", "in '%s' must be equal.", - filename.c_str()); - } - if(m_startup_boost.size()!=m_startup_times.size()) - { - Log::error("[KartProperties]", - "Number of entried for 'startup times' and 'startup-boost"); - Log::fatal("KartProperties", "must be identical."); - } #define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \ Log::fatal("[KartProperties]", \ "Missing default value for '%s' in '%s'.", \ strA,filename.c_str()); \ } - CHECK_NEG(m_mass, "mass" ); - CHECK_NEG(m_time_reset_steer, "turn time-reset-steer" ); - CHECK_NEG(m_wheel_damping_relaxation, "wheels damping-relaxation" ); - CHECK_NEG(m_wheel_damping_compression, "wheels damping-compression" ); - CHECK_NEG(m_wheel_radius, "wheels radius" ); CHECK_NEG(m_friction_slip, "friction slip" ); - CHECK_NEG(m_roll_influence, "stability roll-influence" ); - CHECK_NEG(m_chassis_linear_damping, "stability chassis-linear-damping" ); - CHECK_NEG(m_chassis_angular_damping, "stability chassis-angular-damping"); - CHECK_NEG(m_downward_impulse_factor, "stability downward-impulse-factor"); - CHECK_NEG(m_track_connection_accel, "stability track-connection-accel" ); - CHECK_NEG(m_smooth_flying_impulse, "smooth-flying-impulse" ); - CHECK_NEG(m_max_speed_reverse_ratio, "engine max-speed-reverse-ratio"); - CHECK_NEG(m_brake_factor, "engine brake-factor" ); - CHECK_NEG(m_brake_time_increase, "engine brake-time-increase" ); - CHECK_NEG(m_suspension_stiffness, "suspension stiffness" ); - CHECK_NEG(m_suspension_rest, "suspension rest" ); - CHECK_NEG(m_suspension_travel_cm, "suspension travel-cm" ); - CHECK_NEG(m_max_suspension_force, "suspension max-force" ); + CHECK_NEG(m_collision_terrain_impulse, "collision terrain-impulse" ); CHECK_NEG(m_collision_impulse, "collision impulse" ); CHECK_NEG(m_collision_impulse_time, "collision impulse-time" ); CHECK_NEG(m_restitution, "collision restitution" ); - CHECK_NEG(m_collision_terrain_impulse, "collision terrain-impulse" ); - CHECK_NEG(m_bevel_factor.getX(), "collision bevel-factor" ); - CHECK_NEG(m_bevel_factor.getY(), "collision bevel-factor" ); - CHECK_NEG(m_bevel_factor.getZ(), "collision bevel-factor" ); CHECK_NEG(m_physical_wheel_position, "collision physical-wheel-position"); - CHECK_NEG(m_rubber_band_max_length, "plunger band-max-length" ); - CHECK_NEG(m_rubber_band_force, "plunger band-force" ); - CHECK_NEG(m_rubber_band_duration, "plunger band-duration" ); - CHECK_NEG(m_rubber_band_speed_increase, "plunger band-speed-increase" ); - CHECK_NEG(m_rubber_band_fade_out_time, "plunger band-fade-out-time" ); - CHECK_NEG(m_zipper_time, "zipper-time" ); - CHECK_NEG(m_zipper_fade_out_time, "zipper-fade-out-time" ); - CHECK_NEG(m_zipper_force, "zipper-force" ); - CHECK_NEG(m_zipper_speed_gain, "zipper-speed-gain" ); - CHECK_NEG(m_zipper_max_speed_increase, "zipper-max-speed-increase" ); - CHECK_NEG(m_slipstream_length, "slipstream length" ); - CHECK_NEG(m_slipstream_width, "slipstream width" ); - CHECK_NEG(m_slipstream_collect_time, "slipstream collect-time" ); - CHECK_NEG(m_slipstream_use_time, "slipstream use-time" ); - CHECK_NEG(m_slipstream_add_power, "slipstream add-power" ); - CHECK_NEG(m_slipstream_min_speed, "slipstream min-speed" ); - CHECK_NEG(m_slipstream_max_speed_increase, - "slipstream max-speed-increase" ); - CHECK_NEG(m_slipstream_duration, "slipstream duration" ); - CHECK_NEG(m_slipstream_fade_out_time, "slipstream fade-out-time" ); - CHECK_NEG(m_camera_distance, "camera distance" ); - CHECK_NEG(m_camera_forward_up_angle, "camera forward-up-angle" ); - CHECK_NEG(m_camera_backward_up_angle, "camera forward-up-angle" ); - CHECK_NEG(m_nitro_consumption, "nitro consumption" ); - CHECK_NEG(m_nitro_big_container, "nitro big-container" ); - CHECK_NEG(m_nitro_small_container, "nitro small-container" ); - CHECK_NEG(m_nitro_max_speed_increase, "nitro max-speed-increase" ); - CHECK_NEG(m_nitro_engine_force, "nitro engine-force" ); - CHECK_NEG(m_nitro_duration, "nitro duration" ); - CHECK_NEG(m_nitro_fade_out_time, "nitro fade-out-time" ); - CHECK_NEG(m_nitro_max, "nitro max" ); - CHECK_NEG(m_bubblegum_time, "bubblegum time" ); - CHECK_NEG(m_bubblegum_speed_fraction, "bubblegum speed-fraction" ); - CHECK_NEG(m_bubblegum_fade_in_time , "bubblegum fade-in-time" ); - CHECK_NEG(m_bubblegum_torque, "bubblegum torque" ); - CHECK_NEG(m_swatter_distance2, "swatter distance" ); - CHECK_NEG(m_swatter_duration, "swatter duration" ); - CHECK_NEG(m_squash_duration, "swatter squash-duration" ); - CHECK_NEG(m_squash_slowdown, "swatter squash-slowdown" ); CHECK_NEG(m_max_lean, "lean max" ); CHECK_NEG(m_lean_speed, "lean speed" ); - - CHECK_NEG(m_rescue_height, "rescue height" ); - CHECK_NEG(m_rescue_time, "rescue time" ); - CHECK_NEG(m_rescue_vert_offset, "rescue vert-offset" ); - CHECK_NEG(m_explosion_time, "explosion time" ); - CHECK_NEG(m_explosion_invulnerability_time, - "explosion invulnerability-time"); - CHECK_NEG(m_explosion_radius, "explosion radius" ); CHECK_NEG(m_graphical_y_offset, "graphics y-offset" ); - for(unsigned int i=RaceManager::DIFFICULTY_FIRST; - i<=RaceManager::DIFFICULTY_LAST; i++) - { - CHECK_NEG(m_max_speed[i], "engine maximum-speed[0]"); - CHECK_NEG(m_engine_power[i], "engine power" ); - CHECK_NEG(m_plunger_in_face_duration[i],"plunger in-face-time"); - } m_speed_weighted_object_properties.checkAllSet(); @@ -815,7 +531,13 @@ bool KartProperties::operator<(const KartProperties &other) const const AbstractCharacteristic* KartProperties::getCharacteristic() const { return m_characteristic; -} +} // getCharacteristic + +// ---------------------------------------------------------------------------- +const AbstractCharacteristic* KartProperties::getCombinedCharacteristic() const +{ + return m_combined_characteristic; +} // getCombinedCharacteristic // ---------------------------------------------------------------------------- bool KartProperties::isInGroup(const std::string &group) const @@ -823,32 +545,3 @@ bool KartProperties::isInGroup(const std::string &group) const return std::find(m_groups.begin(), m_groups.end(), group) != m_groups.end(); } // isInGroups - -// ---------------------------------------------------------------------------- -/** Called the first time a kart accelerates after 'ready-set-go'. It searches - * through m_startup_times to find the appropriate slot, and returns the - * speed-boost from the corresponding entry in m_startup_boost. - * If the kart started too slow (i.e. slower than the longest time in - * m_startup_times, it returns 0. - */ -float KartProperties::getStartupBoost() const -{ - float t = World::getWorld()->getTime(); - for(unsigned int i=0; i m_engine_power; - - /** Braking factor * engine_power braking force. */ - float m_brake_factor; - - /** Brake_time * m_brake_time_increase will increase the break time - * over time. */ - float m_brake_time_increase; - - /** Time for player karts to reach full steer angle. */ - InterpolationArray m_time_full_steer; - - /** Time for steering to go back to zero from full steer. */ - float m_time_reset_steer; - - /** A torque impulse applied to keep the kart parallel to the ground. */ - float m_smooth_flying_impulse;; - /** The turn angle depending on speed. */ InterpolationArray m_turn_angle_at_speed; @@ -167,39 +148,6 @@ private: */ float m_physical_wheel_position; - /** Time a kart is moved upwards after when it is rescued. */ - float m_rescue_time; - - /** Distance the kart is raised before dropped. */ - float m_rescue_height; - - /** Time an animated explosion is shown. Longer = more delay for kart. */ - float m_explosion_time; - - /** How far away from an explosion karts will still be affected. */ - float m_explosion_radius; - - /** How long a kart is invulnerable after it is hit by an explosion. */ - float m_explosion_invulnerability_time; - - /** Duration a zipper is active. */ - float m_zipper_time; - - /** Fade out time for a zipper. */ - float m_zipper_fade_out_time; - - /** Additional force added to the acceleration. */ - float m_zipper_force; - - /** Initial one time speed gain. */ - float m_zipper_speed_gain; - - /** Absolute increase of the kart's maximum speed (in m/s). */ - float m_zipper_max_speed_increase; - - /** Vertical offset after rescue. */ - float m_rescue_vert_offset; - /** Minimum time during which nitro is consumed when pressing * the nitro key (to prevent using in very small bursts) */ @@ -210,8 +158,6 @@ private: /** Filename of the wheel models. */ std::string m_wheel_filename[4]; - /** Radius of the graphical wheels. */ - float m_wheel_graphics_radius[4]; /** An additional Y offset added to the y position of the graphical * chassis. Useful for karts that don't have enough space for suspension * compression. */ @@ -221,58 +167,8 @@ private: bool m_prevent_chassis_in_terrain; /** If the kart is supposed to have random wheel rotation at start. */ bool m_has_rand_wheels; - /** Max. length of plunger rubber band. */ - float m_rubber_band_max_length; - /** Force of an attached rubber band. */ - /** Duration a rubber band works. */ - float m_rubber_band_force; - /** How long the rubber band will fly. */ - float m_rubber_band_duration; - /** Increase of maximum speed of the kart when the rubber band pulls. */ - float m_rubber_band_speed_increase; - /** Fade out time when the rubber band is removed. */ - float m_rubber_band_fade_out_time; - /**Duration of plunger in face depending on difficulty. */ - std::vector m_plunger_in_face_duration; /** Wheel base of the kart. */ float m_wheel_base; - /** Nitro consumption. */ - float m_nitro_consumption; - /** Nitro amount for small bottle. */ - float m_nitro_small_container; - /** Nitro amount for big bittle. */ - float m_nitro_big_container; - /** How much the speed of a kart might exceed its maximum speed (in m/s). */ - float m_nitro_max_speed_increase; - /** Additional engine force to affect the kart. */ - float m_nitro_engine_force; - /** How long the increased nitro max speed will be valid after - * the kart stops using nitro (and the fade-out-time starts). */ - float m_nitro_duration; - /** Duration during which the increased maximum speed - * due to nitro fades out. */ - float m_nitro_fade_out_time; - /** Maximum nitro a kart can collect. */ - float m_nitro_max; - /** Bubble gum diration. */ - float m_bubblegum_time; - /** Torque to add when a bubble gum was hit in order to make the kart go - * sideways a bit. */ - float m_bubblegum_torque; - /** Fraction of top speed that can be reached maximum after hitting a - * bubble gum. */ - float m_bubblegum_speed_fraction; - /** How long to fade in the slowdown for a bubble gum. */ - float m_bubblegum_fade_in_time; - /** Square of the maximum distance a swatter can operate. */ - float m_swatter_distance2; - /** How long the swatter lasts. */ - float m_swatter_duration; - /** How long a kart will remain squashed. */ - float m_squash_duration; - /** The slowdown to apply while a kart is squashed. The new maxspeed - * is max_speed*m_squash_slowdown. */ - float m_squash_slowdown; /** The maximum roll a kart graphics should show when driving in a fast * curve. This is read in as degrees, but stored in radians. */ @@ -282,58 +178,19 @@ private: * (in radians/second). */ float m_lean_speed; - /** How long a jump must be in order to trigger the jump animation. */ - float m_jump_animation_time; - /** Engine sound effect. */ std::string m_engine_sfx_type; // bullet physics data // ------------------- - float m_suspension_stiffness; - float m_wheel_damping_relaxation; - float m_wheel_damping_compression; - float m_max_suspension_force; float m_friction_slip; - float m_roll_influence; - float m_wheel_radius; /** Parameters for the speed-weighted objects */ SpeedWeightedObject::Properties m_speed_weighted_object_properties; - /** An impulse pushing the kart down which is proportional to speed. So - * the actual impulse is speed * m_downward_impulse_factor. Set it to - * 0 to disable completely. Based on - * http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=6059\ - * &p=21240&hilit=vehicle#p21240 */ - float m_downward_impulse_factor; - - /** Artifical acceleration that pulls a kart down onto the track if one - * axis loses contact with the track. */ - float m_track_connection_accel; - - /** Linear damping of the chassis to prevent it from toppling over. */ - float m_chassis_linear_damping; - - /** Angular damping to prevent it from turning too easily. */ - float m_chassis_angular_damping; - - /** The maximum speed at each difficulty. */ - std::vector m_max_speed; - - float m_max_speed_reverse_ratio; - /** Shift of center of gravity. */ Vec3 m_gravity_center_shift; - /** The suspension reaction is dampened to reach an exponential behaviour. - * See http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\ - * &p=25236&hilit=vehicle#p25236 for details. */ - bool m_exp_spring_response; - - float m_suspension_rest; - float m_suspension_travel_cm; - public: /** STK can add an impulse to push karts away from the track in case * of a kart-track collision. This can be done in two ways: either @@ -359,57 +216,10 @@ private: /** The restitution factor to be used in collsions for this kart. */ float m_restitution; - /** How far behind a kart slipstreaming is effective. */ - float m_slipstream_length; - /** How wide the slipstream area is at the end. */ - float m_slipstream_width; - /** Time after which sstream gives a bonus. */ - float m_slipstream_collect_time; - /** Time slip-stream bonus is effective. */ - float m_slipstream_use_time; - /** Additional power due to sstreaming. */ - float m_slipstream_add_power; - /** Minimum speed for slipstream to take effect. */ - float m_slipstream_min_speed; - /** How much the speed of the kart might exceed its - * normal maximum speed. */ - float m_slipstream_max_speed_increase; - /** How long the higher speed lasts after slipstream stopped working. */ - float m_slipstream_duration; - /** How long the slip stream speed increase will gradually be reduced. */ - float m_slipstream_fade_out_time; - - /** Distance of normal camera from kart. */ - float m_camera_distance; - - /** Up angle of the camera in relation to the pitch of the kart when - * driving forwards. */ - float m_camera_forward_up_angle; - - /** Up angle of the camera in relation to the pitch of the kart when - * driving backwards. */ - float m_camera_backward_up_angle; - - /** The following two vectors define at what ratio of the maximum speed what - * gear is selected. E.g. 0.25 means: if speed <=0.25*maxSpeed --> gear 1, - * 0.5 means: if speed <=0.5 *maxSpeed --> gear 2 */ - std::vector m_gear_switch_ratio; - /** This vector contains the increase in max power (to simulate different - * gears), e.g. 2.5 as first entry means: 2.5*maxPower in gear 1. See - m_gear_switch_ratio). */ - std::vector m_gear_power_increase; - - /** If the kart starts within the specified time at index I after 'go', - * it receives the speed boost from m_startup_boost[I]. */ - std::vector m_startup_times; - - /** The startup boost is the kart starts fast enough. */ - std::vector m_startup_boost; - void load (const std::string &filename, const std::string &node); - + void combineCharacteristics(); public: /** Returns the string representation of a per-player difficulty. */ @@ -420,13 +230,18 @@ public: void copyFrom (const KartProperties *source); void getAllData (const XMLNode * root); void checkAllSet (const std::string &filename); - float getStartupBoost () const; bool isInGroup (const std::string &group) const; bool operator<(const KartProperties &other) const; // ------------------------------------------------------------------------ /** Returns the characteristics for this kart. */ const AbstractCharacteristic* getCharacteristic() const; + // ------------------------------------------------------------------------ + /** Returns the characteristics for this kart combined with the base + * characteristic. This value isn't used for the race, because the + * difficulty is missing, but it can be used e.g. for the kart stats widget. + */ + const AbstractCharacteristic* getCombinedCharacteristic() const; // ------------------------------------------------------------------------ /** Returns the (maximum) speed for a given turn radius. @@ -517,47 +332,6 @@ public: /** Returns the list of groups this kart belongs to. */ const std::vector& getGroups () const {return m_groups; } - // ------------------------------------------------------------------------ - /** Returns the mass of this kart. */ - float getMass () const {return m_mass; } - // ------------------------------------------------------------------------ - /** Returns the maximum engine power depending on difficulty. */ - float getMaxPower () const - {return m_engine_power[race_manager->getDifficulty()];} - - // ------------------------------------------------------------------------ - /** Returns the time the kart needs to fully steer in one direction from - * steering straight depending on the current steering value. - * \param steer Current steering value, must be >=0. */ - float getTimeFullSteer(float steer) const - { - assert(steer>=0); - return m_time_full_steer.get(steer); - } // getTimeFullSteer - - // ------------------------------------------------------------------------ - /** Returns the time the kart needs to go back to steering straight from - * full steer. */ - float getTimeResetSteer () const { return m_time_reset_steer; } - // ------------------------------------------------------------------------ - /** Get braking information. */ - float getBrakeFactor () const {return m_brake_factor; } - - // ------------------------------------------------------------------------ - /** Returns the additional brake factor which depends on time. */ - float getBrakeTimeIncrease() const { return m_brake_time_increase; } - - // ------------------------------------------------------------------------ - /** Returns the torque scaling factor used to keep the karts parallel to - * the ground when flying. */ - float getSmoothFlyingImpulse() const - { - return m_smooth_flying_impulse; - } // getSmoothFlyingImpulse - - // ------------------------------------------------------------------------ - /** Get maximum reverse speed ratio. */ - float getMaxSpeedReverseRatio() const {return m_max_speed_reverse_ratio; } // ------------------------------------------------------------------------ /** Returns the engine type (used to change sfx depending on kart size). */ @@ -565,35 +339,9 @@ public: // Bullet physics get functions //----------------------------- - /** Returns the suspension stiffness. */ - float getSuspensionStiffness () const {return m_suspension_stiffness; } - - // ------------------------------------------------------------------------ - /** Returns damping relaxation. */ - float getWheelDampingRelaxation () const - {return m_wheel_damping_relaxation; } - - // ------------------------------------------------------------------------ - /** Returns the wheel damping compression. */ - float getWheelDampingCompression() const - {return m_wheel_damping_compression;} - - // ------------------------------------------------------------------------ - /** Returns maximum suspension force. */ - float getMaxSuspensionForce() const {return m_max_suspension_force; } - - // ------------------------------------------------------------------------ /** Returns friction slip. */ float getFrictionSlip () const {return m_friction_slip; } - // ------------------------------------------------------------------------ - /** Returns roll influence. */ - float getRollInfluence () const {return m_roll_influence; } - - // ------------------------------------------------------------------------ - /** Returns wheel radius. */ - float getWheelRadius () const {return m_wheel_radius; } - // ------------------------------------------------------------------------ /** Return the additional Y offset added to the y position of the graphical * chassis. Useful for karts that don't have enough space for suspension @@ -617,99 +365,11 @@ public: /** Returns the wheel base (distance front to rear axis). */ float getWheelBase () const {return m_wheel_base; } - // ------------------------------------------------------------------------ - /** Returns linear damping of chassis. */ - float getChassisLinearDamping () const {return m_chassis_linear_damping;} - - // ------------------------------------------------------------------------ - /** Returns angular damping of chassis. */ - float getChassisAngularDamping () const - {return m_chassis_angular_damping; } - - // ------------------------------------------------------------------------ - /** Artifical downward impulse every frame. */ - float getDownwardImpulseFactor() const { return m_downward_impulse_factor;} - - // ------------------------------------------------------------------------ - /** Returns artificial acceleration to keep wheels on track. */ - float getTrackConnectionAccel () const {return m_track_connection_accel;} - - // ------------------------------------------------------------------------ - /** Returns the maximum speed dependent on the difficult level. */ - float getMaxSpeed () const - { - return m_max_speed[race_manager->getDifficulty()]; - } - - // ------------------------------------------------------------------------ - /** Return the absolute maximum speed, independent on the difficulty. */ - float getAbsMaxSpeed () const - { - return m_max_speed[m_max_speed.size()-1]; - } - - // ------------------------------------------------------------------------ - /** Returns the nitro consumption. */ - float getNitroConsumption () const {return m_nitro_consumption; } - - // ------------------------------------------------------------------------ - /** Returns the amount of nitro for a small container. */ - float getNitroSmallContainer () const {return m_nitro_small_container; } - - // ------------------------------------------------------------------------ - /** Returns the amount of nitro for a big container. */ - float getNitroBigContainer () const {return m_nitro_big_container; } - - // ------------------------------------------------------------------------ - /** Returns the increase of maximum speed due to nitro. */ - float getNitroMaxSpeedIncrease () const - {return m_nitro_max_speed_increase; } - - // ------------------------------------------------------------------------ - float getNitroEngineForce () const {return m_nitro_engine_force; } - // ------------------------------------------------------------------------ - /** Returns how long the increased nitro max speed will be valid after - * the kart stops using nitro (and the fade-out-time starts). */ - float getNitroDuration () const {return m_nitro_duration; } - - // ------------------------------------------------------------------------ - /** Returns the duration during which the increased maximum speed - * due to nitro fades out. */ - float getNitroFadeOutTime () const {return m_nitro_fade_out_time; } - - // ------------------------------------------------------------------------ - /** Returns the maximum amount of nitro a kart can store. */ - float getNitroMax () const {return m_nitro_max; } - // ------------------------------------------------------------------------ - /** Returns how long a bubble gum is active. */ - float getBubblegumTime() const { return m_bubblegum_time; } - // ------------------------------------------------------------------------ - /** Returns the torque to add when a bubble gum was hit . */ - float getBubblegumTorque() const { return m_bubblegum_torque; } - // ------------------------------------------------------------------------ - /** Returns the fraction of top speed that can be reached maximum after - * hitting a bubble gum. */ - float getBubblegumSpeedFraction() const {return m_bubblegum_speed_fraction;} - // ------------------------------------------------------------------------ - /** Returns how long to fade in the slowdown for a bubble gum. */ - float getBubblegumFadeInTime() const { return m_bubblegum_fade_in_time; } // ------------------------------------------------------------------------ /** Returns a shift of the center of mass (lowering the center of mass * makes the karts more stable. */ const Vec3&getGravityCenterShift() const {return m_gravity_center_shift; } - // ------------------------------------------------------------------------ - /** Retusn suspension rest length. */ - float getSuspensionRest () const {return m_suspension_rest; } - - // ------------------------------------------------------------------------ - /** Returns the amount the suspension can extend. */ - float getSuspensionTravelCM () const {return m_suspension_travel_cm; } - - // ------------------------------------------------------------------------ - /** Returns if the spring should be exponentially dampened. */ - bool getExpSpringResponse() const {return m_exp_spring_response; } - // ------------------------------------------------------------------------ /** Returns an artificial impulse to push karts away from the terrain * it hits. */ @@ -734,128 +394,6 @@ public: /** Returns the restitution factor for this kart. */ float getRestitution () const { return m_restitution; } - // ------------------------------------------------------------------------ - /** Returns the vertical offset when rescuing karts to avoid karts being - * rescued in (or under) the track. */ - float getVertRescueOffset () const {return m_rescue_vert_offset; } - - // ------------------------------------------------------------------------ - /** Returns the time a kart is rised during a rescue. */ - float getRescueTime () const {return m_rescue_time; } - - // ------------------------------------------------------------------------ - /** Returns the height a kart is moved to during a rescue. */ - float getRescueHeight () const {return m_rescue_height; } - - // ------------------------------------------------------------------------ - /** Returns the time an explosion animation is shown. */ - float getExplosionTime () const {return m_explosion_time; } - - // ------------------------------------------------------------------------ - /** Returns the height of the explosion animation. */ - float getExplosionRadius () const {return m_explosion_radius; } - - // ------------------------------------------------------------------------ - /** Returns how long a kart is invulnerable after being hit by an - explosion. */ - float getExplosionInvulnerabilityTime() const - { return m_explosion_invulnerability_time; } - - // ------------------------------------------------------------------------ - /** Returns the maximum length of a rubber band before it breaks. */ - float getRubberBandMaxLength () const {return m_rubber_band_max_length;} - - // ------------------------------------------------------------------------ - /** Returns force a rubber band has when attached to a kart. */ - float getRubberBandForce () const {return m_rubber_band_force; } - - // ------------------------------------------------------------------------ - /** Returns the duration a rubber band is active for. */ - float getRubberBandDuration () const {return m_rubber_band_duration; } - - // ------------------------------------------------------------------------ - /** Returns the increase of maximum speed while a rubber band is - * pulling. */ - float getRubberBandSpeedIncrease() const - { - return m_rubber_band_speed_increase; - } - - // ------------------------------------------------------------------------ - /** Return the fade out time once a rubber band is removed. */ - float getRubberBandFadeOutTime() const - { - return m_rubber_band_fade_out_time; - } - - // ------------------------------------------------------------------------ - /** Returns duration of a plunger in your face. */ - float getPlungerInFaceTime () const - {return m_plunger_in_face_duration[race_manager->getDifficulty()];} - - // ------------------------------------------------------------------------ - /** Returns the time a zipper is active. */ - float getZipperTime () const {return m_zipper_time; } - - // ------------------------------------------------------------------------ - /** Returns the time a zipper is active. */ - float getZipperFadeOutTime () const {return m_zipper_fade_out_time; } - - // ------------------------------------------------------------------------ - /** Returns the additional force added applied to the kart. */ - float getZipperForce () const { return m_zipper_force; } - - // ------------------------------------------------------------------------ - /** Returns the initial zipper speed gain. */ - float getZipperSpeedGain () const { return m_zipper_speed_gain; } - - // ------------------------------------------------------------------------ - /** Returns the increase of the maximum speed of the kart - * if a zipper is active. */ - float getZipperMaxSpeedIncrease () const - { return m_zipper_max_speed_increase;} - - // ------------------------------------------------------------------------ - /** Returns how far behind a kart slipstreaming works. */ - float getSlipstreamLength () const {return m_slipstream_length; } - - // ------------------------------------------------------------------------ - /** Returns how wide the slipstream area is at the end. */ - float getSlipstreamWidth () const {return m_slipstream_width; } - - // ------------------------------------------------------------------------ - /** Returns time after which slipstream has maximum effect. */ - float getSlipstreamCollectTime () const - {return m_slipstream_collect_time; } - - // ------------------------------------------------------------------------ - /** Returns time after which slipstream has maximum effect. */ - float getSlipstreamUseTime () const {return m_slipstream_use_time; } - - // ------------------------------------------------------------------------ - /** Returns additional power due to slipstreaming. */ - float getSlipstreamAddPower () const {return m_slipstream_add_power; } - - // ------------------------------------------------------------------------ - /** Returns the minimum slipstream speed. */ - float getSlipstreamMinSpeed () const {return m_slipstream_min_speed; } - - // ------------------------------------------------------------------------ - /** Returns the increase of the maximum speed of a kart - * due to slipstream. */ - float getSlipstreamMaxSpeedIncrease() const - { return m_slipstream_max_speed_increase; } - // ------------------------------------------------------------------------ - /** Returns how long the higher speed lasts after slipstream - * stopped working. */ - float getSlipstreamDuration () const { return m_slipstream_duration; } - - // ------------------------------------------------------------------------ - /** Returns how long the slip stream speed increase will gradually - * be reduced. */ - float getSlipstreamFadeOutTime () const - { return m_slipstream_fade_out_time; } - // ------------------------------------------------------------------------ /** Returns the scale factor by which the shadow plane * had to be set. */ @@ -883,56 +421,10 @@ public: return m_ai_properties[race_manager->getDifficulty()]; } // getAIProperties - // ------------------------------------------------------------------------ - /** Returns ratio of current speed to max speed at which the gear will - * change (for our simualated gears = simple change of engine power). */ - const std::vector& - getGearSwitchRatio () const {return m_gear_switch_ratio; } - - // ------------------------------------------------------------------------ - /** Returns the power increase depending on gear. */ - const std::vector& - getGearPowerIncrease () const {return m_gear_power_increase; } - - // ------------------------------------------------------------------------ - /** Returns the average power of the kart (in all gears). */ - const float getAvgPower () const; - - // ------------------------------------------------------------------------ - /** Returns distance between kart and camera. */ - float getCameraDistance () const {return m_camera_distance; } - - // ------------------------------------------------------------------------ - /** Returns the angle the camera has relative to the pitch of the kart. */ - float getCameraForwardUpAngle () const - {return m_camera_forward_up_angle; } - - // ------------------------------------------------------------------------ - /** Returns the angle the camera has relative to the pitch of the kart. */ - float getCameraBackwardUpAngle () const - {return m_camera_backward_up_angle; } - // ------------------------------------------------------------------------ /** Returns the full path where the files for this kart are stored. */ const std::string& getKartDir () const {return m_root; } - // ------------------------------------------------------------------------ - /** Returns the square of the maximum distance at which a swatter - * can hit karts. */ - float getSwatterDistance2() const { return m_swatter_distance2; } - - // ------------------------------------------------------------------------ - /** Returns how long a swatter will stay attached/ready to be used. */ - float getSwatterDuration() const { return m_swatter_duration; } - - // ------------------------------------------------------------------------ - /** Returns how long a kart remains squashed. */ - float getSquashDuration() const {return m_squash_duration; } - - // ------------------------------------------------------------------------ - /** Returns the slowdown of a kart that is squashed. */ - float getSquashSlowdown() const {return m_squash_slowdown; } - // ------------------------------------------------------------------------ /** The maximum leaning a kart should show (In radians). */ float getMaxLean() const { return m_max_lean; } @@ -941,10 +433,6 @@ public: /** The speed with which a kart should lean (in radians/s). */ float getLeanSpeed() const { return m_lean_speed; } // ------------------------------------------------------------------------ - /** Return show long a jump must last in order to play the jump - * animation. */ - float getJumpAnimationTime() const { return m_jump_animation_time; } - // ------------------------------------------------------------------------ /** Returns true if wheels should have random rotation at start. */ bool hasRandomWheels() const { return m_has_rand_wheels; } // ------------------------------------------------------------------------ diff --git a/src/karts/max_speed.cpp b/src/karts/max_speed.cpp index df105360f..08ee4249d 100644 --- a/src/karts/max_speed.cpp +++ b/src/karts/max_speed.cpp @@ -21,6 +21,7 @@ #include #include +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "physics/btKart.hpp" @@ -62,7 +63,7 @@ MaxSpeed::MaxSpeed(AbstractKart *kart) */ void MaxSpeed::reset() { - m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed(); + m_current_max_speed = m_kart->getCharacteristic()->getEngineMaxSpeed(); m_min_speed = -1.0f; for(unsigned int i=MS_DECREASE_MIN; igetKartProperties()->getMaxSpeed(); + m_current_max_speed = m_kart->getCharacteristic()->getEngineMaxSpeed(); // Then add the speed increase from each category // ---------------------------------------------- diff --git a/src/karts/rescue_animation.cpp b/src/karts/rescue_animation.cpp index caaae1d01..d23810cba 100644 --- a/src/karts/rescue_animation.cpp +++ b/src/karts/rescue_animation.cpp @@ -22,6 +22,7 @@ #include "graphics/camera.hpp" #include "graphics/referee.hpp" #include "items/attachment.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/three_strikes_battle.hpp" @@ -39,8 +40,8 @@ RescueAnimation::RescueAnimation(AbstractKart *kart, bool is_auto_rescue) { m_referee = new Referee(*m_kart); m_kart->getNode()->addChild(m_referee->getSceneNode()); - m_timer = m_kart->getKartProperties()->getRescueTime(); - m_velocity = m_kart->getKartProperties()->getRescueHeight() / m_timer; + m_timer = m_kart->getCharacteristic()->getRescueDuration(); + m_velocity = m_kart->getCharacteristic()->getRescueHeight() / m_timer; m_xyz = m_kart->getXYZ(); m_kart->getAttachment()->clear(); diff --git a/src/karts/xml_characteristic.cpp b/src/karts/xml_characteristic.cpp index e133e23ab..f17aaf477 100644 --- a/src/karts/xml_characteristic.cpp +++ b/src/karts/xml_characteristic.cpp @@ -33,11 +33,18 @@ XmlCharacteristic::XmlCharacteristic(const XMLNode *node) : void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const { + if (m_values[type].empty()) + // That value was not changed in this configuration + return; + switch (getType(type)) { case TYPE_FLOAT: processFloat(m_values[type], value.f, is_set); break; + case TYPE_BOOL: + processBool(m_values[type], value.b, is_set); + break; case TYPE_FLOAT_VECTOR: { const std::vector processors = @@ -162,15 +169,13 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s } break; } + default: + Log::fatal("XmlCharacteristic::process", "Unknown type for %s", getName(type).c_str()); } } void XmlCharacteristic::processFloat(const std::string &processor, float *value, bool *is_set) { - if (processor.empty()) - // That value was not changed in this configuration - return; - // Split the string by operators static const std::string operators = "*/+-"; std::vector parts; @@ -223,7 +228,7 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value, else if (!StringUtils::fromString(parts[index], val)) { Log::fatal("XmlCharacteristic::processFloat", - "Can't process %s: Not a float", parts[index].c_str()); + "Can't parse %s: Not a float", parts[index].c_str()); return; } if (operations[index - 1] == "*") @@ -241,9 +246,25 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value, *is_set = true; } +void XmlCharacteristic::processBool(const std::string &processor, bool *value, bool *is_set) +{ + if (processor == "true") + { + *value = true; + *is_set = true; + } + else if (processor == "false") + { + *value = false; + *is_set = true; + } + else + Log::error("XmlCharacteristic::processBool", "Can't parse %s: Not a bool", processor); +} + void XmlCharacteristic::load(const XMLNode *node) { - // Script-generated content + // Script-generated content getXml if (const XMLNode *sub_node = node->getNode("suspension")) { sub_node->get("stiffness", &m_values[SUSPENSION_STIFFNESS]); @@ -285,9 +306,9 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("power-increase", &m_values[GEAR_POWER_INCREASE]); } - if (const XMLNode *sub_node = node->getNode("")) + if (const XMLNode *sub_node = node->getNode("mass")) { - sub_node->get("mass", &m_values[MASS]); + sub_node->get("value", &m_values[MASS]); } if (const XMLNode *sub_node = node->getNode("wheels")) @@ -347,7 +368,7 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("duration", &m_values[ZIPPER_DURATION]); sub_node->get("force", &m_values[ZIPPER_FORCE]); sub_node->get("speed-gain", &m_values[ZIPPER_SPEED_GAIN]); - sub_node->get("speed-increase", &m_values[ZIPPER_SPEED_INCREASE]); + sub_node->get("max-speed-increase", &m_values[ZIPPER_MAX_SPEED_INCREASE]); sub_node->get("fade-out-time", &m_values[ZIPPER_FADE_OUT_TIME]); } @@ -361,11 +382,11 @@ void XmlCharacteristic::load(const XMLNode *node) if (const XMLNode *sub_node = node->getNode("plunger")) { - sub_node->get("max-length", &m_values[PLUNGER_MAX_LENGTH]); - sub_node->get("force", &m_values[PLUNGER_FORCE]); - sub_node->get("duration", &m_values[PLUNGER_DURATION]); - sub_node->get("speed-increase", &m_values[PLUNGER_SPEED_INCREASE]); - sub_node->get("fade-out-time", &m_values[PLUNGER_FADE_OUT_TIME]); + sub_node->get("band-max-length", &m_values[PLUNGER_BAND_MAX_LENGTH]); + sub_node->get("band-force", &m_values[PLUNGER_BAND_FORCE]); + sub_node->get("band-duration", &m_values[PLUNGER_BAND_DURATION]); + sub_node->get("band-speed-increase", &m_values[PLUNGER_BAND_SPEED_INCREASE]); + sub_node->get("band-fade-out-time", &m_values[PLUNGER_BAND_FADE_OUT_TIME]); sub_node->get("in-face-time", &m_values[PLUNGER_IN_FACE_TIME]); } diff --git a/src/karts/xml_characteristic.hpp b/src/karts/xml_characteristic.hpp index 5084e5ab0..5daa58c7a 100644 --- a/src/karts/xml_characteristic.hpp +++ b/src/karts/xml_characteristic.hpp @@ -40,6 +40,7 @@ public: private: static void processFloat(const std::string &processor, float *value, bool *is_set); + static void processBool(const std::string &processor, bool *value, bool *is_set); }; #endif diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 79a495622..8c470b39f 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -21,6 +21,7 @@ #include "audio/sfx_base.hpp" #include "io/file_manager.hpp" #include "graphics/irr_driver.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart.hpp" #include "karts/kart_model.hpp" @@ -386,7 +387,7 @@ void SoccerWorld::moveKartAfterRescue(AbstractKart* kart) if (kart_over_ground) { //add vertical offset so that the kart starts off above the track - float vertical_offset = kart->getKartProperties()->getVertRescueOffset() * + float vertical_offset = kart->getCharacteristic()->getRescueVertOffset() * kart->getKartHeight(); kart->getBody()->translate(btVector3(0, vertical_offset, 0)); } diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 398fce17d..4113a3416 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -22,6 +22,7 @@ #include "LinearMath/btIDebugDraw.h" #include "BulletDynamics/ConstraintSolver/btContactConstraint.h" +#include "karts/abstract_characteristic.hpp" #include "karts/kart.hpp" #include "modes/world.hpp" #include "physics/triangle_mesh.hpp" @@ -444,7 +445,7 @@ void btKart::updateVehicle( btScalar step ) btVector3 terrain_up(0,1,0); btVector3 axis = kart_up.cross(terrain_up); // Give a nicely balanced feeling for rebalancing the kart - m_chassisBody->applyTorqueImpulse(axis * m_kart->getKartProperties()->getSmoothFlyingImpulse()); + m_chassisBody->applyTorqueImpulse(axis * m_kart->getCharacteristic()->getStabilitySmoothFlyingImpulse()); } // Work around: make sure that either both wheels on one axis @@ -538,7 +539,7 @@ void btKart::updateVehicle( btScalar step ) // If configured, add a force to keep karts on the track // ----------------------------------------------------- - float dif = m_kart->getKartProperties()->getDownwardImpulseFactor(); + float dif = m_kart->getCharacteristic()->getStabilityDownwardImpulseFactor(); if(dif!=0 && m_num_wheels_on_ground==4) { float f = -fabsf(m_kart->getSpeed()) * dif; @@ -650,7 +651,7 @@ void btKart::updateSuspension(btScalar deltaTime) // is already guaranteed that either both or no wheels on one axis // are on the ground, so we have to test only one of the wheels wheel_info.m_wheelsSuspensionForce = - -m_kart->getKartProperties()->getTrackConnectionAccel() + -m_kart->getCharacteristic()->getStabilityTrackConnectionAccel() * chassisMass; continue; } @@ -661,7 +662,7 @@ void btKart::updateSuspension(btScalar deltaTime) btScalar susp_length = wheel_info.getSuspensionRestLength(); btScalar current_length = wheel_info.m_raycastInfo.m_suspensionLength; btScalar length_diff = (susp_length - current_length); - if(m_kart->getKartProperties()->getExpSpringResponse()) + if(m_kart->getCharacteristic()->getSuspensionExpSpringResponse()) length_diff *= fabsf(length_diff)/susp_length; float f = (1.0f + fabsf(length_diff) / susp_length); // Scale the length diff. This results that in uphill sections, when diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 357a36943..d24fb973c 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -26,6 +26,7 @@ #include "graphics/irr_driver.hpp" #include "graphics/stars.hpp" #include "items/flyable.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/kart_properties.hpp" #include "karts/rescue_animation.hpp" #include "karts/controller/player_controller.hpp" @@ -218,9 +219,9 @@ void Physics::update(float dt) } else if (obj->isFlattenKartObject()) { - const KartProperties* kp = kart->getKartProperties(); - kart->setSquash(kp->getSquashDuration(), - kp->getSquashSlowdown()); + const AbstractCharacteristic *ch = kart->getCharacteristic(); + kart->setSquash(ch->getSwatterSquashDuration(), + ch->getSwatterSquashSlowdown()); } else if(obj->isSoccerBall() && race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) @@ -248,9 +249,9 @@ void Physics::update(float dt) else if (anim->isFlattenKartObject()) { AbstractKart *kart = p->getUserPointer(1)->getPointerKart(); - const KartProperties* kp = kart->getKartProperties(); - kart->setSquash(kp->getSquashDuration(), - kp->getSquashSlowdown()); + const AbstractCharacteristic *ch = kart->getCharacteristic(); + kart->setSquash(ch->getSwatterSquashDuration(), + ch->getSwatterSquashSlowdown()); } continue; @@ -397,9 +398,9 @@ void Physics::KartKartCollision(AbstractKart *kart_a, // Add a scaling factor depending on the mass (avoid div by zero). // The value of f_right is applied to the right kart, and f_left // to the left kart. f_left = 1 / f_right - float f_right = right_kart->getKartProperties()->getMass() > 0 - ? left_kart->getKartProperties()->getMass() - / right_kart->getKartProperties()->getMass() + float f_right = right_kart->getCharacteristic()->getMass() > 0 + ? left_kart->getCharacteristic()->getMass() + / right_kart->getCharacteristic()->getMass() : 1.5f; // Add a scaling factor depending on speed (avoid div by 0) f_right *= right_kart->getSpeed() > 0 diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 42076802d..0f36b9c68 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -31,6 +31,7 @@ #include "input/input_manager.hpp" #include "input/device_manager.hpp" #include "items/item_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/kart_properties.hpp" #include "karts/kart_properties_manager.hpp" #include "modes/overworld.hpp" @@ -810,9 +811,12 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id, kart_properties_manager->getKart(selection); if (kp != NULL) { - w->setValue(KartStatsWidget::SKILL_MASS, (int)(kp->getMass()/5)); - w->setValue(KartStatsWidget::SKILL_SPEED, (int)((kp->getAbsMaxSpeed()-20)*9)); - w->setValue(KartStatsWidget::SKILL_POWER, (int)(kp->getAvgPower())); + w->setValue(KartStatsWidget::SKILL_MASS, (int) + (kp->getCombinedCharacteristic()->getMass() / 5)); + w->setValue(KartStatsWidget::SKILL_SPEED, (int) + ((kp->getCombinedCharacteristic()->getEngineMaxSpeed() - 20) * 9)); + w->setValue(KartStatsWidget::SKILL_POWER, (int) + kp->getCombinedCharacteristic()->getEnginePower()); w->update(0); } } diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 92ff1649c..91c308bc6 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -38,6 +38,7 @@ using namespace irr; #include "items/attachment.hpp" #include "items/attachment_manager.hpp" #include "items/powerup_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" @@ -412,7 +413,7 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart, int gauge_height = (int)(GAUGEWIDTH*min_ratio); float state = (float)(kart->getEnergy()) - / kart->getKartProperties()->getNitroMax(); + / kart->getCharacteristic()->getNitroMax(); if (state < 0.0f) state = 0.0f; else if (state > 1.0f) state = 1.0f; @@ -435,7 +436,7 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart, if (race_manager->getCoinTarget() > 0) { float coin_target = (float)race_manager->getCoinTarget() - / kart->getKartProperties()->getNitroMax(); + / kart->getCharacteristic()->getNitroMax(); video::S3DVertex vertices[5]; unsigned int count=2; diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index d222b5857..cb1f8386b 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -36,6 +36,7 @@ #include "items/attachment.hpp" #include "items/attachment_manager.hpp" #include "items/powerup_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" @@ -551,7 +552,7 @@ void RaceGUIOverworld::drawEnergyMeter(int x, int y, const AbstractKart *kart, const core::vector2df &scaling) { float state = (float)(kart->getEnergy()) - / kart->getKartProperties()->getNitroMax(); + / kart->getCharacteristic()->getNitroMax(); if (state < 0.0f) state = 0.0f; else if (state > 1.0f) state = 1.0f; @@ -572,7 +573,7 @@ void RaceGUIOverworld::drawEnergyMeter(int x, int y, const AbstractKart *kart, if (race_manager->getCoinTarget() > 0) { float coin_target = (float)race_manager->getCoinTarget() - / kart->getKartProperties()->getNitroMax(); + / kart->getCharacteristic()->getNitroMax(); const int EMPTY_TOP_PIXELS = 4; const int EMPTY_BOTTOM_PIXELS = 3; diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 8f04de77b..5345398fd 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -44,6 +44,7 @@ #include "io/xml_node.hpp" #include "items/item.hpp" #include "items/item_manager.hpp" +#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/linear_world.hpp" @@ -2444,8 +2445,8 @@ bool Track::findGround(AbstractKart *kart) // length of the suspension with the weight of the kart resting on // it). On the other hand this initial bouncing looks nice imho // - so I'll leave it in for now. - float offset = kart->getKartProperties()->getSuspensionRest() + - kart->getKartProperties()->getWheelRadius(); + float offset = kart->getCharacteristic()->getSuspensionRest() + + kart->getCharacteristic()->getWheelsRadius(); t.setOrigin(hit_point+Vec3(0, offset, 0) ); kart->getBody()->setCenterOfMassTransform(t); kart->setTrans(t); diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index e2ea705a9..e1cc4ed7c 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -25,7 +25,7 @@ import sys # Input data #FIXME is wheelPosition needed? -characteristics = """Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce +characteristics = """Suspension: stiffness, rest, travelCm, expSpringResponse(bool), maxForce Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray) Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio @@ -38,9 +38,9 @@ Lean: max, speed Anvil: duration, weight, speedFactor Parachute: friction, duration, durationOther, lboundFranction, uboundFranction, maxSpeed Bubblegum: duration, speedFraction, torque, fadeInTime, shieldDuration -Zipper: duration, force, speedGain, speedIncrease, fadeOutTime +Zipper: duration, force, speedGain, maxSpeedIncrease, fadeOutTime Swatter: duration, distance, squashDuration, squashSlowdown -Plunger: maxLength, force, duration, speedIncrease, fadeOutTime, inFaceTime +Plunger: bandMaxLength, bandForce, bandDuration, bandSpeedIncrease, bandFadeOutTime, inFaceTime Startup: time(std::vector/floatVector), boost(std::vector/floatVector) Rescue: duration, vertOffset, height Explosion: duration, radius, invulnerabilityTime @@ -51,12 +51,19 @@ Slipstream: duration, length, width, collectTime, useTime, addPower, minSpeed, m class GroupMember: def __init__(self, name, typeC, typeStr): self.name = name + if name == "value": + self.getName = "" + else: + self.getName = name self.typeC = typeC self.typeStr = typeStr """E.g. power(std::vector/floatVector) or speed(InterpolationArray) - The default type is float""" + The default type is float + The name 'value' is special: Only the group name will be used to access + the member but in the xml file it will be still value (because we + need a name).""" def parse(content): typeC = "float" typeStr = typeC @@ -84,8 +91,6 @@ class Group: self.members.append(GroupMember.parse(content)) def getBaseName(self): - if len(self.baseName) == 0 and len(self.members) > 0: - return self.members[0].name return self.baseName """E.g. engine: power, gears(std::vector/Gears) @@ -93,8 +98,8 @@ class Group: def parse(content): pos = content.find(":") if pos == -1: - group = Group("") - group.addMember(content) + group = Group(content) + group.addMember("value") return group else: group = Group(content[:pos].strip()) @@ -118,7 +123,7 @@ def toList(name): """titleCase: true = result is titlecase false = result has underscores""" def joinSubName(group, member, titleCase): - words = toList(group.baseName) + toList(member.name) + words = toList(group.baseName) + toList(member.getName) first = True if titleCase: words = [w.title() for w in words] @@ -129,7 +134,7 @@ def joinSubName(group, member, titleCase): def main(): # Find out what to do if len(sys.argv) == 1: - print("Please specify what you want to know [enum/defs/getter/getProp/getXml]") + print("Please specify what you want to know [enum|defs|getter|getProp|getXml]") return task = sys.argv[1] From db13a1fae61ad0d0577d8276ad58488e9b1f3567 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sat, 11 Jul 2015 19:33:13 +0200 Subject: [PATCH 21/55] Remove data from stk_config.xml --- data/stk_config.xml | 263 -------------------------------------- src/config/stk_config.cpp | 11 -- 2 files changed, 274 deletions(-) diff --git a/data/stk_config.xml b/data/stk_config.xml index 7f1674394..df5733dd7 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -85,24 +85,6 @@ - - - - - - @@ -144,16 +126,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -415,23 +318,6 @@ (like 10000000) disables bullet skidding. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " ); From 5bfb1a2c6ba2e5cd29f4be0a25410585e242e53e Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 12 Jul 2015 00:39:38 +0200 Subject: [PATCH 22/55] Fix some bugs --- data/kart_characteristics.xml | 34 +++++++++++---------- src/graphics/camera.cpp | 6 ++-- src/guiengine/widgets/kart_stats_widget.cpp | 6 ++-- src/karts/combined_characteristic.cpp | 5 +-- src/karts/kart_properties.cpp | 17 ++++++++++- src/karts/kart_properties.hpp | 3 ++ src/karts/kart_properties_manager.cpp | 2 ++ src/karts/xml_characteristic.cpp | 27 +++++++++------- src/states_screens/kart_selection.cpp | 3 +- 9 files changed, 65 insertions(+), 38 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index 64449e202..7a5b54e23 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -7,6 +7,8 @@ would result in 10 - 5 = 5. --> + @@ -61,7 +63,7 @@ 0.5 * 0.25 + 0.5 * 0.15 = 0.2 ... which is overall the same time we had previously. --> - - + in-face-time="4.5" /> @@ -279,7 +283,7 @@ fade-out-time: Duration during which the increased maximum speed due to nitro fades out. max: How much nitro a kart can store. --> - - + + + - - - - - - + + @@ -324,7 +326,7 @@ - @@ -342,7 +344,7 @@ - + + - @@ -370,7 +373,6 @@ duration="0.7" fade-out-time="1.3" /> - diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 66dcd4041..b412d2bfd 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -476,7 +476,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, else { *above_kart = 0.75f; - *cam_angle = ch->getCameraForwardUpAngle(); + *cam_angle = ch->getCameraForwardUpAngle() * DEGREE_TO_RAD; *distance = -m_distance; } float steering = m_kart->getSteerPercent() @@ -491,7 +491,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, case CM_REVERSE: // Same as CM_NORMAL except it looks backwards { *above_kart = 0.75f; - *cam_angle = ch->getCameraBackwardUpAngle(); + *cam_angle = ch->getCameraBackwardUpAngle() * DEGREE_TO_RAD; *sideway = 0; *distance = 2.0f*m_distance; *smoothing = false; @@ -824,7 +824,7 @@ void Camera::handleEndCamera(float dt) case EndCameraInformation::EC_AHEAD_OF_KART: { const AbstractCharacteristic *ch = m_kart->getCharacteristic(); - float cam_angle = ch->getCameraBackwardUpAngle(); + float cam_angle = ch->getCameraBackwardUpAngle() * DEGREE_TO_RAD; positionCamera(dt, /*above_kart*/0.75f, cam_angle, /*side_way*/0, diff --git a/src/guiengine/widgets/kart_stats_widget.cpp b/src/guiengine/widgets/kart_stats_widget.cpp index abe4bfaff..542c9d093 100644 --- a/src/guiengine/widgets/kart_stats_widget.cpp +++ b/src/guiengine/widgets/kart_stats_widget.cpp @@ -79,15 +79,15 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id, m_children.push_back(skill_bar); } - m_skills[SKILL_MASS]->setValue((int)(props->getCombinedCharacteristic()->getMass()/5)); + m_skills[SKILL_MASS]->setValue((int)(props->getCombinedCharacteristic()->getMass() / 5)); m_skills[SKILL_MASS]->setLabel(_("WEIGHT")); m_skills[SKILL_MASS]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_mass", m_player_id); - m_skills[SKILL_SPEED]->setValue((int)((props->getCombinedCharacteristic()->getEngineMaxSpeed()-20)*9)); + m_skills[SKILL_SPEED]->setValue((int)((props->getCombinedCharacteristic()->getEngineMaxSpeed() - 20) * 9)); m_skills[SKILL_SPEED]->setLabel(_("SPEED")); m_skills[SKILL_SPEED]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_speed", m_player_id); - m_skills[SKILL_POWER]->setValue((int)(props->getCombinedCharacteristic()->getEnginePower())); + m_skills[SKILL_POWER]->setValue((int)(props->getAvgPower())); m_skills[SKILL_POWER]->setLabel(_("POWER")); m_skills[SKILL_POWER]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_power", m_player_id); diff --git a/src/karts/combined_characteristic.cpp b/src/karts/combined_characteristic.cpp index 4b760c2c7..9a5ee2484 100644 --- a/src/karts/combined_characteristic.cpp +++ b/src/karts/combined_characteristic.cpp @@ -36,7 +36,8 @@ const SkiddingProperties* CombinedCharacteristic::getSkiddingProperties() const void CombinedCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const { - for (const AbstractCharacteristic *characteristic : m_childs) - characteristic->process(type, value, is_set); + for (std::vector::const_iterator it = m_childs.cbegin(); + it != m_childs.cend(); it++) + (*it)->process(type, value, is_set); } diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 0b4887318..6acac2f36 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -215,6 +215,8 @@ void KartProperties::load(const std::string &filename, const std::string &node) throw std::runtime_error(msg.str()); } getAllData(root); + if (m_characteristic) + delete m_characteristic; m_characteristic = new XmlCharacteristic(root); combineCharacteristics(); } @@ -317,6 +319,8 @@ void KartProperties::combineCharacteristics() m_combined_characteristic = new CombinedCharacteristic(); m_combined_characteristic->addCharacteristic(kart_properties_manager-> getBaseCharacteristic()); + m_combined_characteristic->addCharacteristic(kart_properties_manager-> + getKartTypeCharacteristic(m_kart_type)); m_combined_characteristic->addCharacteristic(m_characteristic); } // combineCharacteristics @@ -397,7 +401,7 @@ void KartProperties::getAllData(const XMLNode * root) } } - if(const XMLNode *turn_node = root->getNode("turn")) + if (const XMLNode *turn_node = root->getNode("turn")) { turn_node->get("turn-radius", &m_turn_angle_at_speed ); // For now store the turn radius in turn angle, the correct @@ -545,3 +549,14 @@ bool KartProperties::isInGroup(const std::string &group) const return std::find(m_groups.begin(), m_groups.end(), group) != m_groups.end(); } // isInGroups +// ---------------------------------------------------------------------------- +float KartProperties::getAvgPower() const +{ + float sum = 0; + std::vector gear_power_increase = m_combined_characteristic->getGearPowerIncrease(); + float max_speed = m_combined_characteristic->getEngineMaxSpeed(); + for (unsigned int i = 0; i < gear_power_increase.size(); ++i) + sum += gear_power_increase[i] * max_speed; + return sum / gear_power_increase.size(); +} // getAvgPower + diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index 48e7a688f..bf67f4dc8 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -453,6 +453,9 @@ public: { return m_physical_wheel_position; } // getPhysicalWheelPosition + + // ------------------------------------------------------------------------ + float getAvgPower() const; }; // KartProperties #endif diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index 4794c410c..a9eaa5b3c 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -219,6 +219,8 @@ void KartPropertiesManager::loadCharacteristics(const XMLNode *root) (*type)->get("name", &name); m_kart_type_characteristics.emplace(name, std::unique_ptr(new XmlCharacteristic(*type))); + XmlCharacteristic *c = (XmlCharacteristic*) &(*((--m_kart_type_characteristics.end())->second)); + c->getMass(); } // Load player difficulties nodes.clear(); diff --git a/src/karts/xml_characteristic.cpp b/src/karts/xml_characteristic.cpp index f17aaf477..ebb001920 100644 --- a/src/karts/xml_characteristic.cpp +++ b/src/karts/xml_characteristic.cpp @@ -88,15 +88,13 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s { const std::vector processors = StringUtils::split(m_values[type], ' '); + // If the interpolation array should be completely replaced + // That has to happen when the format is not the same + bool shouldReplace = false; if (*is_set) { if (processors.size() != value.fv->size()) - { - Log::error("XmlCharacteristic::process", - "InterpolationArrays have different sizes for %s", - getName(type).c_str()); - break; - } + shouldReplace = true; else { for (std::vector::const_iterator it = processors.begin(); @@ -127,16 +125,23 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s } } if (!found) - Log::error("XmlCharacteristic::process", - "Can't find the %f in %s", x, - getName(type).c_str()); + { + // The searched value was not found so we have + // a different format + shouldReplace = true; + break; + } } } } } - } - else + } else + // It's not yet set, so we will the current content + shouldReplace = true; + + if (shouldReplace) { + // Replace all values for (std::vector::const_iterator it = processors.begin(); it != processors.end(); it++) { diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 0f36b9c68..e34becdfb 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -815,8 +815,7 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id, (kp->getCombinedCharacteristic()->getMass() / 5)); w->setValue(KartStatsWidget::SKILL_SPEED, (int) ((kp->getCombinedCharacteristic()->getEngineMaxSpeed() - 20) * 9)); - w->setValue(KartStatsWidget::SKILL_POWER, (int) - kp->getCombinedCharacteristic()->getEnginePower()); + w->setValue(KartStatsWidget::SKILL_POWER, (int) kp->getAvgPower()); w->update(0); } } From 1317714ba1e3c186efdcf993c76e54bab1971248 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 12 Jul 2015 01:09:01 +0200 Subject: [PATCH 23/55] Adjust the speed and power values --- data/kart_characteristics.xml | 8 ++++---- src/guiengine/widgets/kart_stats_widget.cpp | 9 ++++++--- src/karts/kart_properties.cpp | 4 ++-- src/states_screens/kart_selection.cpp | 8 +++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index 7a5b54e23..3094ede00 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -75,7 +75,7 @@ pressed, the harder the kart will brake. max-speed-reverse-ratio is the percentage of max speed for reverse gear. --> - - @@ -76,7 +76,7 @@ max-speed-reverse-ratio is the percentage of max speed for reverse gear. --> + brake-time-increase="6" max-speed-reverse-ratio="0.65" /> - + - + - + - + @@ -323,13 +323,13 @@ - - + - + - - + - + - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + From 324a93cd65701b55d1ac4202bd2cc33c2ccfa6a8 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 24 Jul 2015 02:10:23 +0200 Subject: [PATCH 27/55] Fix karts without a type --- src/karts/abstract_kart.cpp | 9 +++++++-- src/karts/kart_properties.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index 4e803c00e..f158e0858 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -66,8 +66,13 @@ AbstractKart::AbstractKart(const std::string& ident, m_characteristic->addCharacteristic(kart_properties_manager-> getDifficultyCharacteristic(race_manager->getDifficultyAsString( race_manager->getDifficulty()))); - m_characteristic->addCharacteristic(kart_properties_manager-> - getKartTypeCharacteristic(m_kart_properties->getKartType())); + + // Try to get the kart type + const AbstractCharacteristic *characteristic = kart_properties_manager-> + getKartTypeCharacteristic(m_kart_properties->getKartType()); + if (characteristic) + m_characteristic->addCharacteristic(characteristic); + m_characteristic->addCharacteristic(kart_properties_manager-> getPlayerCharacteristic(KartProperties::getPerPlayerDifficultyAsString( m_difficulty))); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index e9e298f49..ebc91162f 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -312,8 +312,17 @@ void KartProperties::combineCharacteristics() m_combined_characteristic = new CombinedCharacteristic(); m_combined_characteristic->addCharacteristic(kart_properties_manager-> getBaseCharacteristic()); - m_combined_characteristic->addCharacteristic(kart_properties_manager-> - getKartTypeCharacteristic(m_kart_type)); + + // Try to get the kart type + const AbstractCharacteristic *characteristic = kart_properties_manager-> + getKartTypeCharacteristic(m_kart_type); + if (!characteristic) + Log::warn("KartProperties", "Can't find kart type '%s' for kart '%s'", + m_kart_type.c_str(), m_name.c_str()); + else + // Kart type found + m_combined_characteristic->addCharacteristic(characteristic); + m_combined_characteristic->addCharacteristic(m_characteristic); } // combineCharacteristics From 37e78e85a6a9c1f151514f71052217f1195a8944 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 29 Jul 2015 02:25:32 +0200 Subject: [PATCH 28/55] Forgot to convert string to char* --- src/karts/xml_characteristic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/karts/xml_characteristic.cpp b/src/karts/xml_characteristic.cpp index 1d534d4a9..68c9a6515 100644 --- a/src/karts/xml_characteristic.cpp +++ b/src/karts/xml_characteristic.cpp @@ -284,7 +284,7 @@ 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); + Log::error("XmlCharacteristic::processBool", "Can't parse %s: Not a bool", processor.c_str()); } void XmlCharacteristic::load(const XMLNode *node) From ec3083827d68ea27c8c888809d15993ec515eda9 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 29 Jul 2015 23:02:16 +0200 Subject: [PATCH 29/55] Add some documenation and try to get some backwards compatibility --- data/kart_characteristics.xml | 28 +++++++++++++++++++++------ src/karts/kart_properties_manager.cpp | 15 ++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index 8134fbc13..adfead682 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -1,6 +1,19 @@ @@ -317,6 +331,8 @@ + diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index 4794c410c..9e7ca250d 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -207,8 +207,9 @@ void KartPropertiesManager::loadCharacteristics(const XMLNode *root) type != nodes.cend(); type++) { (*type)->get("name", &name); - m_difficulty_characteristics.emplace(name, - std::unique_ptr(new XmlCharacteristic(*type))); + m_difficulty_characteristics.insert(std::pair >(name, + std::unique_ptr(new XmlCharacteristic(*type)))); } // Load kart type characteristics nodes.clear(); @@ -217,8 +218,9 @@ void KartPropertiesManager::loadCharacteristics(const XMLNode *root) type != nodes.cend(); type++) { (*type)->get("name", &name); - m_kart_type_characteristics.emplace(name, - std::unique_ptr(new XmlCharacteristic(*type))); + m_kart_type_characteristics.insert(std::pair >(name, + std::unique_ptr(new XmlCharacteristic(*type)))); } // Load player difficulties nodes.clear(); @@ -227,8 +229,9 @@ void KartPropertiesManager::loadCharacteristics(const XMLNode *root) type != nodes.cend(); type++) { (*type)->get("name", &name); - m_player_characteristics.emplace(name, - std::unique_ptr(new XmlCharacteristic(*type))); + m_player_characteristics.insert(std::pair >(name, + std::unique_ptr(new XmlCharacteristic(*type)))); } } From acbc62961010d672e55106c3ac69b75ded6156ee Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 16 Aug 2015 15:48:27 +0200 Subject: [PATCH 30/55] Add a script that automates the code replacements Various other things: - Try to use newer c++ features - Rename travelcm - Remove wheel radius --- data/kart_characteristics.xml | 2 +- src/karts/abstract_characteristic.cpp | 46 +++++++++++--------- src/karts/abstract_characteristic.hpp | 24 ++++++++--- src/karts/abstract_kart.cpp | 2 +- src/karts/combined_characteristic.cpp | 5 +-- src/karts/kart_properties_manager.cpp | 34 +++++++-------- src/karts/kart_properties_manager.hpp | 2 +- src/karts/xml_characteristic.cpp | 36 +++++++++------- tools/create_kart_properties.py | 60 +++++++++++---------------- tools/update_characteristics.py | 57 +++++++++++++++++++++++++ 10 files changed, 165 insertions(+), 103 deletions(-) create mode 100755 tools/update_characteristics.py diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index adfead682..cb3908258 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -113,7 +113,7 @@ position of the physics raycast wheels relative to the center of gravity. Default is to use the corners of the chassis to attach the wheels to. --> - + diff --git a/src/karts/abstract_characteristic.cpp b/src/karts/abstract_characteristic.cpp index 6269228bb..1c07c5f8d 100755 --- a/src/karts/abstract_characteristic.cpp +++ b/src/karts/abstract_characteristic.cpp @@ -45,7 +45,11 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(Characteristic case CHARACTERISTIC_COUNT: Log::fatal("AbstractCharacteristic::getType", "Can't get type of COUNT"); break; - // Script-generated content get-prop first part + // Script-generated content generated by tools/create_kart_properties.py getProp1 + // Please don't change the following tag. It will be automatically detected + // by the script and replace the contained content. + // To update the code, use tools/update_characteristics.py + /* */ case SUSPENSION_STIFFNESS: return TYPE_FLOAT; case SUSPENSION_REST: @@ -218,6 +222,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(Characteristic return TYPE_FLOAT; case SLIPSTREAM_FADE_OUT_TIME: return TYPE_FLOAT; + /* */ } Log::fatal("AbstractCharacteristic::getType", "Unknown type"); return TYPE_FLOAT; @@ -229,13 +234,17 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) { case CHARACTERISTIC_COUNT: return "CHARACTERISTIC_COUNT"; - // Script-generated content get-prop second part + // Script-generated content generated by tools/create_kart_properties.py getProp2 + // Please don't change the following tag. It will be automatically detected + // by the script and replace the contained content. + // To update the code, use tools/update_characteristics.py + /* */ case SUSPENSION_STIFFNESS: return "SUSPENSION_STIFFNESS"; case SUSPENSION_REST: return "SUSPENSION_REST"; - case SUSPENSION_TRAVEL_CM: - return "SUSPENSION_TRAVEL_CM"; + case SUSPENSION_TRAVEL: + return "SUSPENSION_TRAVEL"; case SUSPENSION_EXP_SPRING_RESPONSE: return "SUSPENSION_EXP_SPRING_RESPONSE"; case SUSPENSION_MAX_FORCE: @@ -278,8 +287,6 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) return "WHEELS_DAMPING_RELAXATION"; case WHEELS_DAMPING_COMPRESSION: return "WHEELS_DAMPING_COMPRESSION"; - case WHEELS_RADIUS: - return "WHEELS_RADIUS"; case WHEELS_POSITION: return "WHEELS_POSITION"; case CAMERA_DISTANCE: @@ -402,12 +409,18 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) return "SLIPSTREAM_MAX_SPEED_INCREASE"; case SLIPSTREAM_FADE_OUT_TIME: return "SLIPSTREAM_FADE_OUT_TIME"; + + /* */ } Log::error("AbstractCharacteristic::getName", "Unknown type"); return "Unknown type"; } -// Script-generated getter +// 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. +// To update the code, use tools/update_characteristics.py +/* */ float AbstractCharacteristic::getSuspensionStiffness() const { float result; @@ -428,13 +441,13 @@ float AbstractCharacteristic::getSuspensionRest() const return result; } -float AbstractCharacteristic::getSuspensionTravelCm() const +float AbstractCharacteristic::getSuspensionTravel() const { float result; bool is_set = false; - process(SUSPENSION_TRAVEL_CM, &result, &is_set); + process(SUSPENSION_TRAVEL, &result, &is_set); if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SUSPENSION_TRAVEL_CM).c_str()); + Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(SUSPENSION_TRAVEL).c_str()); return result; } @@ -648,16 +661,6 @@ float AbstractCharacteristic::getWheelsDampingCompression() const return result; } -float AbstractCharacteristic::getWheelsRadius() const -{ - float result; - bool is_set = false; - process(WHEELS_RADIUS, &result, &is_set); - if (!is_set) - Log::fatal("AbstractCharacteristic", "Can't get characteristic %s", getName(WHEELS_RADIUS).c_str()); - return result; -} - std::vector AbstractCharacteristic::getWheelsPosition() const { std::vector result; @@ -1268,3 +1271,6 @@ float AbstractCharacteristic::getSlipstreamFadeOutTime() const return result; } + +/* */ + diff --git a/src/karts/abstract_characteristic.hpp b/src/karts/abstract_characteristic.hpp index b864b5649..f82ec3aec 100755 --- a/src/karts/abstract_characteristic.hpp +++ b/src/karts/abstract_characteristic.hpp @@ -66,11 +66,16 @@ public: enum CharacteristicType { - // Script-generated content + // Script-generated content generated by tools/create_kart_properties.py enum + // Please don't change the following tag. It will be automatically detected + // by the script and replace the contained content. + // To update the code, use tools/update_characteristics.py + /* */ + // Suspension SUSPENSION_STIFFNESS, SUSPENSION_REST, - SUSPENSION_TRAVEL_CM, + SUSPENSION_TRAVEL, SUSPENSION_EXP_SPRING_RESPONSE, SUSPENSION_MAX_FORCE, @@ -104,7 +109,6 @@ public: // Wheels WHEELS_DAMPING_RELAXATION, WHEELS_DAMPING_COMPRESSION, - WHEELS_RADIUS, WHEELS_POSITION, // Camera @@ -195,6 +199,8 @@ public: SLIPSTREAM_MAX_SPEED_INCREASE, SLIPSTREAM_FADE_OUT_TIME, + /* */ + // Count CHARACTERISTIC_COUNT @@ -228,10 +234,15 @@ public: static ValueType getType(CharacteristicType type); static std::string getName(CharacteristicType type); - // Script-generated content + // Script-generated content generated by tools/create_kart_properties.py defs + // Please don't change the following tag. It will be automatically detected + // by the script and replace the contained content. + // To update the code, use tools/update_characteristics.py + /* */ + float getSuspensionStiffness() const; float getSuspensionRest() const; - float getSuspensionTravelCm() const; + float getSuspensionTravel() const; bool getSuspensionExpSpringResponse() const; float getSuspensionMaxForce() const; @@ -259,7 +270,6 @@ public: float getWheelsDampingRelaxation() const; float getWheelsDampingCompression() const; - float getWheelsRadius() const; std::vector getWheelsPosition() const; float getCameraDistance() const; @@ -335,6 +345,8 @@ public: float getSlipstreamMinSpeed() const; float getSlipstreamMaxSpeedIncrease() const; float getSlipstreamFadeOutTime() const; + + /* */ }; #endif diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index f158e0858..d6be55711 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -101,7 +101,7 @@ void AbstractKart::reset() // ---------------------------------------------------------------------------- const AbstractCharacteristic* AbstractKart::getCharacteristic() const { - return &(*m_characteristic); + return m_characteristic.get(); } // ---------------------------------------------------------------------------- diff --git a/src/karts/combined_characteristic.cpp b/src/karts/combined_characteristic.cpp index 9a5ee2484..4b760c2c7 100644 --- a/src/karts/combined_characteristic.cpp +++ b/src/karts/combined_characteristic.cpp @@ -36,8 +36,7 @@ const SkiddingProperties* CombinedCharacteristic::getSkiddingProperties() const void CombinedCharacteristic::process(CharacteristicType type, Value value, bool *is_set) const { - for (std::vector::const_iterator it = m_childs.cbegin(); - it != m_childs.cend(); it++) - (*it)->process(type, value, is_set); + for (const AbstractCharacteristic *characteristic : m_childs) + characteristic->process(type, value, is_set); } diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index 9e7ca250d..a9f58429c 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -186,14 +186,13 @@ void KartPropertiesManager::loadCharacteristics(const XMLNode *root) root->getNodes("characteristic", nodes); bool found = false; std::string name; - for (std::vector::const_iterator baseNode = nodes.cbegin(); - baseNode != nodes.cend(); baseNode++) + for (const XMLNode *baseNode : nodes) { - (*baseNode)->get("name", &name); + baseNode->get("name", &name); if (name == "base") { found = true; - m_base_characteristic.reset(new XmlCharacteristic(*baseNode)); + m_base_characteristic.reset(new XmlCharacteristic(baseNode)); break; } } @@ -203,35 +202,32 @@ void KartPropertiesManager::loadCharacteristics(const XMLNode *root) // Load difficulties nodes.clear(); root->getNode("difficulties")->getNodes("characteristic", nodes); - for (std::vector::const_iterator type = nodes.cbegin(); - type != nodes.cend(); type++) + for (const XMLNode *type : nodes) { - (*type)->get("name", &name); + type->get("name", &name); m_difficulty_characteristics.insert(std::pair >(name, - std::unique_ptr(new XmlCharacteristic(*type)))); + std::unique_ptr(new XmlCharacteristic(type)))); } // Load kart type characteristics nodes.clear(); root->getNode("kart-types")->getNodes("characteristic", nodes); - for (std::vector::const_iterator type = nodes.cbegin(); - type != nodes.cend(); type++) + for (const XMLNode *type : nodes) { - (*type)->get("name", &name); + type->get("name", &name); m_kart_type_characteristics.insert(std::pair >(name, - std::unique_ptr(new XmlCharacteristic(*type)))); + std::unique_ptr(new XmlCharacteristic(type)))); } // Load player difficulties nodes.clear(); root->getNode("player-characteristics")->getNodes("characteristic", nodes); - for (std::vector::const_iterator type = nodes.cbegin(); - type != nodes.cend(); type++) + for (const XMLNode *type : nodes) { - (*type)->get("name", &name); + type->get("name", &name); m_player_characteristics.insert(std::pair >(name, - std::unique_ptr(new XmlCharacteristic(*type)))); + std::unique_ptr(new XmlCharacteristic(type)))); } } @@ -303,7 +299,7 @@ const AbstractCharacteristic* KartPropertiesManager::getDifficultyCharacteristic it = m_difficulty_characteristics.find(type); if (it == m_difficulty_characteristics.cend()) return nullptr; - return &(*it->second); + return it->second.get(); } // getDifficultyCharacteristic //----------------------------------------------------------------------------- @@ -313,7 +309,7 @@ const AbstractCharacteristic* KartPropertiesManager::getKartTypeCharacteristic(c it = m_kart_type_characteristics.find(type); if (it == m_kart_type_characteristics.cend()) return nullptr; - return &(*it->second); + return it->second.get(); } // getKartTypeCharacteristic //----------------------------------------------------------------------------- @@ -323,7 +319,7 @@ const AbstractCharacteristic* KartPropertiesManager::getPlayerCharacteristic(con it = m_player_characteristics.find(type); if (it == m_player_characteristics.cend()) return nullptr; - return &(*it->second); + return it->second.get(); } // getPlayerCharacteristic //----------------------------------------------------------------------------- diff --git a/src/karts/kart_properties_manager.hpp b/src/karts/kart_properties_manager.hpp index 12f1fb497..af621b4e7 100644 --- a/src/karts/kart_properties_manager.hpp +++ b/src/karts/kart_properties_manager.hpp @@ -99,7 +99,7 @@ public: void setHatMeshName(const std::string &hat_name); // ------------------------------------------------------------------------ /** Get the characteristic that holds the base values. */ - const AbstractCharacteristic* getBaseCharacteristic() const { return &(*m_base_characteristic); } + const AbstractCharacteristic* getBaseCharacteristic() const { return m_base_characteristic.get(); } // ------------------------------------------------------------------------ /** Get a characteristic that holds the values for a certain difficulty. */ const AbstractCharacteristic* getDifficultyCharacteristic(const std::string &type) const; diff --git a/src/karts/xml_characteristic.cpp b/src/karts/xml_characteristic.cpp index 68c9a6515..2941307b4 100644 --- a/src/karts/xml_characteristic.cpp +++ b/src/karts/xml_characteristic.cpp @@ -59,17 +59,17 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s else { std::vector::iterator fit = value.fv->begin(); - for (std::vector::const_iterator it = processors.begin(); - it != processors.end(); it++, fit++) + for (const std::string &processor : processors) { - processFloat(*it, &*fit, is_set); + processFloat(processor, &*fit, is_set); if (!*is_set) { Log::error("XmlCharacteristic::process", "Can't process %s", - it->c_str()); + processor.c_str()); value.fv->clear(); break; } + fit++; } } } @@ -80,11 +80,10 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s { value.fv->resize(processors.size()); std::vector::iterator fit = value.fv->begin(); - for (std::vector::const_iterator it = processors.begin(); - it != processors.end(); it++, fit++) + for (const std::string &processor : processors) { *is_set = false; - processFloat(*it, &*fit, is_set); + processFloat(processor, &*fit, is_set); if (!*is_set) { @@ -93,6 +92,7 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s value.fv->clear(); break; } + fit++; } } break; @@ -110,10 +110,9 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s shouldReplace = true; else { - for (std::vector::const_iterator it = processors.begin(); - it != processors.end(); it++) + for (const std::string &processor : processors) { - std::vector pair = StringUtils::split(*it, ':'); + std::vector pair = StringUtils::split(processor, ':'); if (pair.size() != 2) Log::error("XmlCharacteristic::process", "Can't process %s: Wrong format", getName(type).c_str()); @@ -162,10 +161,9 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s if (shouldReplace) { // Replace all values - for (std::vector::const_iterator it = processors.begin(); - it != processors.end(); it++) + for (const std::string &processor : processors) { - std::vector pair = StringUtils::split(*it,':'); + std::vector pair = StringUtils::split(processor,':'); if (pair.size() != 2) Log::error("XmlCharacteristic::process", "Can't process %s: Wrong format", getName(type).c_str()); @@ -289,12 +287,16 @@ void XmlCharacteristic::processBool(const std::string &processor, bool *value, b void XmlCharacteristic::load(const XMLNode *node) { - // Script-generated content getXml + // Script-generated content generated by tools/create_kart_properties.py getXml + // Please don't change the following tag. It will be automatically detected + // by the script and replace the contained content. + // To update the code, use tools/update_characteristics.py + /* */ if (const XMLNode *sub_node = node->getNode("suspension")) { sub_node->get("stiffness", &m_values[SUSPENSION_STIFFNESS]); sub_node->get("rest", &m_values[SUSPENSION_REST]); - sub_node->get("travel-cm", &m_values[SUSPENSION_TRAVEL_CM]); + sub_node->get("travel", &m_values[SUSPENSION_TRAVEL]); sub_node->get("exp-spring-response", &m_values[SUSPENSION_EXP_SPRING_RESPONSE]); sub_node->get("max-force", &m_values[SUSPENSION_MAX_FORCE]); } @@ -340,7 +342,6 @@ void XmlCharacteristic::load(const XMLNode *node) { sub_node->get("damping-relaxation", &m_values[WHEELS_DAMPING_RELAXATION]); sub_node->get("damping-compression", &m_values[WHEELS_DAMPING_COMPRESSION]); - sub_node->get("radius", &m_values[WHEELS_RADIUS]); sub_node->get("position", &m_values[WHEELS_POSITION]); } @@ -459,5 +460,8 @@ void XmlCharacteristic::load(const XMLNode *node) sub_node->get("max-speed-increase", &m_values[SLIPSTREAM_MAX_SPEED_INCREASE]); sub_node->get("fade-out-time", &m_values[SLIPSTREAM_FADE_OUT_TIME]); } + + + /* */ } diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 726ddea53..407a8d881 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -17,21 +17,20 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# This script creates the output for the AbstractCharacteristics +# This script creates code for the characteristics. # It takes an argument that specifies what the output of the script should be. # The output options can be seen by running this script without arguments. import sys # Input data -#FIXME is wheelPosition needed? -characteristics = """Suspension: stiffness, rest, travelCm, expSpringResponse(bool), maxForce +characteristics = """Suspension: stiffness, rest, travel, expSpringResponse(bool), maxForce Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray) Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio Gear: switchRatio(std::vector/floatVector), powerIncrease(std::vector/floatVector) Mass -Wheels: dampingRelaxation, dampingCompression, radius, position(std::vector/floatVector) +Wheels: dampingRelaxation, dampingCompression, position(std::vector/floatVector) Camera: distance, forwardUpAngle, backwardUpAngle Jump: animationTime Lean: max, speed @@ -58,12 +57,12 @@ class GroupMember: self.typeC = typeC self.typeStr = typeStr - """E.g. power(std::vector/floatVector) - or speed(InterpolationArray) - The default type is float - The name 'value' is special: Only the group name will be used to access - the member but in the xml file it will be still value (because we - need a name).""" + """ E.g. power(std::vector/floatVector) + or speed(InterpolationArray) + The default type is float + The name 'value' is special: Only the group name will be used to access + the member but in the xml file it will be still value (because we + need a name). """ def parse(content): typeC = "float" typeStr = typeC @@ -93,8 +92,8 @@ class Group: def getBaseName(self): return self.baseName - """E.g. engine: power, gears(std::vector/Gears) - or mass(float) or only mass""" + """ E.g. engine: power, gears(std::vector/Gears) + or mass(float) or only mass """ def parse(content): pos = content.find(":") if pos == -1: @@ -107,7 +106,7 @@ class Group: group.addMember(m) return group -"""Creates a list of words from a titlecase string""" +""" Creates a list of words from a titlecase string """ def toList(name): result = [] cur = "" @@ -120,8 +119,8 @@ def toList(name): result.append(cur) return result -"""titleCase: true = result is titlecase - false = result has underscores""" +""" titleCase: true = result is titlecase + false = result has underscores """ def joinSubName(group, member, titleCase): words = toList(group.baseName) + toList(member.getName) first = True @@ -134,7 +133,14 @@ def joinSubName(group, member, titleCase): def main(): # Find out what to do if len(sys.argv) == 1: - print("Please specify what you want to know [enum|defs|getter|getProp|getXml]") + print("""Usage: ./create_kart_properties.py +Operations: + enum List the enum values for all characteristics in abstract_characteristic.hpp + defs Create the headers in abstract_characteristic.hpp + getter The getter implementations in abstract_characteristic.cpp + getProp1 Creates the getType function in abstract_characteristic.cpp + getProp2 Creates the getName funciton in abstract_characteristic.cpp + getXml Used to load the characteristics from an xml file in xml_characteristic.cpp""") return task = sys.argv[1] @@ -187,14 +193,14 @@ def main(): return {4}; }} """.format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result)) - elif task == "getProp": + elif task == "getProp1": for g in groups: for m in g.members: nameTitle = joinSubName(g, m, True) nameUnderscore = joinSubName(g, m, False) print(" case {0}:\n return TYPE_{1};". format(nameUnderscore.upper(), "_".join(toList(m.typeStr)).upper())) - print("\n\n-------------------- END --------------------\n") + elif task == "getProp2": for g in groups: for m in g.members: nameTitle = joinSubName(g, m, True) @@ -214,24 +220,6 @@ def main(): else: print("Unknown task") - #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() diff --git a/tools/update_characteristics.py b/tools/update_characteristics.py new file mode 100755 index 000000000..0c8ee9c78 --- /dev/null +++ b/tools/update_characteristics.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# +# SuperTuxKart - a fun racing game with go-kart +# Copyright (C) 2006-2015 SuperTuxKart-Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This script uses create_kart_properties.py to create code and then replaces +# the code in the source files. The parts in the source are marked with tags, that +# contain the argument that has to be passed to create_kart_properties.py. +# The script has to be run from the root directory of this project. + +import os +import re +import subprocess + +# Where and what should be replaced +replacements = [ + ["enum", "karts/abstract_characteristic.hpp"], + ["defs", "karts/abstract_characteristic.hpp"], + ["getter", "karts/abstract_characteristic.cpp"], + ["getProp1", "karts/abstract_characteristic.cpp"], + ["getProp2", "karts/abstract_characteristic.cpp"], + ["getXml", "karts/xml_characteristic.cpp"]] + +def main(): + # Check, if it runs in the root directory + if not os.path.isfile("tools/update_characteristics.py"): + print("Please run this script in the root directory of the project.") + exit(1) + for replacement in replacements: + result = subprocess.Popen("tools/create_kart_properties.py " + + replacement[0] + " 2> /dev/null", shell = True, + stdout = subprocess.PIPE).stdout.read().decode('UTF-8') + with open("src/" + replacement[1], "r") as f: + text = f.read() + # Replace the text by using look behinds and look forwards + text = re.sub("(?<=/\* \ \*/\\n)(.|\n)*(?=\\n\s*/\* \*/)", result, text) + with open("src/" + replacement[1], "w") as f: + f.write(text) + +if __name__ == '__main__': + main() + From 1c29ce7636442cc3b2e846d800ec8d4b083eff2e Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 16 Aug 2015 16:23:06 +0200 Subject: [PATCH 31/55] Fix little issues and remove wheel position from characteristics --- data/kart_characteristics.xml | 2 +- src/karts/abstract_characteristic.cpp | 21 +++------------------ src/karts/abstract_characteristic.hpp | 2 -- src/karts/kart.cpp | 6 +++--- src/karts/xml_characteristic.cpp | 1 - tools/create_kart_properties.py | 2 +- 6 files changed, 8 insertions(+), 26 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index cb3908258..62076a803 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -34,7 +34,7 @@ http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\&p=25236&hilit=vehicle#p25236 for details. max-force: Maximum suspension force --> - [0, 1] - m_real_steering = m_skid_reduce_turn_min+ - m_skid_reduce_turn_delta*f; - if(m_skid_time < m_skid_visual_time) - m_visual_rotation = m_skid_visual*m_real_steering*m_skid_time - / m_skid_visual_time; + m_real_steering = m_kart->getCharacteristic()->getSkidReduceTurnMin() + + m_skid_reduce_turn_delta * f; + if(m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime()) + m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() + * m_real_steering * m_skid_time + / m_kart->getCharacteristic()->getSkidVisualTime(); else - m_visual_rotation = m_skid_visual * m_real_steering; + m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() * m_real_steering; break; } case SKID_ACCUMULATE_LEFT: { float f = (-1.0f+steer)*0.5f; // map [-1,1] --> [-1, 0] - m_real_steering = -m_skid_reduce_turn_min+ - m_skid_reduce_turn_delta*f; - if(m_skid_time < m_skid_visual_time) - m_visual_rotation = m_skid_visual*m_real_steering*m_skid_time - / m_skid_visual_time; + m_real_steering = -m_kart->getCharacteristic()->getSkidReduceTurnMin() + + m_skid_reduce_turn_delta * f; + if(m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime()) + m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() + * m_real_steering * m_skid_time + / m_kart->getCharacteristic()->getSkidVisualTime(); else - m_visual_rotation = m_skid_visual * m_real_steering; + m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() * m_real_steering; break; } @@ -173,13 +175,13 @@ float Skidding::getSteeringWhenSkidding(float steering) const break; case SKID_ACCUMULATE_RIGHT: { - float f = (steering - m_skid_reduce_turn_min) + float f = (steering - m_kart->getCharacteristic()->getSkidReduceTurnMin()) / m_skid_reduce_turn_delta; return f *2.0f-1.0f; } case SKID_ACCUMULATE_LEFT: { - float f = (steering + m_skid_reduce_turn_min) + float f = (steering + m_kart->getCharacteristic()->getSkidReduceTurnMin()) / m_skid_reduce_turn_delta; return 2.0f * f +1.0f; } @@ -212,7 +214,7 @@ void Skidding::update(float dt, bool is_on_ground, #endif // No skidding backwards or while stopped - if(m_kart->getSpeed() < m_min_skid_speed && + if(m_kart->getSpeed() < m_kart->getCharacteristic()->getSkidMinSpeed() && m_skid_state != SKID_NONE && m_skid_state != SKID_BREAK) { m_skid_state = SKID_BREAK; @@ -223,15 +225,16 @@ void Skidding::update(float dt, bool is_on_ground, m_skid_bonus_ready = false; if (is_on_ground) { - if((fabs(steering) > 0.001f) && - m_kart->getSpeed()>m_min_skid_speed && - (skidding==KartControl::SC_LEFT||skidding==KartControl::SC_RIGHT)) + if ((fabs(steering) > 0.001f) && + m_kart->getSpeed() > m_kart->getCharacteristic()->getSkidMinSpeed() && + (skidding == KartControl::SC_LEFT || skidding == KartControl::SC_RIGHT)) { - m_skid_factor += m_skid_increase *dt/m_time_till_max_skid; + m_skid_factor += m_kart->getCharacteristic()->getSkidIncrease() + * dt / m_kart->getCharacteristic()->getSkidTimeTillMax(); } - else if(m_skid_factor>1.0f) + else if (m_skid_factor > 1.0f) { - m_skid_factor *= m_skid_decrease; + m_skid_factor *= m_kart->getCharacteristic()->getSkidDecrease(); } } else @@ -239,10 +242,10 @@ void Skidding::update(float dt, bool is_on_ground, m_skid_factor = 1.0f; // Lose any skid factor as soon as we fly } - if(m_skid_factor>m_skid_max) - m_skid_factor = m_skid_max; + if (m_skid_factor > m_kart->getCharacteristic()->getSkidMax()) + m_skid_factor = m_kart->getCharacteristic()->getSkidMax(); else - if(m_skid_factor<1.0f) m_skid_factor = 1.0f; + if (m_skid_factor < 1.0f) m_skid_factor = 1.0f; // If skidding was started and a graphical jump should still // be displayed, update the data @@ -288,8 +291,9 @@ void Skidding::update(float dt, bool is_on_ground, break; // Don't allow skidding while the kart is (apparently) // still in the air, or when the kart is too slow - if(m_remaining_jump_time>0 || - m_kart->getSpeed() 0 || + m_kart->getSpeed() < m_kart->getCharacteristic()->getSkidMinSpeed()) + break; m_skid_state = skidding==KartControl::SC_RIGHT ? SKID_ACCUMULATE_RIGHT @@ -300,14 +304,14 @@ void Skidding::update(float dt, bool is_on_ground, // Then use this speed to determine the impulse necessary to // reach this speed. float v = World::getWorld()->getTrack()->getGravity() - * 0.5f*m_physical_jump_time; + * 0.5f * m_kart->getCharacteristic()->getSkidPhysicalJumpTime(); btVector3 imp(0, v / m_kart->getBody()->getInvMass(),0); m_kart->getVehicle()->getRigidBody()->applyCentralImpulse(imp); // Some karts might use a graphical-only jump. Set it up: m_jump_speed = World::getWorld()->getTrack()->getGravity() - * 0.5f*m_graphical_jump_time; - m_remaining_jump_time = m_graphical_jump_time; + * 0.5f * m_kart->getCharacteristic()->getSkidGraphicalJumpTime(); + m_remaining_jump_time = m_kart->getCharacteristic()->getSkidGraphicalJumpTime(); #ifdef SKID_DEBUG #define SPEED 20.0f @@ -388,11 +392,11 @@ void Skidding::update(float dt, bool is_on_ground, m_skid_state = m_skid_state == SKID_ACCUMULATE_LEFT ? SKID_SHOW_GFX_LEFT : SKID_SHOW_GFX_RIGHT; - float t = std::min(m_skid_time, m_skid_visual_time); - t = std::min(t, m_skid_revert_visual_time); + float t = std::min(m_skid_time, m_kart->getCharacteristic()->getSkidVisualTime()); + t = std::min(t, m_kart->getCharacteristic()->getSkidRevertVisualTime()); float vso = getVisualSkidRotation(); - btVector3 rot(0, vso*m_post_skid_rotate_factor, 0); + btVector3 rot(0, vso * m_kart->getCharacteristic()->getSkidPostSkidRotateFactor(), 0); m_kart->getVehicle()->setTimedRotation(t, rot); // skid_time is used to count backwards for the GFX m_skid_time = t; @@ -455,13 +459,14 @@ unsigned int Skidding::getSkidBonus(float *bonus_time, *bonus_time = 0; *bonus_speed = 0; *bonus_force = 0; - for(unsigned int i=0; igetCharacteristic()->getSkidBonusSpeed().size(); i++) { - if(m_skid_time<=m_skid_time_till_bonus[i]) return i; - *bonus_speed = m_skid_bonus_speed[i]; - *bonus_time = m_skid_bonus_time[i]; - *bonus_force = m_skid_bonus_force[i]; + if (m_skid_time <= m_kart->getCharacteristic()->getSkidTimeTillBonus()[i]) + return i; + *bonus_speed = m_kart->getCharacteristic()->getSkidBonusSpeed()[i]; + *bonus_time = m_kart->getCharacteristic()->getSkidBonusTime()[i]; + *bonus_force = m_kart->getCharacteristic()->getSkidBonusForce()[i]; } - return (unsigned int) m_skid_bonus_speed.size(); + return (unsigned int) m_kart->getCharacteristic()->getSkidBonusSpeed().size(); } // getSkidBonusForce diff --git a/src/karts/skidding.hpp b/src/karts/skidding.hpp index a53c0d989..4d4d854d8 100644 --- a/src/karts/skidding.hpp +++ b/src/karts/skidding.hpp @@ -19,7 +19,6 @@ #ifndef HEADER_SKIDDING_HPP #define HEADER_SKIDDING_HPP -#include "karts/skidding_properties.hpp" #include "karts/controller/kart_control.hpp" #include "utils/leak_check.hpp" #include "utils/no_copy.hpp" @@ -35,7 +34,7 @@ class ShowCurve; #undef SKID_DEBUG -class Skidding : public SkiddingProperties +class Skidding { public: LEAK_CHECK(); @@ -101,7 +100,7 @@ private: float *bonus_force) const; void updateSteering(float steer, float dt); public: - Skidding(Kart *kart, const SkiddingProperties *sp); + Skidding(Kart *kart); ~Skidding(); void reset(); void update(float dt, bool is_on_ground, float steer, diff --git a/src/karts/skidding_properties.cpp b/src/karts/skidding_properties.cpp deleted file mode 100644 index 0f2f28d6b..000000000 --- a/src/karts/skidding_properties.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2012-2015 Joerg Henrichs -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "karts/skidding_properties.hpp" - -#include "io/xml_node.hpp" -#include "utils/log.hpp" - -#include - -float SkiddingProperties::UNDEFINED = -99.9f; - -SkiddingProperties::SkiddingProperties() -{ - m_skid_increase = UNDEFINED; - m_skid_decrease = UNDEFINED; - m_skid_max = UNDEFINED; - m_time_till_max_skid = UNDEFINED; - m_skid_visual = UNDEFINED; - m_skid_visual_time = UNDEFINED; - m_skid_revert_visual_time = UNDEFINED; - m_post_skid_rotate_factor = UNDEFINED; - m_skid_reduce_turn_min = UNDEFINED; - m_skid_reduce_turn_max = UNDEFINED; - m_physical_jump_time = UNDEFINED; - m_graphical_jump_time = UNDEFINED; - m_min_skid_speed = UNDEFINED; - m_has_skidmarks = true; - - m_skid_bonus_time.clear(); - m_skid_bonus_speed.clear(); - m_skid_time_till_bonus.clear(); - m_skid_bonus_force.clear(); -} // SkiddingProperties - -// ---------------------------------------------------------------------------- -void SkiddingProperties::load(const XMLNode *skid_node) -{ - skid_node->get("increase", &m_skid_increase ); - skid_node->get("decrease", &m_skid_decrease ); - skid_node->get("max", &m_skid_max ); - skid_node->get("time-till-max", &m_time_till_max_skid ); - skid_node->get("visual", &m_skid_visual ); - skid_node->get("visual-time", &m_skid_visual_time ); - skid_node->get("revert-visual-time", &m_skid_revert_visual_time); - skid_node->get("post-skid-rotate-factor",&m_post_skid_rotate_factor); - skid_node->get("reduce-turn-min", &m_skid_reduce_turn_min ); - skid_node->get("reduce-turn-max", &m_skid_reduce_turn_max ); - skid_node->get("enable", &m_has_skidmarks ); - skid_node->get("bonus-time", &m_skid_bonus_time ); - skid_node->get("bonus-speed", &m_skid_bonus_speed ); - skid_node->get("time-till-bonus", &m_skid_time_till_bonus ); - skid_node->get("bonus-force", &m_skid_bonus_force ); - skid_node->get("physical-jump-time", &m_physical_jump_time ); - skid_node->get("graphical-jump-time", &m_graphical_jump_time ); - skid_node->get("min-speed", &m_min_skid_speed ); -} // load - -// ---------------------------------------------------------------------------- -void SkiddingProperties::checkAllSet(const std::string &filename) const -{ -#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \ - Log::fatal("Skidding_Properties", "Missing default value for '%s'"\ - "in '%s'.", \ - strA,filename.c_str()); \ - } - CHECK_NEG(m_skid_increase, "skid increase" ); - CHECK_NEG(m_skid_decrease, "skid decrease" ); - CHECK_NEG(m_skid_max, "skid max" ); - CHECK_NEG(m_time_till_max_skid, "skid time-till-max" ); - CHECK_NEG(m_skid_visual, "skid visual" ); - CHECK_NEG(m_skid_visual_time, "skid visual-time" ); - CHECK_NEG(m_skid_revert_visual_time, "skid revert-visual-time" ); - CHECK_NEG(m_post_skid_rotate_factor, "skid post-skid-rotate-factor" ); - CHECK_NEG(m_skid_reduce_turn_min, "skid reduce-turn-min" ); - CHECK_NEG(m_skid_reduce_turn_max, "skid reduce-turn-max" ); - CHECK_NEG(m_physical_jump_time, "skid physical-jump-time" ); - CHECK_NEG(m_graphical_jump_time, "skid graphical-jump-time" ); - CHECK_NEG(m_min_skid_speed, "skid min-speed" ); - - if(m_skid_time_till_bonus.size()==0) - Log::error("Skidding_Properties", "Warning: no skid time declared," - "can be ignored."); - if(m_skid_time_till_bonus.size()!=m_skid_bonus_speed.size()) - { - Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus" - "and bonus-speed\n must have same number of elements."); - } - if(m_skid_time_till_bonus.size()!=m_skid_bonus_time.size()) - { - Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus" - "and bonus-time must\n have same number of elements."); - } - if(m_skid_time_till_bonus.size()!=m_skid_bonus_force.size()) - { - Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus" - "and bonus-force must\n have same number of elements."); - } - for(unsigned int i=0; i=m_skid_time_till_bonus[i+1]) - { - Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus" - "not sorted."); - } - } // for i - -} // check - -// ---------------------------------------------------------------------------- -void SkiddingProperties::copyFrom(const SkiddingProperties *destination) -{ - *this = *destination; -} // copyFrom - -// ---------------------------------------------------------------------------- - - -/* EOF */ diff --git a/src/karts/skidding_properties.hpp b/src/karts/skidding_properties.hpp deleted file mode 100644 index be9fe790a..000000000 --- a/src/karts/skidding_properties.hpp +++ /dev/null @@ -1,171 +0,0 @@ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2012-2015 Joerg Henrichs -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef HEADER_SKIDDING_PROPERTIES_HPP -#define HEADER_SKIDDING_PROPERTIES_HPP - -#include "utils/leak_check.hpp" -#include "utils/no_copy.hpp" - -class Kart; -class XMLNode; - -#include -#include - -/** A simple class that stores all skidding related properties. It acts as - * interface between kart_properties and Skidding (to avoid either passing - * very many individual variables, or making KartProperties a dependency - * of Skidding). - * \ingroup karts - */ - -class SkiddingProperties -{ -public: - //LEAK_CHECK(); -protected: - /** Skidding is multiplied by this when skidding - * to increase to m_skid_increase. */ - float m_skid_increase; - - /** Skidding is multiplied by this when not skidding to decrease to 1.0. */ - float m_skid_decrease; - - /** How long it takes for visual skid to reach maximum. */ - float m_skid_visual_time; - - /** How long it takes for the physical and graphical bodies to be - * in sync again after a skid. */ - float m_skid_revert_visual_time; - - /** Time till maximum skidding is reached. */ - float m_time_till_max_skid; - - /** Maximal increase of steering when skidding. */ - float m_skid_max; - - /** Additional rotation of 3d model when skidding. */ - float m_skid_visual; - - /** Time for a small physical when skidding starts. */ - float m_physical_jump_time; - - /** Time for a small graphics-only jump when skidding starts. */ - float m_graphical_jump_time; - - /** This factor is used to determine how much the chassis of a kart - * should rotate to match the graphical view. A factor of 1 is - * identical, a smaller factor will rotate the kart less (which might - * feel better). */ - float m_post_skid_rotate_factor; - - /*** Minimum speed a kart must have before it can skid. */ - float m_min_skid_speed; - - /** Time of skidding before you get a bonus boost. It's possible to - * define more than one time, i.e. longer skidding gives more bonus. */ - std::vector m_skid_time_till_bonus; - - /** How much additional speed a kart gets when skidding. It's possible to - * define more than one speed, i.e. longer skidding gives more bonus. */ - std::vector m_skid_bonus_speed; - - /** How long the bonus will last. It's possible to define more than one - * time, i.e. longer skidding gives more bonus. */ - std::vector m_skid_bonus_time; - - /** Additional force accelerating the kart (in addition to the immediate - * speed bonus). Without this force turning to correct the direction - * after skidding will use up nearly all of the additional speed (turning - * reduces the forward engine impulse) */ - std::vector m_skid_bonus_force; - - /** A factor is used to reduce the amount of steering while skidding. This - * is the minimum factor used (i.e. resulting in the largest turn - * radius). */ - float m_skid_reduce_turn_min; - - /** A factor is used to reduce the amount of steering while skidding. This - * is the maximum factor used (i.e. resulting in the smallest turn - * radius). */ - float m_skid_reduce_turn_max; - - - /** Kart leaves skid marks. */ - bool m_has_skidmarks; - - /** Used to check that all values are defined in the xml file. */ - static float UNDEFINED; - -public: - - SkiddingProperties(); - void load(const XMLNode *skid_node); - void copyFrom(const SkiddingProperties *destination); - void checkAllSet(const std::string &filename) const; - // ------------------------------------------------------------------------ - /** Returns if the kart leaves skidmarks or not. */ - bool hasSkidmarks() const { return m_has_skidmarks; } - - // ------------------------------------------------------------------------ - /** Returns the maximum factor by which the steering angle - * can be increased. */ - float getMaxSkid() const {return m_skid_max; } - - // ------------------------------------------------------------------------ - /** Returns additional rotation of 3d model when skidding. */ - float getSkidVisual () const {return m_skid_visual; } - - // ------------------------------------------------------------------------ - /** Returns the time for the visual skid to reach maximum. */ - float getSkidVisualTime () const {return m_skid_visual_time; } - - // ------------------------------------------------------------------------ - /** Returns a factor to be used to determine how much the chassis of a - * kart should rotate to match the graphical view. A factor of 1 is - * identical, a smaller factor will rotate the kart less (which might - * feel better). */ - float getPostSkidRotateFactor () const {return m_post_skid_rotate_factor;} - - // ------------------------------------------------------------------------ - /** Returns the factor by which to recude the amount of steering while - skidding. */ - float getSkidReduceTurnMin () const { return m_skid_reduce_turn_min; } - // ------------------------------------------------------------------------ - float getSkidReduceTurnMax () const { return m_skid_reduce_turn_max; } - // ------------------------------------------------------------------------ - /** Returns how many boni are defined for this kart. */ - int getNumberOfBonusTimes() const { return (int) m_skid_bonus_time.size(); } - // ------------------------------------------------------------------------ - /** Returns how long a kart must skid in order to reach the specified - * bonus level. - * param n Bonus level (0<=n Date: Mon, 23 Nov 2015 01:19:00 +0100 Subject: [PATCH 42/55] Hold one kart properties object per player --- src/karts/abstract_kart.cpp | 5 +++-- src/karts/abstract_kart.hpp | 7 ++----- src/karts/kart.cpp | 2 +- src/karts/kart_properties.cpp | 35 +++++++++++++++++++++++------------ src/karts/kart_properties.hpp | 6 ++++-- 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index e3ed8e993..e8e9044b1 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -41,10 +41,11 @@ AbstractKart::AbstractKart(const std::string& ident, : Moveable() { m_world_kart_id = world_kart_id; - m_kart_properties = kart_properties_manager->getKart(ident); + m_kart_properties.reset(new KartProperties()); + m_kart_properties->copyForPlayer(kart_properties_manager->getKart(ident)); m_difficulty = difficulty; m_kart_animation = NULL; - assert(m_kart_properties != NULL); + assert(m_kart_properties); // We have to take a copy of the kart model, since otherwise // the animations will be mixed up (i.e. different instances of diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index 78c6187a4..516c87200 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -74,7 +74,7 @@ private: protected: /** The kart properties. */ - const KartProperties *m_kart_properties; + std::unique_ptr m_kart_properties; /** The per-player difficulty. */ PerPlayerDifficulty m_difficulty; @@ -128,10 +128,7 @@ public: // ------------------------------------------------------------------------ /** Returns the kart properties of this kart. */ const KartProperties* getKartProperties() const - { return m_kart_properties; } - // ------------------------------------------------------------------------ - /** Sets the kart properties. */ - void setKartProperties(const KartProperties *kp) { m_kart_properties=kp; } + { return m_kart_properties.get(); } // ------------------------------------------------------------------------ /** Returns the characteristics of this kart. */ const AbstractCharacteristic* getCharacteristic() const; diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 4ea131bf0..9ab4f1888 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2455,7 +2455,7 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model) if (!CVS->supportsShadows()) { - m_shadow = new Shadow(m_kart_properties, m_node, + m_shadow = new Shadow(m_kart_properties.get(), m_node, -m_kart_model->getLowestPoint()); } World::getWorld()->kartAdded(this, m_node); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index cb9af29f6..882ab7854 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -94,14 +94,12 @@ KartProperties::KartProperties(const std::string &filename) // The default constructor for stk_config uses filename="" if (filename != "") { - for(unsigned int i=0; im_ai_properties[i]; } @@ -337,7 +348,7 @@ void KartProperties::getAllData(const XMLNode * root) root->get("shadow-x-offset", &m_shadow_x_offset ); root->get("shadow-z-offset", &m_shadow_z_offset ); - root->get("type", &m_kart_type ); + root->get("type", &m_kart_type ); if(const XMLNode *dimensions_node = root->getNode("center")) dimensions_node->get("gravity-shift", &m_gravity_center_shift); diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index dbd54747d..604feb6a2 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -19,6 +19,7 @@ #ifndef HEADER_KART_PROPERTIES_HPP #define HEADER_KART_PROPERTIES_HPP +#include #include #include @@ -63,7 +64,7 @@ private: * reduce dependencies (and therefore compile time) when changing * any AI property. There is one separate object for each * difficulty. */ - AIProperties *m_ai_properties[RaceManager::DIFFICULTY_COUNT]; + std::shared_ptr m_ai_properties[RaceManager::DIFFICULTY_COUNT]; /** The absolute path of the icon texture to use. */ Material *m_icon_material; @@ -212,6 +213,7 @@ public: KartProperties (const std::string &filename=""); ~KartProperties (); + void copyForPlayer (const KartProperties *source); void copyFrom (const KartProperties *source); void getAllData (const XMLNode * root); void checkAllSet (const std::string &filename); @@ -373,7 +375,7 @@ public: /** Returns a pointer to the AI properties. */ const AIProperties *getAIPropertiesForDifficulty() const { - return m_ai_properties[race_manager->getDifficulty()]; + return m_ai_properties[race_manager->getDifficulty()].get(); } // getAIProperties // ------------------------------------------------------------------------ From 9fbe72b3c59c20bd107e193d7e6eba2632bcc3b5 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 29 Nov 2015 02:16:07 +0100 Subject: [PATCH 43/55] Move getter from characteristics to properties --- .gitignore | 1 + src/items/attachment.cpp | 18 +- src/items/plunger.cpp | 2 +- src/items/powerup.cpp | 16 +- src/items/rubber_band.cpp | 8 +- src/items/swatter.cpp | 8 +- src/karts/abstract_characteristic.cpp | 15 +- src/karts/abstract_characteristic.hpp | 5 +- src/karts/kart.cpp | 4 +- src/karts/kart_properties.cpp | 635 +++++++++++++++++++++++++- src/karts/kart_properties.hpp | 142 +++++- tools/create_kart_properties.py | 197 +++++--- tools/update_characteristics.py | 22 +- 13 files changed, 927 insertions(+), 146 deletions(-) diff --git a/.gitignore b/.gitignore index 1ba98ce23..b437bf1b2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ stk-editor/ .config/ supertuxkart-64 make*.bat +__pycache__ data/editor data/karts diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index a8a3045fe..a405a55c7 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -268,7 +268,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) // same banana again once the explosion animation is finished, giving // the kart the same penalty twice. float f = std::max(item->getDisableTime(), - m_kart->getCharacteristic()->getExplosionDuration() + 2.0f); + m_kart->getKartProperties()->getExplosionDuration() + 2.0f); item->setDisableTime(f); break; } @@ -296,7 +296,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) switch (new_attachment) { case 0: - set(ATTACH_PARACHUTE, m_kart->getCharacteristic()-> + set(ATTACH_PARACHUTE, m_kart->getKartProperties()-> getParachuteDuration() + leftover_time); m_initial_speed = m_kart->getSpeed(); @@ -311,13 +311,13 @@ void Attachment::hitBanana(Item *item, int new_attachment) // sound -> playSfx ( SOUND_SHOOMF ) ; break ; case 2: - set(ATTACH_ANVIL, m_kart->getCharacteristic()-> + set(ATTACH_ANVIL, m_kart->getKartProperties()-> getAnvilDuration() + leftover_time); // if ( m_kart == m_kart[0] ) // sound -> playSfx ( SOUND_SHOOMF ) ; // Reduce speed once (see description above), all other changes are // handled in Kart::updatePhysics - m_kart->adjustSpeed(m_kart->getCharacteristic()->getAnvilSpeedFactor()); + m_kart->adjustSpeed(m_kart->getKartProperties()->getAnvilSpeedFactor()); m_kart->updateWeight(); break ; } // switch @@ -422,12 +422,12 @@ void Attachment::update(float dt) // This percentage is based on the ratio of // initial_speed / initial_max_speed - float f = m_initial_speed / m_kart->getCharacteristic()->getParachuteMaxSpeed(); + float f = m_initial_speed / m_kart->getKartProperties()->getParachuteMaxSpeed(); if (f > 1.0f) f = 1.0f; // cap fraction if (m_kart->getSpeed() <= m_initial_speed * - (m_kart->getCharacteristic()->getParachuteLboundFraction() + - f * ( m_kart->getCharacteristic()->getParachuteUboundFraction() - - m_kart->getCharacteristic()->getParachuteLboundFraction()))) + (m_kart->getKartProperties()->getParachuteLboundFraction() + + f * ( m_kart->getKartProperties()->getParachuteUboundFraction() + - m_kart->getKartProperties()->getParachuteLboundFraction()))) { m_time_left = -1; } @@ -512,7 +512,7 @@ void Attachment::update(float dt) // ---------------------------------------------------------------------------- float Attachment::weightAdjust() const { - return m_type == ATTACH_ANVIL ? m_kart->getCharacteristic()->getAnvilWeight() : 0.0f; + return m_type == ATTACH_ANVIL ? m_kart->getKartProperties()->getAnvilWeight() : 0.0f; } // ---------------------------------------------------------------------------- diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 192ccc962..011a0a983 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -177,7 +177,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj) } else { - m_keep_alive = m_owner->getCharacteristic()->getPlungerBandDuration(); + m_keep_alive = m_owner->getKartProperties()->getPlungerBandDuration(); // Make this object invisible by placing it faaar down. Not that if this // objects is simply removed from the scene graph, it might be auto-deleted diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index fd3d754d7..3f89ebe59 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -223,7 +223,7 @@ void Powerup::use() case PowerupManager::POWERUP_SWATTER: m_owner->getAttachment() ->set(Attachment::ATTACH_SWATTER, - m_owner->getCharacteristic()->getSwatterDuration()); + m_owner->getKartProperties()->getSwatterDuration()); break; case PowerupManager::POWERUP_BUBBLEGUM: @@ -258,12 +258,12 @@ void Powerup::use() if (m_owner->getIdent() == "nolok") { m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD, - m_owner->getCharacteristic()->getBubblegumShieldDuration()); + m_owner->getKartProperties()->getBubblegumShieldDuration()); } else { m_owner->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD, - m_owner->getCharacteristic()->getBubblegumShieldDuration()); + m_owner->getKartProperties()->getBubblegumShieldDuration()); } } else // using a bubble gum while still having a shield @@ -271,12 +271,12 @@ void Powerup::use() if (m_owner->getIdent() == "nolok") { m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD, - m_owner->getCharacteristic()->getBubblegumShieldDuration() + m_owner->getShieldTime()); + m_owner->getKartProperties()->getBubblegumShieldDuration() + m_owner->getShieldTime()); } else { m_owner->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD, - m_owner->getCharacteristic()->getBubblegumShieldDuration() + m_owner->getShieldTime()); + m_owner->getKartProperties()->getBubblegumShieldDuration() + m_owner->getShieldTime()); } } @@ -300,9 +300,9 @@ void Powerup::use() if(kart->getPosition() == 1) { kart->getAttachment()->set(Attachment::ATTACH_ANVIL, - m_owner->getCharacteristic()->getAnvilDuration()); + m_owner->getKartProperties()->getAnvilDuration()); kart->updateWeight(); - kart->adjustSpeed(m_owner->getCharacteristic()->getAnvilSpeedFactor() * 0.5f); + kart->adjustSpeed(m_owner->getKartProperties()->getAnvilSpeedFactor() * 0.5f); // should we position the sound at the kart that is hit, // or the kart "throwing" the anvil? Ideally it should be both. @@ -339,7 +339,7 @@ void Powerup::use() { kart->getAttachment() ->set(Attachment::ATTACH_PARACHUTE, - m_owner->getCharacteristic()->getParachuteDurationOther()); + m_owner->getKartProperties()->getParachuteDurationOther()); if(kart->getController()->isPlayerController()) player_kart = kart; diff --git a/src/items/rubber_band.cpp b/src/items/rubber_band.cpp index bfa1303e8..805028b94 100644 --- a/src/items/rubber_band.cpp +++ b/src/items/rubber_band.cpp @@ -150,7 +150,7 @@ void RubberBand::update(float dt) // Check for rubber band snapping // ------------------------------ float l = (m_end_position-k).length2(); - float max_len = m_owner->getCharacteristic()->getPlungerBandMaxLength(); + float max_len = m_owner->getKartProperties()->getPlungerBandMaxLength(); if(l>max_len*max_len) { // Rubber band snaps @@ -163,7 +163,7 @@ void RubberBand::update(float dt) // ---------------------------- if(m_attached_state!=RB_TO_PLUNGER) { - float force = m_owner->getCharacteristic()->getPlungerBandForce(); + float force = m_owner->getKartProperties()->getPlungerBandForce(); Vec3 diff = m_end_position-k; // detach rubber band if kart gets very close to hit point @@ -179,10 +179,10 @@ void RubberBand::update(float dt) diff.normalize(); // diff can't be zero here m_owner->getBody()->applyCentralForce(diff*force); m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER, - m_owner->getCharacteristic()->getPlungerBandSpeedIncrease(), + m_owner->getKartProperties()->getPlungerBandSpeedIncrease(), /*engine_force*/ 0.0f, /*duration*/0.1f, - m_owner->getCharacteristic()->getPlungerBandFadeOutTime()); + m_owner->getKartProperties()->getPlungerBandFadeOutTime()); if(m_attached_state==RB_TO_KART) m_hit_kart->getBody()->applyCentralForce(diff*(-force)); } diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index 4b96e37c8..13140595b 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -157,7 +157,7 @@ bool Swatter::updateAndTestFinished(float dt) (m_target->getXYZ()- Vec3(m_scene_node->getAbsolutePosition())) .length2(); float min_dist2 - = m_kart->getCharacteristic()->getSwatterDistance(); + = m_kart->getKartProperties()->getSwatterDistance(); if(dist_to_target2 < min_dist2) { // Start squashing @@ -265,9 +265,9 @@ void Swatter::pointToTarget() */ void Swatter::squashThingsAround() { - const AbstractCharacteristic *ch = m_kart->getCharacteristic(); + const KartProperties *kp = m_kart->getKartProperties(); // Square of the minimum distance - float min_dist2 = ch->getSwatterDistance(); + float min_dist2 = kp->getSwatterDistance(); const World* world = World::getWorld(); // Get the node corresponding to the joint at the center of the swatter @@ -294,7 +294,7 @@ void Swatter::squashThingsAround() if(dist2 >= min_dist2) continue; // too far away, ignore this kart - kart->setSquash(ch->getSwatterSquashDuration(), ch->getSwatterSquashSlowdown()); + kart->setSquash(kp->getSwatterSquashDuration(), kp->getSwatterSquashSlowdown()); //Handle achievement if the swatter is used by the current player const StateManager::ActivePlayer *const ap = m_kart->getController() diff --git a/src/karts/abstract_characteristic.cpp b/src/karts/abstract_characteristic.cpp index b39d0eb9b..f25c41150 100755 --- a/src/karts/abstract_characteristic.cpp +++ b/src/karts/abstract_characteristic.cpp @@ -53,7 +53,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType( // Please don't change the following tag. It will be automatically detected // by the script and replace the contained content. // To update the code, use tools/update_characteristics.py - /* */ + /* */ case SUSPENSION_STIFFNESS: return TYPE_FLOAT; case SUSPENSION_REST: @@ -259,7 +259,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType( case SKID_ENABLED: return TYPE_BOOL; - /* */ + /* */ } // switch (type) Log::fatal("AbstractCharacteristic::getType", "Unknown type"); return TYPE_FLOAT; @@ -277,7 +277,7 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) // Please don't change the following tag. It will be automatically detected // by the script and replace the contained content. // To update the code, use tools/update_characteristics.py - /* */ + /* */ case SUSPENSION_STIFFNESS: return "SUSPENSION_STIFFNESS"; case SUSPENSION_REST: @@ -483,18 +483,17 @@ std::string AbstractCharacteristic::getName(CharacteristicType type) case SKID_ENABLED: return "SKID_ENABLED"; - /* */ + /* */ } // switch (type) Log::error("AbstractCharacteristic::getName", "Unknown type"); return "Unknown type"; } // getName -// ---------------------------------------------------------------------------- -// Script-generated content generated by tools/create_kart_properties.py getter +// Script-generated content generated by tools/create_kart_properties.py defs // Please don't change the following tag. It will be automatically detected // by the script and replace the contained content. // To update the code, use tools/update_characteristics.py -/* */ +/* */ // ---------------------------------------------------------------------------- float AbstractCharacteristic::getSuspensionStiffness() const { @@ -1720,5 +1719,5 @@ bool AbstractCharacteristic::getSkidEnabled() const } // getSkidEnabled -/* */ +/* */ diff --git a/src/karts/abstract_characteristic.hpp b/src/karts/abstract_characteristic.hpp index 9c5badc90..0f1ac3d2c 100755 --- a/src/karts/abstract_characteristic.hpp +++ b/src/karts/abstract_characteristic.hpp @@ -245,11 +245,12 @@ public: static ValueType getType(CharacteristicType type); static std::string getName(CharacteristicType type); + // Script-generated content generated by tools/create_kart_properties.py defs // Please don't change the following tag. It will be automatically detected // by the script and replace the contained content. // To update the code, use tools/update_characteristics.py - /* */ + /* */ float getSuspensionStiffness() const; float getSuspensionRest() const; @@ -375,7 +376,7 @@ public: float getSkidReduceTurnMax() const; bool getSkidEnabled() const; - /* */ + /* */ }; #endif diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 9ab4f1888..d6ee8c5a0 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2651,14 +2651,14 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, const float steer_frac = m_skidding->getSteeringFraction(); - const float roll_speed = m_kart_properties->getLeanSpeed(); + const float roll_speed = m_kart_properties->getLeanSpeed() * DEGREE_TO_RAD; if(speed_frac > 0.8f && fabsf(steer_frac)>0.5f) { // Use steering ^ 7, which means less effect at lower // steering const float f = m_skidding->getSteeringFraction(); const float f2 = f*f; - const float max_lean = -m_kart_properties->getMaxLean() + const float max_lean = -m_kart_properties->getLeanMax() * DEGREE_TO_RAD * f2*f2*f2*f * speed_frac; if(max_lean>0) diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 882ab7854..09fc83c81 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -321,6 +321,7 @@ void KartProperties::combineCharacteristics() m_combined_characteristic->addCharacteristic(characteristic); m_combined_characteristic->addCharacteristic(m_characteristic.get()); + m_cached_characteristic.reset(new CachedCharacteristic(m_combined_characteristic.get())); } // combineCharacteristics //----------------------------------------------------------------------------- @@ -448,15 +449,6 @@ void KartProperties::getAllData(const XMLNode * root) #endif } // if sounds-node exist - - if(const XMLNode *lean_node= root->getNode("lean")) - { - lean_node->get("max", &m_max_lean ); - lean_node->get("speed", &m_lean_speed); - m_max_lean *= DEGREE_TO_RAD; - m_lean_speed *= DEGREE_TO_RAD; - } - if(m_kart_model) m_kart_model->loadInfo(*root); } // getAllData @@ -482,9 +474,6 @@ void KartProperties::checkAllSet(const std::string &filename) CHECK_NEG(m_restitution, "collision restitution" ); CHECK_NEG(m_physical_wheel_position, "collision physical-wheel-position"); - CHECK_NEG(m_max_lean, "lean max" ); - CHECK_NEG(m_lean_speed, "lean speed" ); - m_speed_weighted_object_properties.checkAllSet(); for(unsigned int i=0; i */ +// ---------------------------------------------------------------------------- +float KartProperties::getSuspensionStiffness() const +{ + return m_cached_characteristic->getSuspensionStiffness(); +} // getSuspensionStiffness + +// ---------------------------------------------------------------------------- +float KartProperties::getSuspensionRest() const +{ + return m_cached_characteristic->getSuspensionRest(); +} // getSuspensionRest + +// ---------------------------------------------------------------------------- +float KartProperties::getSuspensionTravel() const +{ + return m_cached_characteristic->getSuspensionTravel(); +} // getSuspensionTravel + +// ---------------------------------------------------------------------------- +bool KartProperties::getSuspensionExpSpringResponse() const +{ + return m_cached_characteristic->getSuspensionExpSpringResponse(); +} // getSuspensionExpSpringResponse + +// ---------------------------------------------------------------------------- +float KartProperties::getSuspensionMaxForce() const +{ + return m_cached_characteristic->getSuspensionMaxForce(); +} // getSuspensionMaxForce + +// ---------------------------------------------------------------------------- +float KartProperties::getStabilityRollInfluence() const +{ + return m_cached_characteristic->getStabilityRollInfluence(); +} // getStabilityRollInfluence + +// ---------------------------------------------------------------------------- +float KartProperties::getStabilityChassisLinearDamping() const +{ + return m_cached_characteristic->getStabilityChassisLinearDamping(); +} // getStabilityChassisLinearDamping + +// ---------------------------------------------------------------------------- +float KartProperties::getStabilityChassisAngularDamping() const +{ + return m_cached_characteristic->getStabilityChassisAngularDamping(); +} // getStabilityChassisAngularDamping + +// ---------------------------------------------------------------------------- +float KartProperties::getStabilityDownwardImpulseFactor() const +{ + return m_cached_characteristic->getStabilityDownwardImpulseFactor(); +} // getStabilityDownwardImpulseFactor + +// ---------------------------------------------------------------------------- +float KartProperties::getStabilityTrackConnectionAccel() const +{ + return m_cached_characteristic->getStabilityTrackConnectionAccel(); +} // getStabilityTrackConnectionAccel + +// ---------------------------------------------------------------------------- +float KartProperties::getStabilitySmoothFlyingImpulse() const +{ + return m_cached_characteristic->getStabilitySmoothFlyingImpulse(); +} // getStabilitySmoothFlyingImpulse + +// ---------------------------------------------------------------------------- +InterpolationArray KartProperties::getTurnRadius() const +{ + return m_cached_characteristic->getTurnRadius(); +} // getTurnRadius + +// ---------------------------------------------------------------------------- +float KartProperties::getTurnTimeResetSteer() const +{ + return m_cached_characteristic->getTurnTimeResetSteer(); +} // getTurnTimeResetSteer + +// ---------------------------------------------------------------------------- +InterpolationArray KartProperties::getTurnTimeFullSteer() const +{ + return m_cached_characteristic->getTurnTimeFullSteer(); +} // getTurnTimeFullSteer + +// ---------------------------------------------------------------------------- +float KartProperties::getEnginePower() const +{ + return m_cached_characteristic->getEnginePower(); +} // getEnginePower + +// ---------------------------------------------------------------------------- +float KartProperties::getEngineMaxSpeed() const +{ + return m_cached_characteristic->getEngineMaxSpeed(); +} // getEngineMaxSpeed + +// ---------------------------------------------------------------------------- +float KartProperties::getEngineBrakeFactor() const +{ + return m_cached_characteristic->getEngineBrakeFactor(); +} // getEngineBrakeFactor + +// ---------------------------------------------------------------------------- +float KartProperties::getEngineBrakeTimeIncrease() const +{ + return m_cached_characteristic->getEngineBrakeTimeIncrease(); +} // getEngineBrakeTimeIncrease + +// ---------------------------------------------------------------------------- +float KartProperties::getEngineMaxSpeedReverseRatio() const +{ + return m_cached_characteristic->getEngineMaxSpeedReverseRatio(); +} // getEngineMaxSpeedReverseRatio + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getGearSwitchRatio() const +{ + return m_cached_characteristic->getGearSwitchRatio(); +} // getGearSwitchRatio + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getGearPowerIncrease() const +{ + return m_cached_characteristic->getGearPowerIncrease(); +} // getGearPowerIncrease + +// ---------------------------------------------------------------------------- +float KartProperties::getMass() const +{ + return m_cached_characteristic->getMass(); +} // getMass + +// ---------------------------------------------------------------------------- +float KartProperties::getWheelsDampingRelaxation() const +{ + return m_cached_characteristic->getWheelsDampingRelaxation(); +} // getWheelsDampingRelaxation + +// ---------------------------------------------------------------------------- +float KartProperties::getWheelsDampingCompression() const +{ + return m_cached_characteristic->getWheelsDampingCompression(); +} // getWheelsDampingCompression + +// ---------------------------------------------------------------------------- +float KartProperties::getCameraDistance() const +{ + return m_cached_characteristic->getCameraDistance(); +} // getCameraDistance + +// ---------------------------------------------------------------------------- +float KartProperties::getCameraForwardUpAngle() const +{ + return m_cached_characteristic->getCameraForwardUpAngle(); +} // getCameraForwardUpAngle + +// ---------------------------------------------------------------------------- +float KartProperties::getCameraBackwardUpAngle() const +{ + return m_cached_characteristic->getCameraBackwardUpAngle(); +} // getCameraBackwardUpAngle + +// ---------------------------------------------------------------------------- +float KartProperties::getJumpAnimationTime() const +{ + return m_cached_characteristic->getJumpAnimationTime(); +} // getJumpAnimationTime + +// ---------------------------------------------------------------------------- +float KartProperties::getLeanMax() const +{ + return m_cached_characteristic->getLeanMax(); +} // getLeanMax + +// ---------------------------------------------------------------------------- +float KartProperties::getLeanSpeed() const +{ + return m_cached_characteristic->getLeanSpeed(); +} // getLeanSpeed + +// ---------------------------------------------------------------------------- +float KartProperties::getAnvilDuration() const +{ + return m_cached_characteristic->getAnvilDuration(); +} // getAnvilDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getAnvilWeight() const +{ + return m_cached_characteristic->getAnvilWeight(); +} // getAnvilWeight + +// ---------------------------------------------------------------------------- +float KartProperties::getAnvilSpeedFactor() const +{ + return m_cached_characteristic->getAnvilSpeedFactor(); +} // getAnvilSpeedFactor + +// ---------------------------------------------------------------------------- +float KartProperties::getParachuteFriction() const +{ + return m_cached_characteristic->getParachuteFriction(); +} // getParachuteFriction + +// ---------------------------------------------------------------------------- +float KartProperties::getParachuteDuration() const +{ + return m_cached_characteristic->getParachuteDuration(); +} // getParachuteDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getParachuteDurationOther() const +{ + return m_cached_characteristic->getParachuteDurationOther(); +} // getParachuteDurationOther + +// ---------------------------------------------------------------------------- +float KartProperties::getParachuteLboundFraction() const +{ + return m_cached_characteristic->getParachuteLboundFraction(); +} // getParachuteLboundFraction + +// ---------------------------------------------------------------------------- +float KartProperties::getParachuteUboundFraction() const +{ + return m_cached_characteristic->getParachuteUboundFraction(); +} // getParachuteUboundFraction + +// ---------------------------------------------------------------------------- +float KartProperties::getParachuteMaxSpeed() const +{ + return m_cached_characteristic->getParachuteMaxSpeed(); +} // getParachuteMaxSpeed + +// ---------------------------------------------------------------------------- +float KartProperties::getBubblegumDuration() const +{ + return m_cached_characteristic->getBubblegumDuration(); +} // getBubblegumDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getBubblegumSpeedFraction() const +{ + return m_cached_characteristic->getBubblegumSpeedFraction(); +} // getBubblegumSpeedFraction + +// ---------------------------------------------------------------------------- +float KartProperties::getBubblegumTorque() const +{ + return m_cached_characteristic->getBubblegumTorque(); +} // getBubblegumTorque + +// ---------------------------------------------------------------------------- +float KartProperties::getBubblegumFadeInTime() const +{ + return m_cached_characteristic->getBubblegumFadeInTime(); +} // getBubblegumFadeInTime + +// ---------------------------------------------------------------------------- +float KartProperties::getBubblegumShieldDuration() const +{ + return m_cached_characteristic->getBubblegumShieldDuration(); +} // getBubblegumShieldDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getZipperDuration() const +{ + return m_cached_characteristic->getZipperDuration(); +} // getZipperDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getZipperForce() const +{ + return m_cached_characteristic->getZipperForce(); +} // getZipperForce + +// ---------------------------------------------------------------------------- +float KartProperties::getZipperSpeedGain() const +{ + return m_cached_characteristic->getZipperSpeedGain(); +} // getZipperSpeedGain + +// ---------------------------------------------------------------------------- +float KartProperties::getZipperMaxSpeedIncrease() const +{ + return m_cached_characteristic->getZipperMaxSpeedIncrease(); +} // getZipperMaxSpeedIncrease + +// ---------------------------------------------------------------------------- +float KartProperties::getZipperFadeOutTime() const +{ + return m_cached_characteristic->getZipperFadeOutTime(); +} // getZipperFadeOutTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSwatterDuration() const +{ + return m_cached_characteristic->getSwatterDuration(); +} // getSwatterDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getSwatterDistance() const +{ + return m_cached_characteristic->getSwatterDistance(); +} // getSwatterDistance + +// ---------------------------------------------------------------------------- +float KartProperties::getSwatterSquashDuration() const +{ + return m_cached_characteristic->getSwatterSquashDuration(); +} // getSwatterSquashDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getSwatterSquashSlowdown() const +{ + return m_cached_characteristic->getSwatterSquashSlowdown(); +} // getSwatterSquashSlowdown + +// ---------------------------------------------------------------------------- +float KartProperties::getPlungerBandMaxLength() const +{ + return m_cached_characteristic->getPlungerBandMaxLength(); +} // getPlungerBandMaxLength + +// ---------------------------------------------------------------------------- +float KartProperties::getPlungerBandForce() const +{ + return m_cached_characteristic->getPlungerBandForce(); +} // getPlungerBandForce + +// ---------------------------------------------------------------------------- +float KartProperties::getPlungerBandDuration() const +{ + return m_cached_characteristic->getPlungerBandDuration(); +} // getPlungerBandDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getPlungerBandSpeedIncrease() const +{ + return m_cached_characteristic->getPlungerBandSpeedIncrease(); +} // getPlungerBandSpeedIncrease + +// ---------------------------------------------------------------------------- +float KartProperties::getPlungerBandFadeOutTime() const +{ + return m_cached_characteristic->getPlungerBandFadeOutTime(); +} // getPlungerBandFadeOutTime + +// ---------------------------------------------------------------------------- +float KartProperties::getPlungerInFaceTime() const +{ + return m_cached_characteristic->getPlungerInFaceTime(); +} // getPlungerInFaceTime + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getStartupTime() const +{ + return m_cached_characteristic->getStartupTime(); +} // getStartupTime + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getStartupBoost() const +{ + return m_cached_characteristic->getStartupBoost(); +} // getStartupBoost + +// ---------------------------------------------------------------------------- +float KartProperties::getRescueDuration() const +{ + return m_cached_characteristic->getRescueDuration(); +} // getRescueDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getRescueVertOffset() const +{ + return m_cached_characteristic->getRescueVertOffset(); +} // getRescueVertOffset + +// ---------------------------------------------------------------------------- +float KartProperties::getRescueHeight() const +{ + return m_cached_characteristic->getRescueHeight(); +} // getRescueHeight + +// ---------------------------------------------------------------------------- +float KartProperties::getExplosionDuration() const +{ + return m_cached_characteristic->getExplosionDuration(); +} // getExplosionDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getExplosionRadius() const +{ + return m_cached_characteristic->getExplosionRadius(); +} // getExplosionRadius + +// ---------------------------------------------------------------------------- +float KartProperties::getExplosionInvulnerabilityTime() const +{ + return m_cached_characteristic->getExplosionInvulnerabilityTime(); +} // getExplosionInvulnerabilityTime + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroDuration() const +{ + return m_cached_characteristic->getNitroDuration(); +} // getNitroDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroEngineForce() const +{ + return m_cached_characteristic->getNitroEngineForce(); +} // getNitroEngineForce + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroConsumption() const +{ + return m_cached_characteristic->getNitroConsumption(); +} // getNitroConsumption + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroSmallContainer() const +{ + return m_cached_characteristic->getNitroSmallContainer(); +} // getNitroSmallContainer + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroBigContainer() const +{ + return m_cached_characteristic->getNitroBigContainer(); +} // getNitroBigContainer + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroMaxSpeedIncrease() const +{ + return m_cached_characteristic->getNitroMaxSpeedIncrease(); +} // getNitroMaxSpeedIncrease + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroFadeOutTime() const +{ + return m_cached_characteristic->getNitroFadeOutTime(); +} // getNitroFadeOutTime + +// ---------------------------------------------------------------------------- +float KartProperties::getNitroMax() const +{ + return m_cached_characteristic->getNitroMax(); +} // getNitroMax + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamDuration() const +{ + return m_cached_characteristic->getSlipstreamDuration(); +} // getSlipstreamDuration + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamLength() const +{ + return m_cached_characteristic->getSlipstreamLength(); +} // getSlipstreamLength + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamWidth() const +{ + return m_cached_characteristic->getSlipstreamWidth(); +} // getSlipstreamWidth + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamCollectTime() const +{ + return m_cached_characteristic->getSlipstreamCollectTime(); +} // getSlipstreamCollectTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamUseTime() const +{ + return m_cached_characteristic->getSlipstreamUseTime(); +} // getSlipstreamUseTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamAddPower() const +{ + return m_cached_characteristic->getSlipstreamAddPower(); +} // getSlipstreamAddPower + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamMinSpeed() const +{ + return m_cached_characteristic->getSlipstreamMinSpeed(); +} // getSlipstreamMinSpeed + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamMaxSpeedIncrease() const +{ + return m_cached_characteristic->getSlipstreamMaxSpeedIncrease(); +} // getSlipstreamMaxSpeedIncrease + +// ---------------------------------------------------------------------------- +float KartProperties::getSlipstreamFadeOutTime() const +{ + return m_cached_characteristic->getSlipstreamFadeOutTime(); +} // getSlipstreamFadeOutTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidIncrease() const +{ + return m_cached_characteristic->getSkidIncrease(); +} // getSkidIncrease + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidDecrease() const +{ + return m_cached_characteristic->getSkidDecrease(); +} // getSkidDecrease + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidMax() const +{ + return m_cached_characteristic->getSkidMax(); +} // getSkidMax + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidTimeTillMax() const +{ + return m_cached_characteristic->getSkidTimeTillMax(); +} // getSkidTimeTillMax + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidVisual() const +{ + return m_cached_characteristic->getSkidVisual(); +} // getSkidVisual + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidVisualTime() const +{ + return m_cached_characteristic->getSkidVisualTime(); +} // getSkidVisualTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidRevertVisualTime() const +{ + return m_cached_characteristic->getSkidRevertVisualTime(); +} // getSkidRevertVisualTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidMinSpeed() const +{ + return m_cached_characteristic->getSkidMinSpeed(); +} // getSkidMinSpeed + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getSkidTimeTillBonus() const +{ + return m_cached_characteristic->getSkidTimeTillBonus(); +} // getSkidTimeTillBonus + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getSkidBonusSpeed() const +{ + return m_cached_characteristic->getSkidBonusSpeed(); +} // getSkidBonusSpeed + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getSkidBonusTime() const +{ + return m_cached_characteristic->getSkidBonusTime(); +} // getSkidBonusTime + +// ---------------------------------------------------------------------------- +std::vector KartProperties::getSkidBonusForce() const +{ + return m_cached_characteristic->getSkidBonusForce(); +} // getSkidBonusForce + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidPhysicalJumpTime() const +{ + return m_cached_characteristic->getSkidPhysicalJumpTime(); +} // getSkidPhysicalJumpTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidGraphicalJumpTime() const +{ + return m_cached_characteristic->getSkidGraphicalJumpTime(); +} // getSkidGraphicalJumpTime + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidPostSkidRotateFactor() const +{ + return m_cached_characteristic->getSkidPostSkidRotateFactor(); +} // getSkidPostSkidRotateFactor + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidReduceTurnMin() const +{ + return m_cached_characteristic->getSkidReduceTurnMin(); +} // getSkidReduceTurnMin + +// ---------------------------------------------------------------------------- +float KartProperties::getSkidReduceTurnMax() const +{ + return m_cached_characteristic->getSkidReduceTurnMax(); +} // getSkidReduceTurnMax + +// ---------------------------------------------------------------------------- +bool KartProperties::getSkidEnabled() const +{ + return m_cached_characteristic->getSkidEnabled(); +} // getSkidEnabled + + +/* */ + diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index 604feb6a2..c9ff4fc68 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -123,6 +123,8 @@ private: std::shared_ptr m_characteristic; /** The base characteristics combined with the characteristics of this kart. */ std::shared_ptr m_combined_characteristic; + /** The cached combined characteristics. */ + std::unique_ptr m_cached_characteristic; // Physic properties // ----------------- @@ -382,13 +384,6 @@ public: /** Returns the full path where the files for this kart are stored. */ const std::string& getKartDir () const {return m_root; } - // ------------------------------------------------------------------------ - /** The maximum leaning a kart should show (In radians). */ - float getMaxLean() const { return m_max_lean; } - - // ------------------------------------------------------------------------ - /** The speed with which a kart should lean (in radians/s). */ - float getLeanSpeed() const { return m_lean_speed; } // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ /** Returns minimum time during which nitro is consumed when pressing nitro @@ -411,6 +406,139 @@ public: // ------------------------------------------------------------------------ float getAvgPower() const; + + + // Script-generated content generated by tools/create_kart_properties.py defs + // Please don't change the following tag. It will be automatically detected + // by the script and replace the contained content. + // To update the code, use tools/update_characteristics.py + /* */ + + float getSuspensionStiffness() const; + float getSuspensionRest() const; + float getSuspensionTravel() const; + bool getSuspensionExpSpringResponse() const; + float getSuspensionMaxForce() const; + + float getStabilityRollInfluence() const; + float getStabilityChassisLinearDamping() const; + float getStabilityChassisAngularDamping() const; + float getStabilityDownwardImpulseFactor() const; + float getStabilityTrackConnectionAccel() const; + float getStabilitySmoothFlyingImpulse() const; + + InterpolationArray getTurnRadius() const; + float getTurnTimeResetSteer() const; + InterpolationArray getTurnTimeFullSteer() const; + + float getEnginePower() const; + float getEngineMaxSpeed() const; + float getEngineBrakeFactor() const; + float getEngineBrakeTimeIncrease() const; + float getEngineMaxSpeedReverseRatio() const; + + std::vector getGearSwitchRatio() const; + std::vector getGearPowerIncrease() const; + + float getMass() const; + + float getWheelsDampingRelaxation() const; + float getWheelsDampingCompression() const; + + float getCameraDistance() const; + float getCameraForwardUpAngle() const; + float getCameraBackwardUpAngle() const; + + float getJumpAnimationTime() const; + + float getLeanMax() const; + float getLeanSpeed() const; + + float getAnvilDuration() const; + float getAnvilWeight() const; + float getAnvilSpeedFactor() const; + + float getParachuteFriction() const; + float getParachuteDuration() const; + float getParachuteDurationOther() const; + float getParachuteLboundFraction() const; + float getParachuteUboundFraction() const; + float getParachuteMaxSpeed() const; + + float getBubblegumDuration() const; + float getBubblegumSpeedFraction() const; + float getBubblegumTorque() const; + float getBubblegumFadeInTime() const; + float getBubblegumShieldDuration() const; + + float getZipperDuration() const; + float getZipperForce() const; + float getZipperSpeedGain() const; + float getZipperMaxSpeedIncrease() const; + float getZipperFadeOutTime() const; + + float getSwatterDuration() const; + float getSwatterDistance() const; + float getSwatterSquashDuration() const; + float getSwatterSquashSlowdown() const; + + float getPlungerBandMaxLength() const; + float getPlungerBandForce() const; + float getPlungerBandDuration() const; + float getPlungerBandSpeedIncrease() const; + float getPlungerBandFadeOutTime() const; + float getPlungerInFaceTime() const; + + std::vector getStartupTime() const; + std::vector getStartupBoost() const; + + float getRescueDuration() const; + float getRescueVertOffset() const; + float getRescueHeight() const; + + float getExplosionDuration() const; + float getExplosionRadius() const; + float getExplosionInvulnerabilityTime() const; + + float getNitroDuration() const; + float getNitroEngineForce() const; + float getNitroConsumption() const; + float getNitroSmallContainer() const; + float getNitroBigContainer() const; + float getNitroMaxSpeedIncrease() const; + float getNitroFadeOutTime() const; + float getNitroMax() const; + + float getSlipstreamDuration() const; + float getSlipstreamLength() const; + float getSlipstreamWidth() const; + float getSlipstreamCollectTime() const; + float getSlipstreamUseTime() const; + float getSlipstreamAddPower() const; + float getSlipstreamMinSpeed() const; + float getSlipstreamMaxSpeedIncrease() const; + float getSlipstreamFadeOutTime() const; + + float getSkidIncrease() const; + float getSkidDecrease() const; + float getSkidMax() const; + float getSkidTimeTillMax() const; + float getSkidVisual() const; + float getSkidVisualTime() const; + float getSkidRevertVisualTime() const; + float getSkidMinSpeed() const; + std::vector getSkidTimeTillBonus() const; + std::vector getSkidBonusSpeed() const; + std::vector getSkidBonusTime() const; + std::vector getSkidBonusForce() const; + float getSkidPhysicalJumpTime() const; + float getSkidGraphicalJumpTime() const; + float getSkidPostSkidRotateFactor() const; + float getSkidReduceTurnMin() const; + float getSkidReduceTurnMax() const; + bool getSkidEnabled() const; + + /* */ }; // KartProperties #endif diff --git a/tools/create_kart_properties.py b/tools/create_kart_properties.py index 5d6a1c6db..4b00ba3b1 100755 --- a/tools/create_kart_properties.py +++ b/tools/create_kart_properties.py @@ -140,60 +140,35 @@ def joinSubName(group, member, titleCase): else: return "_".join(words) -def main(): - # Find out what to do - if len(sys.argv) == 1: - print("""Usage: ./create_kart_properties.py -Operations: - enum List the enum values for all characteristics in abstract_characteristic.hpp - defs Create the headers in abstract_characteristic.hpp - getter The getter implementations in abstract_characteristic.cpp - getProp1 Creates the getType function in abstract_characteristic.cpp - getProp2 Creates the getName funciton in abstract_characteristic.cpp - getXml Used to load the characteristics from an xml file in xml_characteristic.cpp""") - return - task = sys.argv[1] +# Functions to generate code - groups = [Group.parse(line) for line in characteristics.split("\n")] +def createEnum(groups): + for g in groups: + print() + print(" // {0}".format(g.getBaseName().title())) + for m in g.members: + print(" {0},".format(joinSubName(g, m, False).upper())) - # Find longest name to align the function bodies - nameLengthTitle = 0 - nameLengthUnderscore = 0 +def createAcDefs(groups): + for g in groups: + print() + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False) + typeC = m.typeC + + print(" {0} get{1}() const;". + format(typeC, nameTitle, nameUnderscore)) + +def createAcGetter(groups): for g in groups: for m in g.members: - l = len(joinSubName(g, m, True)) - if l > nameLengthTitle: - nameLengthTitle = l - l = len(joinSubName(g, m, False)) - if l > nameLengthUnderscore: - nameLengthUnderscore = l + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False) + typeC = m.typeC + result = "result" - # Print the results - if task == "enum": - for g in groups: - print() - print(" // {0}".format(g.getBaseName().title())) - for m in g.members: - print(" {0},".format(joinSubName(g, m, False).upper())) - elif task == "defs": - for g in groups: - print() - for m in g.members: - nameTitle = joinSubName(g, m, True) - nameUnderscore = joinSubName(g, m, False) - typeC = m.typeC - - print(" {0} get{1}() const;". - format(typeC, nameTitle, nameUnderscore)) - elif task == "getter": - for g in groups: - for m in g.members: - nameTitle = joinSubName(g, m, True) - nameUnderscore = joinSubName(g, m, False) - typeC = m.typeC - result = "result" - - print("""// ---------------------------------------------------------------------------- + print("""// ---------------------------------------------------------------------------- {3} AbstractCharacteristic::get{1}() const {{ {0} result; @@ -205,33 +180,105 @@ Operations: return {4}; }} // get{1} """.format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result)) - elif task == "getProp1": - for g in groups: - for m in g.members: - nameTitle = joinSubName(g, m, True) - nameUnderscore = joinSubName(g, m, False) - print(" case {0}:\n return TYPE_{1};". - format(nameUnderscore.upper(), "_".join(toList(m.typeStr)).upper())) - elif task == "getProp2": - for g in groups: - for m in g.members: - nameTitle = joinSubName(g, m, True) - nameUnderscore = joinSubName(g, m, False).upper() - print(" case {0}:\n return \"{0}\";". - format(nameUnderscore)) - elif task == "getXml": - for g in groups: - print(" if (const XMLNode *sub_node = node->getNode(\"{0}\"))\n {{". - format(g.baseName.lower())) - for m in g.members: - nameUnderscore = joinSubName(g, m, False) - nameMinus = "-".join(toList(m.name)) - print(""" sub_node->get(\"{0}\", + +def createKpDefs(groups): + for g in groups: + print() + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False) + typeC = m.typeC + + print(" {0} get{1}() const;". + format(typeC, nameTitle, nameUnderscore)) + +def createKpGetter(groups): + for g in groups: + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False) + typeC = m.typeC + result = "result" + + print("""// ---------------------------------------------------------------------------- +{1} KartProperties::get{0}() const +{{ + return m_cached_characteristic->get{0}(); +}} // get{0} +""".format(nameTitle, typeC)) + +def createGetType(groups): + for g in groups: + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False) + print(" case {0}:\n return TYPE_{1};". + format(nameUnderscore.upper(), "_".join(toList(m.typeStr)).upper())) + +def createGetName(groups): + for g in groups: + for m in g.members: + nameTitle = joinSubName(g, m, True) + nameUnderscore = joinSubName(g, m, False).upper() + print(" case {0}:\n return \"{0}\";". + format(nameUnderscore)) + +def createLoadXml(groups): + for g in groups: + print(" if (const XMLNode *sub_node = node->getNode(\"{0}\"))\n {{". + format(g.baseName.lower())) + for m in g.members: + nameUnderscore = joinSubName(g, m, False) + nameMinus = "-".join(toList(m.name)) + print(""" sub_node->get(\"{0}\", &m_values[{1}]);""". - format(nameMinus, nameUnderscore.upper())) - print(" }\n") - else: - print("Unknown task") + format(nameMinus, nameUnderscore.upper())) + print(" }\n") + +# Dicionary that maps an argument string to a tupel of +# a generator function, a help string and a filename +functions = { + "enum": (createEnum, "List the enum values for all characteristics", "karts/abstract_characteristic.hpp"), + "acdefs": (createAcDefs, "Create the header function definitions", "karts/abstract_characteristic.hpp"), + "acgetter": (createAcGetter, "Implement the getters", "karts/abstract_characteristic.cpp"), + "getType": (createGetType, "Implement the getType function", "karts/abstract_characteristic.cpp"), + "getName": (createGetName, "Implement the getName function", "karts/abstract_characteristic.cpp"), + "kpdefs": (createKpDefs, "Create the header function definitions for the getters", "karts/kart_properties.hpp"), + "kpgetter": (createKpGetter, "Implement the getters", "karts/kart_properties.cpp"), + "loadXml": (createLoadXml, "Code to load the characteristics from an xml file", "karts/xml_characteristic.hpp"), +} + +def main(): + # Find out what to do + if len(sys.argv) != 2: + print("""Usage: ./create_kart_properties.py +Operations:""") + maxOperationLength = 0 + maxDescriptionLength = 0 + for o, f in functions.items(): + l = len(o) + if l > maxOperationLength: + maxOperationLength = l + l = len(f[1]) + if l > maxDescriptionLength: + maxDescriptionLength = l + + formatString = " {{0:{0}}} {{1:{1}}} in {{2}}".format(maxOperationLength, maxDescriptionLength) + for o, f in functions.items(): + print(formatString.format(o, f[1], f[2])) + return + + task = sys.argv[1] + + if task not in functions: + print("The wanted operation was not found. Please call this script without arguments to list available arguments.") + return + + # Parse properties + groups = [Group.parse(line) for line in characteristics.split("\n")] + + # Create the wanted code + functions[task][0](groups) if __name__ == '__main__': main() diff --git a/tools/update_characteristics.py b/tools/update_characteristics.py index 0c8ee9c78..6815623e5 100755 --- a/tools/update_characteristics.py +++ b/tools/update_characteristics.py @@ -26,30 +26,24 @@ import os import re import subprocess -# Where and what should be replaced -replacements = [ - ["enum", "karts/abstract_characteristic.hpp"], - ["defs", "karts/abstract_characteristic.hpp"], - ["getter", "karts/abstract_characteristic.cpp"], - ["getProp1", "karts/abstract_characteristic.cpp"], - ["getProp2", "karts/abstract_characteristic.cpp"], - ["getXml", "karts/xml_characteristic.cpp"]] +from create_kart_properties import functions def main(): # Check, if it runs in the root directory if not os.path.isfile("tools/update_characteristics.py"): print("Please run this script in the root directory of the project.") exit(1) - for replacement in replacements: + for operation, function in functions.items(): + # + " 2> /dev/null" result = subprocess.Popen("tools/create_kart_properties.py " + - replacement[0] + " 2> /dev/null", shell = True, + operation, shell = True, stdout = subprocess.PIPE).stdout.read().decode('UTF-8') - with open("src/" + replacement[1], "r") as f: + with open("src/" + function[2], "r") as f: text = f.read() # Replace the text by using look behinds and look forwards - text = re.sub("(?<=/\* \ \*/\\n)(.|\n)*(?=\\n\s*/\* \*/)", result, text) - with open("src/" + replacement[1], "w") as f: + text = re.sub("(?<=/\* \ \*/\\n)(.|\n)*(?=\\n\s*/\* \*/)", result, text) + with open("src/" + function[2], "w") as f: f.write(text) if __name__ == '__main__': From aea68a2c142ffe052e8abd973d3bccf75dea5f84 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 29 Nov 2015 04:03:48 +0100 Subject: [PATCH 44/55] Remove characteristics from kart --- src/graphics/camera.cpp | 18 +-- src/graphics/slip_stream.cpp | 27 ++-- src/items/attachment.cpp | 1 - src/items/plunger.cpp | 1 - src/items/powerup.cpp | 1 - src/items/rubber_band.cpp | 1 - src/items/swatter.cpp | 1 - src/karts/abstract_kart.cpp | 28 ---- src/karts/abstract_kart.hpp | 10 -- src/karts/cannon_animation.cpp | 3 +- src/karts/controller/ai_base_controller.cpp | 3 +- .../controller/network_player_controller.cpp | 3 +- src/karts/controller/player_controller.cpp | 7 +- src/karts/controller/skidding_ai.cpp | 21 ++- src/karts/explosion_animation.cpp | 7 +- src/karts/kart.cpp | 138 +++++++++--------- src/karts/kart_gfx.cpp | 3 +- src/karts/kart_properties.cpp | 3 + src/karts/kart_properties.hpp | 3 +- src/karts/max_speed.cpp | 5 +- src/karts/rescue_animation.cpp | 5 +- src/karts/skidding.cpp | 69 +++++---- src/modes/soccer_world.cpp | 1 - src/physics/btKart.cpp | 9 +- src/physics/physics.cpp | 19 ++- src/scriptengine/script_kart.cpp | 3 +- src/states_screens/race_gui.cpp | 5 +- src/states_screens/race_gui_overworld.cpp | 5 +- src/tracks/track.cpp | 3 +- src/utils/debug.cpp | 8 +- 30 files changed, 176 insertions(+), 235 deletions(-) diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 4742cc253..759c49943 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -25,7 +25,6 @@ #include "config/user_config.hpp" #include "graphics/irr_driver.hpp" #include "io/xml_node.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/explosion_animation.hpp" #include "karts/kart.hpp" @@ -68,7 +67,7 @@ Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL) setupCamera(); if (kart != NULL) { - m_distance = kart->getCharacteristic()->getCameraDistance(); + m_distance = kart->getKartProperties()->getCameraDistance(); setKart(kart); } else @@ -379,9 +378,9 @@ void Camera::smoothMoveCamera(float dt) core::vector3df current_position = m_camera->getPosition(); // Smoothly interpolate towards the position and target - const AbstractCharacteristic *ch = m_kart->getCharacteristic(); - float max_increase_with_zipper = ch->getZipperMaxSpeedIncrease(); - float max_speed_without_zipper = ch->getEngineMaxSpeed(); + const KartProperties *kp = m_kart->getKartProperties(); + float max_increase_with_zipper = kp->getZipperMaxSpeedIncrease(); + float max_speed_without_zipper = kp->getEngineMaxSpeed(); float current_speed = m_kart->getSpeed(); const Skidding *ks = m_kart->getSkidding(); @@ -447,7 +446,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, float *sideway, float *distance, bool *smoothing) { - const AbstractCharacteristic *ch = m_kart->getCharacteristic(); + const KartProperties *kp = m_kart->getKartProperties(); switch(m_mode) { @@ -470,7 +469,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, else { *above_kart = 0.75f; - *cam_angle = ch->getCameraForwardUpAngle() * DEGREE_TO_RAD; + *cam_angle = kp->getCameraForwardUpAngle() * DEGREE_TO_RAD; *distance = -m_distance; } float steering = m_kart->getSteerPercent() @@ -485,7 +484,7 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, case CM_REVERSE: // Same as CM_NORMAL except it looks backwards { *above_kart = 0.75f; - *cam_angle = ch->getCameraBackwardUpAngle() * DEGREE_TO_RAD; + *cam_angle = kp->getCameraBackwardUpAngle() * DEGREE_TO_RAD; *sideway = 0; *distance = 2.0f*m_distance; *smoothing = false; @@ -833,8 +832,7 @@ void Camera::handleEndCamera(float dt) } case EndCameraInformation::EC_AHEAD_OF_KART: { - const AbstractCharacteristic *ch = m_kart->getCharacteristic(); - float cam_angle = ch->getCameraBackwardUpAngle() * DEGREE_TO_RAD; + float cam_angle = m_kart->getKartProperties()->getCameraBackwardUpAngle() * DEGREE_TO_RAD; positionCamera(dt, /*above_kart*/0.75f, cam_angle, /*side_way*/0, diff --git a/src/graphics/slip_stream.cpp b/src/graphics/slip_stream.cpp index 5f0fb37e5..8ed2c2a31 100644 --- a/src/graphics/slip_stream.cpp +++ b/src/graphics/slip_stream.cpp @@ -25,7 +25,6 @@ #include "graphics/material_manager.hpp" #include "graphics/stk_mesh_scene_node.hpp" #include "io/file_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" @@ -68,9 +67,9 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart) setTextureMatrix(&(m_node->getMaterial(0).getTextureMatrix(0))); m_slipstream_time = 0.0f; - float length = m_kart->getCharacteristic()->getSlipstreamLength(); + float length = m_kart->getKartProperties()->getSlipstreamLength(); float kw = m_kart->getKartWidth(); - float ew = m_kart->getCharacteristic()->getSlipstreamWidth(); + float ew = m_kart->getKartProperties()->getSlipstreamWidth(); float kl = m_kart->getKartLength(); Vec3 p[4]; @@ -313,7 +312,7 @@ void SlipStream::setIntensity(float f, const AbstractKart *kart) bool SlipStream::isSlipstreamReady() const { return m_slipstream_time> - m_kart->getCharacteristic()->getSlipstreamCollectTime(); + m_kart->getKartProperties()->getSlipstreamCollectTime(); } // isSlipstreamReady //----------------------------------------------------------------------------- @@ -327,12 +326,12 @@ void SlipStream::updateSlipstreamPower() if(m_slipstream_mode==SS_USE) { setIntensity(2.0f, NULL); - const AbstractCharacteristic *ch=m_kart->getCharacteristic(); + const KartProperties *kp = m_kart->getKartProperties(); m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, - ch->getSlipstreamMaxSpeedIncrease(), - ch->getSlipstreamAddPower(), - ch->getSlipstreamDuration(), - ch->getSlipstreamFadeOutTime()); + kp->getSlipstreamMaxSpeedIncrease(), + kp->getSlipstreamAddPower(), + kp->getSlipstreamDuration(), + kp->getSlipstreamFadeOutTime()); } } // upateSlipstreamPower @@ -388,7 +387,7 @@ void SlipStream::update(float dt) // not moving. This is useful for debugging the graphics of SS-ing. //#define DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING - if(m_kart->getSpeed() < m_kart->getCharacteristic()->getSlipstreamMinSpeed()) + if(m_kart->getSpeed() < m_kart->getKartProperties()->getSlipstreamMinSpeed()) { setIntensity(0, NULL); m_slipstream_mode = SS_NONE; @@ -430,7 +429,7 @@ void SlipStream::update(float dt) // give karts different slipstream properties. #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING if(m_target_kart->getSpeed() < - m_kart->getCharacteristic()->getSlipstreamMinSpeed()) + m_kart->getKartProperties()->getSlipstreamMinSpeed()) { if(UserConfigParams::m_slipstream_debug && m_kart->getController()->isPlayerController()) @@ -444,7 +443,7 @@ void SlipStream::update(float dt) // slipstream length+0.5*kart_length()+0.5*target_kart_length // away from the other kart Vec3 delta = m_kart->getXYZ() - m_target_kart->getXYZ(); - float l = m_kart->getCharacteristic()->getSlipstreamLength() + float l = m_kart->getKartProperties()->getSlipstreamLength() + 0.5f*( m_target_kart->getKartLength() +m_kart->getKartLength() ); if(delta.length2_2d() > l*l) @@ -485,7 +484,7 @@ void SlipStream::update(float dt) m_slipstream_mode = SS_USE; m_kart->handleZipper(); m_slipstream_time = - m_kart->getCharacteristic()->getSlipstreamCollectTime(); + m_kart->getKartProperties()->getSlipstreamCollectTime(); return; } } @@ -506,7 +505,7 @@ void SlipStream::update(float dt) setIntensity(m_slipstream_time, m_target_kart); m_slipstream_mode = SS_COLLECT; - if(m_slipstream_time>m_kart->getCharacteristic()->getSlipstreamCollectTime()) + if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime()) { setIntensity(1.0f, m_target_kart); } diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index a405a55c7..e8c8d3c94 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -30,7 +30,6 @@ #include "items/item_manager.hpp" #include "items/projectile_manager.hpp" #include "items/swatter.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/explosion_animation.hpp" diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 011a0a983..e2f69adfb 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -25,7 +25,6 @@ #include "io/xml_node.hpp" #include "items/rubber_band.hpp" #include "items/projectile_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index 3f89ebe59..2b21202d1 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -28,7 +28,6 @@ #include "items/item_manager.hpp" #include "items/projectile_manager.hpp" #include "items/rubber_ball.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" diff --git a/src/items/rubber_band.cpp b/src/items/rubber_band.cpp index 805028b94..b9441560d 100644 --- a/src/items/rubber_band.cpp +++ b/src/items/rubber_band.cpp @@ -26,7 +26,6 @@ #include "graphics/stk_mesh_scene_node.hpp" #include "items/plunger.hpp" #include "items/projectile_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "karts/max_speed.hpp" diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index 13140595b..419f3061f 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -34,7 +34,6 @@ #include "io/file_manager.hpp" #include "items/attachment.hpp" #include "items/projectile_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/controller/controller.hpp" #include "karts/explosion_animation.hpp" #include "karts/kart_properties.hpp" diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index e8e9044b1..75eea4cbc 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -20,8 +20,6 @@ #include "karts/abstract_kart.hpp" #include "items/powerup.hpp" -#include "karts/cached_characteristic.hpp" -#include "karts/combined_characteristic.hpp" #include "karts/abstract_kart_animation.hpp" #include "karts/kart_model.hpp" #include "karts/kart_properties.hpp" @@ -60,26 +58,6 @@ AbstractKart::AbstractKart(const std::string& ident, m_kart_length = m_kart_model->getLength(); m_kart_highest_point = m_kart_model->getHighestPoint(); m_wheel_graphics_position = m_kart_model->getWheelsGraphicsPosition(); - - // Combine the characteristics for this player - m_combined_characteristic.reset(new CombinedCharacteristic()); - m_combined_characteristic->addCharacteristic(kart_properties_manager-> - getBaseCharacteristic()); - m_combined_characteristic->addCharacteristic(kart_properties_manager-> - getDifficultyCharacteristic(race_manager->getDifficultyAsString( - race_manager->getDifficulty()))); - - // Try to get the kart type - const AbstractCharacteristic *characteristic = kart_properties_manager-> - getKartTypeCharacteristic(m_kart_properties->getKartType()); - if (characteristic) - m_combined_characteristic->addCharacteristic(characteristic); - - m_combined_characteristic->addCharacteristic(kart_properties_manager-> - getPlayerCharacteristic(KartProperties::getPerPlayerDifficultyAsString( - m_difficulty))); - m_combined_characteristic->addCharacteristic(m_kart_properties->getCharacteristic()); - m_characteristic.reset(new CachedCharacteristic(m_combined_characteristic.get())); } // AbstractKart // ---------------------------------------------------------------------------- @@ -101,12 +79,6 @@ void AbstractKart::reset() } } // reset -// ---------------------------------------------------------------------------- -const AbstractCharacteristic* AbstractKart::getCharacteristic() const -{ - return m_characteristic.get(); -} - // ---------------------------------------------------------------------------- /** Returns a name to be displayed for this kart. */ core::stringw AbstractKart::getName() const diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index 516c87200..8857889fa 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -34,13 +34,10 @@ namespace irr } } -class AbstractCharacteristic; class AbstractKartAnimation; class Attachment; class btKart; class btQuaternion; -class CachedCharacteristic; -class CombinedCharacteristic; class Controller; class Item; class KartModel; @@ -78,10 +75,6 @@ protected: /** The per-player difficulty. */ PerPlayerDifficulty m_difficulty; - /** The combined properties of the kart, the player, etc. */ - std::unique_ptr m_combined_characteristic; - /** The cached combined characteristics. */ - std::unique_ptr m_characteristic; /** This stores a copy of the kart model. It has to be a copy * since otherwise incosistencies can happen if the same kart @@ -129,9 +122,6 @@ public: /** Returns the kart properties of this kart. */ const KartProperties* getKartProperties() const { return m_kart_properties.get(); } - // ------------------------------------------------------------------------ - /** Returns the characteristics of this kart. */ - const AbstractCharacteristic* getCharacteristic() const; // ======================================================================== // Access to the per-player difficulty. diff --git a/src/karts/cannon_animation.cpp b/src/karts/cannon_animation.cpp index 411c52f14..39ce1a933 100644 --- a/src/karts/cannon_animation.cpp +++ b/src/karts/cannon_animation.cpp @@ -21,7 +21,6 @@ #include "animations/animation_base.hpp" #include "animations/ipo.hpp" #include "animations/three_d_animation.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/world.hpp" @@ -70,7 +69,7 @@ CannonAnimation::~CannonAnimation() m_kart->getHeading() )); m_kart->getBody()->setCenterOfMassTransform(pos); - Vec3 v(0, 0, m_kart->getCharacteristic()->getEngineMaxSpeed()); + Vec3 v(0, 0, m_kart->getKartProperties()->getEngineMaxSpeed()); m_kart->setVelocity(pos.getBasis()*v); } // ~CannonAnimation diff --git a/src/karts/controller/ai_base_controller.cpp b/src/karts/controller/ai_base_controller.cpp index 19d70f22a..84b9b4666 100644 --- a/src/karts/controller/ai_base_controller.cpp +++ b/src/karts/controller/ai_base_controller.cpp @@ -20,7 +20,6 @@ #include "karts/controller/ai_base_controller.hpp" #include "config/user_config.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "karts/controller/ai_properties.hpp" @@ -501,7 +500,7 @@ bool AIBaseController::doSkid(float steer_fraction) // FIXME: Disable skidding for now if the new skidding // code is activated, since the AI can not handle this // properly. - if(m_kart->getCharacteristic()->getSkidVisualTime() > 0) + if(m_kart->getKartProperties()->getSkidVisualTime() > 0) return false; // Otherwise return if we need a sharp turn (which is diff --git a/src/karts/controller/network_player_controller.cpp b/src/karts/controller/network_player_controller.cpp index f28fd96ee..61ae75113 100644 --- a/src/karts/controller/network_player_controller.cpp +++ b/src/karts/controller/network_player_controller.cpp @@ -7,7 +7,6 @@ #include "items/attachment.hpp" #include "items/item.hpp" #include "items/powerup.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "karts/skidding.hpp" @@ -198,7 +197,7 @@ void NetworkPlayerController::steer(float dt, int steer_val) // change speed is used. const float STEER_CHANGE = ( (steer_val<=0 && m_controls->m_steer<0) || (steer_val>=0 && m_controls->m_steer>0) ) - ? dt/m_kart->getCharacteristic()->getTurnTimeResetSteer() + ? dt/m_kart->getKartProperties()->getTurnTimeResetSteer() : dt/m_kart->getTimeFullSteer(fabsf(m_controls->m_steer)); if (steer_val < 0) { diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index 5d22f1aa3..eb4cadea0 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -29,7 +29,6 @@ #include "items/attachment.hpp" #include "items/item.hpp" #include "items/powerup.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "karts/skidding.hpp" @@ -255,7 +254,7 @@ void PlayerController::steer(float dt, int steer_val) // change speed is used. const float STEER_CHANGE = ( (steer_val<=0 && m_controls->m_steer<0) || (steer_val>=0 && m_controls->m_steer>0) ) - ? dt/m_kart->getCharacteristic()->getTurnTimeResetSteer() + ? dt/m_kart->getKartProperties()->getTurnTimeResetSteer() : dt/m_kart->getTimeFullSteer(fabsf(m_controls->m_steer)); if (steer_val < 0) { @@ -469,8 +468,8 @@ void PlayerController::handleZipper(bool play_sound) */ void PlayerController::collectedItem(const Item &item, int add_info, float old_energy) { - if (old_energy < m_kart->getCharacteristic()->getNitroMax() && - m_kart->getEnergy() == m_kart->getCharacteristic()->getNitroMax()) + if (old_energy < m_kart->getKartProperties()->getNitroMax() && + m_kart->getEnergy() == m_kart->getKartProperties()->getNitroMax()) { m_full_sound->play(); } diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index d87ee1a0d..5d59be034 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -31,7 +31,6 @@ #include "items/item_manager.hpp" #include "items/powerup.hpp" #include "items/projectile_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/kart_control.hpp" #include "karts/controller/ai_properties.hpp" @@ -1052,8 +1051,8 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, case Item::ITEM_NITRO_BIG: // Only collect nitro, if it can actually be stored. if(m_kart->getEnergy() + - m_kart->getCharacteristic()->getNitroBigContainer() - > m_kart->getCharacteristic()->getNitroMax()) + m_kart->getKartProperties()->getNitroBigContainer() + > m_kart->getKartProperties()->getNitroMax()) return; // fall through: if we have enough space to store a big // container, we can also store a small container, and @@ -1061,8 +1060,8 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, case Item::ITEM_NITRO_SMALL: avoid = false; // Only collect nitro, if it can actually be stored. if (m_kart->getEnergy() + - m_kart->getCharacteristic()->getNitroSmallContainer() - > m_kart->getCharacteristic()->getNitroMax()) + m_kart->getKartProperties()->getNitroSmallContainer() + > m_kart->getKartProperties()->getNitroMax()) return; case Item::ITEM_BONUS_BOX: break; @@ -1092,7 +1091,7 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, // be if the kart would need to turn sharper, therefore stops // skidding, and will get the bonus speed. bool high_speed = (m_kart->getCurrentMaxSpeed() > - m_kart->getCharacteristic()->getEngineMaxSpeed() ) || + m_kart->getKartProperties()->getEngineMaxSpeed() ) || m_kart->getSkidding()->getSkidBonusReady(); float max_angle = high_speed ? m_ai_properties->m_max_item_angle_high_speed @@ -1354,13 +1353,13 @@ void SkiddingAI::handleItems(const float dt) case PowerupManager::POWERUP_PARACHUTE: // Wait one second more than a previous parachute - if(m_time_since_last_shot > m_kart->getCharacteristic()->getParachuteDurationOther() + 1.0f) + if(m_time_since_last_shot > m_kart->getKartProperties()->getParachuteDurationOther() + 1.0f) m_controls->m_fire = true; break; // POWERUP_PARACHUTE case PowerupManager::POWERUP_ANVIL: // Wait one second more than a previous anvil - if(m_time_since_last_shot < m_kart->getCharacteristic()->getAnvilDuration() + 1.0f) break; + if(m_time_since_last_shot < m_kart->getKartProperties()->getAnvilDuration() + 1.0f) break; if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER) { @@ -1377,7 +1376,7 @@ void SkiddingAI::handleItems(const float dt) case PowerupManager::POWERUP_SWATTER: { // Squared distance for which the swatter works - float d2 = m_kart->getCharacteristic()->getSwatterDistance(); + float d2 = m_kart->getKartProperties()->getSwatterDistance(); // if the kart has a shield, do not break it by using a swatter. if(m_kart->getShieldTime() > min_bubble_time) break; @@ -2287,8 +2286,8 @@ bool SkiddingAI::doSkid(float steer_fraction) return false; } // If there is a skidding bonus, try to get it. - else if (m_kart->getCharacteristic()->getSkidBonusSpeed().size() > 0 && - m_kart->getCharacteristic()->getSkidTimeTillBonus()[0] < duration) + else if (m_kart->getKartProperties()->getSkidBonusSpeed().size() > 0 && + m_kart->getKartProperties()->getSkidTimeTillBonus()[0] < duration) { #ifdef DEBUG if(!m_controls->m_skid && m_ai_debug) diff --git a/src/karts/explosion_animation.cpp b/src/karts/explosion_animation.cpp index 5cd0864f9..a0c622cce 100644 --- a/src/karts/explosion_animation.cpp +++ b/src/karts/explosion_animation.cpp @@ -22,7 +22,6 @@ #include "graphics/callbacks.hpp" #include "graphics/camera.hpp" #include "items/attachment.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/world.hpp" @@ -41,7 +40,7 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart, { if(kart->isInvulnerable()) return NULL; - float r = kart->getCharacteristic()->getExplosionRadius(); + float r = kart->getKartProperties()->getExplosionRadius(); // Ignore explosion that are too far away. if(!direct_hit && pos.distance2(kart->getXYZ())>r*r) return NULL; @@ -79,7 +78,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart, m_xyz = m_kart->getXYZ(); m_orig_y = m_xyz.getY(); m_kart->playCustomSFX(SFXManager::CUSTOM_EXPLODE); - m_timer = m_kart->getCharacteristic()->getExplosionDuration(); + m_timer = m_kart->getKartProperties()->getExplosionDuration(); // Non-direct hits will be only affected half as much. if(!direct_hit) m_timer*=0.5f; @@ -106,7 +105,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart, m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f ); // Set invulnerable time, and graphical effects - float t = m_kart->getCharacteristic()->getExplosionInvulnerabilityTime(); + float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime(); m_kart->setInvulnerableTime(t); m_kart->showStarEffect(t); diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index d6ee8c5a0..c4c174b13 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -364,8 +364,8 @@ void Kart::reset() // In case that the kart was in the air, in which case its // linear damping is 0 if(m_body) - m_body->setDamping(m_characteristic->getStabilityChassisLinearDamping(), - m_characteristic->getStabilityChassisAngularDamping() ); + m_body->setDamping(m_kart_properties->getStabilityChassisLinearDamping(), + m_kart_properties->getStabilityChassisAngularDamping()); if(m_terrain_sound) { @@ -522,7 +522,7 @@ void Kart::blockViewWithPlunger() { // Avoid that a plunger extends the plunger time if(m_view_blocked_by_plunger<=0 && !isShielded()) - m_view_blocked_by_plunger = m_characteristic->getPlungerInFaceTime(); + m_view_blocked_by_plunger = m_kart_properties->getPlungerInFaceTime(); if(isShielded()) { decreaseShieldTime(); @@ -556,7 +556,7 @@ btTransform Kart::getAlignedTransform(const float custom_pitch) // ---------------------------------------------------------------------------- float Kart::getTimeFullSteer(float steer) const { - return m_characteristic->getTurnTimeFullSteer().get(steer); + return m_kart_properties->getTurnTimeFullSteer().get(steer); } // getTimeFullSteer // ---------------------------------------------------------------------------- @@ -601,7 +601,7 @@ void Kart::createPhysics() if (y == -1) { int index = (x + 1) / 2 + 1 - z; // get index of wheel - float f = getKartProperties()->getPhysicalWheelPosition(); + float f = m_kart_properties->getPhysicalWheelPosition(); // f < 0 indicates to use the old physics position, i.e. // to place the wheels outside of the chassis if(f<0) @@ -639,7 +639,7 @@ void Kart::createPhysics() // Set mass and inertia // -------------------- - float mass = m_characteristic->getMass(); + float mass = m_kart_properties->getMass(); // Position the chassis // -------------------- @@ -648,8 +648,8 @@ void Kart::createPhysics() createBody(mass, trans, &m_kart_chassis, m_kart_properties->getRestitution()); m_user_pointer.set(this); - m_body->setDamping(m_characteristic->getStabilityChassisLinearDamping(), - m_characteristic->getStabilityChassisAngularDamping() ); + m_body->setDamping(m_kart_properties->getStabilityChassisLinearDamping(), + m_kart_properties->getStabilityChassisAngularDamping() ); // Reset velocities // ---------------- @@ -669,18 +669,18 @@ void Kart::createPhysics() // Add wheels // ---------- - float suspension_rest = m_characteristic->getSuspensionRest(); + float suspension_rest = m_kart_properties->getSuspensionRest(); btVector3 wheel_direction(0.0f, -1.0f, 0.0f); btVector3 wheel_axle(-1.0f, 0.0f, 0.0f); btKart::btVehicleTuning tuning; tuning.m_maxSuspensionTravel = - m_characteristic->getSuspensionTravel(); + m_kart_properties->getSuspensionTravel(); tuning.m_maxSuspensionForce = - m_characteristic->getSuspensionMaxForce(); + m_kart_properties->getSuspensionMaxForce(); - const Vec3 &cs = getKartProperties()->getGravityCenterShift(); + const Vec3 &cs = m_kart_properties->getGravityCenterShift(); for(unsigned int i=0; i<4; i++) { bool is_front_wheel = i<2; @@ -689,11 +689,11 @@ void Kart::createPhysics() wheel_direction, wheel_axle, suspension_rest, m_kart_model->getWheelGraphicsRadius(i), tuning, is_front_wheel); - wheel.m_suspensionStiffness = m_characteristic->getSuspensionStiffness(); - wheel.m_wheelsDampingRelaxation = m_characteristic->getWheelsDampingRelaxation(); - wheel.m_wheelsDampingCompression = m_characteristic->getWheelsDampingCompression(); + wheel.m_suspensionStiffness = m_kart_properties->getSuspensionStiffness(); + wheel.m_wheelsDampingRelaxation = m_kart_properties->getWheelsDampingRelaxation(); + wheel.m_wheelsDampingCompression = m_kart_properties->getWheelsDampingCompression(); wheel.m_frictionSlip = m_kart_properties->getFrictionSlip(); - wheel.m_rollInfluence = m_characteristic->getStabilityRollInfluence(); + wheel.m_rollInfluence = m_kart_properties->getStabilityRollInfluence(); } // Obviously these allocs have to be properly managed/freed btTransform t; @@ -779,7 +779,7 @@ void Kart::adjustSpeed(float f) */ void Kart::updateWeight() { - float mass = m_characteristic->getMass() + m_attachment->weightAdjust(); + float mass = m_kart_properties->getMass() + m_attachment->weightAdjust(); btVector3 inertia; m_kart_chassis.calculateLocalInertia(mass, inertia); @@ -791,7 +791,7 @@ void Kart::updateWeight() * \param radius The radius for which the speed needs to be computed. */ float Kart::getSpeedForTurnRadius(float radius) const { - InterpolationArray turn_angle_at_speed = m_characteristic->getTurnRadius(); + InterpolationArray turn_angle_at_speed = m_kart_properties->getTurnRadius(); // Convert the turn radius into turn angle for(std::size_t i = 0; i < turn_angle_at_speed.size(); i++) turn_angle_at_speed.setY(i, sin(m_kart_properties->getWheelBase() / @@ -805,7 +805,7 @@ float Kart::getSpeedForTurnRadius(float radius) const /** Returns the maximum steering angle (depending on speed). */ float Kart::getMaxSteerAngle(float speed) const { - InterpolationArray turn_angle_at_speed = m_characteristic->getTurnRadius(); + InterpolationArray turn_angle_at_speed = m_kart_properties->getTurnRadius(); // Convert the turn radius into turn angle for(std::size_t i = 0; i < turn_angle_at_speed.size(); i++) turn_angle_at_speed.setY(i, sin(m_kart_properties->getWheelBase() / @@ -921,10 +921,10 @@ void Kart::collectedItem(Item *item, int add_info) m_attachment->hitBanana(item, add_info); break; case Item::ITEM_NITRO_SMALL: - m_collected_energy += m_characteristic->getNitroSmallContainer(); + m_collected_energy += m_kart_properties->getNitroSmallContainer(); break; case Item::ITEM_NITRO_BIG: - m_collected_energy += m_characteristic->getNitroBigContainer(); + m_collected_energy += m_kart_properties->getNitroBigContainer(); break; case Item::ITEM_BONUS_BOX : { @@ -936,13 +936,13 @@ void Kart::collectedItem(Item *item, int add_info) item->getEmitter()->getIdent() == "nolok"); // slow down - m_bubblegum_time = m_characteristic->getBubblegumDuration(); + m_bubblegum_time = m_kart_properties->getBubblegumDuration(); m_bubblegum_torque = ((rand()%2) - ? m_characteristic->getBubblegumTorque() - : -m_characteristic->getBubblegumTorque()); + ? m_kart_properties->getBubblegumTorque() + : -m_kart_properties->getBubblegumTorque()); m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE, - m_characteristic->getBubblegumSpeedFraction() , - m_characteristic->getBubblegumFadeInTime(), + m_kart_properties->getBubblegumSpeedFraction() , + m_kart_properties->getBubblegumFadeInTime(), m_bubblegum_time); m_goo_sound->setPosition(getXYZ()); m_goo_sound->play(); @@ -952,8 +952,8 @@ void Kart::collectedItem(Item *item, int add_info) default : break; } // switch TYPE - if ( m_collected_energy > m_characteristic->getNitroMax()) - m_collected_energy = m_characteristic->getNitroMax(); + if ( m_collected_energy > m_kart_properties->getNitroMax()) + m_collected_energy = m_kart_properties->getNitroMax(); m_controller->collectedItem(*item, add_info, old_energy); } // collectedItem @@ -968,11 +968,11 @@ void Kart::collectedItem(Item *item, int add_info) float Kart::getStartupBoost() const { float t = World::getWorld()->getTime(); - std::vector startup_times = m_characteristic->getStartupTime(); + std::vector startup_times = m_kart_properties->getStartupTime(); for (unsigned int i = 0; i < startup_times.size(); i++) { if (t <= startup_times[i]) - return m_characteristic->getStartupBoost()[i]; + return m_kart_properties->getStartupBoost()[i]; } return 0; } // getStartupBoost @@ -985,20 +985,20 @@ float Kart::getActualWheelForce() { float add_force = m_max_speed->getCurrentAdditionalEngineForce(); assert(!isnan(add_force)); - const std::vector& gear_ratio=m_characteristic->getGearSwitchRatio(); + const std::vector& gear_ratio=m_kart_properties->getGearSwitchRatio(); for(unsigned int i=0; igetEngineMaxSpeed() * gear_ratio[i]) + if(m_speed <= m_kart_properties->getEngineMaxSpeed() * gear_ratio[i]) { - assert(!isnan(m_characteristic->getEnginePower())); - assert(!isnan(m_characteristic->getGearPowerIncrease()[i])); - return m_characteristic->getEnginePower() - * m_characteristic->getGearPowerIncrease()[i] + assert(!isnan(m_kart_properties->getEnginePower())); + assert(!isnan(m_kart_properties->getGearPowerIncrease()[i])); + return m_kart_properties->getEnginePower() + * m_kart_properties->getGearPowerIncrease()[i] + add_force; } } - assert(!isnan(m_characteristic->getEnginePower())); - return m_characteristic->getEnginePower() + add_force * 2; + assert(!isnan(m_kart_properties->getEnginePower())); + return m_kart_properties->getEnginePower() + add_force * 2; } // getActualWheelForce @@ -1195,12 +1195,12 @@ void Kart::update(float dt) // When the kart is jumping, linear damping reduces the falling speed // of a kart so much that it can appear to be in slow motion. So // disable linear damping if a kart is in the air - m_body->setDamping(0, m_characteristic->getStabilityChassisAngularDamping()); + m_body->setDamping(0, m_kart_properties->getStabilityChassisAngularDamping()); } else { - m_body->setDamping(m_characteristic->getStabilityChassisLinearDamping(), - m_characteristic->getStabilityChassisAngularDamping()); + m_body->setDamping(m_kart_properties->getStabilityChassisLinearDamping(), + m_kart_properties->getStabilityChassisAngularDamping()); } if(m_kart_animation) @@ -1368,7 +1368,7 @@ void Kart::update(float dt) static video::SColor green(255, 61, 87, 23); // draw skidmarks if relevant (we force pink skidmarks on when hitting a bubblegum) - if(m_characteristic->getSkidEnabled()) + if(m_kart_properties->getSkidEnabled()) { m_skidmarks->update(dt, m_bubblegum_time > 0, @@ -1411,7 +1411,7 @@ void Kart::update(float dt) // Jump if either the jump is estimated to be long enough, or // the texture has the jump property set. - if (t > m_characteristic->getJumpAnimationTime() || + if (t > m_kart_properties->getJumpAnimationTime() || last_m->isJumpTexture()) { m_kart_model->setAnimation(KartModel::AF_JUMP_START); @@ -1706,23 +1706,23 @@ void Kart::handleZipper(const Material *material, bool play_sound) material->getZipperParameter(&max_speed_increase, &duration, &speed_gain, &fade_out_time, &engine_force); if(max_speed_increase<0) - max_speed_increase = m_characteristic->getZipperMaxSpeedIncrease(); + max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease(); if(duration<0) - duration = m_characteristic->getZipperDuration(); + duration = m_kart_properties->getZipperDuration(); if(speed_gain<0) - speed_gain = m_characteristic->getZipperSpeedGain(); + speed_gain = m_kart_properties->getZipperSpeedGain(); if(fade_out_time<0) - fade_out_time = m_characteristic->getZipperFadeOutTime(); + fade_out_time = m_kart_properties->getZipperFadeOutTime(); if(engine_force<0) - engine_force = m_characteristic->getZipperForce(); + engine_force = m_kart_properties->getZipperForce(); } else { - max_speed_increase = m_characteristic->getZipperMaxSpeedIncrease(); - duration = m_characteristic->getZipperDuration(); - speed_gain = m_characteristic->getZipperSpeedGain(); - fade_out_time = m_characteristic->getZipperFadeOutTime(); - engine_force = m_characteristic->getZipperForce(); + max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease(); + duration = m_kart_properties->getZipperDuration(); + speed_gain = m_kart_properties->getZipperSpeedGain(); + fade_out_time = m_kart_properties->getZipperFadeOutTime(); + engine_force = m_kart_properties->getZipperForce(); } // Ignore a zipper that's activated while braking if(m_controls.m_brake || m_speed<0) return; @@ -1763,7 +1763,7 @@ void Kart::updateNitro(float dt) return; } - m_collected_energy -= dt * m_characteristic->getNitroConsumption(); + m_collected_energy -= dt * m_kart_properties->getNitroConsumption(); if (m_collected_energy < 0) { if(m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING) @@ -1777,10 +1777,10 @@ void Kart::updateNitro(float dt) if(m_nitro_sound->getStatus() != SFXBase::SFX_PLAYING) m_nitro_sound->play(); m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO, - m_characteristic->getNitroMaxSpeedIncrease(), - m_characteristic->getNitroEngineForce(), - m_characteristic->getNitroDuration(), - m_characteristic->getNitroFadeOutTime()); + m_kart_properties->getNitroMaxSpeedIncrease(), + m_kart_properties->getNitroEngineForce(), + m_kart_properties->getNitroDuration(), + m_kart_properties->getNitroFadeOutTime()); } else { @@ -1839,7 +1839,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal) #endif const LinearWorld *lw = dynamic_cast(World::getWorld()); - if(getKartProperties()->getTerrainImpulseType() + if(m_kart_properties->getTerrainImpulseType() ==KartProperties::IMPULSE_NORMAL && m_vehicle->getCentralImpulseTime()<=0 ) { @@ -1866,7 +1866,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal) // graph node center (we have to use the previous point since the // kart might have only now reached the new quad, meaning the kart // would be pushed forward). - else if(getKartProperties()->getTerrainImpulseType() + else if(m_kart_properties->getTerrainImpulseType() ==KartProperties::IMPULSE_TO_DRIVELINE && lw && m_vehicle->getCentralImpulseTime()<=0 && World::getWorld()->getTrack()->isPushBackEnabled()) @@ -2137,11 +2137,11 @@ void Kart::updatePhysics(float dt) // Only apply if near ground instead of purely based on speed avoiding // the "parachute on top" look. const Vec3 &v = m_body->getLinearVelocity(); - if(/*isNearGround() &&*/ v.getY() < - m_characteristic->getSuspensionTravel() * 0.01f * 60) + if(/*isNearGround() &&*/ v.getY() < - m_kart_properties->getSuspensionTravel() * 0.01f * 60) { Vec3 v_clamped = v; // clamp the speed to 99% of the maxium falling speed. - v_clamped.setY(-m_characteristic->getSuspensionTravel() * 0.01f * 60 * 0.99f); + v_clamped.setY(-m_kart_properties->getSuspensionTravel() * 0.01f * 60 * 0.99f); //m_body->setLinearVelocity(v_clamped); } @@ -2244,7 +2244,7 @@ void Kart::updateEnginePowerAndBrakes(float dt) // Lose some traction when skidding, to balance the advantage if (m_controls.m_skid && - m_characteristic->getSkidVisualTime() == 0) + m_kart_properties->getSkidVisualTime() == 0) engine_power *= 0.5f; applyEngineForce(engine_power*m_controls.m_accel); @@ -2267,8 +2267,8 @@ void Kart::updateEnginePowerAndBrakes(float dt) m_brake_time += dt; // Apply the brakes - include the time dependent brake increase float f = 1 + m_brake_time - * m_characteristic->getEngineBrakeTimeIncrease(); - m_vehicle->setAllBrakes(m_characteristic->getEngineBrakeFactor() * f); + * m_kart_properties->getEngineBrakeTimeIncrease(); + m_vehicle->setAllBrakes(m_kart_properties->getEngineBrakeFactor() * f); } else // m_speed < 0 { @@ -2276,7 +2276,7 @@ void Kart::updateEnginePowerAndBrakes(float dt) // going backward, apply reverse gear ratio (unless he goes // too fast backwards) if ( -m_speed < m_max_speed->getCurrentMaxSpeed() - *m_characteristic->getEngineMaxSpeedReverseRatio()) + *m_kart_properties->getEngineMaxSpeedReverseRatio()) { // The backwards acceleration is artificially increased to // allow players to get "unstuck" quicker if they hit e.g. @@ -2445,7 +2445,7 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model) m_slipstream = new SlipStream(this); - if (m_characteristic->getSkidEnabled()) + if (m_kart_properties->getSkidEnabled()) { m_skidmarks = new SkidMarks(*this); m_skidmarks->adjustFog( @@ -2629,7 +2629,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, { // fabs(speed) is important, otherwise the negative number will // become a huge unsigned number in the particle scene node! - nitro_frac = fabsf(getSpeed()) / (m_characteristic->getEngineMaxSpeed()); + nitro_frac = fabsf(getSpeed()) / (m_kart_properties->getEngineMaxSpeed()); // The speed of the kart can be higher (due to powerups) than // the normal maximum speed of the kart. if(nitro_frac>1.0f) nitro_frac = 1.0f; @@ -2643,7 +2643,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, // leaning might get less if a kart gets a special that increases // its maximum speed, but not the current speed (by much). On the // other hand, that ratio can often be greater than 1. - float speed_frac = m_speed / m_characteristic->getEngineMaxSpeed(); + float speed_frac = m_speed / m_kart_properties->getEngineMaxSpeed(); if(speed_frac>1.0f) speed_frac = 1.0f; else if (speed_frac < 0.0f) // no leaning when backwards driving diff --git a/src/karts/kart_gfx.cpp b/src/karts/kart_gfx.cpp index dda08e97c..28cf36e8e 100644 --- a/src/karts/kart_gfx.cpp +++ b/src/karts/kart_gfx.cpp @@ -25,7 +25,6 @@ #include "graphics/particle_emitter.hpp" #include "graphics/particle_kind.hpp" #include "graphics/particle_kind_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart.hpp" @@ -327,7 +326,7 @@ void KartGFX::updateTerrain(const ParticleKind *pk) if (skidding > 1.0f && on_ground) rate = fabsf(m_kart->getControls().m_steer) > 0.8 ? skidding - 1 : 0; else if (speed >= 0.5f && on_ground) - rate = speed/m_kart->getCharacteristic()->getEngineMaxSpeed(); + rate = speed/m_kart->getKartProperties()->getEngineMaxSpeed(); else { pe->setCreationRateAbsolute(0); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 09fc83c81..ccf7c2b44 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -309,6 +309,9 @@ void KartProperties::combineCharacteristics() m_combined_characteristic.reset(new CombinedCharacteristic()); m_combined_characteristic->addCharacteristic(kart_properties_manager-> getBaseCharacteristic()); + m_combined_characteristic->addCharacteristic(kart_properties_manager-> + getDifficultyCharacteristic(race_manager->getDifficultyAsString( + race_manager->getDifficulty()))); // Try to get the kart type const AbstractCharacteristic *characteristic = kart_properties_manager-> diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index c9ff4fc68..72b8a5c7c 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -40,6 +40,7 @@ using namespace irr; class AbstractCharacteristic; class AIProperties; +class CachedCharacteristic; class CombinedCharacteristic; class Material; class XMLNode; @@ -124,7 +125,7 @@ private: /** The base characteristics combined with the characteristics of this kart. */ std::shared_ptr m_combined_characteristic; /** The cached combined characteristics. */ - std::unique_ptr m_cached_characteristic; + std::shared_ptr m_cached_characteristic; // Physic properties // ----------------- diff --git a/src/karts/max_speed.cpp b/src/karts/max_speed.cpp index 08ee4249d..377720d81 100644 --- a/src/karts/max_speed.cpp +++ b/src/karts/max_speed.cpp @@ -21,7 +21,6 @@ #include #include -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "physics/btKart.hpp" @@ -63,7 +62,7 @@ MaxSpeed::MaxSpeed(AbstractKart *kart) */ void MaxSpeed::reset() { - m_current_max_speed = m_kart->getCharacteristic()->getEngineMaxSpeed(); + m_current_max_speed = m_kart->getKartProperties()->getEngineMaxSpeed(); m_min_speed = -1.0f; for(unsigned int i=MS_DECREASE_MIN; igetCharacteristic()->getEngineMaxSpeed(); + m_current_max_speed = m_kart->getKartProperties()->getEngineMaxSpeed(); // Then add the speed increase from each category // ---------------------------------------------- diff --git a/src/karts/rescue_animation.cpp b/src/karts/rescue_animation.cpp index d23810cba..29e2bcee9 100644 --- a/src/karts/rescue_animation.cpp +++ b/src/karts/rescue_animation.cpp @@ -22,7 +22,6 @@ #include "graphics/camera.hpp" #include "graphics/referee.hpp" #include "items/attachment.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/three_strikes_battle.hpp" @@ -40,8 +39,8 @@ RescueAnimation::RescueAnimation(AbstractKart *kart, bool is_auto_rescue) { m_referee = new Referee(*m_kart); m_kart->getNode()->addChild(m_referee->getSceneNode()); - m_timer = m_kart->getCharacteristic()->getRescueDuration(); - m_velocity = m_kart->getCharacteristic()->getRescueHeight() / m_timer; + m_timer = m_kart->getKartProperties()->getRescueDuration(); + m_velocity = m_kart->getKartProperties()->getRescueHeight() / m_timer; m_xyz = m_kart->getXYZ(); m_kart->getAttachment()->clear(); diff --git a/src/karts/skidding.cpp b/src/karts/skidding.cpp index 347a793fa..654449054 100644 --- a/src/karts/skidding.cpp +++ b/src/karts/skidding.cpp @@ -23,7 +23,6 @@ #endif #include "achievements/achievement_info.hpp" #include "config/player_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/ghost_kart.hpp" #include "karts/kart.hpp" #include "karts/kart_gfx.hpp" @@ -48,7 +47,7 @@ Skidding::Skidding(Kart *kart) m_actual_curve->setVisible(false); #endif m_kart = kart; - m_skid_reduce_turn_delta = m_kart->getCharacteristic()->getSkidReduceTurnMax() - m_kart->getCharacteristic()->getSkidReduceTurnMin(); + m_skid_reduce_turn_delta = m_kart->getKartProperties()->getSkidReduceTurnMax() - m_kart->getKartProperties()->getSkidReduceTurnMin(); reset(); } // Skidding @@ -101,7 +100,7 @@ void Skidding::updateSteering(float steer, float dt) case SKID_SHOW_GFX_RIGHT: case SKID_NONE: m_real_steering = steer; - if (m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime() && m_skid_time > 0) + if (m_skid_time < m_kart->getKartProperties()->getSkidVisualTime() && m_skid_time > 0) { float f = m_visual_rotation - m_visual_rotation*dt/m_skid_time; // Floating point errors when m_skid_time is very close to 0 @@ -125,27 +124,27 @@ void Skidding::updateSteering(float steer, float dt) case SKID_ACCUMULATE_RIGHT: { float f = (1.0f+steer)*0.5f; // map [-1,1] --> [0, 1] - m_real_steering = m_kart->getCharacteristic()->getSkidReduceTurnMin() + m_real_steering = m_kart->getKartProperties()->getSkidReduceTurnMin() + m_skid_reduce_turn_delta * f; - if(m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime()) - m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() + if(m_skid_time < m_kart->getKartProperties()->getSkidVisualTime()) + m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() * m_real_steering * m_skid_time - / m_kart->getCharacteristic()->getSkidVisualTime(); + / m_kart->getKartProperties()->getSkidVisualTime(); else - m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() * m_real_steering; + m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() * m_real_steering; break; } case SKID_ACCUMULATE_LEFT: { float f = (-1.0f+steer)*0.5f; // map [-1,1] --> [-1, 0] - m_real_steering = -m_kart->getCharacteristic()->getSkidReduceTurnMin() + m_real_steering = -m_kart->getKartProperties()->getSkidReduceTurnMin() + m_skid_reduce_turn_delta * f; - if(m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime()) - m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() + if(m_skid_time < m_kart->getKartProperties()->getSkidVisualTime()) + m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() * m_real_steering * m_skid_time - / m_kart->getCharacteristic()->getSkidVisualTime(); + / m_kart->getKartProperties()->getSkidVisualTime(); else - m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() * m_real_steering; + m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() * m_real_steering; break; } @@ -175,13 +174,13 @@ float Skidding::getSteeringWhenSkidding(float steering) const break; case SKID_ACCUMULATE_RIGHT: { - float f = (steering - m_kart->getCharacteristic()->getSkidReduceTurnMin()) + float f = (steering - m_kart->getKartProperties()->getSkidReduceTurnMin()) / m_skid_reduce_turn_delta; return f *2.0f-1.0f; } case SKID_ACCUMULATE_LEFT: { - float f = (steering + m_kart->getCharacteristic()->getSkidReduceTurnMin()) + float f = (steering + m_kart->getKartProperties()->getSkidReduceTurnMin()) / m_skid_reduce_turn_delta; return 2.0f * f +1.0f; } @@ -214,7 +213,7 @@ void Skidding::update(float dt, bool is_on_ground, #endif // No skidding backwards or while stopped - if(m_kart->getSpeed() < m_kart->getCharacteristic()->getSkidMinSpeed() && + if(m_kart->getSpeed() < m_kart->getKartProperties()->getSkidMinSpeed() && m_skid_state != SKID_NONE && m_skid_state != SKID_BREAK) { m_skid_state = SKID_BREAK; @@ -226,15 +225,15 @@ void Skidding::update(float dt, bool is_on_ground, if (is_on_ground) { if ((fabs(steering) > 0.001f) && - m_kart->getSpeed() > m_kart->getCharacteristic()->getSkidMinSpeed() && + m_kart->getSpeed() > m_kart->getKartProperties()->getSkidMinSpeed() && (skidding == KartControl::SC_LEFT || skidding == KartControl::SC_RIGHT)) { - m_skid_factor += m_kart->getCharacteristic()->getSkidIncrease() - * dt / m_kart->getCharacteristic()->getSkidTimeTillMax(); + m_skid_factor += m_kart->getKartProperties()->getSkidIncrease() + * dt / m_kart->getKartProperties()->getSkidTimeTillMax(); } else if (m_skid_factor > 1.0f) { - m_skid_factor *= m_kart->getCharacteristic()->getSkidDecrease(); + m_skid_factor *= m_kart->getKartProperties()->getSkidDecrease(); } } else @@ -242,8 +241,8 @@ void Skidding::update(float dt, bool is_on_ground, m_skid_factor = 1.0f; // Lose any skid factor as soon as we fly } - if (m_skid_factor > m_kart->getCharacteristic()->getSkidMax()) - m_skid_factor = m_kart->getCharacteristic()->getSkidMax(); + if (m_skid_factor > m_kart->getKartProperties()->getSkidMax()) + m_skid_factor = m_kart->getKartProperties()->getSkidMax(); else if (m_skid_factor < 1.0f) m_skid_factor = 1.0f; @@ -292,7 +291,7 @@ void Skidding::update(float dt, bool is_on_ground, // Don't allow skidding while the kart is (apparently) // still in the air, or when the kart is too slow if (m_remaining_jump_time > 0 || - m_kart->getSpeed() < m_kart->getCharacteristic()->getSkidMinSpeed()) + m_kart->getSpeed() < m_kart->getKartProperties()->getSkidMinSpeed()) break; m_skid_state = skidding==KartControl::SC_RIGHT @@ -304,14 +303,14 @@ void Skidding::update(float dt, bool is_on_ground, // Then use this speed to determine the impulse necessary to // reach this speed. float v = World::getWorld()->getTrack()->getGravity() - * 0.5f * m_kart->getCharacteristic()->getSkidPhysicalJumpTime(); + * 0.5f * m_kart->getKartProperties()->getSkidPhysicalJumpTime(); btVector3 imp(0, v / m_kart->getBody()->getInvMass(),0); m_kart->getVehicle()->getRigidBody()->applyCentralImpulse(imp); // Some karts might use a graphical-only jump. Set it up: m_jump_speed = World::getWorld()->getTrack()->getGravity() - * 0.5f * m_kart->getCharacteristic()->getSkidGraphicalJumpTime(); - m_remaining_jump_time = m_kart->getCharacteristic()->getSkidGraphicalJumpTime(); + * 0.5f * m_kart->getKartProperties()->getSkidGraphicalJumpTime(); + m_remaining_jump_time = m_kart->getKartProperties()->getSkidGraphicalJumpTime(); #ifdef SKID_DEBUG #define SPEED 20.0f @@ -392,11 +391,11 @@ void Skidding::update(float dt, bool is_on_ground, m_skid_state = m_skid_state == SKID_ACCUMULATE_LEFT ? SKID_SHOW_GFX_LEFT : SKID_SHOW_GFX_RIGHT; - float t = std::min(m_skid_time, m_kart->getCharacteristic()->getSkidVisualTime()); - t = std::min(t, m_kart->getCharacteristic()->getSkidRevertVisualTime()); + float t = std::min(m_skid_time, m_kart->getKartProperties()->getSkidVisualTime()); + t = std::min(t, m_kart->getKartProperties()->getSkidRevertVisualTime()); float vso = getVisualSkidRotation(); - btVector3 rot(0, vso * m_kart->getCharacteristic()->getSkidPostSkidRotateFactor(), 0); + btVector3 rot(0, vso * m_kart->getKartProperties()->getSkidPostSkidRotateFactor(), 0); m_kart->getVehicle()->setTimedRotation(t, rot); // skid_time is used to count backwards for the GFX m_skid_time = t; @@ -459,14 +458,14 @@ unsigned int Skidding::getSkidBonus(float *bonus_time, *bonus_time = 0; *bonus_speed = 0; *bonus_force = 0; - for (unsigned int i = 0; i < m_kart->getCharacteristic()->getSkidBonusSpeed().size(); i++) + for (unsigned int i = 0; i < m_kart->getKartProperties()->getSkidBonusSpeed().size(); i++) { - if (m_skid_time <= m_kart->getCharacteristic()->getSkidTimeTillBonus()[i]) + if (m_skid_time <= m_kart->getKartProperties()->getSkidTimeTillBonus()[i]) return i; - *bonus_speed = m_kart->getCharacteristic()->getSkidBonusSpeed()[i]; - *bonus_time = m_kart->getCharacteristic()->getSkidBonusTime()[i]; - *bonus_force = m_kart->getCharacteristic()->getSkidBonusForce()[i]; + *bonus_speed = m_kart->getKartProperties()->getSkidBonusSpeed()[i]; + *bonus_time = m_kart->getKartProperties()->getSkidBonusTime()[i]; + *bonus_force = m_kart->getKartProperties()->getSkidBonusForce()[i]; } - return (unsigned int) m_kart->getCharacteristic()->getSkidBonusSpeed().size(); + return (unsigned int) m_kart->getKartProperties()->getSkidBonusSpeed().size(); } // getSkidBonusForce diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 8c14e82a0..4792491a1 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -21,7 +21,6 @@ #include "audio/sfx_base.hpp" #include "io/file_manager.hpp" #include "graphics/irr_driver.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart.hpp" #include "karts/kart_model.hpp" diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 19055b727..63037b618 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -22,7 +22,6 @@ #include "LinearMath/btIDebugDraw.h" #include "BulletDynamics/ConstraintSolver/btContactConstraint.h" -#include "karts/abstract_characteristic.hpp" #include "karts/kart.hpp" #include "modes/world.hpp" #include "physics/triangle_mesh.hpp" @@ -462,7 +461,7 @@ void btKart::updateVehicle( btScalar step ) av.setZ(0); m_chassisBody->setAngularVelocity(av); // Give a nicely balanced feeling for rebalancing the kart - m_chassisBody->applyTorqueImpulse(axis * m_kart->getCharacteristic()->getStabilitySmoothFlyingImpulse()); + m_chassisBody->applyTorqueImpulse(axis * m_kart->getKartProperties()->getStabilitySmoothFlyingImpulse()); } // Work around: make sure that either both wheels on one axis @@ -544,7 +543,7 @@ void btKart::updateVehicle( btScalar step ) // If configured, add a force to keep karts on the track // ----------------------------------------------------- - float dif = m_kart->getCharacteristic()->getStabilityDownwardImpulseFactor(); + float dif = m_kart->getKartProperties()->getStabilityDownwardImpulseFactor(); if(dif!=0 && m_num_wheels_on_ground==4) { float f = -fabsf(m_kart->getSpeed()) * dif; @@ -656,7 +655,7 @@ void btKart::updateSuspension(btScalar deltaTime) // is already guaranteed that either both or no wheels on one axis // are on the ground, so we have to test only one of the wheels wheel_info.m_wheelsSuspensionForce = - -m_kart->getCharacteristic()->getStabilityTrackConnectionAccel() + -m_kart->getKartProperties()->getStabilityTrackConnectionAccel() * chassisMass; continue; } @@ -667,7 +666,7 @@ void btKart::updateSuspension(btScalar deltaTime) btScalar susp_length = wheel_info.getSuspensionRestLength(); btScalar current_length = wheel_info.m_raycastInfo.m_suspensionLength; btScalar length_diff = (susp_length - current_length); - if(m_kart->getCharacteristic()->getSuspensionExpSpringResponse()) + if(m_kart->getKartProperties()->getSuspensionExpSpringResponse()) length_diff *= fabsf(length_diff)/susp_length; float f = (1.0f + fabsf(length_diff) / susp_length); // Scale the length diff. This results that in uphill sections, when diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 962bf817c..48b29b3db 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -26,7 +26,6 @@ #include "graphics/irr_driver.hpp" #include "graphics/stars.hpp" #include "items/flyable.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/kart_properties.hpp" #include "karts/rescue_animation.hpp" #include "karts/controller/player_controller.hpp" @@ -219,9 +218,9 @@ void Physics::update(float dt) } else if (obj->isFlattenKartObject()) { - const AbstractCharacteristic *ch = kart->getCharacteristic(); - kart->setSquash(ch->getSwatterSquashDuration(), - ch->getSwatterSquashSlowdown()); + const KartProperties *kp = kart->getKartProperties(); + kart->setSquash(kp->getSwatterSquashDuration(), + kp->getSwatterSquashSlowdown()); } else if(obj->isSoccerBall() && race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) @@ -249,9 +248,9 @@ void Physics::update(float dt) else if (anim->isFlattenKartObject()) { AbstractKart *kart = p->getUserPointer(1)->getPointerKart(); - const AbstractCharacteristic *ch = kart->getCharacteristic(); - kart->setSquash(ch->getSwatterSquashDuration(), - ch->getSwatterSquashSlowdown()); + const KartProperties *kp = kart->getKartProperties(); + kart->setSquash(kp->getSwatterSquashDuration(), + kp->getSwatterSquashSlowdown()); } continue; @@ -398,9 +397,9 @@ void Physics::KartKartCollision(AbstractKart *kart_a, // Add a scaling factor depending on the mass (avoid div by zero). // The value of f_right is applied to the right kart, and f_left // to the left kart. f_left = 1 / f_right - float f_right = right_kart->getCharacteristic()->getMass() > 0 - ? left_kart->getCharacteristic()->getMass() - / right_kart->getCharacteristic()->getMass() + float f_right = right_kart->getKartProperties()->getMass() > 0 + ? left_kart->getKartProperties()->getMass() + / right_kart->getKartProperties()->getMass() : 1.5f; // Add a scaling factor depending on speed (avoid div by 0) f_right *= right_kart->getSpeed() > 0 diff --git a/src/scriptengine/script_kart.cpp b/src/scriptengine/script_kart.cpp index 99142b2e0..51b2beecb 100644 --- a/src/scriptengine/script_kart.cpp +++ b/src/scriptengine/script_kart.cpp @@ -18,7 +18,6 @@ #include "script_kart.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/kart.hpp" #include "modes/world.hpp" #include "scriptvec3.hpp" @@ -123,7 +122,7 @@ namespace Scripting float getMaxSpeed(int idKart) { AbstractKart* kart = World::getWorld()->getKart(idKart); - return kart->getCharacteristic()->getEngineMaxSpeed(); + return kart->getKartProperties()->getEngineMaxSpeed(); } /** @}*/ diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index db2bfe577..476d97d92 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -38,7 +38,6 @@ using namespace irr; #include "items/attachment.hpp" #include "items/attachment_manager.hpp" #include "items/powerup_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" @@ -413,7 +412,7 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart, int gauge_height = (int)(GAUGEWIDTH*min_ratio); float state = (float)(kart->getEnergy()) - / kart->getCharacteristic()->getNitroMax(); + / kart->getKartProperties()->getNitroMax(); if (state < 0.0f) state = 0.0f; else if (state > 1.0f) state = 1.0f; @@ -436,7 +435,7 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart, if (race_manager->getCoinTarget() > 0) { float coin_target = (float)race_manager->getCoinTarget() - / kart->getCharacteristic()->getNitroMax(); + / kart->getKartProperties()->getNitroMax(); video::S3DVertex vertices[5]; unsigned int count=2; diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index 4ca9d9295..db5728899 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -36,7 +36,6 @@ #include "items/attachment.hpp" #include "items/attachment_manager.hpp" #include "items/powerup_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" @@ -559,7 +558,7 @@ void RaceGUIOverworld::drawEnergyMeter(int x, int y, const AbstractKart *kart, const core::vector2df &scaling) { float state = (float)(kart->getEnergy()) - / kart->getCharacteristic()->getNitroMax(); + / kart->getKartProperties()->getNitroMax(); if (state < 0.0f) state = 0.0f; else if (state > 1.0f) state = 1.0f; @@ -580,7 +579,7 @@ void RaceGUIOverworld::drawEnergyMeter(int x, int y, const AbstractKart *kart, if (race_manager->getCoinTarget() > 0) { float coin_target = (float)race_manager->getCoinTarget() - / kart->getCharacteristic()->getNitroMax(); + / kart->getKartProperties()->getNitroMax(); const int EMPTY_TOP_PIXELS = 4; const int EMPTY_BOTTOM_PIXELS = 3; diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index cd972eca7..8bfe74232 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -44,7 +44,6 @@ #include "io/xml_node.hpp" #include "items/item.hpp" #include "items/item_manager.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" #include "modes/linear_world.hpp" @@ -2343,7 +2342,7 @@ bool Track::findGround(AbstractKart *kart) // length of the suspension with the weight of the kart resting on // it). On the other hand this initial bouncing looks nice imho // - so I'll leave it in for now. - float offset = kart->getCharacteristic()->getSuspensionRest(); + float offset = kart->getKartProperties()->getSuspensionRest(); t.setOrigin(hit_point+Vec3(0, offset, 0) ); kart->getBody()->setCenterOfMassTransform(t); kart->setTrans(t); diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index f771272b0..9c5c0cf9d 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -25,8 +25,8 @@ #include "graphics/shaders.hpp" #include "items/powerup_manager.hpp" #include "items/attachment.hpp" -#include "karts/abstract_characteristic.hpp" #include "karts/abstract_kart.hpp" +#include "karts/kart_properties.hpp" #include "karts/controller/controller.hpp" #include "modes/world.hpp" #include "physics/irr_debug_drawer.hpp" @@ -137,14 +137,14 @@ void addAttachment(Attachment::AttachmentType type) if (type == Attachment::ATTACH_ANVIL) { kart->getAttachment() - ->set(type, kart->getCharacteristic()->getAnvilDuration()); - kart->adjustSpeed(kart->getCharacteristic()->getAnvilSpeedFactor()); + ->set(type, kart->getKartProperties()->getAnvilDuration()); + kart->adjustSpeed(kart->getKartProperties()->getAnvilSpeedFactor()); kart->updateWeight(); } else if (type == Attachment::ATTACH_PARACHUTE) { kart->getAttachment() - ->set(type, kart->getCharacteristic()->getParachuteDuration()); + ->set(type, kart->getKartProperties()->getParachuteDuration()); } else if (type == Attachment::ATTACH_BOMB) { From ba3bc326ebd7307e100362e51162cc0f520ce2f4 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Sun, 29 Nov 2015 20:02:36 +0100 Subject: [PATCH 45/55] Minor refinements --- data/kart_characteristics.xml | 6 +++--- src/graphics/camera.cpp | 4 ++-- src/karts/kart_properties.cpp | 6 +----- src/karts/kart_properties.hpp | 2 +- tools/update_characteristics.py | 1 - 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index 0a71d47af..f804cf6d5 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -233,12 +233,12 @@ fade-out-time="1.0" /> diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 759c49943..d56096cf5 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -379,8 +379,8 @@ void Camera::smoothMoveCamera(float dt) core::vector3df current_position = m_camera->getPosition(); // Smoothly interpolate towards the position and target const KartProperties *kp = m_kart->getKartProperties(); - float max_increase_with_zipper = kp->getZipperMaxSpeedIncrease(); - float max_speed_without_zipper = kp->getEngineMaxSpeed(); + float max_increase_with_zipper = kp->getZipperMaxSpeedIncrease(); + float max_speed_without_zipper = kp->getEngineMaxSpeed(); float current_speed = m_kart->getSpeed(); const Skidding *ks = m_kart->getSkidding(); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index ccf7c2b44..55a36a297 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -89,7 +89,6 @@ KartProperties::KartProperties(const std::string &filename) m_color = video::SColor(255, 0, 0, 0); m_shape = 32; // close enough to a circle. m_engine_sfx_type = "engine_small"; - m_kart_model = NULL; m_nitro_min_consumption = 0.53f; // The default constructor for stk_config uses filename="" if (filename != "") @@ -107,7 +106,6 @@ KartProperties::KartProperties(const std::string &filename) /** Destructor, dereferences the kart model. */ KartProperties::~KartProperties() { - delete m_kart_model; } // ~KartProperties //----------------------------------------------------------------------------- @@ -187,7 +185,7 @@ void KartProperties::load(const std::string &filename, const std::string &node) // m_kart_model must be initialised after assigning the default // values from stk_config (otherwise all kart_properties will // share the same KartModel - m_kart_model = new KartModel(/*is_master*/true); + m_kart_model.reset(new KartModel(/*is_master*/true)); m_root = StringUtils::getPath(filename)+"/"; m_ident = StringUtils::getBasename(StringUtils::getPath(filename)); @@ -204,7 +202,6 @@ void KartProperties::load(const std::string &filename, const std::string &node) msg << "Couldn't load kart properties '" << filename << "': no kart node."; - delete m_kart_model; throw std::runtime_error(msg.str()); } getAllData(root); @@ -262,7 +259,6 @@ void KartProperties::load(const std::string &filename, const std::string &node) const bool success = m_kart_model->loadModels(*this); if (!success) { - delete m_kart_model; file_manager->popTextureSearchPath(); file_manager->popModelSearchPath(); throw std::runtime_error("Cannot load kart models"); diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index 72b8a5c7c..b8f81438a 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -80,7 +80,7 @@ private: /** The kart model and wheels. It is mutable since the wheels of the * KartModel can rotate and turn, and animations are played, but otherwise * the kart_properties object is const. */ - mutable KartModel *m_kart_model; + mutable std::shared_ptr m_kart_model; /** List of all groups the kart belongs to. */ std::vector m_groups; diff --git a/tools/update_characteristics.py b/tools/update_characteristics.py index 6815623e5..5c09adafe 100755 --- a/tools/update_characteristics.py +++ b/tools/update_characteristics.py @@ -34,7 +34,6 @@ def main(): print("Please run this script in the root directory of the project.") exit(1) for operation, function in functions.items(): - # + " 2> /dev/null" result = subprocess.Popen("tools/create_kart_properties.py " + operation, shell = True, stdout = subprocess.PIPE).stdout.read().decode('UTF-8') From dbecbc384098df614fd663406254be1e7df93d1d Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 2 Dec 2015 19:40:28 +0100 Subject: [PATCH 46/55] Assign KartProperties to a variable instead of fetching it every time --- src/graphics/slip_stream.cpp | 14 ++-- src/guiengine/widgets/kart_stats_widget.cpp | 3 + src/items/attachment.cpp | 22 +++--- src/items/powerup.cpp | 22 +++--- src/items/rubber_band.cpp | 10 ++- src/karts/controller/skidding_ai.cpp | 14 ++-- src/karts/kart.cpp | 2 +- src/karts/skidding.cpp | 81 +++++++++++---------- 8 files changed, 90 insertions(+), 78 deletions(-) diff --git a/src/graphics/slip_stream.cpp b/src/graphics/slip_stream.cpp index 8ed2c2a31..0b59f7407 100644 --- a/src/graphics/slip_stream.cpp +++ b/src/graphics/slip_stream.cpp @@ -361,6 +361,8 @@ void SlipStream::setDebugColor(const video::SColor &color) */ void SlipStream::update(float dt) { + const KartProperties *kp = m_kart->getKartProperties(); + // Low level AIs should not do any slipstreaming. if(m_kart->getController()->disableSlipstreamBonus()) return; @@ -387,7 +389,7 @@ void SlipStream::update(float dt) // not moving. This is useful for debugging the graphics of SS-ing. //#define DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING - if(m_kart->getSpeed() < m_kart->getKartProperties()->getSlipstreamMinSpeed()) + if(m_kart->getSpeed() < kp->getSlipstreamMinSpeed()) { setIntensity(0, NULL); m_slipstream_mode = SS_NONE; @@ -428,8 +430,7 @@ void SlipStream::update(float dt) // entirely sure if this makes sense, but it makes it easier to // give karts different slipstream properties. #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING - if(m_target_kart->getSpeed() < - m_kart->getKartProperties()->getSlipstreamMinSpeed()) + if (m_target_kart->getSpeed() < kp->getSlipstreamMinSpeed()) { if(UserConfigParams::m_slipstream_debug && m_kart->getController()->isPlayerController()) @@ -443,7 +444,7 @@ void SlipStream::update(float dt) // slipstream length+0.5*kart_length()+0.5*target_kart_length // away from the other kart Vec3 delta = m_kart->getXYZ() - m_target_kart->getXYZ(); - float l = m_kart->getKartProperties()->getSlipstreamLength() + float l = kp->getSlipstreamLength() + 0.5f*( m_target_kart->getKartLength() +m_kart->getKartLength() ); if(delta.length2_2d() > l*l) @@ -483,8 +484,7 @@ void SlipStream::update(float dt) { m_slipstream_mode = SS_USE; m_kart->handleZipper(); - m_slipstream_time = - m_kart->getKartProperties()->getSlipstreamCollectTime(); + m_slipstream_time = kp->getSlipstreamCollectTime(); return; } } @@ -505,7 +505,7 @@ void SlipStream::update(float dt) setIntensity(m_slipstream_time, m_target_kart); m_slipstream_mode = SS_COLLECT; - if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime()) + if (m_slipstream_time > kp->getSlipstreamCollectTime()) { setIntensity(1.0f, m_target_kart); } diff --git a/src/guiengine/widgets/kart_stats_widget.cpp b/src/guiengine/widgets/kart_stats_widget.cpp index bf80a7663..ab7400329 100644 --- a/src/guiengine/widgets/kart_stats_widget.cpp +++ b/src/guiengine/widgets/kart_stats_widget.cpp @@ -80,6 +80,9 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id, } // Scale the values so they look better + // The scaling factor and offset were found by trial and error. + // It should look nice and you should be able to see the difference between + // different masses or velocities. m_skills[SKILL_MASS]->setValue((int) ((props->getCombinedCharacteristic()->getMass() - 20) / 4)); m_skills[SKILL_MASS]->setLabel(_("WEIGHT")); diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index e8c8d3c94..d016cff26 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -225,6 +225,7 @@ void Attachment::clear() */ void Attachment::hitBanana(Item *item, int new_attachment) { + const KartProperties *kp = m_kart->getKartProperties(); const StateManager::ActivePlayer *const ap = m_kart->getController() ->getPlayer(); if(ap && ap->getConstProfile()==PlayerManager::getCurrentPlayer()) @@ -266,8 +267,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) // default time. This is necessary to avoid that a kart lands on the // same banana again once the explosion animation is finished, giving // the kart the same penalty twice. - float f = std::max(item->getDisableTime(), - m_kart->getKartProperties()->getExplosionDuration() + 2.0f); + float f = std::max(item->getDisableTime(), kp->getExplosionDuration() + 2.0f); item->setDisableTime(f); break; } @@ -295,8 +295,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) switch (new_attachment) { case 0: - set(ATTACH_PARACHUTE, m_kart->getKartProperties()-> - getParachuteDuration() + leftover_time); + set(ATTACH_PARACHUTE, kp->getParachuteDuration() + leftover_time); m_initial_speed = m_kart->getSpeed(); // if going very slowly or backwards, @@ -310,13 +309,12 @@ void Attachment::hitBanana(Item *item, int new_attachment) // sound -> playSfx ( SOUND_SHOOMF ) ; break ; case 2: - set(ATTACH_ANVIL, m_kart->getKartProperties()-> - getAnvilDuration() + leftover_time); + set(ATTACH_ANVIL, kp->getAnvilDuration() + leftover_time); // if ( m_kart == m_kart[0] ) // sound -> playSfx ( SOUND_SHOOMF ) ; // Reduce speed once (see description above), all other changes are // handled in Kart::updatePhysics - m_kart->adjustSpeed(m_kart->getKartProperties()->getAnvilSpeedFactor()); + m_kart->adjustSpeed(kp->getAnvilSpeedFactor()); m_kart->updateWeight(); break ; } // switch @@ -421,12 +419,14 @@ void Attachment::update(float dt) // This percentage is based on the ratio of // initial_speed / initial_max_speed - float f = m_initial_speed / m_kart->getKartProperties()->getParachuteMaxSpeed(); + const KartProperties *kp = m_kart->getKartProperties(); + + float f = m_initial_speed / kp->getParachuteMaxSpeed(); if (f > 1.0f) f = 1.0f; // cap fraction if (m_kart->getSpeed() <= m_initial_speed * - (m_kart->getKartProperties()->getParachuteLboundFraction() + - f * ( m_kart->getKartProperties()->getParachuteUboundFraction() - - m_kart->getKartProperties()->getParachuteLboundFraction()))) + (kp->getParachuteLboundFraction() + + f * (kp->getParachuteUboundFraction() + - kp->getParachuteLboundFraction()))) { m_time_left = -1; } diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index 2b21202d1..3b06e41c6 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -171,6 +171,8 @@ void Powerup::adjustSound() */ void Powerup::use() { + const KartProperties *kp = m_owner->getKartProperties(); + // The player gets an achievement point for using a powerup StateManager::ActivePlayer * player = m_owner->getController()->getPlayer(); if (m_type != PowerupManager::POWERUP_NOTHING && @@ -221,8 +223,7 @@ void Powerup::use() case PowerupManager::POWERUP_SWATTER: m_owner->getAttachment() - ->set(Attachment::ATTACH_SWATTER, - m_owner->getKartProperties()->getSwatterDuration()); + ->set(Attachment::ATTACH_SWATTER, kp->getSwatterDuration()); break; case PowerupManager::POWERUP_BUBBLEGUM: @@ -257,12 +258,12 @@ void Powerup::use() if (m_owner->getIdent() == "nolok") { m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD, - m_owner->getKartProperties()->getBubblegumShieldDuration()); + kp->getBubblegumShieldDuration()); } else { m_owner->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD, - m_owner->getKartProperties()->getBubblegumShieldDuration()); + kp->getBubblegumShieldDuration()); } } else // using a bubble gum while still having a shield @@ -270,12 +271,12 @@ void Powerup::use() if (m_owner->getIdent() == "nolok") { m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD, - m_owner->getKartProperties()->getBubblegumShieldDuration() + m_owner->getShieldTime()); + kp->getBubblegumShieldDuration() + m_owner->getShieldTime()); } else { m_owner->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD, - m_owner->getKartProperties()->getBubblegumShieldDuration() + m_owner->getShieldTime()); + kp->getBubblegumShieldDuration() + m_owner->getShieldTime()); } } @@ -299,9 +300,9 @@ void Powerup::use() if(kart->getPosition() == 1) { kart->getAttachment()->set(Attachment::ATTACH_ANVIL, - m_owner->getKartProperties()->getAnvilDuration()); + kp->getAnvilDuration()); kart->updateWeight(); - kart->adjustSpeed(m_owner->getKartProperties()->getAnvilSpeedFactor() * 0.5f); + kart->adjustSpeed(kp->getAnvilSpeedFactor() * 0.5f); // should we position the sound at the kart that is hit, // or the kart "throwing" the anvil? Ideally it should be both. @@ -336,9 +337,8 @@ void Powerup::use() } if(m_owner->getPosition() > kart->getPosition()) { - kart->getAttachment() - ->set(Attachment::ATTACH_PARACHUTE, - m_owner->getKartProperties()->getParachuteDurationOther()); + kart->getAttachment()->set(Attachment::ATTACH_PARACHUTE, + kp->getParachuteDurationOther()); if(kart->getController()->isPlayerController()) player_kart = kart; diff --git a/src/items/rubber_band.cpp b/src/items/rubber_band.cpp index b9441560d..22c0f9ab5 100644 --- a/src/items/rubber_band.cpp +++ b/src/items/rubber_band.cpp @@ -134,6 +134,8 @@ void RubberBand::updatePosition() */ void RubberBand::update(float dt) { + const KartProperties *kp = m_owner->getKartProperties(); + if(m_owner->isEliminated()) { // Rubber band snaps @@ -149,7 +151,7 @@ void RubberBand::update(float dt) // Check for rubber band snapping // ------------------------------ float l = (m_end_position-k).length2(); - float max_len = m_owner->getKartProperties()->getPlungerBandMaxLength(); + float max_len = kp->getPlungerBandMaxLength(); if(l>max_len*max_len) { // Rubber band snaps @@ -162,7 +164,7 @@ void RubberBand::update(float dt) // ---------------------------- if(m_attached_state!=RB_TO_PLUNGER) { - float force = m_owner->getKartProperties()->getPlungerBandForce(); + float force = kp->getPlungerBandForce(); Vec3 diff = m_end_position-k; // detach rubber band if kart gets very close to hit point @@ -178,10 +180,10 @@ void RubberBand::update(float dt) diff.normalize(); // diff can't be zero here m_owner->getBody()->applyCentralForce(diff*force); m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER, - m_owner->getKartProperties()->getPlungerBandSpeedIncrease(), + kp->getPlungerBandSpeedIncrease(), /*engine_force*/ 0.0f, /*duration*/0.1f, - m_owner->getKartProperties()->getPlungerBandFadeOutTime()); + kp->getPlungerBandFadeOutTime()); if(m_attached_state==RB_TO_KART) m_hit_kart->getBody()->applyCentralForce(diff*(-force)); } diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 5d59be034..ba24876b1 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -1030,6 +1030,8 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, std::vector *items_to_avoid, std::vector *items_to_collect) { + const KartProperties *kp = m_kart->getKartProperties(); + // Ignore items that are currently disabled if(item->getDisableTime()>0) return; @@ -1050,18 +1052,16 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, // Positive items: try to collect case Item::ITEM_NITRO_BIG: // Only collect nitro, if it can actually be stored. - if(m_kart->getEnergy() + - m_kart->getKartProperties()->getNitroBigContainer() - > m_kart->getKartProperties()->getNitroMax()) + if (m_kart->getEnergy() + kp->getNitroBigContainer() + > kp->getNitroMax()) return; // fall through: if we have enough space to store a big // container, we can also store a small container, and // finally fall through to the bonus box code. case Item::ITEM_NITRO_SMALL: avoid = false; // Only collect nitro, if it can actually be stored. - if (m_kart->getEnergy() + - m_kart->getKartProperties()->getNitroSmallContainer() - > m_kart->getKartProperties()->getNitroMax()) + if (m_kart->getEnergy() + kp->getNitroSmallContainer() + > kp->getNitroMax()) return; case Item::ITEM_BONUS_BOX: break; @@ -1091,7 +1091,7 @@ void SkiddingAI::evaluateItems(const Item *item, float kart_aim_angle, // be if the kart would need to turn sharper, therefore stops // skidding, and will get the bonus speed. bool high_speed = (m_kart->getCurrentMaxSpeed() > - m_kart->getKartProperties()->getEngineMaxSpeed() ) || + kp->getEngineMaxSpeed() ) || m_kart->getSkidding()->getSkidBonusReady(); float max_angle = high_speed ? m_ai_properties->m_max_item_angle_high_speed diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index c4c174b13..1008eb858 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2137,7 +2137,7 @@ void Kart::updatePhysics(float dt) // Only apply if near ground instead of purely based on speed avoiding // the "parachute on top" look. const Vec3 &v = m_body->getLinearVelocity(); - if(/*isNearGround() &&*/ v.getY() < - m_kart_properties->getSuspensionTravel() * 0.01f * 60) + if(/*isNearGround() &&*/ v.getY() < - m_kart_properties->getSuspensionTravel() * 60) { Vec3 v_clamped = v; // clamp the speed to 99% of the maxium falling speed. diff --git a/src/karts/skidding.cpp b/src/karts/skidding.cpp index 654449054..15aafaf25 100644 --- a/src/karts/skidding.cpp +++ b/src/karts/skidding.cpp @@ -47,7 +47,8 @@ Skidding::Skidding(Kart *kart) m_actual_curve->setVisible(false); #endif m_kart = kart; - m_skid_reduce_turn_delta = m_kart->getKartProperties()->getSkidReduceTurnMax() - m_kart->getKartProperties()->getSkidReduceTurnMin(); + m_skid_reduce_turn_delta = m_kart->getKartProperties()->getSkidReduceTurnMax() + - m_kart->getKartProperties()->getSkidReduceTurnMin(); reset(); } // Skidding @@ -94,13 +95,15 @@ void Skidding::reset() */ void Skidding::updateSteering(float steer, float dt) { + const KartProperties *kp = m_kart->getKartProperties(); + switch(m_skid_state) { case SKID_SHOW_GFX_LEFT: case SKID_SHOW_GFX_RIGHT: case SKID_NONE: m_real_steering = steer; - if (m_skid_time < m_kart->getKartProperties()->getSkidVisualTime() && m_skid_time > 0) + if (m_skid_time < kp->getSkidVisualTime() && m_skid_time > 0) { float f = m_visual_rotation - m_visual_rotation*dt/m_skid_time; // Floating point errors when m_skid_time is very close to 0 @@ -124,27 +127,27 @@ void Skidding::updateSteering(float steer, float dt) case SKID_ACCUMULATE_RIGHT: { float f = (1.0f+steer)*0.5f; // map [-1,1] --> [0, 1] - m_real_steering = m_kart->getKartProperties()->getSkidReduceTurnMin() + m_real_steering = kp->getSkidReduceTurnMin() + m_skid_reduce_turn_delta * f; - if(m_skid_time < m_kart->getKartProperties()->getSkidVisualTime()) - m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() + if(m_skid_time < kp->getSkidVisualTime()) + m_visual_rotation = kp->getSkidVisual() * m_real_steering * m_skid_time - / m_kart->getKartProperties()->getSkidVisualTime(); + / kp->getSkidVisualTime(); else - m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() * m_real_steering; + m_visual_rotation = kp->getSkidVisual() * m_real_steering; break; } case SKID_ACCUMULATE_LEFT: { float f = (-1.0f+steer)*0.5f; // map [-1,1] --> [-1, 0] - m_real_steering = -m_kart->getKartProperties()->getSkidReduceTurnMin() + m_real_steering = -kp->getSkidReduceTurnMin() + m_skid_reduce_turn_delta * f; - if(m_skid_time < m_kart->getKartProperties()->getSkidVisualTime()) - m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() + if(m_skid_time < kp->getSkidVisualTime()) + m_visual_rotation = kp->getSkidVisual() * m_real_steering * m_skid_time - / m_kart->getKartProperties()->getSkidVisualTime(); + / kp->getSkidVisualTime(); else - m_visual_rotation = m_kart->getKartProperties()->getSkidVisual() * m_real_steering; + m_visual_rotation = kp->getSkidVisual() * m_real_steering; break; } @@ -199,6 +202,8 @@ float Skidding::getSteeringWhenSkidding(float steering) const void Skidding::update(float dt, bool is_on_ground, float steering, KartControl::SkidControl skidding) { + const KartProperties *kp = m_kart->getKartProperties(); + // If a kart animation is shown, stop all skidding bonuses. if(m_kart->getKartAnimation()) { @@ -213,7 +218,7 @@ void Skidding::update(float dt, bool is_on_ground, #endif // No skidding backwards or while stopped - if(m_kart->getSpeed() < m_kart->getKartProperties()->getSkidMinSpeed() && + if(m_kart->getSpeed() < kp->getSkidMinSpeed() && m_skid_state != SKID_NONE && m_skid_state != SKID_BREAK) { m_skid_state = SKID_BREAK; @@ -225,15 +230,15 @@ void Skidding::update(float dt, bool is_on_ground, if (is_on_ground) { if ((fabs(steering) > 0.001f) && - m_kart->getSpeed() > m_kart->getKartProperties()->getSkidMinSpeed() && + m_kart->getSpeed() > kp->getSkidMinSpeed() && (skidding == KartControl::SC_LEFT || skidding == KartControl::SC_RIGHT)) { - m_skid_factor += m_kart->getKartProperties()->getSkidIncrease() - * dt / m_kart->getKartProperties()->getSkidTimeTillMax(); + m_skid_factor += kp->getSkidIncrease() + * dt / kp->getSkidTimeTillMax(); } else if (m_skid_factor > 1.0f) { - m_skid_factor *= m_kart->getKartProperties()->getSkidDecrease(); + m_skid_factor *= kp->getSkidDecrease(); } } else @@ -241,8 +246,8 @@ void Skidding::update(float dt, bool is_on_ground, m_skid_factor = 1.0f; // Lose any skid factor as soon as we fly } - if (m_skid_factor > m_kart->getKartProperties()->getSkidMax()) - m_skid_factor = m_kart->getKartProperties()->getSkidMax(); + if (m_skid_factor > kp->getSkidMax()) + m_skid_factor = kp->getSkidMax(); else if (m_skid_factor < 1.0f) m_skid_factor = 1.0f; @@ -291,7 +296,7 @@ void Skidding::update(float dt, bool is_on_ground, // Don't allow skidding while the kart is (apparently) // still in the air, or when the kart is too slow if (m_remaining_jump_time > 0 || - m_kart->getSpeed() < m_kart->getKartProperties()->getSkidMinSpeed()) + m_kart->getSpeed() < kp->getSkidMinSpeed()) break; m_skid_state = skidding==KartControl::SC_RIGHT @@ -303,14 +308,14 @@ void Skidding::update(float dt, bool is_on_ground, // Then use this speed to determine the impulse necessary to // reach this speed. float v = World::getWorld()->getTrack()->getGravity() - * 0.5f * m_kart->getKartProperties()->getSkidPhysicalJumpTime(); + * 0.5f * kp->getSkidPhysicalJumpTime(); btVector3 imp(0, v / m_kart->getBody()->getInvMass(),0); m_kart->getVehicle()->getRigidBody()->applyCentralImpulse(imp); // Some karts might use a graphical-only jump. Set it up: m_jump_speed = World::getWorld()->getTrack()->getGravity() - * 0.5f * m_kart->getKartProperties()->getSkidGraphicalJumpTime(); - m_remaining_jump_time = m_kart->getKartProperties()->getSkidGraphicalJumpTime(); + * 0.5f * kp->getSkidGraphicalJumpTime(); + m_remaining_jump_time = kp->getSkidGraphicalJumpTime(); #ifdef SKID_DEBUG #define SPEED 20.0f @@ -321,13 +326,13 @@ void Skidding::update(float dt, bool is_on_ground, m_predicted_curve->setVisible(true); m_predicted_curve->setPosition(m_kart->getXYZ()); m_predicted_curve->setHeading(m_kart->getHeading()); - float angle = m_kart->getKartProperties() + float angle = kp ->getMaxSteerAngle(m_kart->getSpeed()) * fabsf(getSteeringFraction()); - angle = m_kart->getKartProperties() + angle = kp ->getMaxSteerAngle(SPEED) * fabsf(getSteeringFraction()); - float r = m_kart->getKartProperties()->getWheelBase() + float r = kp->getWheelBase() / asin(angle)*1.0f; const int num_steps = 50; @@ -338,7 +343,7 @@ void Skidding::update(float dt, bool is_on_ground, { float real_x = m_skid_state==SKID_ACCUMULATE_LEFT ? -x : x; Vec3 xyz(real_x, 0.2f, sqrt(r*r-(r-x)*(r-x))*(1.0f+SPEED/150.0f) - *(1+(angle/m_kart->getKartProperties()->getMaxSteerAngle(SPEED)-0.6f)*0.1f)); + *(1+(angle/kp->getMaxSteerAngle(SPEED)-0.6f)*0.1f)); Vec3 xyz1=m_kart->getTrans()(xyz); Log::debug("Skidding", "predict %f %f %f speed %f angle %f", xyz1.getX(), xyz1.getY(), xyz1.getZ(), @@ -371,7 +376,7 @@ void Skidding::update(float dt, bool is_on_ground, Log::debug("Skidding", "actual %f %f %f turn %f speed %f angle %f", m_kart->getXYZ().getX(),m_kart->getXYZ().getY(),m_kart->getXYZ().getZ(), m_real_steering, m_kart->getSpeed(), - m_kart->getKartProperties()->getMaxSteerAngle(m_kart->getSpeed())); + kp->getMaxSteerAngle(m_kart->getSpeed())); #endif m_skid_time += dt; float bonus_time, bonus_speed, bonus_force; @@ -391,11 +396,11 @@ void Skidding::update(float dt, bool is_on_ground, m_skid_state = m_skid_state == SKID_ACCUMULATE_LEFT ? SKID_SHOW_GFX_LEFT : SKID_SHOW_GFX_RIGHT; - float t = std::min(m_skid_time, m_kart->getKartProperties()->getSkidVisualTime()); - t = std::min(t, m_kart->getKartProperties()->getSkidRevertVisualTime()); + float t = std::min(m_skid_time, kp->getSkidVisualTime()); + t = std::min(t, kp->getSkidRevertVisualTime()); float vso = getVisualSkidRotation(); - btVector3 rot(0, vso * m_kart->getKartProperties()->getSkidPostSkidRotateFactor(), 0); + btVector3 rot(0, vso * kp->getSkidPostSkidRotateFactor(), 0); m_kart->getVehicle()->setTimedRotation(t, rot); // skid_time is used to count backwards for the GFX m_skid_time = t; @@ -455,17 +460,19 @@ unsigned int Skidding::getSkidBonus(float *bonus_time, float *bonus_speed, float *bonus_force) const { + const KartProperties *kp = m_kart->getKartProperties(); + *bonus_time = 0; *bonus_speed = 0; *bonus_force = 0; - for (unsigned int i = 0; i < m_kart->getKartProperties()->getSkidBonusSpeed().size(); i++) + for (unsigned int i = 0; i < kp->getSkidBonusSpeed().size(); i++) { - if (m_skid_time <= m_kart->getKartProperties()->getSkidTimeTillBonus()[i]) + if (m_skid_time <= kp->getSkidTimeTillBonus()[i]) return i; - *bonus_speed = m_kart->getKartProperties()->getSkidBonusSpeed()[i]; - *bonus_time = m_kart->getKartProperties()->getSkidBonusTime()[i]; - *bonus_force = m_kart->getKartProperties()->getSkidBonusForce()[i]; + *bonus_speed = kp->getSkidBonusSpeed()[i]; + *bonus_time = kp->getSkidBonusTime()[i]; + *bonus_force = kp->getSkidBonusForce()[i]; } - return (unsigned int) m_kart->getKartProperties()->getSkidBonusSpeed().size(); + return (unsigned int) kp->getSkidBonusSpeed().size(); } // getSkidBonusForce From b3cb029087472ed0e0a413bc26f4603a623eb74a Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 2 Dec 2015 19:40:59 +0100 Subject: [PATCH 47/55] Remove kart-type specific turn settings --- data/kart_characteristics.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index f804cf6d5..811c69ae3 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -339,9 +339,6 @@ - @@ -357,9 +354,6 @@ fade-out-time="2.3" /> - @@ -373,9 +367,6 @@ fade-out-time="1.6" /> - From c5277edc54339180190af626fc9b986916e8de21 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Thu, 3 Dec 2015 02:15:58 +0100 Subject: [PATCH 48/55] Change suspension-travel that was changed in master meanwhile --- data/kart_characteristics.xml | 2 +- src/karts/kart.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/kart_characteristics.xml b/data/kart_characteristics.xml index 811c69ae3..e72f40f8f 100644 --- a/data/kart_characteristics.xml +++ b/data/kart_characteristics.xml @@ -34,7 +34,7 @@ http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\&p=25236&hilit=vehicle#p25236 for details. max-force: Maximum suspension force --> -