1) Applied Jonan's patch to fix the layout for many files.

2) Moved STK specific extensions to bullet out of
   bullet src tree.
3) Started to move more files into separate subdirs.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@3027 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2009-01-22 12:02:40 +00:00
parent 115f15d0f2
commit 340fc18548
56 changed files with 709 additions and 758 deletions

View File

@ -139,11 +139,7 @@ supertuxkart_SOURCES = \
race_manager.hpp \
string_utils.cpp \
string_utils.hpp \
track_manager.cpp \
track_manager.hpp \
callback.hpp \
moving_physics.hpp \
moving_physics.cpp \
moving_texture.hpp \
moving_texture.cpp \
callback_manager.cpp \
@ -244,13 +240,6 @@ supertuxkart_SOURCES = \
gui/feature_unlocked.hpp \
gui/font.hpp \
gui/font.cpp \
physics/physics.cpp \
physics/physics.hpp \
physics/kart_motion_state.hpp \
robots/default_robot.cpp \
robots/default_robot.hpp \
robots/track_info.cpp \
robots/track_info.hpp \
modes/follow_the_leader.cpp \
modes/follow_the_leader.hpp \
modes/standard_race.cpp \
@ -263,15 +252,32 @@ supertuxkart_SOURCES = \
modes/linear_world.hpp \
modes/three_strikes_battle.cpp \
modes/three_strikes_battle.hpp \
replay_buffer_tpl.hpp \
replay_buffers.hpp \
replay_buffers.cpp \
replay_base.hpp \
replay_base.cpp \
replay_player.hpp \
replay_player.cpp \
replay_recorder.hpp \
replay_recorder.cpp
physics/btKart.cpp \
physics/btKart.hpp \
physics/btUprightConstraint.cpp \
physics/btUprightConstraint.hpp \
physics/moving_physics.hpp \
physics/moving_physics.hpp \
physics/moving_physics.cpp \
physics/moving_physics.cpp \
physics/physics.cpp \
physics/physics.hpp \
physics/kart_motion_state.hpp \
robots/default_robot.cpp \
robots/default_robot.hpp \
robots/track_info.cpp \
robots/track_info.hpp \
tracks/track_manager.cpp \
tracks/track_manager.hpp \
replay/replay_buffer_tpl.hpp \
replay/replay_buffers.hpp \
replay/replay_buffers.cpp \
replay/replay_base.hpp \
replay/replay_base.cpp \
replay/replay_player.hpp \
replay/replay_player.cpp \
replay/replay_recorder.hpp \
replay/replay_recorder.cpp
# This is a VERY ugly work-around for a compiler bug: if static_ssg s compiled with -O2
# (more particularly: with -fregmove, which is part of -O2), it will causes the kart

View File

@ -21,14 +21,14 @@
#include <stdexcept>
#include "audio/music_ogg.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "string_utils.hpp"
#include "track_manager.hpp"
#include "translation.hpp"
#include "user_config.hpp"
#include "track.hpp"
#include "audio/music_ogg.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "tracks/track_manager.hpp"
#if defined(WIN32) && !defined(__CYGWIN__)
# define snprintf _snprintf

View File

@ -199,8 +199,6 @@ libbulletdynamics_a_SOURCES = \
BulletDynamics/ConstraintSolver/btSolverBody.h \
BulletDynamics/ConstraintSolver/btSolverConstraint.h \
BulletDynamics/ConstraintSolver/btTypedConstraint.cpp \
BulletDynamics/ConstraintSolver/btUprightConstraint.h \
BulletDynamics/ConstraintSolver/btUprightConstraint.cpp \
BulletDynamics/ConstraintSolver/btTypedConstraint.h \
BulletDynamics/Dynamics/btContinuousDynamicsWorld.cpp \
BulletDynamics/Dynamics/btContinuousDynamicsWorld.h \
@ -212,8 +210,6 @@ libbulletdynamics_a_SOURCES = \
BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp \
BulletDynamics/Dynamics/btSimpleDynamicsWorld.h \
BulletDynamics/Dynamics/Bullet-C-API.cpp \
BulletDynamics/Vehicle/btKart.cpp \
BulletDynamics/Vehicle/btKart.h \
BulletDynamics/Vehicle/btRaycastVehicle.cpp \
BulletDynamics/Vehicle/btRaycastVehicle.h \
BulletDynamics/Vehicle/btVehicleRaycaster.h \

View File

@ -30,7 +30,6 @@ subject to the following restrictions:
#include "BulletDynamics/ConstraintSolver/btConeTwistConstraint.h"
#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
#include "BulletDynamics/ConstraintSolver/btSliderConstraint.h"
#include "BulletDynamics/ConstraintSolver/btUprightConstraint.h"
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
///Optional ODE quickstep constraint solver, redistributed under ZLib license
@ -39,7 +38,6 @@ subject to the following restrictions:
///Vehicle simulation, with wheel contact simulated by raycasts
#include "BulletDynamics/Vehicle/btRaycastVehicle.h"
#include "BulletDynamics/Vehicle/btKart.h"

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "callback_manager.hpp"
#include "moving_physics.hpp"
#include "physics/moving_physics.hpp"
CallbackManager *callback_manager=NULL;

View File

@ -17,13 +17,14 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef CALLBACK_MANAGER_H
#define CALLBACK_MANAGER_H
#ifndef CALLBACK_MANAGER_HPP
#define CALLBACK_MANAGER_HPP
#include <vector>
#include "btBulletDynamicsCommon.h"
#include "callback.hpp"
#include "moving_physics.hpp"
class MovingPhysics;
// It might actually be enough to have only two different values: track (which
// get deleted and loaded more than one), and everything else, which only

View File

@ -20,48 +20,16 @@
#include "translation.hpp"
#include "challenges/challenge.hpp"
#include "race_manager.hpp"
#include "track_manager.hpp"
#include "track.hpp"
#include "grand_prix_manager.hpp"
#include "karts/kart_properties_manager.hpp"
#include "karts/kart_properties.hpp"
#include "grand_prix_manager.hpp"
#include "tracks/track_manager.hpp"
#if defined(WIN32) && !defined(__CYGWIN__)
# define snprintf _snprintf
#endif
Challenge::Challenge(std::string id, std::string name) :
m_state(CH_INACTIVE), m_Id(id), m_Name(name)
{
} // Challenge
//-----------------------------------------------------------------------------
/** Loads the state for a challenge object (esp. m_state), and calls the
* virtual function loadState for additional information
*/
void Challenge::load(const lisp::Lisp* config)
{
const lisp::Lisp* subnode= config->getLisp(getId());
if(!subnode) return;
// See if the challenge is solved (it's activated later from the
// unlock_manager).
bool finished=false;
subnode->get("solved", finished);
m_state = finished ? CH_SOLVED : CH_INACTIVE;
if(!finished) loadState(subnode);
} // load
//-----------------------------------------------------------------------------
void Challenge::save(lisp::Writer* writer)
{
writer->beginList(getId());
writer->write("solved", isSolved());
if(!isSolved()) saveState(writer);
writer->endList(getId());
} // save
//-----------------------------------------------------------------------------
void Challenge::addUnlockTrackReward(std::string track_name)
{
@ -70,6 +38,7 @@ void Challenge::addUnlockTrackReward(std::string track_name)
feature.type = UNLOCK_TRACK;
m_feature.push_back(feature);
}
//-----------------------------------------------------------------------------
void Challenge::addUnlockModeReward(std::string internal_mode_name, std::string user_mode_name)
{
@ -79,6 +48,7 @@ void Challenge::addUnlockModeReward(std::string internal_mode_name, std::string
feature.user_name = user_mode_name;
m_feature.push_back(feature);
}
//-----------------------------------------------------------------------------
void Challenge::addUnlockGPReward(std::string gp_name)
{
@ -87,6 +57,7 @@ void Challenge::addUnlockGPReward(std::string gp_name)
feature.type = UNLOCK_GP;
m_feature.push_back(feature);
}
//-----------------------------------------------------------------------------
void Challenge::addUnlockDifficultyReward(std::string internal_name, std::string user_name)
{
@ -96,6 +67,7 @@ void Challenge::addUnlockDifficultyReward(std::string internal_name, std::string
feature.user_name = user_name;
m_feature.push_back(feature);
}
//-----------------------------------------------------------------------------
void Challenge::addUnlockKartReward(std::string internal_name, std::string user_name)
{
@ -105,19 +77,20 @@ void Challenge::addUnlockKartReward(std::string internal_name, std::string user_
feature.user_name = user_name;
m_feature.push_back(feature);
}
//-----------------------------------------------------------------------------
const std::string Challenge::getUnlockedMessage() const
{
std::string unlocked_message;
const unsigned int amount = (unsigned int)m_feature.size();
for(unsigned int n=0; n<amount; n++)
{
// add line break if we are showing multiple messages
if(n>0) unlocked_message+='\n';
char message[128];
// write message depending on feature type
switch(m_feature[n].type)
{
@ -125,7 +98,7 @@ const std::string Challenge::getUnlockedMessage() const
{ // {} avoids compiler warning
Track* track = track_manager->getTrack( m_feature[n].name );
snprintf(message, 127, _("New track '%s'\nnow available"), _(track->getName()) );
break;
break;
}
case UNLOCK_MODE:
snprintf(message, 127, _("New game mode\n'%s'\nnow available"), m_feature[n].user_name.c_str() );
@ -146,6 +119,32 @@ const std::string Challenge::getUnlockedMessage() const
} // switch
unlocked_message += message;
} // for n
return unlocked_message;
}
//-----------------------------------------------------------------------------
/** Loads the state for a challenge object (esp. m_state), and calls the
* virtual function loadState for additional information
*/
void Challenge::load(const lisp::Lisp* config)
{
const lisp::Lisp* subnode= config->getLisp(getId());
if(!subnode) return;
// See if the challenge is solved (it's activated later from the
// unlock_manager).
bool finished=false;
subnode->get("solved", finished);
m_state = finished ? CH_SOLVED : CH_INACTIVE;
if(!finished) loadState(subnode);
} // load
//-----------------------------------------------------------------------------
void Challenge::save(lisp::Writer* writer)
{
writer->beginList(getId());
writer->write("solved", isSolved());
if(!isSolved()) saveState(writer);
writer->endList(getId());
} // save

View File

@ -17,8 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_CHALLENGE_H
#define HEADER_CHALLENGE_H
#ifndef HEADER_CHALLENGE_HPP
#define HEADER_CHALLENGE_HPP
#include <string>
#include <vector>
@ -36,7 +36,7 @@ enum REWARD_TYPE
struct UnlockableFeature
{
std::string name; // itnernal name
std::string name; // internal name
std::string user_name; // not all types of feature have one
REWARD_TYPE type;
};
@ -44,6 +44,7 @@ struct UnlockableFeature
// A base class for all challenges
class Challenge
{
private:
enum {CH_INACTIVE, // challenge not yet possible
CH_ACTIVE, // challenge possible, but not yet solved
CH_SOLVED} m_state; // challenge was solved
@ -56,15 +57,17 @@ public:
Challenge(std::string id, std::string name);
Challenge() {m_Id=""; m_Name="";m_state=CH_INACTIVE;}
virtual ~Challenge() {};
const std::string& getId() const { return m_Id; }
const std::string& getName() const { return m_Name; }
void setName(const std::string& s) { m_Name = s; }
void setId(const std::string& s) { m_Id = s; }
void addUnlockTrackReward(std::string track_name);
void addUnlockModeReward(std::string internal_mode_name, std::string user_mode_name);
void addUnlockGPReward(std::string gp_name);
void addUnlockDifficultyReward(std::string internal_name, std::string user_name);
void addUnlockKartReward(std::string internal_name, std::string user_name);
const std::string
&getId() const { return m_Id; }
const std::string
&getName() const { return m_Name; }
void setName(const std::string& s) { m_Name = s; }
void setId(const std::string& s) { m_Id = s; }
void addUnlockTrackReward(std::string track_name);
void addUnlockModeReward(std::string internal_mode_name, std::string user_mode_name);
void addUnlockGPReward(std::string gp_name);
void addUnlockDifficultyReward(std::string internal_name, std::string user_name);
void addUnlockKartReward(std::string internal_name, std::string user_name);
const std::string getUnlockedMessage() const;
const std::vector<UnlockableFeature>&

View File

@ -24,17 +24,16 @@
#include "translation.hpp"
#include "grand_prix_data.hpp"
#include "grand_prix_manager.hpp"
#include "track_manager.hpp"
#include "karts/kart.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "modes/linear_world.hpp"
#include "tracks/track_manager.hpp"
#if defined(WIN32) && !defined(__CYGWIN__)
# define snprintf _snprintf
#endif
ChallengeData::ChallengeData(const std::string& filename)
{
m_filename = filename;
@ -72,7 +71,7 @@ ChallengeData::ChallengeData(const std::string& filename)
m_major = RaceManager::MAJOR_MODE_SINGLE;
else
error("major");
lisp->get("minor", mode);
if(mode=="timetrial")
m_minor = RaceManager::MINOR_MODE_TIME_TRIAL;
@ -91,9 +90,9 @@ ChallengeData::ChallengeData(const std::string& filename)
setChallengeDescription(s);
if(!lisp->get("karts", m_num_karts) ) error("karts");
// Position is optional except in GP and FTL
if(!lisp->get("position", m_position) &&
if(!lisp->get("position", m_position) &&
//RaceManager::getWorld()->areKartsOrdered() ) // FIXME - order and optional are not the same thing
(m_minor==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
(m_minor==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
m_major==RaceManager::MAJOR_MODE_GRAND_PRIX))
error("position");
lisp->get("difficulty", s);
@ -115,13 +114,13 @@ ChallengeData::ChallengeData(const std::string& filename)
if(!lisp->get("track", m_track_name )) error("track");
if(!lisp->get("laps", m_num_laps ) &&
m_minor!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
error("laps");
error("laps");
}
else // GP
{
if(!lisp->get("gp", m_gp_id )) error("gp");
}
getUnlocks(lisp, "unlock-track", UNLOCK_TRACK);
getUnlocks(lisp, "unlock-gp", UNLOCK_GP );
getUnlocks(lisp, "unlock-mode", UNLOCK_MODE );
@ -275,6 +274,7 @@ bool ChallengeData::raceFinished()
if(m_time>0.0f && kart->getFinishTime()>m_time) return false; // too slow
return true;
} // raceFinished
// ----------------------------------------------------------------------------
bool ChallengeData::grandPrixFinished()
{
@ -291,6 +291,6 @@ bool ChallengeData::grandPrixFinished()
const int rank = race_manager->getKartFinalGPRank(kart->getWorldKartId());
//printf("getting rank for %s : %i \n", kart->getName().c_str(), rank );
if( rank != 0 ) return false;
return true;
return true;
} // grandPrixFinished

View File

@ -17,8 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_CHALLENGE_DATA_H
#define HEADER_CHALLENGE_DATA_H
#ifndef HEADER_CHALLENGE_DATA_HPP
#define HEADER_CHALLENGE_DATA_HPP
#include <string>
#include <vector>
@ -27,7 +27,7 @@
#include "challenges/challenge.hpp"
#include "race_manager.hpp"
class ChallengeData : public Challenge
class ChallengeData : public Challenge
{
private:
RaceManager::MajorRaceModeType m_major;
@ -42,8 +42,8 @@ private:
int m_energy;
std::vector<std::string> m_depends_on;
std::vector<UnlockableFeature> m_unlock;
std::string m_filename;
void getUnlocks(const lisp::Lisp *lisp, const char* type, REWARD_TYPE reward);
void error(const char *id) const;
@ -55,4 +55,4 @@ public:
virtual bool grandPrixFinished();
}; // ChallengeData
#endif
#endif // HEADER_CHALLENGE_DATA_HPP

View File

@ -42,8 +42,6 @@
#include <plib/ul.h>
#include "file_manager.hpp"
#include "btBulletDynamicsCommon.h"
#include "moving_physics.hpp"
#include "moving_texture.hpp"
#include "translation.hpp"
#include "material_manager.hpp"
#include "string_utils.hpp"

View File

@ -17,10 +17,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_FLYABLE_H
#define HEADER_FLYABLE_H
#ifndef HEADER_FLYABLE_HPP
#define HEADER_FLYABLE_HPP
#include "moving_physics.hpp"
#include "terrain_info.hpp"
#include "audio/sfx_manager.hpp"
#include "items/powerup_manager.hpp"
@ -28,6 +27,7 @@
class FlyableInfo;
class Kart;
class MovingPhysics;
class Flyable : public Moveable, public TerrainInfo
{

View File

@ -25,7 +25,7 @@
#include "lisp/lisp.hpp"
#include "grand_prix_data.hpp"
#include "string_utils.hpp"
#include "track_manager.hpp"
#include "tracks/track_manager.hpp"
GrandPrixData::GrandPrixData(const std::string filename)
{

View File

@ -22,11 +22,11 @@
#include "widget_manager.hpp"
#include "menu_manager.hpp"
#include "race_manager.hpp"
#include "track_manager.hpp"
#include "material_manager.hpp"
#include "unlock_manager.hpp"
#include "translation.hpp"
#include "grand_prix_manager.hpp"
#include "tracks/track_manager.hpp"
enum WidgetTokens
{

View File

@ -20,12 +20,12 @@
#include "track_sel.hpp"
#include "widget_manager.hpp"
#include "race_manager.hpp"
#include "track_manager.hpp"
#include "track.hpp"
#include "menu_manager.hpp"
#include "user_config.hpp"
#include "translation.hpp"
#include "unlock_manager.hpp"
#include "tracks/track_manager.hpp"
#if defined(WIN32) && !defined(__CYGWIN__)
# define snprintf _snprintf

View File

@ -19,15 +19,16 @@
#include "widget.hpp"
#include <cmath>
#include <iostream>
//FIXME: this should be removed when the scrolling is cleaned
#include "user_config.hpp"
#include "constants.hpp"
#include "track_manager.hpp"
#include "material_manager.hpp"
#include "track.hpp"
#include <cmath>
#include <iostream>
#include "tracks/track_manager.hpp"
const int Widget::MAX_SCROLL = 1000000;

View File

@ -487,10 +487,6 @@
RelativePath="..\..\bullet\src\BulletDynamics\ConstraintSolver\btTypedConstraint.cpp"
>
</File>
<File
RelativePath="..\..\bullet\src\BulletDynamics\ConstraintSolver\btUprightConstraint.cpp"
>
</File>
</Filter>
<Filter
Name="Dynamics"
@ -519,10 +515,6 @@
<Filter
Name="Vehicle"
>
<File
RelativePath="..\..\bullet\src\BulletDynamics\Vehicle\btKart.cpp"
>
</File>
<File
RelativePath="..\..\bullet\src\BulletDynamics\Vehicle\btRaycastVehicle.cpp"
>
@ -1089,10 +1081,6 @@
RelativePath="..\..\bullet\src\BulletDynamics\ConstraintSolver\btTypedConstraint.h"
>
</File>
<File
RelativePath="..\..\bullet\src\BulletDynamics\ConstraintSolver\btUprightConstraint.h"
>
</File>
</Filter>
<Filter
Name="Dynamics"
@ -1121,10 +1109,6 @@
<Filter
Name="Vehicle"
>
<File
RelativePath="..\..\bullet\src\BulletDynamics\Vehicle\btKart.h"
>
</File>
<File
RelativePath="..\..\bullet\src\BulletDynamics\Vehicle\btRaycastVehicle.h"
>

View File

@ -735,10 +735,6 @@
RelativePath="../../../src\material_manager.cpp"
>
</File>
<File
RelativePath="../../../src\moving_physics.cpp"
>
</File>
<File
RelativePath="../../../src\moving_texture.cpp"
>
@ -747,22 +743,6 @@
RelativePath="../../../src\race_manager.cpp"
>
</File>
<File
RelativePath="../../../src\replay_base.cpp"
>
</File>
<File
RelativePath="../../../src\replay_buffers.cpp"
>
</File>
<File
RelativePath="../../../src\replay_player.cpp"
>
</File>
<File
RelativePath="../../../src\replay_recorder.cpp"
>
</File>
<File
RelativePath="../../../src\scene.cpp"
>
@ -795,10 +775,6 @@
RelativePath="../../../src\track.cpp"
>
</File>
<File
RelativePath="../../../src\track_manager.cpp"
>
</File>
<File
RelativePath="..\..\translation.cpp"
>
@ -1106,6 +1082,18 @@
<Filter
Name="physics"
>
<File
RelativePath="..\..\physics\btKart.cpp"
>
</File>
<File
RelativePath="..\..\physics\btUprightConstraint.cpp"
>
</File>
<File
RelativePath="..\..\physics\moving_physics.cpp"
>
</File>
<File
RelativePath="..\..\physics\physics.cpp"
>
@ -1199,6 +1187,34 @@
>
</File>
</Filter>
<Filter
Name="tracks"
>
<File
RelativePath="..\..\tracks\track_manager.cpp"
>
</File>
</Filter>
<Filter
Name="replay"
>
<File
RelativePath="..\..\replay\replay_base.cpp"
>
</File>
<File
RelativePath="..\..\replay\replay_buffers.cpp"
>
</File>
<File
RelativePath="..\..\replay\replay_player.cpp"
>
</File>
<File
RelativePath="..\..\replay\replay_recorder.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Headerdateien"
@ -1313,26 +1329,6 @@
RelativePath="../../../src\race_manager.hpp"
>
</File>
<File
RelativePath="../../../src\replay_base.hpp"
>
</File>
<File
RelativePath="../../../src\replay_buffer_tpl.hpp"
>
</File>
<File
RelativePath="../../../src\replay_buffers.hpp"
>
</File>
<File
RelativePath="../../../src\replay_player.hpp"
>
</File>
<File
RelativePath="../../../src\replay_recorder.hpp"
>
</File>
<File
RelativePath="../../../src\scene.hpp"
>
@ -1369,10 +1365,6 @@
RelativePath="../../../src\track.hpp"
>
</File>
<File
RelativePath="../../../src\track_manager.hpp"
>
</File>
<File
RelativePath="../../../src\translation.hpp"
>
@ -1780,6 +1772,14 @@
<Filter
Name="physics"
>
<File
RelativePath="..\..\physics\btKart.hpp"
>
</File>
<File
RelativePath="..\..\physics\btUprightConstraint.hpp"
>
</File>
<File
RelativePath="..\..\physics\kart_motion_state.hpp"
>
@ -1845,6 +1845,38 @@
>
</File>
</Filter>
<Filter
Name="tracks"
>
<File
RelativePath="..\..\tracks\track_manager.hpp"
>
</File>
</Filter>
<Filter
Name="replay"
>
<File
RelativePath="..\..\replay\replay_base.hpp"
>
</File>
<File
RelativePath="..\..\replay\replay_buffer_tpl.hpp"
>
</File>
<File
RelativePath="..\..\replay\replay_buffers.hpp"
>
</File>
<File
RelativePath="..\..\replay\replay_player.hpp"
>
</File>
<File
RelativePath="..\..\replay\replay_recorder.hpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Ressourcendateien"

View File

@ -27,6 +27,7 @@
#include "items/projectile_manager.hpp"
#include "karts/player_kart.hpp"
#include "modes/world.hpp"
#include "physics/moving_physics.hpp"
// -----------------------------------------------------------------------------
Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER)

View File

@ -51,6 +51,7 @@
#include "karts/kart_properties_manager.hpp"
#include "network/race_state.hpp"
#include "network/network_manager.hpp"
#include "physics/btUprightConstraint.hpp"
#include "physics/physics.hpp"
#include "utils/coord.hpp"
#include "utils/ssg_help.hpp"
@ -221,7 +222,7 @@ void Kart::createPhysics()
m_uprightConstraint->setErp(1.0f);
m_uprightConstraint->setLimitSoftness(1.0f);
m_uprightConstraint->setDamping(0.0f);
RaceManager::getWorld()->getPhysics()->addKart(this, m_vehicle);
RaceManager::getWorld()->getPhysics()->addKart(this);
//create the engine sound
if(m_engine_sound)
@ -316,7 +317,7 @@ void Kart::reset()
// physics world. Add it again.
if(m_eliminated || m_rescue)
{
RaceManager::getWorld()->getPhysics()->addKart(this, m_vehicle);
RaceManager::getWorld()->getPhysics()->addKart(this);
}
m_attachment.clear();
@ -968,7 +969,7 @@ void Kart::endRescue()
// let the mode decide where to put the kart
RaceManager::getWorld()->moveKartAfterRescue(this, m_body);
RaceManager::getWorld()->getPhysics()->addKart(this, m_vehicle);
RaceManager::getWorld()->getPhysics()->addKart(this);
} // endRescue
//-----------------------------------------------------------------------------

View File

@ -26,25 +26,27 @@
#include "btBulletDynamicsCommon.h"
#include "terrain_info.hpp"
#include "items/attachment.hpp"
#include "items/powerup.hpp"
#include "karts/moveable.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_control.hpp"
#include "items/attachment.hpp"
#include "items/powerup.hpp"
#include "karts/kart_model.hpp"
#include "physics/btKart.hpp"
class SkidMarks;
class Item;
class Smoke;
class Nitro;
class SFXBase;
class btUprightConstraint;
class Kart : public TerrainInfo, public Moveable
{
private:
btTransform m_reset_transform; // reset position
unsigned int m_world_kart_id; // index of kart in world
float m_skidding; /**< Accumulated skidding factor. */
float m_skidding; ///< Accumulated skidding factor.
protected:
Attachment m_attachment;
@ -59,63 +61,58 @@ protected:
* This reduction is accumulated in m_max_speed_reduction. */
float m_max_speed_reduction;
float m_power_reduction;
float m_max_gear_rpm; //maximum engine rpm's for the current gear
float m_max_gear_rpm; /**<Maximum engine rpm's for the current gear*/
float m_max_speed_reverse_ratio;
float m_zipper_time_left; // zipper time left
float m_bounce_back_time; // a short time after a collision acceleration
// is disabled to allow the karts to bounce back
float m_zipper_time_left; /**<Zipper time left. */
float m_bounce_back_time; /**<A short time after a collision acceleration
* is disabled to allow the karts to bounce back*/
// physics parameters, storing it saves time
btKart::btVehicleTuning *m_tuning;
btCompoundShape m_kart_chassis;
btVehicleRaycaster *m_vehicle_raycaster;
btKart *m_vehicle;
btUprightConstraint *m_uprightConstraint;
btKart::btVehicleTuning *m_tuning;
btCompoundShape m_kart_chassis;
btVehicleRaycaster *m_vehicle_raycaster;
btKart *m_vehicle;
btUprightConstraint *m_uprightConstraint;
private:
/** The amount of energy collected bu hitting coins. */
float m_collected_energy;
/** The shadow of the kart. */
ssgTransform *m_shadow;
/** The amount of energy collected by hitting coins. */
float m_collected_energy;
ssgTransform *m_shadow; /**<The shadow of the kart. */
/** If a kart is flying, the shadow is disabled (since it is
* stuck to the kart, i.e. the shadow would be flying, too). */
bool m_shadow_enabled;
/** Smoke from skidding. */
Smoke *m_smoke_system;
bool m_shadow_enabled;
Smoke *m_smoke_system; /**<Smoke from skidding. */
/** Fire when using a nitro. */
Nitro *m_nitro;
Nitro *m_nitro;
float m_wheel_rotation;
float m_wheel_rotation;
/** For each wheel it stores the suspension length after the karts are at
* the start position, i.e. the suspension will be somewhat compressed.
* The bullet suspensionRestLength is the value when the suspension is not
* at all compressed. */
float m_default_suspension_length[4];
float m_default_suspension_length[4];
/** The skidmarks object for this kart. */
SkidMarks* m_skidmarks;
SkidMarks *m_skidmarks;
float m_finish_time;
bool m_finished_race;
float m_finish_time;
bool m_finished_race;
/* When a kart has its view blocked by the plunger, this variable will be > 0
the number it contains is the time left before removing plunger */
float m_view_blocked_by_plunger;
float m_speed;
/** When a kart has its view blocked by the plunger, this variable will be
* > 0 the number it contains is the time left before removing plunger. */
float m_view_blocked_by_plunger;
float m_speed;
float m_current_gear_ratio;
bool m_rescue;
bool m_eliminated;
float m_current_gear_ratio;
bool m_rescue;
bool m_eliminated;
SFXBase *m_engine_sound;
SFXBase *m_beep_sound;
SFXBase *m_crash_sound;
SFXBase *m_skid_sound;
SFXBase *m_goo_sound;
float m_time_last_crash;
SFXBase *m_engine_sound;
SFXBase *m_beep_sound;
SFXBase *m_crash_sound;
SFXBase *m_skid_sound;
SFXBase *m_goo_sound;
float m_time_last_crash;
protected:
float m_rescue_pitch, m_rescue_roll;
@ -129,22 +126,45 @@ public:
unsigned int getWorldKartId() const { return m_world_kart_id; }
void setWorldKartId(unsigned int n) { m_world_kart_id=n; }
void loadData();
virtual void updateGraphics (const Vec3& off_xyz, const Vec3& off_hpr);
virtual void updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr);
const KartProperties*
getKartProperties () const { return m_kart_properties; }
void setKartProperties (const KartProperties *kp)
{ m_kart_properties=kp; }
void attach (attachmentType attachment_, float time)
{ m_attachment.set(attachment_, time); }
void setPowerup (PowerupType t, int n)
{ m_powerup.set(t, n); }
virtual void setPosition (int p)
{ m_race_position = p; }
Attachment *getAttachment () { return &m_attachment; }
void setAttachmentType (attachmentType t, float time_left=0.0f,
Kart*k=NULL)
{ m_attachment.set(t, time_left, k); }
getKartProperties() const { return m_kart_properties; }
// ------------------------------------------------------------------------
/** Sets the kart properties. */
void setKartProperties(const KartProperties *kp)
{
m_kart_properties=kp;
}
// ------------------------------------------------------------------------
/** Sets the attachment and time it stays attached. */
void attach(attachmentType attachment_, float time)
{
m_attachment.set(attachment_, time);
}
// ------------------------------------------------------------------------
/** Sets a new powerup. */
void setPowerup (PowerupType t, int n)
{
m_powerup.set(t, n);
}
// ------------------------------------------------------------------------
/** Sets the position in race this kart has (1<=p<=n). */
virtual void setPosition(int p)
{
m_race_position = p;
}
// ------------------------------------------------------------------------
Attachment *getAttachment()
{
return &m_attachment;
}
// ------------------------------------------------------------------------
void setAttachmentType(attachmentType t, float time_left=0.0f, Kart*k=NULL)
{
m_attachment.set(t, time_left, k);
}
// ------------------------------------------------------------------------
Powerup *getPowerup () { return &m_powerup; }
int getNumPowerup () const { return m_powerup.getNum();}
float getEnergy () const { return m_collected_energy;}

View File

@ -45,12 +45,20 @@ Moveable::~Moveable()
// FIXME LEAK: what about model? ssgDeRefDelete(m_model_transform)
} // ~Moveable
//-----------------------------------------------------------------------------
void Moveable::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
{
Vec3 xyz=getXYZ()+off_xyz;
Vec3 hpr=getHPR()+off_hpr;
sgCoord c=Coord(xyz, hpr).toSgCoord();
m_model_transform->setTransform(&c);
} // updateGraphics
//-----------------------------------------------------------------------------
// The reset position must be set before calling reset
void Moveable::reset()
{
m_material_hot = NULL;
m_normal_hot = NULL;
if(m_body)
{
m_body->setLinearVelocity(btVector3(0.0, 0.0, 0.0));
@ -62,9 +70,20 @@ void Moveable::reset()
} // reset
//-----------------------------------------------------------------------------
void Moveable::createBody(float mass, btTransform& trans,
void Moveable::update(float dt)
{
m_motion_state->getWorldTransform(m_transform);
m_velocityLC = getVelocity()*getTrans().getBasis();
m_hpr.setHPR(m_transform.getBasis());
updateGraphics(Vec3(0,0,0), Vec3(0,0,0));
m_first_time = false ;
} // update
//-----------------------------------------------------------------------------
void Moveable::createBody(float mass, btTransform& trans,
btCollisionShape *shape) {
btVector3 inertia;
shape->calculateLocalInertia(mass, inertia);
m_transform = trans;
@ -95,25 +114,3 @@ void Moveable::setTrans(const btTransform &t)
m_transform=t;
m_motion_state->setWorldTransform(t);
} // setTrans
//-----------------------------------------------------------------------------
void Moveable::update(float dt)
{
m_motion_state->getWorldTransform(m_transform);
m_velocityLC = getVelocity()*getTrans().getBasis();
m_hpr.setHPR(m_transform.getBasis());
updateGraphics(Vec3(0,0,0), Vec3(0,0,0));
m_first_time = false ;
} // update
//-----------------------------------------------------------------------------
void Moveable::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
{
Vec3 xyz=getXYZ()+off_xyz;
Vec3 hpr=getHPR()+off_hpr;
sgCoord c=Coord(xyz, hpr).toSgCoord();
m_model_transform->setTransform(&c);
} // updateGraphics

View File

@ -18,8 +18,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_MOVEABLE_H
#define HEADER_MOVEABLE_H
#ifndef HEADER_MOVEABLE_HPP
#define HEADER_MOVEABLE_HPP
#define _WINSOCKAPI_
#include <plib/ssg.h>
@ -36,50 +36,66 @@ class Material;
#define MAX_ITEMS_COLLECTED 20
class Moveable
class Moveable
{
private:
btVector3 m_velocityLC; /* velocity in kart coordinates */
btVector3 m_velocityLC; /**<Velocity in kart coordinates */
btTransform m_transform;
Vec3 m_hpr;
protected:
UserPointer m_user_pointer;
sgVec4 *m_normal_hot; /* plane on which HOT was computed */
Material *m_material_hot; /* Material at HOT */
ssgTransform *m_model_transform; // The transform where the model is under
ssgTransform *m_model_transform; /**<The transform the model is attached to. */
int m_first_time ;
btRigidBody *m_body;
KartMotionState *m_motion_state;
public:
Moveable ();
virtual ~Moveable();
ssgTransform* getModelTransform() {return m_model_transform; }
virtual const btVector3 &getVelocity() const {return m_body->getLinearVelocity();}
const btVector3 &getVelocityLC() const {return m_velocityLC; }
Moveable();
virtual ~Moveable();
ssgTransform *getModelTransform() {return m_model_transform; }
virtual const btVector3
&getVelocity() const {return m_body->getLinearVelocity();}
const btVector3
&getVelocityLC() const {return m_velocityLC; }
virtual void setVelocity(const btVector3& v) {m_body->setLinearVelocity(v); }
const Vec3& getXYZ () const {return (Vec3&)m_transform.getOrigin();}
const Vec3& getHPR () const {return m_hpr; }
const btQuaternion getRotation() const {return m_transform.getRotation(); }
void setXYZ (const Vec3& a) {m_transform.setOrigin(a);
m_motion_state->setWorldTransform(m_transform);}
void setRotation (const btQuaternion&a){m_transform.setRotation(a);
m_motion_state->setWorldTransform(m_transform);}
void setXYZRotation(const Vec3& xyz, const btQuaternion& a)
{m_transform.setRotation(a);
m_transform.setOrigin(xyz);
m_motion_state->setWorldTransform(m_transform);}
const sgVec4* getNormalHOT () const {return m_normal_hot; }
const Vec3& getXYZ() const {return (Vec3&)m_transform.getOrigin();}
const Vec3& getHPR() const {return m_hpr; }
const btQuaternion
getRotation() const {return m_transform.getRotation(); }
/** Sets the XYZ coordinates of the moveable. */
void setXYZ(const Vec3& a)
{
m_transform.setOrigin(a);
m_motion_state->setWorldTransform(m_transform);
}
// ------------------------------------------------------------------------
/** Sets the rotation of this moveable. */
void setRotation(const btQuaternion&a)
{
m_transform.setRotation(a);
m_motion_state->setWorldTransform(m_transform);
}
// ------------------------------------------------------------------------
/** Sets XYZ position and rotation of this moveable. */
void setXYZRotation(const Vec3& xyz, const btQuaternion& a)
{
m_transform.setRotation(a);
m_transform.setOrigin(xyz);
m_motion_state->setWorldTransform(m_transform);
}
// ------------------------------------------------------------------------
virtual void handleZipper () {};
virtual void updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr);
virtual void handleZipper () {};
virtual void reset ();
virtual void update (float dt) ;
btRigidBody* getBody () const {return m_body; }
virtual void reset();
virtual void update(float dt) ;
btRigidBody *getBody() const {return m_body; }
void createBody(float mass, btTransform& trans,
btCollisionShape *shape);
const btTransform& getTrans() const {return m_transform;}
void setTrans (const btTransform& t);
const btTransform
&getTrans() const {return m_transform;}
void setTrans(const btTransform& t);
}
; // class Moveable

View File

@ -33,11 +33,11 @@
#endif
#include "loader.hpp"
#include "moving_physics.hpp"
#include "moving_texture.hpp"
#include "material_manager.hpp"
#include "file_manager.hpp"
#include "material.hpp"
#include "physics/moving_physics.hpp"
Loader* loader = 0;

View File

@ -46,7 +46,7 @@
#include "user_config.hpp"
#include "unlock_manager.hpp"
#include "track_manager.hpp"
#include "tracks/track_manager.hpp"
#include "track.hpp"
#include "race_manager.hpp"
#include "file_manager.hpp"

View File

@ -25,7 +25,6 @@
#include "file_manager.hpp"
#include "track.hpp"
#include "track_manager.hpp"
#include "race_manager.hpp"
#include "user_config.hpp"
#include "callback_manager.hpp"
@ -45,10 +44,11 @@
#include "karts/auto_kart.hpp"
#include "karts/player_kart.hpp"
#include "karts/kart_properties_manager.hpp"
#include "modes/world.hpp"
#include "network/network_manager.hpp"
#include "network/race_state.hpp"
#include "robots/default_robot.hpp"
#include "modes/world.hpp"
#include "tracks/track_manager.hpp"
#if defined(WIN32) && !defined(__CYGWIN__)
# define snprintf _snprintf

View File

@ -27,8 +27,8 @@
#endif
#include "user_config.hpp"
#include "track_manager.hpp"
#include "karts/kart_properties_manager.hpp"
#include "tracks/track_manager.hpp"
// ----------------------------------------------------------------------------
/** Creates the connect message. It includes the id of the client (currently

View File

@ -9,18 +9,16 @@
* It is provided "as is" without express or implied warranty.
*/
#include "LinearMath/btVector3.h"
#include "btKart.h"
#include "physics/btKart.hpp"
#include "LinearMath/btMinMax.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btQuaternion.h"
#include "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h"
#include "BulletDynamics/ConstraintSolver/btJacobianEntry.h"
#include "LinearMath/btQuaternion.h"
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
#include "btVehicleRaycaster.h"
#include "btWheelInfo.h"
#include "LinearMath/btMinMax.h"
#include "BulletDynamics/Vehicle/btVehicleRaycaster.h"
#include "bulletDynamics/Vehicle/btWheelInfo.h"
#include "BulletDynamics/ConstraintSolver/btContactConstraint.h"
struct btWheelContactPoint;

View File

@ -8,13 +8,10 @@
* of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*/
#ifndef BT_KART_H
#define BT_KART_H
#ifndef HEADER_BT_KART_HPP
#define HEADER_BT_KART_HPP
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "btVehicleRaycaster.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "btRaycastVehicle.h"
#include "btBulletDynamicsCommon.h"
class btDynamicsWorld;
struct btWheelInfo;

View File

@ -15,11 +15,13 @@ subject to the following restrictions:
*/
#include "btUprightConstraint.h"
#include "physics/btUprightConstraint.hpp"
#include <new>
#include <stdio.h>
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "LinearMath/btTransformUtil.h"
#include <new>
#include "stdio.h"
//!
//!

View File

@ -14,12 +14,12 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef UPRIGHT_CONSTRAINT_H
#define UPRIGHT_CONSTRAINT_H
#ifndef HEADER_UPRIGHT_CONSTRAINT_HPP
#define HEADER_UPRIGHT_CONSTRAINT_HPP
#include "LinearMath/btVector3.h"
#include "btJacobianEntry.h"
#include "btTypedConstraint.h"
#include "BulletDynamics/ConstraintSolver/btJacobianEntry.h"
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
class btRigidBody;

View File

@ -16,53 +16,53 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_KART_MOTION_STATE_HPP
#define HEADER_KART_MOTION_STATE_HPP
#include "LinearMath/btMotionState.h"
/** This is a very simple motion state implementation for bullet, which does
* not support any transformation from physics transform to graphics
* transform.
*/
class KartMotionState : public btMotionState
{
private:
btTransform m_center_of_mass;
public:
/** Constructor.
* \param start_trans An optional start transformation. Defaults to
* identity.
*/
KartMotionState(const btTransform& start_trans = btTransform::getIdentity())
: m_center_of_mass(start_trans)
{
} // KartMotionState
// ------------------------------------------------------------------------
/** Returns the current world transform.
* \param center_of_mass The btTransform object that stores the current
* transformation.
*/
virtual void getWorldTransform(btTransform& center_of_mass) const
{
center_of_mass = m_center_of_mass;
} // getWorldTransform
// ------------------------------------------------------------------------
/** Synchronizes world transform from physics to user.
* Bullet calls the update of worldtransform for active objects.
* \param new_trans The new transformation for the object.
*/
virtual void setWorldTransform(const btTransform &new_trans)
{
m_center_of_mass = new_trans;
} // setWorldTransform
}; // KartMotionState
#endif // HEADER_KART_MOTION_STATE
#ifndef HEADER_KART_MOTION_STATE_HPP
#define HEADER_KART_MOTION_STATE_HPP
#include "LinearMath/btMotionState.h"
/** This is a very simple motion state implementation for bullet, which does
* not support any transformation from physics transform to graphics
* transform.
*/
class KartMotionState : public btMotionState
{
private:
btTransform m_center_of_mass;
public:
/** Constructor.
* \param start_trans An optional start transformation. Defaults to
* identity.
*/
KartMotionState(const btTransform& start_trans = btTransform::getIdentity())
: m_center_of_mass(start_trans)
{
} // KartMotionState
// ------------------------------------------------------------------------
/** Returns the current world transform.
* \param center_of_mass The btTransform object that stores the current
* transformation.
*/
virtual void getWorldTransform(btTransform& center_of_mass) const
{
center_of_mass = m_center_of_mass;
} // getWorldTransform
// ------------------------------------------------------------------------
/** Synchronizes world transform from physics to user.
* Bullet calls the update of worldtransform for active objects.
* \param new_trans The new transformation for the object.
*/
virtual void setWorldTransform(const btTransform &new_trans)
{
m_center_of_mass = new_trans;
} // setWorldTransform
}; // KartMotionState
#endif // HEADER_KART_MOTION_STATE_HPP

View File

@ -21,6 +21,7 @@
#include "user_config.hpp"
#include "network/race_state.hpp"
#include "physics/btUprightConstraint.hpp"
#include "utils/ssg_help.hpp"
#include "track.hpp"
@ -30,8 +31,8 @@
*/
Physics::Physics() : btSequentialImpulseConstraintSolver()
{
m_collision_conf = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collision_conf);
m_collision_conf = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collision_conf);
} // Physics
//-----------------------------------------------------------------------------
@ -41,17 +42,17 @@ Physics::Physics() : btSequentialImpulseConstraintSolver()
*/
void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
{
m_axis_sweep = new btAxisSweep3(world_min, world_max);
m_dynamics_world = new btDiscreteDynamicsWorld(m_dispatcher,
m_axis_sweep,
this,
m_collision_conf);
m_axis_sweep = new btAxisSweep3(world_min, world_max);
m_dynamics_world = new btDiscreteDynamicsWorld(m_dispatcher,
m_axis_sweep,
this,
m_collision_conf);
m_dynamics_world->setGravity(btVector3(0.0f, 0.0f,
-RaceManager::getTrack()->getGravity()));
#ifdef HAVE_GLUT
if(user_config->m_bullet_debug)
{
m_debug_drawer=new GLDebugDrawer();
m_debug_drawer = new GLDebugDrawer();
m_debug_drawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
m_dynamics_world->setDebugDrawer(m_debug_drawer);
}
@ -68,7 +69,6 @@ Physics::~Physics()
delete m_axis_sweep;
delete m_dispatcher;
delete m_collision_conf;
} // ~Physics
// -----------------------------------------------------------------------------
@ -77,10 +77,10 @@ Physics::~Physics()
* \param kart The kart to add.
* \param vehicle The raycast vehicle object.
*/
void Physics::addKart(const Kart *kart, btKart *vehicle)
void Physics::addKart(const Kart *kart)
{
m_dynamics_world->addRigidBody(kart->getBody());
m_dynamics_world->addVehicle(vehicle);
m_dynamics_world->addVehicle(kart->getVehicle());
m_dynamics_world->addConstraint(kart->getUprightConstraint());
} // addKart
@ -102,9 +102,9 @@ void Physics::removeKart(const Kart *kart)
*/
void Physics::update(float dt)
{
// Bullet can report the same collision more than once (up to 4
// Bullet can report the same collision more than once (up to 4
// contact points per collision. Additionally, more than one internal
// substep might be taken, resulting in potentially even more
// substep might be taken, resulting in potentially even more
// duplicates. To handle this, all collisions (i.e. pair of objects)
// are stored in a vector, but only one entry per collision pair
// of objects.
@ -154,7 +154,7 @@ void Physics::update(float dt)
//-----------------------------------------------------------------------------
/** Handles the special case of two karts colliding with each other, which means
* that bombs must be passed on. If both karts have a bomb, they'll explode
* that bombs must be passed on. If both karts have a bomb, they'll explode
* immediately. This function is called from physics::update on the server
* (and if no networking is used), and from race_state on the client to replay
* what happened on the server.
@ -164,7 +164,7 @@ void Physics::update(float dt)
void Physics::KartKartCollision(Kart *kartA, Kart *kartB)
{
kartA->crashed(kartB); // will play crash sound for player karts
kartB->crashed(kartA);
kartB->crashed(kartA);
Attachment *attachmentA=kartA->getAttachment();
Attachment *attachmentB=kartB->getAttachment();
@ -175,7 +175,7 @@ void Physics::KartKartCollision(Kart *kartA, Kart *kartB)
{
attachmentA->setTimeLeft(0.0f);
attachmentB->setTimeLeft(0.0f);
}
}
else // only A has a bomb, move it to B (unless it was from B)
{
if(attachmentA->getPreviousOwner()!=kartB)
@ -321,15 +321,14 @@ void Physics::draw()
* \param color Colour to use.
*/
void Physics::debugDraw(float m[16], btCollisionShape *s, const btVector3 color)
{
#ifdef HAVE_GLUT
m_shape_drawer.drawOpenGL(m, s, color, 0);
// btIDebugDraw::DBG_DrawWireframe);
// btIDebugDraw::DBG_DrawAabb);
#endif
} // debugDraw
// -----------------------------------------------------------------------------
/* EOF */

View File

@ -17,8 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_PHYSICS_H
#define HEADER_PHYSICS_H
#ifndef HEADER_PHYSICS_HPP
#define HEADER_PHYSICS_HPP
#include <set>
#include <vector>
@ -37,19 +37,10 @@ class Kart;
class Physics : public btSequentialImpulseConstraintSolver
{
private:
btDynamicsWorld *m_dynamics_world;
Kart *m_kart;
#ifdef HAVE_GLUT
GLDebugDrawer *m_debug_drawer;
GL_ShapeDrawer m_shape_drawer;
#endif
btCollisionDispatcher *m_dispatcher;
btBroadphaseInterface *m_axis_sweep;
btDefaultCollisionConfiguration *m_collision_conf;
// Bullet can report the same collision more than once (up to 4
// Bullet can report the same collision more than once (up to 4
// contact points per collision. Additionally, more than one internal
// substep might be taken, resulting in potentially even more
// substep might be taken, resulting in potentially even more
// duplicates. To handle this, all collisions (i.e. pair of objects)
// are stored in a vector, but only one entry per collision pair
// of objects.
@ -61,23 +52,21 @@ private:
class CollisionPair {
public:
const UserPointer *a, *b;
// The entries in Collision Pairs are sorted: if a projectile
// is included, it's always 'a'. If only two karts are reported
// the first kart pointer is the smaller one
CollisionPair(const UserPointer *a1, const UserPointer *b1) {
if(a1->is(UserPointer::UP_KART) &&
if(a1->is(UserPointer::UP_KART) &&
b1->is(UserPointer::UP_KART) && a1>b1) {
a=b1;b=a1;
} else {
a=a1; b=b1;
}
a=b1;b=a1;
} else {
a=a1; b=b1;
}
}; // CollisionPair
bool operator==(const CollisionPair p) {
return (p.a==a && p.b==b);
} // operator==
}; // CollisionPair
// ------------------------------------------------------------------------
bool operator==(const CollisionPair p) {return (p.a==a && p.b==b);}
}; // CollisionPair
// This class is the list of collision objects, where each collision
// pair is stored as most once.
class CollisionList : public std::vector<CollisionPair> {
@ -88,20 +77,28 @@ private:
if((*i)==p) return;
}
std::vector<CollisionPair>::push_back(p);
}; // push_back
}; // push_back
public:
void push_back(const UserPointer* a, const UserPointer*b) {
push_back(CollisionPair(a, b));
}
}; // CollisionList
// ------------------------------------------------------------------------
CollisionList m_all_collisions;
}; // CollisionList
btDynamicsWorld *m_dynamics_world;
#ifdef HAVE_GLUT
GLDebugDrawer *m_debug_drawer;
GL_ShapeDrawer m_shape_drawer;
#endif
btCollisionDispatcher *m_dispatcher;
btBroadphaseInterface *m_axis_sweep;
btDefaultCollisionConfiguration *m_collision_conf;
CollisionList m_all_collisions;
public:
Physics ();
~Physics ();
void init (const Vec3 &min_world, const Vec3 &max_world);
void addKart (const Kart *k, btKart *v);
void addKart (const Kart *k);
void addBody (btRigidBody* b) {m_dynamics_world->addRigidBody(b);}
void removeKart (const Kart *k);
void removeBody (btRigidBody* b) {m_dynamics_world->removeRigidBody(b);}
@ -118,6 +115,5 @@ public:
btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,
btDispatcher* dispatcher);
};
#endif
/* EOF */
#endif // HEADER_PHYSICS_HPP

View File

@ -21,7 +21,6 @@
#include <iostream>
#include "track_manager.hpp"
#include "unlock_manager.hpp"
#include "modes/world.hpp"
#include "scene.hpp"
@ -33,6 +32,7 @@
#include "modes/standard_race.hpp"
#include "modes/follow_the_leader.hpp"
#include "modes/three_strikes_battle.hpp"
#include "tracks/track_manager.hpp"
RaceManager* race_manager= NULL;

View File

@ -24,6 +24,13 @@
#include "constants.hpp"
#include "track.hpp"
TerrainInfo::TerrainInfo(int frequency)
{
m_HoT_frequency=frequency;
m_HoT_counter=frequency;
}
//-----------------------------------------------------------------------------
TerrainInfo::TerrainInfo(const Vec3 &pos, int frequency)
{
m_HoT_frequency = frequency;
@ -37,8 +44,8 @@ void TerrainInfo::update(const Vec3& pos)
m_HoT_counter++;
if(m_HoT_counter>=m_HoT_frequency)
{
RaceManager::getTrack()->getTerrainInfo(pos, &m_HoT,
&m_normal, &m_material);
RaceManager::getTrack()->getTerrainInfo(pos, &m_HoT,
&m_normal, &m_material);
m_normal.normalize();
m_HoT_counter = 0;
}
@ -56,13 +63,9 @@ float TerrainInfo::getTerrainPitch(float heading) const {
// (x,y,0). (x,y,0) is normalised, so are the coordinates of the plane,
// simplifying the computation of the scalar product.
float pitch = ( m_normal.getX()*X + m_normal.getY()*Y ); // use ( x,y,0)
// The actual angle computed above is between the normal and the (x,y,0)
// line, so to compute the actual angles 90 degrees must be subtracted.
pitch = acosf(pitch) - NINETY_DEGREE_RAD;
return pitch;
} // getTerrainPitch
// -----------------------------------------------------------------------------
/* EOF */

View File

@ -17,8 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_TERRAIN_INFO_H
#define HEADER_TERRAIN_INFO_H
#ifndef HEADER_TERRAIN_INFO_HPP
#define HEADER_TERRAIN_INFO_HPP
#include "material.hpp"
#include "utils/vec3.hpp"
@ -36,16 +36,16 @@ private:
float m_HoT; // height of terrain
public:
TerrainInfo(int frequency=1) {m_HoT_frequency=frequency;
m_HoT_counter=frequency; }
TerrainInfo(const Vec3 &pos, int frequency=1);
virtual ~TerrainInfo() {};
virtual void update(const Vec3 &pos);
float getHoT() const { return m_HoT; }
const Material *getMaterial() const { return m_material; }
const Vec3 &getNormal() const { return m_normal; }
float getTerrainPitch(float heading) const;
TerrainInfo(int frequency=1);
TerrainInfo(const Vec3 &pos, int frequency=1);
virtual ~TerrainInfo() {};
}; // TerrainInfo
virtual void update(const Vec3 &pos);
#endif
float getHoT() const {return m_HoT; }
const Material *getMaterial() const {return m_material;}
const Vec3 &getNormal() const {return m_normal; }
float getTerrainPitch(float heading) const;
}; // TerrainInfo
#endif // HEADER_TERRAIN_INFO_HPP

View File

@ -28,20 +28,20 @@
#include "file_manager.hpp"
#include "loader.hpp"
#include "string_utils.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "stk_config.hpp"
#include "translation.hpp"
#include "scene.hpp"
#include "moving_physics.hpp"
#include "modes/world.hpp"
#include "material_manager.hpp"
#include "isect.hpp"
#include "user_config.hpp"
#include "audio/sound_manager.hpp"
#include "items/item.hpp"
#include "items/item_manager.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "modes/world.hpp"
#include "physics/moving_physics.hpp"
#include "race_manager.hpp"
#include "audio/sound_manager.hpp"
#include "utils/ssg_help.hpp"
#if defined(WIN32) && !defined(__CYGWIN__)

View File

@ -25,8 +25,8 @@
#include "track_manager.hpp"
#include "track.hpp"
#include "stk_config.hpp"
#include "audio/sound_manager.hpp"
#include "translation.hpp"
#include "audio/sound_manager.hpp"
TrackManager* track_manager = 0;

View File

@ -17,8 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_TRACKMANAGER_H
#define HEADER_TRACKMANAGER_H
#ifndef HEADER_TRACK_MANAGER_HPP
#define HEADER_TRACK_MANAGER_HPP
#include <string>
#include <vector>
@ -66,4 +66,4 @@ public:
extern TrackManager* track_manager;
#endif
#endif // HEADER_TRACK_MANAGER_HPP

View File

@ -159,34 +159,27 @@ void UserConfig::setDefaults()
Input(Input::IT_KEYBOARD, SDLK_UP),
Input(Input::IT_MOUSEBUTTON, 4),
Input(Input::IT_STICKMOTION, 0, 1, Input::AD_NEGATIVE));
set(GA_CURSOR_DOWN,
Input(Input::IT_KEYBOARD, SDLK_DOWN),
Input(Input::IT_MOUSEBUTTON, 5),
Input(Input::IT_STICKMOTION, 0, 1, Input::AD_POSITIVE));
set(GA_CURSOR_LEFT,
Input(Input::IT_KEYBOARD, SDLK_LEFT),
Input(Input::IT_STICKMOTION, 0, 0, Input::AD_NEGATIVE));
set(GA_CURSOR_RIGHT,
Input(Input::IT_KEYBOARD, SDLK_RIGHT),
Input(Input::IT_STICKMOTION, 0, 0, Input::AD_POSITIVE));
set(GA_CLEAR_MAPPING,
Input(Input::IT_KEYBOARD, SDLK_BACKSPACE),
Input(Input::IT_STICKBUTTON, 0, 2));
set(GA_INC_SCROLL_SPEED,
Input(Input::IT_KEYBOARD, SDLK_PLUS));
set(GA_INC_SCROLL_SPEED_FAST,
Input(Input::IT_KEYBOARD, SDLK_PAGEDOWN));
set(GA_DEC_SCROLL_SPEED,
Input(Input::IT_KEYBOARD, SDLK_MINUS));
set(GA_DEC_SCROLL_SPEED_FAST,
Input(Input::IT_KEYBOARD, SDLK_PAGEUP));
set(GA_TOGGLE_FULLSCREEN,
Input(Input::IT_KEYBOARD, SDLK_F9));
set(GA_LEAVE_RACE,
@ -212,44 +205,26 @@ void UserConfig::setDefaults()
// b) prevent loading those defaults if config file contains any bindings
/* Player 1 default input settings */
set(GA_P1_LEFT,
Input(Input::IT_KEYBOARD, SDLK_LEFT));
set(GA_P1_RIGHT,
Input(Input::IT_KEYBOARD, SDLK_RIGHT));
set(GA_P1_ACCEL,
Input(Input::IT_KEYBOARD, SDLK_UP));
set(GA_P1_BRAKE,
Input(Input::IT_KEYBOARD, SDLK_DOWN));
set(GA_P1_NITRO,
Input(Input::IT_KEYBOARD, SDLK_l));
set(GA_P1_DRIFT,
Input(Input::IT_KEYBOARD, SDLK_k));
set(GA_P1_RESCUE,
Input(Input::IT_KEYBOARD, SDLK_h));
set(GA_P1_FIRE,
Input(Input::IT_KEYBOARD, SDLK_SPACE));
set(GA_P1_LOOK_BACK,
Input(Input::IT_KEYBOARD, SDLK_j));
set(GA_P1_LEFT, Input(Input::IT_KEYBOARD, SDLK_LEFT));
set(GA_P1_RIGHT, Input(Input::IT_KEYBOARD, SDLK_RIGHT));
set(GA_P1_ACCEL, Input(Input::IT_KEYBOARD, SDLK_UP));
set(GA_P1_BRAKE, Input(Input::IT_KEYBOARD, SDLK_DOWN));
set(GA_P1_NITRO, Input(Input::IT_KEYBOARD, SDLK_l));
set(GA_P1_DRIFT, Input(Input::IT_KEYBOARD, SDLK_k));
set(GA_P1_RESCUE, Input(Input::IT_KEYBOARD, SDLK_h));
set(GA_P1_FIRE, Input(Input::IT_KEYBOARD, SDLK_SPACE));
set(GA_P1_LOOK_BACK, Input(Input::IT_KEYBOARD, SDLK_j));
/* Player 2 default input settings */
set(GA_P2_LEFT,
Input(Input::IT_KEYBOARD, SDLK_a));
set(GA_P2_RIGHT,
Input(Input::IT_KEYBOARD, SDLK_d));
set(GA_P2_ACCEL,
Input(Input::IT_KEYBOARD, SDLK_w));
set(GA_P2_BRAKE,
Input(Input::IT_KEYBOARD, SDLK_s));
set(GA_P2_NITRO,
Input(Input::IT_KEYBOARD, SDLK_LSHIFT));
set(GA_P2_DRIFT,
Input(Input::IT_KEYBOARD, SDLK_CAPSLOCK));
set(GA_P2_RESCUE,
Input(Input::IT_KEYBOARD, SDLK_q));
set(GA_P2_FIRE,
Input(Input::IT_KEYBOARD, SDLK_LCTRL));
set(GA_P2_LOOK_BACK,
Input(Input::IT_KEYBOARD, SDLK_LALT));
set(GA_P2_LEFT, Input(Input::IT_KEYBOARD, SDLK_a));
set(GA_P2_RIGHT, Input(Input::IT_KEYBOARD, SDLK_d));
set(GA_P2_ACCEL, Input(Input::IT_KEYBOARD, SDLK_w));
set(GA_P2_BRAKE, Input(Input::IT_KEYBOARD, SDLK_s));
set(GA_P2_NITRO, Input(Input::IT_KEYBOARD, SDLK_LSHIFT));
set(GA_P2_DRIFT, Input(Input::IT_KEYBOARD, SDLK_CAPSLOCK));
set(GA_P2_RESCUE, Input(Input::IT_KEYBOARD, SDLK_q));
set(GA_P2_FIRE, Input(Input::IT_KEYBOARD, SDLK_LCTRL));
set(GA_P2_LOOK_BACK, Input(Input::IT_KEYBOARD, SDLK_LALT));
// If the same key is used for more than one player, the setting
// is overwritten when reading back the file. To allow us to have
@ -259,44 +234,26 @@ void UserConfig::setDefaults()
#undef DEFAULTS_FOR_PLAYER34
#ifdef DEFAULTS_FOR_PLAYER34
/* Player 3 default input settings */
set(GA_P3_LEFT,
Input(Input::IT_KEYBOARD, SDLK_f));
set(GA_P3_RIGHT,
Input(Input::IT_KEYBOARD, SDLK_h));
set(GA_P3_ACCEL,
Input(Input::IT_KEYBOARD, SDLK_t));
set(GA_P3_BRAKE,
Input(Input::IT_KEYBOARD, SDLK_g));
set(GA_P3_NITRO,
Input(Input::IT_KEYBOARD, SDLK_c));
set(GA_P3_DRIFT,
Input(Input::IT_KEYBOARD, SDLK_v));
set(GA_P3_RESCUE,
Input(Input::IT_KEYBOARD, SDLK_r));
set(GA_P3_FIRE,
Input(Input::IT_KEYBOARD, SDLK_b));
set(GA_P3_LOOK_BACK,
Input(Input::IT_KEYBOARD, SDLK_n));
set(GA_P3_LEFT, Input(Input::IT_KEYBOARD, SDLK_f));
set(GA_P3_RIGHT, Input(Input::IT_KEYBOARD, SDLK_h));
set(GA_P3_ACCEL, Input(Input::IT_KEYBOARD, SDLK_t));
set(GA_P3_BRAKE, Input(Input::IT_KEYBOARD, SDLK_g));
set(GA_P3_NITRO, Input(Input::IT_KEYBOARD, SDLK_c));
set(GA_P3_DRIFT, Input(Input::IT_KEYBOARD, SDLK_v));
set(GA_P3_RESCUE, Input(Input::IT_KEYBOARD, SDLK_r));
set(GA_P3_FIRE, Input(Input::IT_KEYBOARD, SDLK_b));
set(GA_P3_LOOK_BACK, Input(Input::IT_KEYBOARD, SDLK_n));
/* Player 4 default input settings */
set(GA_P4_LEFT,
Input(Input::IT_KEYBOARD, SDLK_j));
set(GA_P4_RIGHT,
Input(Input::IT_KEYBOARD, SDLK_l));
set(GA_P4_ACCEL,
Input(Input::IT_KEYBOARD, SDLK_i));
set(GA_P4_BRAKE,
Input(Input::IT_KEYBOARD, SDLK_k));
set(GA_P4_NITRO,
Input(Input::IT_KEYBOARD, SDLK_m));
set(GA_P4_DRIFT,
Input(Input::IT_KEYBOARD, SDLK_COMMA));
set(GA_P4_RESCUE,
Input(Input::IT_KEYBOARD, SDLK_u));
set(GA_P4_FIRE,
Input(Input::IT_KEYBOARD, SDLK_PERIOD));
set(GA_P4_LOOK_BACK,
Input(Input::IT_KEYBOARD, SDLK_SLASH));
set(GA_P4_LEFT, Input(Input::IT_KEYBOARD, SDLK_j));
set(GA_P4_RIGHT, Input(Input::IT_KEYBOARD, SDLK_l));
set(GA_P4_ACCEL, Input(Input::IT_KEYBOARD, SDLK_i));
set(GA_P4_BRAKE, Input(Input::IT_KEYBOARD, SDLK_k));
set(GA_P4_NITRO, Input(Input::IT_KEYBOARD, SDLK_m));
set(GA_P4_DRIFT, Input(Input::IT_KEYBOARD, SDLK_COMMA));
set(GA_P4_RESCUE, Input(Input::IT_KEYBOARD, SDLK_u));
set(GA_P4_FIRE, Input(Input::IT_KEYBOARD, SDLK_PERIOD));
set(GA_P4_LOOK_BACK, Input(Input::IT_KEYBOARD, SDLK_SLASH));
#endif
} // setDefaults
@ -354,7 +311,6 @@ int UserConfig::CheckAndCreateDir()
printf("Config directory '%s' successfully created.\n",DIRNAME.c_str());
return 2;
}
} // CheckAndCreateDir
// -----------------------------------------------------------------------------
@ -377,7 +333,7 @@ void UserConfig::loadConfig(const std::string& filename)
catch(std::exception& e)
{
(void)e; // avoid warning about unreferenced local variable
printf("Config file '%s' does not exist, it will be created.\n",
printf("Config file '%s' does not exist, it will be created.\n",
filename.c_str());
// This will initialise the last input configuration with the
// default values from the current (=default) player input
@ -461,13 +417,13 @@ void UserConfig::loadConfig(const std::string& filename)
/*get resolution width/height*/
lisp->get("width", m_width);
lisp->get("height", m_height);
lisp->get("prev_width", m_prev_width);
lisp->get("prev_height", m_prev_height);
lisp->get("prev_windowed", m_prev_windowed);
lisp->get("prev_width", m_prev_width);
lisp->get("prev_height", m_prev_height);
lisp->get("prev_windowed", m_prev_windowed);
//detect if resolution change previously crashed STK
lisp->get("crash_detected", m_crashed);
lisp->get("crash_detected", m_crashed);
// blacklisted resolutions
lisp->getVector("blacklisted_resolutions",
lisp->getVector("blacklisted_resolutions",
m_blacklist_res);
/*Get default number of karts, number of laps, and difficulty. */
lisp->get("karts", m_num_karts);
@ -507,9 +463,9 @@ void UserConfig::loadConfig(const std::string& filename)
}
std::string name;
reader->get("name", name);
if (configFileVersion <= 3)
if (configFileVersion <= 3)
{
// For older config files, replace the default player
// For older config files, replace the default player
// names "Player %d" with the user name
char sDefaultName[10];
snprintf(sDefaultName, sizeof(sDefaultName),
@ -524,14 +480,14 @@ void UserConfig::loadConfig(const std::string& filename)
reader->get("lastKartId", lastKartId);
m_player[i].setLastKartId(lastKartId);
// Don't read the key bindings from a config file earlier than
// version 5. These config files contain (unused) keybindings for
// jumping, so it is possible that the same key is used for
// Don't read the key bindings from a config file earlier than
// version 5. These config files contain (unused) keybindings for
// jumping, so it is possible that the same key is used for
// jumping for player 1 and something else for another player.
// In this case jumping for player one would be disabled (see
// unsetDuplicates). To be on the safe side, old key bindings
// unsetDuplicates). To be on the safe side, old key bindings
// are just discarded.
if (configFileVersion <= 4)
if (configFileVersion <= 4)
{
m_warning=_("Old config file found, check your key bindings!");
} // configFileVersion <= 4
@ -545,8 +501,8 @@ void UserConfig::loadConfig(const std::string& filename)
// Leave those in for backwards compatibility (i.e. config files
// with jump/wheelie). If jump/wheelie are not defined, nothing
// happens (the same input is read again).
readPlayerInput(reader, nitro_name, KA_NITRO, i);
readPlayerInput(reader, drift_name, KA_DRIFT, i);
readPlayerInput(reader, nitro_name, KA_NITRO, i);
readPlayerInput(reader, drift_name, KA_DRIFT, i);
} // for i < PLAYERS
// Read the last input device configurations. It is important that this
@ -554,7 +510,6 @@ void UserConfig::loadConfig(const std::string& filename)
// is given, the last config is initialised with the current player
// config.
readLastInputConfigurations(lisp);
}
catch(std::exception& e)
{
@ -563,12 +518,10 @@ void UserConfig::loadConfig(const std::string& filename)
fprintf(stderr, "\n");
}
delete root;
} // loadConfig
// -----------------------------------------------------------------------------
void UserConfig::readStickConfigs(const lisp::Lisp *r)
{
std::string temp;
@ -597,9 +550,7 @@ void UserConfig::readStickConfigs(const lisp::Lisp *r)
m_stickconfigs.push_back(sc);
}
}
}
} // readStickConfigs
// -----------------------------------------------------------------------------
@ -611,7 +562,7 @@ void UserConfig::readStickConfigs(const lisp::Lisp *r)
*/
void UserConfig::readLastInputConfigurations(const lisp::Lisp *reader)
{
const lisp::Lisp* nodeReader = reader
const lisp::Lisp* nodeReader = reader
? reader->getLisp("last-input-configurations")
: NULL;
// No last input configuration specified. Use the current player mappings
@ -649,7 +600,6 @@ void UserConfig::readLastInputConfigurations(const lisp::Lisp *reader)
m_last_input_configuration[device_name].m_input[ka] = input;
} // for ka=KA_FIRST, KA_LAST
} // for i<count
} // readLastInputConfigurations
// -----------------------------------------------------------------------------
@ -678,7 +628,6 @@ void UserConfig::readInputNode(const lisp::Lisp* r, const std::string &node,
{
setInput(action, input);
}
} // readInputNode
// -----------------------------------------------------------------------------
@ -732,13 +681,6 @@ Input UserConfig::readInput(const lisp::Lisp* nodeReader)
return input;
} // readInput
// -----------------------------------------------------------------------------
/** Call saveConfig with the default filename for this platform. */
void UserConfig::saveConfig()
{
saveConfig(m_filename);
} // saveConfig
// -----------------------------------------------------------------------------
/** Write settings to config file. */
void UserConfig::saveConfig(const std::string& filename)
@ -847,12 +789,11 @@ void UserConfig::saveConfig(const std::string& filename)
fprintf(stderr, e.what());
fprintf(stderr, "\n");
}
delete writer;
delete writer;
} // saveConfig
// -----------------------------------------------------------------------------
void UserConfig::writeStickConfigs(lisp::Writer *writer)
{
int count = 0;
@ -922,7 +863,7 @@ void UserConfig::writePlayerInput(lisp::Writer *writer, const std::string &node,
// -----------------------------------------------------------------------------
void UserConfig::writeInputNode(lisp::Writer *writer, const std::string &node,
GameAction action)
GameAction action)
{
writer->beginList(node);
@ -981,7 +922,7 @@ std::string UserConfig::getInputAsString(const Input &input)
{
char msg[MAX_MESSAGE_LENGTH];
std::ostringstream stm;
switch (input.type)
{
case Input::IT_NONE:
@ -1011,9 +952,9 @@ std::string UserConfig::getInputAsString(const Input &input)
default:
snprintf(msg, sizeof(msg), _("Invalid"));
}
stm << msg;
return stm.str();
} // GetKeyAsString
@ -1120,13 +1061,13 @@ std::string UserConfig::getInputDeviceName(int player_index) const
{
case Input::IT_KEYBOARD : { // config name: keyboard+player_index
std::ostringstream s;
s<<"keyboard-"<<left_input.id0;
s<<"keyboard-"<<left_input.id0;
config_name = s.str();
break;
}
case Input::IT_STICKBUTTON :
case Input::IT_STICKHAT :
case Input::IT_STICKMOTION : config_name=m_stickconfigs[left_input.id0]->m_id;
case Input::IT_STICKMOTION : config_name=m_stickconfigs[left_input.id0]->m_id;
break;
case Input::IT_MOUSEBUTTON :
case Input::IT_MOUSEMOTION : config_name="mouse"; break;
@ -1134,6 +1075,7 @@ std::string UserConfig::getInputDeviceName(int player_index) const
} // switch left_input.type
return config_name;
} // getInputDeviceName
// -----------------------------------------------------------------------------
void UserConfig::setInput(int player_index, KartAction ka, const Input &input)
{
@ -1141,7 +1083,7 @@ void UserConfig::setInput(int player_index, KartAction ka, const Input &input)
+ player_index * KC_COUNT + ka),
input);
// Now save the (complete) current configuration as the last used
// Now save the (complete) current configuration as the last used
// configuration for the input device that is defined for the left
// action. First determine the name of the device, and then
// copy the configuration.
@ -1159,8 +1101,8 @@ void UserConfig::setInput(int player_index, KartAction ka, const Input &input)
// to change the left axis for a gamepad anymore.
if(i==KA_LEFT) continue;
Input last_inp = m_last_input_configuration[device_name].m_input[(KartAction)i];
if(last_inp.type==Input::IT_STICKBUTTON ||
last_inp.type==Input::IT_STICKHAT ||
if(last_inp.type==Input::IT_STICKBUTTON ||
last_inp.type==Input::IT_STICKHAT ||
last_inp.type==Input::IT_STICKMOTION )
{ // in case of joystick, adjust the joystick index - in case
// that there are two joystickts with the same name
@ -1177,7 +1119,7 @@ void UserConfig::setInput(int player_index, KartAction ka, const Input &input)
// We change an entry (but not left) --> save as new 'last configuration'
for(int i=KA_FIRST; i<=KA_LAST; i++)
{
m_last_input_configuration[device_name].m_input[(KartAction)i] =
m_last_input_configuration[device_name].m_input[(KartAction)i] =
getInput(player_index, (KartAction)i);
} // for i=KA_FIRST, KA_LAST
} // ka!=KA_LEFT
@ -1234,7 +1176,7 @@ ActionMap *UserConfig::newIngameActionMap()
// (in MenuManager) and RaceGUI needs race_manager, too.
// TODO: Reorder ingame GameAction values so that they start with
// the fixed ones. This would allow simpler looking code here.
// the fixed ones. This would allow simpler looking code here.
GameAction gaEnd = GA_NULL;
@ -1282,24 +1224,3 @@ bool UserConfig::isFixedInput(Input::InputType type, int id0, int id1, int id2)
return false;
} // isFixedInput
// -----------------------------------------------------------------------------
void UserConfig::addStickConfig(StickConfig *sc)
{
m_stickconfigs.push_back(sc);
} // addStickConfig
// -----------------------------------------------------------------------------
const std::vector<UserConfig::StickConfig *> *UserConfig::getStickConfigs() const
{
return &m_stickconfigs;
} // getStickConfigs
// -----------------------------------------------------------------------------
UserConfig::StickConfig::StickConfig(const std::string &newId)
: m_id(newId)
{
// Nothing else to do.
}
/*EOF*/

View File

@ -18,8 +18,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_USERCONFIG_HPP
#define HEADER_USERCONFIG_HPP
#ifndef HEADER_USER_CONFIG_HPP
#define HEADER_USER_CONFIG_HPP
#define PLAYERS 4
@ -59,18 +59,17 @@ class UserConfig
{
public:
/** Stores information about joystick and gamepads. */
class StickConfig
{
public:
std::string m_id;
int m_preferredIndex;
int m_deadzone;
StickConfig(const std::string &id);
};
class StickConfig
{
public:
std::string m_id;
int m_preferredIndex;
int m_deadzone;
StickConfig(const std::string &id) : m_id(id) {}
};
private:
// This class stores the last used input configuration (i.e. which action
// This class stores the last used input configuration (i.e. which action
// is used for left, right, ..., look back) for a certain input
// device (i.e. keyboard, joystick, ...)
struct InputConfiguration
@ -84,25 +83,25 @@ private:
std::string getInputDeviceName(int player_index) const;
std::vector <StickConfig *> m_stickconfigs;
typedef struct
{
int count;
Input inputs[4];
} InputMapEntry;
std::vector <StickConfig *> m_stickconfigs;
typedef struct
{
int count;
Input inputs[4];
} InputMapEntry;
/** Filename of the user config file. */
std::string m_filename;
/** Stores the GameAction->Input mappings in a way that is suitable for
* quick modification of the mappings. Internally this allows multiple
* Input instances per GameAction but the public methods allow only one
* mapping.
*
* It is named after what is put in as values.
*/
InputMapEntry m_input_map[GA_COUNT];
/** Stores the GameAction->Input mappings in a way that is suitable for
* quick modification of the mappings. Internally this allows multiple
* Input instances per GameAction but the public methods allow only one
* mapping.
*
* It is named after what is put in as values.
*/
InputMapEntry m_input_map[GA_COUNT];
void setFilename ();
int CheckAndCreateDir();
@ -121,67 +120,67 @@ private:
/** Index of current background image. */
int m_background_index;
void readStickConfigs(const lisp::Lisp *);
void readStickConfigs(const lisp::Lisp *);
void readLastInputConfigurations(const lisp::Lisp *);
void writeStickConfigs(lisp::Writer *);
void writeStickConfigs(lisp::Writer *);
void writeLastInputConfigurations(lisp::Writer *);
void readPlayerInput(const lisp::Lisp *,
void readPlayerInput(const lisp::Lisp *,
const std::string& node,
KartAction ka,
int);
KartAction ka,
int);
void writePlayerInput(lisp::Writer *,
void writePlayerInput(lisp::Writer *,
const std::string &node,
KartAction,
int);
KartAction,
int);
void readInputNode(const lisp::Lisp *,
const std::string &node,
GameAction);
GameAction);
Input readInput(const lisp::Lisp* nodeReader);
void writeInputNode(lisp::Writer *,
const std::string &node,
GameAction);
GameAction);
void writeInput(lisp::Writer *writer, const Input &input);
void writeInput(lisp::Writer *writer, const Input &input);
/** Iterates through the input mapping and unsets all
* where the given input occurs.
*
* This makes sure an input is not bound multiple times.
*/
void unsetDuplicates(GameAction, const Input &);
/** Creates an GameAction->Input mapping with one Input */
void set(GameAction, const Input &);
/** Creates an GameAction->Input mapping with two Inputs */
void set(GameAction, const Input &, const Input &);
/** Creates an GameAction->Input mapping with three Inputs */
void set(GameAction, const Input &, const Input &, const Input &);
/** Creates an GameAction->Input mapping with four Inputs */
void set(GameAction, const Input &, const Input &, const Input &, const Input &);
/** Iterates through the input mapping and unsets all
* where the given input occurs.
*
* This makes sure an input is not bound multiple times.
*/
void unsetDuplicates(GameAction, const Input &);
std::string getInputAsString(const Input &);
/** Creates an GameAction->Input mapping with one Input */
void set(GameAction, const Input &);
/** Creates an ActionMap for the GameAction values of the specified
* range.
*/
ActionMap *newActionMap(const int, const int);
/** Sets the Input for the given GameAction. Includes a check for
* duplicates and automatic removing of the other candidate(s).
*
* For use when reading from file.
*/
void setInput(GameAction, const Input &);
/** Creates an GameAction->Input mapping with two Inputs */
void set(GameAction, const Input &, const Input &);
/** Creates an GameAction->Input mapping with three Inputs */
void set(GameAction, const Input &, const Input &, const Input &);
/** Creates an GameAction->Input mapping with four Inputs */
void set(GameAction, const Input &, const Input &, const Input &, const Input &);
std::string getInputAsString(const Input &);
/** Creates an ActionMap for the GameAction values of the specified
* range.
*/
ActionMap *newActionMap(const int, const int);
/** Sets the Input for the given GameAction. Includes a check for
* duplicates and automatic removing of the other candidate(s).
*
* For use when reading from file.
*/
void setInput(GameAction, const Input &);
public:
enum UC_Mode {UC_ENABLE, UC_DISABLE, UC_TEMPORARY_DISABLE};
@ -202,28 +201,29 @@ public:
std::string m_item_style;
std::string m_username;
std::string m_background_music;
std::string m_kart_group; //< Kart group used last
std::string m_track_group; //< Track group used last
std::string m_last_track; //< name of the last track used
std::string m_kart_group; /**< Kart group used last. */
std::string m_track_group; /**< Track group used last. */
std::string m_last_track; /**< name of the last track used. */
std::string m_server_address;
int m_server_port;
bool m_use_kph;
int m_width;
int m_height;
int m_prev_width;
int m_prev_height;
bool m_prev_windowed;
bool m_crashed;
std::vector<std::string> m_blacklist_res;
int m_prev_width;
int m_prev_height;
bool m_prev_windowed;
bool m_crashed;
std::vector<std::string>
m_blacklist_res;
Player m_player[PLAYERS];
bool m_log_errors;
UserConfig();
UserConfig(const std::string& filename);
~UserConfig();
UserConfig();
UserConfig(const std::string& filename);
~UserConfig();
void setDefaults();
void setMusic(int m) { m_music = m; }
void setSFX (int m) { m_sfx = m; }
void setSFX(int m) { m_sfx = m; }
bool doMusic() const { return m_music == UC_ENABLE;}
bool doSFX() const { return m_sfx == UC_ENABLE;}
/** Sets the default number of karts. This is only used to store
@ -243,52 +243,50 @@ public:
void setDefaultNumDifficulty(int n) { m_difficulty = n; }
/** Returns the default difficulty. */
int getDefaultDifficulty() const { return m_difficulty; }
void nextBackgroundIndex();
/** Get the index of the background image. */
int getBackgroundIndex() const { return m_background_index; }
int getBackgroundIndex() const { return m_background_index; }
void loadConfig();
void loadConfig(const std::string& filename);
void saveConfig();
void saveConfig(const std::string& filename);
void addStickConfig(UserConfig::StickConfig *);
const std::vector<StickConfig *> *getStickConfigs() const;
void loadConfig();
void loadConfig(const std::string& filename);
void saveConfig() { saveConfig(m_filename); }
void saveConfig(const std::string& filename);
void addStickConfig(UserConfig::StickConfig *sc)
{m_stickconfigs.push_back(sc);}
const std::vector<StickConfig *>
*getStickConfigs() const { return &m_stickconfigs; }
/** Retrieves a human readable string of the mapping for a GameAction */
/** Retrieves a human readable string of the mapping for a GameAction */
std::string getMappingAsString(GameAction);
/** Retrieves a human readable string of the mapping for the given
* player and KartAction.
*/
std::string getMappingAsString(int, KartAction);
/** Sets the Input for the given Player and KartAction. Includes a check
* for duplicates and automatic removing of the other candidate(s).
*
* For use when sensing input.
*/
void setInput(int player_number, KartAction ka, const Input &i0);
/** Retrieves a human readable string of the mapping for the given
* player and KartAction.
*/
std::string getMappingAsString(int, KartAction);
/** Sets the Input for the given Player and KartAction. Includes a check
* for duplicates and automatic removing of the other candidate(s).
*
* For use when sensing input.
*/
void setInput(int player_number, KartAction ka, const Input &i0);
const Input &getInput(int player_index, KartAction ka) const;
/** Clears the mapping for a given Player and KartAction. */
void clearInput(int, KartAction);
bool isFixedInput(Input::InputType, int, int, int);
const std::string& getWarning() {return m_warning;}
void resetWarning() {m_warning="";}
void setWarning(std::string& warning) {m_warning=warning;}
/** Clears the mapping for a given Player and KartAction. */
void clearInput(int, KartAction);
bool isFixedInput(Input::InputType, int, int, int);
const std::string
&getWarning() { return m_warning; }
void resetWarning() { m_warning=""; }
void setWarning(std::string& warning) { m_warning=warning; }
/** Creates ActionMap for use in menu mode. */
ActionMap *newMenuActionMap();
/** Creates ActionMap for use in ingame mode. */
ActionMap *newIngameActionMap();
/** Creates ActionMap for use in menu mode. */
ActionMap *newMenuActionMap();
/** Creates ActionMap for use in ingame mode. */
ActionMap *newIngameActionMap();
};

View File

@ -20,7 +20,6 @@
#include "random_generator.hpp"
#include <stdlib.h>
#include <algorithm>
#include <ctime>
std::vector<RandomGenerator*> RandomGenerator::m_all_random_generators;
@ -28,7 +27,7 @@ std::vector<RandomGenerator*> RandomGenerator::m_all_random_generators;
RandomGenerator::RandomGenerator()
{
m_a = 1103515245;
m_c = 12345;
m_c = 12345;
m_all_random_generators.push_back(this);
m_random_value = 3141591;
std::srand((unsigned int)std::time(0));
@ -42,32 +41,19 @@ std::vector<int> RandomGenerator::generateAllSeeds()
{
int seed = rand();
all_seeds.push_back(seed);
m_all_random_generators[i]->seed(seed);
}
seedAll(all_seeds);
return all_seeds;
} // generateAllSeeds
// ----------------------------------------------------------------------------
void RandomGenerator::seedAll(std::vector<int> all_seeds)
{
for(unsigned int i=0; i<all_seeds.size(); i++)
{
m_all_random_generators[i]->seed(all_seeds[i]);
}
} // seed
// ----------------------------------------------------------------------------
void RandomGenerator::seed(int s)
{
m_random_value = s;
} // seed
#if 0
// ----------------------------------------------------------------------------
int RandomGenerator::get(int n)
{
// This generator is (currently) not good enough, i.e. it often gives
// long sequences of same numbers. And the seeding is not done (the
// mid term goal is to synchronise all random number generators on
// mid term goal is to synchronise all random number generators on
// client and server to make less communication necessary).
// For now: just use standard random numbers:
return rand() % n;
@ -81,5 +67,4 @@ int RandomGenerator::get(int n)
#endif
} // get
// ----------------------------------------------------------------------------
#endif // if 0

View File

@ -17,12 +17,13 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_RANDOM_NUMBER_H
#define HEADER_RANDOM_NUMBER_H
#ifndef HEADER_RANDOM_GENERATOR_HPP
#define HEADER_RANDOM_GENERATOR_HPP
#include <algorithm>
#include <vector>
/** A random number generator. Each objects that needs a random number uses
/** A random number generator. Each objects that needs a random number uses
its own number random generator. They are all seeded with number provided
by the server. This guarantees that in a network game all 'random' values
are actually identical among all machines.
@ -32,18 +33,17 @@
class RandomGenerator
{
private:
unsigned int m_random_value;
unsigned int m_a, m_c;
unsigned int m_random_value;
unsigned int m_a, m_c;
static std::vector<RandomGenerator*> m_all_random_generators;
public:
RandomGenerator();
static void seedAll(std::vector<int> all_seeds);
RandomGenerator();
std::vector<int> generateAllSeeds();
void seed(int s);
/** Returns a pseudo random number between 0 and n-1 inclusive */
int get (int n);
}; // RandomGenerator
#endif
int get(int n) {return rand() % n; }
void seed(int s) {m_random_value = s;}
}; // RandomGenerator
#endif // HEADER_RANDOM_GENERATOR_HPP

View File

@ -29,22 +29,21 @@ class Vec3 : public btVector3
{
private:
inline float clampToUnity(float f) {return f<-1?f:(f>1?1:f);}
void setPitchRoll(const Vec3 &normal);
void setPitchRoll(const Vec3 &normal);
public:
inline Vec3(sgVec3 a) : btVector3(a[0], a[1], a[2]) {}
inline Vec3(const btVector3& a) : btVector3(a) {}
inline Vec3() : btVector3() {}
inline Vec3(float x, float y, float z)
: btVector3(x,y,z) {}
inline Vec3(float x) : btVector3(x,x,x) {}
/** Sets the heading, and computes pitch and roll dependent
* on the normal it is displayed on.
* \param heading The heading to set.
* \param normal The normal from which pitch and roll
should be computed. */
inline Vec3(float heading, const Vec3& normal)
{m_x=heading;
setPitchRoll(normal);}
inline Vec3(sgVec3 a) : btVector3(a[0], a[1], a[2]) {}
inline Vec3(const btVector3& a) : btVector3(a) {}
inline Vec3() : btVector3() {}
inline Vec3(float x, float y, float z) : btVector3(x,y,z) {}
inline Vec3(float x) : btVector3(x,x,x) {}
/** Sets the heading, and computes pitch and roll dependent
* on the normal it is displayed on.
* \param heading The heading to set.
* \param normal The normal from which pitch and roll should be computed. */
inline Vec3(float heading, const Vec3& normal)
{m_x=heading;
setPitchRoll(normal);}
void setHPR(const btMatrix3x3& m);
inline const float operator[](int n) const {return *(&m_x+n); }