void config_init(void)
{
- memset(option_d, 0, CONFIG_OPTION_D_COUNT * sizeof (int));
- memset(option_s, 0, CONFIG_OPTION_S_COUNT * sizeof (char *));
+ memset(option_d, 0, sizeof (option_d));
+ memset(option_s, 0, sizeof (option_s));
config_set_d(CONFIG_FULLSCREEN, DEFAULT_FULLSCREEN);
config_set_d(CONFIG_WIDTH, DEFAULT_WIDTH);
config_set_d(CONFIG_VIEW_DZ, DEFAULT_VIEW_DZ);
config_set_d(CONFIG_ROTATE_FAST, DEFAULT_ROTATE_FAST);
config_set_d(CONFIG_ROTATE_SLOW, DEFAULT_ROTATE_SLOW);
- config_set_d(CONFIG_LAST_SET, DEFAULT_LAST_SET);
+ config_set_d(CONFIG_MODE, DEFAULT_MODE);
+ config_set_d(CONFIG_CHEAT, DEFAULT_CHEAT);
config_set_s(CONFIG_PLAYER, DEFAULT_PLAYER);
config_set_s(CONFIG_BALL, DEFAULT_BALL);
- config_set_s(CONFIG_COIN, DEFAULT_COIN);
+ config_set_s(CONFIG_BALL_BONUS, DEFAULT_BALL_BONUS);
config_set_s(CONFIG_LANG, DEFAULT_LANG);
}
config_set_d(CONFIG_ROTATE_FAST, atoi(val));
else if (strcmp(key, "rotate_slow") == 0)
config_set_d(CONFIG_ROTATE_SLOW, atoi(val));
- else if (strcmp(key, "last_set") == 0)
- config_set_d(CONFIG_LAST_SET, atoi(val));
+ else if (strcmp(key, "mode") == 0)
+ config_set_d(CONFIG_MODE, atoi(val));
+ else if (strcmp(key, "cheat") == 0 && ALLOW_CHEAT)
+ config_set_d(CONFIG_CHEAT, atoi(val));
else if (strcmp(key, "key_camera_1") == 0)
config_key(val, CONFIG_KEY_CAMERA_1, DEFAULT_KEY_CAMERA_1);
else if (strcmp(key, "key_camera_l") == 0)
config_key(val, CONFIG_KEY_CAMERA_L, DEFAULT_KEY_CAMERA_L);
- else if (strcmp(key, "player") == 0)
- config_set_s(CONFIG_PLAYER, val);
- else if (strcmp(key, "ball") == 0)
- config_set_s(CONFIG_BALL, val);
- else if (strcmp(key, "coin") == 0)
- config_set_s(CONFIG_COIN, val);
- else if (strcmp(key, "lang") == 0)
- config_set_s(CONFIG_LANG, val);
+ else if (strcmp(key, "player") == 0)
+ config_set_s(CONFIG_PLAYER, val);
+ else if (strcmp(key, "ball") == 0)
+ config_set_s(CONFIG_BALL, val);
+ else if (strcmp(key, "ball_bonus") == 0)
+ config_set_s(CONFIG_BALL_BONUS, val);
+ else if (strcmp(key, "lang") == 0)
+ config_set_s(CONFIG_LANG, val);
}
fclose(fp);
option_d[CONFIG_ROTATE_FAST]);
fprintf(fp, "rotate_slow %d\n",
option_d[CONFIG_ROTATE_SLOW]);
- fprintf(fp, "last_set %d\n",
- option_d[CONFIG_LAST_SET]);
+ fprintf(fp, "mode %d\n",
+ option_d[CONFIG_MODE]);
+
+ if (option_d[CONFIG_CHEAT])
+ fprintf(fp,
+ "cheat %d\n",
+ option_d[CONFIG_CHEAT]);
fprintf(fp, "key_camera_1 %s\n",
SDL_GetKeyName(option_d[CONFIG_KEY_CAMERA_1]));
fprintf(fp, "player %s\n", option_s[CONFIG_PLAYER]);
fprintf(fp, "ball %s\n", option_s[CONFIG_BALL]);
- fprintf(fp, "coin %s\n", option_s[CONFIG_COIN]);
+ fprintf(fp, "ball_bonus %s\n", option_s[CONFIG_BALL_BONUS]);
fprintf(fp, "lang %s\n", option_s[CONFIG_LANG]);
fclose(fp);
if (SDL_SetVideoMode(w, h, 0, SDL_OPENGL | (f ? SDL_FULLSCREEN : 0)))
{
- option_d[CONFIG_FULLSCREEN] = f;
- option_d[CONFIG_WIDTH] = w;
- option_d[CONFIG_HEIGHT] = h;
- option_d[CONFIG_SHADOW] = option_d[CONFIG_SHADOW];
+ config_set_d(CONFIG_FULLSCREEN, f);
+ config_set_d(CONFIG_WIDTH, w);
+ config_set_d(CONFIG_HEIGHT, h);
glViewport(0, 0, w, h);
glClearColor(0.0f, 0.0f, 0.1f, 0.0f);
/*---------------------------------------------------------------------------*/
-static char data_path[MAXSTR];
-static char user_path[MAXSTR];
-
-/*
- * Given a path and a file name relative to that path, create an
- * absolute path name and return a temporary pointer to it.
- */
-static const char *config_file(const char *path, const char *file)
-{
- static char absolute[MAXSTR];
-
- size_t d = strlen(path);
-
- strncpy(absolute, path, MAXSTR - 1);
- strncat(absolute, "/", MAXSTR - d - 1);
- strncat(absolute, file, MAXSTR - d - 2);
-
- return absolute;
-}
-
-static int config_test(const char *path, const char *file)
-{
- if (file)
- {
- FILE *fp;
-
- if ((fp = fopen(config_file(path, file), "r")))
- {
- fclose(fp);
- return 1;
- }
- return 0;
- }
- return 1;
-}
-
-const char *config_data(const char *file)
-{
- return config_file(data_path, file);
-}
-
-const char *config_user(const char *file)
-{
- return config_file(user_path, file);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Attempt to find the game data directory. Search the command line
- * paramater, the environment, and the hard-coded default, in that
- * order. Confirm it by checking for presense of the named file.
- */
-int config_data_path(const char *path, const char *file)
-{
- char *dir;
-
- if (path && config_test(path, file))
- {
- strncpy(data_path, path, MAXSTR);
- return 1;
- }
-
- if ((dir = getenv("NEVERBALL_DATA")) && config_test(dir, file))
- {
- strncpy(data_path, dir, MAXSTR);
- return 1;
- }
-
- if (CONFIG_DATA && config_test(CONFIG_DATA, file))
- {
- strncpy(data_path, CONFIG_DATA, MAXSTR);
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Determine the location of the user's home directory. Ensure there
- * is a directory there for storing configuration, high scores, and
- * replays.
- *
- * HACK: under Windows just assume the user has permission to write to
- * the data directory. This is more reliable than trying to devine
- * anything reasonable from the environment.
- */
-int config_user_path(const char *file)
-{
-#ifdef _WIN32
- size_t d = strlen(CONFIG_USER);
-
- strncpy(user_path, data_path, MAXSTR - 1);
- strncat(user_path, "\\", MAXSTR - d - 1);
- strncat(user_path, CONFIG_USER, MAXSTR - d - 2);
-
- if ((mkdir(user_path) == 0) || (errno = EEXIST))
- if (config_test(user_path, file))
- return 1;
-#else
- char *dir;
-
- if ((dir = getenv("HOME")))
- {
- size_t d = strlen(dir);
-
- strncpy(user_path, getenv("HOME"), MAXSTR - 1);
- strncat(user_path, "/", MAXSTR - d - 1);
- strncat(user_path, CONFIG_USER, MAXSTR - d - 2);
- }
-
- if ((mkdir(user_path, 0777) == 0) || (errno = EEXIST))
- if (config_test(user_path, file))
- return 1;
-#endif
-
- return 0;
-}
-
-/*---------------------------------------------------------------------------*/
-
void config_set_d(int i, int d)
{
option_d[i] = d;
void config_tgl_d(int i)
{
option_d[i] = (option_d[i] ? 0 : 1);
+ dirty = 1;
}
int config_tst_d(int i, int d)
strncpy(dst, option_s[i], len);
}
-const char * config_simple_get_s(int i)
+const char *config_simple_get_s(int i)
{
- return option_s[i];
+ return option_s[i];
}
/*---------------------------------------------------------------------------*/
GLdouble s = sin(r);
GLdouble c = cos(r) / s;
- GLdouble a = ((GLdouble) option_d[CONFIG_WIDTH] /
+ GLdouble a = ((GLdouble) option_d[CONFIG_WIDTH] /
(GLdouble) option_d[CONFIG_HEIGHT]);
glMatrixMode(GL_PROJECTION);