2005-07-24 14:12:37 +00:00
/* $Id$ */
2006-04-22 00:10:38 +00:00
/** @file
* 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-22 07:02:20 +00:00
# include "functions.h"
2005-07-25 07:28:32 +00:00
# include "macros.h"
2005-07-19 06:47:07 +00:00
# include "screenshot.h"
2004-08-09 17:04:08 +00:00
# include "sound.h"
2005-02-06 13:41:02 +00:00
# include "string.h"
2005-07-21 18:44:27 +00:00
# include "variables.h"
2004-12-04 17:54:56 +00:00
# include "network.h"
# include "settings.h"
2006-03-02 01:56:25 +00:00
# include "command.h"
# include "console.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"
2004-08-09 17:04:08 +00:00
2006-03-02 02:22:15 +00:00
/** The patch values that are used for new games and/or modified in config file */
Patches _patches_newgame ;
2004-08-09 17:04:08 +00:00
typedef struct IniFile IniFile ;
typedef struct IniItem IniItem ;
typedef struct IniGroup IniGroup ;
2005-02-01 17:48:20 +00:00
typedef struct SettingsMemoryPool SettingsMemoryPool ;
2004-08-09 17:04:08 +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 ) ;
2005-02-01 17:48:20 +00:00
static void pool_init ( SettingsMemoryPool * * pool ) ;
static void * pool_alloc ( SettingsMemoryPool * * pool , uint size ) ;
static void * pool_strdup ( SettingsMemoryPool * * pool , const char * mem , uint size ) ;
static void pool_free ( SettingsMemoryPool * * pool ) ;
2006-05-27 16:12:16 +00:00
static bool IsSignedVarMemType ( VarType vt ) ;
2004-08-09 17:04:08 +00:00
2005-02-01 17:48:20 +00:00
struct SettingsMemoryPool {
2004-08-09 17:04:08 +00:00
uint pos , size ;
2005-02-01 17:48:20 +00:00
SettingsMemoryPool * next ;
2004-08-09 17:04:08 +00:00
byte mem [ 1 ] ;
} ;
2005-02-01 17:48:20 +00:00
static SettingsMemoryPool * pool_new ( uint minsize )
2004-08-09 17:04:08 +00:00
{
2005-02-01 17:48:20 +00:00
SettingsMemoryPool * p ;
2004-08-09 17:04:08 +00:00
if ( minsize < 4096 - 12 ) minsize = 4096 - 12 ;
2004-09-10 19:02:27 +00:00
2005-02-01 17:48:20 +00:00
p = malloc ( sizeof ( SettingsMemoryPool ) - 1 + minsize ) ;
2004-08-09 17:04:08 +00:00
p - > pos = 0 ;
p - > size = minsize ;
p - > next = NULL ;
return p ;
}
2005-02-01 17:48:20 +00:00
static void pool_init ( SettingsMemoryPool * * pool )
2004-08-09 17:04:08 +00:00
{
* pool = pool_new ( 0 ) ;
}
2005-02-01 17:48:20 +00:00
static void * pool_alloc ( SettingsMemoryPool * * pool , uint size )
2004-08-09 17:04:08 +00:00
{
uint pos ;
2005-02-01 17:48:20 +00:00
SettingsMemoryPool * p = * pool ;
2004-08-09 17:04:08 +00:00
2005-09-23 14:21:39 +00:00
size = ALIGN ( size , sizeof ( void * ) ) ;
2004-08-09 17:04:08 +00:00
// first check if there's memory in the next pool
if ( p - > next & & p - > next - > pos + size < = p - > next - > size ) {
p = p - > next ;
// then check if there's not memory in the cur pool
} else if ( p - > pos + size > p - > size ) {
2005-02-01 17:48:20 +00:00
SettingsMemoryPool * n = pool_new ( size ) ;
2004-08-09 17:04:08 +00:00
* pool = n ;
n - > next = p ;
2004-09-10 19:02:27 +00:00
p = n ;
2004-08-09 17:04:08 +00:00
}
pos = p - > pos ;
p - > pos + = size ;
return p - > mem + pos ;
}
2005-02-01 17:48:20 +00:00
static void * pool_strdup ( SettingsMemoryPool * * pool , const char * mem , uint size )
2004-08-09 17:04:08 +00:00
{
byte * p = pool_alloc ( pool , size + 1 ) ;
p [ size ] = 0 ;
memcpy ( p , mem , size ) ;
return p ;
}
2005-02-01 17:48:20 +00:00
static void pool_free ( SettingsMemoryPool * * pool )
2004-08-09 17:04:08 +00:00
{
2005-02-01 17:48:20 +00:00
SettingsMemoryPool * p = * pool , * n ;
2004-08-09 17:04:08 +00:00
* pool = NULL ;
while ( p ) {
n = p - > next ;
free ( p ) ;
p = n ;
}
}
// structs describing the ini format.
struct IniItem {
char * name ;
char * value ;
char * comment ;
IniItem * next ;
} ;
struct IniGroup {
char * name ; // name of group
char * comment ; //comment for group
IniItem * item , * * last_item ;
IniGroup * next ;
IniFile * ini ;
2004-12-18 16:00:10 +00:00
IniGroupType type ; // type of group
2004-08-09 17:04:08 +00:00
} ;
struct IniFile {
2005-02-01 17:48:20 +00:00
SettingsMemoryPool * pool ;
2004-08-09 17:04:08 +00:00
IniGroup * group , * * last_group ;
char * comment ; // last comment in file
} ;
// allocate an inifile object
2005-01-22 20:23:18 +00:00
static IniFile * ini_alloc ( void )
2004-08-09 17:04:08 +00:00
{
IniFile * ini ;
2005-02-01 17:48:20 +00:00
SettingsMemoryPool * pool ;
2004-08-09 17:04:08 +00:00
pool_init ( & pool ) ;
ini = ( IniFile * ) pool_alloc ( & pool , sizeof ( IniFile ) ) ;
ini - > pool = pool ;
ini - > group = NULL ;
ini - > last_group = & ini - > group ;
ini - > comment = NULL ;
return ini ;
}
// allocate an ini group object
static IniGroup * ini_group_alloc ( IniFile * ini , const char * grpt , int len )
{
IniGroup * grp = pool_alloc ( & ini - > pool , sizeof ( IniGroup ) ) ;
grp - > ini = ini ;
grp - > name = pool_strdup ( & ini - > pool , grpt , len ) ;
2006-02-01 09:08:25 +00:00
if ( ! strcmp ( grp - > name , " newgrf " ) | | ! strcmp ( grp - > name , " servers " ) | | ! strcmp ( grp - > name , " bans " ) ) {
2004-12-18 16:00:10 +00:00
grp - > type = IGT_LIST ;
2006-02-01 09:08:25 +00:00
} else {
2004-12-18 16:00:10 +00:00
grp - > type = IGT_VARIABLES ;
2006-02-01 09:08:25 +00:00
}
2004-08-09 17:04:08 +00:00
grp - > next = NULL ;
grp - > item = NULL ;
grp - > comment = NULL ;
grp - > last_item = & grp - > item ;
* ini - > last_group = grp ;
ini - > last_group = & grp - > next ;
return grp ;
}
static IniItem * ini_item_alloc ( IniGroup * group , const char * name , int len )
{
IniItem * item = pool_alloc ( & group - > ini - > pool , sizeof ( IniItem ) ) ;
item - > name = pool_strdup ( & group - > ini - > pool , name , len ) ;
item - > next = NULL ;
item - > comment = NULL ;
item - > value = NULL ;
* group - > last_item = item ;
group - > last_item = & item - > next ;
return item ;
}
// load an ini file into the "abstract" format
static IniFile * ini_load ( const char * filename )
{
char buffer [ 1024 ] , c , * s , * t , * e ;
FILE * in ;
IniFile * ini ;
IniGroup * group = NULL ;
IniItem * item ;
2005-02-06 22:25:27 +00:00
char * comment = NULL ;
2004-08-09 17:04:08 +00:00
uint comment_size = 0 ;
uint comment_alloc = 0 ;
ini = ini_alloc ( ) ;
in = fopen ( filename , " r " ) ;
if ( in = = NULL ) return ini ;
// for each line in the file
while ( fgets ( buffer , sizeof ( buffer ) , in ) ) {
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
// trim whitespace from the left side
2006-04-20 22:08:20 +00:00
for ( s = buffer ; * s = = ' ' | | * s = = ' \t ' ; s + + ) ;
2004-08-09 17:04:08 +00:00
// trim whitespace from right side.
e = s + strlen ( s ) ;
while ( e > s & & ( ( c = e [ - 1 ] ) = = ' \n ' | | c = = ' \r ' | | c = = ' ' | | c = = ' \t ' ) ) e - - ;
2006-04-20 22:08:20 +00:00
* e = ' \0 ' ;
2004-08-09 17:04:08 +00:00
// skip comments and empty lines
2006-04-20 22:08:20 +00:00
if ( * s = = ' # ' | | * s = = ' \0 ' ) {
2004-08-09 17:04:08 +00:00
uint ns = comment_size + ( e - s + 1 ) ;
uint a = comment_alloc ;
uint pos ;
// add to comment
if ( ns > a ) {
a = max ( a , 128 ) ;
do a * = 2 ; while ( a < ns ) ;
comment = realloc ( comment , comment_alloc = a ) ;
}
pos = comment_size ;
comment_size + = ( e - s + 1 ) ;
comment [ pos + e - s ] = ' \n ' ; // comment newline
memcpy ( comment + pos , s , e - s ) ; // copy comment contents
continue ;
}
// it's a group?
if ( s [ 0 ] = = ' [ ' ) {
if ( e [ - 1 ] ! = ' ] ' )
ShowInfoF ( " ini: invalid group name '%s' \n " , buffer ) ;
else
e - - ;
s + + ; // skip [
group = ini_group_alloc ( ini , s , e - s ) ;
if ( comment_size ) {
group - > comment = pool_strdup ( & ini - > pool , comment , comment_size ) ;
comment_size = 0 ;
}
} else if ( group ) {
// find end of keyname
2006-04-20 22:08:20 +00:00
for ( t = s ; * t ! = ' \0 ' & & * t ! = ' = ' & & * t ! = ' \t ' & & * t ! = ' ' ; t + + ) ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
// it's an item in an existing group
item = ini_item_alloc ( group , s , t - s ) ;
if ( comment_size ) {
item - > comment = pool_strdup ( & ini - > pool , comment , comment_size ) ;
comment_size = 0 ;
}
// find start of parameter
while ( * t = = ' = ' | | * t = = ' ' | | * t = = ' \t ' ) t + + ;
2004-12-22 13:19:26 +00:00
// remove starting quotation marks
2006-02-01 07:36:15 +00:00
if ( * t = = ' \" ' ) t + + ;
2004-12-22 13:19:26 +00:00
// remove ending quotation marks
e = t + strlen ( t ) ;
2006-04-20 22:08:20 +00:00
if ( e > t & & e [ - 1 ] = = ' \" ' ) e - - ;
* e = ' \0 ' ;
2004-12-22 13:19:26 +00:00
2004-08-09 17:04:08 +00:00
item - > value = pool_strdup ( & ini - > pool , t , e - t ) ;
} else {
// it's an orphan item
ShowInfoF ( " ini: '%s' outside of group \n " , buffer ) ;
}
}
2006-04-22 00:10:38 +00:00
if ( comment_size > 0 ) {
2004-08-09 17:04:08 +00:00
ini - > comment = pool_strdup ( & ini - > pool , comment , comment_size ) ;
comment_size = 0 ;
}
free ( comment ) ;
fclose ( in ) ;
return ini ;
}
// lookup a group or make a new one
static IniGroup * ini_getgroup ( IniFile * ini , const char * name , int len )
{
IniGroup * group ;
if ( len = = - 1 ) len = strlen ( name ) ;
// does it exist already?
2006-02-01 07:36:15 +00:00
for ( group = ini - > group ; group ; group = group - > next )
2004-08-09 17:04:08 +00:00
if ( ! memcmp ( group - > name , name , len ) & & group - > name [ len ] = = 0 )
return group ;
// otherwise make a new one
group = ini_group_alloc ( ini , name , len ) ;
group - > comment = pool_strdup ( & ini - > pool , " \n " , 1 ) ;
return group ;
}
// lookup an item or make a new one
static IniItem * ini_getitem ( IniGroup * group , const char * name , bool create )
{
IniItem * item ;
uint len = strlen ( name ) ;
2006-02-01 07:36:15 +00:00
for ( item = group - > item ; item ; item = item - > next )
2006-02-04 22:48:57 +00:00
if ( strcmp ( item - > name , name ) = = 0 ) return item ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
if ( ! create ) return NULL ;
// otherwise make a new one
2006-02-04 22:48:57 +00:00
return ini_item_alloc ( group , name , len ) ;
2004-08-09 17:04:08 +00:00
}
// save ini file from the "abstract" format.
static bool ini_save ( const char * filename , IniFile * ini )
{
FILE * f ;
IniGroup * group ;
IniItem * item ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
f = fopen ( filename , " w " ) ;
if ( f = = NULL ) return false ;
2006-01-29 19:50:01 +00:00
for ( group = ini - > group ; group ! = NULL ; group = group - > next ) {
2004-08-09 17:04:08 +00:00
if ( group - > comment ) fputs ( group - > comment , f ) ;
fprintf ( f , " [%s] \n " , group - > name ) ;
2006-01-29 19:50:01 +00:00
for ( item = group - > item ; item ! = NULL ; item = item - > next ) {
2006-04-20 22:09:49 +00:00
assert ( item - > value ! = NULL ) ;
if ( item - > comment ! = NULL ) fputs ( item - > comment , f ) ;
//*Don't give an equal sign to list items that don't have a parameter */
if ( group - > type = = IGT_LIST & & * item - > value = = ' \0 ' ) {
fprintf ( f , " %s \n " , item - > name ) ;
} else
fprintf ( f , " %s = %s \n " , item - > name , item - > value ) ;
2004-08-09 17:04:08 +00:00
}
}
if ( ini - > comment ) fputs ( ini - > comment , f ) ;
fclose ( f ) ;
return true ;
}
static void ini_free ( IniFile * ini )
{
pool_free ( & ini - > pool ) ;
}
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 */
2004-08-09 17:04:08 +00:00
static int lookup_oneofmany ( const char * many , const char * one , int onelen )
{
const char * s ;
int idx ;
if ( onelen = = - 1 ) onelen = strlen ( one ) ;
// check if it's an integer
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 ( ; ; ) {
2004-08-09 17:04:08 +00:00
// find end of item
s = many ;
while ( * s ! = ' | ' & & * s ! = 0 ) s + + ;
if ( s - many = = onelen & & ! memcmp ( one , many , onelen ) ) return idx ;
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
* of seperated by a whitespace \ tab or | character
* @ 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 ( ; ; ) {
2004-08-09 17:04:08 +00:00
// skip "whitespace"
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 ;
2006-02-04 22:48:57 +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
* @ 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 . ) */
(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 make_intlist ( char * buf , 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 ( ) ;
}
2006-02-04 22:48:57 +00:00
buf + = sprintf ( buf , ( 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
* @ param many the full - domain string of possible values
* @ param id the value of the variable and whose string - representation must be found */
2006-02-04 22:52:30 +00:00
static void make_oneofmany ( char * buf , 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 ;
// Look for the id'th element
while ( - - id > = 0 ) {
for ( ; * many ! = ' | ' ; many + + ) {
if ( * many = = ' \0 ' ) { // not found
sprintf ( buf , " %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
}
2006-02-04 22:52:30 +00:00
// copy string until next item (|) or the end of the list if this is the last one
while ( * many ! = ' \0 ' & & * many ! = ' | ' ) * buf + + = * many + + ;
* 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
* @ 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 */
2004-08-09 17:04:08 +00:00
static void make_manyofmany ( char * buf , const char * many , uint32 x )
{
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
if ( HASBIT ( x , 0 ) ) { // item found, copy it
2004-08-09 17:04:08 +00:00
if ( ! init ) * buf + + = ' | ' ;
init = false ;
if ( start = = many ) {
buf + = sprintf ( buf , " %d " , i ) ;
} 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 : {
2006-02-04 22:48:57 +00:00
long r = lookup_oneofmany ( desc - > many , str , - 1 ) ;
2004-08-09 17:04:08 +00:00
if ( r ! = - 1 ) return ( void * ) r ;
ShowInfoF ( " ini: invalid value '%s' for '%s' " , str , desc - > name ) ;
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 ;
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 ;
if ( sdb - > cmd ! = SDT_BOOLX & & sdb - > cmd ! = SDT_NUMX & &
sdb - > cmd ! = SDT_ONEOFMANY & & sdb - > cmd ! = SDT_MANYOFMANY ) return ;
/* 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 ;
val = clamp ( val , min , sdb - > max ) ;
} 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 ;
WriteValue ( ptr , SLE_VAR_U32 , ( int64 ) clampu ( val , min , sdb - > max ) ) ;
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
* @ param grpname the group of the IniFile to search in for the new values */
(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 ;
IniGroup * group_def = ini_getgroup ( ini , grpname , - 1 ) ;
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 ;
2006-02-04 22:48:57 +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 ) {
(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
group = ini_getgroup ( ini , 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
2004-08-09 17:04:08 +00:00
item = ini_getitem ( group , s , false ) ;
(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 ) ;
ptr = ini_get_variable ( sld , object ) ;
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 :
case SLE_VAR_STRQ :
if ( p ! = NULL ) ttd_strlcpy ( ( char * ) ptr , p , sld - > length ) ;
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 : {
(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 ( ! load_intlist ( p , ptr , sld - > length , GetVarMemType ( sld - > conv ) ) )
ShowInfoF ( " ini: error in array '%s' " , sdb - > name ) ;
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
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
2006-02-04 22:48:57 +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 ) {
(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
group = ini_getgroup ( ini , sdb - > name , s - sdb - > name ) ;
2004-08-09 17:04:08 +00:00
s + + ;
} else {
2006-02-04 22:48:57 +00:00
if ( group_def = = NULL ) group_def = ini_getgroup ( ini , grpname , - 1 ) ;
(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
2004-08-09 17:04:08 +00:00
item = ini_getitem ( group , s , true ) ;
(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
ptr = ini_get_variable ( sld , object ) ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
if ( item - > value ! = NULL ) {
2004-09-10 19:02:27 +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
* 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 :
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 ;
2006-05-27 16:12:16 +00:00
case SDT_NUMX : sprintf ( buf , IsSignedVarMemType ( sld - > conv ) ? " %d " : " %u " , i ) ; 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 SDT_ONEOFMANY : make_oneofmany ( buf , sdb - > many , i ) ; break ;
case SDT_MANYOFMANY : make_manyofmany ( 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 ;
case SLE_VAR_STRQ : sprintf ( buf , " \" %s \" " , ( char * ) ptr ) ; break ;
case SLE_VAR_CHAR : sprintf ( buf , " \" %c \" " , * ( 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 :
(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
make_intlist ( 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 */
2004-08-09 17:04:08 +00:00
item - > value = pool_strdup ( & ini - > pool , buf , strlen ( 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 .
* @ param IniFile handle to the ini file with the source data
* @ 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
{
IniGroup * group = ini_getgroup ( ini , grpname , - 1 ) ;
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 .
* @ param IniFile handle to the ini file where the destination data is saved
* @ 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
* source to be saved into the relevant ini section
* @ 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
{
IniGroup * group = ini_getgroup ( ini , grpname , - 1 ) ;
IniItem * item = NULL ;
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 ;
bool first = true ;
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
if ( first ) { // add first item to the head of the group
2006-04-22 13:17:13 +00:00
item = ini_item_alloc ( group , entry , strlen ( 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
item - > value = item - > name ;
group - > item = item ;
first = false ;
} else { // all other items are attached to the previous one
2006-04-22 13:17:13 +00:00
item - > next = ini_item_alloc ( group , entry , strlen ( 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
item = item - > next ;
item - > value = item - > name ;
}
}
}
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
* Base / Offset and runtime variable selection mechanism , known from the saveload * convention ( it also has global so it should not be hard ) .
* 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
* place ) and you DON ' T have to increase the savegame version . */
2006-03-02 00:07:41 +00:00
# define NSD_GENERAL(name, def, cmd, guiflags, min, max, many, str, proc)\
2006-05-27 16:12:16 +00:00
{ name , ( const void * ) ( def ) , cmd , guiflags , min , max , many , str , proc }
2006-03-02 00:07:41 +00:00
/* Macros for various objects to go in the configuration file.
* This section is for global variables */
# define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, full, str, proc, from, to)\
{ NSD_GENERAL ( name , def , sdt_cmd , guiflags , min , max , full , str , proc ) , SLEG_GENERAL ( sle_cmd , var , type | flags , length , from , to ) }
# define SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, str, proc, from, to)\
SDTG_GENERAL ( name , SDT_NUMX , SL_VAR , type , flags , guiflags , var , 0 , def , min , max , NULL , str , proc , from , to )
# define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, str, proc)\
SDTG_CONDVAR ( name , type , flags , guiflags , var , def , min , max , str , proc , 0 , SL_MAX_VERSION )
# define SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, from, to)\
SDTG_GENERAL ( name , SDT_BOOLX , SL_VAR , SLE_UINT8 , flags , guiflags , var , 0 , def , 0 , 1 , NULL , str , proc , from , to )
# 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)\
SDTG_GENERAL ( name , SDT_INTLIST , SL_ARR , type , flags , guiflags , var , length , def , 0 , 0 , NULL , str , proc , from , to )
# define SDTG_LIST(name, type, flags, guiflags, var, def, str, proc)\
SDTG_GENERAL ( name , SDT_INTLIST , SL_ARR , type , flags , guiflags , var , lengthof ( var ) , def , 0 , 0 , NULL , str , proc , 0 , SL_MAX_VERSION )
# define SDTG_CONDSTR(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
SDTG_GENERAL ( name , SDT_STRING , SL_STR , type , flags , guiflags , var , length , def , 0 , 0 , NULL , str , proc , from , to )
# define SDTG_STR(name, type, flags, guiflags, var, def, str, proc)\
SDTG_GENERAL ( name , SDT_STRING , SL_STR , type , flags , guiflags , var , lengthof ( var ) , def , 0 , 0 , NULL , str , proc , 0 , SL_MAX_VERSION )
# define SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to)\
SDTG_GENERAL ( name , SDT_ONEOFMANY , SL_VAR , type , flags , guiflags , var , 0 , def , 0 , max , full , str , proc , from , to )
# define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc)\
SDTG_CONDOMANY ( name , type , flags , guiflags , var , def , max full , str , proc , 0 , SL_MAX_VERSION )
# define SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to)\
SDTG_GENERAL ( name , SDT_MANYOFMANY , SL_VAR , type , flags , guiflags , var , 0 , def , 0 , 0 , full , str , proc , from , to )
# 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)\
2006-03-17 08:01:54 +00:00
{ { " " , NULL , 0 , 0 , 0 , 0 , NULL , STR_NULL , NULL } , SLEG_CONDNULL ( length , from , to ) }
2006-03-16 00:20:33 +00:00
2006-03-02 00:07:41 +00:00
# define SDTG_END() {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLEG_END()}
/* Macros for various objects to go in the configuration file.
* This section is for structures where their various members are saved */
# define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, full, str, proc, from, to)\
{ NSD_GENERAL ( name , def , sdt_cmd , guiflags , min , max , full , str , proc ) , SLE_GENERAL ( sle_cmd , base , var , type | flags , length , from , to ) }
# define SDT_CONDVAR(base, var, type, from, to, flags, guiflags, def, min, max, str, proc)\
SDT_GENERAL ( # var , SDT_NUMX , SL_VAR , type , flags , guiflags , base , var , 1 , def , min , max , NULL , str , proc , from , to )
# define SDT_VAR(base, var, type, flags, guiflags, def, min, max, str, proc)\
SDT_CONDVAR ( base , var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , min , max , str , proc )
# define SDT_CONDBOOL(base, var, from, to, flags, guiflags, def, str, proc)\
SDT_GENERAL ( # var , SDT_BOOLX , SL_VAR , SLE_BOOL , flags , guiflags , base , var , 1 , def , 0 , 1 , NULL , str , proc , from , to )
# 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)\
SDT_GENERAL ( # var , SDT_INTLIST , SL_ARR , type , flags , guiflags , base , var , lengthof ( ( ( base * ) 8 ) - > var ) , def , 0 , 0 , NULL , str , proc , from , to )
# 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 )
# define SDT_CONDLISTO(base, var, length, type, from, to, flags, guiflags, def, str, proc)\
SDT_GENERAL ( # var , SDT_INTLIST , SL_ARR , type , flags , guiflags , base , var , length , def , 0 , 0 , NULL , str , proc , from , to )
# define SDT_CONDSTR(base, var, type, from, to, flags, guiflags, def, str, proc)\
SDT_GENERAL ( # var , SDT_STRING , SL_STR , type , flags , guiflags , base , var , lengthof ( ( ( base * ) 8 ) - > var ) , def , 0 , 0 , NULL , str , proc , from , to )
# 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)\
SDT_GENERAL ( # var , SDT_STRING , SL_VAR , SLE_CHAR , flags , guiflags , base , var , 1 , def , 0 , 0 , NULL , str , proc , from , to )
# define SDT_CHR(base, var, flags, guiflags, def, str, proc)\
SDT_CONDCHR ( base , var , 0 , SL_MAX_VERSION , flags , guiflags , def , str , proc )
# define SDT_CONDOMANY(base, var, type, from, to, flags, guiflags, def, max, full, str, proc)\
SDT_GENERAL ( # var , SDT_ONEOFMANY , SL_VAR , type , flags , guiflags , base , var , 1 , def , 0 , max , full , str , proc , from , to )
# define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, proc)\
SDT_CONDOMANY ( base , var , type , 0 , SL_MAX_VERSION , flags , guiflags , def , max , full , str , proc )
# define SDT_CONDMMANY(base, var, type, from, to, flags, guiflags, def, full, str, proc)\
SDT_GENERAL ( # var , SDT_MANYOFMANY , SL_VAR , type , flags , guiflags , base , var , 1 , def , 0 , 0 , full , str , proc , from , to )
# 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)\
2006-03-17 08:01:54 +00:00
{ { " " , NULL , 0 , 0 , 0 , 0 , NULL , STR_NULL , NULL } , SLE_CONDNULL ( length , from , to ) }
2006-03-16 00:20:33 +00:00
2006-03-02 00:07:41 +00:00
# define SDT_END() {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLE_END()}
/* 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
2006-05-27 16:12:16 +00:00
# define NS SLF_SAVE_NO
2006-03-02 00:07:41 +00:00
# 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
# include "table/strings.h"
2006-03-03 11:27:18 +00:00
/* Begin - Callback Functions for the various settings */
# include "window.h"
# include "gui.h"
# include "town.h"
# include "gfx.h"
// virtual PositionMainToolbar function, calls the right one.
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 ) ;
_patches . ainew_active = true ;
}
return 0 ;
}
static int32 PopulationInLabelActive ( int32 p1 )
{
Town * t ;
FOR_ALL_TOWNS ( t ) {
if ( t - > xy ! = 0 ) UpdateTownVirtCoord ( t ) ;
}
return 0 ;
}
static int32 InvisibleTreesActive ( int32 p1 )
{
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 ;
}
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
static int32 CheckInterval ( int32 p1 )
{
bool warning ;
const Patches * ptc = ( _game_mode = = GM_MENU ) ? & _patches_newgame : & _patches ;
if ( p1 ) {
warning = ( ( IS_INT_INSIDE ( ptc - > servint_trains , 5 , 90 + 1 ) | | ptc - > servint_trains = = 0 ) & &
( IS_INT_INSIDE ( ptc - > servint_roadveh , 5 , 90 + 1 ) | | ptc - > servint_roadveh = = 0 ) & &
( IS_INT_INSIDE ( ptc - > servint_aircraft , 5 , 90 + 1 ) | | ptc - > servint_aircraft = = 0 ) & &
( IS_INT_INSIDE ( ptc - > servint_ships , 5 , 90 + 1 ) | | ptc - > servint_ships = = 0 ) ) ;
} else {
warning = ( ( IS_INT_INSIDE ( ptc - > servint_trains , 30 , 800 + 1 ) | | ptc - > servint_trains = = 0 ) & &
( IS_INT_INSIDE ( ptc - > servint_roadveh , 30 , 800 + 1 ) | | ptc - > servint_roadveh = = 0 ) & &
( IS_INT_INSIDE ( ptc - > servint_aircraft , 30 , 800 + 1 ) | | ptc - > servint_aircraft = = 0 ) & &
( IS_INT_INSIDE ( ptc - > servint_ships , 30 , 800 + 1 ) | | ptc - > servint_ships = = 0 ) ) ;
}
if ( ! warning )
ShowErrorMessage ( INVALID_STRING_ID , STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE , 0 , 0 ) ;
return InValidateDetailsWindow ( 0 ) ;
}
static int32 EngineRenewUpdate ( int32 p1 )
{
DoCommandP ( 0 , 0 , _patches . autorenew , NULL , CMD_REPLACE_VEHICLE ) ;
return 0 ;
}
static int32 EngineRenewMonthsUpdate ( int32 p1 )
{
DoCommandP ( 0 , 1 , _patches . autorenew_months , NULL , CMD_REPLACE_VEHICLE ) ;
return 0 ;
}
static int32 EngineRenewMoneyUpdate ( int32 p1 )
{
DoCommandP ( 0 , 2 , _patches . autorenew_money , NULL , CMD_REPLACE_VEHICLE ) ;
return 0 ;
}
/* 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 [ ] = {
SDT_VAR ( MusicFileSettings , playlist , SLE_UINT8 , S , 0 , 0 , 0 , 5 , STR_NULL , NULL ) ,
SDT_VAR ( MusicFileSettings , music_vol , SLE_UINT8 , S , 0 , 128 , 0 , 100 , STR_NULL , NULL ) ,
SDT_VAR ( MusicFileSettings , effect_vol , SLE_UINT8 , S , 0 , 128 , 0 , 100 , STR_NULL , NULL ) ,
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 ) ,
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
extern bool _force_full_redraw , _double_size ;
extern uint _display_hz , _fullscreen_bpp ;
2006-03-02 09:57:28 +00:00
static const SettingDescGlobVarList _win32_settings [ ] = {
2006-03-02 00:07:41 +00:00
SDTG_VAR ( " display_hz " , SLE_UINT , S , 0 , _display_hz , 0 , 0 , 120 , 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 , STR_NULL , NULL ) ,
SDTG_BOOL ( " double_size " , S , 0 , _double_size , false , STR_NULL , NULL ) ,
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 [ ] = {
SDTG_MMANY ( " display_opt " , SLE_UINT8 , S , 0 , _display_opt , ( DO_SHOW_TOWN_NAMES | DO_SHOW_STATION_NAMES | DO_SHOW_SIGNS | DO_FULL_ANIMATION | DO_FULL_DETAIL | DO_TRANS_BUILDINGS | DO_WAYPOINTS ) , " SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|TRANS_BUILDINGS|FULL_DETAIL|WAYPOINTS " , STR_NULL , NULL ) ,
SDTG_VAR ( " news_display_opt " , SLE_UINT , S , 0 , _news_display_opt , 0xAAAAAAAA , 0 , 0xAAAAAAAA , STR_NULL , NULL ) , // default to all full messages: 10101010101010101010 = 0xAAAAAAAA
SDTG_BOOL ( " news_ticker_sound " , S , 0 , _news_ticker_sound , true , STR_NULL , NULL ) ,
SDTG_BOOL ( " fullscreen " , S , 0 , _fullscreen , false , STR_NULL , NULL ) ,
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 ) ,
SDTG_STR ( " language " , SLE_STRB , S , 0 , _dynlang . curr_file , NULL , STR_NULL , NULL ) ,
SDTG_LIST ( " resolution " , SLE_UINT16 , S , 0 , _cur_resolution , " 640,480 " , STR_NULL , NULL ) ,
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 ) ,
SDTG_END ( )
2004-08-09 17:04:08 +00:00
} ;
2004-12-04 17:54:56 +00:00
# ifdef ENABLE_NETWORK
2006-03-02 00:07:41 +00:00
static const SettingDescGlobVarList _network_settings [ ] = {
SDTG_VAR ( " sync_freq " , SLE_UINT16 , C | S , 0 , _network_sync_freq , 100 , 0 , 100 , STR_NULL , NULL ) ,
SDTG_VAR ( " frame_freq " , SLE_UINT8 , C | S , 0 , _network_frame_freq , 0 , 0 , 100 , STR_NULL , NULL ) ,
SDTG_VAR ( " max_join_time " , SLE_UINT16 , S , 0 , _network_max_join_time , 500 , 0 , 32000 , STR_NULL , NULL ) ,
2006-03-21 21:07:50 +00:00
SDTG_BOOL ( " pause_on_join " , S , 0 , _network_pause_on_join , true , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_STR ( " server_bind_ip " , SLE_STRB , S , 0 , _network_server_bind_ip_host , " 0.0.0.0 " , STR_NULL , NULL ) ,
2006-03-06 19:23:26 +00:00
SDTG_VAR ( " server_port " , SLE_UINT16 , S , 0 , _network_server_port , NETWORK_DEFAULT_PORT , 0 , 65535 , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_BOOL ( " server_advertise " , S , 0 , _network_advertise , false , STR_NULL , NULL ) ,
2006-05-19 20:32:45 +00:00
SDTG_VAR ( " lan_internet " , SLE_UINT8 , S , 0 , _network_lan_internet , 0 , 0 , 1 , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_STR ( " player_name " , SLE_STRB , S , 0 , _network_player_name , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " server_password " , SLE_STRB , S , 0 , _network_server_password , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " rcon_password " , SLE_STRB , S , 0 , _network_rcon_password , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " server_name " , SLE_STRB , S , 0 , _network_server_name , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " connect_to_ip " , SLE_STRB , S , 0 , _network_default_ip , NULL , STR_NULL , NULL ) ,
SDTG_STR ( " network_id " , SLE_STRB , S , 0 , _network_unique_id , NULL , STR_NULL , NULL ) ,
SDTG_BOOL ( " autoclean_companies " , S , 0 , _network_autoclean_companies , false , STR_NULL , NULL ) ,
SDTG_VAR ( " autoclean_unprotected " , SLE_UINT8 , S , 0 , _network_autoclean_unprotected , 12 , 0 , 60 , STR_NULL , NULL ) ,
SDTG_VAR ( " autoclean_protected " , SLE_UINT8 , S , 0 , _network_autoclean_protected , 36 , 0 , 180 , STR_NULL , NULL ) ,
2006-03-13 23:20:24 +00:00
SDTG_VAR ( " restart_game_date " , SLE_UINT16 , S , D0 , _network_restart_game_date , 0 , MAX_YEAR_BEGIN_REAL , MAX_YEAR_END_REAL , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDTG_END ( )
2004-08-09 17:04:08 +00:00
} ;
2004-12-04 17:54:56 +00:00
# endif /* ENABLE_NETWORK */
2004-08-09 17:04:08 +00:00
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
* and why not byte for example ? */
SDT_GENERAL ( " diff_custom " , SDT_INTLIST , SL_ARR , ( SLE_FILE_I16 | SLE_VAR_I32 ) , 0 , 0 , GameOptions , diff , 17 , 0 , 0 , 0 , NULL , STR_NULL , NULL , 0 , 3 ) ,
SDT_GENERAL ( " diff_custom " , SDT_INTLIST , SL_ARR , ( SLE_FILE_I16 | SLE_VAR_I32 ) , 0 , 0 , GameOptions , diff , 18 , 0 , 0 , 0 , NULL , STR_NULL , NULL , 4 , SL_MAX_VERSION ) ,
SDT_VAR ( GameOptions , diff_level , SLE_UINT8 , 0 , 0 , 9 , 0 , 9 , STR_NULL , NULL ) ,
2006-04-20 21:13:08 +00:00
SDT_OMANY ( GameOptions , 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|SEK|custom " , STR_NULL , NULL ) ,
2006-03-26 21:50:57 +00:00
SDT_OMANY ( GameOptions , units , SLE_UINT8 , N , 0 , 1 , 2 , " imperial|metric|si " , STR_NULL , NULL ) ,
2006-05-01 09:25:23 +00:00
SDT_OMANY ( GameOptions , town_name , SLE_UINT8 , 0 , 0 , 0 , 18 , " english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish " , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDT_OMANY ( GameOptions , landscape , SLE_UINT8 , 0 , 0 , 0 , 3 , " normal|hilly|desert|candy " , STR_NULL , NULL ) ,
SDT_VAR ( GameOptions , snow_line , SLE_UINT8 , 0 , 0 , 1 , 0 , 56 , STR_NULL , NULL ) ,
2006-03-17 08:06:56 +00:00
SDT_CONDOMANY ( GameOptions , autosave , SLE_UINT8 , 0 , 22 , N , 0 , 0 , 0 , " " , STR_NULL , NULL ) ,
SDT_CONDOMANY ( GameOptions , autosave , SLE_UINT8 , 23 , SL_MAX_VERSION , S , 0 , 1 , 4 , " off|monthly|quarterly|half year|yearly " , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDT_OMANY ( GameOptions , road_side , SLE_UINT8 , 0 , 0 , 1 , 1 , " left|right " , STR_NULL , NULL ) ,
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
* assigns his value . If the setting was player - based , that would mean that
* 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 [ ] = {
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* User-interface section of the GUI-configure patches window */
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , vehicle_speed , S , 0 , true , STR_CONFIG_PATCHES_VEHICLESPEED , NULL ) ,
SDT_BOOL ( Patches , status_long_date , S , 0 , true , STR_CONFIG_PATCHES_LONGDATE , NULL ) ,
SDT_BOOL ( Patches , show_finances , S , 0 , true , STR_CONFIG_PATCHES_SHOWFINANCES , NULL ) ,
SDT_BOOL ( Patches , autoscroll , S , 0 , false , STR_CONFIG_PATCHES_AUTOSCROLL , NULL ) ,
SDT_BOOL ( Patches , reverse_scroll , S , 0 , false , STR_CONFIG_PATCHES_REVERSE_SCROLLING , NULL ) ,
SDT_VAR ( Patches , errmsg_duration , SLE_UINT8 , S , 0 , 5 , 0 , 20 , STR_CONFIG_PATCHES_ERRMSG_DURATION , NULL ) ,
2006-03-03 11:27:18 +00:00
SDT_VAR ( Patches , toolbar_pos , SLE_UINT8 , S , MS , 0 , 0 , 2 , STR_CONFIG_PATCHES_TOOLBAR_POS , v_PositionMainToolbar ) ,
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , window_snap_radius , SLE_UINT8 , S , D0 , 10 , 1 , 32 , STR_CONFIG_PATCHES_SNAP_RADIUS , NULL ) ,
2006-03-03 11:27:18 +00:00
SDT_BOOL ( Patches , invisible_trees , S , 0 , false , STR_CONFIG_PATCHES_INVISIBLE_TREES , InvisibleTreesActive ) ,
SDT_BOOL ( Patches , population_in_label , S , 0 , true , STR_CONFIG_PATCHES_POPULATION_IN_LABEL , PopulationInLabelActive ) ,
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , map_x , SLE_UINT8 , S , 0 , 8 , 6 , 11 , STR_CONFIG_PATCHES_MAP_X , NULL ) ,
SDT_VAR ( Patches , map_y , SLE_UINT8 , S , 0 , 8 , 6 , 11 , STR_CONFIG_PATCHES_MAP_Y , NULL ) ,
SDT_BOOL ( Patches , link_terraform_toolbar , S , 0 , false , STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR , NULL ) ,
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* Construction section of the GUI-configure patches window */
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , build_on_slopes , 0 , 0 , true , STR_CONFIG_PATCHES_BUILDONSLOPES , NULL ) ,
SDT_BOOL ( Patches , extra_dynamite , 0 , 0 , false , STR_CONFIG_PATCHES_EXTRADYNAMITE , NULL ) ,
SDT_BOOL ( Patches , longbridges , 0 , 0 , true , STR_CONFIG_PATCHES_LONGBRIDGES , NULL ) ,
SDT_BOOL ( Patches , signal_side , N , 0 , true , STR_CONFIG_PATCHES_SIGNALSIDE , NULL ) ,
SDT_BOOL ( Patches , always_small_airport , 0 , 0 , false , STR_CONFIG_PATCHES_SMALL_AIRPORTS , NULL ) ,
SDT_VAR ( Patches , drag_signals_density , SLE_UINT8 , S , 0 , 4 , 1 , 20 , STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY , NULL ) ,
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* Vehicle section of the GUI-configure patches window */
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , realistic_acceleration , 0 , 0 , false , STR_CONFIG_PATCHES_REALISTICACCEL , NULL ) ,
SDT_BOOL ( Patches , forbid_90_deg , 0 , 0 , false , STR_CONFIG_PATCHES_FORBID_90_DEG , NULL ) ,
SDT_BOOL ( Patches , mammoth_trains , 0 , 0 , true , STR_CONFIG_PATCHES_MAMMOTHTRAINS , NULL ) ,
SDT_BOOL ( Patches , gotodepot , 0 , 0 , true , STR_CONFIG_PATCHES_GOTODEPOT , NULL ) ,
SDT_BOOL ( Patches , roadveh_queue , 0 , 0 , true , STR_CONFIG_PATCHES_ROADVEH_QUEUE , NULL ) ,
SDT_BOOL ( Patches , new_pathfinding_all , 0 , 0 , false , STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL , NULL ) ,
2006-05-27 16:12:16 +00:00
SDT_CONDBOOL ( Patches , yapf . ship_use_yapf , 28 , SL_MAX_VERSION , 0 , 0 , false , STR_CONFIG_PATCHES_YAPF_SHIPS , NULL ) ,
SDT_CONDBOOL ( Patches , yapf . road_use_yapf , 28 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_YAPF_ROAD , NULL ) ,
SDT_CONDBOOL ( Patches , yapf . rail_use_yapf , 28 , SL_MAX_VERSION , 0 , 0 , true , STR_CONFIG_PATCHES_YAPF_RAIL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , train_income_warn , S , 0 , true , STR_CONFIG_PATCHES_WARN_INCOME_LESS , NULL ) ,
SDT_VAR ( Patches , order_review_system , SLE_UINT8 , S , MS , 2 , 0 , 2 , STR_CONFIG_PATCHES_ORDER_REVIEW , NULL ) ,
SDT_BOOL ( Patches , never_expire_vehicles , 0 , 0 , false , STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES , NULL ) ,
SDT_VAR ( Patches , lost_train_days , SLE_UINT16 , S , D0 , 180 , 180 , 720 , STR_CONFIG_PATCHES_LOST_TRAIN_DAYS , NULL ) ,
2006-03-03 11:27:18 +00:00
SDT_BOOL ( Patches , autorenew , S , 0 , false , STR_CONFIG_PATCHES_AUTORENEW_VEHICLE , EngineRenewUpdate ) ,
SDT_VAR ( Patches , autorenew_months , SLE_INT16 , S , 0 , 6 , - 12 , 12 , STR_CONFIG_PATCHES_AUTORENEW_MONTHS , EngineRenewMonthsUpdate ) ,
SDT_VAR ( Patches , autorenew_money , SLE_UINT , S , CR , 100000 , 0 , 2000000 , STR_CONFIG_PATCHES_AUTORENEW_MONEY , EngineRenewMoneyUpdate ) ,
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , max_trains , SLE_UINT16 , 0 , 0 , 500 , 0 , 5000 , STR_CONFIG_PATCHES_MAX_TRAINS , NULL ) ,
SDT_VAR ( Patches , max_roadveh , SLE_UINT16 , 0 , 0 , 500 , 0 , 5000 , STR_CONFIG_PATCHES_MAX_ROADVEH , NULL ) ,
SDT_VAR ( Patches , max_aircraft , SLE_UINT16 , 0 , 0 , 200 , 0 , 5000 , STR_CONFIG_PATCHES_MAX_AIRCRAFT , NULL ) ,
SDT_VAR ( Patches , max_ships , SLE_UINT16 , 0 , 0 , 300 , 0 , 5000 , STR_CONFIG_PATCHES_MAX_SHIPS , NULL ) ,
2006-03-03 11:27:18 +00:00
SDT_BOOL ( Patches , servint_ispercent , 0 , 0 , false , STR_CONFIG_PATCHES_SERVINT_ISPERCENT , CheckInterval ) ,
2006-03-17 20:56:51 +00:00
SDT_VAR ( Patches , servint_trains , SLE_UINT16 , 0 , D0 , 150 , 5 , 800 , STR_CONFIG_PATCHES_SERVINT_TRAINS , InValidateDetailsWindow ) ,
2006-03-03 11:27:18 +00:00
SDT_VAR ( Patches , servint_roadveh , SLE_UINT16 , 0 , D0 , 150 , 5 , 800 , STR_CONFIG_PATCHES_SERVINT_ROADVEH , InValidateDetailsWindow ) ,
2006-03-17 20:56:51 +00:00
SDT_VAR ( Patches , servint_ships , SLE_UINT16 , 0 , D0 , 360 , 5 , 800 , STR_CONFIG_PATCHES_SERVINT_SHIPS , InValidateDetailsWindow ) ,
SDT_VAR ( Patches , servint_aircraft , SLE_UINT16 , 0 , D0 , 100 , 5 , 800 , STR_CONFIG_PATCHES_SERVINT_AIRCRAFT , InValidateDetailsWindow ) ,
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , no_servicing_if_no_breakdowns , 0 , 0 , false , STR_CONFIG_PATCHES_NOSERVICE , NULL ) ,
SDT_BOOL ( Patches , wagon_speed_limits , 0 , 0 , true , STR_CONFIG_PATCHES_WAGONSPEEDLIMITS , NULL ) ,
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* Station section of the GUI-configure patches window */
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , join_stations , 0 , 0 , true , STR_CONFIG_PATCHES_JOINSTATIONS , NULL ) ,
SDT_BOOL ( Patches , full_load_any , 0 , 0 , true , STR_CONFIG_PATCHES_FULLLOADANY , NULL ) ,
SDT_BOOL ( Patches , improved_load , 0 , 0 , false , STR_CONFIG_PATCHES_IMPROVEDLOAD , NULL ) ,
SDT_BOOL ( Patches , selectgoods , 0 , 0 , true , STR_CONFIG_PATCHES_SELECTGOODS , NULL ) ,
SDT_BOOL ( Patches , new_nonstop , 0 , 0 , false , STR_CONFIG_PATCHES_NEW_NONSTOP , NULL ) ,
SDT_BOOL ( Patches , nonuniform_stations , 0 , 0 , true , STR_CONFIG_PATCHES_NONUNIFORM_STATIONS , NULL ) ,
2006-03-03 11:27:18 +00:00
SDT_VAR ( Patches , station_spread , SLE_UINT8 , 0 , 0 , 12 , 4 , 64 , STR_CONFIG_PATCHES_STATION_SPREAD , InvalidateStationBuildWindow ) ,
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , serviceathelipad , 0 , 0 , true , STR_CONFIG_PATCHES_SERVICEATHELIPAD , NULL ) ,
SDT_BOOL ( Patches , modified_catchment , 0 , 0 , true , STR_CONFIG_PATCHES_CATCHMENT , NULL ) ,
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* Economy section of the GUI-configure patches window */
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , inflation , 0 , 0 , true , STR_CONFIG_PATCHES_INFLATION , NULL ) ,
SDT_BOOL ( Patches , build_rawmaterial_ind , 0 , 0 , false , STR_CONFIG_PATCHES_BUILDXTRAIND , NULL ) ,
SDT_BOOL ( Patches , multiple_industry_per_town , 0 , 0 , false , STR_CONFIG_PATCHES_MULTIPINDTOWN , NULL ) ,
SDT_BOOL ( Patches , same_industry_close , 0 , 0 , false , STR_CONFIG_PATCHES_SAMEINDCLOSE , NULL ) ,
SDT_BOOL ( Patches , bribe , 0 , 0 , true , STR_CONFIG_PATCHES_BRIBE , NULL ) ,
SDT_VAR ( Patches , snow_line_height , SLE_UINT8 , 0 , 0 , 7 , 2 , 13 , STR_CONFIG_PATCHES_SNOWLINE_HEIGHT , NULL ) ,
SDT_VAR ( Patches , colored_news_date , SLE_UINT , 0 , NC , 2000 , 1900 , 2200 , STR_CONFIG_PATCHES_COLORED_NEWS_DATE , NULL ) ,
SDT_VAR ( Patches , starting_date , SLE_UINT , 0 , NC , 1950 , MAX_YEAR_BEGIN_REAL , MAX_YEAR_END_REAL , STR_CONFIG_PATCHES_STARTING_DATE , NULL ) ,
SDT_VAR ( Patches , ending_date , SLE_UINT , 0 , NC | NO , 2051 , MAX_YEAR_BEGIN_REAL , MAX_YEAR_END_REAL , STR_CONFIG_PATCHES_ENDING_DATE , NULL ) ,
SDT_BOOL ( Patches , smooth_economy , 0 , 0 , true , STR_CONFIG_PATCHES_SMOOTH_ECONOMY , NULL ) ,
SDT_BOOL ( Patches , allow_shares , 0 , 0 , true , STR_CONFIG_PATCHES_ALLOW_SHARES , NULL ) ,
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* AI section of the GUI-configure patches window */
2006-03-03 11:27:18 +00:00
SDT_BOOL ( Patches , ainew_active , 0 , 0 , false , STR_CONFIG_PATCHES_AINEW_ACTIVE , AiNew_PatchActive_Warning ) ,
SDT_BOOL ( Patches , ai_in_multiplayer , 0 , 0 , false , STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER , Ai_In_Multiplayer_Warning ) ,
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , ai_disable_veh_train , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_TRAINS , NULL ) ,
SDT_BOOL ( Patches , ai_disable_veh_roadveh , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH , NULL ) ,
SDT_BOOL ( Patches , ai_disable_veh_aircraft , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT , NULL ) ,
SDT_BOOL ( Patches , ai_disable_veh_ship , 0 , 0 , false , STR_CONFIG_PATCHES_AI_BUILDS_SHIPS , NULL ) ,
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* Patches without any GUI representation */
2006-03-02 00:07:41 +00:00
SDT_BOOL ( Patches , keep_all_autosave , S , 0 , false , STR_NULL , NULL ) ,
SDT_BOOL ( Patches , autosave_on_exit , S , 0 , false , STR_NULL , NULL ) ,
SDT_VAR ( Patches , max_num_autosaves , SLE_UINT8 , S , 0 , 16 , 0 , 255 , STR_NULL , NULL ) ,
SDT_BOOL ( Patches , bridge_pillars , S , 0 , true , STR_NULL , NULL ) ,
SDT_VAR ( Patches , extend_vehicle_life , SLE_UINT8 , 0 , 0 , 0 , 0 , 100 , STR_NULL , NULL ) ,
SDT_BOOL ( Patches , auto_euro , S , 0 , true , STR_NULL , NULL ) ,
SDT_VAR ( Patches , dist_local_authority , SLE_UINT8 , 0 , 0 , 20 , 5 , 60 , STR_NULL , NULL ) ,
SDT_VAR ( Patches , wait_oneway_signal , SLE_UINT8 , 0 , 0 , 15 , 2 , 100 , STR_NULL , NULL ) ,
SDT_VAR ( Patches , wait_twoway_signal , SLE_UINT8 , 0 , 0 , 41 , 2 , 100 , STR_NULL , NULL ) ,
/***************************************************************************/
2006-03-17 22:47:52 +00:00
/* New Pathfinding patch settings */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , pf_maxlength , SLE_UINT16 , 0 , 0 , 4096 , 64 , 65535 , STR_NULL , NULL ) ,
SDT_VAR ( Patches , pf_maxdepth , SLE_UINT8 , 0 , 0 , 48 , 4 , 255 , STR_NULL , NULL ) ,
2005-04-15 15:28:01 +00:00
/* The maximum number of nodes to search */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , npf_max_search_nodes , SLE_UINT , 0 , 0 , 10000 , 500 , 100000 , STR_NULL , NULL ) ,
2005-04-15 15:28:01 +00:00
2005-02-02 20:36:04 +00:00
/* When a red signal is encountered, a small detour can be made around
2006-06-10 08:37:41 +00:00
* it . This specifically occurs when a track is doubled , in which case
* the detour is typically 2 tiles . It is also often used at station
* entrances , when there is a choice of multiple platforms . If we take
* a typical 4 platform station , the detour is 4 tiles . To properly
* support larger stations we increase this value .
* We want to prevent that trains that want to leave at one side of a
* station , leave through the other side , turn around , enter the
* station on another platform and exit the station on the right side
* again , just because the sign at the right side was red . If we take
* a typical 5 length station , this detour is 10 or 11 tiles ( not
* sure ) , so we set the default penalty at 10 ( the station tile
* penalty will further prevent this .
* We give presignal exits ( and combo ' s ) a different ( larger ) penalty , because
* we really don ' t want trains waiting in front of a presignal exit . */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , npf_rail_firstred_penalty , SLE_UINT , 0 , 0 , ( 10 * NPF_TILE_LENGTH ) , 0 , 100000 , STR_NULL , NULL ) ,
SDT_VAR ( Patches , npf_rail_firstred_exit_penalty , SLE_UINT , 0 , 0 , ( 100 * NPF_TILE_LENGTH ) , 0 , 100000 , STR_NULL , NULL ) ,
2005-03-08 19:54:10 +00:00
/* This penalty is for when the last signal before the target is red.
* This is useful for train stations , where there are multiple
* platforms to choose from , which lie in different signal blocks .
* Every target in a occupied signal block ( ie an occupied platform )
2006-03-02 00:07:41 +00:00
* will get this penalty . */
SDT_VAR ( Patches , npf_rail_lastred_penalty , SLE_UINT , 0 , 0 , ( 10 * NPF_TILE_LENGTH ) , 0 , 100000 , STR_NULL , NULL ) ,
2005-02-02 20:36:04 +00:00
/* When a train plans a route over a station tile, this penalty is
2006-03-02 00:07:41 +00:00
* applied . We want that trains plan a route around a typical , 4 x5
* station , which means two tiles to the right , and two tiles back to
* the left around it , or 5 tiles of station through it . If we assign
* a penalty of 1 tile for every station tile passed , the route will
* be around it . */
SDT_VAR ( Patches , npf_rail_station_penalty , SLE_UINT , 0 , 0 , ( 1 * NPF_TILE_LENGTH ) , 0 , 100000 , STR_NULL , NULL ) ,
SDT_VAR ( Patches , npf_rail_slope_penalty , SLE_UINT , 0 , 0 , ( 1 * NPF_TILE_LENGTH ) , 0 , 100000 , STR_NULL , NULL ) ,
2005-05-02 22:13:20 +00:00
/* This penalty is applied when a train makes a turn. Its value of 1 makes
* sure that it has a minimal impact on the pathfinding , only when two
* paths have equal length it will make a difference */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , npf_rail_curve_penalty , SLE_UINT , 0 , 0 , 1 , 0 , 100000 , STR_NULL , NULL ) ,
2005-05-07 22:00:36 +00:00
/* Ths penalty is applied when a vehicle reverses inside a depot (doesn't
* apply to ships , as they can just come out the other end ) . XXX : Is this a
* good value ? */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , npf_rail_depot_reverse_penalty , SLE_UINT , 0 , 0 , ( NPF_TILE_LENGTH * 50 ) , 0 , 100000 , STR_NULL , NULL ) ,
SDT_VAR ( Patches , npf_buoy_penalty , SLE_UINT , 0 , 0 , ( 2 * NPF_TILE_LENGTH ) , 0 , 100000 , STR_NULL , NULL ) ,
2005-05-02 22:13:20 +00:00
/* This penalty is applied when a ship makes a turn. It is bigger than the
* rail curve penalty , since ships ( realisticly ) have more trouble with
* making turns */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , npf_water_curve_penalty , SLE_UINT , 0 , 0 , ( NPF_TILE_LENGTH / 4 ) , 0 , 100000 , STR_NULL , NULL ) ,
2005-06-16 17:53:40 +00:00
/* This is the penalty for road, same as for rail. */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , npf_road_curve_penalty , SLE_UINT , 0 , 0 , 1 , 0 , 100000 , STR_NULL , NULL ) ,
2005-07-03 13:02:54 +00:00
/* This is the penalty for level crossings, for both road and rail vehicles */
2006-03-02 00:07:41 +00:00
SDT_VAR ( Patches , npf_crossing_penalty , SLE_UINT , 0 , 0 , ( 3 * NPF_TILE_LENGTH ) , 0 , 100000 , STR_NULL , NULL ) ,
2005-05-02 22:13:20 +00:00
2006-05-27 16:12:16 +00:00
// The maximum number of nodes to search
SDT_CONDBOOL ( Patches , yapf . disable_node_optimization , 28 , SL_MAX_VERSION , 0 , 0 , false , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . max_search_nodes , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10000 , 500 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDBOOL ( Patches , yapf . rail_firstred_twoway_eol , 28 , SL_MAX_VERSION , 0 , 0 , true , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_firstred_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_firstred_exit_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 100 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_lastred_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_lastred_exit_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 100 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_station_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 30 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_slope_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 2 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_curve45_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 1 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_curve90_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 6 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
// This penalty is applied when a train reverses inside a depot
SDT_CONDVAR ( Patches , yapf . rail_depot_reverse_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 50 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
// This is the penalty for level crossings (for trains only)
SDT_CONDVAR ( Patches , yapf . rail_crossing_penalty , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 3 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
// look-ahead how many signals are checked
SDT_CONDVAR ( Patches , yapf . rail_look_ahead_max_signals , SLE_UINT , 28 , SL_MAX_VERSION , 0 , 0 , 10 , 0 , 100 , STR_NULL , NULL ) ,
// look-ahead n-th red signal penalty polynomial: penalty = p2 * n^2 + p1 * n + p0
SDT_CONDVAR ( Patches , yapf . rail_look_ahead_signal_p0 , SLE_INT , 28 , SL_MAX_VERSION , 0 , 0 , 500 , - 1000000 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_look_ahead_signal_p1 , SLE_INT , 28 , SL_MAX_VERSION , 0 , 0 , - 100 , - 1000000 , 1000000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_look_ahead_signal_p2 , SLE_INT , 28 , SL_MAX_VERSION , 0 , 0 , 5 , - 1000000 , 1000000 , STR_NULL , NULL ) ,
2006-06-01 21:39:35 +00:00
// penalties for too long or too short station platforms (TODO: NS flag or higher revision?)
2006-06-07 21:26:57 +00:00
SDT_CONDVAR ( Patches , yapf . rail_longer_platform_penalty , SLE_UINT , 28 , SL_MAX_VERSION , NS , 0 , 8 * YAPF_TILE_LENGTH , 0 , 20000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_longer_platform_per_tile_penalty , SLE_UINT , 28 , SL_MAX_VERSION , NS , 0 , 0 * YAPF_TILE_LENGTH , 0 , 20000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_shorter_platform_penalty , SLE_UINT , 28 , SL_MAX_VERSION , NS , 0 , 40 * YAPF_TILE_LENGTH , 0 , 20000 , STR_NULL , NULL ) ,
SDT_CONDVAR ( Patches , yapf . rail_shorter_platform_per_tile_penalty , SLE_UINT , 28 , SL_MAX_VERSION , NS , 0 , 0 * YAPF_TILE_LENGTH , 0 , 20000 , STR_NULL , NULL ) ,
2006-06-08 17:31:03 +00:00
// road vehicles - penalties
SDT_CONDVAR ( Patches , yapf . road_slope_penalty , SLE_UINT , 28 , SL_MAX_VERSION , NS , 0 , 2 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
2006-06-08 17:36:06 +00:00
SDT_CONDVAR ( Patches , yapf . road_crossing_penalty , SLE_UINT , 28 , SL_MAX_VERSION , NS , 0 , 3 * YAPF_TILE_LENGTH , 0 , 1000000 , STR_NULL , NULL ) ,
2006-05-27 16:12:16 +00:00
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 [ ] = {
SDT_VAR ( CurrencySpec , rate , SLE_UINT16 , S , 0 , 1 , 0 , 100 , STR_NULL , NULL ) ,
2006-03-13 23:10:02 +00:00
SDT_CHR ( CurrencySpec , separator , S , 0 , " . " , STR_NULL , NULL ) ,
2006-03-02 00:07:41 +00:00
SDT_VAR ( CurrencySpec , to_euro , SLE_UINT16 , S , 0 , 0 , 0 , 1000 , STR_NULL , NULL ) ,
SDT_STR ( CurrencySpec , prefix , SLE_STRQ , S , 0 , NULL , STR_NULL , NULL ) ,
SDT_STR ( CurrencySpec , suffix , SLE_STRQ , S , 0 , " credits " , STR_NULL , NULL ) ,
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
2006-04-22 13:17:13 +00:00
const char * GRFProcessParams ( const IniItem * item , uint index )
{
GRFConfig * c ;
/* Saving newgrf stuff to configuration, not done since it is kept the same */
if ( item = = NULL ) return NULL ;
/* Loading newgrf stuff from configuration file */
c = calloc ( 1 , sizeof ( * c ) ) ;
c - > filename = strdup ( item - > name ) ;
2006-04-22 13:59:21 +00:00
if ( * item - > value ! = ' \0 ' ) {
c - > num_params = parse_intlist ( item - > value , ( int * ) c - > param , lengthof ( c - > param ) ) ;
2006-04-22 14:06:46 +00:00
if ( c - > num_params = = ( byte ) - 1 ) {
ShowInfoF ( " ini: error in array '%s' " , item - > name ) ;
c - > num_params = 0 ;
}
2006-04-22 13:17:13 +00:00
}
if ( _first_grfconfig = = NULL ) {
_first_grfconfig = c ;
} else {
GRFConfig * c2 ;
/* Attach the label to the end of the list */
for ( c2 = _first_grfconfig ; c2 - > next ! = NULL ; c2 = c2 - > next ) ;
c2 - > next = c ;
}
return c - > filename ;
}
2004-08-09 17:04:08 +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
proc ( ini , _gameopt_settings , " gameopt " , & _opt_newgame ) ;
2006-03-02 02:22:15 +00:00
proc ( ini , _patch_settings , " patches " , & _patches_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-03-02 00:07:41 +00:00
proc ( ini , ( const SettingDesc * ) _network_settings , " network " , NULL ) ;
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
}
2006-03-02 00:07:41 +00:00
/** Load the values from the configuration files */
2005-01-22 20:23:18 +00:00
void LoadFromConfig ( void )
2004-08-09 17:04:08 +00:00
{
IniFile * ini = ini_load ( _config_file ) ;
2006-03-02 00:07:41 +00:00
HandleSettingDescs ( ini , ini_load_settings , ini_load_setting_list ) ;
2006-04-22 13:17:13 +00:00
ini_load_setting_list ( ini , " newgrf " , NULL , 0 , GRFProcessParams ) ;
2004-08-09 17:04:08 +00:00
ini_free ( ini ) ;
}
2006-03-02 00:07:41 +00:00
/** Save the values to the configuration file */
2005-01-22 20:23:18 +00:00
void SaveToConfig ( void )
2004-08-09 17:04:08 +00:00
{
IniFile * ini = ini_load ( _config_file ) ;
2006-03-02 00:07:41 +00:00
HandleSettingDescs ( ini , ini_save_settings , ini_save_setting_list ) ;
2004-08-09 17:04:08 +00:00
ini_save ( _config_file , ini ) ;
ini_free ( ini ) ;
}
2005-04-13 23:03:31 +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).
* @ 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
*/
2006-04-10 07:15:58 +00:00
int32 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
if ( flags & DC_EXEC ) {
2006-03-02 02:22:15 +00:00
Patches * patches_ptr = ( _game_mode = = GM_MENU ) ? & _patches_newgame : & _patches ;
2006-03-02 01:56:25 +00:00
void * var = ini_get_variable ( & sd - > save , patches_ptr ) ;
Write_ValidateSetting ( var , sd , ( int32 ) p2 ) ;
InvalidateWindow ( WC_GAME_OPTIONS , 0 ) ;
}
return 0 ;
}
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 */
void SetPatchValue ( uint index , const Patches * object , int32 value )
{
const SettingDesc * sd = & _patch_settings [ index ] ;
/* If an item is player-based, we do not send it over the network
* ( if any ) to change . Also * hack * hack * we update the _newgame version
* of patches because changing a player - based setting in a game also
* changes its defaults . At least that is the convention we have chosen */
if ( sd - > save . conv & SLF_NETWORK_NO ) {
void * var = ini_get_variable ( & sd - > save , object ) ;
Write_ValidateSetting ( var , sd , value ) ;
2006-03-02 02:22:15 +00:00
if ( _game_mode ! = GM_MENU ) {
void * var2 = ini_get_variable ( & sd - > save , & _patches_newgame ) ;
Write_ValidateSetting ( var2 , sd , value ) ;
}
2006-03-02 01:41:25 +00:00
} else {
DoCommandP ( 0 , index , value , NULL , CMD_CHANGE_PATCH_SETTING ) ;
}
}
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 ;
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
}
return NULL ;
}
/* Those 2 functions need to be here, else we have to make some stuff non-static
* and besides , it is also better to keep stuff like this at the same place */
void IConsoleSetPatchSetting ( const char * name , const char * value )
{
char newval [ 20 ] ;
2006-03-03 11:27:18 +00:00
int32 val ;
2006-03-02 01:56:25 +00:00
uint index ;
const SettingDesc * sd = GetPatchFromName ( name , & index ) ;
const Patches * patches_ptr ;
void * ptr ;
if ( sd = = NULL ) {
IConsolePrintF ( _icolour_warn , " '%s' is an unknown patch setting. " , name ) ;
return ;
}
sscanf ( value , " %d " , & val ) ;
2006-03-02 02:22:15 +00:00
patches_ptr = ( _game_mode = = GM_MENU ) ? & _patches_newgame : & _patches ;
2006-03-02 01:56:25 +00:00
ptr = ini_get_variable ( & sd - > save , patches_ptr ) ;
SetPatchValue ( index , patches_ptr , val ) ;
2006-03-03 11:27:18 +00:00
val = ReadValue ( ptr , sd - > save . conv ) ;
if ( sd - > desc . proc ! = NULL ) sd - > desc . proc ( val ) ;
2006-03-02 01:56:25 +00:00
if ( sd - > desc . cmd = = SDT_BOOLX ) {
2006-03-03 11:27:18 +00:00
snprintf ( newval , sizeof ( newval ) , ( val ! = 0 ) ? " on " : " off " ) ;
2006-03-02 01:56:25 +00:00
} else {
2006-03-03 11:27:18 +00:00
snprintf ( newval , sizeof ( newval ) , " %d " , val ) ;
2006-03-02 01:56:25 +00:00
}
IConsolePrintF ( _icolour_warn , " '%s' changed to: %s " , name , newval ) ;
}
void IConsoleGetPatchSetting ( const char * name )
{
char value [ 20 ] ;
uint index ;
const SettingDesc * sd = GetPatchFromName ( name , & index ) ;
const void * ptr ;
if ( sd = = NULL ) {
IConsolePrintF ( _icolour_warn , " '%s' is an unknown patch setting. " , name ) ;
return ;
}
2006-03-02 02:22:15 +00:00
ptr = ini_get_variable ( & sd - > save , ( _game_mode = = GM_MENU ) ? & _patches_newgame : & _patches ) ;
2006-03-02 01:56:25 +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 ) ) ;
}
IConsolePrintF ( _icolour_warn , " 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 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 ;
void * ptr = ini_get_variable ( sld , object ) ;
if ( ! SlObjectMember ( ptr , sld ) ) continue ;
}
}
/** Loadhandler for a list of global variables
* @ 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
* @ 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 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 + + ) {
length + = SlCalcObjMemberLength ( & i - > save ) ;
}
SlSetLength ( length ) ;
for ( i = sd ; i - > save . cmd ! = SL_END ; i + + ) {
void * ptr = ini_get_variable ( & i - > save , object ) ;
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 ) ;
}
static void Load_OPTS ( void )
{
/* 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 */
_opt = _opt_newgame ;
LoadSettings ( _gameopt_settings , & _opt ) ;
}
static void Save_OPTS ( void )
{
SaveSettings ( _gameopt_settings , & _opt ) ;
}
2006-03-02 02:22:15 +00:00
static void Load_PATS ( void )
{
/* 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 */
_patches = _patches_newgame ;
LoadSettings ( _patch_settings , & _patches ) ;
}
static void Save_PATS ( void )
{
SaveSettings ( _patch_settings , & _patches ) ;
}
2005-04-13 23:03:31 +00:00
void CheckConfig ( void )
{
// fix up news_display_opt from old to new
int i ;
uint32 tmp ;
2005-04-24 18:24:29 +00:00
for ( i = 0 , tmp = _news_display_opt ; i ! = 10 ; i + + , tmp > > = 2 ) {
2005-04-13 23:03:31 +00:00
if ( ( tmp & 0x3 ) = = 0x3 ) { // old settings
_news_display_opt = 0xAAAAAAAA ; // set all news-messages to full 1010101010...
break ;
}
}
2005-07-12 20:28:19 +00:00
// Increase old default values for pf_maxdepth and pf_maxlength
// to support big networks.
2006-03-02 02:22:15 +00:00
if ( _patches_newgame . pf_maxdepth = = 16 & & _patches_newgame . pf_maxlength = = 512 ) {
_patches_newgame . pf_maxdepth = 48 ;
_patches_newgame . 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
2006-03-02 02:22:15 +00:00
void UpdatePatches ( void )
{
/* Since old(er) savegames don't have any patches saved, we initialise
* them with the default values just as it was in the old days .
* Also new games need this copying - over */
_patches = _patches_newgame ; /* backwards compatibility */
}
2006-03-01 21:15:25 +00:00
const ChunkHandler _setting_chunk_handlers [ ] = {
2006-03-02 02:22:15 +00:00
{ ' OPTS ' , Save_OPTS , Load_OPTS , CH_RIFF } ,
{ ' 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 ;
}