Fix some bugs

This commit is contained in:
Flakebi 2015-07-12 00:39:38 +02:00
parent db13a1fae6
commit 5bfb1a2c6b
9 changed files with 65 additions and 38 deletions

View File

@ -7,6 +7,8 @@
would result in 10 - 5 = 5.
-->
<characteristics>
<!-- The default values that can be modified by the difficulty, karts, etc.
The values here should also be the values of the maximum difficulty. -->
<characteristic name="base">
<!-- ********** Physics ********** -->
@ -61,7 +63,7 @@
0.5 * 0.25 + 0.5 * 0.15 = 0.2 ... which is overall the same
time we had previously. -->
<turn turn-radius="0:2.0 10:7.5 25:15 45:30"
time-full-steer=""
time-full-steer="0:0.17 0.5:0.17 0.5:0.28 1.0:0.28"
time-reset-steer="0.1" />
<!-- Speed and acceleration
@ -73,7 +75,7 @@
pressed, the harder the kart will brake.
max-speed-reverse-ratio is the percentage of max speed for reverse gear.
-->
<engine power="475" max-speed="21" brake-factor="11.0"
<engine power="875" max-speed="25" brake-factor="11.0"
brake-time-increase="6" max-speed-reverse-ratio="0.3" />
<!-- Simulated gears
@ -219,10 +221,12 @@
<!-- Swatter
duration: how long can the swatter be active.
distance: How close a kart or an item must be before it can be hit.
This is the square of the distance to accelerate the
compution.
squash-duration: How long a kart will remain squashed.
squash-slowdown: percentage of max speed that a kart is
restricted to. -->
<swatter duration="10" distance="3" squash-duration="5"
<swatter duration="10" distance="9" squash-duration="5"
squash-slowdown="0.5" />
<!-- Plunger and rubber band handling
@ -233,7 +237,7 @@
in your face is removed. -->
<plunger band-max-length="50" band-force="1500" band-duration="1"
band-speed-increase="7" band-fade-out-time="3"
in-face-time="4" />
in-face-time="4.5" />
<!-- ********** Miscellaneous ********** -->
@ -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. -->
<nitro engine-force="500" consumption="1" small-container="1" big-container="3"
<nitro engine-force="600" consumption="1" small-container="1" big-container="3"
max-speed-increase="5" duration="1" fade-out-time="2" max="20" />
<!-- Slipstream
@ -303,19 +307,17 @@
<!-- The different difficulties (like easy, medium, hard) -->
<difficulties>
<characteristic name="easy">
<engine power="450" max-speed="17" />
<engine power="*0.6" max-speed="*0.6" />
<plunger in-face-time="3" />
</characteristic>
<characteristic name="medium">
<engine power="*0.7" max-speed="*0.7" />
<plunger in-face-time="4" />
</characteristic>
<characteristic name="hard">
<engine power="500" max-speed="23" />
<plunger in-face-time="4.5" />
</characteristic>
<characteristic name="best">
<engine power="510" max-speed="25" />
<plunger in-face-time="4.5" />
<engine power="*0.85" max-speed="*0.85" />
</characteristic>
<characteristic name="best" />
</difficulties>
<!-- The different kart types, that can be specified in the kart.xml file -->
@ -324,7 +326,7 @@
<turn turn-radius="0:3.0 10:10.0 25:20.0 45:40.0"
time-full-steer ="0:0.15 0.5:0.15 0.5:0.25 1.0:0.25"
time-reset-steer="0.1" />
<engine power="250 300 350 400" max-speed="13 18 21 23.0" brake-factor="15.0"
<engine power="*0.45" max-speed="*0.8" brake-factor="0.8"
max-speed-reverse-ratio="0.5" />
<gear switch-ratio="0.20 0.55 1" power-increase="5 4 3" />
<mass value="195" />
@ -342,7 +344,7 @@
<turn turn-radius="0:4.5 10:16.0 25:30.0 45:60.0"
time-full-steer ="0:0.17 0.5:0.17 0.5:0.28 1.0:0.28"
time-reset-steer="0.1" />
<engine power="375 450 525 550" max-speed="14 19 22.0 25" />
<engine power="*0.6" max-speed="*0.9" brake-factor="*0.9" />
<gear switch-ratio="0.30 0.7 1.0" power-increase="2.2 2.2 2.5" />
<mass value="250" />
<startup time="0.3 0.5"
@ -353,10 +355,11 @@
<slipstream use-time="3.3" add-power="2.8" duration="0.9"
fade-out-time="1.6" />
</characteristic>
<characteristic name="heavy">
<turn turn-radius="0:4.0 10:18.5 25:43.0 45:72.5"
time-full-steer ="0:0.23 0.5:0.23 0.5:0.41 1.0:0.41"
time-reset-steer="0.1" />
<engine power="575 675 775 875" max-speed="15 20 23 25" brake-factor="10"
<engine power="*1" max-speed="*1" brake-factor="*1"
max-speed-reverse-ratio="0.65" />
<gear switch-ratio="0.45 0.70 1" power-increase="1.5 1.7 2.5" />
<mass value="350" />
@ -370,7 +373,6 @@
duration="0.7" fade-out-time="1.3" />
<slipstream length="8.5" use-time="4" add-power="2.7" min-speed="10.5"
max-speed-increase="8" duration="0.7" fade-out-time="1" />
<characteristic name="heavy">
</characteristic>
</kart-types>

View File

@ -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,

View File

@ -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);

View File

@ -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 AbstractCharacteristic*>::const_iterator it = m_childs.cbegin();
it != m_childs.cend(); it++)
(*it)->process(type, value, is_set);
}

View File

@ -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<float> 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

View File

@ -453,6 +453,9 @@ public:
{
return m_physical_wheel_position;
} // getPhysicalWheelPosition
// ------------------------------------------------------------------------
float getAvgPower() const;
}; // KartProperties
#endif

View File

@ -219,6 +219,8 @@ void KartPropertiesManager::loadCharacteristics(const XMLNode *root)
(*type)->get("name", &name);
m_kart_type_characteristics.emplace(name,
std::unique_ptr<AbstractCharacteristic>(new XmlCharacteristic(*type)));
XmlCharacteristic *c = (XmlCharacteristic*) &(*((--m_kart_type_characteristics.end())->second));
c->getMass();
}
// Load player difficulties
nodes.clear();

View File

@ -88,15 +88,13 @@ void XmlCharacteristic::process(CharacteristicType type, Value value, bool *is_s
{
const std::vector<std::string> 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<std::string>::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<std::string>::const_iterator it = processors.begin();
it != processors.end(); it++)
{

View File

@ -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);
}
}