1) Applied Peter's patch to support 16 bit windows (and remove the "ssgInit called

without a valid OpenGL context" error, instead a better error message is printed.
2) Changed sdldrv to follow our layout, added some documentation, fixed a few 
   warnings.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2373 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2008-10-24 05:03:12 +00:00
parent f2f09deff8
commit f0ff625227
10 changed files with 726 additions and 698 deletions

View File

@@ -142,7 +142,7 @@ void MenuManager::update()
&& m_current_menu == m_RaceGUI)
{
m_RaceGUI = 0;
inputDriver->setMode(MENU);
inputDriver->setMode(SDLDriver::MENU);
}
delete m_current_menu;
@@ -192,7 +192,7 @@ void MenuManager::update()
m_current_menu= new NumPlayers();
break;
case MENUID_RACE:
inputDriver->setMode(INGAME);
inputDriver->setMode(SDLDriver::INGAME);
m_current_menu = new RaceGUI();
m_RaceGUI = m_current_menu;
break;

View File

@@ -107,7 +107,7 @@ void NetworkGUI::select()
case WTOK_SERVER_ADDRESS:
// Switch to typing in the address of the server
widget_manager->setWgtText(WTOK_SERVER_ADDRESS, (m_server_address + "<").c_str());
inputDriver->setMode(LOWLEVEL);
inputDriver->setMode(SDLDriver::LOWLEVEL);
break;
case WTOK_CONNECT:
// If we could connect here, no message could be displayed since
@@ -256,7 +256,7 @@ void NetworkGUI::handle(GameAction ga, int value)
case GA_ENTER:
// If the user is typing her name this will be finished at this
// point.
if (inputDriver->isInMode(LOWLEVEL))
if (inputDriver->isInMode(SDLDriver::LOWLEVEL))
{
// Prevents zero-length names.
if (m_server_address.length() == 0)
@@ -276,7 +276,7 @@ void NetworkGUI::handle(GameAction ga, int value)
}
widget_manager->setWgtText(WTOK_SERVER_ADDRESS, m_server_address.c_str());
inputDriver->setMode(MENU);
inputDriver->setMode(SDLDriver::MENU);
}
else
select();
@@ -284,14 +284,14 @@ void NetworkGUI::handle(GameAction ga, int value)
case GA_LEAVE:
// If the user is typing her name this will be cancelled at this
// point.
if (inputDriver->isInMode(LOWLEVEL))
if (inputDriver->isInMode(SDLDriver::LOWLEVEL))
{
std::ostringstream s;
s<<user_config->m_server_address<<":"<<user_config->m_server_port;
m_server_address=s.str();
widget_manager->setWgtText(WTOK_SERVER_ADDRESS, m_server_address.c_str());
inputDriver->setMode(MENU);
inputDriver->setMode(SDLDriver::MENU);
break;
}
// Fall through to reach the usual GA_LEAVE code (leave menu).

View File

@@ -149,7 +149,7 @@ PlayerControls::select()
// Switch to typing in the player's name.
widget_manager->setWgtText(WTOK_PLYR_NAME1, (m_name + "<").c_str());
inputDriver->setMode(LOWLEVEL);
inputDriver->setMode(SDLDriver::LOWLEVEL);
break;
case WTOK_QUIT:
@@ -171,7 +171,7 @@ PlayerControls::select()
m_edit_action = static_cast<KartAction>(selected - WTOK_LEFT);
widget_manager->setWgtText(selected, _("Press key"));
inputDriver->setMode(INPUT_SENSE);
inputDriver->setMode(SDLDriver::INPUT_SENSE);
break;
}
@@ -251,7 +251,7 @@ void PlayerControls::handle(GameAction ga, int value)
inputDriver->getSensedInput());
// Fall through to recover the widget labels.
case GA_SENSE_CANCEL:
inputDriver->setMode(MENU);
inputDriver->setMode(SDLDriver::MENU);
// Refresh all key labels since they mave changed because of
// conflicting bindings.
@@ -260,7 +260,7 @@ void PlayerControls::handle(GameAction ga, int value)
case GA_ENTER:
// If the user is typing her name this will be finished at this
// point.
if (inputDriver->isInMode(LOWLEVEL))
if (inputDriver->isInMode(SDLDriver::LOWLEVEL))
{
// Prevents zero-length names.
if (m_name.length() == 0)
@@ -269,7 +269,7 @@ void PlayerControls::handle(GameAction ga, int value)
user_config->m_player[m_player_index].setName(m_name);
widget_manager->setWgtText(WTOK_PLYR_NAME1, m_name.c_str());
inputDriver->setMode(MENU);
inputDriver->setMode(SDLDriver::MENU);
}
else
select();
@@ -277,12 +277,12 @@ void PlayerControls::handle(GameAction ga, int value)
case GA_LEAVE:
// If the user is typing her name this will be cancelled at this
// point.
if (inputDriver->isInMode(LOWLEVEL))
if (inputDriver->isInMode(SDLDriver::LOWLEVEL))
{
m_name = user_config->m_player[m_player_index].getName();
widget_manager->setWgtText(WTOK_PLYR_NAME1, m_name.c_str());
inputDriver->setMode(MENU);
inputDriver->setMode(SDLDriver::MENU);
break;
}
// Fall through to reach the usual GA_LEAVE code (leave menu).

View File

@@ -1,195 +1,195 @@
// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2006 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_KARTPROPERTIES_H
#define HEADER_KARTPROPERTIES_H
#include <string>
#include <vector>
#include "vec3.hpp"
#include "lisp/lisp.hpp"
#include "no_copy.hpp"
class Material;
class ssgEntity;
/** This class stores the properties of a kart. This includes size, name,
* identifier, physical properties etc. It is atm also the base class for
* STKConfig, which stores the default values for all physics constants.
*/
class KartProperties
{
private:
Material *m_icon_material; /**< The icon texture to use. */
ssgEntity *m_model; /**< The 3d model of the kart.*/
std::vector<std::string> m_groups; /**< List of all groups the kart
belongs to. */
// $Id$
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2006 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_KARTPROPERTIES_H
#define HEADER_KARTPROPERTIES_H
#include <string>
#include <vector>
#include "vec3.hpp"
#include "lisp/lisp.hpp"
#include "no_copy.hpp"
class Material;
class ssgEntity;
/** This class stores the properties of a kart. This includes size, name,
* identifier, physical properties etc. It is atm also the base class for
* STKConfig, which stores the default values for all physics constants.
*/
class KartProperties
{
private:
Material *m_icon_material; /**< The icon texture to use. */
ssgEntity *m_model; /**< The 3d model of the kart.*/
std::vector<std::string> m_groups; /**< List of all groups the kart
belongs to. */
static float UNDEFINED;
protected:
// Display and gui
// ---------------
std::string m_name; /**< The human readable Name of the kart
* driver. */
std::string m_ident; /**< The computer readable-name of the kart
* driver. */
std::string m_model_file; /**< Filename of 3d model that is used for
* kart.*/
std::string m_icon_file; /**< Filename of icon that represents the kart
* in the statusbar and the character select
* screen. */
std::string m_shadow_file; /**< Filename of the image file that contains
* the shadow for this kart. */
Vec3 m_color; /**< Color the represents the kart in the status
* bar and on the track-view. */
// Physic properties
// -----------------
float m_kart_width; /**< Width of kart. */
float m_kart_length; /**< Length of kart. */
float m_kart_height; /**< Height of kart. */
float m_mass; /**< Weight of kart. */
float m_wheel_base; /**< Distance between front and rear
* wheels. */
float m_engine_power; /**< Maximum force from engine. */
float m_brake_factor; /**< Braking factor * engine_power =
* braking force. */
float m_time_full_steer; /**< Time for player karts to reach full
* steer angle. */
float m_wheelie_max_speed_ratio; /**< Percentage of maximum speed for
* wheelies. */
float m_wheelie_max_pitch; /**< Maximum pitch for wheelies. */
float m_wheelie_pitch_rate; /**< Rate/sec with which kart goes up. */
float m_wheelie_restore_rate; /**< Rate/sec with which kart does down.*/
float m_wheelie_speed_boost; /**< Speed boost while doing a wheelie. */
float m_wheelie_power_boost; /**< Increase in engine power. */
float m_min_speed_turn, m_angle_at_min; /**< Speed dependent steering:
* maximum speed to use. */
float m_max_speed_turn, m_angle_at_max; /**< Turn angle at lowest speed
* etc. */
float m_speed_angle_increase;
// bullet physics data
// -------------------
float m_suspension_stiffness;
float m_wheel_damping_relaxation;
float m_wheel_damping_compression;
float m_friction_slip;
float m_roll_influence;
float m_wheel_radius;
float m_chassis_linear_damping;
float m_chassis_angular_damping;
float m_maximum_speed;
float m_max_speed_reverse_ratio;
Vec3 m_gravity_center_shift; /**< Shift of center of gravity. */
Vec3 m_front_wheel_connection; /**< Connection point relative to center of */
Vec3 m_rear_wheel_connection; /**< Gravity for front and rear right wheels
* (X is mirrored for left wheels). */
float m_track_connection_accel; /**< Artifical acceleration that pulls a
* kart down onto the track if one axis
* loses contact with the track. */
float m_suspension_rest;
float m_suspension_travel_cm;
float m_jump_velocity; // z velocity set when jumping
float m_upright_tolerance;
float m_upright_max_force;
// Camera related setting
// ----------------------
float m_camera_max_accel; // maximum acceleration of camera
float m_camera_max_brake; // maximum braking of camera
float m_camera_distance; // distance of normal camera from kart
/** The following two vectors define at what ratio of the maximum speed what
* gear is selected. E.g. 0.25 means: if speed <=0.25*maxSpeed --> gear 1,
* 0.5 means: if speed <=0.5 *maxSpeed --> gear 2
* The next vector contains the increase in max power (to simulate different
* gears), e.g. 2.5 as first entry means: 2.5*maxPower in gear 1 */
std::vector<float> m_gear_switch_ratio,
m_gear_power_increase;
public:
KartProperties ();
~KartProperties ();
void getAllData (const lisp::Lisp* lisp);
void load (const std::string &filename,
const std::string &node="tuxkart-kart",
bool dont_load_models=false);
void checkAllSet(const std::string &filename);
float getMaxSteerAngle (float speed) const;
Material* getIconMaterial () const {return m_icon_material; }
ssgEntity* getModel () const {return m_model; }
const std::string& getName () const {return m_name; }
const std::string& getIdent () const {return m_ident; }
const std::string& getShadowFile() const {return m_shadow_file; }
const std::string& getIconFile () const {return m_icon_file; }
const Vec3 &getColor () const {return m_color; }
const std::vector<std::string>&
getGroups () const {return m_groups; }
float getMass () const {return m_mass; }
float getKartLength () const {return m_kart_length; }
float getKartWidth () const {return m_kart_width; }
float getKartHeight () const {return m_kart_height; }
float getMaxPower () const {return m_engine_power; }
float getTimeFullSteer () const {return m_time_full_steer; }
float getBrakeFactor () const {return m_brake_factor; }
float getWheelBase () const {return m_wheel_base; }
float getMaxSpeedReverseRatio () const {return m_max_speed_reverse_ratio; }
float getWheelieMaxSpeedRatio () const {return m_wheelie_max_speed_ratio; }
float getWheelieMaxPitch () const {return m_wheelie_max_pitch; }
float getWheeliePitchRate () const {return m_wheelie_pitch_rate; }
float getWheelieRestoreRate () const {return m_wheelie_restore_rate; }
float getWheelieSpeedBoost () const {return m_wheelie_speed_boost; }
float getWheeliePowerBoost () const {return m_wheelie_power_boost; }
//bullet physics get functions
float getSuspensionStiffness () const {return m_suspension_stiffness; }
float getWheelDampingRelaxation () const {return m_wheel_damping_relaxation; }
float getWheelDampingCompression() const {return m_wheel_damping_compression;}
float getFrictionSlip () const {return m_friction_slip; }
float getRollInfluence () const {return m_roll_influence; }
float getWheelRadius () const {return m_wheel_radius; }
float getChassisLinearDamping () const {return m_chassis_linear_damping; }
float getChassisAngularDamping () const {return m_chassis_angular_damping; }
float getMaximumSpeed () const {return m_maximum_speed; }
const Vec3& getGravityCenterShift() const {return m_gravity_center_shift; }
const Vec3& getFrontWheelConnection()const {return m_front_wheel_connection; }
const Vec3& getRearWheelConnection()const {return m_rear_wheel_connection; }
float getSuspensionRest () const {return m_suspension_rest; }
float getSuspensionTravelCM () const {return m_suspension_travel_cm; }
float getJumpVelocity () const {return m_jump_velocity; }
float getUprightTolerance () const {return m_upright_tolerance; }
float getUprightMaxForce () const {return m_upright_max_force; }
float getTrackConnectionAccel () const {return m_track_connection_accel; }
const std::vector<float>&
getGearSwitchRatio () const {return m_gear_switch_ratio; }
const std::vector<float>&
getGearPowerIncrease () const {return m_gear_power_increase; }
float getCameraMaxAccel () const {return m_camera_max_accel; }
float getCameraMaxBrake () const {return m_camera_max_brake; }
float getCameraDistance () const {return m_camera_distance; }
};
#endif
/* EOF */
protected:
// Display and gui
// ---------------
std::string m_name; /**< The human readable Name of the kart
* driver. */
std::string m_ident; /**< The computer readable-name of the kart
* driver. */
std::string m_model_file; /**< Filename of 3d model that is used for
* kart.*/
std::string m_icon_file; /**< Filename of icon that represents the kart
* in the statusbar and the character select
* screen. */
std::string m_shadow_file; /**< Filename of the image file that contains
* the shadow for this kart. */
Vec3 m_color; /**< Color the represents the kart in the status
* bar and on the track-view. */
// Physic properties
// -----------------
float m_kart_width; /**< Width of kart. */
float m_kart_length; /**< Length of kart. */
float m_kart_height; /**< Height of kart. */
float m_mass; /**< Weight of kart. */
float m_wheel_base; /**< Distance between front and rear
* wheels. */
float m_engine_power; /**< Maximum force from engine. */
float m_brake_factor; /**< Braking factor * engine_power =
* braking force. */
float m_time_full_steer; /**< Time for player karts to reach full
* steer angle. */
float m_wheelie_max_speed_ratio; /**< Percentage of maximum speed for
* wheelies. */
float m_wheelie_max_pitch; /**< Maximum pitch for wheelies. */
float m_wheelie_pitch_rate; /**< Rate/sec with which kart goes up. */
float m_wheelie_restore_rate; /**< Rate/sec with which kart does down.*/
float m_wheelie_speed_boost; /**< Speed boost while doing a wheelie. */
float m_wheelie_power_boost; /**< Increase in engine power. */
float m_min_speed_turn, m_angle_at_min; /**< Speed dependent steering:
* maximum speed to use. */
float m_max_speed_turn, m_angle_at_max; /**< Turn angle at lowest speed
* etc. */
float m_speed_angle_increase;
// bullet physics data
// -------------------
float m_suspension_stiffness;
float m_wheel_damping_relaxation;
float m_wheel_damping_compression;
float m_friction_slip;
float m_roll_influence;
float m_wheel_radius;
float m_chassis_linear_damping;
float m_chassis_angular_damping;
float m_maximum_speed;
float m_max_speed_reverse_ratio;
Vec3 m_gravity_center_shift; /**< Shift of center of gravity. */
Vec3 m_front_wheel_connection; /**< Connection point relative to center of */
Vec3 m_rear_wheel_connection; /**< Gravity for front and rear right wheels
* (X is mirrored for left wheels). */
float m_track_connection_accel; /**< Artifical acceleration that pulls a
* kart down onto the track if one axis
* loses contact with the track. */
float m_suspension_rest;
float m_suspension_travel_cm;
float m_jump_velocity; // z velocity set when jumping
float m_upright_tolerance;
float m_upright_max_force;
// Camera related setting
// ----------------------
float m_camera_max_accel; // maximum acceleration of camera
float m_camera_max_brake; // maximum braking of camera
float m_camera_distance; // distance of normal camera from kart
/** The following two vectors define at what ratio of the maximum speed what
* gear is selected. E.g. 0.25 means: if speed <=0.25*maxSpeed --> gear 1,
* 0.5 means: if speed <=0.5 *maxSpeed --> gear 2
* The next vector contains the increase in max power (to simulate different
* gears), e.g. 2.5 as first entry means: 2.5*maxPower in gear 1 */
std::vector<float> m_gear_switch_ratio,
m_gear_power_increase;
public:
KartProperties ();
~KartProperties ();
void getAllData (const lisp::Lisp* lisp);
void load (const std::string &filename,
const std::string &node="tuxkart-kart",
bool dont_load_models=false);
void checkAllSet(const std::string &filename);
float getMaxSteerAngle (float speed) const;
Material* getIconMaterial () const {return m_icon_material; }
ssgEntity* getModel () const {return m_model; }
const std::string& getName () const {return m_name; }
const std::string& getIdent () const {return m_ident; }
const std::string& getShadowFile() const {return m_shadow_file; }
const std::string& getIconFile () const {return m_icon_file; }
const Vec3 &getColor () const {return m_color; }
const std::vector<std::string>&
getGroups () const {return m_groups; }
float getMass () const {return m_mass; }
float getKartLength () const {return m_kart_length; }
float getKartWidth () const {return m_kart_width; }
float getKartHeight () const {return m_kart_height; }
float getMaxPower () const {return m_engine_power; }
float getTimeFullSteer () const {return m_time_full_steer; }
float getBrakeFactor () const {return m_brake_factor; }
float getWheelBase () const {return m_wheel_base; }
float getMaxSpeedReverseRatio () const {return m_max_speed_reverse_ratio; }
float getWheelieMaxSpeedRatio () const {return m_wheelie_max_speed_ratio; }
float getWheelieMaxPitch () const {return m_wheelie_max_pitch; }
float getWheeliePitchRate () const {return m_wheelie_pitch_rate; }
float getWheelieRestoreRate () const {return m_wheelie_restore_rate; }
float getWheelieSpeedBoost () const {return m_wheelie_speed_boost; }
float getWheeliePowerBoost () const {return m_wheelie_power_boost; }
//bullet physics get functions
float getSuspensionStiffness () const {return m_suspension_stiffness; }
float getWheelDampingRelaxation () const {return m_wheel_damping_relaxation; }
float getWheelDampingCompression() const {return m_wheel_damping_compression;}
float getFrictionSlip () const {return m_friction_slip; }
float getRollInfluence () const {return m_roll_influence; }
float getWheelRadius () const {return m_wheel_radius; }
float getChassisLinearDamping () const {return m_chassis_linear_damping; }
float getChassisAngularDamping () const {return m_chassis_angular_damping; }
float getMaximumSpeed () const {return m_maximum_speed; }
const Vec3& getGravityCenterShift() const {return m_gravity_center_shift; }
const Vec3& getFrontWheelConnection()const {return m_front_wheel_connection; }
const Vec3& getRearWheelConnection()const {return m_rear_wheel_connection; }
float getSuspensionRest () const {return m_suspension_rest; }
float getSuspensionTravelCM () const {return m_suspension_travel_cm; }
float getJumpVelocity () const {return m_jump_velocity; }
float getUprightTolerance () const {return m_upright_tolerance; }
float getUprightMaxForce () const {return m_upright_max_force; }
float getTrackConnectionAccel () const {return m_track_connection_accel; }
const std::vector<float>&
getGearSwitchRatio () const {return m_gear_switch_ratio; }
const std::vector<float>&
getGearPowerIncrease () const {return m_gear_power_increase; }
float getCameraMaxAccel () const {return m_camera_max_accel; }
float getCameraMaxBrake () const {return m_camera_max_brake; }
float getCameraDistance () const {return m_camera_distance; }
};
#endif
/* EOF */

View File

@@ -355,7 +355,7 @@ void RaceManager::RaceFinished(const Kart *kart, float time)
}
assert(pos-1 >= 0);
assert(pos-1 < m_kart_status.size());
assert(pos-1 < (int)m_kart_status.size());
m_kart_status[i].m_score += m_score_for_position[pos-1];
m_kart_status[i].m_last_score = m_score_for_position[pos-1];

File diff suppressed because it is too large Load Diff

View File

@@ -29,74 +29,56 @@
class ActionMap;
enum MouseState { INITIAL, MOVED, RESET_NEEDED };
enum InputDriverMode {
MENU = 0,
INGAME,
INPUT_SENSE,
LOWLEVEL,
BOOTSTRAP
};
/** Class to handle SDL.
*/
class SDLDriver
{
class StickInfo {
public:
enum InputDriverMode {
MENU = 0,
INGAME,
INPUT_SENSE,
LOWLEVEL,
BOOTSTRAP
};
private:
class StickInfo {
public:
SDL_Joystick *sdlJoystick;
std::string *id;
int deadzone;
int index;
AxisDirection *prevAxisDirections;
SDL_Joystick *m_sdlJoystick;
std::string m_id;
int m_deadzone;
int m_index;
AxisDirection *m_prevAxisDirections;
StickInfo(int);
~StickInfo();
};
}; // Stickinfo
Input *sensedInput;
ActionMap *actionMap;
SDL_Surface *mainSurface;
long flags;
StickInfo **stickInfos;
Input *sensedInput;
ActionMap *actionMap;
SDL_Surface *mainSurface;
long flags;
StickInfo **stickInfos;
InputDriverMode mode;
/* Helper values to store and track the relative mouse movements. If these
* values exceed the deadzone value the input is reported to the game. This
* makes the mouse behave like an analog axis on a gamepad/joystick.
*/
int mouseValX;
int mouseValY;
void showPointer();
void hidePointer();
void input(InputType, int, int, int, int);
int mouseValX, mouseValY;
void showPointer();
void hidePointer();
void input(InputType, int, int, int, int);
public:
SDLDriver();
~SDLDriver();
void initStickInfos();
void toggleFullscreen(bool resetTextures=1);
void setVideoMode(bool resetTextures=1);
void input();
void setMode(InputDriverMode);
bool isInMode(InputDriverMode);
SDLDriver();
~SDLDriver();
void initStickInfos();
void toggleFullscreen(bool resetTextures=1);
void setVideoMode(bool resetTextures=1);
void input();
void setMode(InputDriverMode);
bool isInMode(InputDriverMode);
Input &getSensedInput();
};

View File

@@ -547,8 +547,8 @@ void UserConfig::readStickConfigs(const lisp::Lisp *r)
StickConfig *sc = new StickConfig(*id);
screader->get("preferredIndex", sc->preferredIndex);
screader->get("deadzone", sc->deadzone);
screader->get("preferredIndex", sc->m_preferredIndex);
screader->get("deadzone", sc->m_deadzone);
m_stickconfigs.push_back(sc);
}
@@ -768,10 +768,10 @@ void UserConfig::writeStickConfigs(lisp::Writer *writer)
writer->beginList(temp);
writer->write("id", sc->id);
writer->write("preferredIndex", sc->preferredIndex);
writer->write("id", sc->m_id);
writer->write("preferredIndex", sc->m_preferredIndex);
writer->writeComment("0 means that the default deadzone value is used.");
writer->write("deadzone", sc->deadzone);
writer->write("deadzone", sc->m_deadzone);
writer->endList(temp);
}
@@ -1083,7 +1083,7 @@ const std::vector<UserConfig::StickConfig *> *UserConfig::getStickConfigs() cons
// -----------------------------------------------------------------------------
UserConfig::StickConfig::StickConfig(string &newId)
: id(newId)
: m_id(newId)
{
// Nothing else to do.
}

View File

@@ -52,20 +52,17 @@
class ActionMap;
/*class for managing general tuxkart configuration data*/
/** Class for managing general STK user configuration data. */
class UserConfig
{
public:
/** Stores information about joystick and gamepads. */
class StickConfig
{
public:
std::string &id;
int preferredIndex;
int deadzone;
std::string &m_id;
int m_preferredIndex;
int m_deadzone;
StickConfig(std::string &);
};
@@ -80,6 +77,7 @@ private:
Input *inputs;
} InputMapEntry;
/** Filename of the user config file. */
std::string m_filename;
/** Stores the GameAction->Input mappings in a way that is suitable for

View File

@@ -53,7 +53,7 @@ void RandomGenerator::seedAll(std::vector<int> all_seeds)
}
} // seed
// -------------------q---------------------------------------------------------
// ----------------------------------------------------------------------------
void RandomGenerator::seed(int s)
{
m_random_value = s;
@@ -63,6 +63,10 @@ void RandomGenerator::seed(int s)
int RandomGenerator::get(int n)
{
m_random_value = m_random_value*m_a+m_c;
// Note: the lower bits can have a very short cycle, e.g. for n = 4 the
// cycle length is 4, meaning that the same sequence 1,2,3,4 is repeated
// over and over again. The higher bits are more random, so the lower
// 8 bits are discarded.
return (m_random_value >> 8) % n;
} // get