Merge remote-tracking branch 'origin/master' into render_kart_driver_differently

This commit is contained in:
Benau 2016-06-30 11:02:40 +08:00
commit 4a2bac1cd5
12 changed files with 117 additions and 54 deletions

View File

@ -6,7 +6,7 @@ the game assets from Sourceforge using SVN.
`svn checkout https://svn.code.sf.net/p/supertuxkart/code/stk-assets stk-assets`
Place the `stk-assets` folder next to the source root `stk-code` folder.
See <http://supertuxkart.sourceforge.net/Source_control> for more information
See <https://supertuxkart.net/Source_control> for more information
## Building STK on Linux
@ -75,8 +75,8 @@ location, specify `CMAKE_INSTALL_PREFIX` when running cmake, e.g.:
## Building STK on OS X
See <http://supertuxkart.sourceforge.net/Building_and_packaging_on_OSX>
See <https://supertuxkart.net/Building_and_packaging_on_OSX>
## Building STK on Windows
See <http://supertuxkart.sourceforge.net/How_to_build_the_Windows_version>
See <https://supertuxkart.net/How_to_build_the_Windows_version>

View File

@ -3,9 +3,9 @@
SuperTuxKart is a free kart racing game. It focuses on fun and not on realistic kart physics. Instructions can be found on the in-game help page.
The SuperTuxKart homepage can be found at: <http://supertuxkart.sourceforge.net>
The SuperTuxKart homepage can be found at: <https://supertuxkart.net/>
The official SuperTuxKart forum is at <http://supertuxkart.sourceforge.net/forum>. If you need support, this would be the best place to start.
The official SuperTuxKart forum is at <http://forum.freegamedev.net/viewforum.php?f=16>. If you need support, this would be the best place to start.
Hope you enjoy the game.
@ -22,7 +22,7 @@ Hope you enjoy the game.
### Windows
1. Install VS 2013 (or later). The free express versions work fine.
2. Download and install a source package - either a released package or from our [git/svn repositories](http://supertuxkart.sourceforge.net/Source_control).
2. Download and install a source package - either a released package or from our [git/svn repositories](https://supertuxkart.net/Source_control).
3. Download the latest dependency package from [here](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart%20Dependencies/Windows/). Unzip it in the root directory, so that the dependencies directory is next to the src and data directories (if you are updating from a previous dependency package, you can delete the .dll files in the root directory, they are not needed anymore).
4. Download cmake and install it. Then start cmake-gui and select the STK root directory as 'Where is the source code', and a new directory in the root directory (next to src, data etc) as the build directory (for now I assume that this directory is called bld).
5. Click on configure. You will be asked to create the directory (yes), then for your VS version. Make sure you select the right version (be aware of the easy to confuse version numbers: VS 2013 = version 12). Click on configure, then generate. This will create the directory 'bld', and a VS solution in that directory.
@ -30,10 +30,12 @@ Hope you enjoy the game.
7. Right click on the supertuxkart project in the solution explorer, and select "Set as StartUp Project".
8. Select Build->Build Solution (or press F7) to compile.
See <https://supertuxkart.net/How_to_build_the_Windows_version> for more information.
Compilation with cygwin is not officially supported, but this has been done (check with the forum for details).
### Mac OS X
The latest information about compilation on Mac are on our wiki: <http://supertuxkart.sourceforge.net/Building_and_packaging_on_OSX>
The latest information about compilation on Mac are at our site: <https://supertuxkart.net/Building_and_packaging_on_OSX>
### UNIX
See [`INSTALL.md`](INSTALL.md) for details.

View File

@ -180,9 +180,9 @@ public:
* \throw out_of_range if there is no data for 'type'.
* \param type Type of kart (e.g. heavy, medium, ...).
*/
const KartProperties& getKartProperties(std::string type)
const KartProperties& getKartProperties(const std::string &type)
{
return *m_kart_properties.at(type);
return *m_kart_properties.at(type);
} // getKartProperties
}
; // STKConfig

View File

@ -18,36 +18,42 @@
#include "graphics/stars.hpp"
#include <cmath>
#include "graphics/irr_driver.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_model.hpp"
#include "utils/constants.hpp"
#include <ISceneNode.h>
#include <IBillboardSceneNode.h>
#include <cmath>
const int STAR_AMOUNT = 7;
const float RADIUS = 0.7f;
const float STAR_SIZE = 0.4f;
Stars::Stars(scene::ISceneNode* parentKart, core::vector3df center)
Stars::Stars(AbstractKart *kart)
{
m_parent_kart_node = parentKart;
m_parent_kart_node = kart->getNode();
m_enabled = false;
video::ITexture* texture = irr_driver->getTexture("starparticle.png");
Material* star_material =
material_manager->getMaterial("starparticle.png");
m_center = center;
m_center = core::vector3df(0.0f,
kart->getKartModel()->getModel()
->getBoundingBox().MaxEdge.Y,
0.0f );
for (int n=0; n<STAR_AMOUNT; n++)
{
scene::ISceneNode* billboard =
irr_driver->addBillboard(core::dimension2df(STAR_SIZE, STAR_SIZE),
texture, parentKart);
texture, kart->getNode());
#ifdef DEBUG
billboard->setName("star");
#endif

View File

@ -21,9 +21,12 @@
#include "utils/no_copy.hpp"
#include "vector3d.h"
#include <vector>
#include <vector3d.h>
class AbstractKart;
namespace irr
{
namespace scene { class ISceneNode; }
@ -54,7 +57,7 @@ private:
float m_remaining_time;
public:
Stars (scene::ISceneNode* parentKart, core::vector3df center);
Stars (AbstractKart *kart);
~Stars ();
void showFor(float time);
void reset();

View File

@ -18,10 +18,15 @@
#include "karts/combined_characteristic.hpp"
#include "io/file_manager.hpp"
#include "karts/xml_characteristic.hpp"
#include <assert.h>
void CombinedCharacteristic::addCharacteristic(
const AbstractCharacteristic *characteristic)
{
m_childs.push_back(characteristic);
m_children.push_back(characteristic);
} // addCharacteristic
// ----------------------------------------------------------------------------
@ -29,7 +34,59 @@ void CombinedCharacteristic::addCharacteristic(
void CombinedCharacteristic::process(CharacteristicType type, Value value,
bool *is_set) const
{
for (const AbstractCharacteristic *characteristic : m_childs)
for (const AbstractCharacteristic *characteristic : m_children)
characteristic->process(type, value, is_set);
} // process
// ============================================================================
void CombinedCharacteristic::unitTesting()
{
// We need to use really existing xml attributes, all characteristics
// were designed to work with those names.
std::string s1=
"<?xml version=\"1.0\"?>"
" <characteristic name=\"base\">"
" <suspension stiffness=\"4.5\" rest=\"-0.3\" travel=\"1+2\"/>"
" <stability roll-influence=\"1+2*3\" chassis-linear-damping=\"2*3+1\""
" chassis-angular-damping=\"0\" downward-impulse-factor=\"5\""
" track-connection-accel=\"2\" smooth-flying-impulse=\"250\" />"
" </characteristic>"
"</characteristics>";
XMLNode *xml1= file_manager->createXMLTreeFromString(s1);
XmlCharacteristic *c1 = new XmlCharacteristic(xml1);
delete xml1;
CombinedCharacteristic *cc = new CombinedCharacteristic();
cc->addCharacteristic(c1);
assert( cc->getSuspensionStiffness() == 4.5f );
assert( cc->getSuspensionRest() == -0.3f );
assert( cc->getSuspensionTravel() == 3.0f );
// Note: no operator precedence supported, so 1+2*3 = 9
assert( cc->getStabilityRollInfluence() == 9.0f );
assert( cc->getStabilityChassisLinearDamping() == 7.0f );
std::string s2=
"<?xml version=\"1.0\"?>"
" <characteristic name=\"base\">"
" <suspension stiffness=\"+1\" rest=\"-1\" travel=\"*2\"/>"
" <stability roll-influence=\"/3\" chassis-linear-damping=\"*1\"/>"
" </characteristic>"
"</characteristics>";
XMLNode *xml2= file_manager->createXMLTreeFromString(s2);
XmlCharacteristic *c2 = new XmlCharacteristic(xml2);
delete xml2;
cc->addCharacteristic(c2);
assert( cc->getSuspensionStiffness() == 5.5f );
assert( cc->getSuspensionRest() == -1.3f );
assert( cc->getSuspensionTravel() == 6.0f );
// Note: no operator precedence supported, so (1+2*3) / 3 = 3
assert( cc->getStabilityRollInfluence() == 3.0f );
assert( cc->getStabilityChassisLinearDamping() == 7.0f );
} // unitTesting

View File

@ -24,9 +24,11 @@
class CombinedCharacteristic : public AbstractCharacteristic
{
private:
std::vector<const AbstractCharacteristic*> m_childs;
std::vector<const AbstractCharacteristic*> m_children;
public:
static void unitTesting();
void addCharacteristic(const AbstractCharacteristic *characteristic);
virtual void process(CharacteristicType type, Value value, bool *is_set) const;

View File

@ -38,8 +38,6 @@
#include "graphics/stk_text_billboard.hpp"
#include "graphics/stars.hpp"
#include "guiengine/scalable_font.hpp"
#include "karts/abstract_characteristic.hpp"
#include "karts/cached_characteristic.hpp"
#include "karts/explosion_animation.hpp"
#include "karts/kart_gfx.hpp"
#include "karts/rescue_animation.hpp"
@ -181,27 +179,18 @@ void Kart::init(RaceManager::KartType type)
// In multiplayer mode, sounds are NOT positional
if (race_manager->getNumLocalPlayers() > 1)
{
float factor = 1.0f / race_manager->getNumberOfKarts();
// players have louder sounds than AIs
if (type == RaceManager::KT_PLAYER)
{
// players have louder sounds than AIs
const float factor = std::min(1.0f, race_manager->getNumLocalPlayers()/2.0f);
m_goo_sound->setVolume( 1.0f / factor );
m_skid_sound->setVolume( 1.0f / factor );
m_crash_sound->setVolume( 1.0f / factor );
m_boing_sound->setVolume( 1.0f / factor );
m_beep_sound->setVolume( 1.0f / factor );
m_nitro_sound->setVolume( 1.0f / factor );
}
else
{
m_goo_sound->setVolume( 1.0f / race_manager->getNumberOfKarts() );
m_skid_sound->setVolume( 1.0f / race_manager->getNumberOfKarts() );
m_crash_sound->setVolume( 1.0f / race_manager->getNumberOfKarts() );
m_beep_sound->setVolume( 1.0f / race_manager->getNumberOfKarts() );
m_boing_sound->setVolume( 1.0f / race_manager->getNumberOfKarts() );
m_nitro_sound->setVolume( 1.0f / race_manager->getNumberOfKarts() );
}
}
factor = std::min(1.0f, race_manager->getNumLocalPlayers()/2.0f);
m_goo_sound->setVolume(factor);
m_skid_sound->setVolume(factor);
m_crash_sound->setVolume(factor);
m_boing_sound->setVolume(factor);
m_beep_sound->setVolume(factor);
m_nitro_sound->setVolume(factor);
} // if getNumLocalPlayers > 1
if(!m_engine_sound)
{
@ -224,12 +213,7 @@ void Kart::init(RaceManager::KartType type)
m_kart_gfx = new KartGFX(this);
m_skidding = new Skidding(this);
// Create the stars effect
m_stars_effect =
new Stars(getNode(),
core::vector3df(0.0f,
getKartModel()->getModel()
->getBoundingBox().MaxEdge.Y,
0.0f) );
m_stars_effect = new Stars(this);
reset();
} // init

View File

@ -212,8 +212,9 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value,
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));
std::string s = processor.substr(pos, pos2);
parts.push_back(processor.substr(pos, pos2-pos));
operations.push_back(processor.substr(pos2, 1));
pos = pos2 + 1;
}
parts.push_back(processor.substr(pos));
@ -224,15 +225,15 @@ void XmlCharacteristic::processFloat(const std::string &processor, float *value,
// If nothing preceeds the first operator, insert x
if (parts[index].empty())
{
if (!*is_set)
// - is a special case: We don't take e.g. "-5" as relative, it
// describes a negative number. So
if (!*is_set && operations[index] == "-")
*value = 0;
else if (!*is_set)
{
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;
}

View File

@ -168,6 +168,7 @@
#include "items/attachment_manager.hpp"
#include "items/item_manager.hpp"
#include "items/projectile_manager.hpp"
#include "karts/combined_characteristic.hpp"
#include "karts/controller/ai_base_lap_controller.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp"
@ -1857,6 +1858,11 @@ void runUnitTests()
assert( isEasterMode(22, 3, 2016, 5));
assert(!isEasterMode(21, 3, 2016, 5));
UserConfigParams::m_easter_ear_mode = saved_easter_mode;
Log::info("UnitTest", " - Kart characteristics");
CombinedCharacteristic::unitTesting();
Log::info("UnitTest", "=====================");
Log::info("UnitTest", "Testing successful ");
Log::info("UnitTest", "=====================");

View File

@ -47,6 +47,8 @@ void NetworkString::unitTesting()
s.addUInt16(12345);
s.addFloat(1.2345f);
// Since this string was not received, we need to skip the type and token explicitly.
s.skip(5);
assert(s.getUInt16() == 12345);
float f = s.getFloat();
assert(f==1.2345f);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 151 KiB