2005-07-24 14:12:37 +00:00
/* $Id$ */
2007-04-04 01:35:16 +00:00
/** @file settings.cpp
2006-04-22 00:10:38 +00:00
* All actions handling saving and loading of the settings / configuration goes on in this file .
* The file consists of four parts :
* < ol >
* < li > Parsing the configuration file ( openttd . cfg ) . This is achieved with the ini_ functions which
* handle various types , such as normal ' key = value ' pairs , lists and value combinations of
* lists , strings , integers , ' bit ' - masks and element selections .
* < li > Defining the data structures that go into the configuration . These include for example
* the _patches struct , but also network - settings , banlists , newgrf , etc . There are a lot
* of helper macros available for the various types , and also saving / loading of these settings
* in a savegame is handled inside these structures .
* < li > Handle reading and writing to the setting - structures from inside the game either from
* the console for example or through the gui with CMD_ functions .
* < li > Handle saving / loading of the PATS chunk inside the savegame .
* < / ol >
* @ see SettingDesc
* @ see SaveLoad
*/
2004-08-09 17:04:08 +00:00
# include "stdafx.h"
2005-06-02 19:30:21 +00:00
# include "openttd.h"
2005-08-06 14:59:54 +00:00
# include "currency.h"
2005-07-19 06:47:07 +00:00
# include "screenshot.h"
2005-07-21 18:44:27 +00:00
# include "variables.h"
2007-01-02 17:34:03 +00:00
# include "network/network.h"
2008-05-30 18:20:26 +00:00
# include "network/network_func.h"
2008-01-07 00:19:09 +00:00
# include "settings_internal.h"
2007-12-21 21:50:46 +00:00
# include "command_func.h"
2008-05-24 10:15:06 +00:00
# include "console_func.h"
2006-03-01 21:15:25 +00:00
# include "saveload.h"
2006-03-29 19:00:56 +00:00
# include "npf.h"
2006-05-27 16:12:16 +00:00
# include "yapf/yapf.h"
2006-04-22 13:17:13 +00:00
# include "newgrf.h"
2006-12-04 08:30:04 +00:00
# include "newgrf_config.h"
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
# include "genworld.h"
2006-11-17 19:31:44 +00:00
# include "rail.h"
2007-10-18 20:32:36 +00:00
# include "train.h"
2008-03-28 08:53:36 +00:00
# include "news_func.h"
2007-12-19 20:45:46 +00:00
# include "window_func.h"
2007-12-21 19:49:27 +00:00
# include "strings_func.h"
2007-12-27 13:35:39 +00:00
# include "vehicle_func.h"
2007-12-29 09:24:26 +00:00
# include "sound_func.h"
2008-01-07 14:02:26 +00:00
# include "core/alloc_func.hpp"
2008-09-30 20:51:04 +00:00
# include "company_func.h"
2008-05-04 21:53:36 +00:00
# include "rev.h"
2006-11-16 22:05:33 +00:00
# ifdef WITH_FREETYPE
# include "fontcache.h"
# endif
2007-06-05 10:40:29 +00:00
# include "spritecache.h"
2007-11-10 01:17:15 +00:00
# include "transparency.h"
2008-03-26 10:08:17 +00:00
# include "textbuf_gui.h"
2008-01-07 14:23:25 +00:00
# include "string_func.h"
2008-04-03 21:54:31 +00:00
# include "rail_gui.h"
2008-05-08 16:48:29 +00:00
# include "elrail_func.h"
2008-01-13 01:21:35 +00:00
# include "gui.h"
# include "town.h"
2008-01-13 21:41:24 +00:00
# include "video/video_driver.hpp"
# include "sound/sound_driver.hpp"
# include "music/music_driver.hpp"
# include "blitter/factory.hpp"
2008-08-31 08:46:43 +00:00
# include "gfxinit.h"
2008-06-03 18:35:58 +00:00
# include "gamelog.h"
2008-05-26 00:31:36 +00:00
# include "station_func.h"
2008-07-22 14:17:29 +00:00
# include "settings_func.h"
2008-08-24 13:50:31 +00:00
# include "ini_type.h"
2008-01-13 01:21:35 +00:00
# include "table/strings.h"
2004-08-09 17:04:08 +00:00
2008-05-29 15:13:28 +00:00
ClientSettings _settings_client ;
GameSettings _settings_game ;
GameSettings _settings_newgame ;
2006-03-02 02:22:15 +00:00
2006-04-22 13:17:13 +00:00
typedef const char * SettingListCallbackProc ( const IniItem * item , uint index ) ;
typedef void SettingDescProc ( IniFile * ini , const SettingDesc * desc , const char * grpname , void * object ) ;
typedef void SettingDescProcList ( IniFile * ini , const char * grpname , char * * list , uint len , SettingListCallbackProc proc ) ;
2006-05-27 16:12:16 +00:00
static bool IsSignedVarMemType ( VarType vt ) ;
2004-08-09 17:04:08 +00:00
2008-08-24 13:50:31 +00:00
/**
* Groups in openttd . cfg that are actually lists .
*/
static const char * _list_group_names [ ] = {
" bans " ,
" newgrf " ,
" servers " ,
NULL
2004-08-09 17:04:08 +00:00
} ;
2006-04-22 00:10:38 +00:00
/** Find the index value of a ONEofMANY type in a string seperated by |
2006-02-04 22:48:57 +00:00
* @ param many full domain of values the ONEofMANY setting can have
* @ param one the current value of the setting for which a value needs found
* @ param onelen force calculation of the * one parameter
* @ return the integer index of the full - list , or - 1 if not found */
2008-05-08 14:04:52 +00:00
static int lookup_oneofmany ( const char * many , const char * one , size_t onelen = 0 )
2004-08-09 17:04:08 +00:00
{
const char * s ;
int idx ;
2008-05-08 14:04:52 +00:00
if ( onelen = = 0 ) onelen = strlen ( one ) ;
2004-08-09 17:04:08 +00:00
2007-04-04 01:35:16 +00:00
/* check if it's an integer */
2004-08-09 17:04:08 +00:00
if ( * one > = ' 0 ' & & * one < = ' 9 ' )
return strtoul ( one , NULL , 0 ) ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
idx = 0 ;
2006-02-01 07:36:15 +00:00
for ( ; ; ) {
2007-04-04 01:35:16 +00:00
/* find end of item */
2004-08-09 17:04:08 +00:00
s = many ;
while ( * s ! = ' | ' & & * s ! = 0 ) s + + ;
2008-05-08 14:04:52 +00:00
if ( ( size_t ) ( s - many ) = = onelen & & ! memcmp ( one , many , onelen ) ) return idx ;
2004-08-09 17:04:08 +00:00
if ( * s = = 0 ) return - 1 ;
many = s + 1 ;
idx + + ;
}
}
2006-04-22 00:10:38 +00:00
/** Find the set-integer value MANYofMANY type in a string
2006-02-04 22:48:57 +00:00
* @ param many full domain of values the MANYofMANY setting can have
* @ param str the current string value of the setting , each individual
2007-04-17 21:09:38 +00:00
* of seperated by a whitespace , tab or | character
2006-02-04 22:48:57 +00:00
* @ return the ' fully ' set integer , or - 1 if a set is not found */
2004-08-09 17:04:08 +00:00
static uint32 lookup_manyofmany ( const char * many , const char * str )
{
const char * s ;
int r ;
uint32 res = 0 ;
2006-02-01 07:36:15 +00:00
for ( ; ; ) {
2007-04-04 01:35:16 +00:00
/* skip "whitespace" */
2004-08-09 17:04:08 +00:00
while ( * str = = ' ' | | * str = = ' \t ' | | * str = = ' | ' ) str + + ;
if ( * str = = 0 ) break ;
s = str ;
while ( * s ! = 0 & & * s ! = ' ' & & * s ! = ' \t ' & & * s ! = ' | ' ) s + + ;
r = lookup_oneofmany ( many , str , s - str ) ;
if ( r = = - 1 ) return ( uint32 ) - 1 ;
2007-11-20 13:35:54 +00:00
SetBit ( res , r ) ; // value found, set it
2004-08-09 17:04:08 +00:00
if ( * s = = 0 ) break ;
str = s + 1 ;
}
return res ;
}
2006-02-04 22:48:57 +00:00
/** Parse an integerlist string and set each found value
2006-04-22 00:10:38 +00:00
* @ param p the string to be parsed . Each element in the list is seperated by a
* comma or a space character
2006-02-04 22:48:57 +00:00
* @ param items pointer to the integerlist - array that will be filled with values
* @ param maxitems the maximum number of elements the integerlist - array has
* @ return returns the number of items found , or - 1 on an error */
2004-08-09 17:04:08 +00:00
static int parse_intlist ( const char * p , int * items , int maxitems )
{
int n = 0 , v ;
char * end ;
2006-02-01 07:36:15 +00:00
for ( ; ; ) {
2004-08-09 17:04:08 +00:00
v = strtol ( p , & end , 0 ) ;
if ( p = = end | | n = = maxitems ) return - 1 ;
p = end ;
items [ n + + ] = v ;
2006-04-20 22:08:20 +00:00
if ( * p = = ' \0 ' ) break ;
2006-04-20 22:09:12 +00:00
if ( * p ! = ' , ' & & * p ! = ' ' ) return - 1 ;
2004-08-09 17:04:08 +00:00
p + + ;
}
return n ;
}
2006-04-22 00:10:38 +00:00
/** Load parsed string-values into an integer-array (intlist)
2006-02-04 22:48:57 +00:00
* @ param str the string that contains the values ( and will be parsed )
* @ param array pointer to the integer - arrays that will be filled
* @ param nelems the number of elements the array holds . Maximum is 64 elements
* @ param type the type of elements the array holds ( eg INT8 , UINT16 , etc . )
* @ return return true on success and false on error */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
static bool load_intlist ( const char * str , void * array , int nelems , VarType type )
2004-08-09 17:04:08 +00:00
{
int items [ 64 ] ;
2006-02-04 22:48:57 +00:00
int i , nitems ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
if ( str = = NULL ) {
memset ( items , 0 , sizeof ( items ) ) ;
nitems = nelems ;
} else {
nitems = parse_intlist ( str , items , lengthof ( items ) ) ;
2006-02-04 22:48:57 +00:00
if ( nitems ! = nelems ) return false ;
2004-08-09 17:04:08 +00:00
}
2006-02-01 07:36:15 +00:00
switch ( type ) {
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SLE_VAR_BL :
case SLE_VAR_I8 :
case SLE_VAR_U8 :
2006-02-01 07:36:15 +00:00
for ( i = 0 ; i ! = nitems ; i + + ) ( ( byte * ) array ) [ i ] = items [ i ] ;
2004-08-09 17:04:08 +00:00
break ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SLE_VAR_I16 :
case SLE_VAR_U16 :
2006-02-01 07:36:15 +00:00
for ( i = 0 ; i ! = nitems ; i + + ) ( ( uint16 * ) array ) [ i ] = items [ i ] ;
2004-08-09 17:04:08 +00:00
break ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SLE_VAR_I32 :
case SLE_VAR_U32 :
2006-02-01 07:36:15 +00:00
for ( i = 0 ; i ! = nitems ; i + + ) ( ( uint32 * ) array ) [ i ] = items [ i ] ;
2004-08-09 17:04:08 +00:00
break ;
2006-02-04 22:48:57 +00:00
default : NOT_REACHED ( ) ;
2004-08-09 17:04:08 +00:00
}
return true ;
}
2006-04-22 00:10:38 +00:00
/** Convert an integer-array (intlist) to a string representation. Each value
* is seperated by a comma or a space character
2006-02-04 22:48:57 +00:00
* @ param buf output buffer where the string - representation will be stored
2008-10-28 14:42:31 +00:00
* @ param last last item to write to in the output buffer
2006-02-04 22:48:57 +00:00
* @ param array pointer to the integer - arrays that is read from
* @ param nelems the number of elements the array holds .
* @ param type the type of elements the array holds ( eg INT8 , UINT16 , etc . ) */
2008-10-28 14:42:31 +00:00
static void make_intlist ( char * buf , const char * last , const void * array , int nelems , VarType type )
2004-08-09 17:04:08 +00:00
{
int i , v = 0 ;
2006-02-04 22:48:57 +00:00
const byte * p = ( const byte * ) array ;
2006-02-01 07:36:15 +00:00
for ( i = 0 ; i ! = nelems ; i + + ) {
switch ( type ) {
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SLE_VAR_BL :
case SLE_VAR_I8 : v = * ( int8 * ) p ; p + = 1 ; break ;
case SLE_VAR_U8 : v = * ( byte * ) p ; p + = 1 ; break ;
case SLE_VAR_I16 : v = * ( int16 * ) p ; p + = 2 ; break ;
case SLE_VAR_U16 : v = * ( uint16 * ) p ; p + = 2 ; break ;
case SLE_VAR_I32 : v = * ( int32 * ) p ; p + = 4 ; break ;
case SLE_VAR_U32 : v = * ( uint32 * ) p ; p + = 4 ; break ;
2004-08-09 17:04:08 +00:00
default : NOT_REACHED ( ) ;
}
2008-10-28 14:42:31 +00:00
buf + = seprintf ( buf , last , ( i = = 0 ) ? " %d " : " ,%d " , v ) ;
2004-08-09 17:04:08 +00:00
}
}
2006-04-22 00:10:38 +00:00
/** Convert a ONEofMANY structure to a string representation.
2006-02-04 22:48:57 +00:00
* @ param buf output buffer where the string - representation will be stored
2008-10-28 14:42:31 +00:00
* @ param last last item to write to in the output buffer
2006-02-04 22:48:57 +00:00
* @ param many the full - domain string of possible values
* @ param id the value of the variable and whose string - representation must be found */
2008-10-28 14:42:31 +00:00
static void make_oneofmany ( char * buf , const char * last , const char * many , int id )
2004-08-09 17:04:08 +00:00
{
2006-02-04 22:52:30 +00:00
int orig_id = id ;
2007-04-04 01:35:16 +00:00
/* Look for the id'th element */
2006-02-04 22:52:30 +00:00
while ( - - id > = 0 ) {
for ( ; * many ! = ' | ' ; many + + ) {
if ( * many = = ' \0 ' ) { // not found
2008-10-28 14:42:31 +00:00
seprintf ( buf , last , " %d " , orig_id ) ;
2004-08-09 17:04:08 +00:00
return ;
}
2006-02-04 22:52:30 +00:00
}
many + + ; // pass the |-character
2004-08-09 17:04:08 +00:00
}
2007-04-04 01:35:16 +00:00
/* copy string until next item (|) or the end of the list if this is the last one */
2008-10-28 14:42:31 +00:00
while ( * many ! = ' \0 ' & & * many ! = ' | ' & & buf < last ) * buf + + = * many + + ;
2006-02-04 22:52:30 +00:00
* buf = ' \0 ' ;
2004-08-09 17:04:08 +00:00
}
2006-04-22 00:10:38 +00:00
/** Convert a MANYofMANY structure to a string representation.
2006-02-04 22:48:57 +00:00
* @ param buf output buffer where the string - representation will be stored
2008-10-28 14:42:31 +00:00
* @ param last last item to write to in the output buffer
2006-02-04 22:48:57 +00:00
* @ param many the full - domain string of possible values
* @ param x the value of the variable and whose string - representation must
* be found in the bitmasked many string */
2008-10-28 14:42:31 +00:00
static void make_manyofmany ( char * buf , const char * last , const char * many , uint32 x )
2004-08-09 17:04:08 +00:00
{
const char * start ;
int i = 0 ;
bool init = true ;
2006-02-04 22:52:30 +00:00
for ( ; x ! = 0 ; x > > = 1 , i + + ) {
2004-08-09 17:04:08 +00:00
start = many ;
2006-02-04 22:52:30 +00:00
while ( * many ! = 0 & & * many ! = ' | ' ) many + + ; // advance to the next element
2007-11-19 21:02:30 +00:00
if ( HasBit ( x , 0 ) ) { // item found, copy it
2008-10-28 14:42:31 +00:00
if ( ! init ) buf + = seprintf ( buf , last , " | " ) ;
2004-08-09 17:04:08 +00:00
init = false ;
if ( start = = many ) {
2008-10-28 14:42:31 +00:00
buf + = seprintf ( buf , last , " %d " , i ) ;
2004-08-09 17:04:08 +00:00
} else {
memcpy ( buf , start , many - start ) ;
buf + = many - start ;
}
}
2006-02-04 22:52:30 +00:00
2004-08-09 17:04:08 +00:00
if ( * many = = ' | ' ) many + + ;
2006-02-04 22:52:30 +00:00
}
* buf = ' \0 ' ;
2004-08-09 17:04:08 +00:00
}
2006-02-04 22:48:57 +00:00
/** Convert a string representation (external) of a setting to the internal rep.
* @ param desc SettingDesc struct that holds all information about the variable
* @ param str input string that will be parsed based on the type of desc
* @ return return the parsed value of the setting */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
static const void * string_to_val ( const SettingDescBase * desc , const char * str )
2006-02-04 22:48:57 +00:00
{
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
switch ( desc - > cmd ) {
2006-02-04 22:48:57 +00:00
case SDT_NUMX : {
char * end ;
2006-02-06 22:30:43 +00:00
unsigned long val = strtoul ( str , & end , 0 ) ;
2006-02-04 22:48:57 +00:00
if ( * end ! = ' \0 ' ) ShowInfoF ( " ini: trailing characters at end of setting '%s' " , desc - > name ) ;
2004-08-09 17:04:08 +00:00
return ( void * ) val ;
2006-02-04 22:48:57 +00:00
}
2004-08-09 17:04:08 +00:00
case SDT_ONEOFMANY : {
2008-05-08 14:04:52 +00:00
long r = lookup_oneofmany ( desc - > many , str ) ;
2007-03-22 03:35:18 +00:00
/* if the first attempt of conversion from string to the appropriate value fails,
* look if we have defined a converter from old value to new value . */
if ( r = = - 1 & & desc - > proc_cnvt ! = NULL ) r = desc - > proc_cnvt ( str ) ;
if ( r ! = - 1 ) return ( void * ) r ; //and here goes converted value
ShowInfoF ( " ini: invalid value '%s' for '%s' " , str , desc - > name ) ; //sorry, we failed
2004-08-09 17:04:08 +00:00
return 0 ;
}
case SDT_MANYOFMANY : {
2006-02-04 22:48:57 +00:00
unsigned long r = lookup_manyofmany ( desc - > many , str ) ;
2006-01-29 20:32:30 +00:00
if ( r ! = ( unsigned long ) - 1 ) return ( void * ) r ;
2004-08-09 17:04:08 +00:00
ShowInfoF ( " ini: invalid value '%s' for '%s' " , str , desc - > name ) ;
return 0 ;
}
case SDT_BOOLX :
2006-02-04 22:48:57 +00:00
if ( strcmp ( str , " true " ) = = 0 | | strcmp ( str , " on " ) = = 0 | | strcmp ( str , " 1 " ) = = 0 )
2004-08-09 17:04:08 +00:00
return ( void * ) true ;
2006-02-04 22:48:57 +00:00
if ( strcmp ( str , " false " ) = = 0 | | strcmp ( str , " off " ) = = 0 | | strcmp ( str , " 0 " ) = = 0 )
2004-08-09 17:04:08 +00:00
return ( void * ) false ;
ShowInfoF ( " ini: invalid setting value '%s' for '%s' " , str , desc - > name ) ;
break ;
2004-09-10 19:02:27 +00:00
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SDT_STRING :
case SDT_INTLIST : return str ;
2007-01-10 18:56:51 +00:00
default : break ;
2004-08-09 17:04:08 +00:00
}
return NULL ;
}
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
/** Set the value of a setting and if needed clamp the value to
* the preset minimum and maximum .
* @ param ptr the variable itself
* @ param sd pointer to the ' information ' - database of the variable
* @ param val signed long version of the new value
* @ pre SettingDesc is of type SDT_BOOLX , SDT_NUMX ,
* SDT_ONEOFMANY or SDT_MANYOFMANY . Other types are not supported as of now */
static void Write_ValidateSetting ( void * ptr , const SettingDesc * sd , int32 val )
{
const SettingDescBase * sdb = & sd - > desc ;
2006-06-27 21:25:53 +00:00
if ( sdb - > cmd ! = SDT_BOOLX & &
sdb - > cmd ! = SDT_NUMX & &
sdb - > cmd ! = SDT_ONEOFMANY & &
sdb - > cmd ! = SDT_MANYOFMANY ) {
return ;
}
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
/* We cannot know the maximum value of a bitset variable, so just have faith */
2006-03-28 21:51:14 +00:00
if ( sdb - > cmd ! = SDT_MANYOFMANY ) {
/* We need to take special care of the uint32 type as we receive from the function
* a signed integer . While here also bail out on 64 - bit settings as those are not
* supported . Unsigned 8 and 16 - bit variables are safe since they fit into a signed
* 32 - bit variable
* TODO : Support 64 - bit settings / variables */
switch ( GetVarMemType ( sd - > save . conv ) ) {
case SLE_VAR_BL :
case SLE_VAR_I8 :
case SLE_VAR_U8 :
case SLE_VAR_I16 :
case SLE_VAR_U16 :
case SLE_VAR_I32 : {
/* Override the minimum value. No value below sdb->min, except special value 0 */
int32 min = ( ( sdb - > flags & SGF_0ISDISABLED ) & & val < = sdb - > min ) ? 0 : sdb - > min ;
2007-11-19 18:38:10 +00:00
val = Clamp ( val , min , sdb - > max ) ;
2006-03-28 21:51:14 +00:00
} break ;
case SLE_VAR_U32 : {
/* Override the minimum value. No value below sdb->min, except special value 0 */
uint min = ( ( sdb - > flags & SGF_0ISDISABLED ) & & ( uint ) val < = ( uint ) sdb - > min ) ? 0 : sdb - > min ;
2007-11-19 18:38:10 +00:00
WriteValue ( ptr , SLE_VAR_U32 , ( int64 ) ClampU ( val , min , sdb - > max ) ) ;
2006-03-28 21:51:14 +00:00
return ;
}
case SLE_VAR_I64 :
case SLE_VAR_U64 :
default : NOT_REACHED ( ) ; break ;
}
}
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
WriteValue ( ptr , sd - > save . conv , ( int64 ) val ) ;
}
2006-02-04 22:48:57 +00:00
/** Load values from a group of an IniFile structure into the internal representation
* @ param ini pointer to IniFile structure that holds administrative information
2006-04-22 00:10:38 +00:00
* @ param sd pointer to SettingDesc structure whose internally pointed variables will
2006-02-04 22:48:57 +00:00
* be given values
2007-04-17 21:09:38 +00:00
* @ param grpname the group of the IniFile to search in for the new values
* @ param object pointer to the object been loaded */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
static void ini_load_settings ( IniFile * ini , const SettingDesc * sd , const char * grpname , void * object )
2004-08-09 17:04:08 +00:00
{
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
IniGroup * group ;
2008-08-24 13:50:31 +00:00
IniGroup * group_def = ini - > GetGroup ( grpname ) ;
2004-08-09 17:04:08 +00:00
IniItem * item ;
2004-09-12 21:49:38 +00:00
const void * p ;
2004-08-09 17:04:08 +00:00
void * ptr ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
const char * s ;
for ( ; sd - > save . cmd ! = SL_END ; sd + + ) {
const SettingDescBase * sdb = & sd - > desc ;
const SaveLoad * sld = & sd - > save ;
2004-08-09 17:04:08 +00:00
2006-03-02 00:32:48 +00:00
if ( ! SlIsObjectCurrentlyValid ( sld - > version_from , sld - > version_to ) ) continue ;
2008-05-25 19:17:03 +00:00
/* For patches.xx.yy load the settings from [xx] yy = ? */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
s = strchr ( sdb - > name , ' . ' ) ;
2006-02-04 22:48:57 +00:00
if ( s ! = NULL ) {
2008-08-24 13:50:31 +00:00
group = ini - > GetGroup ( sdb - > name , s - sdb - > name ) ;
2004-08-09 17:04:08 +00:00
s + + ;
} else {
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
s = sdb - > name ;
2004-08-09 17:04:08 +00:00
group = group_def ;
}
2004-09-10 19:02:27 +00:00
2008-08-24 13:50:31 +00:00
item = group - > GetItem ( s , false ) ;
2008-05-25 19:17:03 +00:00
if ( item = = NULL & & group ! = group_def ) {
/* For patches.xx.yy load the settings from [patches] yy = ? in case the previous
* did not exist ( e . g . loading old config files with a [ patches ] section */
2008-08-24 13:50:31 +00:00
item = group_def - > GetItem ( s , false ) ;
2008-05-25 19:17:03 +00:00
}
if ( item = = NULL ) {
/* For patches.xx.zz.yy load the settings from [zz] yy = ? in case the previous
* did not exist ( e . g . loading old config files with a [ yapf ] section */
const char * sc = strchr ( s , ' . ' ) ;
2008-08-24 13:50:31 +00:00
if ( sc ! = NULL ) item = ini - > GetGroup ( s , sc - s ) - > GetItem ( sc + 1 , false ) ;
2008-05-25 19:17:03 +00:00
}
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
p = ( item = = NULL ) ? sdb - > def : string_to_val ( sdb , item - > value ) ;
2008-05-29 15:13:28 +00:00
ptr = GetVariableAddress ( object , sld ) ;
2004-09-10 19:02:27 +00:00
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
switch ( sdb - > cmd ) {
2006-02-04 22:48:57 +00:00
case SDT_BOOLX : /* All four are various types of (integer) numbers */
case SDT_NUMX :
2004-08-09 17:04:08 +00:00
case SDT_ONEOFMANY :
case SDT_MANYOFMANY :
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
Write_ValidateSetting ( ptr , sd , ( unsigned long ) p ) ; break ;
2005-08-07 14:18:17 +00:00
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SDT_STRING :
switch ( GetVarMemType ( sld - > conv ) ) {
case SLE_VAR_STRB :
2006-08-12 22:56:45 +00:00
case SLE_VAR_STRBQ :
2007-01-10 18:56:51 +00:00
if ( p ! = NULL ) ttd_strlcpy ( ( char * ) ptr , ( const char * ) p , sld - > length ) ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
break ;
2006-08-12 22:56:45 +00:00
case SLE_VAR_STR :
case SLE_VAR_STRQ :
if ( p ! = NULL ) {
free ( * ( char * * ) ptr ) ;
* ( char * * ) ptr = strdup ( ( const char * ) p ) ;
}
break ;
2006-03-13 23:10:02 +00:00
case SLE_VAR_CHAR : * ( char * ) ptr = * ( char * ) p ; break ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
default : NOT_REACHED ( ) ; break ;
}
2005-08-07 14:18:17 +00:00
break ;
2004-08-09 17:04:08 +00:00
case SDT_INTLIST : {
2008-05-24 02:54:47 +00:00
if ( ! load_intlist ( ( const char * ) p , ptr , sld - > length , GetVarMemType ( sld - > conv ) ) ) {
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
ShowInfoF ( " ini: error in array '%s' " , sdb - > name ) ;
2008-05-24 02:54:47 +00:00
} else if ( sd - > desc . proc_cnvt ! = NULL ) {
sd - > desc . proc_cnvt ( ( const char * ) p ) ;
}
2004-08-09 17:04:08 +00:00
break ;
}
2006-02-04 22:48:57 +00:00
default : NOT_REACHED ( ) ; break ;
2004-08-09 17:04:08 +00:00
}
2004-09-10 19:02:27 +00:00
}
2004-08-09 17:04:08 +00:00
}
2006-04-22 00:10:38 +00:00
/** Save the values of settings to the inifile.
2006-02-04 22:48:57 +00:00
* @ param ini pointer to IniFile structure
2006-04-22 00:10:38 +00:00
* @ param sd read - only SettingDesc structure which contains the unmodified ,
2006-02-04 22:48:57 +00:00
* loaded values of the configuration file and various information about it
* @ param grpname holds the name of the group ( eg . [ network ] ) where these will be saved
2007-04-17 21:09:38 +00:00
* @ param object pointer to the object been saved
2006-06-10 08:37:41 +00:00
* The function works as follows : for each item in the SettingDesc structure we
* have a look if the value has changed since we started the game ( the original
* values are reloaded when saving ) . If settings indeed have changed , we get
* these and save them .
*/
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
static void ini_save_settings ( IniFile * ini , const SettingDesc * sd , const char * grpname , void * object )
2004-08-09 17:04:08 +00:00
{
IniGroup * group_def = NULL , * group ;
IniItem * item ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
char buf [ 512 ] ;
2004-08-09 17:04:08 +00:00
const char * s ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
void * ptr ;
2004-08-09 17:04:08 +00:00
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
for ( ; sd - > save . cmd ! = SL_END ; sd + + ) {
const SettingDescBase * sdb = & sd - > desc ;
const SaveLoad * sld = & sd - > save ;
/* If the setting is not saved to the configuration
* file , just continue with the next setting */
2006-03-02 00:32:48 +00:00
if ( ! SlIsObjectCurrentlyValid ( sld - > version_from , sld - > version_to ) ) continue ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
if ( sld - > conv & SLF_CONFIG_NO ) continue ;
2004-09-10 19:02:27 +00:00
2007-04-04 01:35:16 +00:00
/* XXX - wtf is this?? (group override?) */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
s = strchr ( sdb - > name , ' . ' ) ;
2006-02-04 22:48:57 +00:00
if ( s ! = NULL ) {
2008-08-24 13:50:31 +00:00
group = ini - > GetGroup ( sdb - > name , s - sdb - > name ) ;
2004-08-09 17:04:08 +00:00
s + + ;
} else {
2008-08-24 13:50:31 +00:00
if ( group_def = = NULL ) group_def = ini - > GetGroup ( grpname ) ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
s = sdb - > name ;
2004-08-09 17:04:08 +00:00
group = group_def ;
}
2004-09-10 19:02:27 +00:00
2008-08-24 13:50:31 +00:00
item = group - > GetItem ( s , true ) ;
2006-11-21 20:20:30 +00:00
ptr = GetVariableAddress ( object , sld ) ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
if ( item - > value ! = NULL ) {
2007-04-04 01:35:16 +00:00
/* check if the value is the same as the old value */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
const void * p = string_to_val ( sdb , item - > value ) ;
2004-08-09 17:04:08 +00:00
2006-02-04 22:48:57 +00:00
/* The main type of a variable/setting is in bytes 8-15
2006-09-04 20:40:33 +00:00
* The subtype ( what kind of numbers do we have there ) is in 0 - 7 */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
switch ( sdb - > cmd ) {
2006-02-04 22:48:57 +00:00
case SDT_BOOLX :
case SDT_NUMX :
2004-08-09 17:04:08 +00:00
case SDT_ONEOFMANY :
case SDT_MANYOFMANY :
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
switch ( GetVarMemType ( sld - > conv ) ) {
case SLE_VAR_BL :
2007-01-10 18:56:51 +00:00
if ( * ( bool * ) ptr = = ( p ! = NULL ) ) continue ;
2006-11-10 11:45:50 +00:00
break ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SLE_VAR_I8 :
case SLE_VAR_U8 :
2006-02-04 22:48:57 +00:00
if ( * ( byte * ) ptr = = ( byte ) ( unsigned long ) p ) continue ;
2004-08-09 17:04:08 +00:00
break ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SLE_VAR_I16 :
case SLE_VAR_U16 :
2006-02-04 22:48:57 +00:00
if ( * ( uint16 * ) ptr = = ( uint16 ) ( unsigned long ) p ) continue ;
2004-08-09 17:04:08 +00:00
break ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SLE_VAR_I32 :
case SLE_VAR_U32 :
2006-02-04 22:48:57 +00:00
if ( * ( uint32 * ) ptr = = ( uint32 ) ( unsigned long ) p ) continue ;
2004-08-09 17:04:08 +00:00
break ;
2006-02-04 22:48:57 +00:00
default : NOT_REACHED ( ) ;
2004-08-09 17:04:08 +00:00
}
break ;
2006-02-04 22:48:57 +00:00
default : break ; /* Assume the other types are always changed */
2004-08-09 17:04:08 +00:00
}
}
2006-02-04 22:48:57 +00:00
/* Value has changed, get the new value and put it into a buffer */
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
switch ( sdb - > cmd ) {
2006-02-04 22:48:57 +00:00
case SDT_BOOLX :
case SDT_NUMX :
2004-08-09 17:04:08 +00:00
case SDT_ONEOFMANY :
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SDT_MANYOFMANY : {
uint32 i = ( uint32 ) ReadValue ( ptr , sld - > conv ) ;
switch ( sdb - > cmd ) {
case SDT_BOOLX : strcpy ( buf , ( i ! = 0 ) ? " true " : " false " ) ; break ;
2008-10-28 14:42:31 +00:00
case SDT_NUMX : seprintf ( buf , lastof ( buf ) , IsSignedVarMemType ( sld - > conv ) ? " %d " : " %u " , i ) ; break ;
case SDT_ONEOFMANY : make_oneofmany ( buf , lastof ( buf ) , sdb - > many , i ) ; break ;
case SDT_MANYOFMANY : make_manyofmany ( buf , lastof ( buf ) , sdb - > many , i ) ; break ;
2006-02-04 22:48:57 +00:00
default : NOT_REACHED ( ) ;
2004-08-09 17:04:08 +00:00
}
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
} break ;
2006-02-04 22:48:57 +00:00
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
case SDT_STRING :
switch ( GetVarMemType ( sld - > conv ) ) {
case SLE_VAR_STRB : strcpy ( buf , ( char * ) ptr ) ; break ;
2008-10-28 14:42:31 +00:00
case SLE_VAR_STRBQ : seprintf ( buf , lastof ( buf ) , " \" %s \" " , ( char * ) ptr ) ; break ;
2006-08-12 22:56:45 +00:00
case SLE_VAR_STR : strcpy ( buf , * ( char * * ) ptr ) ; break ;
2008-10-28 14:42:31 +00:00
case SLE_VAR_STRQ : seprintf ( buf , " \" %s \" " , lastof ( buf ) , * ( char * * ) ptr ) ; break ;
case SLE_VAR_CHAR : seprintf ( buf , " \" %c \" " , lastof ( buf ) , * ( char * ) ptr ) ; break ;
2006-02-04 22:48:57 +00:00
default : NOT_REACHED ( ) ;
2004-08-09 17:04:08 +00:00
}
break ;
2006-02-04 22:48:57 +00:00
case SDT_INTLIST :
2008-10-28 14:42:31 +00:00
make_intlist ( buf , lastof ( buf ) , ptr , sld - > length , GetVarMemType ( sld - > conv ) ) ;
2006-02-04 22:48:57 +00:00
break ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
default : NOT_REACHED ( ) ;
2004-08-09 17:04:08 +00:00
}
2006-02-04 22:48:57 +00:00
/* The value is different, that means we have to write it to the ini */
2008-08-24 13:50:31 +00:00
free ( item - > value ) ;
item - > value = strdup ( buf ) ;
2004-09-10 19:02:27 +00:00
}
2004-08-09 17:04:08 +00:00
}
2006-04-22 00:10:38 +00:00
/** Loads all items from a 'grpname' section into a list
* The list parameter can be a NULL pointer , in this case nothing will be
* saved and a callback function should be defined that will take over the
* list - handling and store the data itself somewhere .
2007-04-17 21:09:38 +00:00
* @ param ini IniFile handle to the ini file with the source data
2006-04-22 00:10:38 +00:00
* @ param grpname character string identifying the section - header of the ini
* file that will be parsed
* @ param list pointer to an string ( pointer ) array that will store the parsed
* entries of the given section
2006-04-22 13:17:13 +00:00
* @ param len the maximum number of items available for the above list
* @ param proc callback function that can override how the values are stored
* inside the list */
static void ini_load_setting_list ( IniFile * ini , const char * grpname , char * * list , uint len , SettingListCallbackProc proc )
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
{
2008-08-24 13:50:31 +00:00
IniGroup * group = ini - > GetGroup ( grpname ) ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
IniItem * item ;
2006-04-22 13:17:13 +00:00
const char * entry ;
uint i , j ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
if ( group = = NULL ) return ;
2006-04-22 13:17:13 +00:00
for ( i = j = 0 , item = group - > item ; item ! = NULL ; item = item - > next ) {
entry = ( proc ! = NULL ) ? proc ( item , i + + ) : item - > name ;
if ( entry = = NULL | | list = = NULL ) continue ;
if ( j = = len ) break ;
list [ j + + ] = strdup ( entry ) ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
}
}
2006-04-22 00:10:38 +00:00
/** Saves all items from a list into the 'grpname' section
* The list parameter can be a NULL pointer , in this case a callback function
* should be defined that will provide the source data to be saved .
2007-04-18 18:00:33 +00:00
* @ param ini IniFile handle to the ini file where the destination data is saved
2006-04-22 00:10:38 +00:00
* @ param grpname character string identifying the section - header of the ini file
* @ param list pointer to an string ( pointer ) array that will be used as the
2007-04-18 18:00:33 +00:00
* source to be saved into the relevant ini section
2006-04-22 00:10:38 +00:00
* @ param len the maximum number of items available for the above list
* @ param proc callback function that can will provide the source data if defined */
2006-04-22 13:17:13 +00:00
static void ini_save_setting_list ( IniFile * ini , const char * grpname , char * * list , uint len , SettingListCallbackProc proc )
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
{
2008-08-24 13:50:31 +00:00
IniGroup * group = ini - > GetGroup ( grpname ) ;
2006-04-22 13:17:13 +00:00
const char * entry ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
uint i ;
2006-04-22 13:17:13 +00:00
if ( proc = = NULL & & list = = NULL ) return ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
if ( group = = NULL ) return ;
group - > item = NULL ;
for ( i = 0 ; i ! = len ; i + + ) {
2006-04-22 13:17:13 +00:00
entry = ( proc ! = NULL ) ? proc ( NULL , i ) : list [ i ] ;
if ( entry = = NULL | | * entry = = ' \0 ' ) continue ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
2008-08-25 15:15:41 +00:00
group - > GetItem ( entry , true ) - > SetValue ( " " ) ;
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
}
}
2004-08-09 17:04:08 +00:00
//***************************
2006-02-04 22:48:57 +00:00
// OTTD specific INI stuff
2004-08-09 17:04:08 +00:00
//***************************
2006-03-02 00:07:41 +00:00
/** Settings-macro usage:
* The list might look daunting at first , but is in general easy to understand .
* We have two types of list :
* 1. SDTG_something
* 2. SDT_something
2006-06-10 08:37:41 +00:00
* The ' G ' stands for global , so this is the one you will use for a
* SettingDescGlobVarList section meaning global variables . The other uses a
2007-04-12 18:36:54 +00:00
* Base / Offset and runtime variable selection mechanism , known from the saveload
* convention ( it also has global so it should not be hard ) .
2006-06-10 08:37:41 +00:00
* Of each type there are again two versions , the normal one and one prefixed
* with ' COND ' .
* COND means that the setting is only valid in certain savegame versions
* ( since patches are saved to the savegame , this bookkeeping is necessary .
2006-03-02 00:07:41 +00:00
* Now there are a lot of types . Easy ones are :
* - VAR : any number type , ' type ' field specifies what number . eg int8 or uint32
* - BOOL : a boolean number type
* - STR : a string or character . ' type ' field specifies what string . Normal , string , or quoted
* A bit more difficult to use are MMANY ( meaning ManyOfMany ) and OMANY ( OneOfMany )
2006-06-10 08:37:41 +00:00
* These are actually normal numbers , only bitmasked . In MMANY several bits can
* be set , in the other only one .
2006-03-02 00:07:41 +00:00
* The most complex type is INTLIST . This is basically an array of numbers . If
* the intlist is only valid in certain savegame versions because for example
* it has grown in size its length cannot be automatically be calculated so
* use SDT ( G ) _CONDLISTO ( ) meaning Old .
2006-06-10 08:37:41 +00:00
* If nothing fits you , you can use the GENERAL macros , but it exposes the
* internal structure somewhat so it needs a little looking . There are _NULL ( )
* macros as well , these fill up space so you can add more patches there ( in
2007-03-22 03:15:58 +00:00
* place ) and you DON ' T have to increase the savegame version .
*
* While reading values from openttd . cfg , some values may not be converted
* properly , for any kind of reasons . In order to allow a process of self - cleaning
* mechanism , a callback procedure is made available . You will have to supply the function , which
* will work on a string , one function per patch . And of course , enable the callback param
* on the appropriate macro .
*/
2006-03-02 00:07:41 +00:00
2007-03-22 03:15:58 +00:00
# define NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, proc, load)\
{ name , ( const void * ) ( def ) , { cmd } , { guiflags } , min , max , interval , many , str , proc , load }
2006-03-02 00:07:41 +00:00
/* Macros for various objects to go in the configuration file.
* This section is for global variables */
2006-08-28 09:13:33 +00:00
# define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, proc, from, to)\
2007-03-22 03:15:58 +00:00
{ NSD_GENERAL ( name , def , sdt_cmd , guiflags , min , max , interval , full , str , proc , NULL ) , SLEG_GENERAL ( sle_cmd , var , type | flags , length , from , to ) }
2006-03-02 00:07:41 +00:00
2006-08-28 09:13:33 +00:00
# define SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc, from, to)\
SDTG_GENERAL ( name , SDT_NUMX , SL_VAR , type , flags , guiflags , var , 0 , def , min , max , interval , NULL , str , proc , from , to )
# define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc)\
SDTG_CONDVAR ( name , type , flags , guiflags , var , def , min , max , interval , str , proc , 0 , SL_MAX_VERSION )
2006-03-02 00:07:41 +00:00
# define SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, from, to)\
2007-02-11 23:18:01 +00:00
SDTG_GENERAL ( name , SDT_BOOLX , SL_VAR , SLE_BOOL , flags , guiflags , var , 0 , def , 0 , 1 , 0 , NULL , str , proc , from , to )
2006-03-02 00:07:41 +00:00
# define SDTG_BOOL(name, flags, guiflags, var, def, str, proc)\
SDTG_CONDBOOL ( name , flags , guiflags , var , def , str , proc , 0 , SL_MAX_VERSION )
# define SDTG_CONDLIST(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
2006-08-28 09:13:33 +00:00
SDTG_GENERAL ( name , SDT_INTLIST , SL_ARR , type , flags , guiflags , var , length , def , 0 , 0 , 0 , NULL , str , proc , from , to )
2006-03-02 00:07:41 +00:00
# define SDTG_LIST(name, type, flags, guiflags, var, def, str, proc)\
2006-08-28 09:13:33 +00:00
SDTG_GENERAL ( name , SDT_INTLIST , SL_ARR , type , flags , guiflags , var , lengthof ( var ) , def , 0 , 0 , 0 , NULL , str , proc , 0 , SL_MAX_VERSION )
2006-03-02 00:07:41 +00:00
# define SDTG_CONDSTR(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
2006-08-28 09:13:33 +00:00
SDTG_GENERAL ( name , SDT_STRING , SL_STR , type , flags , guiflags , var , length , def , 0 , 0 , 0 , NULL , str , proc , from , to )
2006-03-02 00:07:41 +00:00
# define SDTG_STR(name, type, flags, guiflags, var, def, str, proc)\
2006-08-28 09:13:33 +00:00
SDTG_GENERAL ( name , SDT_STRING , SL_STR , type , flags , guiflags , var , lengthof ( var ) , def , 0 , 0 , 0 , NULL , str , proc , 0 , SL_MAX_VERSION )
2006-03-02 00:07:41 +00:00
# define SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to)\
2006-08-28 09:13:33 +00:00
SDTG_GENERAL ( name , SDT_ONEOFMANY , SL_VAR , type , flags , guiflags , var , 0 , def , 0 , max , 0 , full , str , proc , from , to )
2006-03-02 00:07:41 +00:00
# define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc)\
2007-04-25 17:40:06 +00:00
SDTG_CONDOMANY ( name , type , flags , guiflags , var , def , max , full , str , proc , 0 , SL_MAX_VERSION )
2006-03-02 00:07:41 +00:00
# define SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to)\
2006-08-28 09:13:33 +00:00
SDTG_GENERAL ( name , SDT_MANYOFMANY , SL_VAR , type , flags , guiflags , var , 0 , def , 0 , 0 , 0 , full , str , proc , from , to )
2006-03-02 00:07:41 +00:00
# define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, proc)\
SDTG_CONDMMANY ( name , type , flags , guiflags , var , def , full , str , proc , 0 , SL_MAX_VERSION )
2006-03-16 00:20:33 +00:00
# define SDTG_CONDNULL(length, from, to)\
2007-03-22 03:15:58 +00:00
{ { " " , NULL , { 0 } , { 0 } , 0 , 0 , 0 , NULL , STR_NULL , NULL , NULL } , SLEG_CONDNULL ( length , from , to ) }
2006-03-16 00:20:33 +00:00
2007-03-22 03:15:58 +00:00
# define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLEG_END()}
2006-03-02 00:07:41 +00:00
/* Macros for various objects to go in the configuration file.
* This section is for structures where their various members are saved */
2007-03-22 03:35:18 +00:00
# define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, proc, load, from, to)\
{ NSD_GENERAL ( name , def , sdt_cmd , guiflags , min , max , interval , full , str , proc , load ) , SLE_GENERAL ( sle_cmd , base , var , type | flags , length , from , to ) }
2006-03-02 00:07:41 +00:00
2006-08-28 09:13:33 +00:00
# define SDT_CONDVAR(base, var, type, from, to, flags, guiflags, def, min, max, interval, str, proc)\
2007-03-22 03:35:18 +00:00
SDT_GENERAL ( # var , SDT_NUMX , SL_VAR , type , flags , guiflags , base , var , 1 , def , min , max , interval , NULL , str , proc , NULL , from , to )
2006-08-28 09:13:33 +00:00
# define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, proc)\
SDT_CONDVAR ( base , var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , min , max , interval , str , proc )
2006-03-02 00:07:41 +00:00
# define SDT_CONDBOOL(base, var, from, to, flags, guiflags, def, str, proc)\
2007-03-22 03:35:18 +00:00
SDT_GENERAL ( # var , SDT_BOOLX , SL_VAR , SLE_BOOL , flags , guiflags , base , var , 1 , def , 0 , 1 , 0 , NULL , str , proc , NULL , from , to )
2006-03-02 00:07:41 +00:00
# define SDT_BOOL(base, var, flags, guiflags, def, str, proc)\
SDT_CONDBOOL ( base , var , 0 , SL_MAX_VERSION , flags , guiflags , def , str , proc )
# define SDT_CONDLIST(base, var, type, from, to, flags, guiflags, def, str, proc)\
2007-03-22 03:35:18 +00:00
SDT_GENERAL ( # var , SDT_INTLIST , SL_ARR , type , flags , guiflags , base , var , lengthof ( ( ( base * ) 8 ) - > var ) , def , 0 , 0 , 0 , NULL , str , proc , NULL , from , to )
2006-03-02 00:07:41 +00:00
# define SDT_LIST(base, var, type, flags, guiflags, def, str, proc)\
SDT_CONDLIST ( base , var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , str , proc )
2008-05-24 02:54:47 +00:00
# define SDT_CONDLISTO(base, var, length, type, from, to, flags, guiflags, def, str, proc, load)\
SDT_GENERAL ( # var , SDT_INTLIST , SL_ARR , type , flags , guiflags , base , var , length , def , 0 , 0 , 0 , NULL , str , proc , load , from , to )
2006-03-02 00:07:41 +00:00
# define SDT_CONDSTR(base, var, type, from, to, flags, guiflags, def, str, proc)\
2007-03-22 03:35:18 +00:00
SDT_GENERAL ( # var , SDT_STRING , SL_STR , type , flags , guiflags , base , var , lengthof ( ( ( base * ) 8 ) - > var ) , def , 0 , 0 , 0 , NULL , str , proc , NULL , from , to )
2006-03-02 00:07:41 +00:00
# define SDT_STR(base, var, type, flags, guiflags, def, str, proc)\
SDT_CONDSTR ( base , var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , str , proc )
# define SDT_CONDSTRO(base, var, length, type, from, to, flags, def, str, proc)\
SDT_GENERAL ( # var , SDT_STRING , SL_STR , type , flags , 0 , base , var , length , def , 0 , 0 , NULL , str , proc , from , to )
# define SDT_CONDCHR(base, var, from, to, flags, guiflags, def, str, proc)\
2007-03-22 03:35:18 +00:00
SDT_GENERAL ( # var , SDT_STRING , SL_VAR , SLE_CHAR , flags , guiflags , base , var , 1 , def , 0 , 0 , 0 , NULL , str , proc , NULL , from , to )
2006-03-02 00:07:41 +00:00
# define SDT_CHR(base, var, flags, guiflags, def, str, proc)\
SDT_CONDCHR ( base , var , 0 , SL_MAX_VERSION , flags , guiflags , def , str , proc )
2007-03-22 03:35:18 +00:00
# define SDT_CONDOMANY(base, var, type, from, to, flags, guiflags, def, max, full, str, proc, load)\
SDT_GENERAL ( # var , SDT_ONEOFMANY , SL_VAR , type , flags , guiflags , base , var , 1 , def , 0 , max , 0 , full , str , proc , load , from , to )
# define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, proc, load)\
SDT_CONDOMANY ( base , var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , max , full , str , proc , load )
2006-03-02 00:07:41 +00:00
# define SDT_CONDMMANY(base, var, type, from, to, flags, guiflags, def, full, str, proc)\
2007-03-22 03:35:18 +00:00
SDT_GENERAL ( # var , SDT_MANYOFMANY , SL_VAR , type , flags , guiflags , base , var , 1 , def , 0 , 0 , 0 , full , str , proc , NULL , from , to )
2006-03-02 00:07:41 +00:00
# define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc)\
SDT_CONDMMANY ( base , var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , full , str , proc )
2006-03-16 00:20:33 +00:00
# define SDT_CONDNULL(length, from, to)\
2007-03-22 03:15:58 +00:00
{ { " " , NULL , { 0 } , { 0 } , 0 , 0 , 0 , NULL , STR_NULL , NULL , NULL } , SLE_CONDNULL ( length , from , to ) }
2006-03-16 00:20:33 +00:00
2008-05-29 15:13:28 +00:00
# define SDTC_CONDVAR(var, type, from, to, flags, guiflags, def, min, max, interval, str, proc)\
2008-05-29 19:06:54 +00:00
SDTG_GENERAL ( # var , SDT_NUMX , SL_VAR , type , flags , guiflags , _settings_client . var , 1 , def , min , max , interval , NULL , str , proc , from , to )
2008-05-29 15:13:28 +00:00
# define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, proc)\
SDTC_CONDVAR ( var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , min , max , interval , str , proc )
# define SDTC_CONDBOOL(var, from, to, flags, guiflags, def, str, proc)\
2008-05-29 19:06:54 +00:00
SDTG_GENERAL ( # var , SDT_BOOLX , SL_VAR , SLE_BOOL , flags , guiflags , _settings_client . var , 1 , def , 0 , 1 , 0 , NULL , str , proc , from , to )
2008-05-29 15:13:28 +00:00
# define SDTC_BOOL(var, flags, guiflags, def, str, proc)\
SDTC_CONDBOOL ( var , 0 , SL_MAX_VERSION , flags , guiflags , def , str , proc )
# define SDTC_CONDLIST(var, type, length, flags, guiflags, def, str, proc, from, to)\
SDTG_GENERAL ( # var , SDT_INTLIST , SL_ARR , type , flags , guiflags , _settings_client . var , length , def , 0 , 0 , 0 , NULL , str , proc , from , to )
# define SDTC_LIST(var, type, flags, guiflags, def, str, proc)\
2008-05-30 09:23:05 +00:00
SDTG_GENERAL ( # var , SDT_INTLIST , SL_ARR , type , flags , guiflags , _settings_client . var , lengthof ( _settings_client . var ) , def , 0 , 0 , 0 , NULL , str , proc , 0 , SL_MAX_VERSION )
2008-05-29 15:13:28 +00:00
# define SDTC_CONDSTR(var, type, length, flags, guiflags, def, str, proc, from, to)\
SDTG_GENERAL ( # var , SDT_STRING , SL_STR , type , flags , guiflags , _settings_client . var , length , def , 0 , 0 , 0 , NULL , str , proc , from , to )
# define SDTC_STR(var, type, flags, guiflags, def, str, proc)\
2008-05-30 09:23:05 +00:00
SDTG_GENERAL ( # var , SDT_STRING , SL_STR , type , flags , guiflags , _settings_client . var , lengthof ( _settings_client . var ) , def , 0 , 0 , 0 , NULL , str , proc , 0 , SL_MAX_VERSION )
2008-05-29 15:13:28 +00:00
# define SDTC_CONDOMANY(var, type, from, to, flags, guiflags, def, max, full, str, proc)\
2008-05-29 19:06:54 +00:00
SDTG_GENERAL ( # var , SDT_ONEOFMANY , SL_VAR , type , flags , guiflags , _settings_client . var , 1 , def , 0 , max , 0 , full , str , proc , from , to )
2008-05-29 15:13:28 +00:00
# define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, proc)\
SDTC_CONDOMANY ( var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , max , full , str , proc )
2007-03-22 03:15:58 +00:00
# define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLE_END()}
2006-03-02 00:07:41 +00:00
/* Shortcuts for macros below. Logically if we don't save the value
* we also don ' t sync it in a network game */
# define S SLF_SAVE_NO | SLF_NETWORK_NO
# define C SLF_CONFIG_NO
# define N SLF_NETWORK_NO
# define D0 SGF_0ISDISABLED
# define NC SGF_NOCOMMA
# define MS SGF_MULTISTRING
# define NO SGF_NETWORK_ONLY
# define CR SGF_CURRENCY
2007-11-17 22:25:16 +00:00
# define NN SGF_NO_NETWORK
2008-05-26 00:31:36 +00:00
# define NG SGF_NEWGAME_ONLY
2006-03-02 00:07:41 +00:00
2006-03-03 11:27:18 +00:00
/* Begin - Callback Functions for the various settings */
2007-04-04 01:35:16 +00:00
/* virtual PositionMainToolbar function, calls the right one.*/
2006-03-03 11:27:18 +00:00
static int32 v_PositionMainToolbar ( int32 p1 )
{
if ( _game_mode ! = GM_MENU ) PositionMainToolbar ( NULL ) ;
return 0 ;
}
static int32 AiNew_PatchActive_Warning ( int32 p1 )
{
if ( p1 = = 1 ) ShowErrorMessage ( INVALID_STRING_ID , TEMP_AI_ACTIVATED , 0 , 0 ) ;
return 0 ;
}
static int32 Ai_In_Multiplayer_Warning ( int32 p1 )
{
if ( p1 = = 1 ) {
ShowErrorMessage ( INVALID_STRING_ID , TEMP_AI_MULTIPLAYER , 0 , 0 ) ;
2008-05-29 15:13:28 +00:00
_settings_game . ai . ainew_active = true ;
2006-03-03 11:27:18 +00:00
}
return 0 ;
}
static int32 PopulationInLabelActive ( int32 p1 )
{
Town * t ;
2006-08-22 15:33:35 +00:00
FOR_ALL_TOWNS ( t ) UpdateTownVirtCoord ( t ) ;
2006-03-03 11:27:18 +00:00
return 0 ;
}
2006-06-28 06:12:23 +00:00
static int32 RedrawScreen ( int32 p1 )
2006-03-03 11:27:18 +00:00
{
MarkWholeScreenDirty ( ) ;
return 0 ;
}
static int32 InValidateDetailsWindow ( int32 p1 )
{
InvalidateWindowClasses ( WC_VEHICLE_DETAILS ) ;
return 0 ;
}
static int32 InvalidateStationBuildWindow ( int32 p1 )
{
InvalidateWindow ( WC_BUILD_STATION , 0 ) ;
return 0 ;
}
2008-05-12 14:54:33 +00:00
static int32 InvalidateBuildIndustryWindow ( int32 p1 )
{
InvalidateWindowData ( WC_BUILD_INDUSTRY , 0 ) ;
return 0 ;
}
2008-05-11 02:15:02 +00:00
static int32 CloseSignalGUI ( int32 p1 )
{
if ( p1 = = 0 ) {
DeleteWindowByClass ( WC_BUILD_SIGNAL ) ;
}
return 0 ;
}
2008-05-24 02:54:47 +00:00
static int32 InvalidateTownViewWindow ( int32 p1 )
{
InvalidateWindowClassesData ( WC_TOWN_VIEW , p1 ) ;
return 0 ;
}
2007-10-18 20:32:36 +00:00
static int32 UpdateConsists ( int32 p1 )
{
Vehicle * v ;
FOR_ALL_VEHICLES ( v ) {
/* Update the consist of all trains so the maximum speed is set correctly. */
2008-07-24 15:19:26 +00:00
if ( v - > type = = VEH_TRAIN & & ( IsFrontEngine ( v ) | | IsFreeWagon ( v ) ) ) TrainConsistChanged ( v , true ) ;
2007-10-18 20:32:36 +00:00
}
return 0 ;
}
2006-03-03 11:27:18 +00:00
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
static int32 CheckInterval ( int32 p1 )
{
bool warning ;
2008-05-29 15:13:28 +00:00
const VehicleSettings * ptc = ( _game_mode = = GM_MENU ) ? & _settings_newgame . vehicle : & _settings_game . vehicle ;
2006-03-03 11:27:18 +00:00
if ( p1 ) {
2007-11-24 10:38:43 +00:00
warning = ( ( IsInsideMM ( ptc - > servint_trains , 5 , 90 + 1 ) | | ptc - > servint_trains = = 0 ) & &
( IsInsideMM ( ptc - > servint_roadveh , 5 , 90 + 1 ) | | ptc - > servint_roadveh = = 0 ) & &
( IsInsideMM ( ptc - > servint_aircraft , 5 , 90 + 1 ) | | ptc - > servint_aircraft = = 0 ) & &
( IsInsideMM ( ptc - > servint_ships , 5 , 90 + 1 ) | | ptc - > servint_ships = = 0 ) ) ;
2006-03-03 11:27:18 +00:00
} else {
2007-11-24 10:38:43 +00:00
warning = ( ( IsInsideMM ( ptc - > servint_trains , 30 , 800 + 1 ) | | ptc - > servint_trains = = 0 ) & &
( IsInsideMM ( ptc - > servint_roadveh , 30 , 800 + 1 ) | | ptc - > servint_roadveh = = 0 ) & &
( IsInsideMM ( ptc - > servint_aircraft , 30 , 800 + 1 ) | | ptc - > servint_aircraft = = 0 ) & &
( IsInsideMM ( ptc - > servint_ships , 30 , 800 + 1 ) | | ptc - > servint_ships = = 0 ) ) ;
2006-03-03 11:27:18 +00:00
}
if ( ! warning )
ShowErrorMessage ( INVALID_STRING_ID , STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE , 0 , 0 ) ;
return InValidateDetailsWindow ( 0 ) ;
}
static int32 EngineRenewUpdate ( int32 p1 )
{
2008-05-29 15:13:28 +00:00
DoCommandP ( 0 , 0 , _settings_client . gui . autorenew , NULL , CMD_SET_AUTOREPLACE ) ;
2006-03-03 11:27:18 +00:00
return 0 ;
}
static int32 EngineRenewMonthsUpdate ( int32 p1 )
{
2008-05-29 15:13:28 +00:00
DoCommandP ( 0 , 1 , _settings_client . gui . autorenew_months , NULL , CMD_SET_AUTOREPLACE ) ;
2006-03-03 11:27:18 +00:00
return 0 ;
}
static int32 EngineRenewMoneyUpdate ( int32 p1 )
{
2008-05-29 15:13:28 +00:00
DoCommandP ( 0 , 2 , _settings_client . gui . autorenew_money , NULL , CMD_SET_AUTOREPLACE ) ;
2006-03-03 11:27:18 +00:00
return 0 ;
}
2007-05-04 16:27:13 +00:00
2008-03-15 19:24:13 +00:00
static int32 RealisticAccelerationChanged ( int32 p1 )
{
Vehicle * v ;
FOR_ALL_VEHICLES ( v ) {
if ( v - > type = = VEH_TRAIN & & IsFrontEngine ( v ) ) UpdateTrainAcceleration ( v ) ;
}
return 0 ;
}
2008-04-03 22:31:57 +00:00
static int32 DragSignalsDensityChanged ( int32 )
{
2008-05-06 22:08:18 +00:00
SetWindowDirty ( FindWindowById ( WC_BUILD_SIGNAL , 0 ) ) ;
2008-04-03 22:31:57 +00:00
return 0 ;
}
2008-05-26 00:31:36 +00:00
/*
* A : competitors
* B : start time in months / 3
* C : town count ( 3 = high , 0 = very low )
* D : industry count ( 4 = high , 0 = none )
* E : inital loan ( in GBP )
* F : interest rate
* G : running costs ( 0 = low , 2 = high )
* H : construction speed of competitors ( 0 = very slow , 4 = very fast )
* I : intelligence ( 0 - 2 )
* J : breakdowns ( 0 = off , 2 = normal )
* K : subsidy multiplier ( 0 = 1.5 , 3 = 4.0 )
* L : construction cost ( 0 - 2 )
* M : terrain type ( 0 = very flat , 3 = mountainous )
* N : amount of water ( 0 = very low , 3 = high )
* O : economy ( 0 = steady , 1 = fluctuating )
* P : Train reversing ( 0 = end of line + stations , 1 = end of line )
* Q : disasters
* R : area restructuring ( 0 = permissive , 2 = hostile )
* S : the difficulty level
*/
static const DifficultySettings _default_game_diff [ 3 ] = { /*
A , B , C , D , E , F , G , H , I , J , K , L , M , N , O , P , Q , R , S */
{ 2 , 2 , 2 , 4 , 300000 , 2 , 0 , 2 , 0 , 1 , 2 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 } , ///< easy
{ 4 , 1 , 2 , 3 , 150000 , 3 , 1 , 3 , 1 , 2 , 1 , 1 , 2 , 1 , 1 , 1 , 1 , 1 , 1 } , ///< medium
{ 7 , 0 , 3 , 3 , 100000 , 4 , 1 , 3 , 2 , 2 , 0 , 2 , 3 , 2 , 1 , 1 , 1 , 2 , 2 } , ///< hard
} ;
void SetDifficultyLevel ( int mode , DifficultySettings * gm_opt )
{
assert ( mode < = 3 ) ;
if ( mode ! = 3 ) {
* gm_opt = _default_game_diff [ mode ] ;
} else {
gm_opt - > diff_level = 3 ;
}
}
/**
* Checks the difficulty levels read from the configuration and
* forces them to be correct when invalid .
*/
void CheckDifficultyLevels ( )
{
if ( _settings_newgame . difficulty . diff_level ! = 3 ) {
SetDifficultyLevel ( _settings_newgame . difficulty . diff_level , & _settings_newgame . difficulty ) ;
}
}
static int32 DifficultyReset ( int32 level )
{
2008-05-29 15:13:28 +00:00
SetDifficultyLevel ( level , ( _game_mode = = GM_MENU ) ? & _settings_newgame . difficulty : & _settings_game . difficulty ) ;
2008-05-26 00:31:36 +00:00
return 0 ;
}
static int32 DifficultyChange ( int32 )
{
if ( _game_mode = = GM_MENU ) {
_settings_newgame . difficulty . diff_level = 3 ;
} else {
2008-05-29 15:13:28 +00:00
_settings_game . difficulty . diff_level = 3 ;
2008-05-26 00:31:36 +00:00
}
/* If we are a network-client, update the difficult setting (if it is open).
* Use this instead of just dirtying the window because we need to load in
* the new difficulty settings */
if ( _networking & & FindWindowById ( WC_GAME_OPTIONS , 0 ) ! = NULL ) {
ShowGameDifficulty ( ) ;
}
return 0 ;
}
static int32 DifficultyNoiseChange ( int32 i )
{
if ( _game_mode = = GM_NORMAL ) {
UpdateAirportsNoise ( ) ;
2008-05-29 15:13:28 +00:00
if ( _settings_game . economy . station_noise_level ) {
2008-05-26 00:31:36 +00:00
InvalidateWindowClassesData ( WC_TOWN_VIEW , 0 ) ;
}
}
return DifficultyChange ( i ) ;
}
2007-05-04 16:27:13 +00:00
/**
* Check for right TownLayout usage in editor mode .
* The No Road mode is not desirable since towns have to be
* able to grow . If a user desires to have a town with no road ,
* he can easily remove them himself . This would create less confusion
* @ param p1 unused
* @ return always 0
*/
static int32 CheckTownLayout ( int32 p1 )
{
2008-05-29 15:13:28 +00:00
if ( _settings_game . economy . town_layout = = TL_NO_ROADS & & _game_mode = = GM_EDITOR ) {
2007-05-04 16:27:13 +00:00
ShowErrorMessage ( INVALID_STRING_ID , STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID , 0 , 0 ) ;
2008-05-29 15:13:28 +00:00
_settings_game . economy . town_layout = TL_ORIGINAL ;
2007-05-04 16:27:13 +00:00
}
return 0 ;
}
2008-05-29 15:13:28 +00:00
/** Conversion callback for _gameopt_settings_game.landscape
2007-03-22 03:35:18 +00:00
* It converts ( or try ) between old values and the new ones ,
2008-08-25 20:10:45 +00:00
* without losing initial setting of the user
2007-03-22 03:35:18 +00:00
* @ param value that was read from config file
* @ return the " hopefully " converted value
*/
static int32 ConvertLandscape ( const char * value )
{
/* try with the old values */
2008-05-08 14:04:52 +00:00
return lookup_oneofmany ( " normal|hilly|desert|candy " , value ) ;
2007-03-22 03:35:18 +00:00
}
2008-05-24 02:54:47 +00:00
/**
* Check for decent values been supplied by the user for the noise tolerance setting .
* The primary idea is to avoid division by zero in game mode .
* The secondary idea is to make it so the values will be somewhat sane and that towns will
* not be overcrowed with airports . It would be easy to abuse such a feature
* So basically , 200 , 400 , 800 are the lowest allowed values */
static int32 CheckNoiseToleranceLevel ( const char * value )
{
2008-05-29 15:13:28 +00:00
GameSettings * s = ( _game_mode = = GM_MENU ) ? & _settings_newgame : & _settings_game ;
2008-05-25 19:17:03 +00:00
for ( uint16 i = 0 ; i < lengthof ( s - > economy . town_noise_population ) ; i + + ) {
s - > economy . town_noise_population [ i ] = max ( uint16 ( 200 * ( i + 1 ) ) , s - > economy . town_noise_population [ i ] ) ;
2008-05-24 02:54:47 +00:00
}
return 0 ;
}
2008-05-30 09:23:05 +00:00
# ifdef ENABLE_NETWORK
2008-09-30 20:39:50 +00:00
static int32 UpdateMinActiveClients ( int32 p1 )
2008-05-30 09:23:05 +00:00
{
2008-09-30 20:39:50 +00:00
CheckMinActiveClients ( ) ;
2008-05-30 09:23:05 +00:00
return 0 ;
}
2008-09-30 20:39:50 +00:00
static int32 UpdateClientName ( int32 p1 )
2008-05-30 09:23:05 +00:00
{
2008-09-30 20:39:50 +00:00
NetworkUpdateClientName ( ) ;
2008-05-30 09:23:05 +00:00
return 0 ;
}
static int32 UpdateServerPassword ( int32 p1 )
{
if ( strcmp ( _settings_client . network . server_password , " * " ) = = 0 ) {
_settings_client . network . server_password [ 0 ] = ' \0 ' ;
}
return 0 ;
}
static int32 UpdateRconPassword ( int32 p1 )
{
if ( strcmp ( _settings_client . network . rcon_password , " * " ) = = 0 ) {
_settings_client . network . rcon_password [ 0 ] = ' \0 ' ;
}
return 0 ;
}
# endif /* ENABLE_NETWORK */
2006-03-03 11:27:18 +00:00
/* End - Callback Functions */
2005-03-27 15:42:25 +00:00
# ifndef EXTERNAL_PLAYER
# define EXTERNAL_PLAYER "timidity"
# endif
2006-03-02 00:07:41 +00:00
static const SettingDesc _music_settings [ ] = {
2006-08-28 09:13:33 +00:00
SDT_VAR ( MusicFileSettings , playlist , SLE_UINT8 , S , 0 , 0 , 0 , 5 , 1 , STR_NULL , NULL ) ,
2008-09-11 13:58:59 +00:00
SDT_VAR ( MusicFileSettings , music_vol , SLE_UINT8 , S , 0 , 127 , 0 , 127 , 1 , STR_NULL , NULL ) ,
SDT_VAR ( MusicFileSettings , effect_vol , SLE_UINT8 , S , 0 , 127 , 0 , 127 , 1 , STR_NULL , NULL ) ,
2006-08-22 14:38:37 +00:00
SDT_LIST ( MusicFileSettings , custom_1 , SLE_UINT8 , S , 0 , NULL , STR_NULL , NULL ) ,
SDT_LIST ( MusicFileSettings , custom_2 , SLE_UINT8 , S , 0 , NULL , STR_NULL , NULL ) ,
SDT_BOOL ( MusicFileSettings , playing , S , 0 , true , STR_NULL , NULL ) ,
SDT_BOOL ( MusicFileSettings , shuffle , S , 0 , false , STR_NULL , NULL ) ,
SDT_STR ( MusicFileSettings , extmidi , SLE_STRB , S , 0 , EXTERNAL_PLAYER , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDT_END ( )
2004-08-09 17:04:08 +00:00
} ;
2006-02-20 23:01:58 +00:00
/* win32_v.c only settings */
# ifdef WIN32
2007-06-12 20:24:12 +00:00
extern bool _force_full_redraw , _window_maximize ;
2006-02-20 23:01:58 +00:00
extern uint _display_hz , _fullscreen_bpp ;
2006-03-02 09:57:28 +00:00
static const SettingDescGlobVarList _win32_settings [ ] = {
2006-08-28 09:13:33 +00:00
SDTG_VAR ( " display_hz " , SLE_UINT , S , 0 , _display_hz , 0 , 0 , 120 , 0 , STR_NULL , NULL ) ,
SDTG_BOOL ( " force_full_redraw " , S , 0 , _force_full_redraw , false , STR_NULL , NULL ) ,
SDTG_VAR ( " fullscreen_bpp " , SLE_UINT , S , 0 , _fullscreen_bpp , 8 , 8 , 32 , 0 , STR_NULL , NULL ) ,
SDTG_BOOL ( " window_maximize " , S , 0 , _window_maximize , false , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_END ( )
2004-08-09 17:04:08 +00:00
} ;
2006-02-20 23:01:58 +00:00
# endif /* WIN32 */
2004-08-09 17:04:08 +00:00
2006-03-02 00:07:41 +00:00
static const SettingDescGlobVarList _misc_settings [ ] = {
2007-05-26 07:47:52 +00:00
SDTG_MMANY ( " display_opt " , SLE_UINT8 , S , 0 , _display_opt , ( 1 < < DO_SHOW_TOWN_NAMES | 1 < < DO_SHOW_STATION_NAMES | 1 < < DO_SHOW_SIGNS | 1 < < DO_FULL_ANIMATION | 1 < < DO_FULL_DETAIL | 1 < < DO_WAYPOINTS ) , " SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION||FULL_DETAIL|WAYPOINTS " , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_BOOL ( " news_ticker_sound " , S , 0 , _news_ticker_sound , true , STR_NULL , NULL ) ,
SDTG_BOOL ( " fullscreen " , S , 0 , _fullscreen , false , STR_NULL , NULL ) ,
2008-08-31 08:46:43 +00:00
SDTG_STR ( " graphicsset " , SLE_STRB , C | S , 0 , _ini_graphics_set , NULL , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_STR ( " videodriver " , SLE_STRB , C | S , 0 , _ini_videodriver , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " musicdriver " , SLE_STRB , C | S , 0 , _ini_musicdriver , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " sounddriver " , SLE_STRB , C | S , 0 , _ini_sounddriver , NULL , STR_NULL , NULL ) ,
2007-09-13 12:28:53 +00:00
SDTG_STR ( " blitter " , SLE_STRB , C | S , 0 , _ini_blitter , NULL , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_STR ( " language " , SLE_STRB , S , 0 , _dynlang . curr_file , NULL , STR_NULL , NULL ) ,
2008-06-16 19:38:41 +00:00
SDTG_CONDLIST ( " resolution " , SLE_INT , 2 , S , 0 , _cur_resolution , " 640,480 " , STR_NULL , NULL , 0 , SL_MAX_VERSION ) , // workaround for implicit lengthof() in SDTG_LIST
2006-03-02 00:07:41 +00:00
SDTG_STR ( " screenshot_format " , SLE_STRB , S , 0 , _screenshot_format_name , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " savegame_format " , SLE_STRB , S , 0 , _savegame_format , NULL , STR_NULL , NULL ) ,
SDTG_BOOL ( " rightclick_emulate " , S , 0 , _rightclick_emulate , false , STR_NULL , NULL ) ,
2006-11-16 22:05:33 +00:00
# ifdef WITH_FREETYPE
SDTG_STR ( " small_font " , SLE_STRB , S , 0 , _freetype . small_font , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " medium_font " , SLE_STRB , S , 0 , _freetype . medium_font , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " large_font " , SLE_STRB , S , 0 , _freetype . large_font , NULL , STR_NULL , NULL ) ,
SDTG_VAR ( " small_size " , SLE_UINT , S , 0 , _freetype . small_size , 6 , 0 , 72 , 0 , STR_NULL , NULL ) ,
SDTG_VAR ( " medium_size " , SLE_UINT , S , 0 , _freetype . medium_size , 10 , 0 , 72 , 0 , STR_NULL , NULL ) ,
SDTG_VAR ( " large_size " , SLE_UINT , S , 0 , _freetype . large_size , 16 , 0 , 72 , 0 , STR_NULL , NULL ) ,
2007-06-15 16:21:56 +00:00
SDTG_BOOL ( " small_aa " , S , 0 , _freetype . small_aa , false , STR_NULL , NULL ) ,
SDTG_BOOL ( " medium_aa " , S , 0 , _freetype . medium_aa , false , STR_NULL , NULL ) ,
SDTG_BOOL ( " large_aa " , S , 0 , _freetype . large_aa , false , STR_NULL , NULL ) ,
2006-11-16 22:05:33 +00:00
# endif
2007-06-11 11:50:49 +00:00
SDTG_VAR ( " sprite_cache_size " , SLE_UINT , S , 0 , _sprite_cache_size , 4 , 1 , 64 , 0 , STR_NULL , NULL ) ,
2008-09-30 20:39:50 +00:00
SDTG_VAR ( " player_face " , SLE_UINT32 , S , 0 , _company_manager_face , 0 , 0 , 0xFFFFFFFF , 0 , STR_NULL , NULL ) ,
2008-02-10 18:31:33 +00:00
SDTG_VAR ( " transparency_options " , SLE_UINT , S , 0 , _transparency_opt , 0 , 0 , 0x1FF , 0 , STR_NULL , NULL ) ,
SDTG_VAR ( " transparency_locks " , SLE_UINT , S , 0 , _transparency_lock , 0 , 0 , 0x1FF , 0 , STR_NULL , NULL ) ,
2008-04-03 19:55:40 +00:00
SDTG_VAR ( " invisibility_options " , SLE_UINT , S , 0 , _invisibility_opt , 0 , 0 , 0xFF , 0 , STR_NULL , NULL ) ,
2008-03-26 10:08:17 +00:00
SDTG_STR ( " keyboard " , SLE_STRB , S , 0 , _keyboard_opt [ 0 ] , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " keyboard_caps " , SLE_STRB , S , 0 , _keyboard_opt [ 1 ] , NULL , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_END ( )
2004-08-09 17:04:08 +00:00
} ;
2008-05-26 00:31:36 +00:00
static const uint GAME_DIFFICULTY_NUM = 18 ;
uint16 _old_diff_custom [ GAME_DIFFICULTY_NUM ] ;
2006-03-02 00:07:41 +00:00
static const SettingDesc _gameopt_settings [ ] = {
/* In version 4 a new difficulty setting has been added to the difficulty settings,
* town attitude towards demolishing . Needs special handling because some dimwit thought
* it funny to have the GameDifficulty struct be an array while it is a struct of
* same - sized members
* XXX - To save file - space and since values are never bigger than about 10 ? only
* save the first 16 bits in the savegame . Question is why the values are still int32
2008-01-22 21:01:35 +00:00
* and why not byte for example ?
* ' SLE_FILE_I16 | SLE_VAR_U16 ' in " diff_custom " is needed to get around SlArray ( ) hack
* for savegames version 0 - though it is an array , it has to go through the byteswap process */
2008-05-26 00:31:36 +00:00
SDTG_GENERAL ( " diff_custom " , SDT_INTLIST , SL_ARR , SLE_FILE_I16 | SLE_VAR_U16 , C , 0 , _old_diff_custom , 17 , 0 , 0 , 0 , 0 , NULL , STR_NULL , NULL , 0 , 3 ) ,
SDTG_GENERAL ( " diff_custom " , SDT_INTLIST , SL_ARR , SLE_UINT16 , C , 0 , _old_diff_custom , 18 , 0 , 0 , 0 , 0 , NULL , STR_NULL , NULL , 4 , 96 ) ,
2008-05-29 15:13:28 +00:00
SDT_VAR ( GameSettings , difficulty . diff_level , SLE_UINT8 , 0 , 0 , 0 , 0 , 3 , 0 , STR_NULL , NULL ) ,
2008-06-05 11:26:38 +00:00
SDT_OMANY ( GameSettings , locale . currency , SLE_UINT8 , N , 0 , 0 , CUSTOM_CURRENCY_ID , " GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom " , STR_NULL , NULL , NULL ) ,
SDT_OMANY ( GameSettings , locale . units , SLE_UINT8 , N , 0 , 1 , 2 , " imperial|metric|si " , STR_NULL , NULL , NULL ) ,
2007-06-18 23:00:55 +00:00
/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
2008-05-29 15:13:28 +00:00
SDT_OMANY ( GameSettings , game_creation . town_name , SLE_UINT8 , 0 , 0 , 0 , 255 , " english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan " , STR_NULL , NULL , NULL ) ,
SDT_OMANY ( GameSettings , game_creation . landscape , SLE_UINT8 , 0 , 0 , 0 , 3 , " temperate|arctic|tropic|toyland " , STR_NULL , NULL , ConvertLandscape ) ,
SDT_VAR ( GameSettings , game_creation . snow_line , SLE_UINT8 , 0 , 0 , 7 * TILE_HEIGHT , 2 * TILE_HEIGHT , 13 * TILE_HEIGHT , 0 , STR_NULL , NULL ) ,
2008-05-29 21:36:10 +00:00
SDT_CONDNULL ( 1 , 0 , 22 ) ,
2008-05-29 15:13:28 +00:00
SDTC_CONDOMANY ( gui . autosave , SLE_UINT8 , 23 , SL_MAX_VERSION , S , 0 , 1 , 4 , " off|monthly|quarterly|half year|yearly " , STR_NULL , NULL ) ,
SDT_OMANY ( GameSettings , vehicle . road_side , SLE_UINT8 , 0 , 0 , 1 , 1 , " left|right " , STR_NULL , NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDT_END ( )
2004-12-04 17:54:56 +00:00
} ;
2004-09-07 23:41:09 +00:00
2006-03-02 00:07:41 +00:00
/* Some patches do not need to be synchronised when playing in multiplayer.
* These include for example the GUI settings and will not be saved with the
* savegame .
* It is also a bit tricky since you would think that service_interval
2006-06-10 08:37:41 +00:00
* for example doesn ' t need to be synched . Every client assigns the
* service_interval value to the v - > service_interval , meaning that every client
2008-09-30 20:39:50 +00:00
* assigns his value . If the setting was company - based , that would mean that
2006-06-10 08:37:41 +00:00
* vehicles could decide on different moments that they are heading back to a
* service depot , causing desyncs on a massive scale . */
2006-03-02 00:07:41 +00:00
const SettingDesc _patch_settings [ ] = {
/***************************************************************************/
2008-05-25 19:17:03 +00:00
/* Saved patch variables. */
2008-05-26 00:31:36 +00:00
/* Do not ADD or REMOVE something in this "difficulty.XXX" table or before it. It breaks savegame compatability. */
2008-05-29 15:13:28 +00:00
SDT_CONDVAR ( GameSettings , difficulty . max_no_competitors , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 2 , 0 , 7 , 1 , STR_NULL , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . competitor_start_time , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 2 , 0 , 3 , 1 , STR_6830_IMMEDIATE , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . number_towns , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 2 , 0 , 3 , 1 , STR_NUM_VERY_LOW , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . number_industries , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 4 , 0 , 4 , 1 , STR_NONE , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . max_loan , SLE_UINT32 , 97 , SL_MAX_VERSION , 0 , NG | CR , 300000 , 100000 , 500000 , 50000 , STR_NULL , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . initial_interest , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 2 , 2 , 4 , 1 , STR_NULL , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . vehicle_costs , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 0 , 0 , 2 , 1 , STR_6820_LOW , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . competitor_speed , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 2 , 0 , 4 , 1 , STR_681B_VERY_SLOW , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . competitor_intelligence , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 0 , 0 , 2 , 1 , STR_6820_LOW , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . vehicle_breakdowns , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 1 , 0 , 2 , 1 , STR_6823_NONE , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . subsidy_multiplier , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 2 , 0 , 3 , 1 , STR_6826_X1_5 , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . construction_cost , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 0 , 0 , 2 , 1 , STR_6820_LOW , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . terrain_type , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 1 , 0 , 3 , 1 , STR_682A_VERY_FLAT , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . quantity_sea_lakes , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 0 , 0 , 3 , 1 , STR_VERY_LOW , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . economy , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 0 , 0 , 1 , 1 , STR_682E_STEADY , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . line_reverse_mode , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 0 , 0 , 1 , 1 , STR_6834_AT_END_OF_LINE_AND_AT_STATIONS , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . disasters , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 0 , 0 , 1 , 1 , STR_6836_OFF , DifficultyChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . town_council_tolerance , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , 0 , 0 , 0 , 2 , 1 , STR_PERMISSIVE , DifficultyNoiseChange ) ,
SDT_CONDVAR ( GameSettings , difficulty . diff_level , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NG , 0 , 0 , 3 , 0 , STR_NULL , DifficultyReset ) ,
2008-05-26 00:31:36 +00:00
/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
2008-05-29 15:13:28 +00:00
SDT_CONDOMANY ( GameSettings , game_creation . town_name , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NN , 0 , 255 , " english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan " , STR_NULL , NULL , NULL ) ,
SDT_CONDOMANY ( GameSettings , game_creation . landscape , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NN , 0 , 3 , " temperate|arctic|tropic|toyland " , STR_NULL , NULL , ConvertLandscape ) ,
SDT_CONDVAR ( GameSettings , game_creation . snow_line , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NN , 7 * TILE_HEIGHT , 2 * TILE_HEIGHT , 13 * TILE_HEIGHT , 0 , STR_NULL , NULL ) ,
SDT_CONDOMANY ( GameSettings , vehicle . road_side , SLE_UINT8 , 97 , SL_MAX_VERSION , 0 , NN , 1 , 1 , " left|right " , STR_NULL , NULL , NULL ) ,
SDT_BOOL ( GameSettings , construction . build_on_slopes , 0 , NN , true , STR_CONFIG_PATCHES_BUILDONSLOPES , NULL ) ,
SDT_CONDBOOL ( GameSettings , construction . autoslope , 75 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_AUTOSLOPE , NULL ) ,
SDT_BOOL ( GameSettings , construction . extra_dynamite , 0 , 0 , false , STR_CONFIG_PATCHES_EXTRADYNAMITE , NULL ) ,
SDT_BOOL ( GameSettings , construction . longbridges , 0 , NN , true , STR_CONFIG_PATCHES_LONGBRIDGES , NULL ) ,
SDT_BOOL ( GameSettings , construction . signal_side , N , NN , true , STR_CONFIG_PATCHES_SIGNALSIDE , RedrawScreen ) ,
SDT_BOOL ( GameSettings , station . always_small_airport , 0 , NN , false , STR_CONFIG_PATCHES_SMALL_AIRPORTS , NULL ) ,
SDT_CONDVAR ( GameSettings , economy . town_layout , SLE_UINT8 , 59 , SL_MAX_VERSION , 0 , MS , TL_ORIGINAL , TL_NO_ROADS , NUM_TLS - 1 , 1 , STR_CONFIG_PATCHES_TOWN_LAYOUT , CheckTownLayout ) ,
SDT_BOOL ( GameSettings , vehicle . realistic_acceleration , 0 , 0 , false , STR_CONFIG_PATCHES_REALISTICACCEL , RealisticAccelerationChanged ) ,
SDT_BOOL ( GameSettings , pf . forbid_90_deg , 0 , 0 , false , STR_CONFIG_PATCHES_FORBID_90_DEG , NULL ) ,
SDT_BOOL ( GameSettings , vehicle . mammoth_trains , 0 , NN , true , STR_CONFIG_PATCHES_MAMMOTHTRAINS , NULL ) ,
SDT_BOOL ( GameSettings , order . gotodepot , 0 , 0 , true , STR_CONFIG_PATCHES_GOTODEPOT , NULL ) ,
SDT_BOOL ( GameSettings , pf . roadveh_queue , 0 , 0 , true , STR_CONFIG_PATCHES_ROADVEH_QUEUE , NULL ) ,
SDT_CONDBOOL ( GameSettings , pf . new_pathfinding_all , 0 , 86 , 0 , 0 , false , STR_NULL , NULL ) ,
SDT_CONDBOOL ( GameSettings , pf . yapf . ship_use_yapf , 28 , 86 , 0 , 0 , false , STR_NULL , NULL ) ,
SDT_CONDBOOL ( GameSettings , pf . yapf . road_use_yapf , 28 , 86 , 0 , 0 , true , STR_NULL , NULL ) ,
SDT_CONDBOOL ( GameSettings , pf . yapf . rail_use_yapf , 28 , 86 , 0 , 0 , true , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . pathfinder_for_trains , SLE_UINT8 , 87 , SL_MAX_VERSION , 0 , MS , 2 , 0 , 2 , 1 , STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . pathfinder_for_roadvehs , SLE_UINT8 , 87 , SL_MAX_VERSION , 0 , MS , 2 , 0 , 2 , 1 , STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . pathfinder_for_ships , SLE_UINT8 , 87 , SL_MAX_VERSION , 0 , MS , 0 , 0 , 2 , 1 , STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS , NULL ) ,
SDT_BOOL ( GameSettings , vehicle . never_expire_vehicles , 0 , NN , false , STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES , NULL ) ,
SDT_VAR ( GameSettings , vehicle . max_trains , SLE_UINT16 , 0 , 0 , 500 , 0 , 5000 , 0 , STR_CONFIG_PATCHES_MAX_TRAINS , RedrawScreen ) ,
SDT_VAR ( GameSettings , vehicle . max_roadveh , SLE_UINT16 , 0 , 0 , 500 , 0 , 5000 , 0 , STR_CONFIG_PATCHES_MAX_ROADVEH , RedrawScreen ) ,
SDT_VAR ( GameSettings , vehicle . max_aircraft , SLE_UINT16 , 0 , 0 , 200 , 0 , 5000 , 0 , STR_CONFIG_PATCHES_MAX_AIRCRAFT , RedrawScreen ) ,
SDT_VAR ( GameSettings , vehicle . max_ships , SLE_UINT16 , 0 , 0 , 300 , 0 , 5000 , 0 , STR_CONFIG_PATCHES_MAX_SHIPS , RedrawScreen ) ,
SDT_BOOL ( GameSettings , vehicle . servint_ispercent , 0 , 0 , false , STR_CONFIG_PATCHES_SERVINT_ISPERCENT , CheckInterval ) ,
SDT_VAR ( GameSettings , vehicle . servint_trains , SLE_UINT16 , 0 , D0 , 150 , 5 , 800 , 0 , STR_CONFIG_PATCHES_SERVINT_TRAINS , InValidateDetailsWindow ) ,
SDT_VAR ( GameSettings , vehicle . servint_roadveh , SLE_UINT16 , 0 , D0 , 150 , 5 , 800 , 0 , STR_CONFIG_PATCHES_SERVINT_ROADVEH , InValidateDetailsWindow ) ,
SDT_VAR ( GameSettings , vehicle . servint_ships , SLE_UINT16 , 0 , D0 , 360 , 5 , 800 , 0 , STR_CONFIG_PATCHES_SERVINT_SHIPS , InValidateDetailsWindow ) ,
SDT_VAR ( GameSettings , vehicle . servint_aircraft , SLE_UINT16 , 0 , D0 , 100 , 5 , 800 , 0 , STR_CONFIG_PATCHES_SERVINT_AIRCRAFT , InValidateDetailsWindow ) ,
SDT_BOOL ( GameSettings , order . no_servicing_if_no_breakdowns , 0 , 0 , false , STR_CONFIG_PATCHES_NOSERVICE , NULL ) ,
SDT_BOOL ( GameSettings , vehicle . wagon_speed_limits , 0 , NN , true , STR_CONFIG_PATCHES_WAGONSPEEDLIMITS , UpdateConsists ) ,
SDT_CONDBOOL ( GameSettings , vehicle . disable_elrails , 38 , SL_MAX_VERSION , 0 , NN , false , STR_CONFIG_PATCHES_DISABLE_ELRAILS , SettingsDisableElrail ) ,
SDT_CONDVAR ( GameSettings , vehicle . freight_trains , SLE_UINT8 , 39 , SL_MAX_VERSION , 0 , NN , 1 , 1 , 255 , 1 , STR_CONFIG_PATCHES_FREIGHT_TRAINS , NULL ) ,
SDT_CONDBOOL ( GameSettings , order . timetabling , 67 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_TIMETABLE_ALLOW , NULL ) ,
SDT_CONDVAR ( GameSettings , vehicle . plane_speed , SLE_UINT8 , 90 , SL_MAX_VERSION , 0 , 0 , 4 , 1 , 4 , 0 , STR_CONFIG_PATCHES_PLANE_SPEED , NULL ) ,
SDT_CONDBOOL ( GameSettings , vehicle . dynamic_engines , 95 , SL_MAX_VERSION , 0 , NN , false , STR_CONFIG_PATCHES_DYNAMIC_ENGINES , NULL ) ,
SDT_BOOL ( GameSettings , station . join_stations , 0 , 0 , true , STR_CONFIG_PATCHES_JOINSTATIONS , NULL ) ,
SDTC_CONDBOOL ( gui . sg_full_load_any , 0 , 92 , 0 , 0 , true , STR_NULL , NULL ) ,
SDT_BOOL ( GameSettings , order . improved_load , 0 , NN , true , STR_CONFIG_PATCHES_IMPROVEDLOAD , NULL ) ,
SDT_BOOL ( GameSettings , order . selectgoods , 0 , 0 , true , STR_CONFIG_PATCHES_SELECTGOODS , NULL ) ,
SDTC_CONDBOOL ( gui . sg_new_nonstop , 0 , 92 , 0 , 0 , false , STR_NULL , NULL ) ,
SDT_BOOL ( GameSettings , station . nonuniform_stations , 0 , NN , true , STR_CONFIG_PATCHES_NONUNIFORM_STATIONS , NULL ) ,
SDT_VAR ( GameSettings , station . station_spread , SLE_UINT8 , 0 , 0 , 12 , 4 , 64 , 0 , STR_CONFIG_PATCHES_STATION_SPREAD , InvalidateStationBuildWindow ) ,
SDT_BOOL ( GameSettings , order . serviceathelipad , 0 , 0 , true , STR_CONFIG_PATCHES_SERVICEATHELIPAD , NULL ) ,
SDT_BOOL ( GameSettings , station . modified_catchment , 0 , 0 , true , STR_CONFIG_PATCHES_CATCHMENT , NULL ) ,
SDT_CONDBOOL ( GameSettings , order . gradual_loading , 40 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_GRADUAL_LOADING , NULL ) ,
SDT_CONDBOOL ( GameSettings , construction . road_stop_on_town_road , 47 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD , NULL ) ,
SDT_CONDBOOL ( GameSettings , station . adjacent_stations , 62 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_ADJACENT_STATIONS , NULL ) ,
SDT_CONDBOOL ( GameSettings , economy . station_noise_level , 96 , SL_MAX_VERSION , 0 , 0 , false , STR_CONFIG_PATCHES_NOISE_LEVEL , InvalidateTownViewWindow ) ,
SDT_BOOL ( GameSettings , economy . inflation , 0 , 0 , true , STR_CONFIG_PATCHES_INFLATION , NULL ) ,
SDT_VAR ( GameSettings , construction . raw_industry_construction , SLE_UINT8 , 0 , MS , 0 , 0 , 2 , 0 , STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD , InvalidateBuildIndustryWindow ) ,
SDT_BOOL ( GameSettings , economy . multiple_industry_per_town , 0 , 0 , false , STR_CONFIG_PATCHES_MULTIPINDTOWN , NULL ) ,
SDT_BOOL ( GameSettings , economy . same_industry_close , 0 , 0 , false , STR_CONFIG_PATCHES_SAMEINDCLOSE , NULL ) ,
SDT_BOOL ( GameSettings , economy . bribe , 0 , 0 , true , STR_CONFIG_PATCHES_BRIBE , NULL ) ,
SDT_CONDBOOL ( GameSettings , economy . exclusive_rights , 79 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE , NULL ) ,
SDT_CONDBOOL ( GameSettings , economy . give_money , 79 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY , NULL ) ,
SDT_VAR ( GameSettings , game_creation . snow_line_height , SLE_UINT8 , 0 , 0 , 7 , 2 , 13 , 0 , STR_CONFIG_PATCHES_SNOWLINE_HEIGHT , NULL ) ,
SDTC_VAR ( gui . colored_news_year , SLE_INT32 , 0 , NC , 2000 , MIN_YEAR , MAX_YEAR , 1 , STR_CONFIG_PATCHES_COLORED_NEWS_YEAR , NULL ) ,
SDT_VAR ( GameSettings , game_creation . starting_year , SLE_INT32 , 0 , NC , 1950 , MIN_YEAR , MAX_YEAR , 1 , STR_CONFIG_PATCHES_STARTING_YEAR , NULL ) ,
SDTC_VAR ( gui . ending_year , SLE_INT32 , 0 , NC | NO , 2051 , MIN_YEAR , MAX_YEAR , 1 , STR_CONFIG_PATCHES_ENDING_YEAR , NULL ) ,
SDT_BOOL ( GameSettings , economy . smooth_economy , 0 , 0 , true , STR_CONFIG_PATCHES_SMOOTH_ECONOMY , NULL ) ,
SDT_BOOL ( GameSettings , economy . allow_shares , 0 , 0 , false , STR_CONFIG_PATCHES_ALLOW_SHARES , NULL ) ,
SDT_CONDVAR ( GameSettings , economy . town_growth_rate , SLE_UINT8 , 54 , SL_MAX_VERSION , 0 , MS , 2 , 0 , 4 , 0 , STR_CONFIG_PATCHES_TOWN_GROWTH , NULL ) ,
SDT_CONDVAR ( GameSettings , economy . larger_towns , SLE_UINT8 , 54 , SL_MAX_VERSION , 0 , D0 , 4 , 0 , 255 , 1 , STR_CONFIG_PATCHES_LARGER_TOWNS , NULL ) ,
SDT_CONDVAR ( GameSettings , economy . initial_city_size , SLE_UINT8 , 56 , SL_MAX_VERSION , 0 , 0 , 2 , 1 , 10 , 1 , STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER , NULL ) ,
SDT_CONDBOOL ( GameSettings , economy . mod_road_rebuild , 77 , SL_MAX_VERSION , 0 , 0 , false , STR_CONFIG_MODIFIED_ROAD_REBUILD , NULL ) ,
SDT_BOOL ( GameSettings , ai . ainew_active , 0 , 0 , false , STR_CONFIG_PATCHES_AINEW_ACTIVE , AiNew_PatchActive_Warning ) ,
SDT_BOOL ( GameSettings , ai . ai_in_multiplayer , 0 , 0 , false , STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER , Ai_In_Multiplayer_Warning ) ,
SDT_BOOL ( GameSettings , ai . ai_disable_veh_train , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_TRAINS , NULL ) ,
SDT_BOOL ( GameSettings , ai . ai_disable_veh_roadveh , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH , NULL ) ,
SDT_BOOL ( GameSettings , ai . ai_disable_veh_aircraft , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT , NULL ) ,
SDT_BOOL ( GameSettings , ai . ai_disable_veh_ship , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_SHIPS , NULL ) ,
SDT_VAR ( GameSettings , vehicle . extend_vehicle_life , SLE_UINT8 , 0 , 0 , 0 , 0 , 100 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , economy . dist_local_authority , SLE_UINT8 , 0 , 0 , 20 , 5 , 60 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . wait_oneway_signal , SLE_UINT8 , 0 , 0 , 15 , 2 , 100 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . wait_twoway_signal , SLE_UINT8 , 0 , 0 , 41 , 2 , 100 , 0 , STR_NULL , NULL ) ,
SDT_CONDLISTO ( GameSettings , economy . town_noise_population , 3 , SLE_UINT16 , 96 , SL_MAX_VERSION , 0 , D0 , " 800,2000,4000 " , STR_NULL , NULL , CheckNoiseToleranceLevel ) ,
2008-08-02 22:53:51 +00:00
SDT_CONDVAR ( GameSettings , pf . wait_for_pbs_path , SLE_UINT8 , 100 , SL_MAX_VERSION , 0 , 0 , 30 , 2 , 255 , 0 , STR_NULL , NULL ) ,
SDT_CONDBOOL ( GameSettings , pf . reserve_paths , 100 , SL_MAX_VERSION , 0 , 0 , false , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . path_backoff_interval , SLE_UINT8 , 100 , SL_MAX_VERSION , 0 , 0 , 20 , 1 , 255 , 0 , STR_NULL , NULL ) ,
2008-05-29 15:13:28 +00:00
SDT_VAR ( GameSettings , pf . opf . pf_maxlength , SLE_UINT16 , 0 , 0 , 4096 , 64 , 65535 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . opf . pf_maxdepth , SLE_UINT8 , 0 , 0 , 48 , 4 , 255 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_max_search_nodes , SLE_UINT , 0 , 0 , 10000 , 500 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_rail_firstred_penalty , SLE_UINT , 0 , 0 , ( 10 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_rail_firstred_exit_penalty , SLE_UINT , 0 , 0 , ( 100 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_rail_lastred_penalty , SLE_UINT , 0 , 0 , ( 10 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_rail_station_penalty , SLE_UINT , 0 , 0 , ( 1 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_rail_slope_penalty , SLE_UINT , 0 , 0 , ( 1 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_rail_curve_penalty , SLE_UINT , 0 , 0 , 1 , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_rail_depot_reverse_penalty , SLE_UINT , 0 , 0 , ( 50 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:52:36 +00:00
SDT_CONDVAR ( GameSettings , pf . npf . npf_rail_pbs_cross_penalty , SLE_UINT , 100 , SL_MAX_VERSION , 0 , 0 , ( 3 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . npf . npf_rail_pbs_signal_back_penalty , SLE_UINT , 100 , SL_MAX_VERSION , 0 , 0 , ( 15 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
2008-05-29 15:13:28 +00:00
SDT_VAR ( GameSettings , pf . npf . npf_buoy_penalty , SLE_UINT , 0 , 0 , ( 2 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_water_curve_penalty , SLE_UINT , 0 , 0 , ( NPF_TILE_LENGTH / 4 ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_road_curve_penalty , SLE_UINT , 0 , 0 , 1 , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_VAR ( GameSettings , pf . npf . npf_crossing_penalty , SLE_UINT , 0 , 0 , ( 3 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . npf . npf_road_drive_through_penalty , SLE_UINT , 47 , SL_MAX_VERSION , 0 , 0 , ( 8 * NPF_TILE_LENGTH ) , 0 , 100000 , 0 , STR_NULL , NULL ) ,
SDT_CONDBOOL ( GameSettings , pf . yapf . disable_node_optimization , 28 , SL_MAX_VERSION , 0 , 0 , false , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . max_search_nodes , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10000 , 500 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDBOOL ( GameSettings , pf . yapf . rail_firstred_twoway_eol , 28 , SL_MAX_VERSION , 0 , 0 , true , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_firstred_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_firstred_exit_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 100 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_lastred_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_lastred_exit_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 100 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:57:47 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_station_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-05-29 15:13:28 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_slope_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 2 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:57:47 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_curve45_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 3 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-05-29 15:13:28 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_curve90_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 6 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_depot_reverse_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 50 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_crossing_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 3 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_look_ahead_max_signals , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10 , 1 , 100 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_look_ahead_signal_p0 , SLE_INT , 28 , SL_MAX_VERSION , 0 , 0 , 500 , - 1000000 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_look_ahead_signal_p1 , SLE_INT , 28 , SL_MAX_VERSION , 0 , 0 , - 100 , - 1000000 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_look_ahead_signal_p2 , SLE_INT , 28 , SL_MAX_VERSION , 0 , 0 , 5 , - 1000000 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:51:07 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_pbs_cross_penalty , SLE_UINT , 100 , SL_MAX_VERSION , 0 , 0 , 3 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:51:38 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_pbs_station_penalty , SLE_UINT , 100 , SL_MAX_VERSION , 0 , 0 , 8 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:51:07 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_pbs_signal_back_penalty , SLE_UINT , 100 , SL_MAX_VERSION , 0 , 0 , 15 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:51:23 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_doubleslip_penalty , SLE_UINT , 100 , SL_MAX_VERSION , 0 , 0 , 1 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
2008-05-29 15:13:28 +00:00
SDT_CONDVAR ( GameSettings , pf . yapf . rail_longer_platform_penalty , SLE_UINT , 33 , SL_MAX_VERSION , 0 , 0 , 8 * YAPF_TILE_LENGTH , 0 , 20000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_longer_platform_per_tile_penalty , SLE_UINT , 33 , SL_MAX_VERSION , 0 , 0 , 0 * YAPF_TILE_LENGTH , 0 , 20000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_shorter_platform_penalty , SLE_UINT , 33 , SL_MAX_VERSION , 0 , 0 , 40 * YAPF_TILE_LENGTH , 0 , 20000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . rail_shorter_platform_per_tile_penalty , SLE_UINT , 33 , SL_MAX_VERSION , 0 , 0 , 0 * YAPF_TILE_LENGTH , 0 , 20000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . road_slope_penalty , SLE_UINT , 33 , SL_MAX_VERSION , 0 , 0 , 2 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . road_curve_penalty , SLE_UINT , 33 , SL_MAX_VERSION , 0 , 0 , 1 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . road_crossing_penalty , SLE_UINT , 33 , SL_MAX_VERSION , 0 , 0 , 3 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , pf . yapf . road_stop_penalty , SLE_UINT , 47 , SL_MAX_VERSION , 0 , 0 , 8 * YAPF_TILE_LENGTH , 0 , 1000000 , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , game_creation . land_generator , SLE_UINT8 , 30 , SL_MAX_VERSION , 0 , MS , 1 , 0 , 1 , 0 , STR_CONFIG_PATCHES_LAND_GENERATOR , NULL ) ,
SDT_CONDVAR ( GameSettings , game_creation . oil_refinery_limit , SLE_UINT8 , 30 , SL_MAX_VERSION , 0 , 0 , 32 , 12 , 48 , 0 , STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE , NULL ) ,
SDT_CONDVAR ( GameSettings , game_creation . tgen_smoothness , SLE_UINT8 , 30 , SL_MAX_VERSION , 0 , MS , 1 , 0 , 3 , 0 , STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN , NULL ) ,
SDT_CONDVAR ( GameSettings , game_creation . generation_seed , SLE_UINT32 , 30 , SL_MAX_VERSION , 0 , 0 , GENERATE_NEW_SEED , 0 , UINT32_MAX , 0 , STR_NULL , NULL ) ,
SDT_CONDVAR ( GameSettings , game_creation . tree_placer , SLE_UINT8 , 30 , SL_MAX_VERSION , 0 , MS , 2 , 0 , 2 , 0 , STR_CONFIG_PATCHES_TREE_PLACER , NULL ) ,
SDT_VAR ( GameSettings , game_creation . heightmap_rotation , SLE_UINT8 , S , MS , 0 , 0 , 1 , 0 , STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION , NULL ) ,
SDT_VAR ( GameSettings , game_creation . se_flat_world_height , SLE_UINT8 , S , 0 , 0 , 0 , 15 , 0 , STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT , NULL ) ,
SDT_VAR ( GameSettings , game_creation . map_x , SLE_UINT8 , S , 0 , 8 , 6 , 11 , 0 , STR_CONFIG_PATCHES_MAP_X , NULL ) ,
SDT_VAR ( GameSettings , game_creation . map_y , SLE_UINT8 , S , 0 , 8 , 6 , 11 , 0 , STR_CONFIG_PATCHES_MAP_Y , NULL ) ,
2008-06-05 11:26:38 +00:00
SDT_CONDOMANY ( GameSettings , locale . currency , SLE_UINT8 , 97 , SL_MAX_VERSION , N , 0 , 0 , CUSTOM_CURRENCY_ID , " GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom " , STR_NULL , NULL , NULL ) ,
SDT_CONDOMANY ( GameSettings , locale . units , SLE_UINT8 , 97 , SL_MAX_VERSION , N , 0 , 1 , 2 , " imperial|metric|si " , STR_NULL , NULL , NULL ) ,
2008-05-26 00:31:36 +00:00
2006-03-02 00:07:41 +00:00
/***************************************************************************/
2008-05-25 19:17:03 +00:00
/* Unsaved patch variables. */
2008-05-30 09:23:05 +00:00
SDTC_OMANY ( gui . autosave , SLE_UINT8 , S , 0 , 1 , 4 , " off|monthly|quarterly|half year|yearly " , STR_NULL , NULL ) ,
SDTC_BOOL ( gui . vehicle_speed , S , 0 , true , STR_CONFIG_PATCHES_VEHICLESPEED , NULL ) ,
SDTC_BOOL ( gui . status_long_date , S , 0 , true , STR_CONFIG_PATCHES_LONGDATE , NULL ) ,
SDTC_BOOL ( gui . show_finances , S , 0 , true , STR_CONFIG_PATCHES_SHOWFINANCES , NULL ) ,
SDTC_BOOL ( gui . autoscroll , S , 0 , false , STR_CONFIG_PATCHES_AUTOSCROLL , NULL ) ,
SDTC_BOOL ( gui . reverse_scroll , S , 0 , false , STR_CONFIG_PATCHES_REVERSE_SCROLLING , NULL ) ,
SDTC_BOOL ( gui . smooth_scroll , S , 0 , false , STR_CONFIG_PATCHES_SMOOTH_SCROLLING , NULL ) ,
SDTC_BOOL ( gui . measure_tooltip , S , 0 , false , STR_CONFIG_PATCHES_MEASURE_TOOLTIP , NULL ) ,
SDTC_VAR ( gui . errmsg_duration , SLE_UINT8 , S , 0 , 5 , 0 , 20 , 0 , STR_CONFIG_PATCHES_ERRMSG_DURATION , NULL ) ,
SDTC_VAR ( gui . toolbar_pos , SLE_UINT8 , S , MS , 0 , 0 , 2 , 0 , STR_CONFIG_PATCHES_TOOLBAR_POS , v_PositionMainToolbar ) ,
SDTC_VAR ( gui . window_snap_radius , SLE_UINT8 , S , D0 , 10 , 1 , 32 , 0 , STR_CONFIG_PATCHES_SNAP_RADIUS , NULL ) ,
SDTC_BOOL ( gui . population_in_label , S , 0 , true , STR_CONFIG_PATCHES_POPULATION_IN_LABEL , PopulationInLabelActive ) ,
SDTC_BOOL ( gui . link_terraform_toolbar , S , 0 , false , STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR , NULL ) ,
SDTC_VAR ( gui . liveries , SLE_UINT8 , S , MS , 2 , 0 , 2 , 0 , STR_CONFIG_PATCHES_LIVERIES , RedrawScreen ) ,
SDTC_BOOL ( gui . prefer_teamchat , S , 0 , false , STR_CONFIG_PATCHES_PREFER_TEAMCHAT , NULL ) ,
SDTC_VAR ( gui . scrollwheel_scrolling , SLE_UINT8 , S , MS , 0 , 0 , 2 , 0 , STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING , NULL ) ,
SDTC_VAR ( gui . scrollwheel_multiplier , SLE_UINT8 , S , 0 , 5 , 1 , 15 , 1 , STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER , NULL ) ,
SDTC_BOOL ( gui . pause_on_newgame , S , 0 , false , STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME , NULL ) ,
SDTC_VAR ( gui . advanced_vehicle_list , SLE_UINT8 , S , MS , 1 , 0 , 2 , 0 , STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS , NULL ) ,
SDTC_BOOL ( gui . timetable_in_ticks , S , 0 , false , STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS , NULL ) ,
SDTC_VAR ( gui . loading_indicators , SLE_UINT8 , S , MS , 1 , 0 , 2 , 0 , STR_CONFIG_PATCHES_LOADING_INDICATORS , RedrawScreen ) ,
SDTC_VAR ( gui . default_rail_type , SLE_UINT8 , S , MS , 4 , 0 , 6 , 0 , STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE , NULL ) ,
SDTC_BOOL ( gui . enable_signal_gui , S , 0 , false , STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI , CloseSignalGUI ) ,
SDTC_VAR ( gui . drag_signals_density , SLE_UINT8 , S , 0 , 4 , 1 , 20 , 0 , STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY , DragSignalsDensityChanged ) ,
SDTC_VAR ( gui . semaphore_build_before , SLE_INT32 , S , NC , 1975 , MIN_YEAR , MAX_YEAR , 1 , STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE , ResetSignalVariant ) ,
SDTC_BOOL ( gui . train_income_warn , S , 0 , true , STR_CONFIG_PATCHES_WARN_INCOME_LESS , NULL ) ,
SDTC_VAR ( gui . order_review_system , SLE_UINT8 , S , MS , 2 , 0 , 2 , 0 , STR_CONFIG_PATCHES_ORDER_REVIEW , NULL ) ,
SDTC_BOOL ( gui . lost_train_warn , S , 0 , true , STR_CONFIG_PATCHES_WARN_LOST_TRAIN , NULL ) ,
SDTC_BOOL ( gui . autorenew , S , 0 , false , STR_CONFIG_PATCHES_AUTORENEW_VEHICLE , EngineRenewUpdate ) ,
SDTC_VAR ( gui . autorenew_months , SLE_INT16 , S , 0 , 6 , - 12 , 12 , 0 , STR_CONFIG_PATCHES_AUTORENEW_MONTHS , EngineRenewMonthsUpdate ) ,
SDTC_VAR ( gui . autorenew_money , SLE_UINT , S , CR , 100000 , 0 , 2000000 , 0 , STR_CONFIG_PATCHES_AUTORENEW_MONEY , EngineRenewMoneyUpdate ) ,
SDTC_BOOL ( gui . always_build_infrastructure , S , 0 , false , STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE , RedrawScreen ) ,
2008-09-08 19:20:39 +00:00
SDTC_BOOL ( gui . new_nonstop , S , 0 , false , STR_CONFIG_PATCHES_NONSTOP_BY_DEFAULT , NULL ) ,
2008-05-30 09:23:05 +00:00
SDTC_BOOL ( gui . keep_all_autosave , S , 0 , false , STR_NULL , NULL ) ,
SDTC_BOOL ( gui . autosave_on_exit , S , 0 , false , STR_NULL , NULL ) ,
SDTC_VAR ( gui . max_num_autosaves , SLE_UINT8 , S , 0 , 16 , 0 , 255 , 0 , STR_NULL , NULL ) ,
SDTC_BOOL ( gui . bridge_pillars , S , 0 , true , STR_NULL , NULL ) ,
SDTC_BOOL ( gui . auto_euro , S , 0 , true , STR_NULL , NULL ) ,
SDTC_VAR ( gui . news_message_timeout , SLE_UINT8 , S , 0 , 2 , 1 , 255 , 0 , STR_NULL , NULL ) ,
2008-08-02 22:47:34 +00:00
SDTC_BOOL ( gui . show_track_reservation , S , 0 , false , STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION , RedrawScreen ) ,
2008-08-02 22:49:23 +00:00
SDTC_VAR ( gui . default_signal_type , SLE_UINT8 , S , MS , 0 , 0 , 2 , 1 , STR_CONFIG_PATCHES_DEFAULT_SIGNAL_TYPE , NULL ) ,
SDTC_VAR ( gui . cycle_signal_types , SLE_UINT8 , S , MS , 0 , 0 , 2 , 1 , STR_CONFIG_PATCHES_CYCLE_SIGNAL_TYPES , NULL ) ,
2008-05-30 09:23:05 +00:00
2008-08-12 20:49:27 +00:00
SDTC_VAR ( gui . console_backlog_timeout , SLE_UINT16 , S , 0 , 100 , 10 , 65500 , 0 , STR_NULL , NULL ) ,
SDTC_VAR ( gui . console_backlog_length , SLE_UINT16 , S , 0 , 100 , 10 , 65500 , 0 , STR_NULL , NULL ) ,
2008-05-30 09:23:05 +00:00
# ifdef ENABLE_NETWORK
2008-08-12 12:23:05 +00:00
SDTC_VAR ( gui . network_chat_box_width , SLE_UINT16 , S , 0 , 700 , 200 , 65535 , 0 , STR_NULL , NULL ) ,
SDTC_VAR ( gui . network_chat_box_height , SLE_UINT8 , S , 0 , 25 , 5 , 255 , 0 , STR_NULL , NULL ) ,
2008-05-30 09:23:05 +00:00
SDTC_VAR ( network . sync_freq , SLE_UINT16 , C | S , NO , 100 , 0 , 100 , 0 , STR_NULL , NULL ) ,
SDTC_VAR ( network . frame_freq , SLE_UINT8 , C | S , NO , 0 , 0 , 100 , 0 , STR_NULL , NULL ) ,
SDTC_VAR ( network . max_join_time , SLE_UINT16 , S , NO , 500 , 0 , 32000 , 0 , STR_NULL , NULL ) ,
SDTC_BOOL ( network . pause_on_join , S , NO , true , STR_NULL , NULL ) ,
SDTC_STR ( network . server_bind_ip , SLE_STRB , S , NO , " 0.0.0.0 " , STR_NULL , NULL ) ,
SDTC_VAR ( network . server_port , SLE_UINT16 , S , NO , NETWORK_DEFAULT_PORT , 0 , 65535 , 0 , STR_NULL , NULL ) ,
SDTC_BOOL ( network . server_advertise , S , NO , false , STR_NULL , NULL ) ,
SDTC_VAR ( network . lan_internet , SLE_UINT8 , S , NO , 0 , 0 , 1 , 0 , STR_NULL , NULL ) ,
2008-09-30 20:39:50 +00:00
SDTC_STR ( network . client_name , SLE_STRB , S , 0 , NULL , STR_NULL , UpdateClientName ) ,
2008-05-30 09:23:05 +00:00
SDTC_STR ( network . server_password , SLE_STRB , S , NO , NULL , STR_NULL , UpdateServerPassword ) ,
SDTC_STR ( network . rcon_password , SLE_STRB , S , NO , NULL , STR_NULL , UpdateRconPassword ) ,
SDTC_STR ( network . default_company_pass , SLE_STRB , S , 0 , NULL , STR_NULL , NULL ) ,
2008-06-03 08:04:35 +00:00
SDTC_STR ( network . server_name , SLE_STRB , S , NO , NULL , STR_NULL , NULL ) ,
2008-05-30 09:23:05 +00:00
SDTC_STR ( network . connect_to_ip , SLE_STRB , S , 0 , NULL , STR_NULL , NULL ) ,
SDTC_STR ( network . network_id , SLE_STRB , S , NO , NULL , STR_NULL , NULL ) ,
SDTC_BOOL ( network . autoclean_companies , S , NO , false , STR_NULL , NULL ) ,
2008-07-21 13:05:43 +00:00
SDTC_VAR ( network . autoclean_unprotected , SLE_UINT8 , S , D0 | NO , 12 , 0 , 240 , 0 , STR_NULL , NULL ) ,
SDTC_VAR ( network . autoclean_protected , SLE_UINT8 , S , D0 | NO , 36 , 0 , 240 , 0 , STR_NULL , NULL ) ,
2008-09-30 20:39:50 +00:00
SDTC_VAR ( network . max_companies , SLE_UINT8 , S , NO , 8 , 1 , MAX_COMPANIES , 0 , STR_NULL , NULL ) ,
2008-05-30 09:23:05 +00:00
SDTC_VAR ( network . max_clients , SLE_UINT8 , S , NO , 10 , 2 , MAX_CLIENTS , 0 , STR_NULL , NULL ) ,
SDTC_VAR ( network . max_spectators , SLE_UINT8 , S , NO , 10 , 0 , MAX_CLIENTS , 0 , STR_NULL , NULL ) ,
SDTC_VAR ( network . restart_game_year , SLE_INT32 , S , D0 | NO | NC , 0 , MIN_YEAR , MAX_YEAR , 1 , STR_NULL , NULL ) ,
2008-09-30 20:39:50 +00:00
SDTC_VAR ( network . min_active_clients , SLE_UINT8 , S , NO , 0 , 0 , 10 , 0 , STR_NULL , UpdateMinActiveClients ) ,
2008-05-30 09:23:05 +00:00
SDTC_OMANY ( network . server_lang , SLE_UINT8 , S , NO , 0 , 35 , " ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN " , STR_NULL , NULL ) ,
SDTC_BOOL ( network . reload_cfg , S , NO , false , STR_NULL , NULL ) ,
SDTC_STR ( network . last_host , SLE_STRB , S , 0 , " 0.0.0.0 " , STR_NULL , NULL ) ,
SDTC_VAR ( network . last_port , SLE_UINT16 , S , 0 , 0 , 0 , UINT16_MAX , 0 , STR_NULL , NULL ) ,
# endif /* ENABLE_NETWORK */
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
2007-12-25 01:29:54 +00:00
/*
* Since the network code ( CmdChangePatchSetting and friends ) use the index in this array to decide
* which patch the server is talking about all conditional compilation of this array must be at the
* end . This isn ' t really the best solution , the patches the server can tell the client about should
* either use a seperate array or some other form of identifier .
*/
# ifdef __APPLE__
/* We might need to emulate a right mouse button on mac */
2008-05-29 15:13:28 +00:00
SDTC_VAR ( gui . right_mouse_btn_emulation , SLE_UINT8 , S , MS , 0 , 0 , 2 , 0 , STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU , NULL ) ,
2007-12-25 01:29:54 +00:00
# endif
2006-03-02 00:07:41 +00:00
SDT_END ( )
2004-08-09 17:04:08 +00:00
} ;
2006-03-02 00:07:41 +00:00
static const SettingDesc _currency_settings [ ] = {
2006-08-28 09:13:33 +00:00
SDT_VAR ( CurrencySpec , rate , SLE_UINT16 , S , 0 , 1 , 0 , 100 , 0 , STR_NULL , NULL ) ,
SDT_CHR ( CurrencySpec , separator , S , 0 , " . " , STR_NULL , NULL ) ,
2007-04-18 22:10:36 +00:00
SDT_VAR ( CurrencySpec , to_euro , SLE_INT32 , S , 0 , 0 , 0 , 3000 , 0 , STR_NULL , NULL ) ,
2006-08-28 09:13:33 +00:00
SDT_STR ( CurrencySpec , prefix , SLE_STRBQ , S , 0 , NULL , STR_NULL , NULL ) ,
SDT_STR ( CurrencySpec , suffix , SLE_STRBQ , S , 0 , " credits " , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDT_END ( )
2004-12-22 13:19:26 +00:00
} ;
2006-03-02 00:07:41 +00:00
/* Undefine for the shortcut macros above */
# undef S
# undef C
# undef N
# undef D0
# undef NC
# undef MS
# undef NO
# undef CR
2008-05-28 14:36:06 +00:00
/**
* Prepare for reading and old diff_custom by zero - ing the memory .
*/
2008-05-26 00:31:36 +00:00
static void PrepareOldDiffCustom ( )
{
memset ( _old_diff_custom , 0 , sizeof ( _old_diff_custom ) ) ;
}
2008-05-28 14:36:06 +00:00
/**
* Reading of the old diff_custom array and transforming it to the new format .
* @ param savegame is it read from the config or savegame . In the latter case
* we are sure there is an array ; in the former case we have
* to check that .
*/
static void HandleOldDiffCustom ( bool savegame )
2008-05-26 00:31:36 +00:00
{
2008-05-28 14:36:06 +00:00
uint options_to_load = GAME_DIFFICULTY_NUM - ( ( savegame & & CheckSavegameVersion ( 4 ) ) ? 1 : 0 ) ;
2008-05-26 00:31:36 +00:00
2008-05-28 14:36:06 +00:00
if ( ! savegame ) {
/* If we did read to old_diff_custom, then at least one value must be non 0. */
bool old_diff_custom_used = false ;
for ( uint i = 0 ; i < options_to_load & & ! old_diff_custom_used ; i + + ) {
old_diff_custom_used = ( _old_diff_custom [ i ] ! = 0 ) ;
}
2008-05-26 00:31:36 +00:00
2008-05-28 14:36:06 +00:00
if ( ! old_diff_custom_used ) return ;
}
2008-05-26 00:31:36 +00:00
for ( uint i = 0 ; i < options_to_load ; i + + ) {
const SettingDesc * sd = & _patch_settings [ i ] ;
2008-05-29 15:13:28 +00:00
void * var = GetVariableAddress ( savegame ? & _settings_game : & _settings_newgame , & sd - > save ) ;
2008-05-26 00:31:36 +00:00
Write_ValidateSetting ( var , sd , ( int32 ) ( ( i = = 4 ? 1000 : 1 ) * _old_diff_custom [ i ] ) ) ;
}
}
2008-07-30 01:53:03 +00:00
/** tries to convert newly introduced news settings based on old ones
* @ param name pointer to the string defining name of the old news config
* @ param value pointer to the string defining value of the old news config
* @ returns true if conversion could have been made */
bool ConvertOldNewsSetting ( const char * name , const char * value )
{
if ( strcasecmp ( name , " openclose " ) = = 0 ) {
/* openclose has been split in "open" and "close".
* So the job is now to decrypt the value of the old news config
* and give it to the two newly introduced ones */
NewsDisplay display = ND_OFF ; //default
if ( strcasecmp ( value , " full " ) = = 0 ) {
display = ND_FULL ;
} else if ( strcasecmp ( value , " summarized " ) = = 0 ) {
display = ND_SUMMARY ;
}
/* tranfert of values */
_news_type_data [ NT_INDUSTRY_OPEN ] . display = display ;
_news_type_data [ NT_INDUSTRY_CLOSE ] . display = display ;
return true ;
}
return false ;
}
2008-05-26 00:31:36 +00:00
2008-04-20 11:40:33 +00:00
static void NewsDisplayLoadConfig ( IniFile * ini , const char * grpname )
2007-03-10 12:10:00 +00:00
{
2008-08-24 13:50:31 +00:00
IniGroup * group = ini - > GetGroup ( grpname ) ;
2007-03-10 12:10:00 +00:00
IniItem * item ;
2008-04-20 11:40:33 +00:00
/* If no group exists, return */
if ( group = = NULL ) return ;
2007-03-10 12:10:00 +00:00
for ( item = group - > item ; item ! = NULL ; item = item - > next ) {
int news_item = - 1 ;
for ( int i = 0 ; i < NT_END ; i + + ) {
2008-04-19 12:50:02 +00:00
if ( strcasecmp ( item - > name , _news_type_data [ i ] . name ) = = 0 ) {
2007-03-10 12:10:00 +00:00
news_item = i ;
break ;
}
}
2008-07-30 01:53:03 +00:00
/* the config been read is not within current aceptable config */
2007-03-10 12:10:00 +00:00
if ( news_item = = - 1 ) {
2008-07-30 01:53:03 +00:00
/* if the conversion function cannot process it, advice by a debug warning*/
if ( ! ConvertOldNewsSetting ( item - > name , item - > value ) ) {
DEBUG ( misc , 0 , " Invalid display option: %s " , item - > name ) ;
}
/* in all cases, there is nothing left to do */
2007-03-10 12:10:00 +00:00
continue ;
}
if ( strcasecmp ( item - > value , " full " ) = = 0 ) {
2008-04-20 11:40:33 +00:00
_news_type_data [ news_item ] . display = ND_FULL ;
2007-03-10 12:10:00 +00:00
} else if ( strcasecmp ( item - > value , " off " ) = = 0 ) {
2008-04-20 11:40:33 +00:00
_news_type_data [ news_item ] . display = ND_OFF ;
2007-03-10 12:10:00 +00:00
} else if ( strcasecmp ( item - > value , " summarized " ) = = 0 ) {
2008-04-20 11:40:33 +00:00
_news_type_data [ news_item ] . display = ND_SUMMARY ;
2007-03-10 12:10:00 +00:00
} else {
DEBUG ( misc , 0 , " Invalid display value: %s " , item - > value ) ;
continue ;
}
}
}
2006-12-12 19:38:41 +00:00
/* Load a GRF configuration from the given group name */
static GRFConfig * GRFLoadConfig ( IniFile * ini , const char * grpname , bool is_static )
2006-04-22 13:17:13 +00:00
{
2008-08-24 13:50:31 +00:00
IniGroup * group = ini - > GetGroup ( grpname ) ;
2006-12-12 19:38:41 +00:00
IniItem * item ;
GRFConfig * first = NULL ;
GRFConfig * * curr = & first ;
2006-04-22 13:17:13 +00:00
2006-12-12 19:38:41 +00:00
if ( group = = NULL ) return NULL ;
2006-04-22 13:17:13 +00:00
2006-12-12 19:38:41 +00:00
for ( item = group - > item ; item ! = NULL ; item = item - > next ) {
2007-01-11 17:29:39 +00:00
GRFConfig * c = CallocT < GRFConfig > ( 1 ) ;
2007-06-23 21:12:09 +00:00
c - > filename = strdup ( item - > name ) ;
2006-04-22 13:59:21 +00:00
2006-12-12 19:38:41 +00:00
/* Parse parameters */
2008-08-24 13:50:31 +00:00
if ( ! StrEmpty ( item - > value ) ) {
2006-12-12 19:38:41 +00:00
c - > num_params = parse_intlist ( item - > value , ( int * ) c - > param , lengthof ( c - > param ) ) ;
if ( c - > num_params = = ( byte ) - 1 ) {
ShowInfoF ( " ini: error in array '%s' " , item - > name ) ;
c - > num_params = 0 ;
}
2006-04-22 14:06:46 +00:00
}
2006-04-22 13:17:13 +00:00
2006-12-12 19:38:41 +00:00
/* Check if item is valid */
if ( ! FillGRFDetails ( c , is_static ) ) {
const char * msg ;
2007-03-06 19:33:28 +00:00
if ( c - > status = = GCS_NOT_FOUND ) {
2006-12-12 19:38:41 +00:00
msg = " not found " ;
2007-11-19 21:02:30 +00:00
} else if ( HasBit ( c - > flags , GCF_UNSAFE ) ) {
2006-12-12 19:38:41 +00:00
msg = " unsafe for static use " ;
2007-11-19 21:02:30 +00:00
} else if ( HasBit ( c - > flags , GCF_SYSTEM ) ) {
2006-12-12 19:38:41 +00:00
msg = " system NewGRF " ;
} else {
msg = " unknown " ;
}
ShowInfoF ( " ini: ignoring invalid NewGRF '%s': %s " , item - > name , msg ) ;
2006-12-20 20:43:52 +00:00
ClearGRFConfig ( & c ) ;
2006-12-12 19:38:41 +00:00
continue ;
}
/* Mark file as static to avoid saving in savegame. */
2007-11-20 13:35:54 +00:00
if ( is_static ) SetBit ( c - > flags , GCF_STATIC ) ;
2006-12-12 19:38:41 +00:00
/* Add item to list */
* curr = c ;
curr = & c - > next ;
2006-04-22 13:17:13 +00:00
}
2006-12-12 19:38:41 +00:00
return first ;
2006-04-22 13:17:13 +00:00
}
2004-08-09 17:04:08 +00:00
2008-04-20 11:40:33 +00:00
static void NewsDisplaySaveConfig ( IniFile * ini , const char * grpname )
2007-03-10 12:10:00 +00:00
{
2008-08-24 13:50:31 +00:00
IniGroup * group = ini - > GetGroup ( grpname ) ;
2007-03-10 12:10:00 +00:00
for ( int i = 0 ; i < NT_END ; i + + ) {
const char * value ;
2008-04-20 11:40:33 +00:00
int v = _news_type_data [ i ] . display ;
2007-03-10 12:10:00 +00:00
2008-04-20 11:40:33 +00:00
value = ( v = = ND_OFF ? " off " : ( v = = ND_SUMMARY ? " summarized " : " full " ) ) ;
2007-03-10 12:10:00 +00:00
2008-08-25 15:15:41 +00:00
group - > GetItem ( _news_type_data [ i ] . name , true ) - > SetValue ( value ) ;
2007-03-10 12:10:00 +00:00
}
}
2006-12-12 19:38:41 +00:00
2008-03-27 15:29:42 +00:00
/**
* Save the version of OpenTTD to the ini file .
* @ param ini the ini to write to
*/
static void SaveVersionInConfig ( IniFile * ini )
{
2008-08-24 13:50:31 +00:00
IniGroup * group = ini - > GetGroup ( " version " ) ;
2008-03-27 15:29:42 +00:00
char version [ 9 ] ;
snprintf ( version , lengthof ( version ) , " %08X " , _openttd_newgrf_version ) ;
const char * versions [ ] [ 2 ] = {
{ " version_string " , _openttd_revision } ,
{ " version_number " , version }
} ;
for ( uint i = 0 ; i < lengthof ( versions ) ; i + + ) {
2008-08-25 15:15:41 +00:00
group - > GetItem ( versions [ i ] [ 0 ] , true ) - > SetValue ( versions [ i ] [ 1 ] ) ;
2008-03-27 15:29:42 +00:00
}
}
2006-12-12 19:38:41 +00:00
/* Save a GRF configuration to the given group name */
2006-12-10 11:32:54 +00:00
static void GRFSaveConfig ( IniFile * ini , const char * grpname , const GRFConfig * list )
{
2008-08-29 21:06:49 +00:00
ini - > RemoveGroup ( grpname ) ;
2008-08-24 13:50:31 +00:00
IniGroup * group = ini - > GetGroup ( grpname ) ;
2006-12-10 11:32:54 +00:00
const GRFConfig * c ;
for ( c = list ; c ! = NULL ; c = c - > next ) {
char params [ 512 ] ;
GRFBuildParamList ( params , c , lastof ( params ) ) ;
2008-08-25 15:15:41 +00:00
group - > GetItem ( c - > filename , true ) - > SetValue ( params ) ;
2006-12-10 11:32:54 +00:00
}
}
2006-03-02 00:07:41 +00:00
/* Common handler for saving/loading variables to the configuration file */
static void HandleSettingDescs ( IniFile * ini , SettingDescProc * proc , SettingDescProcList * proc_list )
2004-08-09 17:04:08 +00:00
{
2006-03-02 00:07:41 +00:00
proc ( ini , ( const SettingDesc * ) _misc_settings , " misc " , NULL ) ;
proc ( ini , ( const SettingDesc * ) _music_settings , " music " , & msf ) ;
2006-02-20 23:01:58 +00:00
# ifdef WIN32
2006-03-02 00:07:41 +00:00
proc ( ini , ( const SettingDesc * ) _win32_settings , " win32 " , NULL ) ;
2006-02-20 23:01:58 +00:00
# endif /* WIN32 */
2006-03-02 00:07:41 +00:00
2008-05-25 19:17:03 +00:00
proc ( ini , _patch_settings , " patches " , & _settings_newgame ) ;
2006-03-02 00:07:41 +00:00
proc ( ini , _currency_settings , " currency " , & _custom_currency ) ;
2004-12-04 17:54:56 +00:00
# ifdef ENABLE_NETWORK
2006-04-22 13:17:13 +00:00
proc_list ( ini , " servers " , _network_host_list , lengthof ( _network_host_list ) , NULL ) ;
proc_list ( ini , " bans " , _network_ban_list , lengthof ( _network_ban_list ) , NULL ) ;
2004-12-04 17:54:56 +00:00
# endif /* ENABLE_NETWORK */
2004-08-09 17:04:08 +00:00
}
2008-08-24 13:50:31 +00:00
static IniFile * IniLoadConfig ( )
{
IniFile * ini = new IniFile ( _list_group_names ) ;
ini - > LoadFromDisk ( _config_file ) ;
return ini ;
}
2006-03-02 00:07:41 +00:00
/** Load the values from the configuration files */
2007-03-07 11:47:46 +00:00
void LoadFromConfig ( )
2004-08-09 17:04:08 +00:00
{
2008-08-24 13:50:31 +00:00
IniFile * ini = IniLoadConfig ( ) ;
2007-03-25 23:42:55 +00:00
ResetCurrencies ( false ) ; // Initialize the array of curencies, without preserving the custom one
2008-05-28 14:36:06 +00:00
PrepareOldDiffCustom ( ) ;
ini_load_settings ( ini , _gameopt_settings , " gameopt " , & _settings_newgame ) ;
HandleOldDiffCustom ( false ) ;
2006-03-02 00:07:41 +00:00
HandleSettingDescs ( ini , ini_load_settings , ini_load_setting_list ) ;
2006-12-12 19:38:41 +00:00
_grfconfig_newgame = GRFLoadConfig ( ini , " newgrf " , false ) ;
_grfconfig_static = GRFLoadConfig ( ini , " newgrf-static " , true ) ;
2008-04-20 11:40:33 +00:00
NewsDisplayLoadConfig ( ini , " news_display " ) ;
2007-03-25 19:21:22 +00:00
CheckDifficultyLevels ( ) ;
2008-08-24 13:50:31 +00:00
delete ini ;
2004-08-09 17:04:08 +00:00
}
2006-03-02 00:07:41 +00:00
/** Save the values to the configuration file */
2007-03-07 11:47:46 +00:00
void SaveToConfig ( )
2004-08-09 17:04:08 +00:00
{
2008-08-24 13:50:31 +00:00
IniFile * ini = IniLoadConfig ( ) ;
2008-05-25 19:17:03 +00:00
/* Remove some obsolete groups. These have all been loaded into other groups. */
2008-08-24 13:50:31 +00:00
ini - > RemoveGroup ( " patches " ) ;
ini - > RemoveGroup ( " yapf " ) ;
ini - > RemoveGroup ( " gameopt " ) ;
2008-05-25 19:17:03 +00:00
2006-03-02 00:07:41 +00:00
HandleSettingDescs ( ini , ini_save_settings , ini_save_setting_list ) ;
2006-12-10 11:32:54 +00:00
GRFSaveConfig ( ini , " newgrf " , _grfconfig_newgame ) ;
2006-12-12 19:38:41 +00:00
GRFSaveConfig ( ini , " newgrf-static " , _grfconfig_static ) ;
2008-04-20 11:40:33 +00:00
NewsDisplaySaveConfig ( ini , " news_display " ) ;
2008-03-27 15:29:42 +00:00
SaveVersionInConfig ( ini ) ;
2008-08-24 13:50:31 +00:00
ini - > SaveToDisk ( _config_file ) ;
delete ini ;
2004-08-09 17:04:08 +00:00
}
2005-04-13 23:03:31 +00:00
2008-07-22 14:17:29 +00:00
void GetGRFPresetList ( GRFPresetList * list )
{
list - > Clear ( ) ;
2008-08-24 13:50:31 +00:00
IniFile * ini = IniLoadConfig ( ) ;
2008-07-22 14:17:29 +00:00
IniGroup * group ;
for ( group = ini - > group ; group ! = NULL ; group = group - > next ) {
if ( strncmp ( group - > name , " preset- " , 7 ) = = 0 ) {
* list - > Append ( ) = strdup ( group - > name + 7 ) ;
}
}
2008-08-24 13:50:31 +00:00
delete ini ;
2008-07-22 14:17:29 +00:00
}
GRFConfig * LoadGRFPresetFromConfig ( const char * config_name )
{
char * section = ( char * ) alloca ( strlen ( config_name ) + 8 ) ;
sprintf ( section , " preset-%s " , config_name ) ;
2008-08-24 13:50:31 +00:00
IniFile * ini = IniLoadConfig ( ) ;
2008-07-22 14:17:29 +00:00
GRFConfig * config = GRFLoadConfig ( ini , section , false ) ;
2008-08-24 13:50:31 +00:00
delete ini ;
2008-07-22 14:17:29 +00:00
return config ;
}
void SaveGRFPresetToConfig ( const char * config_name , GRFConfig * config )
{
char * section = ( char * ) alloca ( strlen ( config_name ) + 8 ) ;
sprintf ( section , " preset-%s " , config_name ) ;
2008-08-24 13:50:31 +00:00
IniFile * ini = IniLoadConfig ( ) ;
2008-07-22 14:17:29 +00:00
GRFSaveConfig ( ini , section , config ) ;
2008-08-24 13:50:31 +00:00
ini - > SaveToDisk ( _config_file ) ;
delete ini ;
2008-07-22 14:17:29 +00:00
}
void DeleteGRFPresetFromConfig ( const char * config_name )
{
char * section = ( char * ) alloca ( strlen ( config_name ) + 8 ) ;
sprintf ( section , " preset-%s " , config_name ) ;
2008-08-24 13:50:31 +00:00
IniFile * ini = IniLoadConfig ( ) ;
ini - > RemoveGroup ( section ) ;
ini - > SaveToDisk ( _config_file ) ;
delete ini ;
2008-07-22 14:17:29 +00:00
}
2006-03-17 22:47:52 +00:00
static const SettingDesc * GetSettingDescription ( uint index )
2006-03-02 01:41:25 +00:00
{
if ( index > = lengthof ( _patch_settings ) ) return NULL ;
return & _patch_settings [ index ] ;
}
2006-03-02 01:56:25 +00:00
/** Network-safe changing of patch-settings (server-only).
2007-04-17 21:09:38 +00:00
* @ param tile unused
* @ param flags operation to perform
2006-03-02 01:56:25 +00:00
* @ param p1 the index of the patch in the SettingDesc array which identifies it
* @ param p2 the new value for the patch
* The new value is properly clamped to its minimum / maximum when setting
* @ see _patch_settings
*/
2007-06-18 10:48:15 +00:00
CommandCost CmdChangePatchSetting ( TileIndex tile , uint32 flags , uint32 p1 , uint32 p2 )
2006-03-02 01:56:25 +00:00
{
const SettingDesc * sd = GetSettingDescription ( p1 ) ;
if ( sd = = NULL ) return CMD_ERROR ;
2006-03-16 00:22:36 +00:00
if ( ! SlIsObjectCurrentlyValid ( sd - > save . version_from , sd - > save . version_to ) ) return CMD_ERROR ;
2006-03-02 01:56:25 +00:00
2008-05-30 09:23:05 +00:00
if ( ( sd - > desc . flags & SGF_NETWORK_ONLY ) & & ! _networking & & _game_mode ! = GM_MENU ) return CMD_ERROR ;
2007-11-17 22:25:16 +00:00
if ( ( sd - > desc . flags & SGF_NO_NETWORK ) & & _networking ) return CMD_ERROR ;
2008-05-26 00:31:36 +00:00
if ( ( sd - > desc . flags & SGF_NEWGAME_ONLY ) & & _game_mode ! = GM_MENU ) return CMD_ERROR ;
2007-11-17 22:25:16 +00:00
2006-03-02 01:56:25 +00:00
if ( flags & DC_EXEC ) {
2008-05-29 15:13:28 +00:00
GameSettings * s = ( _game_mode = = GM_MENU ) ? & _settings_newgame : & _settings_game ;
2008-05-25 19:17:03 +00:00
void * var = GetVariableAddress ( s , & sd - > save ) ;
2008-06-03 18:35:58 +00:00
int32 oldval = ( int32 ) ReadValue ( var , sd - > save . conv ) ;
int32 newval = ( int32 ) p2 ;
Write_ValidateSetting ( var , sd , newval ) ;
newval = ( int32 ) ReadValue ( var , sd - > save . conv ) ;
if ( sd - > desc . proc ! = NULL ) sd - > desc . proc ( newval ) ;
if ( ( sd - > desc . flags & SGF_NO_NETWORK ) & & oldval ! = newval ) {
GamelogStartAction ( GLAT_PATCH ) ;
GamelogPatch ( sd - > desc . name , oldval , newval ) ;
GamelogStopAction ( ) ;
}
2006-03-02 01:56:25 +00:00
InvalidateWindow ( WC_GAME_OPTIONS , 0 ) ;
}
2007-06-18 19:53:50 +00:00
return CommandCost ( ) ;
2006-03-02 01:56:25 +00:00
}
2006-04-22 00:10:38 +00:00
/** Top function to save the new value of an element of the Patches struct
2006-03-02 01:41:25 +00:00
* @ param index offset in the SettingDesc array of the Patches struct which
* identifies the patch member we want to change
* @ param object pointer to a valid patches struct that has its settings change .
* This only affects patch - members that are not needed to be the same on all
* clients in a network game .
* @ param value new value of the patch */
2008-05-29 15:13:28 +00:00
bool SetPatchValue ( uint index , int32 value )
2006-03-02 01:41:25 +00:00
{
const SettingDesc * sd = & _patch_settings [ index ] ;
2008-09-30 20:39:50 +00:00
/* If an item is company-based, we do not send it over the network
2006-03-02 01:41:25 +00:00
* ( if any ) to change . Also * hack * hack * we update the _newgame version
2008-09-30 20:39:50 +00:00
* of patches because changing a company - based setting in a game also
2006-03-02 01:41:25 +00:00
* changes its defaults . At least that is the convention we have chosen */
if ( sd - > save . conv & SLF_NETWORK_NO ) {
2008-05-29 15:13:28 +00:00
void * var = GetVariableAddress ( ( _game_mode = = GM_MENU ) ? & _settings_newgame : & _settings_game , & sd - > save ) ;
2006-03-02 01:41:25 +00:00
Write_ValidateSetting ( var , sd , value ) ;
2006-03-02 02:22:15 +00:00
if ( _game_mode ! = GM_MENU ) {
2008-05-25 19:17:03 +00:00
void * var2 = GetVariableAddress ( & _settings_newgame , & sd - > save ) ;
2006-06-27 21:25:53 +00:00
Write_ValidateSetting ( var2 , sd , value ) ;
2006-03-02 02:22:15 +00:00
}
2006-11-17 10:42:20 +00:00
if ( sd - > desc . proc ! = NULL ) sd - > desc . proc ( ( int32 ) ReadValue ( var , sd - > save . conv ) ) ;
2006-09-14 23:26:58 +00:00
InvalidateWindow ( WC_GAME_OPTIONS , 0 ) ;
return true ;
2006-03-02 01:41:25 +00:00
}
2006-09-14 23:26:58 +00:00
2008-09-30 20:39:50 +00:00
/* send non-company-based settings over the network */
2006-09-14 23:26:58 +00:00
if ( ! _networking | | ( _networking & & _network_server ) ) {
return DoCommandP ( 0 , index , value , NULL , CMD_CHANGE_PATCH_SETTING ) ;
}
return false ;
2006-03-02 01:41:25 +00:00
}
2008-05-30 09:23:05 +00:00
/**
* Set a patch value with a string .
* @ param index the patch settings index .
* @ param value the value to write
* @ note CANNOT BE SAVED IN THE SAVEGAME .
*/
bool SetPatchValue ( uint index , const char * value )
{
const SettingDesc * sd = & _patch_settings [ index ] ;
assert ( sd - > save . conv & SLF_NETWORK_NO ) ;
char * var = ( char * ) GetVariableAddress ( NULL , & sd - > save ) ;
ttd_strlcpy ( var , value , sd - > save . length ) ;
2008-06-03 08:04:35 +00:00
if ( sd - > desc . proc ! = NULL ) sd - > desc . proc ( 0 ) ;
2008-05-30 09:23:05 +00:00
return true ;
}
2008-09-28 15:42:15 +00:00
/**
* Given a name of patch , return a setting description of it .
* @ param name Name of the patch to return a setting description of
* @ param i Pointer to an integer that will contain the index of the setting after the call , if it is successful .
* @ return Pointer to the setting description of patch \ a name if it can be found ,
* \ c NULL indicates failure to obtain the description
*/
2006-03-17 22:47:52 +00:00
const SettingDesc * GetPatchFromName ( const char * name , uint * i )
2006-03-02 01:56:25 +00:00
{
const SettingDesc * sd ;
2008-05-26 05:58:15 +00:00
/* First check all full names */
2006-03-03 11:27:18 +00:00
for ( * i = 0 , sd = _patch_settings ; sd - > save . cmd ! = SL_END ; sd + + , ( * i ) + + ) {
2006-03-16 00:22:36 +00:00
if ( ! SlIsObjectCurrentlyValid ( sd - > save . version_from , sd - > save . version_to ) ) continue ;
2006-03-15 12:37:59 +00:00
if ( strcmp ( sd - > desc . name , name ) = = 0 ) return sd ;
2006-03-02 01:56:25 +00:00
}
2008-05-26 05:58:15 +00:00
/* Then check the shortcut variant of the name. */
for ( * i = 0 , sd = _patch_settings ; sd - > save . cmd ! = SL_END ; sd + + , ( * i ) + + ) {
if ( ! SlIsObjectCurrentlyValid ( sd - > save . version_from , sd - > save . version_to ) ) continue ;
const char * short_name = strchr ( sd - > desc . name , ' . ' ) ;
if ( short_name ! = NULL ) {
short_name + + ;
if ( strcmp ( short_name , name ) = = 0 ) return sd ;
}
}
2006-03-02 01:56:25 +00:00
return NULL ;
}
/* Those 2 functions need to be here, else we have to make some stuff non-static
2006-08-15 07:37:01 +00:00
* and besides , it is also better to keep stuff like this at the same place */
2008-05-30 09:23:05 +00:00
void IConsoleSetPatchSetting ( const char * name , const char * value )
2006-03-02 01:56:25 +00:00
{
uint index ;
const SettingDesc * sd = GetPatchFromName ( name , & index ) ;
if ( sd = = NULL ) {
2008-05-24 10:35:15 +00:00
IConsolePrintF ( CC_WARNING , " '%s' is an unknown patch setting. " , name ) ;
2008-06-02 23:01:57 +00:00
return ;
2006-03-02 01:56:25 +00:00
}
2008-05-30 09:23:05 +00:00
bool success ;
if ( sd - > desc . cmd = = SDT_STRING ) {
success = SetPatchValue ( index , value ) ;
} else {
uint32 val ;
extern bool GetArgumentInteger ( uint32 * value , const char * arg ) ;
success = GetArgumentInteger ( & val , value ) ;
if ( success ) success = SetPatchValue ( index , val ) ;
}
if ( ! success ) {
if ( _network_server ) {
IConsoleError ( " This command/variable is not available during network games. " ) ;
} else {
IConsoleError ( " This command/variable is only available to a network server. " ) ;
}
}
}
2006-03-02 01:56:25 +00:00
2008-05-30 09:23:05 +00:00
void IConsoleSetPatchSetting ( const char * name , int value )
{
uint index ;
const SettingDesc * sd = GetPatchFromName ( name , & index ) ;
assert ( sd ! = NULL ) ;
SetPatchValue ( index , value ) ;
2006-03-02 01:56:25 +00:00
}
2008-09-28 15:42:15 +00:00
/**
* Output value of a specific patch to the console
* @ param name Name of the patch to output its value
*/
2006-03-02 01:56:25 +00:00
void IConsoleGetPatchSetting ( const char * name )
{
char value [ 20 ] ;
uint index ;
const SettingDesc * sd = GetPatchFromName ( name , & index ) ;
const void * ptr ;
if ( sd = = NULL ) {
2008-05-24 10:35:15 +00:00
IConsolePrintF ( CC_WARNING , " '%s' is an unknown patch setting. " , name ) ;
2006-03-02 01:56:25 +00:00
return ;
}
2008-05-29 15:13:28 +00:00
ptr = GetVariableAddress ( ( _game_mode = = GM_MENU ) ? & _settings_newgame : & _settings_game , & sd - > save ) ;
2006-03-02 01:56:25 +00:00
2008-05-30 09:23:05 +00:00
if ( sd - > desc . cmd = = SDT_STRING ) {
IConsolePrintF ( CC_WARNING , " Current value for '%s' is: '%s' " , name , ( const char * ) ptr ) ;
2006-03-02 01:56:25 +00:00
} else {
2008-05-30 09:23:05 +00:00
if ( sd - > desc . cmd = = SDT_BOOLX ) {
snprintf ( value , sizeof ( value ) , ( * ( bool * ) ptr = = 1 ) ? " on " : " off " ) ;
} else {
snprintf ( value , sizeof ( value ) , " %d " , ( int32 ) ReadValue ( ptr , sd - > save . conv ) ) ;
}
2006-03-02 01:56:25 +00:00
2008-05-30 09:23:05 +00:00
IConsolePrintF ( CC_WARNING , " Current value for '%s' is: '%s' (min: %s%d, max: %d) " ,
name , value , ( sd - > desc . flags & SGF_0ISDISABLED ) ? " (0) " : " " , sd - > desc . min , sd - > desc . max ) ;
}
2006-03-02 01:56:25 +00:00
}
2008-09-28 15:42:15 +00:00
/**
* List all patches and their value to the console
*
* @ param prefilter If not \ c NULL , only list patches with names that begin with \ a prefilter prefix
*/
2008-08-11 17:15:31 +00:00
void IConsoleListPatches ( const char * prefilter )
2007-04-05 12:59:57 +00:00
{
2008-05-24 10:35:15 +00:00
IConsolePrintF ( CC_WARNING , " All patches with their current value: " ) ;
2007-04-05 12:59:57 +00:00
for ( const SettingDesc * sd = _patch_settings ; sd - > save . cmd ! = SL_END ; sd + + ) {
2008-08-11 17:15:31 +00:00
if ( prefilter ! = NULL ) {
if ( strncmp ( sd - > desc . name , prefilter , min ( strlen ( sd - > desc . name ) , strlen ( prefilter ) ) ) ! = 0 ) continue ;
}
2007-04-05 12:59:57 +00:00
char value [ 80 ] ;
2008-05-29 15:13:28 +00:00
const void * ptr = GetVariableAddress ( ( _game_mode = = GM_MENU ) ? & _settings_newgame : & _settings_game , & sd - > save ) ;
2007-04-05 12:59:57 +00:00
if ( sd - > desc . cmd = = SDT_BOOLX ) {
snprintf ( value , lengthof ( value ) , ( * ( bool * ) ptr = = 1 ) ? " on " : " off " ) ;
2008-05-30 09:23:05 +00:00
} else if ( sd - > desc . cmd = = SDT_STRING ) {
snprintf ( value , sizeof ( value ) , " %s " , ( const char * ) ptr ) ;
2007-04-05 12:59:57 +00:00
} else {
snprintf ( value , lengthof ( value ) , " %d " , ( uint32 ) ReadValue ( ptr , sd - > save . conv ) ) ;
}
2008-05-24 10:35:15 +00:00
IConsolePrintF ( CC_DEFAULT , " %s = %s " , sd - > desc . name , value ) ;
2007-04-05 12:59:57 +00:00
}
2008-05-24 10:35:15 +00:00
IConsolePrintF ( CC_WARNING , " Use 'patch' command to change a value " ) ;
2007-04-05 12:59:57 +00:00
}
2006-03-02 00:32:48 +00:00
/** Save and load handler for patches/settings
* @ param osd SettingDesc struct containing all information
* @ param object can be either NULL in which case we load global variables or
* a pointer to a struct which is getting saved */
static void LoadSettings ( const SettingDesc * osd , void * object )
{
for ( ; osd - > save . cmd ! = SL_END ; osd + + ) {
const SaveLoad * sld = & osd - > save ;
2008-05-29 15:13:28 +00:00
void * ptr = GetVariableAddress ( object , sld ) ;
2006-03-02 00:32:48 +00:00
if ( ! SlObjectMember ( ptr , sld ) ) continue ;
}
}
/** Loadhandler for a list of global variables
2007-04-17 21:09:38 +00:00
* @ param sdg pointer for the global variable list SettingDescGlobVarList
2006-03-02 00:32:48 +00:00
* @ note this is actually a stub for LoadSettings with the
* object pointer set to NULL */
static inline void LoadSettingsGlobList ( const SettingDescGlobVarList * sdg )
{
LoadSettings ( ( const SettingDesc * ) sdg , NULL ) ;
}
/** Save and load handler for patches/settings
2007-04-17 21:09:38 +00:00
* @ param sd SettingDesc struct containing all information
2006-03-02 00:32:48 +00:00
* @ param object can be either NULL in which case we load global variables or
* a pointer to a struct which is getting saved */
static void SaveSettings ( const SettingDesc * sd , void * object )
{
/* We need to write the CH_RIFF header, but unfortunately can't call
* SlCalcLength ( ) because we have a different format . So do this manually */
const SettingDesc * i ;
size_t length = 0 ;
for ( i = sd ; i - > save . cmd ! = SL_END ; i + + ) {
2006-11-21 20:23:57 +00:00
const void * ptr = GetVariableAddress ( object , & i - > save ) ;
length + = SlCalcObjMemberLength ( ptr , & i - > save ) ;
2006-03-02 00:32:48 +00:00
}
SlSetLength ( length ) ;
for ( i = sd ; i - > save . cmd ! = SL_END ; i + + ) {
2006-11-21 20:20:30 +00:00
void * ptr = GetVariableAddress ( object , & i - > save ) ;
2006-03-02 00:32:48 +00:00
SlObjectMember ( ptr , & i - > save ) ;
}
}
/** Savehandler for a list of global variables
* @ note this is actually a stub for SaveSettings with the
* object pointer set to NULL */
static inline void SaveSettingsGlobList ( const SettingDescGlobVarList * sdg )
{
SaveSettings ( ( const SettingDesc * ) sdg , NULL ) ;
}
2007-03-07 11:47:46 +00:00
static void Load_OPTS ( )
2006-03-02 00:32:48 +00:00
{
/* Copy over default setting since some might not get loaded in
* a networking environment . This ensures for example that the local
* autosave - frequency stays when joining a network - server */
2008-05-26 00:31:36 +00:00
PrepareOldDiffCustom ( ) ;
2008-05-29 15:13:28 +00:00
LoadSettings ( _gameopt_settings , & _settings_game ) ;
2008-05-28 14:36:06 +00:00
HandleOldDiffCustom ( true ) ;
2006-03-02 00:32:48 +00:00
}
2007-03-07 11:47:46 +00:00
static void Load_PATS ( )
2006-03-02 02:22:15 +00:00
{
/* Copy over default setting since some might not get loaded in
* a networking environment . This ensures for example that the local
* signal_side stays when joining a network - server */
2008-05-29 15:13:28 +00:00
LoadSettings ( _patch_settings , & _settings_game ) ;
2006-03-02 02:22:15 +00:00
}
2007-03-07 11:47:46 +00:00
static void Save_PATS ( )
2006-03-02 02:22:15 +00:00
{
2008-05-29 15:13:28 +00:00
SaveSettings ( _patch_settings , & _settings_game ) ;
2006-03-02 02:22:15 +00:00
}
2007-03-07 11:47:46 +00:00
void CheckConfig ( )
2005-04-13 23:03:31 +00:00
{
2008-05-26 21:38:17 +00:00
/*
* Increase old default values for pf_maxdepth and pf_maxlength
* to support big networks .
*/
2008-05-25 19:17:03 +00:00
if ( _settings_newgame . pf . opf . pf_maxdepth = = 16 & & _settings_newgame . pf . opf . pf_maxlength = = 512 ) {
_settings_newgame . pf . opf . pf_maxdepth = 48 ;
_settings_newgame . pf . opf . pf_maxlength = 4096 ;
2005-07-12 20:28:19 +00:00
}
2005-04-13 23:03:31 +00:00
}
2006-03-01 21:15:25 +00:00
2007-01-10 18:56:51 +00:00
extern const ChunkHandler _setting_chunk_handlers [ ] = {
2008-05-26 00:31:36 +00:00
{ ' OPTS ' , NULL , Load_OPTS , CH_RIFF } ,
2006-03-02 02:22:15 +00:00
{ ' PATS ' , Save_PATS , Load_PATS , CH_RIFF | CH_LAST } ,
2006-03-01 21:15:25 +00:00
} ;
2006-05-27 16:12:16 +00:00
static bool IsSignedVarMemType ( VarType vt )
{
switch ( GetVarMemType ( vt ) ) {
case SLE_VAR_I8 :
case SLE_VAR_I16 :
case SLE_VAR_I32 :
case SLE_VAR_I64 :
return true ;
}
return false ;
}