diff --git a/ChangeLog b/ChangeLog index 21b6a60..827cf32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,9 @@ -$Id: ChangeLog,v 1.50 2004/01/06 20:49:57 stpohle Exp $ +$Id: ChangeLog,v 1.51 2004/01/06 23:07:21 stpohle Exp $ Version 0.11.0 ============== 2004-01-06 -- Added Programm flags to the game. For more information +- Added Programm options to the game. For more information run BomberClone with -help. - Compiler Flag added for disabling debuging. Compiler diff --git a/src/configuration.c b/src/configuration.c index 44e52f1..51d72bd 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -19,13 +19,13 @@ config_init (int argc, char **argv) srand (((int) time (NULL))); // initialize randomgenerator for (i = 0; i < MAX_PLAYERS; i++) { - players[i].gfx = NULL; /* we will select them in the wait_for_players loop */ + players[i].gfx = NULL; /* we will select them in the wait_for_players loop */ players[i].gfx_nr = -1; /* and even now in the singleplayer menu */ } - menu.oldscreen = NULL; - - stonelist_del (); + menu.oldscreen = NULL; + + stonelist_del (); chat.visible = 0; chat.startline = 0; keybinput_new (&chat.input, KEYBI_text, 255); @@ -35,7 +35,7 @@ config_init (int argc, char **argv) bman.maxplayer = MAX_PLAYERS; bman.net_ai_family = PF_INET; - bman.sock = -1; + bman.sock = -1; bman.gamename[0] = 0; sprintf (bman.port, "%d", DEFAULT_UDPPORT); sprintf (bman.ogcserver, DEFAULT_GAMECACHE); @@ -47,58 +47,60 @@ config_init (int argc, char **argv) debug = 0; gfx.res.x = 640; gfx.res.y = 480; - gfx.bpp = 16; - map.tileset[0] = 0; - map.random_tileset = 1; + gfx.bpp = 16; + map.tileset[0] = 0; + map.random_tileset = 1; map.size.x = 25; map.size.y = 17; sprintf (bman.datapath, PACKAGE_DATA_DIR); map.map[0] = 0; - map.map_selection = 2; - map.type = -1; - bman.firewall = 0; - bman.init_timeout = GAME_TIMEOUT; - bman.ai_players = 1; - snd.inited = 0; - snd.audio_rate = 22050; - snd.audio_format = AUDIO_S16; - snd.audio_channels = 2; - snd.playmusic = 1; - snd.playsound = 1; - map.bombs = GAME_SPECIAL_ITEMBOMB; - map.fire = GAME_SPECIAL_ITEMFIRE; - map.shoes = GAME_SPECIAL_ITEMSHOE; - map.mixed = GAME_SPECIAL_ITEMMIXED; - map.death = GAME_SPECIAL_ITEMDEATH; - map.sp_trigger = GAME_SPECIAL_ITEMSTRIGGER; - map.sp_row = GAME_SPECIAL_ITEMSROW; - map.sp_push = GAME_SPECIAL_ITEMSPUSH; - - d_printf ("\n\n ***** Bomberclone Version %s \n\n",VERSION); - if (config_read()) { /* error on reading the config file */ - ReadPrgArgs (argc, argv); - gfx_init (); - draw_logo (); - bman.playername[LEN_PLAYERNAME-1] = 0; - bman.playername[0] = 0; - config_menu (); - } else { - ReadPrgArgs (argc, argv); - gfx_init (); - draw_logo (); - if (bman.askplayername) - config_menu (); - } - - snd_init (); - gfx_blitdraw (); - SDL_Flip (gfx.screen); + map.map_selection = 2; + map.type = -1; + bman.firewall = 0; + bman.init_timeout = GAME_TIMEOUT; + bman.ai_players = 1; + snd.inited = 0; + snd.audio_rate = 22050; + snd.audio_format = AUDIO_S16; + snd.audio_channels = 2; + snd.playmusic = 1; + snd.playsound = 1; + map.bombs = GAME_SPECIAL_ITEMBOMB; + map.fire = GAME_SPECIAL_ITEMFIRE; + map.shoes = GAME_SPECIAL_ITEMSHOE; + map.mixed = GAME_SPECIAL_ITEMMIXED; + map.death = GAME_SPECIAL_ITEMDEATH; + map.sp_trigger = GAME_SPECIAL_ITEMSTRIGGER; + map.sp_row = GAME_SPECIAL_ITEMSROW; + map.sp_push = GAME_SPECIAL_ITEMSPUSH; + d_printf ("\n\n ***** Bomberclone Version %s \n\n", VERSION); + if (config_read ()) { /* error on reading the config file */ + ReadPrgArgs (argc, argv); + gfx_init (); + draw_logo (); + bman.playername[LEN_PLAYERNAME - 1] = 0; + bman.playername[0] = 0; + config_menu (); + } + else { + ReadPrgArgs (argc, argv); + gfx_init (); + draw_logo (); + if (bman.askplayername) + config_menu (); + } + + snd_init (); + gfx_blitdraw (); + SDL_Flip (gfx.screen); }; /* read the configuration file * return -1 if something went wrong and 0 if no problem */ -int config_read () { +int +config_read () +{ FILE *config; char buf[1024]; char *findit, @@ -185,7 +187,7 @@ int config_read () { LEN_PATHFILENAME); } value[511] = 0; - strcpy(map.map,value); + strcpy (map.map, value); } if (!strcmp (keyword, "firewall")) { bman.firewall = atoi (value); @@ -241,21 +243,21 @@ int config_read () { if (!strcmp (keyword, "gametimeout")) { bman.init_timeout = atoi (value); } - if(!strcmp (keyword, "sndrate")) { - snd.audio_rate = atoi (value); - } - if (!strcmp (keyword, "sndchannels")) { - snd.audio_channels = atoi (value); - } - if (!strcmp (keyword, "sndformat")) { - snd.audio_format = atoi (value); - } - if (!strcmp (keyword, "sndplaymusic")) { - snd.playmusic = atoi (value); - } - if (!strcmp (keyword, "sndplaysound")) { - snd.playsound = atoi (value); - } + if (!strcmp (keyword, "sndrate")) { + snd.audio_rate = atoi (value); + } + if (!strcmp (keyword, "sndchannels")) { + snd.audio_channels = atoi (value); + } + if (!strcmp (keyword, "sndformat")) { + snd.audio_format = atoi (value); + } + if (!strcmp (keyword, "sndplaymusic")) { + snd.playmusic = atoi (value); + } + if (!strcmp (keyword, "sndplaysound")) { + snd.playsound = atoi (value); + } } fclose (config); return 0; @@ -281,7 +283,7 @@ config_write () fprintf (config, "mapname=%s\n", map.map); fprintf (config, "firewall=%d\n", bman.firewall); fprintf (config, "udpport=%s\n", bman.port); - fprintf (config, "ai_players=%d\n", bman.ai_players); + fprintf (config, "ai_players=%d\n", bman.ai_players); fprintf (config, "fieldsizex=%d\n", map.size.x); fprintf (config, "fieldsizey=%d\n", map.size.y); fprintf (config, "notify=%d\n", bman.notifygamemaster); @@ -294,14 +296,14 @@ config_write () fprintf (config, "debug=%d\n", debug); fprintf (config, "askplayername=%d\n", bman.askplayername); fprintf (config, "playername=%s\n", bman.playername); - fprintf (config, "bitsperpixel=%d\n", gfx.bpp); - fprintf (config, "randomtileset=%d\n", map.random_tileset); - fprintf (config, "mapselection=%d\n", map.map_selection); - fprintf (config, "sndrate=%d\n", snd.audio_rate); - fprintf (config, "sndchannels=%d\n", snd.audio_channels); - fprintf (config, "sndformat=%d\n", snd.audio_format); - fprintf (config, "sndplaymusic=%d\n", snd.playmusic); - fprintf (config, "sndplaysound=%d\n", snd.playsound); + fprintf (config, "bitsperpixel=%d\n", gfx.bpp); + fprintf (config, "randomtileset=%d\n", map.random_tileset); + fprintf (config, "mapselection=%d\n", map.map_selection); + fprintf (config, "sndrate=%d\n", snd.audio_rate); + fprintf (config, "sndchannels=%d\n", snd.audio_channels); + fprintf (config, "sndformat=%d\n", snd.audio_format); + fprintf (config, "sndplaymusic=%d\n", snd.playmusic); + fprintf (config, "sndplaysound=%d\n", snd.playsound); fclose (config); return 0; } @@ -311,68 +313,72 @@ config_write () void config_video () { - int done = 0, menuselect, x, y; + int done = 0, + menuselect, + x, + y; _charlist screenres[] = { {"640x480", NULL}, - {"800x600", NULL}, + {"800x600", NULL}, {"1024x768", NULL}, {"1280x1024", NULL} }; _charlist screenbpp[] = { {"16", NULL}, - {"24", NULL}, + {"24", NULL}, {"32", NULL} }; - _charlist *selres = NULL; - _charlist *selbpp = NULL; - char text[100]; - - /* set all pointers in this array */ - charlist_fillarraypointer (screenres, 4); - charlist_fillarraypointer (screenbpp, 3); - - /* select the current settings */ - sprintf (text, "%dx%d", gfx.res.x, gfx.res.y); - selres = charlist_findtext (screenres, text); - sprintf (text, "%d", gfx.bpp); - selbpp = charlist_findtext (screenbpp, text); - - while (!done && bman.state != GS_quit) { - menu_new ("Video Setup", 325, 300); - menu_create_label ("Resolution", 25, 70, 0); - menu_create_list ("res", 155, 55, 150, 70, screenres, &selres, 1); - menu_create_label ("Colors", 65, 160, 0); - menu_create_list ("bpp", 195, 145, 50, 55, screenbpp, &selbpp, 2); - menu_create_bool ("Fullscreen", -1, 210, 150, &gfx.fullscreen, 3); - menu_create_button ("OK", -1, 250, 100, 0); - menuselect = menu_loop (); - menu_delete (); - - switch (menuselect) { - case (0): - done = 1; - gfx_shutdown (); - gfx_init (); - break; - case (1): // new resolution - gfx_shutdown (); - sscanf (selres->text, "%dx%d", &x, &y); - gfx.res.x = x; gfx.res.y = y; - gfx_init (); - break; - case (2): // new color depth - gfx_shutdown (); - sscanf (selbpp->text, "%d", &x); - gfx.bpp = x; - gfx_init (); - break; - default: - done = 1; - break; - } - }; - draw_logo (); - SDL_Flip (gfx.screen); + _charlist *selres = NULL; + _charlist *selbpp = NULL; + char text[100]; + + /* set all pointers in this array */ + charlist_fillarraypointer (screenres, 4); + charlist_fillarraypointer (screenbpp, 3); + + /* select the current settings */ + sprintf (text, "%dx%d", gfx.res.x, gfx.res.y); + selres = charlist_findtext (screenres, text); + sprintf (text, "%d", gfx.bpp); + selbpp = charlist_findtext (screenbpp, text); + + while (!done && bman.state != GS_quit) { + menu_new ("Video Setup", 325, 300); + menu_create_label ("Resolution", 25, 70, 0); + menu_create_list ("res", 155, 55, 150, 70, screenres, &selres, 1); + menu_create_label ("Colors", 65, 160, 0); + menu_create_list ("bpp", 195, 145, 50, 55, screenbpp, &selbpp, 2); + menu_create_bool ("Fullscreen", -1, 210, 150, &gfx.fullscreen, 3); + menu_create_button ("OK", -1, 250, 100, 0); + menuselect = menu_loop (); + menu_delete (); + + switch (menuselect) { + case (0): + done = 1; + gfx_shutdown (); + gfx_init (); + break; + case (1): // new resolution + gfx_shutdown (); + sscanf (selres->text, "%dx%d", &x, &y); + gfx.res.x = x; + gfx.res.y = y; + gfx_init (); + break; + case (2): // new color depth + gfx_shutdown (); + sscanf (selbpp->text, "%d", &x); + gfx.bpp = x; + gfx_init (); + break; + default: + done = 1; + break; + } + }; + draw_logo (); + SDL_Flip (gfx.screen); }; @@ -383,43 +389,43 @@ config_video () void config_menu () { - int menuselect = 0; - - menu_new ("Configuration", 400, 300); - menu_create_label ("General Option", -1, 50, 1); - menu_create_entry ("Name", -1, 85, 200, bman.playername, LEN_PLAYERNAME, MENU_entrytext, 1); - menu_create_button ("Video Setup", -1, 120, 200, 2); - menu_create_label ("Sound", 25 , 154, 0); - menu_create_bool ("ON", 100, 150, 50, &snd.playsound, 3); - menu_create_label ("Music", 250 , 154, 0); - menu_create_bool ("ON", 325, 150, 50, &snd.playmusic, 4); - menu_create_label ("Extended Option", -1, 200, 1); - menu_create_bool ("Debug", 25, 230, 150, &debug, 5); - menu_create_bool ("Ask Playername", 250, 230, 150, &bman.askplayername, 6); - menu_create_button ("Ok", -1, 270, 150, 0); - while (menuselect != -1 && bman.state != GS_quit) { - if (bman.playername[0] == '\0') - menu_focus_id (1); - else - menu_focus_id (0); - - menu_reload (); - menuselect = menu_loop (); - - switch (menuselect) { - case (0): // Back to the Main Menu - if (bman.playername[0] == '\0') - menuselect = 0; - else - menuselect = -1; - break; - case (2): // Screen Options - config_video (); - break; - } - } - menu_delete (); - config_write (); + int menuselect = 0; + + while (menuselect != -1 && bman.state != GS_quit) { + menu_new ("Configuration", 400, 300); + menu_create_label ("General Option", -1, 50, 1); + menu_create_entry ("Name", -1, 85, 200, bman.playername, LEN_PLAYERNAME, MENU_entrytext, 1); + menu_create_button ("Video Setup", -1, 120, 200, 2); + menu_create_label ("Sound", 25, 154, 0); + menu_create_bool ("ON", 100, 150, 50, &snd.playsound, 3); + menu_create_label ("Music", 250, 154, 0); + menu_create_bool ("ON", 325, 150, 50, &snd.playmusic, 4); + menu_create_label ("Extended Option", -1, 200, 1); + menu_create_bool ("Debug", 25, 230, 150, &debug, 5); + menu_create_bool ("Ask Playername", 250, 230, 150, &bman.askplayername, 6); + menu_create_button ("Ok", -1, 270, 150, 0); + if (bman.playername[0] == '\0') + menu_focus_id (1); + else + menu_focus_id (0); + + menu_reload (); + menuselect = menu_loop (); + + menu_delete (); + switch (menuselect) { + case (0): // Back to the Main Menu + if (bman.playername[0] == '\0') + menuselect = 0; + else + menuselect = -1; + break; + case (2): // Screen Options + config_video (); + break; + } + } + config_write (); }; @@ -434,27 +440,27 @@ ReadPrgArgs (int argc, char **argv) strncpy (bman.port, argv[++i], LEN_PORT); if (!strcmp (argv[i], "-ogcport")) strncpy (bman.ogc_port, argv[++i], LEN_PORT); - if (!strcmp (argv[i], "-firewall")) - bman.firewall = 1; - if (!strcmp (argv[i], "-name")) - strncpy (bman.playername, argv[++i], LEN_PLAYERNAME); - if (!strcmp (argv[i], "-help")) { - printf ("BomberClone Version " VERSION "\n"); - printf (" WebPage : http://www.bomberclone.de\n"); - printf (" Bug Report to :\n"); - printf (" http://sourceforge.net/tracker/?group_id=79449&atid=556629\n"); - printf (" Other Comments: steffen@bomberclone.de\n"); - printf ("\nProgramm options:\n"); - printf (" -name PLAYERNAME - set the Playername\n"); - printf (" -port PORT - set the local BomberClone port (Def.: 11000)\n"); - printf (" -ogcport PORT - set the local OGC Port (Def.: 11100)\n"); - printf (" -ogc 0/1 - Enable/Disable OGC\n"); - printf (" -firewall - Client is behind a firewall\n"); - printf (" Only set this if you get some problems\n"); - printf (" with network games.\n"); - exit (0); - } - if (!strcmp (argv[i], "-ogc")) - bman.notifygamemaster = atoi (argv[++i]); - } + if (!strcmp (argv[i], "-firewall")) + bman.firewall = 1; + if (!strcmp (argv[i], "-name")) + strncpy (bman.playername, argv[++i], LEN_PLAYERNAME); + if (!strcmp (argv[i], "-help")) { + printf ("BomberClone Version " VERSION "\n"); + printf (" WebPage : http://www.bomberclone.de\n"); + printf (" Bug Report to :\n"); + printf (" http://sourceforge.net/tracker/?group_id=79449&atid=556629\n"); + printf (" Other Comments: steffen@bomberclone.de\n"); + printf ("\nProgramm options:\n"); + printf (" -name PLAYERNAME - set the Playername\n"); + printf (" -port PORT - set the local BomberClone port (Def.: 11000)\n"); + printf (" -ogcport PORT - set the local OGC Port (Def.: 11100)\n"); + printf (" -ogc 0/1 - Enable/Disable OGC\n"); + printf (" -firewall - Client is behind a firewall\n"); + printf (" Only set this if you get some problems\n"); + printf (" with network games.\n"); + exit (0); + } + if (!strcmp (argv[i], "-ogc")) + bman.notifygamemaster = atoi (argv[++i]); + } };