From: Holger Schemel Date: Sat, 17 Oct 1998 10:26:59 +0000 (+0200) Subject: rnd-19981017-1 X-Git-Tag: 1.2.0^2~54 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=e5c5bf5c4a76a04f9bf64e92227bf2ef969fd25c rnd-19981017-1 --- diff --git a/src/buttons.c b/src/buttons.c index d80dd860..de63c630 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -535,7 +535,7 @@ int CheckVideoButtons(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; static int video_button[5] = { VIDEO_PRESS_EJECT_ON, @@ -595,12 +595,12 @@ int CheckSoundButtons(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; int sound_state[3]; - sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * sound_music_on); - sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * sound_loops_on); - sound_state[2] = BUTTON_SOUND_SIMPLE | (BUTTON_ON * sound_simple_on); + sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music_on); + sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops_on); + sound_state[2] = BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple_on); if (button) { @@ -652,7 +652,7 @@ int CheckGameButtons(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; int game_state[3] = { BUTTON_GAME_STOP, @@ -710,7 +710,7 @@ int CheckYesNoButtons(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; static int yesno_button[5] = { BUTTON_OK, @@ -767,7 +767,7 @@ int CheckConfirmButton(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; if (button) { @@ -818,7 +818,7 @@ int CheckPlayerButtons(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; int player_state[4] = { BUTTON_PLAYER_1, @@ -879,7 +879,7 @@ int CheckEditButtons(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; static int edit_button[6] = { ED_BUTTON_CTRL, @@ -949,7 +949,7 @@ int CheckCtrlButtons(int mx, int my, int button) { int return_code = 0; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; static int ctrl_button[4] = { ED_BUTTON_EDIT, @@ -1008,7 +1008,7 @@ int CheckElemButtons(int mx, int my, int button) { int return_code = -1; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; if (button) { @@ -1069,7 +1069,7 @@ int CheckCountButtons(int mx, int my, int button) { int return_code = -1; static int choice = -1; - static BOOL pressed = FALSE; + static boolean pressed = FALSE; if (button) { diff --git a/src/cartoons.c b/src/cartoons.c index 9eef8e1e..6b145d6d 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -17,7 +17,7 @@ #include "tools.h" static void HandleAnimation(int); -static BOOL AnimateToon(int, BOOL); +static boolean AnimateToon(int, boolean); static void DrawAnim(Pixmap, GC, int, int, int, int, int, int, int, int); struct AnimInfo @@ -27,7 +27,7 @@ struct AnimInfo int frames; int frames_per_second; int stepsize; - BOOL pingpong; + boolean pingpong; int direction; int position; }; @@ -109,12 +109,12 @@ void HandleAnimation(int mode) { static long animstart_delay = -1; static long animstart_delay_value = 0; - static BOOL anim_restart = TRUE; - static BOOL reset_delay = TRUE; + static boolean anim_restart = TRUE; + static boolean reset_delay = TRUE; static int toon_nr = 0; int draw_mode; - if (!toons_on) + if (!setup.toons_on) return; switch(mode) @@ -124,7 +124,7 @@ void HandleAnimation(int mode) reset_delay = TRUE; /* Fill empty backbuffer for animation functions */ - if (direct_draw_on && game_status == PLAYING) + if (setup.direct_draw_on && game_status == PLAYING) { int xx,yy; @@ -138,7 +138,7 @@ void HandleAnimation(int mode) SetDrawtoField(DRAW_DIRECT); } - if (soft_scrolling_on && game_status == PLAYING) + if (setup.soft_scrolling_on && game_status == PLAYING) { int fx = FX, fy = FY; @@ -158,12 +158,12 @@ void HandleAnimation(int mode) redraw_mask |= (REDRAW_FIELD | REDRAW_FROM_BACKBUFFER); /* Redraw background even when in direct drawing mode */ - draw_mode = direct_draw_on; - direct_draw_on = FALSE; + draw_mode = setup.direct_draw_on; + setup.direct_draw_on = FALSE; BackToFront(); - direct_draw_on = draw_mode; + setup.direct_draw_on = draw_mode; return; break; @@ -189,12 +189,12 @@ void HandleAnimation(int mode) anim_restart = reset_delay = AnimateToon(toon_nr,anim_restart); } -BOOL AnimateToon(int toon_nr, BOOL restart) +boolean AnimateToon(int toon_nr, boolean restart) { static pos_x = 0, pos_y = 0; static delta_x = 0, delta_y = 0; static int frame = 0, frame_step = 1; - static BOOL horiz_move, vert_move; + static boolean horiz_move, vert_move; static long anim_delay = 0; static int anim_delay_value = 0; static int width,height; diff --git a/src/editor.c b/src/editor.c index 6ec17e91..c17a4967 100644 --- a/src/editor.c +++ b/src/editor.c @@ -21,8 +21,8 @@ #define CHOICE_DELAY_VALUE 100 static int level_xpos,level_ypos; -static BOOL edit_mode; -static BOOL name_typing; +static boolean edit_mode; +static boolean name_typing; static int new_element1 = EL_MAUERWERK; static int new_element2 = EL_LEERRAUM; static int new_element3 = EL_ERDREICH; @@ -638,7 +638,7 @@ void LevelEd(int mx, int my, int button) { static int last_button = 0; static int in_field_pressed = FALSE; - static BOOL use_floodfill = FALSE; + static boolean use_floodfill = FALSE; int x = (mx-SX)/MINI_TILEX; int y = (my-SY)/MINI_TILEY; diff --git a/src/events.c b/src/events.c index 088650b1..d4ec4802 100644 --- a/src/events.c +++ b/src/events.c @@ -136,7 +136,7 @@ void ClearEventQueue() void SleepWhileUnmapped() { - BOOL window_unmapped = TRUE; + boolean window_unmapped = TRUE; XAutoRepeatOn(display); @@ -177,7 +177,7 @@ void HandleExposeEvent(XExposeEvent *event) int x = event->x, y = event->y; int width = event->width, height = event->height; - if (direct_draw_on && game_status==PLAYING) + if (setup.direct_draw_on && game_status==PLAYING) { int xx,yy; int x1 = (x-SX)/TILEX, y1 = (y-SY)/TILEY; @@ -194,7 +194,7 @@ void HandleExposeEvent(XExposeEvent *event) SetDrawtoField(DRAW_DIRECT); } - if (soft_scrolling_on && game_status == PLAYING) + if (setup.soft_scrolling_on && game_status == PLAYING) { int fx = FX, fy = FY; @@ -672,7 +672,7 @@ void HandleKey(KeySym key, int key_status) } */ - printf("direct_draw_on == %d\n", direct_draw_on); + printf("direct_draw_on == %d\n", setup.direct_draw_on); break; @@ -726,7 +726,7 @@ void HandleNoXEvent() return; } - if (network) + if (options.network) HandleNetworking(); switch(game_status) diff --git a/src/files.c b/src/files.c index 5a290699..e1a4b80c 100644 --- a/src/files.c +++ b/src/files.c @@ -17,7 +17,7 @@ #include "tape.h" #include "joystick.h" -BOOL CreateNewScoreFile() +boolean CreateNewScoreFile() { int i,j,k; char filename[MAX_FILENAME_LEN]; @@ -51,7 +51,7 @@ BOOL CreateNewScoreFile() return(TRUE); } -BOOL CreateNewNamesFile(int mode) +boolean CreateNewNamesFile(int mode) { char filename[MAX_FILENAME_LEN]; FILE *file; @@ -72,7 +72,7 @@ BOOL CreateNewNamesFile(int mode) return(TRUE); } -BOOL LoadLevelInfo() +boolean LoadLevelInfo() { int i; char filename[MAX_FILENAME_LEN]; @@ -214,7 +214,7 @@ void LoadLevelTape(int level_nr) char filename[MAX_FILENAME_LEN]; char cookie[MAX_FILENAME_LEN]; FILE *file; - BOOL levelrec_10 = FALSE; + boolean levelrec_10 = FALSE; #ifndef MSDOS sprintf(filename,"%s/%s/%d.tape", @@ -519,7 +519,7 @@ void SaveLevelTape(int level_nr) int i; char filename[MAX_FILENAME_LEN]; FILE *file; - BOOL new_tape = TRUE; + boolean new_tape = TRUE; #ifndef MSDOS sprintf(filename,"%s/%s/%d.tape", diff --git a/src/files.h b/src/files.h index c0050d36..05107253 100644 --- a/src/files.h +++ b/src/files.h @@ -51,9 +51,9 @@ #define SETUP_SCROLL_DELAY_ON(x) (((x) & SETUP_SCROLL_DELAY) != 0) #define SETUP_SOFT_SCROLL_ON(x) (((x) & SETUP_SOFT_SCROLL) != 0) -BOOL CreateNewScoreFile(void); -BOOL CreateNewNamesFile(int); -BOOL LoadLevelInfo(void); +boolean CreateNewScoreFile(void); +boolean CreateNewNamesFile(int); +boolean LoadLevelInfo(void); void LoadLevel(int); void LoadLevelTape(int); void LoadScore(int); diff --git a/src/game.c b/src/game.c index 7e678bfb..4851f4aa 100644 --- a/src/game.c +++ b/src/game.c @@ -25,7 +25,7 @@ void GetPlayerConfig() { - int old_joystick_nr = joystick_nr; + int old_joystick_nr = setup.joystick_nr; if (sound_status==SOUND_OFF) local_player->setup &= ~SETUP_SOUND; @@ -35,20 +35,20 @@ void GetPlayerConfig() local_player->setup &= ~SETUP_SOUND_MUSIC; } - sound_on = sound_simple_on = SETUP_SOUND_ON(local_player->setup); - sound_loops_on = SETUP_SOUND_LOOPS_ON(local_player->setup); - sound_music_on = SETUP_SOUND_MUSIC_ON(local_player->setup); - toons_on = SETUP_TOONS_ON(local_player->setup); - direct_draw_on = SETUP_DIRECT_DRAW_ON(local_player->setup); - fading_on = SETUP_FADING_ON(local_player->setup); - autorecord_on = SETUP_AUTO_RECORD_ON(local_player->setup); - joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup); - quick_doors = SETUP_QUICK_DOORS_ON(local_player->setup); - scroll_delay_on = SETUP_SCROLL_DELAY_ON(local_player->setup); - soft_scrolling_on = SETUP_SOFT_SCROLL_ON(local_player->setup); + setup.sound_on = setup.sound_simple_on = SETUP_SOUND_ON(local_player->setup); + setup.sound_loops_on = SETUP_SOUND_LOOPS_ON(local_player->setup); + setup.sound_music_on = SETUP_SOUND_MUSIC_ON(local_player->setup); + setup.toons_on = SETUP_TOONS_ON(local_player->setup); + setup.direct_draw_on = SETUP_DIRECT_DRAW_ON(local_player->setup); + setup.fading_on = SETUP_FADING_ON(local_player->setup); + setup.autorecord_on = SETUP_AUTO_RECORD_ON(local_player->setup); + setup.joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup); + setup.quick_doors = SETUP_QUICK_DOORS_ON(local_player->setup); + setup.scroll_delay_on = SETUP_SCROLL_DELAY_ON(local_player->setup); + setup.soft_scrolling_on = SETUP_SOFT_SCROLL_ON(local_player->setup); #ifndef MSDOS - if (joystick_nr != old_joystick_nr) + if (setup.joystick_nr != old_joystick_nr) { if (joystick_device) close(joystick_device); @@ -60,11 +60,11 @@ void GetPlayerConfig() void InitGame() { int i,j, x,y; - BOOL emulate_bd = TRUE; /* unless non-BOULDERDASH elements found */ - BOOL emulate_sb = TRUE; /* unless non-SOKOBAN elements found */ + boolean emulate_bd = TRUE; /* unless non-BOULDERDASH elements found */ + boolean emulate_sb = TRUE; /* unless non-SOKOBAN elements found */ /* don't play tapes over network */ - network_playing = (network && !tape.playing); + network_playing = (options.network && !tape.playing); for(i=0; i 0) { - if (!sound_loops_on) + if (!setup.sound_loops_on) PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); if (TimeLeft && !(TimeLeft % 10)) RaiseScore(level.score[SC_ZEITBONUS]); @@ -534,7 +534,7 @@ void GameWon() Delay(10); } - if (sound_loops_on) + if (setup.sound_loops_on) StopSound(SND_SIRR); } @@ -581,7 +581,7 @@ void GameWon() BackToFront(); } -BOOL NewHiScore() +boolean NewHiScore() { int k,l; int position = -1; @@ -1065,8 +1065,8 @@ void Blurb(int x, int y) void Impact(int x, int y) { - BOOL lastline = (y==lev_fieldy-1); - BOOL object_hit = FALSE; + boolean lastline = (y==lev_fieldy-1); + boolean object_hit = FALSE; int element = Feld[x][y]; int smashed = 0; @@ -1296,7 +1296,7 @@ void TurnRound(int x, int y) } else if (element==EL_MAMPFER) { - BOOL can_turn_left = FALSE, can_turn_right = FALSE; + boolean can_turn_left = FALSE, can_turn_right = FALSE; if (IN_LEV_FIELD(left_x,left_y) && (IS_FREE_OR_PLAYER(left_x,left_y) || @@ -1320,7 +1320,7 @@ void TurnRound(int x, int y) } else if (element==EL_MAMPFER2) { - BOOL can_turn_left = FALSE, can_turn_right = FALSE; + boolean can_turn_left = FALSE, can_turn_right = FALSE; if (IN_LEV_FIELD(left_x,left_y) && (IS_FREE_OR_PLAYER(left_x,left_y) || @@ -1344,7 +1344,7 @@ void TurnRound(int x, int y) } else if (element==EL_PACMAN) { - BOOL can_turn_left = FALSE, can_turn_right = FALSE; + boolean can_turn_left = FALSE, can_turn_right = FALSE; if (IN_LEV_FIELD(left_x,left_y) && (IS_FREE_OR_PLAYER(left_x,left_y) || @@ -1368,9 +1368,9 @@ void TurnRound(int x, int y) } else if (element==EL_SCHWEIN) { - BOOL can_turn_left = FALSE, can_turn_right = FALSE, can_move_on = FALSE; - BOOL should_turn_left = FALSE, should_turn_right = FALSE; - BOOL should_move_on = FALSE; + boolean can_turn_left = FALSE, can_turn_right = FALSE, can_move_on = FALSE; + boolean should_turn_left = FALSE, should_turn_right = FALSE; + boolean should_move_on = FALSE; int rnd_value = 24; int rnd = RND(rnd_value); @@ -1440,7 +1440,7 @@ void TurnRound(int x, int y) } else if (element==EL_DRACHE) { - BOOL can_turn_left = FALSE, can_turn_right = FALSE, can_move_on = FALSE; + boolean can_turn_left = FALSE, can_turn_right = FALSE, can_move_on = FALSE; int rnd_value = 24; int rnd = RND(rnd_value); @@ -1559,7 +1559,7 @@ void TurnRound(int x, int y) if ((MovDir[x][y]&(MV_LEFT|MV_RIGHT)) && (MovDir[x][y]&(MV_UP|MV_DOWN))) { - BOOL first_horiz = RND(2); + boolean first_horiz = RND(2); int new_move_dir = MovDir[x][y]; MovDir[x][y] = @@ -1593,7 +1593,7 @@ void TurnRound(int x, int y) } } -static BOOL JustBeingPushed(int x, int y) +static boolean JustBeingPushed(int x, int y) { int i; @@ -1738,10 +1738,10 @@ void StartMoving(int x, int y) } else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1]) { - BOOL left = (x>0 && IS_FREE(x-1,y) && - (IS_FREE(x-1,y+1) || Feld[x-1][y+1]==EL_SALZSAEURE)); - BOOL right = (x0 && IS_FREE(x-1,y) && + (IS_FREE(x-1,y+1) || Feld[x-1][y+1]==EL_SALZSAEURE)); + boolean right = (xjx, jy = player->jy; int left = player_action & JOY_LEFT; int right = player_action & JOY_RIGHT; @@ -2999,7 +2999,7 @@ void GameActions(byte player_action) { /* int actual_player_action = - (network ? network_player_action[i] : player_action); + (options.network ? network_player_action[i] : player_action); */ int actual_player_action = @@ -3020,7 +3020,7 @@ void GameActions(byte player_action) actual_player_action = 0; */ - if (!network && i != TestPlayer) + if (!options.network && i != TestPlayer) actual_player_action = 0; /* TEST TEST TEST */ @@ -3129,7 +3129,7 @@ void GameActions(byte player_action) if (SiebAktiv) { - BOOL sieb = FALSE; + boolean sieb = FALSE; int jx = local_player->jx, jy = local_player->jy; if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL || @@ -3199,7 +3199,7 @@ void GameActions(byte player_action) DrawAllPlayers(); } -static BOOL AllPlayersInSight(struct PlayerInfo *player, int x, int y) +static boolean AllPlayersInSight(struct PlayerInfo *player, int x, int y) { int min_x = x, min_y = y, max_x = x, max_y = y; int i; @@ -3221,7 +3221,7 @@ static BOOL AllPlayersInSight(struct PlayerInfo *player, int x, int y) return(max_x - min_x < SCR_FIELDX && max_y - min_y < SCR_FIELDY); } -static BOOL AllPlayersInVisibleScreen() +static boolean AllPlayersInVisibleScreen() { int i; @@ -3241,7 +3241,7 @@ static BOOL AllPlayersInVisibleScreen() void ScrollLevel(int dx, int dy) { - int softscroll_offset = (soft_scrolling_on ? TILEX : 0); + int softscroll_offset = (setup.soft_scrolling_on ? TILEX : 0); int x,y; /* @@ -3272,8 +3272,8 @@ void ScrollLevel(int dx, int dy) redraw_mask |= REDRAW_FIELD; } -BOOL MoveFigureOneStep(struct PlayerInfo *player, - int dx, int dy, int real_dx, int real_dy) +boolean MoveFigureOneStep(struct PlayerInfo *player, + int dx, int dy, int real_dx, int real_dy) { int jx = player->jx, jy = player->jy; int new_jx = jx+dx, new_jy = jy+dy; @@ -3291,7 +3291,7 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player, if (!IN_LEV_FIELD(new_jx,new_jy)) return(MF_NO_ACTION); - if (!network && !AllPlayersInSight(player, new_jx,new_jy)) + if (!options.network && !AllPlayersInSight(player, new_jx,new_jy)) return(MF_NO_ACTION); element = MovingOrBlocked2Element(new_jx,new_jy); @@ -3331,7 +3331,7 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player, return(MF_MOVING); } -BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy) +boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) { int jx = player->jx, jy = player->jy; int old_jx = jx, old_jy = jy; @@ -3364,10 +3364,10 @@ BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy) */ if (moved & MF_MOVING && !ScreenMovPos && - (player == local_player || !network)) + (player == local_player || !options.network)) { int old_scroll_x = scroll_x, old_scroll_y = scroll_y; - int offset = (scroll_delay_on ? 3 : 0); + int offset = (setup.scroll_delay_on ? 3 : 0); /* if (player == local_player) @@ -3434,7 +3434,7 @@ BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy) if (scroll_x != old_scroll_x || scroll_y != old_scroll_y) { - if (!network && !AllPlayersInVisibleScreen()) + if (!options.network && !AllPlayersInVisibleScreen()) { scroll_x = old_scroll_x; scroll_y = old_scroll_y; @@ -4045,7 +4045,7 @@ int DigField(struct PlayerInfo *player, return(MF_MOVING); } -BOOL SnapField(struct PlayerInfo *player, int dx, int dy) +boolean SnapField(struct PlayerInfo *player, int dx, int dy) { int jx = player->jx, jy = player->jy; int x = jx + dx, y = jy + dy; @@ -4080,7 +4080,7 @@ BOOL SnapField(struct PlayerInfo *player, int dx, int dy) return(TRUE); } -BOOL PlaceBomb(struct PlayerInfo *player) +boolean PlaceBomb(struct PlayerInfo *player) { int jx = player->jx, jy = player->jy; int element; @@ -4126,8 +4126,8 @@ void PlaySoundLevel(int x, int y, int sound_nr) int volume, stereo; int silence_distance = 8; - if ((!sound_simple_on && !IS_LOOP_SOUND(sound_nr)) || - (!sound_loops_on && IS_LOOP_SOUND(sound_nr))) + if ((!setup.sound_simple_on && !IS_LOOP_SOUND(sound_nr)) || + (!setup.sound_loops_on && IS_LOOP_SOUND(sound_nr))) return; if (!IN_LEV_FIELD(x,y) || diff --git a/src/game.h b/src/game.h index 901254c2..c8684fe7 100644 --- a/src/game.h +++ b/src/game.h @@ -42,7 +42,7 @@ void InitGame(void); void InitMovDir(int, int); void InitAmoebaNr(int, int); void GameWon(void); -BOOL NewHiScore(void); +boolean NewHiScore(void); void InitMovingField(int, int, int); void Moving2Blocked(int, int, int *, int *); void Blocked2Moving(int, int, int *, int *); @@ -77,8 +77,8 @@ void MauerAbleger(int, int); void GameActions(byte); void ScrollLevel(int, int); -BOOL MoveFigureOneStep(struct PlayerInfo *, int, int, int, int); -BOOL MoveFigure(struct PlayerInfo *, int, int); +boolean MoveFigureOneStep(struct PlayerInfo *, int, int, int, int); +boolean MoveFigure(struct PlayerInfo *, int, int); void ScrollFigure(struct PlayerInfo *, int); void ScrollScreen(struct PlayerInfo *, int); @@ -93,8 +93,8 @@ void KillHero(struct PlayerInfo *); void BuryHero(struct PlayerInfo *); void RemoveHero(struct PlayerInfo *); int DigField(struct PlayerInfo *, int, int, int, int, int); -BOOL SnapField(struct PlayerInfo *, int, int); -BOOL PlaceBomb(struct PlayerInfo *); +boolean SnapField(struct PlayerInfo *, int, int); +boolean PlaceBomb(struct PlayerInfo *); void PlaySoundLevel(int, int, int); void RaiseScore(int); void RaiseScoreElement(int); diff --git a/src/init.c b/src/init.c index cbfab54b..ce82c209 100644 --- a/src/init.c +++ b/src/init.c @@ -34,7 +34,7 @@ struct PictureFileInfo { char *picture_filename; - BOOL picture_with_mask; + boolean picture_with_mask; }; struct IconFileInfo @@ -57,9 +57,9 @@ static void InitElementProperties(void); void OpenAll(int argc, char *argv[]) { - if (serveronly) + if (options.serveronly) { - NetworkServer(server_port, serveronly); + NetworkServer(options.server_port, options.serveronly); /* never reached */ exit(0); @@ -94,6 +94,21 @@ void InitLevelAndPlayerInfo() { int i; + /* initialize local player's setup */ + setup.sound_on = TRUE; + setup.sound_loops_on = FALSE; + setup.sound_music_on = FALSE; + setup.sound_simple_on = FALSE; + setup.toons_on = TRUE; + setup.direct_draw_on = FALSE; + setup.scroll_delay_on = FALSE; + setup.soft_scrolling_on = TRUE; + setup.fading_on = FALSE; + setup.autorecord_on = FALSE; + setup.quick_doors = FALSE; + setup.joystick_nr = 0; + + /* choose default local player */ local_player = &stored_player[0]; if (!LoadLevelInfo()) /* global level info */ @@ -102,6 +117,7 @@ void InitLevelAndPlayerInfo() LoadPlayerInfo(PLAYER_SETUP); /* global setup info */ LoadPlayerInfo(PLAYER_LEVEL); /* level specific info */ + /* after LoadPlayerInfo(), because it overwrites 'local_player' */ for (i=0; ialias_name); @@ -157,11 +173,11 @@ void InitSound() #ifdef VOXWARE sound_loops_allowed = TRUE; - sound_loops_on = TRUE; + setup.sound_loops_on = TRUE; #endif #else sound_loops_allowed = TRUE; - sound_loops_on = TRUE; + setup.sound_loops_on = TRUE; #endif for(i=0; iJOYSTICK_PERCENT) result |= JOY_LEFT; diff --git a/src/main.c b/src/main.c index 49478464..48fcc7c7 100644 --- a/src/main.c +++ b/src/main.c @@ -47,52 +47,37 @@ char *level_directory = LEVEL_PATH; int width, height; char *program_name = NULL; -char *display_name = NULL; -char *server_host = NULL; -int server_port = 0; -int serveronly = FALSE; -int network = FALSE; -int verbose = FALSE; int game_status = MAINMENU; int game_emulation = EMU_NONE; -int network_playing = FALSE; -int button_status = MB_NOT_PRESSED, motion_status = FALSE; +boolean network_playing = FALSE; +int button_status = MB_NOT_PRESSED; +boolean motion_status = FALSE; int key_joystick_mapping = 0; int global_joystick_status = JOYSTICK_STATUS; int joystick_status = JOYSTICK_STATUS; -int sound_status = SOUND_STATUS, sound_on = TRUE; -int sound_loops_allowed = FALSE, sound_loops_on = FALSE; -int sound_music_on = FALSE; -int sound_simple_on = FALSE; -int toons_on = TRUE; -int direct_draw_on = FALSE; -int scroll_delay_on = FALSE; -int soft_scrolling_on = TRUE; -int fading_on = FALSE; -int autorecord_on = FALSE; -int joystick_nr = 0; -int quick_doors = FALSE; - -BOOL redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +int sound_status = SOUND_STATUS; +boolean sound_loops_allowed = FALSE; + +boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; int redraw_x1 = 0, redraw_y1 = 0; int redraw_mask; int redraw_tiles; -int Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -int AmoebaCnt[MAX_NUM_AMOEBA], AmoebaCnt2[MAX_NUM_AMOEBA]; -long Elementeigenschaften[MAX_ELEMENTS]; +short Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +boolean Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short AmoebaCnt[MAX_NUM_AMOEBA], AmoebaCnt2[MAX_NUM_AMOEBA]; +unsigned long Elementeigenschaften[MAX_ELEMENTS]; int level_nr, leveldir_nr, num_leveldirs; int lev_fieldx,lev_fieldy, scroll_x,scroll_y; @@ -108,7 +93,7 @@ int FrameCounter, TimeFrames, TimeLeft; int MampferNr, SiebAktiv; byte network_player_action[MAX_PLAYERS]; -BOOL network_player_action_received = FALSE; +boolean network_player_action_received = FALSE; int TestPlayer = 0; struct LevelDirInfo leveldir[MAX_LEVDIR_ENTRIES]; @@ -118,6 +103,8 @@ struct PlayerInfo *local_player; struct HiScore highscore[MAX_SCORE_ENTRIES]; struct SoundInfo Sound[NUM_SOUNDS]; struct RecordingInfo tape; +struct OptionInfo options; +struct SetupInfo setup; struct JoystickInfo joystick[2] = { diff --git a/src/main.h b/src/main.h index 0e967f3d..f1b8671c 100644 --- a/src/main.h +++ b/src/main.h @@ -39,7 +39,7 @@ #include "msdos.h" #endif /* #ifndef MSDOS */ -typedef int BOOL; +typedef unsigned char boolean; typedef unsigned char byte; #ifndef FALSE @@ -207,12 +207,38 @@ struct HiScore int Score; }; +struct OptionInfo +{ + char *display_name; + char *server_host; + int server_port; + boolean serveronly; + boolean network; + boolean verbose; +}; + +struct SetupInfo +{ + boolean sound_on; + boolean sound_loops_on; + boolean sound_music_on; + boolean sound_simple_on; + boolean toons_on; + boolean direct_draw_on; + boolean scroll_delay_on; + boolean soft_scrolling_on; + boolean fading_on; + boolean autorecord_on; + boolean quick_doors; + int joystick_nr; +}; + struct PlayerInfo { - BOOL present; /* player present in level playfield */ - BOOL connected; /* player connected locally or via network */ - BOOL local; /* player connected locally */ - BOOL active; /* player (present && connected) */ + boolean present; /* player present in level playfield */ + boolean connected; /* player connected locally or via network */ + boolean local; /* player connected locally */ + boolean active; /* player (present && connected) */ int index_nr, client_nr, element_nr; @@ -227,9 +253,9 @@ struct PlayerInfo int MovDir, MovPos, GfxPos; int Frame; - BOOL Pushing; - BOOL gone, LevelSolved, GameOver; - BOOL snapped; + boolean Pushing; + boolean gone, LevelSolved, GameOver; + boolean snapped; long move_delay; int last_move_dir; @@ -283,10 +309,10 @@ struct RecordingInfo unsigned long length; unsigned long length_seconds; unsigned int delay_played; - BOOL pause_before_death; - BOOL recording, playing, pausing; - BOOL fast_forward; - BOOL changed; + boolean pause_before_death; + boolean recording, playing, pausing; + boolean fast_forward; + boolean changed; struct { byte action[MAX_PLAYERS]; @@ -324,51 +350,36 @@ extern char *level_directory; extern int width, height; extern char *program_name; -extern char *display_name; -extern char *server_host; -extern int server_port; -extern int serveronly; -extern int network; -extern int verbose; extern int game_status; extern int game_emulation; -extern int network_playing; -extern int button_status, motion_status; +extern boolean network_playing; +extern int button_status; +extern boolean motion_status; extern int key_joystick_mapping; extern int global_joystick_status, joystick_status; -extern int sound_status, sound_on; -extern int sound_loops_allowed, sound_loops_on; -extern int sound_music_on; -extern int sound_simple_on; -extern int toons_on; -extern int direct_draw_on; -extern int scroll_delay_on; -extern int soft_scrolling_on; -extern int fading_on; -extern int autorecord_on; -extern int joystick_nr; -extern int quick_doors; - -extern BOOL redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +extern int sound_status; +extern boolean sound_loops_allowed; + +extern boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; extern int redraw_x1, redraw_y1; extern int redraw_mask; extern int redraw_tiles; -extern int Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern int AmoebaCnt[MAX_NUM_AMOEBA], AmoebaCnt2[MAX_NUM_AMOEBA]; -extern long Elementeigenschaften[MAX_ELEMENTS]; +extern short Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern boolean Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short AmoebaCnt[MAX_NUM_AMOEBA], AmoebaCnt2[MAX_NUM_AMOEBA]; +extern unsigned long Elementeigenschaften[MAX_ELEMENTS]; extern int level_nr, leveldir_nr, num_leveldirs; extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y; @@ -383,7 +394,7 @@ extern int FrameCounter, TimeFrames, TimeLeft; extern int MampferNr, SiebAktiv; extern byte network_player_action[]; -extern BOOL network_player_action_received; +extern boolean network_player_action_received; extern int TestPlayer; extern struct LevelDirInfo leveldir[]; @@ -394,6 +405,8 @@ extern struct HiScore highscore[]; extern struct RecordingInfo tape; extern struct SoundInfo Sound[]; extern struct JoystickInfo joystick[]; +struct OptionInfo options; +struct SetupInfo setup; extern char *sound_name[]; extern int background_loop[]; diff --git a/src/misc.c b/src/misc.c index a482d748..6cbd9655 100644 --- a/src/misc.c +++ b/src/misc.c @@ -84,7 +84,8 @@ void Delay(unsigned long delay) /* Sleep specified number of milliseconds */ sleep_milliseconds(delay); } -BOOL FrameReached(unsigned long *frame_counter_var, unsigned long frame_delay) +boolean FrameReached(unsigned long *frame_counter_var, + unsigned long frame_delay) { unsigned long actual_frame_counter = FrameCounter; @@ -96,7 +97,8 @@ BOOL FrameReached(unsigned long *frame_counter_var, unsigned long frame_delay) return(TRUE); } -BOOL DelayReached(unsigned long *counter_var, unsigned long delay) +boolean DelayReached(unsigned long *counter_var, + unsigned long delay) { unsigned long actual_counter = Counter(); @@ -193,6 +195,14 @@ void GetOptions(char *argv[]) { char **options_left = &argv[1]; + /* initialize global program options */ + options.display_name = NULL; + options.server_host = NULL; + options.server_port = 0; + options.serveronly = FALSE; + options.network = FALSE; + options.verbose = FALSE; + while (*options_left) { char option_str[MAX_OPTION_LEN]; @@ -244,11 +254,11 @@ void GetOptions(char *argv[]) if (option_arg == NULL) Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str); - display_name = option_arg; + options.display_name = option_arg; if (option_arg == next_option) options_left++; - printf("--display == '%s'\n", display_name); + printf("--display == '%s'\n", options.display_name); } else if (strncmp(option, "-levels", option_len) == 0) { @@ -265,35 +275,35 @@ void GetOptions(char *argv[]) { printf("--network\n"); - network = TRUE; + options.network = TRUE; } else if (strncmp(option, "-serveronly", option_len) == 0) { printf("--serveronly\n"); - serveronly = TRUE; + options.serveronly = TRUE; } else if (strncmp(option, "-verbose", option_len) == 0) { printf("--verbose\n"); - verbose = TRUE; + options.verbose = TRUE; } else if (*option == '-') Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str); - else if (server_host == NULL) + else if (options.server_host == NULL) { - server_host = *options_left; + options.server_host = *options_left; - printf("server.name == '%s'\n", server_host); + printf("server.name == '%s'\n", options.server_host); } - else if (server_port == 0) + else if (options.server_port == 0) { - server_port = atoi(*options_left); - if (server_port < 1024) - Error(ERR_EXIT_HELP, "bad port number '%d'", server_port); + options.server_port = atoi(*options_left); + if (options.server_port < 1024) + Error(ERR_EXIT_HELP, "bad port number '%d'", options.server_port); - printf("port == %d\n", server_port); + printf("port == %d\n", options.server_port); } else Error(ERR_EXIT_HELP, "too many arguments"); diff --git a/src/misc.h b/src/misc.h index dff44fb7..0c5ef87f 100644 --- a/src/misc.h +++ b/src/misc.h @@ -29,8 +29,8 @@ void InitCounter(void); unsigned long Counter(void); void Delay(unsigned long); -BOOL FrameReached(unsigned long *, unsigned long); -BOOL DelayReached(unsigned long *, unsigned long); +boolean FrameReached(unsigned long *, unsigned long); +boolean DelayReached(unsigned long *, unsigned long); void WaitUntilDelayReached(unsigned long *, unsigned long); char *int2str(int, int); unsigned int SimpleRND(unsigned int); diff --git a/src/msdos.c b/src/msdos.c index 54502aef..4d2c4329 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -30,14 +30,14 @@ DECLARE_JOYSTICK_DRIVER_LIST(JOYSTICK_DRIVER_STANDARD) static int key_buffer[OSD_MAX_KEY]; static XEvent event_buffer[MAX_EVENT_BUFFER]; static int pending_events; -static BOOL joystick_event; -static BOOL mouse_installed = FALSE; +static boolean joystick_event; +static boolean mouse_installed = FALSE; static int last_mouse_pos; static int last_mouse_b; static int last_joystick_state; static BITMAP* video_bitmap; -BOOL wait_for_vsync; +boolean wait_for_vsync; extern int playing_sounds; extern struct SoundControl playlist[MAX_SOUNDS_PLAYING]; @@ -72,7 +72,8 @@ void allegro_drivers() } -BOOL hide_mouse(Display *display, int x, int y, unsigned int width, unsigned int height) +boolean hide_mouse(Display *display, int x, int y, + unsigned int width, unsigned int height) { if(mouse_x + display->mouse_ptr->w < x || mouse_x > x+width) return FALSE; if(mouse_y + display->mouse_ptr->h < y || mouse_y > y+height) return FALSE; @@ -203,7 +204,7 @@ void XMapWindow(Display* display, Window w) { int x, y; unsigned int width, height; - BOOL mouse_off; + boolean mouse_off; x = display->screens[display->default_screen].x; y = display->screens[display->default_screen].y; @@ -350,7 +351,7 @@ void XFillRectangle( unsigned int width, unsigned int height) { - BOOL mouse_off; + boolean mouse_off; if((BITMAP *) d == video_bitmap) { @@ -395,7 +396,7 @@ inline void XCopyArea( int dest_x, int dest_y) { - BOOL mouse_off; + boolean mouse_off; if((BITMAP *) src == video_bitmap ) { @@ -484,7 +485,7 @@ void XNextEvent(Display* display, XEvent* event_return) int XPending(Display* display) { int i, state; - static BOOL joy_button_2 = FALSE; + static boolean joy_button_2 = FALSE; XKeyEvent *xkey; XButtonEvent *xbutton; diff --git a/src/netserv.c b/src/netserv.c index bafb1fe8..5b32ba04 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -120,7 +120,7 @@ static void dropuser(struct user *u) { struct user *v, *w; - if (verbose) + if (options.verbose) printf("RND_SERVER: dropping client %d (%s)\n", u->number, u->nick); if (u == user0) @@ -170,7 +170,7 @@ static void dropuser(struct user *u) if (onceonly && clients == bots) { - if (verbose) + if (options.verbose) { printf("RND_SERVER: no clients left\n"); printf("RND_SERVER: aborting\n"); @@ -224,7 +224,7 @@ static void new_connect(int fd) } u->number = nxn; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d connecting from %s\n", nxn, inet_ntoa(saddr.sin_addr)); clients++; @@ -238,7 +238,7 @@ static void Handle_OP_PROTOCOL_VERSION(struct user *u, unsigned int len) { if (len != 5 || buf[2] != PROT_VERS_1 || buf[3] != PROT_VERS_2) { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) has wrong protocol version %d.%d.%d\n", u->number, u->nick, buf[2], buf[3], buf[4]); buf[0] = 0; @@ -254,7 +254,7 @@ static void Handle_OP_PROTOCOL_VERSION(struct user *u, unsigned int len) } else { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) uses protocol version %d.%d.%d\n", u->number, u->nick, buf[2], buf[3], buf[4]); } } @@ -266,7 +266,7 @@ static void Handle_OP_NUMBER_WANTED(struct user *u) int nr_wanted = buf[2]; int nr_is_free = 1; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) wants to switch to # %d\n", u->number, u->nick, nr_wanted); @@ -279,7 +279,7 @@ static void Handle_OP_NUMBER_WANTED(struct user *u) } } - if (verbose) + if (options.verbose) { if (nr_is_free) printf("RND_SERVER: client %d (%s) switches to # %d\n", @@ -333,7 +333,7 @@ static void Handle_OP_NICKNAME(struct user *u, unsigned int len) broadcast(u, 2, 0); } - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d calls itself \"%s\"\n", u->number, u->nick); buf[1] = OP_NICKNAME; broadcast(u, len, 0); @@ -376,7 +376,7 @@ static void Handle_OP_START_PLAYING(struct user *u) { struct user *v, *w; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) starts game [level %d from levedir %d (%s)]\n", u->number, u->nick, (buf[2] << 8) + buf[3], @@ -429,7 +429,7 @@ static void Handle_OP_START_PLAYING(struct user *u) static void Handle_OP_PAUSE_PLAYING(struct user *u) { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) pauses game\n", u->number, u->nick); broadcast(NULL, 2, 0); paused = 1; @@ -437,7 +437,7 @@ static void Handle_OP_PAUSE_PLAYING(struct user *u) static void Handle_OP_CONTINUE_PLAYING(struct user *u) { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) continues game\n", u->number, u->nick); broadcast(NULL, 2, 0); paused = 0; @@ -445,7 +445,7 @@ static void Handle_OP_CONTINUE_PLAYING(struct user *u) static void Handle_OP_STOP_PLAYING(struct user *u) { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) stops game\n", u->number, u->nick); broadcast(NULL, 2, 0); } @@ -557,7 +557,7 @@ void NetworkServer(int port, int serveronly) if (is_daemon) { /* become a daemon, breaking all ties with the controlling terminal */ - verbose = 0; + options.verbose = 0; for (i=0; i<255; i++) { if (i != lfd) @@ -577,7 +577,7 @@ void NetworkServer(int port, int serveronly) open("/dev/null", O_WRONLY); } - if (verbose) + if (options.verbose) { printf("rocksndiamonds network server: started up, listening on port %d\n", port); @@ -594,7 +594,7 @@ void NetworkServer(int port, int serveronly) { buf[0] = 0; do_play(); - if (verbose) + if (options.verbose) printf("RND_SERVER: everyone lost... restarting game\n"); timetoplay = 0; } @@ -626,7 +626,7 @@ void NetworkServer(int port, int serveronly) if (clients > 0 && clients == bots) { - if (verbose) + if (options.verbose) printf("RND_SERVER: only bots left... dropping all bots\n"); while (user0) dropuser(user0); @@ -668,7 +668,7 @@ void NetworkServer(int port, int serveronly) r = read(u->fd, u->readbuf + u->nread, MAX_BUFFER_SIZE - u->nread); if (r <= 0) { - if (verbose) + if (options.verbose) printf("RND_SERVER: EOF from client %d (%s)\n", u->number, u->nick); dropuser(u); interrupt = 1; @@ -680,7 +680,7 @@ void NetworkServer(int port, int serveronly) len = u->readbuf[3]; if (u->readbuf[0] || u->readbuf[1] || u->readbuf[2]) { - if (verbose) + if (options.verbose) printf("RND_SERVER: crap from client %d (%s)\n", u->number, u->nick); write(u->fd, "\033]50;kanji24\007\033#8\033(0", 19); dropuser(u); @@ -694,7 +694,7 @@ void NetworkServer(int port, int serveronly) buf[0] = u->number; if (!u->introduced && buf[1] != OP_NICKNAME) { - if (verbose) + if (options.verbose) printf("RND_SERVER: !(client %d)->introduced && buf[1]==%d (expected OP_NICKNAME)\n", buf[0], buf[1]); dropuser(u); @@ -746,7 +746,7 @@ void NetworkServer(int port, int serveronly) { if (v->isbot) { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) kills bot %d (%s)\n", u->number, u->nick, v->number, v->nick); dropuser(v); @@ -755,7 +755,7 @@ void NetworkServer(int port, int serveronly) } else { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) attempting to kill non-bot %d (%s)\n", u->number, u->nick, v->number, v->nick); } } @@ -763,7 +763,7 @@ void NetworkServer(int port, int serveronly) case OP_MODE: mode = buf[2]; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) sets mode %d (%s)\n", u->number, u->nick, buf[2], buf[2] == 0 ? "normal" : (buf[2] == 1 ? "fun" : "unknown")); broadcast(NULL, 3, 0); break; @@ -772,13 +772,13 @@ void NetworkServer(int port, int serveronly) if (!u->isbot) bots++; u->isbot = 1; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) declares itself to be a bot\n", u->number, u->nick); break; case OP_LEVEL: levelnr = buf[2]; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) sets level %d\n", u->number, u->nick, buf[2]); broadcast(NULL, 3, 0); break; @@ -787,7 +787,7 @@ void NetworkServer(int port, int serveronly) { struct user *won = NULL; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) has lost\n", u->number, u->nick); u->playing = 0; broadcast(u, 2, 1); @@ -837,7 +837,7 @@ void NetworkServer(int port, int serveronly) case OP_ZERO: broadcast(NULL, 2, 0); - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) resets the game counters\n", u->number, u->nick); for (v=user0; v; v=v->next) v->games = 0; @@ -850,7 +850,7 @@ void NetworkServer(int port, int serveronly) case OP_MSG: buf[len] = '\0'; - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) sends message: %s\n", u->number, u->nick, &buf[2]); broadcast(u, len, 0); break; @@ -858,7 +858,7 @@ void NetworkServer(int port, int serveronly) case OP_LINES: if (len != 3) { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) sends crap for an OP_LINES\n", u->number, u->nick); dropuser(u); @@ -867,7 +867,7 @@ void NetworkServer(int port, int serveronly) } if (u->nextvictim) { - if (verbose) + if (options.verbose) printf("RND_SERVER: client %d (%s) sends %d %s to client %d (%s)\n", u->number, u->nick, (int)buf[2], buf[2] == 1 ? "line" : "lines", u->nextvictim->number, u->nextvictim->nick); sendtoone(u->nextvictim, 3); buf[3] = u->nextvictim->number; @@ -882,12 +882,12 @@ void NetworkServer(int port, int serveronly) } } } - else if (verbose) + else if (options.verbose) printf("RND_SERVER: client %d (%s) makes %d %s but has no victim\n", u->number, u->nick, (int)buf[2], buf[2] == 1 ? "line" : "lines"); break; default: - if (verbose) + if (options.verbose) printf("RND_SERVER: opcode %d from client %d (%s) not understood\n", buf[0], u->number, u->nick); } } diff --git a/src/network.c b/src/network.c index 28a7d892..092de4d0 100644 --- a/src/network.c +++ b/src/network.c @@ -62,7 +62,7 @@ int nread = 0, nwrite = 0; static void sysmsg(char *s) { - if (verbose) + if (options.verbose) { printf("** %s\n", s); fflush(stdout); @@ -88,7 +88,7 @@ static void flushbuf() static void sendbuf(int len) { - if (network) + if (options.network) { realbuf[0] = realbuf[1] = realbuf[2] = 0; realbuf[3] = (unsigned char)len; @@ -139,7 +139,7 @@ static void StartNetworkServer(int port) switch (fork()) { case 0: - NetworkServer(port, serveronly); + NetworkServer(port, options.serveronly); /* never reached */ exit(0); @@ -147,7 +147,7 @@ static void StartNetworkServer(int port) case -1: Error(ERR_RETURN, "cannot create network server process - no network games"); - network = FALSE; + options.network = FALSE; return; default: @@ -156,7 +156,7 @@ static void StartNetworkServer(int port) } } -BOOL ConnectToServer(char *host, int port) +boolean ConnectToServer(char *host, int port) { struct hostent *hp; struct sockaddr_in s; @@ -498,7 +498,7 @@ static void Handle_OP_START_PLAYING() - if (autorecord_on) + if (setup.autorecord_on) TapeStartRecording(); diff --git a/src/network.h b/src/network.h index 41bbef5b..036b8975 100644 --- a/src/network.h +++ b/src/network.h @@ -16,7 +16,7 @@ #include "main.h" -BOOL ConnectToServer(char *, int); +boolean ConnectToServer(char *, int); void SendToServer_Nickname(char *); void SendToServer_ProtocolVersion(void); void SendToServer_NrWanted(int); diff --git a/src/screens.c b/src/screens.c index f689f1a0..d728c42a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -215,10 +215,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (y==8) { - if (autorecord_on) + if (setup.autorecord_on) TapeStartRecording(); - if (network) + if (options.network) SendToServer_StartPlaying(); else { @@ -1245,12 +1245,12 @@ void CalibrateJoystick() new_joystick_xmiddle = joy_ctrl.x; new_joystick_ymiddle = joy_ctrl.y; - joystick[joystick_nr].xleft = new_joystick_xleft; - joystick[joystick_nr].yupper = new_joystick_yupper; - joystick[joystick_nr].xright = new_joystick_xright; - joystick[joystick_nr].ylower = new_joystick_ylower; - joystick[joystick_nr].xmiddle = new_joystick_xmiddle; - joystick[joystick_nr].ymiddle = new_joystick_ymiddle; + joystick[setup.joystick_nr].xleft = new_joystick_xleft; + joystick[setup.joystick_nr].yupper = new_joystick_yupper; + joystick[setup.joystick_nr].xright = new_joystick_xright; + joystick[setup.joystick_nr].ylower = new_joystick_ylower; + joystick[setup.joystick_nr].xmiddle = new_joystick_xmiddle; + joystick[setup.joystick_nr].ymiddle = new_joystick_ymiddle; CheckJoystickData(); @@ -1359,7 +1359,7 @@ void HandleVideoButtons(int mx, int my, int button) { TapeStartRecording(); - if (network) + if (options.network) SendToServer_StartPlaying(); else { @@ -1432,16 +1432,16 @@ void HandleSoundButtons(int mx, int my, int button) switch(CheckSoundButtons(mx,my,button)) { case BUTTON_SOUND_MUSIC: - if (sound_music_on) + if (setup.sound_music_on) { - sound_music_on = FALSE; + setup.sound_music_on = FALSE; local_player->setup &= ~SETUP_SOUND_MUSIC; FadeSound(background_loop[level_nr % num_bg_loops]); DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF); } else if (sound_loops_allowed) { - sound_on = sound_music_on = TRUE; + setup.sound_on = setup.sound_music_on = TRUE; local_player->setup |= (SETUP_SOUND | SETUP_SOUND_MUSIC); PlaySoundLoop(background_loop[level_nr % num_bg_loops]); DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON); @@ -1451,15 +1451,15 @@ void HandleSoundButtons(int mx, int my, int button) break; case BUTTON_SOUND_LOOPS: - if (sound_loops_on) + if (setup.sound_loops_on) { - sound_loops_on = FALSE; + setup.sound_loops_on = FALSE; local_player->setup &= ~SETUP_SOUND_LOOPS; DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF); } else if (sound_loops_allowed) { - sound_on = sound_loops_on = TRUE; + setup.sound_on = setup.sound_loops_on = TRUE; local_player->setup |= (SETUP_SOUND | SETUP_SOUND_LOOPS); DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON); } @@ -1468,15 +1468,15 @@ void HandleSoundButtons(int mx, int my, int button) break; case BUTTON_SOUND_SIMPLE: - if (sound_simple_on) + if (setup.sound_simple_on) { - sound_simple_on = FALSE; + setup.sound_simple_on = FALSE; local_player->setup &= ~SETUP_SOUND; DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF); } else if (sound_status==SOUND_AVAILABLE) { - sound_on = sound_simple_on = TRUE; + setup.sound_on = setup.sound_simple_on = TRUE; local_player->setup |= SETUP_SOUND; DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON); } @@ -1510,7 +1510,7 @@ void HandleGameButtons(int mx, int my, int button) if (Request("Do you really want to quit the game ?", REQ_ASK | REQ_STAY_CLOSED)) { - if (network) + if (options.network) SendToServer_StopPlaying(); else { @@ -1523,7 +1523,7 @@ void HandleGameButtons(int mx, int my, int button) break; case BUTTON_GAME_PAUSE: - if (network) + if (options.network) { if (tape.pausing) SendToServer_ContinuePlaying(); @@ -1536,7 +1536,7 @@ void HandleGameButtons(int mx, int my, int button) /* if (tape.pausing) { - if (network) + if (options.network) SendToServer_ContinuePlaying(); else { @@ -1546,7 +1546,7 @@ void HandleGameButtons(int mx, int my, int button) } else { - if (network) + if (options.network) SendToServer_PausePlaying(); else { @@ -1561,7 +1561,7 @@ void HandleGameButtons(int mx, int my, int button) case BUTTON_GAME_PLAY: if (tape.pausing) { - if (network) + if (options.network) SendToServer_ContinuePlaying(); else { diff --git a/src/sound.c b/src/sound.c index 1858a8f3..be825edc 100644 --- a/src/sound.c +++ b/src/sound.c @@ -119,7 +119,7 @@ void SoundServer() char *sample_ptr; long sample_size, max_sample_size; long fragment_size; - BOOL stereo; + boolean stereo; if (playing_sounds || (sound_device=open(sound_device_name,O_WRONLY))>=0) { @@ -615,7 +615,7 @@ static unsigned long be2long(unsigned long *be) /* big-endian -> longword */ return(ptr[0]<<24 | ptr[1]<<16 | ptr[2]<<8 | ptr[3]); } -BOOL LoadSound(struct SoundInfo *snd_info) +boolean LoadSound(struct SoundInfo *snd_info) { FILE *file; char filename[256]; @@ -734,11 +734,11 @@ void PlaySoundLoop(int nr) PlaySoundExt(nr, PSND_MAX_VOLUME, PSND_MIDDLE, PSND_LOOP); } -void PlaySoundExt(int nr, int volume, int stereo, BOOL loop) +void PlaySoundExt(int nr, int volume, int stereo, boolean loop) { struct SoundControl snd_ctrl = emptySoundControl; - if (sound_status==SOUND_OFF || !sound_on) + if (sound_status==SOUND_OFF || !setup.sound_on) return; if (volume #ifdef MSDOS -extern BOOL wait_for_vsync; +extern boolean wait_for_vsync; #endif void SetDrawtoField(int mode) { - if (mode == DRAW_BUFFERED && soft_scrolling_on) + if (mode == DRAW_BUFFERED && setup.soft_scrolling_on) { FX = TILEX; FY = TILEY; @@ -66,7 +66,7 @@ void BackToFront() int x,y; Drawable buffer = (drawto_field != window ? drawto_field : backbuffer); - if (direct_draw_on && game_status == PLAYING) + if (setup.direct_draw_on && game_status == PLAYING) redraw_mask &= ~REDRAW_MAIN; if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD) @@ -107,7 +107,7 @@ void BackToFront() { int fx = FX, fy = FY; - if (soft_scrolling_on) + if (setup.soft_scrolling_on) { fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0); fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0); @@ -189,7 +189,7 @@ void FadeToFront() /* long fading_delay = 300; - if (fading_on && (redraw_mask & REDRAW_FIELD)) + if (setup.fading_on && (redraw_mask & REDRAW_FIELD)) { */ @@ -257,7 +257,7 @@ void ClearWindow() XFillRectangle(display,backbuffer,gc, REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); - if (soft_scrolling_on && game_status==PLAYING) + if (setup.soft_scrolling_on && game_status==PLAYING) { XFillRectangle(display,fieldbuffer,gc, 0,0, FXSIZE,FYSIZE); @@ -266,7 +266,7 @@ void ClearWindow() else SetDrawtoField(DRAW_BACKBUFFER); - if (direct_draw_on && game_status==PLAYING) + if (setup.direct_draw_on && game_status==PLAYING) { XFillRectangle(display,window,gc, REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); @@ -410,7 +410,7 @@ void DrawPlayer(struct PlayerInfo *player) if (!IN_SCR_FIELD(sx,sy)) return; - if (direct_draw_on) + if (setup.direct_draw_on) SetDrawtoField(DRAW_BUFFERED); /* draw things behind the player, if needed */ @@ -442,7 +442,7 @@ void DrawPlayer(struct PlayerInfo *player) syy = player->GfxPos; } - if (!soft_scrolling_on && ScreenMovPos) + if (!setup.soft_scrolling_on && ScreenMovPos) sxx = syy = 0; DrawGraphicShiftedThruMask(sx,sy, sxx,syy, graphic, NO_CUTTING); @@ -503,7 +503,7 @@ void DrawPlayer(struct PlayerInfo *player) GFX_EXPLOSION + ((phase-1)/delay-1)); } - if (direct_draw_on) + if (setup.direct_draw_on) { int dest_x = SX + SCREENX(MIN(jx,last_jx))*TILEX; int dest_y = SY + SCREENY(MIN(jy,last_jy))*TILEY; @@ -913,7 +913,7 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, } else if (element==EL_MAUER_LEBT) { - BOOL links_massiv = FALSE, rechts_massiv = FALSE; + boolean links_massiv = FALSE, rechts_massiv = FALSE; if (!IN_LEV_FIELD(ux-1,uy) || IS_MAUER(Feld[ux-1][uy])) links_massiv = TRUE; @@ -1104,7 +1104,7 @@ void DrawScreenField(int x, int y) if (IS_MOVING(ux,uy)) { int horiz_move = (MovDir[ux][uy]==MV_LEFT || MovDir[ux][uy]==MV_RIGHT); - BOOL cut_mode = NO_CUTTING; + boolean cut_mode = NO_CUTTING; if (Store[ux][uy]==EL_MORAST_LEER || Store[ux][uy]==EL_SIEB_LEER || @@ -1134,7 +1134,7 @@ void DrawScreenField(int x, int y) int oldx,oldy; int sx, sy; int horiz_move; - BOOL cut_mode = NO_CUTTING; + boolean cut_mode = NO_CUTTING; Blocked2Moving(ux,uy,&oldx,&oldy); sx = SCREENX(oldx); @@ -1234,7 +1234,7 @@ void DrawLevel() for(y=BY1; y<=BY2; y++) DrawScreenField(x,y); - if (soft_scrolling_on) + if (setup.soft_scrolling_on) XCopyArea(display,fieldbuffer,backbuffer,gc, FX,FY, SXSIZE,SYSIZE, SX,SY); @@ -1303,13 +1303,15 @@ int REQ_in_range(int x, int y) return(0); } -BOOL Request(char *text, unsigned int req_state) +boolean Request(char *text, unsigned int req_state) { int mx,my, ty, result = -1; unsigned int old_door_state; /* pause network game while waiting for request to answer */ - if (network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR) + if (options.network && + game_status == PLAYING && + req_state & REQUEST_WAIT_FOR) SendToServer_PausePlaying(); old_door_state = GetDoorState(); @@ -1511,7 +1513,9 @@ BOOL Request(char *text, unsigned int req_state) } /* continue network game after request */ - if (network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR) + if (options.network && + game_status == PLAYING && + req_state & REQUEST_WAIT_FOR) SendToServer_ContinuePlaying(); return(result); @@ -1573,7 +1577,7 @@ unsigned int MoveDoor(unsigned int door_state) else if (door2==DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2) door_state &= ~DOOR_CLOSE_2; - if (quick_doors) + if (setup.quick_doors) { stepsize = 20; door_delay_value = 0; diff --git a/src/tools.h b/src/tools.h index 40430781..ab49aded 100644 --- a/src/tools.h +++ b/src/tools.h @@ -96,7 +96,7 @@ void DrawMicroElement(int, int, int); void DrawLevel(void); void DrawMiniLevel(int, int); void DrawMicroLevel(int, int); -BOOL Request(char *, unsigned int); +boolean Request(char *, unsigned int); unsigned int OpenDoor(unsigned int); unsigned int CloseDoor(unsigned int); unsigned int GetDoorState(void);