@ -1,4 +1,4 @@
/* $Id: configuration.c,v 1.7 5 2005/04/10 00:22:17 stpohle Exp $
/* $Id: configuration.c,v 1.7 6 2005/07/06 13:11:55 stpohle Exp $
* configuration */
* configuration */
# include <SDL.h>
# include <SDL.h>
@ -21,29 +21,31 @@
* 2 ) . / data
* 2 ) . / data
* 3 ) . . / data
* 3 ) . . / data
*/
*/
void config_get_datapath ( ) {
void
FILE * f ;
config_get_datapath ( )
char filename [ 255 ] ;
{
FILE * f ;
char filename [ 255 ] ;
sprintf ( bman . datapath , PACKAGE_DATA_DIR ) ;
sprintf ( bman . datapath , PACKAGE_DATA_DIR ) ;
sprintf ( filename , " %s/gfx/logo.png " , bman . datapath ) ;
sprintf ( filename , " %s/gfx/logo.png " , bman . datapath ) ;
f = fopen ( filename , " r " ) ;
f = fopen ( filename , " r " ) ;
if ( ! f ) {
if ( ! f ) {
sprintf ( bman . datapath , " data " ) ;
sprintf ( bman . datapath , " data " ) ;
sprintf ( filename , " %s/gfx/logo.png " , bman . datapath ) ;
sprintf ( filename , " %s/gfx/logo.png " , bman . datapath ) ;
f = fopen ( filename , " r " ) ;
f = fopen ( filename , " r " ) ;
if ( ! f ) {
if ( ! f ) {
sprintf ( bman . datapath , " ../data " ) ;
sprintf ( bman . datapath , " ../data " ) ;
sprintf ( filename , " %s/gfx/logo.png " , bman . datapath ) ;
sprintf ( filename , " %s/gfx/logo.png " , bman . datapath ) ;
f = fopen ( filename , " r " ) ;
f = fopen ( filename , " r " ) ;
if ( ! f ) {
if ( ! f ) {
printf ( " Can't find Datafiles. \n " ) ;
printf ( " Can't find Datafiles. \n " ) ;
exit ( 1 ) ;
exit ( 1 ) ;
}
}
}
}
}
}
fclose ( f ) ;
fclose ( f ) ;
}
}
@ -53,26 +55,28 @@ void config_get_datapath () {
void
void
config_init ( int argc , char * * argv )
config_init ( int argc , char * * argv )
{
{
SDL_Surface * icon_img ;
SDL_Surface * icon_img ;
char text [ 255 ] , icon [ 255 ] ;
char text [ 255 ] ,
int i , j ;
icon [ 255 ] ;
int i ,
j ;
config_get_datapath ( ) ;
config_get_datapath ( ) ;
srand ( ( ( int ) time ( NULL ) ) ) ; // initialize randomgenerator
srand ( ( ( int ) time ( NULL ) ) ) ; // initialize randomgenerator
for ( i = 0 ; i < MAX_TEAMS ; i + + ) {
for ( i = 0 ; i < MAX_TEAMS ; i + + ) {
teams [ i ] . col = i ;
teams [ i ] . col = i ;
sprintf ( teams [ i ] . name , " Team %d " , i + 1 ) ;
sprintf ( teams [ i ] . name , " Team %d " , i + 1 ) ;
for ( j = 0 ; j < MAX_PLAYERS ; j + + )
for ( j = 0 ; j < MAX_PLAYERS ; j + + )
teams [ i ] . players [ j ] = NULL ;
teams [ i ] . players [ j ] = NULL ;
}
}
stonelist_del ( ) ;
stonelist_del ( ) ;
chat . oldscreen = NULL ;
chat . oldscreen = NULL ;
chat . active = 0 ;
chat . active = 0 ;
chat . curline = 0 ;
chat . curline = 0 ;
keyb_config_reset ( ) ;
keyb_config_reset ( ) ;
keybinput_new ( & chat . input , KEYBI_text , 255 ) ;
keybinput_new ( & chat . input , KEYBI_text , 255 ) ;
for ( i = 0 ; i < CHAT_MAX_LINES ; i + + )
for ( i = 0 ; i < CHAT_MAX_LINES ; i + + )
@ -81,28 +85,27 @@ config_init (int argc, char **argv)
bman . maxplayer = MAX_PLAYERS ;
bman . maxplayer = MAX_PLAYERS ;
bman . net_ai_family = PF_INET ;
bman . net_ai_family = PF_INET ;
bman . sock = - 1 ;
bman . sock = - 1 ;
bman . p_nr = - 1 ;
bman . p_nr = - 1 ;
bman . p2_nr = - 1 ;
bman . p2_nr = - 1 ;
bman . gamename [ 0 ] = 0 ;
bman . gamename [ 0 ] = 0 ;
sprintf ( bman . playername , " Player1 " ) ;
sprintf ( bman . playername , " Player1 " ) ;
sprintf ( bman . player2name , " Player2 " ) ;
sprintf ( bman . player2name , " Player2 " ) ;
sprintf ( bman . port , " %d " , DEFAULT_UDPPORT ) ;
sprintf ( bman . port , " %d " , DEFAULT_UDPPORT ) ;
sprintf ( bman . ogcserver , DEFAULT_GAMECACHE ) ;
sprintf ( bman . ogcserver , DEFAULT_GAMECACHE ) ;
sprintf ( bman . ogc_port , DEFAULT_GAMECACHEPORT ) ;
sprintf ( bman . ogc_port , DEFAULT_GAMECACHEPORT ) ;
resend_cache . data = NULL ;
resend_cache . data = NULL ;
resend_cache . fill = - 1 ;
resend_cache . fill = - 1 ;
bman . notifygamemaster = 1 ;
bman . notifygamemaster = 1 ;
bman . broadcast = 1 ;
bman . broadcast = 1 ;
bman . dedicated = 0 ;
bman . autostart = AUTOSTART ;
bman . autostart = AUTOSTART ;
bman . askplayername = 0 ;
bman . askplayername = 0 ;
debug = 0 ;
debug = 0 ;
gfx . res . x = 640 ;
gfx . res . x = 640 ;
gfx . res . y = 480 ;
gfx . res . y = 480 ;
gfx . bpp = 16 ;
gfx . bpp = 16 ;
gfx . players = NULL ;
gfx . players = NULL ;
bman . password [ 0 ] = 0 ;
bman . password [ 0 ] = 0 ;
bman . passwordenabled = 0 ;
bman . passwordenabled = 0 ;
map . tileset [ 0 ] = 0 ;
map . tileset [ 0 ] = 0 ;
map . random_tileset = 1 ;
map . random_tileset = 1 ;
map . size . x = 25 ;
map . size . x = 25 ;
@ -113,7 +116,7 @@ config_init (int argc, char **argv)
bman . firewall = 0 ;
bman . firewall = 0 ;
bman . init_timeout = GAME_TIMEOUT ;
bman . init_timeout = GAME_TIMEOUT ;
bman . ai_players = 1 ;
bman . ai_players = 1 ;
bman . minplayers = 0 ;
bman . minplayers = 0 ;
snd . inited = 0 ;
snd . inited = 0 ;
snd . audio_rate = 22050 ;
snd . audio_rate = 22050 ;
snd . audio_format = AUDIO_S16 ;
snd . audio_format = AUDIO_S16 ;
@ -130,51 +133,51 @@ config_init (int argc, char **argv)
map . sp_push = GAME_SPECIAL_ITEMSPUSH ;
map . sp_push = GAME_SPECIAL_ITEMSPUSH ;
map . sp_kick = GAME_SPECIAL_ITEMSKICK ;
map . sp_kick = GAME_SPECIAL_ITEMSKICK ;
bman . start_bombs = START_BOMBS ;
bman . start_bombs = START_BOMBS ;
bman . start_speed = START_SPEED ;
bman . start_speed = START_SPEED ;
bman . start_range = START_RANGE ;
bman . start_range = START_RANGE ;
bman . bomb_tickingtime = BOMB_TIMEOUT ;
bman . bomb_tickingtime = BOMB_TIMEOUT ;
bman . dropitemsondeath = 0 ;
bman . dropitemsondeath = 0 ;
d_printf ( " \n \n ***** Bomberclone Version %s \n \n " , VERSION ) ;
d_printf ( " \n \n ***** Bomberclone Version %s \n \n " , VERSION ) ;
config_read ( ) ;
config_read ( ) ;
ReadPrgArgs ( argc , argv ) ;
ReadPrgArgs ( argc , argv ) ;
gfx_init ( ) ;
gfx_init ( ) ;
draw_logo ( ) ;
draw_logo ( ) ;
if ( bman . askplayername )
if ( bman . askplayername )
playernamemenu ( ) ;
playernamemenu ( ) ;
snd_init ( ) ;
snd_init ( ) ;
gfx_blitdraw ( ) ;
gfx_blitdraw ( ) ;
if ( ! bman . dedicated )
SDL_Flip ( gfx . screen ) ;
SDL_Flip ( gfx . screen ) ;
sprintf ( text , " Bomberclone %s " , VERSION ) ;
sprintf ( text , " Bomberclone %s " , VERSION ) ;
sprintf ( icon , " %s/pixmaps/bomberclone.png " , bman . datapath ) ;
sprintf ( icon , " %s/pixmaps/bomberclone.png " , bman . datapath ) ;
SDL_WM_SetCaption ( text , NULL ) ;
SDL_WM_SetCaption ( text , NULL ) ;
icon_img = IMG_Load ( icon ) ;
icon_img = IMG_Load ( icon ) ;
if ( icon_img = = NULL )
if ( icon_img = = NULL )
d_printf ( " could not load icon. (%s) \n " , icon ) ;
d_printf ( " could not load icon. (%s) \n " , icon ) ;
# ifdef _WIN32
# ifdef _WIN32
{
{
SDL_Surface * tmp = icon_img ;
SDL_Surface * tmp = icon_img ;
icon_img = scale_image ( tmp , 32 , 32 ) ;
icon_img = scale_image ( tmp , 32 , 32 ) ;
SDL_FreeSurface ( tmp ) ;
SDL_FreeSurface ( tmp ) ;
}
}
# endif
# endif
SDL_WM_SetIcon ( icon_img , NULL ) ;
SDL_WM_SetIcon ( icon_img , NULL ) ;
ReadPrgArgs_Jump ( argc , argv ) ;
ReadPrgArgs_Jump ( argc , argv ) ;
} ;
} ;
/* read the configuration file
/* read the configuration file
* return - 1 if something went wrong and 0 if no problem */
* return - 1 if something went wrong and 0 if no problem */
int
int
config_read ( ) {
config_read ( )
{
FILE * config ;
FILE * config ;
char buf [ 1024 ] ;
char buf [ 1024 ] ;
char * findit ,
char * findit ,
@ -373,60 +376,60 @@ config_read () {
bman . dropitemsondeath = atoi ( value ) ;
bman . dropitemsondeath = atoi ( value ) ;
}
}
for ( i = 0 ; i < MAX_TEAMS ; i + + ) {
for ( i = 0 ; i < MAX_TEAMS ; i + + ) {
char txt [ 255 ] ;
char txt [ 255 ] ;
sprintf ( txt , " teamcol%d " , i ) ;
sprintf ( txt , " teamcol%d " , i ) ;
if ( ! strcmp ( keyword , txt ) ) {
if ( ! strcmp ( keyword , txt ) ) {
teams [ i ] . col = atoi ( value ) ;
teams [ i ] . col = atoi ( value ) ;
}
}
sprintf ( txt , " teamname%d " , i ) ;
sprintf ( txt , " teamname%d " , i ) ;
if ( ! strcmp ( keyword , txt ) ) {
if ( ! strcmp ( keyword , txt ) ) {
strncpy ( teams [ i ] . name , value , LEN_PLAYERNAME ) ;
strncpy ( teams [ i ] . name , value , LEN_PLAYERNAME ) ;
}
}
}
}
/*
/*
* keyboard config , i will give names to the keys insteed of the numbers ,
* keyboard config , i will give names to the keys insteed of the numbers ,
* this is done to add more keys to the game without destroying the config .
* this is done to add more keys to the game without destroying the config .
*/
*/
if ( ! strcmp ( keyword , " key_p1_up " ) )
if ( ! strcmp ( keyword , " key_p1_up " ) )
keyb_gamekeys . keycode [ BCPK_up ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_up ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p1_down " ) )
if ( ! strcmp ( keyword , " key_p1_down " ) )
keyb_gamekeys . keycode [ BCPK_down ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_down ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p1_left " ) )
if ( ! strcmp ( keyword , " key_p1_left " ) )
keyb_gamekeys . keycode [ BCPK_left ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_left ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p1_right " ) )
if ( ! strcmp ( keyword , " key_p1_right " ) )
keyb_gamekeys . keycode [ BCPK_right ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_right ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p1_bomb " ) )
if ( ! strcmp ( keyword , " key_p1_bomb " ) )
keyb_gamekeys . keycode [ BCPK_drop ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_drop ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p1_special " ) )
if ( ! strcmp ( keyword , " key_p1_special " ) )
keyb_gamekeys . keycode [ BCPK_special ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_special ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p2_up " ) )
if ( ! strcmp ( keyword , " key_p2_up " ) )
keyb_gamekeys . keycode [ BCPK_max + BCPK_up ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_max + BCPK_up ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p2_down " ) )
if ( ! strcmp ( keyword , " key_p2_down " ) )
keyb_gamekeys . keycode [ BCPK_max + BCPK_down ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_max + BCPK_down ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p2_left " ) )
if ( ! strcmp ( keyword , " key_p2_left " ) )
keyb_gamekeys . keycode [ BCPK_max + BCPK_left ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_max + BCPK_left ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p2_right " ) )
if ( ! strcmp ( keyword , " key_p2_right " ) )
keyb_gamekeys . keycode [ BCPK_max + BCPK_right ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_max + BCPK_right ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p2_bomb " ) )
if ( ! strcmp ( keyword , " key_p2_bomb " ) )
keyb_gamekeys . keycode [ BCPK_max + BCPK_drop ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_max + BCPK_drop ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_p2_special " ) )
if ( ! strcmp ( keyword , " key_p2_special " ) )
keyb_gamekeys . keycode [ BCPK_max + BCPK_special ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCPK_max + BCPK_special ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_help " ) )
if ( ! strcmp ( keyword , " key_help " ) )
keyb_gamekeys . keycode [ BCK_help ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCK_help ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_playermenu " ) )
if ( ! strcmp ( keyword , " key_playermenu " ) )
keyb_gamekeys . keycode [ BCK_playermenu ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCK_playermenu ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_mapmenu " ) )
if ( ! strcmp ( keyword , " key_mapmenu " ) )
keyb_gamekeys . keycode [ BCK_mapmenu ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCK_mapmenu ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_chat " ) )
if ( ! strcmp ( keyword , " key_chat " ) )
keyb_gamekeys . keycode [ BCK_chat ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCK_chat ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_pause " ) )
if ( ! strcmp ( keyword , " key_pause " ) )
keyb_gamekeys . keycode [ BCK_pause ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCK_pause ] = atoi ( value ) ;
if ( ! strcmp ( keyword , " key_fullscreen " ) )
if ( ! strcmp ( keyword , " key_fullscreen " ) )
keyb_gamekeys . keycode [ BCK_fullscreen ] = atoi ( value ) ;
keyb_gamekeys . keycode [ BCK_fullscreen ] = atoi ( value ) ;
}
}
fclose ( config ) ;
fclose ( config ) ;
return 0 ;
return 0 ;
@ -437,7 +440,7 @@ int
config_write ( )
config_write ( )
{
{
FILE * config ;
FILE * config ;
int i ;
int i ;
char filename [ 512 ] ;
char filename [ 512 ] ;
# ifdef _WIN32
# ifdef _WIN32
@ -466,8 +469,8 @@ config_write ()
fprintf ( config , " gametype=%d \n " , bman . gametype ) ;
fprintf ( config , " gametype=%d \n " , bman . gametype ) ;
fprintf ( config , " maxplayer=%d \n " , bman . maxplayer ) ;
fprintf ( config , " maxplayer=%d \n " , bman . maxplayer ) ;
fprintf ( config , " debug=%d \n " , debug ) ;
fprintf ( config , " debug=%d \n " , debug ) ;
fprintf ( config , " password=%s \n " , bman . password ) ;
fprintf ( config , " password=%s \n " , bman . password ) ;
fprintf ( config , " passwordenabled=%d \n " , bman . passwordenabled ) ;
fprintf ( config , " passwordenabled=%d \n " , bman . passwordenabled ) ;
fprintf ( config , " askplayername=%d \n " , bman . askplayername ) ;
fprintf ( config , " askplayername=%d \n " , bman . askplayername ) ;
fprintf ( config , " playername=%s \n " , bman . playername ) ;
fprintf ( config , " playername=%s \n " , bman . playername ) ;
fprintf ( config , " player2name=%s \n " , bman . player2name ) ;
fprintf ( config , " player2name=%s \n " , bman . player2name ) ;
@ -479,37 +482,37 @@ config_write ()
fprintf ( config , " sndformat=%d \n " , snd . audio_format ) ;
fprintf ( config , " sndformat=%d \n " , snd . audio_format ) ;
fprintf ( config , " sndplaymusic=%d \n " , snd . playmusic ) ;
fprintf ( config , " sndplaymusic=%d \n " , snd . playmusic ) ;
fprintf ( config , " sndplaysound=%d \n " , snd . playsound ) ;
fprintf ( config , " sndplaysound=%d \n " , snd . playsound ) ;
fprintf ( config , " start_bombs=%d \n " , bman . start_bombs ) ;
fprintf ( config , " start_bombs=%d \n " , bman . start_bombs ) ;
fprintf ( config , " start_range=%d \n " , bman . start_range ) ;
fprintf ( config , " start_range=%d \n " , bman . start_range ) ;
fprintf ( config , " start_speed=%f \n " , bman . start_speed ) ;
fprintf ( config , " start_speed=%f \n " , bman . start_speed ) ;
fprintf ( config , " bomb_ticking=%f \n " , bman . bomb_tickingtime ) ;
fprintf ( config , " bomb_ticking=%f \n " , bman . bomb_tickingtime ) ;
for ( i = 0 ; i < MAX_TEAMS ; i + + ) {
for ( i = 0 ; i < MAX_TEAMS ; i + + ) {
fprintf ( config , " teamcol%d=%d \n " , i , teams [ i ] . col ) ;
fprintf ( config , " teamcol%d=%d \n " , i , teams [ i ] . col ) ;
fprintf ( config , " teamname%d=%s \n " , i , teams [ i ] . name ) ;
fprintf ( config , " teamname%d=%s \n " , i , teams [ i ] . name ) ;
}
}
/*
/*
* keyboard config
* keyboard config
*/
*/
fprintf ( config , " key_p1_up=%d \n " , keyb_gamekeys . keycode [ BCPK_up ] ) ;
fprintf ( config , " key_p1_up=%d \n " , keyb_gamekeys . keycode [ BCPK_up ] ) ;
fprintf ( config , " key_p1_down=%d \n " , keyb_gamekeys . keycode [ BCPK_down ] ) ;
fprintf ( config , " key_p1_down=%d \n " , keyb_gamekeys . keycode [ BCPK_down ] ) ;
fprintf ( config , " key_p1_left=%d \n " , keyb_gamekeys . keycode [ BCPK_left ] ) ;
fprintf ( config , " key_p1_left=%d \n " , keyb_gamekeys . keycode [ BCPK_left ] ) ;
fprintf ( config , " key_p1_right=%d \n " , keyb_gamekeys . keycode [ BCPK_right ] ) ;
fprintf ( config , " key_p1_right=%d \n " , keyb_gamekeys . keycode [ BCPK_right ] ) ;
fprintf ( config , " key_p1_bomb=%d \n " , keyb_gamekeys . keycode [ BCPK_drop ] ) ;
fprintf ( config , " key_p1_bomb=%d \n " , keyb_gamekeys . keycode [ BCPK_drop ] ) ;
fprintf ( config , " key_p1_special=%d \n " , keyb_gamekeys . keycode [ BCPK_special ] ) ;
fprintf ( config , " key_p1_special=%d \n " , keyb_gamekeys . keycode [ BCPK_special ] ) ;
fprintf ( config , " key_p2_up=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_up ] ) ;
fprintf ( config , " key_p2_up=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_up ] ) ;
fprintf ( config , " key_p2_down=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_down ] ) ;
fprintf ( config , " key_p2_down=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_down ] ) ;
fprintf ( config , " key_p2_left=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_left ] ) ;
fprintf ( config , " key_p2_left=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_left ] ) ;
fprintf ( config , " key_p2_right=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_right ] ) ;
fprintf ( config , " key_p2_right=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_right ] ) ;
fprintf ( config , " key_p2_bomb=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_drop ] ) ;
fprintf ( config , " key_p2_bomb=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_drop ] ) ;
fprintf ( config , " key_p2_special=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_special ] ) ;
fprintf ( config , " key_p2_special=%d \n " , keyb_gamekeys . keycode [ BCPK_max + BCPK_special ] ) ;
fprintf ( config , " key_help=%d \n " , keyb_gamekeys . keycode [ BCK_help ] ) ;
fprintf ( config , " key_help=%d \n " , keyb_gamekeys . keycode [ BCK_help ] ) ;
fprintf ( config , " key_fullscreen=%d \n " , keyb_gamekeys . keycode [ BCK_fullscreen ] ) ;
fprintf ( config , " key_fullscreen=%d \n " , keyb_gamekeys . keycode [ BCK_fullscreen ] ) ;
fprintf ( config , " key_chat=%d \n " , keyb_gamekeys . keycode [ BCK_chat ] ) ;
fprintf ( config , " key_chat=%d \n " , keyb_gamekeys . keycode [ BCK_chat ] ) ;
fprintf ( config , " key_mapmenu=%d \n " , keyb_gamekeys . keycode [ BCK_mapmenu ] ) ;
fprintf ( config , " key_mapmenu=%d \n " , keyb_gamekeys . keycode [ BCK_mapmenu ] ) ;
fprintf ( config , " key_pause=%d \n " , keyb_gamekeys . keycode [ BCK_pause ] ) ;
fprintf ( config , " key_pause=%d \n " , keyb_gamekeys . keycode [ BCK_pause ] ) ;
fprintf ( config , " key_playermenu=%d \n " , keyb_gamekeys . keycode [ BCK_playermenu ] ) ;
fprintf ( config , " key_playermenu=%d \n " , keyb_gamekeys . keycode [ BCK_playermenu ] ) ;
fclose ( config ) ;
fclose ( config ) ;
return 0 ;
return 0 ;
@ -540,7 +543,7 @@ config_video ()
_charlist * selbpp = NULL ;
_charlist * selbpp = NULL ;
char text [ 100 ] ;
char text [ 100 ] ;
_menu * menu ;
_menu * menu ;
/* set all pointers in this array */
/* set all pointers in this array */
charlist_fillarraypointer ( screenres , 5 ) ;
charlist_fillarraypointer ( screenres , 5 ) ;
@ -576,14 +579,14 @@ config_video ()
gfx . res . y = y ;
gfx . res . y = y ;
gfx_init ( ) ;
gfx_init ( ) ;
draw_logo ( ) ;
draw_logo ( ) ;
break ;
break ;
case ( 2 ) : // new color depth
case ( 2 ) : // new color depth
gfx_shutdown ( ) ;
gfx_shutdown ( ) ;
sscanf ( selbpp - > text , " %d " , & x ) ;
sscanf ( selbpp - > text , " %d " , & x ) ;
gfx . bpp = x ;
gfx . bpp = x ;
gfx_init ( ) ;
gfx_init ( ) ;
draw_logo ( ) ;
draw_logo ( ) ;
break ;
break ;
default :
default :
done = 1 ;
done = 1 ;
break ;
break ;
@ -602,7 +605,7 @@ void
config_menu ( )
config_menu ( )
{
{
int menuselect = 0 ;
int menuselect = 0 ;
_menu * menu ;
_menu * menu ;
while ( menuselect ! = - 1 & & bman . state ! = GS_quit ) {
while ( menuselect ! = - 1 & & bman . state ! = GS_quit ) {
menu = menu_new ( " Configuration " , 400 , 300 ) ;
menu = menu_new ( " Configuration " , 400 , 300 ) ;
@ -634,13 +637,13 @@ config_menu ()
else
else
menuselect = - 1 ;
menuselect = - 1 ;
break ;
break ;
case ( 1 ) : // player screen
case ( 1 ) : // player screen
playernamemenu ( ) ;
playernamemenu ( ) ;
break ;
break ;
case ( 2 ) : // keyboard settings
case ( 2 ) : // keyboard settings
keyb_config ( ) ;
keyb_config ( ) ;
break ;
break ;
case ( 3 ) : // Screen Options
case ( 3 ) : // Screen Options
config_video ( ) ;
config_video ( ) ;
break ;
break ;
}
}
@ -665,18 +668,17 @@ ReadPrgArgs (int argc, char **argv)
printf ( " \n Programm options: \n " ) ;
printf ( " \n Programm options: \n " ) ;
printf ( " -name PLAYERNAME - set the Playername \n " ) ;
printf ( " -name PLAYERNAME - set the Playername \n " ) ;
printf ( " -name2 PLAYERNAME - set the Playername for the second player \n " ) ;
printf ( " -name2 PLAYERNAME - set the Playername for the second player \n " ) ;
printf ( " -gamename GAMENAME - set the name of the game \n " ) ;
printf ( " -gamename GAMENAME - set the name of the game \n " ) ;
printf ( " -port PORT - set the local BomberClone port \n " ) ;
printf ( " -port PORT - set the local BomberClone port \n " ) ;
printf ( " (Def.: 11000) \n " ) ;
printf ( " (Def.: 11000) \n " ) ;
printf ( " -ogcport PORT - set the local OGC Port (Def.: 11100) \n " ) ;
printf ( " -ogcport PORT - set the local OGC Port (Def.: 11100) \n " ) ;
printf ( " -ogc 0/1 - Enable/Disable OGC \n " ) ;
printf ( " -ogc 0/1 - Enable/Disable OGC \n " ) ;
printf ( " -broadcast 0/1 - Enable/Disable broadcast requests. \n " ) ;
printf ( " -broadcast 0/1 - Enable/Disable broadcast requests. \n " ) ;
printf ( " -host - start a network game \n " ) ;
printf ( " -host - start a network game \n " ) ;
printf ( " -join - go into the join menu \n " ) ;
printf ( " -join - go into the join menu \n " ) ;
printf ( " -connect ADDRESS - connect to a server \n " ) ;
printf ( " -connect ADDRESS - connect to a server \n " ) ;
printf ( " -debug 0/1 - enable/disable debug \n " ) ;
printf ( " -debug 0/1 - enable/disable debug \n " ) ;
printf ( " -dedicated - run as dedicated server \n " ) ;
printf ( " -autostart SECONDS - time before a game starts \n " ) ;
printf ( " -autostart SECONDS - time before a game starts \n " ) ;
exit ( 0 ) ;
exit ( 0 ) ;
}
}
if ( ! strcmp ( argv [ i ] , " -port " ) )
if ( ! strcmp ( argv [ i ] , " -port " ) )
@ -686,24 +688,18 @@ ReadPrgArgs (int argc, char **argv)
if ( ! strcmp ( argv [ i ] , " -name " ) )
if ( ! strcmp ( argv [ i ] , " -name " ) )
strncpy ( bman . playername , argv [ + + i ] , LEN_PLAYERNAME ) ;
strncpy ( bman . playername , argv [ + + i ] , LEN_PLAYERNAME ) ;
if ( ! strcmp ( argv [ i ] , " -name2 " ) )
if ( ! strcmp ( argv [ i ] , " -name2 " ) )
strncpy ( bman . player2name , argv [ + + i ] , LEN_PLAYERNAME ) ;
strncpy ( bman . player2name , argv [ + + i ] , LEN_PLAYERNAME ) ;
if ( ! strcmp ( argv [ i ] , " -gamename " ) )
if ( ! strcmp ( argv [ i ] , " -gamename " ) )
strncpy ( bman . gamename , argv [ + + i ] , LEN_GAMENAME ) ;
strncpy ( bman . gamename , argv [ + + i ] , LEN_GAMENAME ) ;
if ( ! strcmp ( argv [ i ] , " -ogc " ) )
if ( ! strcmp ( argv [ i ] , " -ogc " ) )
bman . notifygamemaster = atoi ( argv [ + + i ] ) ;
bman . notifygamemaster = atoi ( argv [ + + i ] ) ;
if ( ! strcmp ( argv [ i ] , " -broadcast " ) )
if ( ! strcmp ( argv [ i ] , " -broadcast " ) )
bman . broadcast = atoi ( argv [ + + i ] ) ;
bman . broadcast = atoi ( argv [ + + i ] ) ;
if ( ! strcmp ( argv [ i ] , " -debug " ) )
if ( ! strcmp ( argv [ i ] , " -debug " ) )
debug = atoi ( argv [ + + i ] ) ;
debug = atoi ( argv [ + + i ] ) ;
if ( ! strcmp ( argv [ i ] , " -dedicated " ) ) {
if ( ! strcmp ( argv [ i ] , " -autostart " ) )
if ( bman . minplayers < = 1 )
bman . autostart = atoi ( argv [ + + i ] ) ;
bman . minplayers = 2 ;
bman . dedicated = 1 ;
printf ( " \n Dedicated Bomberclone Server - Version " VERSION " \n \n " ) ;
}
}
if ( ! strcmp ( argv [ i ] , " -autostart " ) )
bman . autostart = atoi ( argv [ + + i ] ) ;
}
} ;
} ;
@ -715,43 +711,45 @@ ReadPrgArgs_Jump (int argc, char **argv)
int i = 0 ;
int i = 0 ;
while ( argv [ + + i ] ! = NULL ) {
while ( argv [ + + i ] ! = NULL ) {
/* check for commands which will put us into a certain menu */
/* check for commands which will put us into a certain menu */
if ( ! strcmp ( argv [ i ] , " -host " ) ) {
if ( ! strcmp ( argv [ i ] , " -host " ) ) {
host_multiplayer_game ( ) ;
host_multiplayer_game ( ) ;
}
}
else if ( ! strcmp ( argv [ i ] , " -join " ) ) {
else if ( ! strcmp ( argv [ i ] , " -join " ) ) {
join_multiplayer_game ( ) ;
join_multiplayer_game ( ) ;
}
}
else if ( ! strcmp ( argv [ i ] , " -connect " ) ) {
else if ( ! strcmp ( argv [ i ] , " -connect " ) ) {
strncpy ( bman . servername , argv [ + + i ] , LEN_SERVERNAME + LEN_PORT + 2 ) ;
strncpy ( bman . servername , argv [ + + i ] , LEN_SERVERNAME + LEN_PORT + 2 ) ;
join_multiplayer_game ( ) ;
join_multiplayer_game ( ) ;
}
}
}
}
if ( bman . dedicated > 0 )
host_multiplayer_game ( ) ;
} ;
} ;
/* check the version number, return [ 0 =] [-1 <] [ 1 >] */
/* check the version number, return [ 0 =] [-1 <] [ 1 >] */
int check_version ( int ma , int mi , int su , char * ver ) {
int
int v1 , v2 , v3 , res = 0 ;
check_version ( int ma , int mi , int su , char * ver )
{
sscanf ( ver , " %d.%d.%d " , & v1 , & v2 , & v3 ) ;
int v1 ,
if ( v1 < ma )
v2 ,
res = - 1 ;
v3 ,
else if ( v1 > ma )
res = 0 ;
res = 1 ;
else if ( v2 < mi )
sscanf ( ver , " %d.%d.%d " , & v1 , & v2 , & v3 ) ;
res = - 1 ;
if ( v1 < ma )
else if ( v2 > mi )
res = - 1 ;
res = 1 ;
else if ( v1 > ma )
else if ( v3 < su )
res = 1 ;
res = - 1 ;
else if ( v2 < mi )
else if ( v3 > su )
res = - 1 ;
res = 1 ;
else if ( v2 > mi )
res = 1 ;
// d_printf ("version_check (%d.%d.%d, %s = %d\n" , ma, mi, su, ver, res);
else if ( v3 < su )
res = - 1 ;
return res ;
else if ( v3 > su )
res = 1 ;
// d_printf ("version_check (%d.%d.%d, %s = %d\n" , ma, mi, su, ver, res);
return res ;
} ;
} ;