Back to index

extremetuxracer  0.5beta
Defines | Functions
game_config.h File Reference
#include "etracer.h"
#include <string>

Go to the source code of this file.

Defines

#define PROTO_PARAM(name, type)
#define PROTO_PARAM_STRING(name)   PROTO_PARAM( name, char* )
#define PROTO_PARAM_CHAR(name)   PROTO_PARAM( name, char )
#define PROTO_PARAM_INT(name)   PROTO_PARAM( name, int )
#define PROTO_PARAM_BOOL(name)   PROTO_PARAM( name, bool )

Functions

void init_game_configuration ()
void read_config_file (std::string &file)
void write_config_file ()
void clear_config_cache ()
void register_game_config_callbacks (Tcl_Interp *ip)
int get_config_dir_name (char *buff, unsigned int len)
 PROTO_PARAM_STRING (data_dir)
 PROTO_PARAM_BOOL (draw_tux_shadow)
 PROTO_PARAM_BOOL (draw_particles)
 PROTO_PARAM_INT (tux_sphere_divisions)
 PROTO_PARAM_INT (tux_shadow_sphere_divisions)
 PROTO_PARAM_BOOL (nice_fog)
 PROTO_PARAM_BOOL (use_sphere_display_list)
 PROTO_PARAM_BOOL (display_fps)
 PROTO_PARAM_BOOL (display_course_percentage)
 PROTO_PARAM_INT (x_resolution)
 PROTO_PARAM_INT (y_resolution)
 PROTO_PARAM_BOOL (x_resolution_half_width)
 PROTO_PARAM_BOOL (capture_mouse)
 PROTO_PARAM_BOOL (do_intro_animation)
 PROTO_PARAM_INT (mipmap_type)
 PROTO_PARAM_BOOL (fullscreen)
 PROTO_PARAM_INT (bpp_mode)
 PROTO_PARAM_BOOL (force_window_position)
 PROTO_PARAM_INT (ode_solver)
 PROTO_PARAM_STRING (quit_key)
 PROTO_PARAM_INT (turn_left_key)
 PROTO_PARAM_INT (turn_right_key)
 PROTO_PARAM_INT (trick_modifier_key)
 PROTO_PARAM_INT (brake_key)
 PROTO_PARAM_INT (paddle_key)
 PROTO_PARAM_STRING (above_view_key)
 PROTO_PARAM_STRING (behind_view_key)
 PROTO_PARAM_STRING (eye_view_key)
 PROTO_PARAM_STRING (follow_view_key)
 PROTO_PARAM_INT (view_mode)
 PROTO_PARAM_STRING (screenshot_key)
 PROTO_PARAM_STRING (pause_key)
 PROTO_PARAM_INT (reset_key)
 PROTO_PARAM_INT (jump_key)
 PROTO_PARAM_INT (joystick_jump_button)
 PROTO_PARAM_INT (joystick_brake_button)
 PROTO_PARAM_INT (joystick_paddle_button)
 PROTO_PARAM_INT (joystick_trick_button)
 PROTO_PARAM_INT (joystick_continue_button)
 PROTO_PARAM_INT (joystick_x_axis)
 PROTO_PARAM_INT (joystick_y_axis)
 PROTO_PARAM_INT (fov)
 PROTO_PARAM_STRING (debug)
 PROTO_PARAM_INT (warning_level)
 PROTO_PARAM_INT (forward_clip_distance)
 PROTO_PARAM_INT (backward_clip_distance)
 PROTO_PARAM_INT (tree_detail_distance)
 PROTO_PARAM_INT (course_detail_level)
 PROTO_PARAM_BOOL (terrain_blending)
 PROTO_PARAM_BOOL (perfect_terrain_blending)
 PROTO_PARAM_BOOL (terrain_envmap)
 PROTO_PARAM_BOOL (disable_fog)
 PROTO_PARAM_BOOL (use_cva)
 PROTO_PARAM_BOOL (cva_hack)
 PROTO_PARAM_BOOL (no_audio)
 PROTO_PARAM_BOOL (sound_enabled)
 PROTO_PARAM_BOOL (music_enabled)
 PROTO_PARAM_INT (sound_volume)
 PROTO_PARAM_INT (music_volume)
 PROTO_PARAM_INT (audio_freq_mode)
 PROTO_PARAM_INT (audio_format_mode)
 PROTO_PARAM_BOOL (audio_stereo)
 PROTO_PARAM_INT (audio_buffer_size)
 PROTO_PARAM_BOOL (track_marks)
 PROTO_PARAM_BOOL (ui_snow)
 PROTO_PARAM_BOOL (write_diagnostic_log)
 PROTO_PARAM_BOOL (stencil_buffer)
 PROTO_PARAM_BOOL (enable_fsaa)
 PROTO_PARAM_INT (multisamples)
 PROTO_PARAM_BOOL (always_save_event_race_data)
 PROTO_PARAM_BOOL (disable_collision_detection)
 PROTO_PARAM_BOOL (disable_joystick)
 PROTO_PARAM_BOOL (disable_videomode_autodetection)
 PROTO_PARAM_BOOL (disable_background)
 PROTO_PARAM_STRING (ui_language)

Define Documentation

#define PROTO_PARAM (   name,
  type 
)
Value:
type getparam_ ## name(); \
    void setparam_ ## name( type val )

Definition at line 36 of file game_config.h.

#define PROTO_PARAM_BOOL (   name)    PROTO_PARAM( name, bool )

Definition at line 49 of file game_config.h.

#define PROTO_PARAM_CHAR (   name)    PROTO_PARAM( name, char )

Definition at line 43 of file game_config.h.

#define PROTO_PARAM_INT (   name)    PROTO_PARAM( name, int )

Definition at line 46 of file game_config.h.

#define PROTO_PARAM_STRING (   name)    PROTO_PARAM( name, char* )

Definition at line 40 of file game_config.h.


Function Documentation

Definition at line 1003 of file game_config.cpp.

{
    struct param *parm;
    unsigned int i;

    for (i=0; i<sizeof(Params)/sizeof(struct param); i++) {
       parm = (struct param*)&Params + i;
       parm->loaded = false;
    }
}

Here is the caller graph for this function:

int get_config_dir_name ( char *  buff,
unsigned int  len 
)

Definition at line 958 of file game_config.cpp.

{
#if defined( WIN32 ) 
    if ( strlen( CONFIG_DIR ) +1 > len ) {
       return 1;
    }
    strcpy( buff, CONFIG_DIR );
    return 0;
#else
    struct passwd *pwent;

    pwent = getpwuid( getuid() );
    if ( pwent == NULL ) {
       perror( "getpwuid" );
       return 1;
    }

    if ( strlen( pwent->pw_dir ) + strlen( CONFIG_DIR) + 2 > len ) {
       return 1;
    }

    sprintf( buff, "%s/%s", pwent->pw_dir, CONFIG_DIR );
    return 0;
#endif /* defined( WIN32 ) */
}

Here is the caller graph for this function:

Definition at line 484 of file game_config.cpp.

{
    INIT_PARAM_STRING( 
       data_dir, DATA_DIR, 
       "# The location of the ET Racer data files" );

       INIT_PARAM_BOOL( 
       stencil_buffer, false, 
       "# Set this to true to activate the stencil buffer" );
       
       INIT_PARAM_BOOL( 
       enable_fsaa, false, 
       "# Set this to true to activate FSAA" );

       INIT_PARAM_INT( 
       multisamples, 2,
       "# Set multisamples for FSAA" );
       
    INIT_PARAM_BOOL( 
       draw_tux_shadow, false, 
       "# Set this to true to display Tux's shadow.  Note that this is a \n"
       "# hack and is quite expensive in terms of framerate.\n"
       "# [EXPERT] This looks better if your card has a stencil buffer; \n"
       "# if compiling use the --enable-stencil-buffer configure option \n"
       "# to enable the use of the stencil buffer" );
       
       

    INIT_PARAM_BOOL( 
       draw_particles, true,
       "# Controls the drawing of snow particles that are kicked up as Tux\n"
       "# turns and brakes.  Setting this to false should help improve \n"
       "# performance." );

    INIT_PARAM_INT( 
       tux_sphere_divisions, 15,
       "# [EXPERT] Higher values result in a more finely subdivided mesh \n"
       "# for Tux, and vice versa.  If you're experiencing low framerates,\n"
       "# try lowering this value." );

    INIT_PARAM_INT( 
       tux_shadow_sphere_divisions, 3,
       "# [EXPERT] The level of subdivision of Tux's shadow." );

    INIT_PARAM_BOOL( 
       nice_fog, false,
       "# [EXPERT] If true, then the GL_NICEST hint will be used when\n"
       "# rendering fog.  On some cards, setting this to false may improve\n"
       "# performance.");

    INIT_PARAM_BOOL( 
       use_sphere_display_list, true,
       "# [EXPERT]  Mesa 3.1 sometimes renders Tux strangely when display \n"
       "# lists are used.  Setting this to false should solve the problem \n"
       "# at the cost of a few Hz." );

    INIT_PARAM_BOOL( 
       display_fps, false,
       "# Set this to true to display the current framerate in Hz." );

    INIT_PARAM_BOOL( 
       display_course_percentage, true,
       "# Set this to true to display a progressbar of \n"
       "# the course percentage." );

    INIT_PARAM_INT( 
       x_resolution, 800,
       "# The horizontal size of the Tux Racer window" );

    INIT_PARAM_INT( 
       y_resolution, 600,
       "# The vertical size of the Tux Racer window" );

       INIT_PARAM_BOOL( 
       x_resolution_half_width, false, 
       "# Set this to true to use only half of the resolution width" );

    INIT_PARAM_BOOL( 
       capture_mouse, false,
       "# If true, then the mouse will not be able to leave the \n"
       "# Tux Racer window.\n"
       "# If you lose keyboard focus while running Tux Racer, try setting\n"
       "# this to true." );

    INIT_PARAM_BOOL( 
       do_intro_animation, true,
       "# If false, then the introductory animation sequence will be skipped." 
       );

    INIT_PARAM_INT( 
       mipmap_type, 5,
       "# [EXPERT] Allows you to control which type of texture\n"
       "# interpolation/mipmapping is used when rendering textures.  The\n"
       "# values correspond to the following OpenGL settings:\n"
       "#\n"
        "#  0: GL_NEAREST\n"
        "#  1: GL_LINEAR\n"
        "#  2: GL_NEAREST_MIPMAP_NEAREST\n"
       "#  3: GL_LINEAR_MIPMAP_NEAREST\n"
        "#  4: GL_NEAREST_MIPMAP_LINEAR\n"
        "#  5: GL_LINEAR_MIPMAP_LINEAR\n"
       "#\n"
       "# On some cards, you may be able to improve performance by\n"
        "# decreasing this number, at the cost of lower image quality." );

    INIT_PARAM_BOOL( 
       fullscreen, true,
       "# If true then the game will run in full-screen mode." );

    INIT_PARAM_INT( 
       bpp_mode, 0,
       "# Controls how many bits per pixel are used in the game.\n"
       "# Valid values are:\n"
       "#\n"
       "#  0: Use current bpp setting of operating system\n"
       "#  1: 16 bpp\n"
       "#  2: 32 bpp\n"
       "# Note that some cards (e.g., Voodoo1, Voodoo2, Voodoo3) only support\n"
       "# 16 bits per pixel." );

    INIT_PARAM_BOOL( 
       force_window_position, false ,
       "# If true, then the Tux Racer window will automatically be\n"
       "# placed at (0,0)" );

    INIT_PARAM_INT( 
       ode_solver, 2 ,
       "# Selects the ODE (ordinary differential equation) solver.  \n"
       "# Possible values are:\n"
       "#\n"
       "#   0: Modified Euler     (fastest but least accurate)\n"
        "#   1: Runge-Kutta (2,3)\n"
       "#   2: Runge-Kutta (4,5)  (slowest but most accurate)" );

    INIT_PARAM_STRING( 
       quit_key, "q escape" ,
       "# Key binding for quitting a race" );
    INIT_PARAM_INT( 
       turn_left_key, SDLK_LEFT ,
       "# Key binding for turning left" );
    INIT_PARAM_INT( 
       turn_right_key, SDLK_RIGHT ,
       "# Key binding for turning right" );
    INIT_PARAM_INT( 
       trick_modifier_key, 't' ,
       "# Key binding for doing tricks" );
    INIT_PARAM_INT( 
       brake_key, SDLK_DOWN ,
       "# Key binding for braking" );
    INIT_PARAM_INT( 
       paddle_key, SDLK_UP ,
       "# Key binding for paddling (on the ground) and flapping (in the air)" 
       );
    INIT_PARAM_STRING( 
       follow_view_key, "1" ,
       "# Key binding for the \"Follow\" camera mode" );
    INIT_PARAM_STRING( 
       behind_view_key, "2" ,
       "# Key binding for the \"Behind\" camera mode" );
    INIT_PARAM_STRING( 
       above_view_key, "3" ,
       "# Key binding for the \"Above\" camera mode" );
    INIT_PARAM_INT( 
       view_mode, 1 ,
       "# Default view mode. Possible values are\n" 
       "#\n"
       "#   0: Behind\n"
       "#   1: Follow\n"
       "#   2: Above" );
    INIT_PARAM_STRING( 
       screenshot_key, "=" ,
       "# Key binding for taking a screenshot" );
    INIT_PARAM_STRING( 
       pause_key, "p" ,
       "# Key binding for pausing the game" );
    INIT_PARAM_INT( 
       reset_key, 'r' ,
       "# Key binding for resetting the player position" );
    INIT_PARAM_INT( 
       jump_key, 'e' ,
       "# Key binding for jumping" );

    INIT_PARAM_INT( 
       joystick_paddle_button, 0 ,
       "# Joystick button for paddling (numbering starts at 0).\n" 
       "# Set to -1 to disable." );

    INIT_PARAM_INT( 
       joystick_brake_button, 2 ,
       "# Joystick button for braking (numbering starts at 0).\n" 
       "# Set to -1 to disable." );

    INIT_PARAM_INT( 
       joystick_jump_button, 3 ,
       "# Joystick button for jumping (numbering starts at 0)" );

    INIT_PARAM_INT( 
       joystick_trick_button, 1 ,
       "# Joystick button for doing tricks (numbering starts at 0)" );

    INIT_PARAM_INT( 
       joystick_continue_button, 0 ,
       "# Joystick button for moving past intro, paused, and \n"
       "# game over screens (numbering starts at 0)" );
    
    INIT_PARAM_INT(
       joystick_x_axis, 0 ,
       "# Joystick axis to use for turning (numbering starts at 0)" );

    INIT_PARAM_INT(
       joystick_y_axis, 1 ,
       "# Joystick axis to use for paddling/braking (numbering starts at 0)" );
   
       INIT_PARAM_BOOL(
       disable_joystick, false ,
       "# Disables the joystick support" );

    INIT_PARAM_INT( 
       fov, 60 ,
       "# [EXPERT] Sets the camera field-of-view" );
    INIT_PARAM_STRING( 
       debug, "" ,
       "# [EXPERT] Controls the Tux Racer debugging modes" );
    INIT_PARAM_INT( 
       warning_level, 100 ,
       "# [EXPERT] Controls the Tux Racer warning messages" );
    INIT_PARAM_INT( 
       forward_clip_distance, 100 ,
       "# Controls how far ahead of the camera the course\n"
       "# is rendered.  Larger values mean that more of the course is\n"
       "# rendered, resulting in slower performance. Decreasing this \n"
       "# value is an effective way to improve framerates." );
    INIT_PARAM_INT( 
       backward_clip_distance, 10 ,
       "# [EXPERT] Some objects aren't yet clipped to the view frustum, \n"
       "# so this value is used to control how far up the course these \n"
       "# objects are drawn." );
    INIT_PARAM_INT( 
       tree_detail_distance, 20 ,
       "# [EXPERT] Controls the distance at which trees are drawn with \n"
       "# two rectangles instead of one." );
    INIT_PARAM_BOOL( 
       terrain_blending, true ,
       "# Controls the blending of the terrain textures.  Setting this\n"
       "# to false will help improve performance." );
    INIT_PARAM_BOOL( 
       perfect_terrain_blending, false ,
       "# [EXPERT] If true, then terrain triangles with three different\n"
       "# terrain types at the vertices will be blended correctly\n"
       "# (instead of using a faster but imperfect approximation)." );
    INIT_PARAM_BOOL( 
       terrain_envmap, true ,
       "# If true, then the ice will be drawn with an \"environment map\",\n"
       "# which gives the ice a shiny appearance.  Setting this to false\n"
       "# will help improve performance." );
    INIT_PARAM_BOOL( 
       disable_fog, false ,
       "# If true, then fog will be turned off.  Some Linux drivers for the\n"
       "# ATI Rage128 seem to have a bug in their fog implementation which\n"
       "# makes the screen nearly pure white when racing; if you experience\n"
       "# this problem then set this variable to true." );
    INIT_PARAM_BOOL( 
       use_cva, true ,
       "# [EXPERT] If true, then compiled vertex arrays will be used when\n"
       "# drawing the terrain.  Whether or not this helps performance\n"
       "# is driver- and card-dependent." );
    INIT_PARAM_BOOL( 
       cva_hack, true ,
       "# Some card/driver combinations render the terrrain incorrectly\n"
       "# when using compiled vertex arrays.  This activates a hack \n"
       "# to work around that problem." );
    INIT_PARAM_INT( 
       course_detail_level, 75 ,
       "# [EXPERT] This controls how accurately the course terrain is \n"
       "# rendered. A high value results in greater accuracy at the cost of \n"
       "# performance, and vice versa.  This value can be decreased and \n"
       "# increased in 10% increments at runtime using the F9 and F10 keys.\n"
       "# To better see the effect, activate wireframe mode using the F11 \n"
       "# key (this is a toggle)." );
    INIT_PARAM_BOOL( 
       no_audio, false ,
       "# If true, then audio in the game is completely disabled." );
    INIT_PARAM_BOOL( 
       sound_enabled, true ,
       "# Use this to turn sound effects on and off." );
    INIT_PARAM_BOOL( 
       music_enabled, true ,
       "# Use this to turn music on and off." );
    INIT_PARAM_INT( 
       sound_volume, 64 ,
       "# This controls the sound volume (valid range is 0-127)." );
    INIT_PARAM_INT( 
       music_volume, 127 ,
       "# This controls the music volume (valid range is 0-127)." );
    INIT_PARAM_INT( 
       audio_freq_mode, 1 ,
       "# The controls the frequency of the audio.  Valid values are:\n"
       "# \n"
       "#   0: 11025 Hz\n"
       "#   1: 22050 Hz\n"
       "#   2: 44100 Hz" );
    INIT_PARAM_INT( 
       audio_format_mode, 1 ,
       "# This controls the number of bits per sample for the audio.\n"
       "# Valid values are:\n"
       "#\n"
       "#   0: 8 bits\n"
       "#   1: 16 bits" );
    INIT_PARAM_BOOL( 
       audio_stereo, true ,
       "# Audio will be played in stereo of true, and mono if false" );
    INIT_PARAM_INT( 
       audio_buffer_size, 2048 ,
       "# [EXPERT] Controls the size of the audio buffer.  \n"
       "# Increase the buffer size if you experience choppy audio\n" 
       "# (at the cost of greater audio latency)" );
    INIT_PARAM_BOOL( 
       track_marks, true ,
       "# If true, then the players will leave track marks in the snow." );
    INIT_PARAM_BOOL( 
       ui_snow, true ,
       "# If true, then the ui screens will have falling snow." );

    INIT_PARAM_BOOL( 
       write_diagnostic_log, false ,
       "# If true, then a file called diagnostic_log.txt will be generated\n" 
       "# which you should attach to any bug reports you make.\n"
       "# To generate the file, set this variable to \"true\", and\n"
       "# then run the game so that you reproduce the bug, if possible."
       );
       
    INIT_PARAM_BOOL( 
       always_save_event_race_data, false ,
       "# only for cheating purpose"
       );     
       
       INIT_PARAM_BOOL( 
       disable_collision_detection, false ,
       "# If true, collision detection with tree models is disabled"
       );
       
       INIT_PARAM_BOOL( 
       disable_videomode_autodetection, false, 
       "# Set this to true disable the autodetection\n"
       "# for available video modes." );
              
       INIT_PARAM_BOOL(
       disable_background, false,
       "# Set this to completely remove the background (skybox)\n"
       "# This option would improve the performance." );
       
       INIT_PARAM_STRING( 
       ui_language, "en_GB" ,
       "# set the language for the ui"
       );
       
}

Here is the call graph for this function:

Here is the caller graph for this function:

PROTO_PARAM_BOOL ( nice_fog  )
PROTO_PARAM_BOOL ( use_sphere_display_list  )
PROTO_PARAM_BOOL ( display_fps  )
PROTO_PARAM_BOOL ( display_course_percentage  )
PROTO_PARAM_BOOL ( x_resolution_half_width  )
PROTO_PARAM_BOOL ( capture_mouse  )
PROTO_PARAM_BOOL ( do_intro_animation  )
PROTO_PARAM_BOOL ( fullscreen  )
PROTO_PARAM_BOOL ( force_window_position  )
PROTO_PARAM_BOOL ( terrain_blending  )
PROTO_PARAM_BOOL ( perfect_terrain_blending  )
PROTO_PARAM_BOOL ( terrain_envmap  )
PROTO_PARAM_BOOL ( disable_fog  )
PROTO_PARAM_BOOL ( use_cva  )
PROTO_PARAM_BOOL ( cva_hack  )
PROTO_PARAM_BOOL ( no_audio  )
PROTO_PARAM_BOOL ( sound_enabled  )
PROTO_PARAM_BOOL ( music_enabled  )
PROTO_PARAM_BOOL ( audio_stereo  )
PROTO_PARAM_BOOL ( ui_snow  )
PROTO_PARAM_BOOL ( write_diagnostic_log  )
PROTO_PARAM_BOOL ( stencil_buffer  )
PROTO_PARAM_BOOL ( enable_fsaa  )
PROTO_PARAM_BOOL ( always_save_event_race_data  )
PROTO_PARAM_BOOL ( disable_collision_detection  )
PROTO_PARAM_BOOL ( disable_joystick  )
PROTO_PARAM_BOOL ( disable_videomode_autodetection  )
PROTO_PARAM_BOOL ( disable_background  )
PROTO_PARAM_INT ( tux_sphere_divisions  )
PROTO_PARAM_INT ( tux_shadow_sphere_divisions  )
PROTO_PARAM_INT ( x_resolution  )
PROTO_PARAM_INT ( y_resolution  )
PROTO_PARAM_INT ( mipmap_type  )
PROTO_PARAM_INT ( bpp_mode  )
PROTO_PARAM_INT ( ode_solver  )
PROTO_PARAM_INT ( turn_left_key  )
PROTO_PARAM_INT ( turn_right_key  )
PROTO_PARAM_INT ( trick_modifier_key  )
PROTO_PARAM_INT ( brake_key  )
PROTO_PARAM_INT ( paddle_key  )
PROTO_PARAM_INT ( view_mode  )
PROTO_PARAM_INT ( reset_key  )
PROTO_PARAM_INT ( jump_key  )
PROTO_PARAM_INT ( joystick_jump_button  )
PROTO_PARAM_INT ( joystick_brake_button  )
PROTO_PARAM_INT ( joystick_paddle_button  )
PROTO_PARAM_INT ( joystick_trick_button  )
PROTO_PARAM_INT ( joystick_continue_button  )
PROTO_PARAM_INT ( joystick_x_axis  )
PROTO_PARAM_INT ( joystick_y_axis  )
PROTO_PARAM_INT ( fov  )
PROTO_PARAM_INT ( warning_level  )
PROTO_PARAM_INT ( forward_clip_distance  )
PROTO_PARAM_INT ( backward_clip_distance  )
PROTO_PARAM_INT ( tree_detail_distance  )
PROTO_PARAM_INT ( course_detail_level  )
PROTO_PARAM_INT ( sound_volume  )
PROTO_PARAM_INT ( music_volume  )
PROTO_PARAM_INT ( audio_freq_mode  )
PROTO_PARAM_INT ( audio_format_mode  )
PROTO_PARAM_INT ( audio_buffer_size  )
PROTO_PARAM_STRING ( data_dir  )
PROTO_PARAM_STRING ( quit_key  )
PROTO_PARAM_STRING ( above_view_key  )
PROTO_PARAM_STRING ( behind_view_key  )
PROTO_PARAM_STRING ( eye_view_key  )
PROTO_PARAM_STRING ( follow_view_key  )
PROTO_PARAM_STRING ( screenshot_key  )
PROTO_PARAM_STRING ( pause_key  )
PROTO_PARAM_STRING ( debug  )
PROTO_PARAM_STRING ( ui_language  )
void read_config_file ( std::string &  file)

Definition at line 1014 of file game_config.cpp.

{
    char config_file[BUFF_LEN];
    char config_dir[BUFF_LEN];

    clear_config_cache();

       if( !file.empty()){
              if ( Tcl_EvalFile( tclInterp, FUCKTCL file.c_str() ) != TCL_OK ) {
              handle_error( 1, "error evalating %s: %s", file.c_str(),
                           Tcl_GetStringResult( tclInterp ) );
           }  
              sp_config_file = file.c_str();     
              return;
       }else{
              sp_config_file = NULL;
       }
       
    if ( get_config_file_name( config_file, sizeof( config_file ) ) != 0 ) {
              return;
    }
    if ( get_config_dir_name( config_dir, sizeof( config_dir ) ) != 0 ) {
              return;
    }

       

    if ( dir_exists( config_dir ) ) {
       if ( file_exists( config_file ) ) {
           /* File exists -- let's try to evaluate it. */
           if ( Tcl_EvalFile( tclInterp, config_file ) != TCL_OK ) {
              handle_error( 1, "error evalating %s: %s", config_file,
                           Tcl_GetStringResult( tclInterp ) );
           }
       }
       return;
    }

    /* File does not exist -- look for old version */
    if ( get_old_config_file_name( config_file, sizeof( config_file ) ) != 0 ) {
       return;
    }
    if ( !file_exists( config_file ) ) {
       return;
    }
    /* Old file exists -- let's try to evaluate it. */
    if ( Tcl_EvalFile( tclInterp, config_file ) != TCL_OK ) {
       handle_error( 1, "error evalating deprecated %s: %s", config_file,
                    Tcl_GetStringResult( tclInterp ) );
    } else {
       /* Remove old file and save info in new file location */
       remove(config_file);
       write_config_file();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void register_game_config_callbacks ( Tcl_Interp *  ip)

Definition at line 1312 of file game_config.cpp.

{
    Tcl_CreateCommand (ip, "tux_get_param", get_param_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_set_param", set_param_cb,   0,0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1070 of file game_config.cpp.

{
    FILE *config_stream;
    char config_file[BUFF_LEN];
    char config_dir[BUFF_LEN];
    struct param *parm;
    unsigned int i;
       
       if(sp_config_file==NULL){

    if ( get_config_file_name( config_file, sizeof( config_file ) ) != 0 ) {
       return;
    }
    if ( get_config_dir_name( config_dir, sizeof( config_dir ) ) != 0 ) {
       return;
    }

    if ( !dir_exists( config_dir ) ) {

#if defined(WIN32) && !defined(__CYGWIN__)
       if (mkdir( config_dir ) != 0) {
           return;
       }
#else
       if (mkdir( config_dir, 0775) != 0) {
           return;
       }
#endif

    }

    config_stream = fopen( config_file, "w" );
       if ( config_stream == NULL ) {
       print_warning( CRITICAL_WARNING, 
                     "couldn't open %s for writing: %s", 
                     config_file, strerror(errno) );
       return;
    }
       
       }else{
              std::cout << "Writing to custom config file: "
                              << sp_config_file << std::endl;
              config_stream = fopen( sp_config_file, "w" );
              if ( config_stream == NULL ) {
                     print_warning( CRITICAL_WARNING, 
                     "couldn't open %s for writing: %s", 
                     sp_config_file, strerror(errno) );
                     return;
       }
       }
       
    fprintf( config_stream, 
            "# PP Racer " VERSION " configuration file\n"
            "#\n"
       );

    for (i=0; i<sizeof(Params)/sizeof(struct param); i++) {
       parm = (struct param*)&Params + i;
       if ( parm->comment != NULL ) {
#ifdef __APPLE__
        // on mac, do not save data path, it's to be determined dynamically at runtime
        if( strcmp(parm->name, "data_dir") == 0) continue;
#endif
           fprintf( config_stream, "\n# %s\n#\n%s\n#\n", 
                   parm->name, parm->comment );
       }
       switch ( parm->type ) {
       case PARAM_STRING:
           fetch_param_string( parm );
           fprintf( config_stream, "set %s \"%s\"\n",
                   parm->name, parm->val.string_val );
           break;
       case PARAM_CHAR:
           fetch_param_char( parm );
           fprintf( config_stream, "set %s %c\n",
                   parm->name, parm->val.char_val );
           break;
       case PARAM_INT:
           fetch_param_int( parm );
           fprintf( config_stream, "set %s %d\n",
                   parm->name, parm->val.int_val );
           break;
       case PARAM_BOOL:
           fetch_param_bool( parm );
           fprintf( config_stream, "set %s %s\n",
                   parm->name, parm->val.bool_val ? "true" : "false" );
           break;
       default:
           code_not_reached();
       }
    }

    if ( fclose( config_stream ) != 0 ) {
       perror( "fclose" );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: