From: Holger Schemel Date: Sat, 26 Apr 2003 18:45:19 +0000 (+0200) Subject: rnd-20030426-2-src X-Git-Tag: 3.0.0^2~80 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=9073d88279c0b9c5be103a6bb4d5c608ab0d90cc;p=rocksndiamonds.git rnd-20030426-2-src --- diff --git a/src/cartoons.c b/src/cartoons.c index b9552504..5bacdf29 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -24,7 +24,7 @@ static struct ToonInfo toons[MAX_NUM_TOONS]; static void PrepareBackbuffer() { /* Fill empty backbuffer for animation functions */ - if (setup.direct_draw && game_status == PLAYING) + if (setup.direct_draw && game_status == GAME_MODE_PLAYING) { int xx,yy; @@ -38,7 +38,7 @@ static void PrepareBackbuffer() SetDrawtoField(DRAW_DIRECT); } - if (setup.soft_scrolling && game_status == PLAYING) + if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING) { int fx = FX, fy = FY; @@ -51,8 +51,8 @@ static void PrepareBackbuffer() boolean ToonNeedsRedraw() { - return (game_status == HELPSCREEN || - (game_status == MAINMENU && + return (game_status == GAME_MODE_INFO || + (game_status == GAME_MODE_MAIN && ((redraw_mask & REDRAW_MICROLEVEL) || (redraw_mask & REDRAW_MICROLABEL)))); } diff --git a/src/conf_gfx.c b/src/conf_gfx.c index ef05d3bf..7b341da3 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -3342,8 +3342,8 @@ struct ConfigInfo image_config[] = { "background.SETUP", UNDEFINED_FILENAME }, { "background.DOOR", UNDEFINED_FILENAME }, - /* the following directives are not associated with an image, - but make sense to be defined in "graphicsinfo.conf", too */ + /* the following directives are not associated with an image, but + probably make sense to be defined in "graphicsinfo.conf", too */ { "global.num_toons", "20" }, @@ -3351,6 +3351,16 @@ struct ConfigInfo image_config[] = { "menu.draw_yoffset", "0" }, { "menu.draw_xoffset.MAIN", "0" }, { "menu.draw_yoffset.MAIN", "0" }, + { "menu.draw_xoffset.LEVELS", "0" }, + { "menu.draw_yoffset.LEVELS", "0" }, + { "menu.draw_xoffset.SCORES", "0" }, + { "menu.draw_yoffset.SCORES", "0" }, + { "menu.draw_xoffset.EDITOR", "0" }, + { "menu.draw_yoffset.EDITOR", "0" }, + { "menu.draw_xoffset.INFO", "0" }, + { "menu.draw_yoffset.INFO", "0" }, + { "menu.draw_xoffset.SETUP", "0" }, + { "menu.draw_yoffset.SETUP", "0" }, { "door.step_offset", "2" }, { "door.step_delay", "10" }, diff --git a/src/conftime.h b/src/conftime.h index f4dfe726..c8aa1774 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-04-26 19:05]" +#define COMPILE_DATE_STRING "[2003-04-26 20:44]" diff --git a/src/editor.c b/src/editor.c index b028364f..7e47789d 100644 --- a/src/editor.c +++ b/src/editor.c @@ -2607,7 +2607,7 @@ void CreateLevelEditorGadgets() int old_game_status = game_status; /* setting 'game_status' is needed to get the right fonts for the editor */ - game_status = LEVELED; + game_status = GAME_MODE_EDITOR; ReinitializeElementList(); @@ -5047,7 +5047,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) TapeStartRecording(); level_editor_test_game = TRUE; - game_status = PLAYING; + game_status = GAME_MODE_PLAYING; InitGame(); } @@ -5205,7 +5205,7 @@ void HandleEditorGadgetInfoText(void *ptr) char shortcut[MAX_OUTPUT_LINESIZE + 1]; int max_infotext_len = getMaxInfoTextLength(); - if (game_status != LEVELED) + if (game_status != GAME_MODE_EDITOR) return; ClearEditorGadgetInfoText(); @@ -5386,7 +5386,7 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed) /* CloseDoor(DOOR_CLOSE_ALL); */ - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } else diff --git a/src/events.c b/src/events.c index 1f78e6b2..3d3cdde0 100644 --- a/src/events.c +++ b/src/events.c @@ -50,7 +50,7 @@ int FilterMouseMotionEvents(const Event *event) cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE && motion->y >= SY && motion->y < SY + SYSIZE); - if (game_status == PLAYING && playfield_cursor_set) + if (game_status == GAME_MODE_PLAYING && playfield_cursor_set) { SetMouseCursor(CURSOR_DEFAULT); playfield_cursor_set = FALSE; @@ -58,7 +58,7 @@ int FilterMouseMotionEvents(const Event *event) } /* skip mouse motion events without pressed button outside level editor */ - if (button_status == MB_RELEASED && game_status != LEVELED) + if (button_status == MB_RELEASED && game_status != GAME_MODE_EDITOR) return 0; else return 1; @@ -116,7 +116,7 @@ void EventLoop(void) else { /* when playing, display a special mouse pointer inside the playfield */ - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { if (!playfield_cursor_set && cursor_inside_playfield && DelayReached(&playfield_cursor_delay, 1000)) @@ -137,7 +137,7 @@ void EventLoop(void) /* don't use all CPU time when idle; the main loop while playing has its own synchronization and is CPU friendly, too */ - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) HandleGameActions(); else { @@ -149,7 +149,7 @@ void EventLoop(void) /* refresh window contents from drawing buffer, if needed */ BackToFront(); - if (game_status == EXITGAME) + if (game_status == GAME_MODE_QUIT) return; } } @@ -266,7 +266,7 @@ void SleepWhileUnmapped() } } - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) KeyboardAutoRepeatOff(); } @@ -296,7 +296,7 @@ void HandleMotionEvent(MotionEvent *event) return; /* window and pointer are on different screens */ #if 1 - if (button_status == MB_RELEASED && game_status != LEVELED) + if (button_status == MB_RELEASED && game_status != GAME_MODE_EDITOR) return; #endif @@ -308,7 +308,7 @@ void HandleMotionEvent(MotionEvent *event) void HandleKeyEvent(KeyEvent *event) { int key_status = (event->type==EVENT_KEYPRESS ? KEY_PRESSED : KEY_RELEASED); - boolean with_modifiers = (game_status == PLAYING ? FALSE : TRUE); + boolean with_modifiers = (game_status == GAME_MODE_PLAYING ? FALSE : TRUE); Key key = GetEventKey(event, with_modifiers); HandleKey(key, key_status); @@ -339,12 +339,12 @@ void HandleFocusEvent(FocusChangeEvent *event) because unfortunately this is a global setting and not (which would be far better) set for each X11 window individually. The effect would be keyboard auto repeat while playing the game - (game_status == PLAYING), which is not desired. + (game_status == GAME_MODE_PLAYING), which is not desired. To avoid this special case, we just wait 1/10 second before processing the 'FocusIn' event. */ - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { Delay(100); KeyboardAutoRepeatOff(); @@ -380,34 +380,34 @@ void HandleButton(int mx, int my, int button) switch(game_status) { - case MAINMENU: + case GAME_MODE_MAIN: HandleMainMenu(mx,my, 0,0, button); break; - case TYPENAME: + case GAME_MODE_PSEUDO_TYPENAME: HandleTypeName(0, KSYM_Return); break; - case CHOOSELEVEL: + case GAME_MODE_LEVELS: HandleChooseLevel(mx,my, 0,0, button); break; - case HALLOFFAME: + case GAME_MODE_SCORES: HandleHallOfFame(0,0, 0,0, button); break; - case LEVELED: + case GAME_MODE_EDITOR: break; - case HELPSCREEN: + case GAME_MODE_INFO: HandleHelpScreen(button); break; - case SETUP: + case GAME_MODE_SETUP: HandleSetupScreen(mx,my, 0,0, button); break; - case PLAYING: + case GAME_MODE_PLAYING: #ifdef DEBUG if (button == MB_RELEASED) { @@ -463,7 +463,7 @@ void HandleKey(Key key, int key_status) { &custom_key.bomb, DEFAULT_KEY_BOMB, JOY_BUTTON_2 } }; - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { /* only needed for single-step tape recording mode */ static boolean clear_button_2[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE }; @@ -545,36 +545,36 @@ void HandleKey(Key key, int key_status) HandleJoystick(); } - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) key_joystick_mapping = 0; if (key_status == KEY_RELEASED) return; if ((key == KSYM_Return || key == setup.shortcut.toggle_pause) && - game_status == PLAYING && AllPlayersGone) + game_status == GAME_MODE_PLAYING && AllPlayersGone) { CloseDoor(DOOR_CLOSE_1); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); return; } /* allow quick escape to the main menu with the Escape key */ if (key == KSYM_Escape && - game_status != MAINMENU && - game_status != PLAYING && - game_status != LEVELED && - game_status != CHOOSELEVEL && - game_status != SETUP) + game_status != GAME_MODE_MAIN && + game_status != GAME_MODE_PLAYING && + game_status != GAME_MODE_EDITOR && + game_status != GAME_MODE_LEVELS && + game_status != GAME_MODE_SETUP) { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); return; } /* special key shortcuts */ - if (game_status == MAINMENU || game_status == PLAYING) + if (game_status == GAME_MODE_MAIN || game_status == GAME_MODE_PLAYING) { if (key == setup.shortcut.save_game) TapeQuickSave(); @@ -587,7 +587,7 @@ void HandleKey(Key key, int key_status) #if 0 #ifndef DEBUG - if (game_status == PLAYING && (tape.playing || tape.pausing)) + if (game_status == GAME_MODE_PLAYING && (tape.playing || tape.pausing)) return; #endif @@ -598,42 +598,42 @@ void HandleKey(Key key, int key_status) switch(game_status) { - case TYPENAME: + case GAME_MODE_PSEUDO_TYPENAME: HandleTypeName(0, key); break; - case MAINMENU: - case CHOOSELEVEL: - case SETUP: + case GAME_MODE_MAIN: + case GAME_MODE_LEVELS: + case GAME_MODE_SETUP: switch(key) { case KSYM_Return: - if (game_status == MAINMENU) + if (game_status == GAME_MODE_MAIN) HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE); - else if (game_status == CHOOSELEVEL) + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 0,0, MB_MENU_CHOICE); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0,0, MB_MENU_CHOICE); break; case KSYM_Escape: - if (game_status == CHOOSELEVEL) + if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 0,0, MB_MENU_LEAVE); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0,0, MB_MENU_LEAVE); break; case KSYM_Page_Up: - if (game_status == CHOOSELEVEL) + if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 0,-SCR_FIELDY, MB_MENU_MARK); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0,-SCR_FIELDY, MB_MENU_MARK); break; case KSYM_Page_Down: - if (game_status == CHOOSELEVEL) + if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0,SCR_FIELDY, MB_MENU_MARK); break; @@ -648,15 +648,15 @@ void HandleKey(Key key, int key_status) } break; - case HELPSCREEN: + case GAME_MODE_INFO: HandleHelpScreen(MB_RELEASED); break; - case HALLOFFAME: + case GAME_MODE_SCORES: switch(key) { case KSYM_Return: - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); BackToFront(); break; @@ -674,12 +674,12 @@ void HandleKey(Key key, int key_status) } break; - case LEVELED: + case GAME_MODE_EDITOR: if (!anyTextGadgetActiveOrJustFinished || key == KSYM_Escape) HandleLevelEditorKeyInput(key); break; - case PLAYING: + case GAME_MODE_PLAYING: { switch(key) { @@ -830,7 +830,7 @@ void HandleKey(Key key, int key_status) void HandleNoEvent() { - if (button_status && game_status != PLAYING) + if (button_status && game_status != GAME_MODE_PLAYING) { HandleButton(0, 0, -button_status); return; @@ -886,9 +886,9 @@ void HandleJoystick() switch(game_status) { - case MAINMENU: - case CHOOSELEVEL: - case SETUP: + case GAME_MODE_MAIN: + case GAME_MODE_LEVELS: + case GAME_MODE_SETUP: { static unsigned long joystickmove_delay = 0; @@ -896,35 +896,35 @@ void HandleJoystick() !DelayReached(&joystickmove_delay, GADGET_FRAME_DELAY)) newbutton = dx = dy = 0; - if (game_status == MAINMENU) + if (game_status == GAME_MODE_MAIN) HandleMainMenu(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); - else if (game_status == CHOOSELEVEL) + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); break; } - case HALLOFFAME: + case GAME_MODE_SCORES: HandleHallOfFame(0,0, dx,dy, !newbutton); break; - case HELPSCREEN: + case GAME_MODE_INFO: HandleHelpScreen(!newbutton); break; - case LEVELED: + case GAME_MODE_EDITOR: HandleLevelEditorIdle(); break; - case PLAYING: + case GAME_MODE_PLAYING: if (tape.playing || keyboard) newbutton = ((joy & JOY_BUTTON) != 0); if (AllPlayersGone && newbutton) { CloseDoor(DOOR_CLOSE_1); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); return; } diff --git a/src/game.c b/src/game.c index 25e13806..436751f6 100644 --- a/src/game.c +++ b/src/game.c @@ -1183,7 +1183,7 @@ void GameWon() if ((hi_pos = NewHiScore()) >= 0) { - game_status = HALLOFFAME; + game_status = GAME_MODE_SCORES; DrawHallOfFame(hi_pos); if (raise_level) { @@ -1193,7 +1193,7 @@ void GameWon() } else { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; if (raise_level) { level_nr++; @@ -4543,7 +4543,7 @@ void GameActions() byte *recorded_player_action; byte summarized_player_action = 0; - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; action_delay_value = @@ -4569,7 +4569,7 @@ void GameActions() HandleNetworking(); #endif - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; if (!network_player_action_received) @@ -6812,7 +6812,7 @@ void RequestQuitGame(boolean ask_if_really_quit) else #endif { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } } @@ -6973,7 +6973,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) { int id = gi->custom_id; - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; switch (id) diff --git a/src/init.c b/src/init.c index 6b6ed64e..d327a93d 100644 --- a/src/init.c +++ b/src/init.c @@ -260,21 +260,11 @@ static int getFontBitmapID(int font_nr) { int special = -1; - if (game_status == MAINMENU || game_status == TYPENAME) + if (game_status >= GAME_MODE_MAIN && game_status <= GAME_MODE_PSEUDO_PREVIEW) + special = game_status; + else if (game_status == GAME_MODE_PSEUDO_TYPENAME) special = GFX_SPECIAL_ARG_MAIN; - else if (game_status == CHOOSELEVEL) - special = GFX_SPECIAL_ARG_LEVELS; - else if (game_status == HALLOFFAME) - special = GFX_SPECIAL_ARG_SCORES; - else if (game_status == LEVELED) - special = GFX_SPECIAL_ARG_EDITOR; - else if (game_status == HELPSCREEN) - special = GFX_SPECIAL_ARG_INFO; - else if (game_status == SETUP) - special = GFX_SPECIAL_ARG_SETUP; - else if (game_status == PSEUDO_PREVIEW) - special = GFX_SPECIAL_ARG_PREVIEW; - else if (game_status == PLAYING || game_status == PSEUDO_DOOR) + else if (game_status == GAME_MODE_PLAYING) special = GFX_SPECIAL_ARG_DOOR; if (special != -1) @@ -2578,6 +2568,16 @@ static void InitArtworkConfig() "menu.draw_yoffset", "menu.draw_xoffset.MAIN", "menu.draw_yoffset.MAIN", + "menu.draw_xoffset.LEVELS", + "menu.draw_yoffset.LEVELS", + "menu.draw_xoffset.SCORES", + "menu.draw_yoffset.SCORES", + "menu.draw_xoffset.EDITOR", + "menu.draw_yoffset.EDITOR", + "menu.draw_xoffset.INFO", + "menu.draw_yoffset.INFO", + "menu.draw_xoffset.SETUP", + "menu.draw_yoffset.SETUP", "door.step_offset", "door.step_delay", NULL @@ -2973,7 +2973,7 @@ void OpenAll() return; } - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 8be4c7a8..47bc9b47 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1125,11 +1125,19 @@ static unsigned int get_hash_from_key(void *key) /* djb2 - this algorithm (k=33) was first reported by dan bernstein many years ago in - comp.lang.c. another version of this algorithm (now favored by bernstein) - uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why + This algorithm (k=33) was first reported by Dan Bernstein many years ago in + 'comp.lang.c'. Another version of this algorithm (now favored by Bernstein) + uses XOR: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why it works better than many other constants, prime or not) has never been adequately explained. + + If you just want to have a good hash function, and cannot wait, djb2 + is one of the best string hash functions i know. It has excellent + distribution and speed on many different sets of keys and table sizes. + You are not likely to do better with one of the "well known" functions + such as PJW, K&R, etc. + + Ozan (oz) Yigit [http://www.cs.yorku.ca/~oz/hash.html] */ char *str = (char *)key; @@ -1190,26 +1198,6 @@ void setHashEntry(SetupFileHash *hash, char *token, char *value) #ifdef DEBUG static void printSetupFileHash(SetupFileHash *hash) { -#if 0 - if (hash == NULL) - return; - - /* iterator constructor only returns valid iterator for non-empty hash */ - if (hash != NULL && hashtable_count(hash) > 0) - { - struct hashtable_itr *itr = hashtable_iterator(hash); - - do - { - printf("token: '%s'\n", (char *)hashtable_iterator_key(itr)); - printf("value: '%s'\n", (char *)hashtable_iterator_value(itr)); - } - while (hashtable_iterator_advance(itr)); - - free(itr); - } -#endif - BEGIN_HASH_ITERATION(hash, itr) { printf("token: '%s'\n", HASH_ITERATION_TOKEN(itr)); diff --git a/src/main.c b/src/main.c index 7fd87aee..a3f25094 100644 --- a/src/main.c +++ b/src/main.c @@ -2988,14 +2988,14 @@ struct ElementDirectionInfo element_direction_info[NUM_DIRECTIONS + 1] = struct SpecialSuffixInfo special_suffix_info[NUM_SPECIAL_GFX_ARGS + 1] = { - { ".MAIN", 0, }, - { ".LEVELS", 0, }, - { ".SCORES", 0, }, - { ".EDITOR", 0, }, - { ".INFO", 0, }, - { ".SETUP", 0, }, - { ".DOOR", 0, }, - { ".PREVIEW", 0, }, + { ".MAIN", GAME_MODE_MAIN, }, + { ".LEVELS", GAME_MODE_LEVELS }, + { ".SCORES", GAME_MODE_SCORES, }, + { ".EDITOR", GAME_MODE_EDITOR, }, + { ".INFO", GAME_MODE_INFO, }, + { ".SETUP", GAME_MODE_SETUP, }, + { ".DOOR", GAME_MODE_PSEUDO_DOOR, }, + { ".PREVIEW", GAME_MODE_PSEUDO_PREVIEW, }, { NULL, 0, } }; diff --git a/src/main.h b/src/main.h index 21232762..bfb6c400 100644 --- a/src/main.h +++ b/src/main.h @@ -791,7 +791,7 @@ #define NUM_ACTIONS 26 -/* values for special image configuration suffixes */ +/* values for special image configuration suffixes (must match game mode) */ #define GFX_SPECIAL_ARG_MAIN 0 #define GFX_SPECIAL_ARG_LEVELS 1 #define GFX_SPECIAL_ARG_SCORES 2 @@ -872,18 +872,20 @@ #define NUM_FONTS 28 #define NUM_INITIAL_FONTS 4 -/* values for game_status */ -#define EXITGAME 0 -#define MAINMENU 1 -#define PLAYING 2 -#define LEVELED 3 -#define HELPSCREEN 4 -#define CHOOSELEVEL 5 -#define TYPENAME 6 -#define HALLOFFAME 7 -#define SETUP 8 -#define PSEUDO_PREVIEW 9 -#define PSEUDO_DOOR 10 +/* values for game_status (must match special image configuration suffixes) */ +#define GAME_MODE_MAIN 0 +#define GAME_MODE_LEVELS 1 +#define GAME_MODE_SCORES 2 +#define GAME_MODE_EDITOR 3 +#define GAME_MODE_INFO 4 +#define GAME_MODE_SETUP 5 +#define GAME_MODE_PSEUDO_DOOR 6 +#define GAME_MODE_PSEUDO_PREVIEW 7 + +/* there are no special config file suffixes for these modes */ +#define GAME_MODE_PLAYING 8 +#define GAME_MODE_PSEUDO_TYPENAME 9 +#define GAME_MODE_QUIT 10 #define PROGRAM_VERSION_MAJOR 2 #define PROGRAM_VERSION_MINOR 2 diff --git a/src/network.c b/src/network.c index fba7b48c..a2928592 100644 --- a/src/network.c +++ b/src/network.c @@ -455,7 +455,7 @@ static void Handle_OP_START_PLAYING() InitRND(new_random_seed); - game_status = PLAYING; + game_status = GAME_MODE_PLAYING; InitGame(); } @@ -482,7 +482,7 @@ static void Handle_OP_STOP_PLAYING() printf("OP_STOP_PLAYING: %d\n", buffer[0]); Error(ERR_NETWORK_CLIENT, "client %d stops game", buffer[0]); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } diff --git a/src/screens.c b/src/screens.c index 437ab3cb..d02f2cca 100644 --- a/src/screens.c +++ b/src/screens.c @@ -75,9 +75,9 @@ static int setup_mode = SETUP_MODE_MAIN; static int mSX = SX; static int mSY = SY; #else -#define mSX (SX + (game_status == MAINMENU ? global.menu_draw_xoffset_MAIN : \ +#define mSX (SX + (game_status == GAME_MODE_MAIN ? global.menu_draw_xoffset_MAIN : \ global.menu_draw_xoffset)) -#define mSY (SY + (game_status == MAINMENU ? global.menu_draw_yoffset_MAIN : \ +#define mSY (SY + (game_status == GAME_MODE_MAIN ? global.menu_draw_yoffset_MAIN : \ global.menu_draw_yoffset)) #endif @@ -208,7 +208,7 @@ void DrawMainMenu() /* needed if last screen was the playing screen, invoked from level editor */ if (level_editor_test_game) { - game_status = LEVELED; + game_status = GAME_MODE_EDITOR; DrawLevelEd(); return; } @@ -406,14 +406,14 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { if (y == 0) { - game_status = TYPENAME; + game_status = GAME_MODE_PSEUDO_TYPENAME; HandleTypeName(strlen(setup.player_name), 0); } else if (y == 1) { if (leveldir_first) { - game_status = CHOOSELEVEL; + game_status = GAME_MODE_LEVELS; SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); @@ -424,7 +424,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (y == 2) { - game_status = HALLOFFAME; + game_status = GAME_MODE_SCORES; DrawHallOfFame(-1); } else if (y == 3) @@ -432,12 +432,12 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (leveldir_current->readonly && strcmp(setup.player_name, "Artsoft") != 0) Request("This level is read only !", REQ_CONFIRM); - game_status = LEVELED; + game_status = GAME_MODE_EDITOR; DrawLevelEd(); } else if (y == 4) { - game_status = HELPSCREEN; + game_status = GAME_MODE_INFO; DrawHelpScreen(); } else if (y == 5) @@ -451,14 +451,14 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) else #endif { - game_status = PLAYING; + game_status = GAME_MODE_PLAYING; StopAnimation(); InitGame(); } } else if (y == 6) { - game_status = SETUP; + game_status = GAME_MODE_SETUP; setup_mode = SETUP_MODE_MAIN; DrawSetupScreen(); } @@ -467,7 +467,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED)) - game_status = EXITGAME; + game_status = GAME_MODE_QUIT; } } } @@ -476,7 +476,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) out: - if (game_status == MAINMENU) + if (game_status == GAME_MODE_MAIN) { DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE); DoAnimation(); @@ -1101,7 +1101,7 @@ void HandleHelpScreen(int button) { FadeSounds(); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } } @@ -1177,7 +1177,7 @@ void HandleTypeName(int newxpos, Key key) DrawText(startx + xpos * font_width, starty, " ", FONT_INPUT_1_ACTIVE); SaveSetup(); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; } BackToFront(); @@ -1235,7 +1235,8 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, DrawText(SX + offset, SY + offset, title_string, FONT_TITLE_1); - game_status = CHOOSELEVEL; /* force LEVELS font on artwork setup screen */ + /* force LEVELS font on artwork setup screen */ + game_status = GAME_MODE_LEVELS; for(i=0; inode_parent; DrawChooseTree(ti_ptr); } - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) { execSetupArtwork(); } else { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } @@ -1489,13 +1490,13 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, TapeErase(); } - if (game_status == SETUP) + if (game_status == GAME_MODE_SETUP) { execSetupArtwork(); } else { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } } @@ -1504,7 +1505,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, BackToFront(); - if (game_status == CHOOSELEVEL || game_status == SETUP) + if (game_status == GAME_MODE_LEVELS || game_status == GAME_MODE_SETUP) DoAnimation(); } @@ -1619,13 +1620,13 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) if (button_released) { FadeSound(SND_BACKGROUND_SCORES); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } BackToFront(); - if (game_status == HALLOFFAME) + if (game_status == GAME_MODE_SCORES) { DoAnimation(); #if 1 @@ -1726,7 +1727,7 @@ static void execSetupShortcut() static void execExitSetup() { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } @@ -2126,7 +2127,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) BackToFront(); - if (game_status == SETUP) + if (game_status == GAME_MODE_SETUP) DoAnimation(); } @@ -2372,7 +2373,7 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) out: - if (game_status == SETUP) + if (game_status == GAME_MODE_SETUP) DoAnimation(); } @@ -2736,7 +2737,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) void HandleGameActions() { - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; if (local_player->LevelSolved) @@ -3009,29 +3010,29 @@ static void HandleScreenGadgets(struct GadgetInfo *gi) { int id = gi->custom_id; - if (game_status != CHOOSELEVEL && game_status != SETUP) + if (game_status != GAME_MODE_LEVELS && game_status != GAME_MODE_SETUP) return; switch (id) { case SCREEN_CTRL_ID_SCROLL_UP: - if (game_status == CHOOSELEVEL) + if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(SX,SY + 32, 0,0, MB_MENU_MARK); break; case SCREEN_CTRL_ID_SCROLL_DOWN: - if (game_status == CHOOSELEVEL) + if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK); break; case SCREEN_CTRL_ID_SCROLL_VERTICAL: - if (game_status == CHOOSELEVEL) + if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE); break; diff --git a/src/tape.c b/src/tape.c index 69ed9f93..85fd2903 100644 --- a/src/tape.c +++ b/src/tape.c @@ -366,7 +366,7 @@ static void TapeStartGameRecording() else #endif { - game_status = PLAYING; + game_status = GAME_MODE_PLAYING; StopAnimation(); InitGame(); } @@ -511,7 +511,7 @@ static void TapeStartGamePlaying() { TapeStartPlaying(); - game_status = PLAYING; + game_status = GAME_MODE_PLAYING; StopAnimation(); InitGame(); } @@ -646,7 +646,7 @@ static void TapeSingleStep() void TapeQuickSave() { - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { if (tape.recording) TapeHaltRecording(); /* prepare tape for saving on-the-fly */ @@ -656,13 +656,13 @@ void TapeQuickSave() else SaveTape(tape.level_nr); } - else if (game_status == MAINMENU) + else if (game_status == GAME_MODE_MAIN) Request("No game that can be saved !", REQ_CONFIRM); } void TapeQuickLoad() { - if (game_status == PLAYING || game_status == MAINMENU) + if (game_status == GAME_MODE_PLAYING || game_status == GAME_MODE_MAIN) { TapeStop(); TapeErase(); @@ -943,7 +943,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi) { int id = gi->custom_id; - if (game_status != MAINMENU && game_status != PLAYING) + if (game_status != GAME_MODE_MAIN && game_status != GAME_MODE_PLAYING) return; switch (id) diff --git a/src/tools.c b/src/tools.c index 0c7bf17b..89de2f61 100644 --- a/src/tools.c +++ b/src/tools.c @@ -70,7 +70,7 @@ void SetDrawtoField(int mode) void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height) { - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { if (force_redraw) { @@ -118,7 +118,7 @@ void BackToFront() int x,y; DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field); - if (setup.direct_draw && game_status == PLAYING) + if (setup.direct_draw && game_status == GAME_MODE_PLAYING) redraw_mask &= ~REDRAW_MAIN; if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD) @@ -130,7 +130,7 @@ void BackToFront() if (redraw_mask == REDRAW_NONE) return; - if (global.fps_slowdown && game_status == PLAYING) + if (global.fps_slowdown && game_status == GAME_MODE_PLAYING) { static boolean last_frame_skipped = FALSE; boolean skip_even_when_not_scrolling = TRUE; @@ -175,7 +175,8 @@ void BackToFront() if (redraw_mask & REDRAW_FIELD) { - if (game_status != PLAYING || redraw_mask & REDRAW_FROM_BACKBUFFER) + if (game_status != GAME_MODE_PLAYING || + redraw_mask & REDRAW_FROM_BACKBUFFER) { BlitBitmap(backbuffer, window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, REAL_SX, REAL_SY); @@ -388,7 +389,7 @@ void ClearWindow() { DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); - if (setup.soft_scrolling && game_status == PLAYING) + if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING) { ClearRectangle(fieldbuffer, 0, 0, FXSIZE, FYSIZE); SetDrawtoField(DRAW_BUFFERED); @@ -396,7 +397,7 @@ void ClearWindow() else SetDrawtoField(DRAW_BACKBUFFER); - if (setup.direct_draw && game_status == PLAYING) + if (setup.direct_draw && game_status == GAME_MODE_PLAYING) { ClearRectangle(window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); SetDrawtoField(DRAW_DIRECT); @@ -1588,7 +1589,8 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) static int label_state, label_counter; int last_game_status = game_status; /* save current game status */ - game_status = PSEUDO_PREVIEW; /* force PREVIEW font on preview level */ + /* force PREVIEW font on preview level */ + game_status = GAME_MODE_PSEUDO_PREVIEW; if (restart) { @@ -1711,7 +1713,7 @@ boolean Request(char *text, unsigned int req_state) #if defined(PLATFORM_UNIX) /* pause network game while waiting for request to answer */ if (options.network && - game_status == PLAYING && + game_status == GAME_MODE_PLAYING && req_state & REQUEST_WAIT_FOR) SendToServer_PausePlaying(); #endif @@ -1732,7 +1734,8 @@ boolean Request(char *text, unsigned int req_state) /* clear door drawing field */ DrawBackground(DX, DY, DXSIZE, DYSIZE); - game_status = PSEUDO_DOOR; /* force DOOR font on preview level */ + /* force DOOR font on preview level */ + game_status = GAME_MODE_PSEUDO_DOOR; /* write text for request */ for(ty=0; ty < MAX_REQUEST_LINES; ty++) @@ -1804,7 +1807,7 @@ boolean Request(char *text, unsigned int req_state) return FALSE; } - if (game_status != MAINMENU) + if (game_status != GAME_MODE_MAIN) InitAnimation(); button_status = MB_RELEASED; @@ -1928,7 +1931,7 @@ boolean Request(char *text, unsigned int req_state) Delay(10); } - if (game_status != MAINMENU) + if (game_status != GAME_MODE_MAIN) StopAnimation(); UnmapToolButtons(); @@ -1953,7 +1956,7 @@ boolean Request(char *text, unsigned int req_state) #if defined(PLATFORM_UNIX) /* continue network game after request */ if (options.network && - game_status == PLAYING && + game_status == GAME_MODE_PLAYING && req_state & REQUEST_WAIT_FOR) SendToServer_ContinuePlaying(); #endif @@ -2146,7 +2149,7 @@ unsigned int MoveDoor(unsigned int door_state) BackToFront(); - if (game_status == MAINMENU) + if (game_status == GAME_MODE_MAIN) DoAnimation(); } }