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 the stk website, donating and reseting the password */
231  std::string m_stk_website_url;
232  std::string m_donate_url;
233  std::string m_password_reset_url;
234  std::string m_assets_download_url;
235 
236  /* SRV records for stun server lists created */
237  std::string m_stun_ipv4;
238  std::string m_stun_ipv6;
239 
241  std::vector<std::string> m_normal_ttf;
242  std::vector<std::string> m_digit_ttf;
243  std::string m_color_emoji_ttf;
244 
246  float m_snb_min_adjust_length, m_snb_max_adjust_length,
247  m_snb_min_adjust_speed, m_snb_max_adjust_time,
248  m_snb_adjust_length_threshold;
249 
251  std::string m_server_api;
252 
254  uint32_t m_server_api_version = 0;
255 
257  std::string m_server_addons;
258 
261 
264 
267  std::set<std::string> m_network_capabilities;
268 
269 private:
275 
278 
279  std::string m_title_music_file;
280  std::string m_default_music_file;
281  std::string m_race_win_music_file;
282  std::string m_race_neutral_music_file;
283  std::string m_race_lose_music_file;
284  std::string m_gp_win_music_file;
285  std::string m_gp_lose_music_file;
286  std::string m_unlock_music_file;
287 
288 public:
289  STKConfig();
290  ~STKConfig();
291  void init_defaults();
292  void getAllData(const XMLNode * root);
293  void load(const std::string &filename);
294  const std::string &getMainMenuPicture(int n);
295  const std::string &getBackgroundPicture(int n);
296  void initMusicFiles();
297  void getAllScores(std::vector<int> *all_scores, int num_karts);
298  // ------------------------------------------------------------------------
300  const KartProperties &
302 
303  // ------------------------------------------------------------------------
308  const KartProperties& getKartProperties(const std::string &type)
309  {
310  return *m_kart_properties.at(type);
311  } // getKartProperties
312  // ------------------------------------------------------------------------
314  float ticks2Time(int ticks) { return float(ticks)/m_physics_fps; }
315  // ------------------------------------------------------------------------
317  int time2Ticks(float t) { return int(t * m_physics_fps); }
318  // ------------------------------------------------------------------------
320  int getPhysicsFPS() const { return m_physics_fps; }
321 }
322 ; // STKConfig
323 
324 extern STKConfig* stk_config;
325 #endif
This class stores the properties of a kart.
Definition: kart_properties.hpp:60
Wrapper around an instance of the Music interface Adds information like composer, song title,...
Definition: music_information.hpp:43
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Global STK configuration information.
Definition: stk_config.hpp:51
MusicInformation * m_default_music
Filename of the music that is played when the track's music was not found.
Definition: stk_config.hpp:173
int m_min_track_version
The minimum and maximum .track file.
Definition: stk_config.hpp:138
float m_bomb_time_increase
Time added to bomb timer when it's passed on.
Definition: stk_config.hpp:77
MusicInformation * m_race_win_music
Filename of the music to play when a player finishes in 1st place.
Definition: stk_config.hpp:176
int m_bubblegum_counter
How many times bubble gums must be driven over before they disappear.
Definition: stk_config.hpp:80
static float UNDEFINED
Time until a bubble gum collected bý a kart returns.
Definition: stk_config.hpp:75
int m_max_karts
Maximum number of karts.
Definition: stk_config.hpp:91
STKConfig()
Constructor, which only initialises the object.
Definition: stk_config.cpp:40
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
int m_max_skidmarks
Maximum number of skid marks/kart.
Definition: stk_config.hpp:130
bool m_smooth_normals
If normals for raycasts for wheels should be interpolated.
Definition: stk_config.hpp:92
enum STKConfig::@3 m_same_powerup_mode
What to do if a kart already has a powerup when it hits a bonus box:
float m_bomb_time
Time before a bomb explodes.
Definition: stk_config.hpp:76
std::string m_server_hardware_report
URL for the server used for hardware reporting statistics.
Definition: stk_config.hpp:260
std::set< std::string > m_network_capabilities
List of network capabilities to handle different servers with same version.
Definition: stk_config.hpp:267
MusicInformation * m_gp_win_music
Filename of the grand prix win music to play.
Definition: stk_config.hpp:187
int m_penalty_ticks
Penalty time when starting too early.
Definition: stk_config.hpp:85
float m_default_moveable_friction
Default friction to be used for any moveable, e.g.
Definition: stk_config.hpp:115
std::vector< float > m_leader_intervals
Interval in follow the leader till last kart is reomved.
Definition: stk_config.hpp:159
int m_max_track_version
version supported by this binary.
Definition: stk_config.hpp:139
const KartProperties & getDefaultKartProperties() const
Returns the default kart properties for each kart.
Definition: stk_config.hpp:301
int time2Ticks(float t)
Converts a time value into ticks (of physics time steps).
Definition: stk_config.hpp:317
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
void initMusicFiles()
Init the music files after downloading assets.
Definition: stk_config.cpp:644
MusicInformation * m_gp_lose_music
Filename of the grand prix lose music to play.
Definition: stk_config.hpp:190
void init_defaults()
Init all values with invalid defaults, which are tested later.
Definition: stk_config.cpp:205
int m_max_display_news
How often a news message is displayed before it is ignored.
Definition: stk_config.hpp:142
std::vector< std::string > m_normal_ttf
Lists of TTF files used in STK.
Definition: stk_config.hpp:241
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
std::string m_server_addons
URL for the server used for the addons management.
Definition: stk_config.hpp:257
bool m_shield_restrict_weapons
Wether weapon usage is punished.
Definition: stk_config.hpp:82
std::vector< int > m_switch_items
How to switch items.
Definition: stk_config.hpp:163
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_replay_dt
Maximum time between consecutive saved tranform events.
Definition: stk_config.hpp:199
int m_banana_item_return_ticks
Time until a nitro collected by a kart returns.
Definition: stk_config.hpp:72
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
float m_no_explosive_items_timeout
Prevent early explosive items before this world time.
Definition: stk_config.hpp:96
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:711
int m_solver_set_flags
Bit flags to modify the solver mode.
Definition: stk_config.hpp:128
int m_max_kart_version
version supported by this binary.
Definition: stk_config.hpp:137
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
float m_minimap_size
The minimap size.
Definition: stk_config.hpp:210
float m_camera_fov[MAX_PLAYER_COUNT]
The field of view for 1, 2, 3, 4 player split screen.
Definition: stk_config.hpp:217
MusicInformation * m_title_music
Filename of the title music to play.
Definition: stk_config.hpp:170
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_bubblegum_item_return_ticks
Time until a banana collected by a kart return.
Definition: stk_config.hpp:73
bool m_allow_news_redirects
If true we allow all the server urls to be redirected by the news.xml.
Definition: stk_config.hpp:263
int m_min_server_version
The minimum and maximum server.
Definition: stk_config.hpp:140
float m_solver_split_impulse_thresh
Threshold when to use the split impulse approach.
Definition: stk_config.hpp:124
void getAllData(const XMLNode *root)
Extracts the actual information from a xml file.
Definition: stk_config.cpp:279
std::string m_server_api
URL for the server used for the API multiplayer.
Definition: stk_config.hpp:251
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
float ticks2Time(int ticks)
Converts a tick value (in physics time step size) into seconds.
Definition: stk_config.hpp:314
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
uint32_t m_server_api_version
Version of the server API to use.
Definition: stk_config.hpp:254
MusicInformation * m_unlock_music
Filename of the feature unlock music to play.
Definition: stk_config.hpp:193
const KartProperties & getKartProperties(const std::string &type)
Returns the kart properties for a certain type of kart.
Definition: stk_config.hpp:308
float m_music_credit_time
Time the music credits are displayed.
Definition: stk_config.hpp:89
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_item_switch_ticks
Time items will be switched.
Definition: stk_config.hpp:79
float m_snb_min_adjust_length
Configurable values used in SmoothNetworkBody class.
Definition: stk_config.hpp:246
bool m_solver_split_impulse
If position and velocity constraints are solved separately.
Definition: stk_config.hpp:121
int m_max_server_version
version supported by this binary.
Definition: stk_config.hpp:141
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
float m_skid_fadeout_time
Time till skidmarks fade away.
Definition: stk_config.hpp:131
int m_max_moveable_objects
Maximum number of moveable objects in a track when networking is on.
Definition: stk_config.hpp:99
KartProperties * m_default_kart_properties
Default kart properties.
Definition: stk_config.hpp:54
int m_nitro_item_return_ticks
Time until a bonus box collected by a kart returns.
Definition: stk_config.hpp:71
bool m_disable_steer_while_unskid
Disable steering if skidding is stopped.
Definition: stk_config.hpp:149
int getPhysicsFPS() const
Returns the physics frame per seconds rate.
Definition: stk_config.hpp:320
float m_delay_finish_time
Delay after a race finished before the results are displayed.
Definition: stk_config.hpp:87
int m_physics_fps
Default FPS rate for physics.
Definition: stk_config.hpp:277
float m_leader_time_per_kart
Additional time to each leader interval for each additional kart.
Definition: stk_config.hpp:161
int m_min_kart_version
The minimum and maximum .kart file
Definition: stk_config.hpp:136
bool m_has_been_loaded
True if stk_config has been loaded.
Definition: stk_config.hpp:274
void load(const std::string &filename)
Loads the stk configuration file.
Definition: stk_config.cpp:97
float m_explosion_impulse_objects
Impulse of explosion on moving objects, e.g.
Definition: stk_config.hpp:83
float m_default_track_friction
Default friction for the track and any track/library object.
Definition: stk_config.hpp:112
int m_solver_iterations
Number of solver iterations.
Definition: stk_config.hpp:118
utility class used to parse XML files
Definition: xml_node.hpp:48