Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 40174 Details for
Bug 64431
ebuilds for new game tomatoes (I Have No Tomatoes)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
adds ~/.tomatoesrc support
homedir.patch (text/plain), 5.62 KB, created by
Greg Watson (linuxkrn)
on 2004-09-22 10:21:26 UTC
(
hide
)
Description:
adds ~/.tomatoesrc support
Filename:
MIME Type:
Creator:
Greg Watson (linuxkrn)
Created:
2004-09-22 10:21:26 UTC
Size:
5.62 KB
patch
obsolete
>--- include/config.h 2004-07-24 09:41:38.000000000 -0600 >+++ ../tomatoes-1.0.1/include/config.h 2004-09-22 09:42:42.336501969 -0600 >@@ -55,10 +55,10 @@ > }; > > // Load config from file >-void load_config(char *file, CONFIG *conf); >+bool load_config(char *file, CONFIG *conf); > > // Save config to file >-void save_config(char *file, CONFIG *conf); >+bool save_config(char *file, CONFIG *conf); > > #endif > >--- src/main.cpp 2004-07-24 09:41:41.000000000 -0600 >+++ ../tomatoes-1.0.1/src/main.cpp 2004-09-22 10:35:17.632927145 -0600 >@@ -22,9 +22,12 @@ > 3. This notice may not be removed or altered from any source > distribution. > >- > Mika Halttunen <lsoft@mbnet.fi> > >+ 09/22/2004 - Added support for ~/.tomatoesrc >+ Greg Watson <gwatson@linuxlogin.com> >+ >+ > *************************************************************************/ > > #include <stdlib.h> >@@ -105,6 +108,11 @@ > > // The good old main() > int main(int argc, char *argv[]) { >+ // filename for ~/.tomatoesrc >+ char filename[255]; >+ strncpy(filename, getenv("HOME"), 200); >+ strcat(filename, "/.tomatoesrc"); >+ > // Initialize SDL and OpenGL > init_sdl_and_gl(); > >@@ -173,7 +181,9 @@ > FSOUND_Close(); > > // Save the config >- save_config("./config.cfg", &config); >+ // Try ~/.tomatoesrc first >+ if (!save_config(filename, &config)) >+ save_config("./config.cfg", &config); > return 0; > } > >--- src/menu.cpp 2004-07-24 09:41:41.000000000 -0600 >+++ ../tomatoes-1.0.1/src/menu.cpp 2004-09-22 10:35:22.448855743 -0600 >@@ -490,6 +490,14 @@ > setting_key = false; > key_to_set = NULL; > prev_key = 0; >+ >+ // buffer for filename for config file >+ char filename[255]; >+ >+ >+ // make the filename = ~/.tomatoesrc >+ strncpy(filename, getenv("HOME"), 200); >+ strcat(filename, "/.tomatoesrc"); > > // Load the hiscores > load_hiscore_list(HISCORE_FILE); >@@ -611,7 +619,8 @@ > mid_state_wait = 3 * 60; > > // Restore the settings >- load_config("./config.cfg", &config); >+ if (!load_config(filename, &config)) >+ load_config("./config.cfg", &config); > FSOUND_SetSFXMasterVolume(config.sound_vol); > FMUSIC_SetMasterVolume(music_mod, config.music_vol); > } >@@ -697,7 +706,9 @@ > mid_state = 1; > mid_state_wait = 3 * 60; > >- save_config("./config.cfg", &config); >+ // Try to write to ~/.tomatoesrc file first >+ if (!save_config(filename, &config)) >+ save_config("./config.cfg", &config); > break; > > case MENU_CANCEL: // Cancel the changes >@@ -710,7 +721,8 @@ > mid_state_wait = 3 * 60; > > // Restore the settings >- load_config("./config.cfg", &config); >+ if (!load_config(filename, &config)) >+ load_config("./config.cfg", &config); > FSOUND_SetSFXMasterVolume(config.sound_vol); > FMUSIC_SetMasterVolume(music_mod, config.music_vol); > } >--- src/init.cpp 2004-07-24 09:41:41.000000000 -0600 >+++ ../tomatoes-1.0.1/src/init.cpp 2004-09-22 10:35:06.242095986 -0600 >@@ -24,12 +24,16 @@ > > > Mika Halttunen <lsoft@mbnet.fi> >+ >+ 09/22/2004 - Added support for ~/.tomatoesrc instead of just ./config.cfg >+ Greg Watson <gwatson@linuxlogin.com> > > *************************************************************************/ > > #include <stdio.h> > #include <stdlib.h> > #include <stdarg.h> >+#include <string.h> > > #include "SDL.h" > #ifdef WIN32 >@@ -85,9 +89,14 @@ > > // Initialize SDL and OpenGL > void init_sdl_and_gl() { >+ char filename[255]; > > // Load the config >- load_config("./config.cfg", &config); >+ // Check the users ~/.tomatoesrc first >+ strncpy(filename, getenv("HOME"), 200); >+ strcat(filename, "/.tomatoesrc"); >+ if (!load_config(filename, &config)) >+ load_config("./config.cfg", &config); > > // Check for 8-bit > if(config.vid_color_depth == 8) >--- src/config.cpp 2004-07-24 09:41:41.000000000 -0600 >+++ ../tomatoes-1.0.1/src/config.cpp 2004-09-22 10:36:17.319022826 -0600 >@@ -25,19 +25,30 @@ > > Mika Halttunen <lsoft@mbnet.fi> > >+ 09/22/2004 - Changed functions to return bool on success/failure of >+ load/save config. Greg Watson <gwatson@linuxlogin.com> >+ > *************************************************************************/ > > #include <stdio.h> >+#include <string.h> > #include "config.h" > #include "init.h" > > > // Load config from file >-void load_config(char *file, CONFIG *conf) { >+bool load_config(char *file, CONFIG *conf) { > > FILE *f = fopen(file, "rt"); >- if(!f) >- error_msg("Unable to load config file: %s!", file); >+ if (!f) { >+ // If we are not tying to load ~/.tomatoesrc, then >+ // abort program, since no config was found at all >+ if (!strstr(file, "tomatoesrc")) >+ error_msg("Unable to load config file: %s!", file); >+ >+ // return false since we couldn't load >+ return false; >+ } > > fscanf(f, "video_mode = %d x %d\n", &(conf->vid_w), &(conf->vid_h)); > fscanf(f, "video_mode_color_depth = %d\n", &(conf->vid_color_depth)); >@@ -56,15 +67,18 @@ > fscanf(f, "perspective = %d\n", &(conf->perspective_mode)); > fscanf(f, "moving_style = %d\n", &(conf->moving_style)); > fclose(f); >+ return true; > } > > > // Save config to file >-void save_config(char *file, CONFIG *conf) { >+bool save_config(char *file, CONFIG *conf) { > > FILE *f = fopen(file, "wt"); >- if(!f) >+ if(!f) { > error_msg("Unable to save config file: %s!", file); >+ return false; >+ } > > fprintf(f, "video_mode = %d x %d\n", (conf->vid_w), (conf->vid_h)); > fprintf(f, "video_mode_color_depth = %d\n", (conf->vid_color_depth)); >@@ -83,6 +97,7 @@ > fprintf(f, "perspective = %d\n", (conf->perspective_mode)); > fprintf(f, "moving_style = %d\n", (conf->moving_style)); > fclose(f); >+ return true; > } > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 64431
:
39773
|
39774
|
39810
|
39870
|
40145
|
40173
| 40174 |
41456
|
42009