Move getter from characteristics to properties
This commit is contained in:
parent
6e36c223b9
commit
9fbe72b3c5
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@ stk-editor/
|
|||||||
.config/
|
.config/
|
||||||
supertuxkart-64
|
supertuxkart-64
|
||||||
make*.bat
|
make*.bat
|
||||||
|
__pycache__
|
||||||
|
|
||||||
data/editor
|
data/editor
|
||||||
data/karts
|
data/karts
|
||||||
|
@ -268,7 +268,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
|||||||
// same banana again once the explosion animation is finished, giving
|
// same banana again once the explosion animation is finished, giving
|
||||||
// the kart the same penalty twice.
|
// the kart the same penalty twice.
|
||||||
float f = std::max(item->getDisableTime(),
|
float f = std::max(item->getDisableTime(),
|
||||||
m_kart->getCharacteristic()->getExplosionDuration() + 2.0f);
|
m_kart->getKartProperties()->getExplosionDuration() + 2.0f);
|
||||||
item->setDisableTime(f);
|
item->setDisableTime(f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
|||||||
switch (new_attachment)
|
switch (new_attachment)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
set(ATTACH_PARACHUTE, m_kart->getCharacteristic()->
|
set(ATTACH_PARACHUTE, m_kart->getKartProperties()->
|
||||||
getParachuteDuration() + leftover_time);
|
getParachuteDuration() + leftover_time);
|
||||||
m_initial_speed = m_kart->getSpeed();
|
m_initial_speed = m_kart->getSpeed();
|
||||||
|
|
||||||
@ -311,13 +311,13 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
|||||||
// sound -> playSfx ( SOUND_SHOOMF ) ;
|
// sound -> playSfx ( SOUND_SHOOMF ) ;
|
||||||
break ;
|
break ;
|
||||||
case 2:
|
case 2:
|
||||||
set(ATTACH_ANVIL, m_kart->getCharacteristic()->
|
set(ATTACH_ANVIL, m_kart->getKartProperties()->
|
||||||
getAnvilDuration() + leftover_time);
|
getAnvilDuration() + leftover_time);
|
||||||
// if ( m_kart == m_kart[0] )
|
// if ( m_kart == m_kart[0] )
|
||||||
// sound -> playSfx ( SOUND_SHOOMF ) ;
|
// sound -> playSfx ( SOUND_SHOOMF ) ;
|
||||||
// Reduce speed once (see description above), all other changes are
|
// Reduce speed once (see description above), all other changes are
|
||||||
// handled in Kart::updatePhysics
|
// handled in Kart::updatePhysics
|
||||||
m_kart->adjustSpeed(m_kart->getCharacteristic()->getAnvilSpeedFactor());
|
m_kart->adjustSpeed(m_kart->getKartProperties()->getAnvilSpeedFactor());
|
||||||
m_kart->updateWeight();
|
m_kart->updateWeight();
|
||||||
break ;
|
break ;
|
||||||
} // switch
|
} // switch
|
||||||
@ -422,12 +422,12 @@ void Attachment::update(float dt)
|
|||||||
// This percentage is based on the ratio of
|
// This percentage is based on the ratio of
|
||||||
// initial_speed / initial_max_speed
|
// 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 (f > 1.0f) f = 1.0f; // cap fraction
|
||||||
if (m_kart->getSpeed() <= m_initial_speed *
|
if (m_kart->getSpeed() <= m_initial_speed *
|
||||||
(m_kart->getCharacteristic()->getParachuteLboundFraction() +
|
(m_kart->getKartProperties()->getParachuteLboundFraction() +
|
||||||
f * ( m_kart->getCharacteristic()->getParachuteUboundFraction()
|
f * ( m_kart->getKartProperties()->getParachuteUboundFraction()
|
||||||
- m_kart->getCharacteristic()->getParachuteLboundFraction())))
|
- m_kart->getKartProperties()->getParachuteLboundFraction())))
|
||||||
{
|
{
|
||||||
m_time_left = -1;
|
m_time_left = -1;
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ void Attachment::update(float dt)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
float Attachment::weightAdjust() const
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -177,7 +177,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
|
|||||||
}
|
}
|
||||||
else
|
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
|
// 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
|
// objects is simply removed from the scene graph, it might be auto-deleted
|
||||||
|
@ -223,7 +223,7 @@ void Powerup::use()
|
|||||||
case PowerupManager::POWERUP_SWATTER:
|
case PowerupManager::POWERUP_SWATTER:
|
||||||
m_owner->getAttachment()
|
m_owner->getAttachment()
|
||||||
->set(Attachment::ATTACH_SWATTER,
|
->set(Attachment::ATTACH_SWATTER,
|
||||||
m_owner->getCharacteristic()->getSwatterDuration());
|
m_owner->getKartProperties()->getSwatterDuration());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PowerupManager::POWERUP_BUBBLEGUM:
|
case PowerupManager::POWERUP_BUBBLEGUM:
|
||||||
@ -258,12 +258,12 @@ void Powerup::use()
|
|||||||
if (m_owner->getIdent() == "nolok")
|
if (m_owner->getIdent() == "nolok")
|
||||||
{
|
{
|
||||||
m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
||||||
m_owner->getCharacteristic()->getBubblegumShieldDuration());
|
m_owner->getKartProperties()->getBubblegumShieldDuration());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_owner->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD,
|
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
|
else // using a bubble gum while still having a shield
|
||||||
@ -271,12 +271,12 @@ void Powerup::use()
|
|||||||
if (m_owner->getIdent() == "nolok")
|
if (m_owner->getIdent() == "nolok")
|
||||||
{
|
{
|
||||||
m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
m_owner->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
||||||
m_owner->getCharacteristic()->getBubblegumShieldDuration() + m_owner->getShieldTime());
|
m_owner->getKartProperties()->getBubblegumShieldDuration() + m_owner->getShieldTime());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_owner->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD,
|
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)
|
if(kart->getPosition() == 1)
|
||||||
{
|
{
|
||||||
kart->getAttachment()->set(Attachment::ATTACH_ANVIL,
|
kart->getAttachment()->set(Attachment::ATTACH_ANVIL,
|
||||||
m_owner->getCharacteristic()->getAnvilDuration());
|
m_owner->getKartProperties()->getAnvilDuration());
|
||||||
kart->updateWeight();
|
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,
|
// should we position the sound at the kart that is hit,
|
||||||
// or the kart "throwing" the anvil? Ideally it should be both.
|
// or the kart "throwing" the anvil? Ideally it should be both.
|
||||||
@ -339,7 +339,7 @@ void Powerup::use()
|
|||||||
{
|
{
|
||||||
kart->getAttachment()
|
kart->getAttachment()
|
||||||
->set(Attachment::ATTACH_PARACHUTE,
|
->set(Attachment::ATTACH_PARACHUTE,
|
||||||
m_owner->getCharacteristic()->getParachuteDurationOther());
|
m_owner->getKartProperties()->getParachuteDurationOther());
|
||||||
|
|
||||||
if(kart->getController()->isPlayerController())
|
if(kart->getController()->isPlayerController())
|
||||||
player_kart = kart;
|
player_kart = kart;
|
||||||
|
@ -150,7 +150,7 @@ void RubberBand::update(float dt)
|
|||||||
// Check for rubber band snapping
|
// Check for rubber band snapping
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
float l = (m_end_position-k).length2();
|
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)
|
if(l>max_len*max_len)
|
||||||
{
|
{
|
||||||
// Rubber band snaps
|
// Rubber band snaps
|
||||||
@ -163,7 +163,7 @@ void RubberBand::update(float dt)
|
|||||||
// ----------------------------
|
// ----------------------------
|
||||||
if(m_attached_state!=RB_TO_PLUNGER)
|
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;
|
Vec3 diff = m_end_position-k;
|
||||||
|
|
||||||
// detach rubber band if kart gets very close to hit point
|
// 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
|
diff.normalize(); // diff can't be zero here
|
||||||
m_owner->getBody()->applyCentralForce(diff*force);
|
m_owner->getBody()->applyCentralForce(diff*force);
|
||||||
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
|
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
|
||||||
m_owner->getCharacteristic()->getPlungerBandSpeedIncrease(),
|
m_owner->getKartProperties()->getPlungerBandSpeedIncrease(),
|
||||||
/*engine_force*/ 0.0f,
|
/*engine_force*/ 0.0f,
|
||||||
/*duration*/0.1f,
|
/*duration*/0.1f,
|
||||||
m_owner->getCharacteristic()->getPlungerBandFadeOutTime());
|
m_owner->getKartProperties()->getPlungerBandFadeOutTime());
|
||||||
if(m_attached_state==RB_TO_KART)
|
if(m_attached_state==RB_TO_KART)
|
||||||
m_hit_kart->getBody()->applyCentralForce(diff*(-force));
|
m_hit_kart->getBody()->applyCentralForce(diff*(-force));
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ bool Swatter::updateAndTestFinished(float dt)
|
|||||||
(m_target->getXYZ()- Vec3(m_scene_node->getAbsolutePosition()))
|
(m_target->getXYZ()- Vec3(m_scene_node->getAbsolutePosition()))
|
||||||
.length2();
|
.length2();
|
||||||
float min_dist2
|
float min_dist2
|
||||||
= m_kart->getCharacteristic()->getSwatterDistance();
|
= m_kart->getKartProperties()->getSwatterDistance();
|
||||||
if(dist_to_target2 < min_dist2)
|
if(dist_to_target2 < min_dist2)
|
||||||
{
|
{
|
||||||
// Start squashing
|
// Start squashing
|
||||||
@ -265,9 +265,9 @@ void Swatter::pointToTarget()
|
|||||||
*/
|
*/
|
||||||
void Swatter::squashThingsAround()
|
void Swatter::squashThingsAround()
|
||||||
{
|
{
|
||||||
const AbstractCharacteristic *ch = m_kart->getCharacteristic();
|
const KartProperties *kp = m_kart->getKartProperties();
|
||||||
// Square of the minimum distance
|
// Square of the minimum distance
|
||||||
float min_dist2 = ch->getSwatterDistance();
|
float min_dist2 = kp->getSwatterDistance();
|
||||||
const World* world = World::getWorld();
|
const World* world = World::getWorld();
|
||||||
|
|
||||||
// Get the node corresponding to the joint at the center of the swatter
|
// 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
|
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
|
//Handle achievement if the swatter is used by the current player
|
||||||
const StateManager::ActivePlayer *const ap = m_kart->getController()
|
const StateManager::ActivePlayer *const ap = m_kart->getController()
|
||||||
|
@ -53,7 +53,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
|
|||||||
// Please don't change the following tag. It will be automatically detected
|
// Please don't change the following tag. It will be automatically detected
|
||||||
// by the script and replace the contained content.
|
// by the script and replace the contained content.
|
||||||
// To update the code, use tools/update_characteristics.py
|
// To update the code, use tools/update_characteristics.py
|
||||||
/* <characteristics-start getProp1> */
|
/* <characteristics-start getType> */
|
||||||
case SUSPENSION_STIFFNESS:
|
case SUSPENSION_STIFFNESS:
|
||||||
return TYPE_FLOAT;
|
return TYPE_FLOAT;
|
||||||
case SUSPENSION_REST:
|
case SUSPENSION_REST:
|
||||||
@ -259,7 +259,7 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
|
|||||||
case SKID_ENABLED:
|
case SKID_ENABLED:
|
||||||
return TYPE_BOOL;
|
return TYPE_BOOL;
|
||||||
|
|
||||||
/* <characteristics-end getProp1> */
|
/* <characteristics-end getType> */
|
||||||
} // switch (type)
|
} // switch (type)
|
||||||
Log::fatal("AbstractCharacteristic::getType", "Unknown type");
|
Log::fatal("AbstractCharacteristic::getType", "Unknown type");
|
||||||
return TYPE_FLOAT;
|
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
|
// Please don't change the following tag. It will be automatically detected
|
||||||
// by the script and replace the contained content.
|
// by the script and replace the contained content.
|
||||||
// To update the code, use tools/update_characteristics.py
|
// To update the code, use tools/update_characteristics.py
|
||||||
/* <characteristics-start getProp2> */
|
/* <characteristics-start getName> */
|
||||||
case SUSPENSION_STIFFNESS:
|
case SUSPENSION_STIFFNESS:
|
||||||
return "SUSPENSION_STIFFNESS";
|
return "SUSPENSION_STIFFNESS";
|
||||||
case SUSPENSION_REST:
|
case SUSPENSION_REST:
|
||||||
@ -483,18 +483,17 @@ std::string AbstractCharacteristic::getName(CharacteristicType type)
|
|||||||
case SKID_ENABLED:
|
case SKID_ENABLED:
|
||||||
return "SKID_ENABLED";
|
return "SKID_ENABLED";
|
||||||
|
|
||||||
/* <characteristics-end getProp2> */
|
/* <characteristics-end getName> */
|
||||||
} // switch (type)
|
} // switch (type)
|
||||||
Log::error("AbstractCharacteristic::getName", "Unknown type");
|
Log::error("AbstractCharacteristic::getName", "Unknown type");
|
||||||
return "Unknown type";
|
return "Unknown type";
|
||||||
} // getName
|
} // getName
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// Script-generated content generated by tools/create_kart_properties.py defs
|
||||||
// Script-generated content generated by tools/create_kart_properties.py getter
|
|
||||||
// Please don't change the following tag. It will be automatically detected
|
// Please don't change the following tag. It will be automatically detected
|
||||||
// by the script and replace the contained content.
|
// by the script and replace the contained content.
|
||||||
// To update the code, use tools/update_characteristics.py
|
// To update the code, use tools/update_characteristics.py
|
||||||
/* <characteristics-start getter> */
|
/* <characteristics-start acgetter> */
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
float AbstractCharacteristic::getSuspensionStiffness() const
|
float AbstractCharacteristic::getSuspensionStiffness() const
|
||||||
{
|
{
|
||||||
@ -1720,5 +1719,5 @@ bool AbstractCharacteristic::getSkidEnabled() const
|
|||||||
} // getSkidEnabled
|
} // getSkidEnabled
|
||||||
|
|
||||||
|
|
||||||
/* <characteristics-end getter> */
|
/* <characteristics-end acgetter> */
|
||||||
|
|
||||||
|
@ -245,11 +245,12 @@ public:
|
|||||||
static ValueType getType(CharacteristicType type);
|
static ValueType getType(CharacteristicType type);
|
||||||
static std::string getName(CharacteristicType type);
|
static std::string getName(CharacteristicType type);
|
||||||
|
|
||||||
|
|
||||||
// Script-generated content generated by tools/create_kart_properties.py defs
|
// Script-generated content generated by tools/create_kart_properties.py defs
|
||||||
// Please don't change the following tag. It will be automatically detected
|
// Please don't change the following tag. It will be automatically detected
|
||||||
// by the script and replace the contained content.
|
// by the script and replace the contained content.
|
||||||
// To update the code, use tools/update_characteristics.py
|
// To update the code, use tools/update_characteristics.py
|
||||||
/* <characteristics-start defs> */
|
/* <characteristics-start acdefs> */
|
||||||
|
|
||||||
float getSuspensionStiffness() const;
|
float getSuspensionStiffness() const;
|
||||||
float getSuspensionRest() const;
|
float getSuspensionRest() const;
|
||||||
@ -375,7 +376,7 @@ public:
|
|||||||
float getSkidReduceTurnMax() const;
|
float getSkidReduceTurnMax() const;
|
||||||
bool getSkidEnabled() const;
|
bool getSkidEnabled() const;
|
||||||
|
|
||||||
/* <characteristics-end defs> */
|
/* <characteristics-end acdefs> */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2651,14 +2651,14 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
|||||||
|
|
||||||
const float steer_frac = m_skidding->getSteeringFraction();
|
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)
|
if(speed_frac > 0.8f && fabsf(steer_frac)>0.5f)
|
||||||
{
|
{
|
||||||
// Use steering ^ 7, which means less effect at lower
|
// Use steering ^ 7, which means less effect at lower
|
||||||
// steering
|
// steering
|
||||||
const float f = m_skidding->getSteeringFraction();
|
const float f = m_skidding->getSteeringFraction();
|
||||||
const float f2 = f*f;
|
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
|
* f2*f2*f2*f
|
||||||
* speed_frac;
|
* speed_frac;
|
||||||
if(max_lean>0)
|
if(max_lean>0)
|
||||||
|
@ -321,6 +321,7 @@ void KartProperties::combineCharacteristics()
|
|||||||
m_combined_characteristic->addCharacteristic(characteristic);
|
m_combined_characteristic->addCharacteristic(characteristic);
|
||||||
|
|
||||||
m_combined_characteristic->addCharacteristic(m_characteristic.get());
|
m_combined_characteristic->addCharacteristic(m_characteristic.get());
|
||||||
|
m_cached_characteristic.reset(new CachedCharacteristic(m_combined_characteristic.get()));
|
||||||
} // combineCharacteristics
|
} // combineCharacteristics
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -448,15 +449,6 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
#endif
|
#endif
|
||||||
} // if sounds-node exist
|
} // 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)
|
if(m_kart_model)
|
||||||
m_kart_model->loadInfo(*root);
|
m_kart_model->loadInfo(*root);
|
||||||
} // getAllData
|
} // getAllData
|
||||||
@ -482,9 +474,6 @@ void KartProperties::checkAllSet(const std::string &filename)
|
|||||||
CHECK_NEG(m_restitution, "collision restitution" );
|
CHECK_NEG(m_restitution, "collision restitution" );
|
||||||
CHECK_NEG(m_physical_wheel_position, "collision physical-wheel-position");
|
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();
|
m_speed_weighted_object_properties.checkAllSet();
|
||||||
|
|
||||||
for(unsigned int i=0; i<RaceManager::DIFFICULTY_COUNT; i++)
|
for(unsigned int i=0; i<RaceManager::DIFFICULTY_COUNT; i++)
|
||||||
@ -535,3 +524,625 @@ float KartProperties::getAvgPower() const
|
|||||||
sum += gear_power_increase[i] * power;
|
sum += gear_power_increase[i] * power;
|
||||||
return sum / gear_power_increase.size();
|
return sum / gear_power_increase.size();
|
||||||
} // getAvgPower
|
} // getAvgPower
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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
|
||||||
|
/* <characteristics-start kpgetter> */
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
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<float> KartProperties::getGearSwitchRatio() const
|
||||||
|
{
|
||||||
|
return m_cached_characteristic->getGearSwitchRatio();
|
||||||
|
} // getGearSwitchRatio
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
std::vector<float> 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<float> KartProperties::getStartupTime() const
|
||||||
|
{
|
||||||
|
return m_cached_characteristic->getStartupTime();
|
||||||
|
} // getStartupTime
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
std::vector<float> 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<float> KartProperties::getSkidTimeTillBonus() const
|
||||||
|
{
|
||||||
|
return m_cached_characteristic->getSkidTimeTillBonus();
|
||||||
|
} // getSkidTimeTillBonus
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
std::vector<float> KartProperties::getSkidBonusSpeed() const
|
||||||
|
{
|
||||||
|
return m_cached_characteristic->getSkidBonusSpeed();
|
||||||
|
} // getSkidBonusSpeed
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
std::vector<float> KartProperties::getSkidBonusTime() const
|
||||||
|
{
|
||||||
|
return m_cached_characteristic->getSkidBonusTime();
|
||||||
|
} // getSkidBonusTime
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
std::vector<float> 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
|
||||||
|
|
||||||
|
|
||||||
|
/* <characteristics-end kpgetter> */
|
||||||
|
|
||||||
|
@ -123,6 +123,8 @@ private:
|
|||||||
std::shared_ptr<AbstractCharacteristic> m_characteristic;
|
std::shared_ptr<AbstractCharacteristic> m_characteristic;
|
||||||
/** The base characteristics combined with the characteristics of this kart. */
|
/** The base characteristics combined with the characteristics of this kart. */
|
||||||
std::shared_ptr<CombinedCharacteristic> m_combined_characteristic;
|
std::shared_ptr<CombinedCharacteristic> m_combined_characteristic;
|
||||||
|
/** The cached combined characteristics. */
|
||||||
|
std::unique_ptr<CachedCharacteristic> m_cached_characteristic;
|
||||||
|
|
||||||
// Physic properties
|
// Physic properties
|
||||||
// -----------------
|
// -----------------
|
||||||
@ -382,13 +384,6 @@ public:
|
|||||||
/** Returns the full path where the files for this kart are stored. */
|
/** Returns the full path where the files for this kart are stored. */
|
||||||
const std::string& getKartDir () const {return m_root; }
|
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
|
/** Returns minimum time during which nitro is consumed when pressing nitro
|
||||||
@ -411,6 +406,139 @@ public:
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
float getAvgPower() const;
|
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
|
||||||
|
/* <characteristics-start kpdefs> */
|
||||||
|
|
||||||
|
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<float> getGearSwitchRatio() const;
|
||||||
|
std::vector<float> 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<float> getStartupTime() const;
|
||||||
|
std::vector<float> 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<float> getSkidTimeTillBonus() const;
|
||||||
|
std::vector<float> getSkidBonusSpeed() const;
|
||||||
|
std::vector<float> getSkidBonusTime() const;
|
||||||
|
std::vector<float> getSkidBonusForce() const;
|
||||||
|
float getSkidPhysicalJumpTime() const;
|
||||||
|
float getSkidGraphicalJumpTime() const;
|
||||||
|
float getSkidPostSkidRotateFactor() const;
|
||||||
|
float getSkidReduceTurnMin() const;
|
||||||
|
float getSkidReduceTurnMax() const;
|
||||||
|
bool getSkidEnabled() const;
|
||||||
|
|
||||||
|
/* <characteristics-end kpdefs> */
|
||||||
}; // KartProperties
|
}; // KartProperties
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -140,60 +140,35 @@ def joinSubName(group, member, titleCase):
|
|||||||
else:
|
else:
|
||||||
return "_".join(words)
|
return "_".join(words)
|
||||||
|
|
||||||
def main():
|
# Functions to generate code
|
||||||
# Find out what to do
|
|
||||||
if len(sys.argv) == 1:
|
|
||||||
print("""Usage: ./create_kart_properties.py <operation>
|
|
||||||
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]
|
|
||||||
|
|
||||||
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
|
def createAcDefs(groups):
|
||||||
nameLengthTitle = 0
|
for g in groups:
|
||||||
nameLengthUnderscore = 0
|
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 g in groups:
|
||||||
for m in g.members:
|
for m in g.members:
|
||||||
l = len(joinSubName(g, m, True))
|
nameTitle = joinSubName(g, m, True)
|
||||||
if l > nameLengthTitle:
|
nameUnderscore = joinSubName(g, m, False)
|
||||||
nameLengthTitle = l
|
typeC = m.typeC
|
||||||
l = len(joinSubName(g, m, False))
|
result = "result"
|
||||||
if l > nameLengthUnderscore:
|
|
||||||
nameLengthUnderscore = l
|
|
||||||
|
|
||||||
# Print the results
|
print("""// ----------------------------------------------------------------------------
|
||||||
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("""// ----------------------------------------------------------------------------
|
|
||||||
{3} AbstractCharacteristic::get{1}() const
|
{3} AbstractCharacteristic::get{1}() const
|
||||||
{{
|
{{
|
||||||
{0} result;
|
{0} result;
|
||||||
@ -205,33 +180,105 @@ Operations:
|
|||||||
return {4};
|
return {4};
|
||||||
}} // get{1}
|
}} // get{1}
|
||||||
""".format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result))
|
""".format(m.typeC, nameTitle, nameUnderscore.upper(), typeC, result))
|
||||||
elif task == "getProp1":
|
|
||||||
for g in groups:
|
def createKpDefs(groups):
|
||||||
for m in g.members:
|
for g in groups:
|
||||||
nameTitle = joinSubName(g, m, True)
|
print()
|
||||||
nameUnderscore = joinSubName(g, m, False)
|
for m in g.members:
|
||||||
print(" case {0}:\n return TYPE_{1};".
|
nameTitle = joinSubName(g, m, True)
|
||||||
format(nameUnderscore.upper(), "_".join(toList(m.typeStr)).upper()))
|
nameUnderscore = joinSubName(g, m, False)
|
||||||
elif task == "getProp2":
|
typeC = m.typeC
|
||||||
for g in groups:
|
|
||||||
for m in g.members:
|
print(" {0} get{1}() const;".
|
||||||
nameTitle = joinSubName(g, m, True)
|
format(typeC, nameTitle, nameUnderscore))
|
||||||
nameUnderscore = joinSubName(g, m, False).upper()
|
|
||||||
print(" case {0}:\n return \"{0}\";".
|
def createKpGetter(groups):
|
||||||
format(nameUnderscore))
|
for g in groups:
|
||||||
elif task == "getXml":
|
for m in g.members:
|
||||||
for g in groups:
|
nameTitle = joinSubName(g, m, True)
|
||||||
print(" if (const XMLNode *sub_node = node->getNode(\"{0}\"))\n {{".
|
nameUnderscore = joinSubName(g, m, False)
|
||||||
format(g.baseName.lower()))
|
typeC = m.typeC
|
||||||
for m in g.members:
|
result = "result"
|
||||||
nameUnderscore = joinSubName(g, m, False)
|
|
||||||
nameMinus = "-".join(toList(m.name))
|
print("""// ----------------------------------------------------------------------------
|
||||||
print(""" sub_node->get(\"{0}\",
|
{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}]);""".
|
&m_values[{1}]);""".
|
||||||
format(nameMinus, nameUnderscore.upper()))
|
format(nameMinus, nameUnderscore.upper()))
|
||||||
print(" }\n")
|
print(" }\n")
|
||||||
else:
|
|
||||||
print("Unknown task")
|
# 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 <operation>
|
||||||
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -26,30 +26,24 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# Where and what should be replaced
|
from create_kart_properties import functions
|
||||||
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():
|
def main():
|
||||||
# Check, if it runs in the root directory
|
# Check, if it runs in the root directory
|
||||||
if not os.path.isfile("tools/update_characteristics.py"):
|
if not os.path.isfile("tools/update_characteristics.py"):
|
||||||
print("Please run this script in the root directory of the project.")
|
print("Please run this script in the root directory of the project.")
|
||||||
exit(1)
|
exit(1)
|
||||||
for replacement in replacements:
|
for operation, function in functions.items():
|
||||||
|
# + " 2> /dev/null"
|
||||||
result = subprocess.Popen("tools/create_kart_properties.py " +
|
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')
|
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()
|
text = f.read()
|
||||||
# Replace the text by using look behinds and look forwards
|
# Replace the text by using look behinds and look forwards
|
||||||
text = re.sub("(?<=/\* \<characteristics-start " + replacement[0] +
|
text = re.sub("(?<=/\* \<characteristics-start " + operation +
|
||||||
"\> \*/\\n)(.|\n)*(?=\\n\s*/\* <characteristics-end " + replacement[0] + "> \*/)", result, text)
|
"\> \*/\\n)(.|\n)*(?=\\n\s*/\* <characteristics-end " + operation + "> \*/)", result, text)
|
||||||
with open("src/" + replacement[1], "w") as f:
|
with open("src/" + function[2], "w") as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user