SuperTuxKart
stk_config.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2006-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_STK_CONFIG_HPP
20 #define HEADER_STK_CONFIG_HPP
21 
30 #include "utils/interpolation_array.hpp"
31 #include "utils/no_copy.hpp"
32 
33 #include "utils/constants.hpp"
34 #include <map>
35 #include <set>
36 #include <string>
37 #include <vector>
38 
39 class KartProperties;
40 class MusicInformation;
41 class XMLNode;
42 
50 class STKConfig : public NoCopy
51 {
52 protected:
55  std::map<std::string, KartProperties*> m_kart_properties;
56 
57 public:
63  enum {
64  POWERUP_MODE_NEW,
65  POWERUP_MODE_SAME,
66  POWERUP_MODE_ONLY_IF_SAME
67  }
69 
70  int m_bonusbox_item_return_ticks;
75  static float UNDEFINED;
76  float m_bomb_time;
97 
100 
105 
110 
113 
116 
119 
122 
125 
128  int m_solver_set_flags, m_solver_reset_flags;
129 
150 
154 
158  std::vector<float>
163  std::vector<int> m_switch_items;
167  std::vector<int> m_score_increase;
168 
171 
174 
177 
181 
185 
188 
191 
194 
197 
199  float m_replay_dt;
200 
204 
208 
211 
212  /* The size of icons for AIs and human players, respectively */
213  float m_minimap_ai_icon;
214  float m_minimap_player_icon;
215 
217  float m_camera_fov[MAX_PLAYER_COUNT];
218 
219  float m_cutscene_fov;
220 
221  unsigned m_max_skinning_bones;
222 
223  unsigned m_tc_quality;
224 
227  uint16_t m_client_port;
228  uint16_t m_server_port;
229 
230  /* URLs for donating and reseting the password */
231  std::string m_donate_url;
232  std::string m_password_reset_url;
233  std::string m_assets_download_url;
234 
235  /* SRV records for stun server lists created */
236  std::string m_stun_ipv4;
237  std::string m_stun_ipv6;
238 
240  std::vector<std::string> m_normal_ttf;
241  std::vector<std::string> m_digit_ttf;
242  std::string m_color_emoji_ttf;
243 
245  float m_snb_min_adjust_length, m_snb_max_adjust_length,
246  m_snb_min_adjust_speed, m_snb_max_adjust_time,
247  m_snb_adjust_length_threshold;
248 
250  std::string m_server_api;
251 
253  uint32_t m_server_api_version = 0;
254 
256  std::string m_server_addons;
257 
260 
263 
266  std::set<std::string> m_network_capabilities;
267 
268 private:
274 
277 
278  std::string m_title_music_file;
279  std::string m_default_music_file;
280  std::string m_race_win_music_file;
281  std::string m_race_neutral_music_file;
282  std::string m_race_lose_music_file;
283  std::string m_gp_win_music_file;
284  std::string m_gp_lose_music_file;
285  std::string m_unlock_music_file;
286 
287 public:
288  STKConfig();
289  ~STKConfig();
290  void init_defaults();
291  void getAllData(const XMLNode * root);
292  void load(const std::string &filename);
293  const std::string &getMainMenuPicture(int n);
294  const std::string &getBackgroundPicture(int n);
295  void initMusicFiles();
296  void getAllScores(std::vector<int> *all_scores, int num_karts);
297  // ------------------------------------------------------------------------
299  const KartProperties &
301 
302  // ------------------------------------------------------------------------
307  const KartProperties& getKartProperties(const std::string &type)
308  {
309  return *m_kart_properties.at(type);
310  } // getKartProperties
311  // ------------------------------------------------------------------------
313  float ticks2Time(int ticks) { return float(ticks)/m_physics_fps; }
314  // ------------------------------------------------------------------------
316  int time2Ticks(float t) { return int(t * m_physics_fps); }
317  // ------------------------------------------------------------------------
319  int getPhysicsFPS() const { return m_physics_fps; }
320 }
321 ; // STKConfig
322 
323 extern STKConfig* stk_config;
324 #endif
int m_max_kart_version
version supported by this binary.
Definition: stk_config.hpp:136
int m_physics_fps
Default FPS rate for physics.
Definition: stk_config.hpp:276
MusicInformation * m_race_neutral_music
Filename of the music to play when a player finishes anywhere in the top half of the total karts but ...
Definition: stk_config.hpp:180
float m_solver_split_impulse_thresh
Threshold when to use the split impulse approach.
Definition: stk_config.hpp:124
bool m_has_been_loaded
True if stk_config has been loaded.
Definition: stk_config.hpp:273
float m_ai_acceleration
Between 0 and 1, default being 1, can be used to give a handicap to AIs.
Definition: stk_config.hpp:155
MusicInformation * m_gp_lose_music
Filename of the grand prix lose music to play.
Definition: stk_config.hpp:190
float m_skid_fadeout_time
Time till skidmarks fade away.
Definition: stk_config.hpp:131
float m_replay_delta_steering
A steering difference of more than that will trigger a new event to be generated. ...
Definition: stk_config.hpp:207
bool m_shield_restrict_weapons
Wether weapon usage is punished.
Definition: stk_config.hpp:82
Wrapper around an instance of the Music interface Adds information like composer, song title...
Definition: music_information.hpp:42
MusicInformation * m_default_music
Filename of the music that is played when the track&#39;s music was not found.
Definition: stk_config.hpp:173
int m_solver_set_flags
Bit flags to modify the solver mode.
Definition: stk_config.hpp:128
float m_music_credit_time
Time the music credits are displayed.
Definition: stk_config.hpp:89
bool m_allow_news_redirects
If true we allow all the server urls to be redirected by the news.xml.
Definition: stk_config.hpp:262
const KartProperties & getKartProperties(const std::string &type)
Returns the kart properties for a certain type of kart.
Definition: stk_config.hpp:307
float ticks2Time(int ticks)
Converts a tick value (in physics time step size) into seconds.
Definition: stk_config.hpp:313
int m_max_track_version
version supported by this binary.
Definition: stk_config.hpp:138
std::vector< std::string > m_normal_ttf
Lists of TTF files used in STK.
Definition: stk_config.hpp:240
static float UNDEFINED
Time until a bubble gum collected bý a kart returns.
Definition: stk_config.hpp:75
bool m_smooth_normals
If normals for raycasts for wheels should be interpolated.
Definition: stk_config.hpp:92
float m_default_moveable_friction
Default friction to be used for any moveable, e.g.
Definition: stk_config.hpp:115
void getAllScores(std::vector< int > *all_scores, int num_karts)
Defines the points for each position for a race with a given number of karts.
Definition: stk_config.cpp:710
MusicInformation * m_unlock_music
Filename of the feature unlock music to play.
Definition: stk_config.hpp:193
float m_minimap_size
The minimap size.
Definition: stk_config.hpp:210
Global STK configuration information.
Definition: stk_config.hpp:50
std::vector< int > m_switch_items
How to switch items.
Definition: stk_config.hpp:163
float m_bomb_time_increase
Time added to bomb timer when it&#39;s passed on.
Definition: stk_config.hpp:77
float m_delay_finish_time
Delay after a race finished before the results are displayed.
Definition: stk_config.hpp:87
int m_max_skidmarks
Maximum number of skid marks/kart.
Definition: stk_config.hpp:130
float m_replay_dt
Maximum time between consecutive saved tranform events.
Definition: stk_config.hpp:199
MusicInformation * m_race_lose_music
Filename of the music to play when a player finishes in the bottom half of the total karts...
Definition: stk_config.hpp:184
int m_max_moveable_objects
Maximum number of moveable objects in a track when networking is on.
Definition: stk_config.hpp:99
int m_bubblegum_item_return_ticks
Time until a banana collected by a kart return.
Definition: stk_config.hpp:73
float m_replay_delta_speed
If the speed difference with the last transform event is larger than this, a new event is generated...
Definition: stk_config.hpp:203
int m_replay_max_frames
Maximum number of transform events of a replay.
Definition: stk_config.hpp:196
bool m_camera_follow_skid
If true the camera will stay behind the kart, potentially making it easier to see where the kart is g...
Definition: stk_config.hpp:153
KartProperties * m_default_kart_properties
Default kart properties.
Definition: stk_config.hpp:54
int m_min_server_version
The minimum and maximum server.
Definition: stk_config.hpp:140
float m_near_ground
Determines when a kart is not near ground anymore and the upright constraint is disabled to allow for...
Definition: stk_config.hpp:132
bool m_disable_steer_while_unskid
Disable steering if skidding is stopped.
Definition: stk_config.hpp:149
MusicInformation * m_gp_win_music
Filename of the grand prix win music to play.
Definition: stk_config.hpp:187
float m_snb_min_adjust_length
Configurable values used in SmoothNetworkBody class.
Definition: stk_config.hpp:245
int m_max_karts
Maximum number of karts.
Definition: stk_config.hpp:91
int m_bubblegum_counter
How many times bubble gums must be driven over before they disappear.
Definition: stk_config.hpp:80
std::vector< int > m_score_increase
The number of points a kart on position X has more than the next kart.
Definition: stk_config.hpp:167
int m_penalty_ticks
Penalty time when starting too early.
Definition: stk_config.hpp:85
std::vector< float > m_leader_intervals
Interval in follow the leader till last kart is reomved.
Definition: stk_config.hpp:159
int m_min_track_version
The minimum and maximum .track file.
Definition: stk_config.hpp:138
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
float m_network_steering_reduction
In case of a network race, remote karts will get their steering somewhat reduced each frame...
Definition: stk_config.hpp:104
STKConfig()
Constructor, which only initialises the object.
Definition: stk_config.cpp:40
void load(const std::string &filename)
Loads the stk configuration file.
Definition: stk_config.cpp:97
int getPhysicsFPS() const
Returns the physics frame per seconds rate.
Definition: stk_config.hpp:319
float m_default_track_friction
Default friction for the track and any track/library object.
Definition: stk_config.hpp:112
float m_camera_fov[MAX_PLAYER_COUNT]
The field of view for 1, 2, 3, 4 player split screen.
Definition: stk_config.hpp:217
int m_nitro_item_return_ticks
Time until a bonus box collected by a kart returns.
Definition: stk_config.hpp:71
void initMusicFiles()
Init the music files after downloading assets.
Definition: stk_config.cpp:643
std::set< std::string > m_network_capabilities
List of network capabilities to handle different servers with same version.
Definition: stk_config.hpp:266
int m_item_switch_ticks
Time items will be switched.
Definition: stk_config.hpp:79
int m_max_server_version
version supported by this binary.
Definition: stk_config.hpp:140
float m_leader_time_per_kart
Additional time to each leader interval for each additional kart.
Definition: stk_config.hpp:161
This class stores the properties of a kart.
Definition: kart_properties.hpp:59
int m_min_kart_version
The minimum and maximum .kart file.
Definition: stk_config.hpp:136
void getAllData(const XMLNode *root)
Extracts the actual information from a xml file.
Definition: stk_config.cpp:279
bool m_solver_split_impulse
If position and velocity constraints are solved separately.
Definition: stk_config.hpp:121
float m_smooth_angle_limit
If the angle between a normal on a vertex and the normal of the triangle are more than this value...
Definition: stk_config.hpp:109
std::string m_server_addons
URL for the server used for the addons management.
Definition: stk_config.hpp:256
const KartProperties & getDefaultKartProperties() const
Returns the default kart properties for each kart.
Definition: stk_config.hpp:300
utility class used to parse XML files
Definition: xml_node.hpp:47
int m_banana_item_return_ticks
Time until a nitro collected by a kart returns.
Definition: stk_config.hpp:72
float m_no_explosive_items_timeout
Prevent early explosive items before this world time.
Definition: stk_config.hpp:96
void init_defaults()
Init all values with invalid defaults, which are tested later.
Definition: stk_config.cpp:205
uint16_t m_server_discovery_port
Client and server port use random ports if enabled in user config.
Definition: stk_config.hpp:226
float m_explosion_impulse_objects
Impulse of explosion on moving objects, e.g.
Definition: stk_config.hpp:83
MusicInformation * m_race_win_music
Filename of the music to play when a player finishes in 1st place.
Definition: stk_config.hpp:176
std::string m_server_hardware_report
URL for the server used for hardware reporting statistics.
Definition: stk_config.hpp:259
float m_bomb_time
Time before a bomb explodes.
Definition: stk_config.hpp:76
int time2Ticks(float t)
Converts a time value into ticks (of physics time steps).
Definition: stk_config.hpp:316
int m_max_display_news
How often a news message is displayed before it is ignored.
Definition: stk_config.hpp:142
uint32_t m_server_api_version
Version of the server API to use.
Definition: stk_config.hpp:253
enum STKConfig::@3 m_same_powerup_mode
What to do if a kart already has a powerup when it hits a bonus box:
std::string m_server_api
URL for the server used for the API multiplayer.
Definition: stk_config.hpp:250
MusicInformation * m_title_music
Filename of the title music to play.
Definition: stk_config.hpp:170
int m_solver_iterations
Number of solver iterations.
Definition: stk_config.hpp:118