Re: [AD] set_config_file before allegro_init |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sun, 2005-03-06 at 15:04 +0000, Grzegorz Adam Hankiewicz wrote:
> When people want to customise their game they may prefer to have
> gamename.cfg rather than allegro.cfg and gamename.cfg. Plus the
> latter is both confusing to users and game code. Oh, and the log
> message says it fixes a crash too. I would say the only "bug"
> here is Allegro writting an empty configuration file on exit. I
> guess it should not be created if no config variables change.
>
Just went through my "sent messages" folder, and found my reply to this.
But it seems, that reply never actually got through SF to the list
(*sigh*).
Anyway, attached now is the patch. If I understand it right,
set_config_file before allegro_init currently is broken. The patch
simply reloads the current config file inside allegro_init.
So:
set_config_file("mygame.cfg");
allegro_init();
Would currently ignore the contents of mygame.cfg, while now, it does
just the same as:
allegro_init();
set_config_file("mygame.cfg");
Only that the mygame.cfg contents are already available during
allegro_init.
--
Elias Pschernig
Index: src/allegro.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/allegro.c,v
retrieving revision 1.49
diff -r1.49 allegro.c
355a356,358
> /* needed in case set_config_file was called before allegro_init */
> _reload_config();
>
Index: src/config.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/config.c,v
retrieving revision 1.28
diff -r1.28 config.c
1182a1183,1197
> /* _reload_config:
> * Internal helper to reload the configuration from allegro_init, in case
> * set_config_file was called before allegro_init.
> */
> void _reload_config(void)
> {
> if (config[0]) {
> char *name = strdup(config[0]->filename);
> set_config_file(name);
> free(name);
> }
> }
>
>
>
Index: include/allegro/internal/aintern.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/internal/aintern.h,v
retrieving revision 1.32
diff -r1.32 aintern.h
114a115,118
> /* config stuff */
> void _reload_config(void);
>
>