From: Holger Schemel Date: Sun, 20 Nov 2005 01:56:53 +0000 (+0100) Subject: rnd-20051120-1-src X-Git-Tag: 3.1.2^2~52 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c93f939100438a9047653b2c2c6b86f034e1bb01;p=rocksndiamonds.git rnd-20051120-1-src * fixed music initialization bug in init.c (thanks to David Binderman) * fixed mouse wheel "button" bug in editor (thanks to Tomi Belan) (this bug must probably be fixed at other places, too) * fixed buggy '#include "SDL.h"' statements in src/libgame/sdl.h (should be '#include ' instead) --- diff --git a/ChangeLog b/ChangeLog index 61685439..f02adce9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-11-19 + * fixed music initialization bug in init.c (thanks to David Binderman) + * fixed mouse wheel "button" bug in editor (thanks to Tomi Belan) + (this bug must probably be fixed at other places, too) + +2005-10-16 + * fixed buggy '#include "SDL.h"' statements in src/libgame/sdl.h + (should be '#include ' instead) + 2005-08-20 * fixed bug preventing "walkable from no direction" from being ignored (due to compatibility code overwriting this setting after loading) diff --git a/src/conftime.h b/src/conftime.h index f9a04fd0..8b2851d2 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2005-08-20 17:50]" +#define COMPILE_DATE_STRING "[2005-11-20 02:42]" diff --git a/src/editor.c b/src/editor.c index f4b017cc..04409147 100644 --- a/src/editor.c +++ b/src/editor.c @@ -474,11 +474,14 @@ #define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 19) #define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 20) #define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 21) -#define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22) -#define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 23) +#define GADGET_ID_CHANGE_ACTION (GADGET_ID_SELECTBOX_FIRST + 22) +#define GADGET_ID_CHANGE_ACTION_MODE (GADGET_ID_SELECTBOX_FIRST + 23) +#define GADGET_ID_CHANGE_ACTION_ARG (GADGET_ID_SELECTBOX_FIRST + 24) +#define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 25) +#define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 26) /* textbutton identifiers */ -#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 24) +#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 27) #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0) #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1) @@ -553,12 +556,13 @@ #define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 33) #define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 34) #define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 35) -#define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 36) -#define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 37) -#define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 38) +#define GADGET_ID_CHANGE_USE_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 36) +#define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 37) +#define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 38) +#define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 39) /* gadgets for buttons in element list */ -#define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 39) +#define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 40) #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \ ED_NUM_ELEMENTLIST_BUTTONS - 1) @@ -676,10 +680,13 @@ #define ED_SELECTBOX_ID_CHANGE_PLAYER 19 #define ED_SELECTBOX_ID_CHANGE_PAGE 20 #define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 21 -#define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 22 -#define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 23 +#define ED_SELECTBOX_ID_CHANGE_ACTION 22 +#define ED_SELECTBOX_ID_CHANGE_ACTION_MODE 23 +#define ED_SELECTBOX_ID_CHANGE_ACTION_ARG 24 +#define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 25 +#define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 26 -#define ED_NUM_SELECTBOX 24 +#define ED_NUM_SELECTBOX 27 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS #define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE @@ -761,8 +768,9 @@ #define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 34 #define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 35 #define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 36 +#define ED_CHECKBUTTON_ID_CHANGE_USE_ACTION 37 -#define ED_NUM_CHECKBUTTONS 37 +#define ED_NUM_CHECKBUTTONS 38 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_INITIAL_GRAVITY #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED @@ -775,7 +783,7 @@ #define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM2_LAST #define ED_CHECKBUTTON_ID_CHANGE_FIRST ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE -#define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM +#define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_USE_ACTION /* values for radiobutton gadgets */ #define ED_RADIOBUTTON_ID_PERCENTAGE 0 @@ -1526,6 +1534,79 @@ static struct ValueTextInfo options_change_replace_when[] = { -1, NULL } }; +static struct ValueTextInfo options_change_action[] = +{ + { CA_NO_ACTION, "no action" }, + { CA_EXIT_PLAYER, "exit player" }, + { CA_KILL_PLAYER, "kill player" }, + { CA_RESTART_LEVEL, "restart level" }, + { CA_SHOW_ENVELOPE, "show envelope" }, + { CA_ADD_KEY, "add key" }, + { CA_DEL_KEY, "remove key" }, + { CA_SET_PLAYER_SPEED, "set player speed" }, + { CA_SET_GEMS, "set gems" }, + { CA_SET_SCORE, "set score" }, + { CA_SET_TIME, "set time" }, + { CA_SET_COUNTER, "set counter" }, + { CA_SET_DYNABOMB_NUMBER, "set bomb number" }, + { CA_SET_DYNABOMB_SIZE, "set bomb size" }, + { CA_SET_DYNABOMB_POWER, "set bomb power" }, + { CA_TOGGLE_PLAYER_GRAVITY, "toggle gravity" }, + { CA_ENABLE_PLAYER_GRAVITY, "enable gravity" }, + { CA_DISABLE_PLAYER_GRAVITY, "disable gravity" }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_change_action_mode[] = +{ + { CA_MODE_UNDEFINED, " " }, + { CA_MODE_ADD, "+" }, + { CA_MODE_SUBTRACT, "-" }, + { CA_MODE_MULTIPLY, "*" }, + { CA_MODE_DIVIDE, "/" }, + { CA_MODE_SET, "=" }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_change_action_arg[] = +{ + { CA_ARG_PLAYER_HEADLINE, "[players]" }, + { CA_ARG_PLAYER_1, "1" }, + { CA_ARG_PLAYER_2, "2" }, + { CA_ARG_PLAYER_3, "3" }, + { CA_ARG_PLAYER_4, "4" }, + { CA_ARG_PLAYER_ANY, "any" }, + { CA_ARG_PLAYER_TRIGGER, "trigger" }, + { CA_ARG_UNDEFINED, " " }, + { CA_ARG_NUMBER_HEADLINE, "[numbers]" }, + { CA_ARG_0, "0" }, + { CA_ARG_1, "1" }, + { CA_ARG_2, "2" }, + { CA_ARG_3, "3" }, + { CA_ARG_4, "4" }, + { CA_ARG_5, "5" }, + { CA_ARG_6, "6" }, + { CA_ARG_7, "7" }, + { CA_ARG_8, "8" }, + { CA_ARG_9, "9" }, + { CA_ARG_10, "10" }, + { CA_ARG_20, "20" }, + { CA_ARG_25, "25" }, + { CA_ARG_50, "50" }, + { CA_ARG_100, "100" }, + { CA_ARG_1000, "1000" }, + { CA_ARG_UNDEFINED, " " }, + { CA_ARG_NUMBER_MIN, "min" }, + { CA_ARG_NUMBER_MAX, "max" }, + { CA_ARG_NUMBER_NORMAL, "normal" }, + { CA_ARG_NUMBER_RESET, "reset" }, + { CA_ARG_NUMBER_COUNT, "counter" }, + + { -1, NULL } +}; + static char options_change_page_strings[MAX_CHANGE_PAGES][10]; static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] = { @@ -1741,6 +1822,30 @@ static struct &custom_element_change.replace_when, "replace when", NULL, "which elements can be replaced" }, + { + ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(13), + GADGET_ID_CHANGE_ACTION, GADGET_ID_NONE, + -1, + options_change_action, + &custom_element_change.change_action, + NULL, NULL, "action on specified condition" + }, + { + -1, ED_ELEMENT_SETTINGS_YPOS(13), + GADGET_ID_CHANGE_ACTION_MODE, GADGET_ID_CHANGE_ACTION, + -1, + options_change_action_mode, + &custom_element_change.change_action_mode, + NULL, NULL, "action operator" + }, + { + -1, ED_ELEMENT_SETTINGS_YPOS(13), + GADGET_ID_CHANGE_ACTION_ARG, GADGET_ID_CHANGE_ACTION_MODE, + -1, + options_change_action_arg, + &custom_element_change.change_action_arg, + NULL, NULL, "action parameter" + }, { ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(14), GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE, @@ -2213,7 +2318,7 @@ static struct ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(1), GADGET_ID_CUSTOM_CAN_CHANGE, GADGET_ID_NONE, &custom_element_change.can_change, - NULL, "element changes to:", "element can change to other element" + NULL, "element changes to:", "change element on specified condition" }, { ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2), @@ -2257,6 +2362,12 @@ static struct &custom_element_change.use_random_replace, NULL, NULL, "use percentage for random replace" }, + { + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13), + GADGET_ID_CHANGE_USE_ACTION, GADGET_ID_NONE, + &custom_element_change.use_change_action, + NULL, NULL, "execute action on specified condition" + }, }; static struct @@ -2493,6 +2604,7 @@ static int new_element1 = EL_WALL; static int new_element2 = EL_EMPTY; static int new_element3 = EL_SAND; +#define IS_VALID_BUTTON(button) (button >= 1 && button <= 3) #define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \ (button) == 2 ? new_element2 : \ (button) == 3 ? new_element3 : EL_EMPTY) @@ -8454,8 +8566,13 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) if (!started_inside_drawing_area) return; +#if 1 + if (!IS_VALID_BUTTON(button) && !button_release_event) + return; +#else if (!button && !button_release_event) return; +#endif /* automatically switch to 'single item' drawing mode, if needed */ actual_drawing_function = @@ -9024,6 +9141,14 @@ static void HandleControlButtons(struct GadgetInfo *gi) int new_element = BUTTON_ELEMENT(button); int x, y; +#if 0 + /* MAKES PROBLEMS WITH ELEMENT LIST SCROLLBAR AND IS PROBABLY NOT NEEDED */ + /* !!! CHECK WHAT HAPPENS WHEN MOUSE WHEEL IS USED OVER ELEMENT LIST !!! */ + + if (!IS_VALID_BUTTON(button)) + return; +#endif + if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT) DrawLevelText(0, 0, 0, TEXT_END); diff --git a/src/files.c b/src/files.c index e1cd2ed4..d522761c 100644 --- a/src/files.c +++ b/src/files.c @@ -114,6 +114,11 @@ void setElementChangeInfoToDefaults(struct ElementChangeInfo *change) change->random_percentage = 100; change->replace_when = CP_WHEN_EMPTY; + change->use_change_action = FALSE; + change->change_action = CA_NO_ACTION; + change->change_action_mode = CA_MODE_UNDEFINED; + change->change_action_arg = CA_ARG_UNDEFINED; + for (x = 0; x < 3; x++) for (y = 0; y < 3; y++) change->target_content[x][y] = EL_EMPTY_SPACE; @@ -293,6 +298,9 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) element_info[element].explosion_delay = 16; element_info[element].ignition_delay = 8; + element_info[element].counter_initial = 0; + element_info[element].counter = 0; + for (x = 0; x < 3; x++) for (y = 0; y < 3; y++) element_info[element].content[x][y] = EL_EMPTY_SPACE; diff --git a/src/game.c b/src/game.c index 56768b1b..e3007408 100644 --- a/src/game.c +++ b/src/game.c @@ -7859,7 +7859,26 @@ static void ChangeActiveTrap(int x, int y) DrawLevelFieldCrumbledSand(x, y); } -static void ChangeElementNowExt(int x, int y, int target_element) +static void HandleChangeAction(int change_action) +{ + if (change_action == CA_EXIT_PLAYER) + { + printf("::: CA_EXIT_GAME\n"); + + /* !!! local_player <-> 4 players !!! (EXTEND THIS) !!! */ + local_player->LevelSolved = local_player->GameOver = TRUE; + } + else if (change_action == CA_KILL_PLAYER) + { + printf("::: CA_KILL_PLAYER\n"); + + /* !!! local_player <-> 4 players !!! (EXTEND THIS) !!! */ + KillHero(local_player); + } +} + +static void ChangeElementNowExt(struct ElementChangeInfo *change, + int x, int y, int target_element) { int previous_move_direction = MovDir[x][y]; #if 1 @@ -7946,6 +7965,9 @@ static void ChangeElementNowExt(int x, int y, int target_element) TestIfPlayerTouchesCustomElement(x, y); TestIfElementTouchesCustomElement(x, y); #endif + + if (change->use_change_action) + HandleChangeAction(change->change_action); } static boolean ChangeElementNow(int x, int y, int element, int page) @@ -8127,7 +8149,7 @@ static boolean ChangeElementNow(int x, int y, int element, int page) content_element = change->target_content[xx][yy]; target_element = GET_TARGET_ELEMENT(content_element, change); - ChangeElementNowExt(ex, ey, target_element); + ChangeElementNowExt(change, ex, ey, target_element); something_has_changed = TRUE; @@ -8145,7 +8167,7 @@ static boolean ChangeElementNow(int x, int y, int element, int page) { target_element = GET_TARGET_ELEMENT(change->target_element, change); - ChangeElementNowExt(x, y, target_element); + ChangeElementNowExt(change, x, y, target_element); PlayLevelSoundElementAction(x, y, element, ACTION_CHANGING); } diff --git a/src/init.c b/src/init.c index 1f580732..718f4394 100644 --- a/src/init.c +++ b/src/init.c @@ -4415,7 +4415,7 @@ static void InitArtworkConfig() for (i = 0; i < NUM_MUSIC_PREFIXES; i++) music_id_prefix[i] = music_prefix_info[i].prefix; - music_id_prefix[MAX_LEVELS] = NULL; + music_id_prefix[NUM_MUSIC_PREFIXES] = NULL; for (i = 0; i < NUM_ACTIONS; i++) action_id_suffix[i] = element_action_info[i].suffix; diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index fc05cb70..9c8e9b58 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -14,11 +14,11 @@ #ifndef SDL_H #define SDL_H -#include "SDL.h" -#include "SDL_image.h" -#include "SDL_mixer.h" -#include "SDL_net.h" -#include "SDL_thread.h" +#include +#include +#include +#include +#include /* definitions needed for "system.c" */ diff --git a/src/main.h b/src/main.h index f1e41134..10fed0f8 100644 --- a/src/main.h +++ b/src/main.h @@ -259,8 +259,11 @@ #define CH_PLAYER_2 (1 << 1) #define CH_PLAYER_3 (1 << 2) #define CH_PLAYER_4 (1 << 3) -#define CH_PLAYER_ANY (CH_PLAYER_1 | CH_PLAYER_2 | CH_PLAYER_3 | \ +#define CH_PLAYER_ANY (CH_PLAYER_1 | \ + CH_PLAYER_2 | \ + CH_PLAYER_3 | \ CH_PLAYER_4) +#define CH_PLAYER_TRIGGER (1 << 4) /* values for change page for custom elements */ #define CH_PAGE_ANY_FILE (0xff) @@ -274,6 +277,68 @@ #define CP_WHEN_REMOVABLE 4 #define CP_WHEN_WALKABLE 5 +/* values for change actions for custom elements */ +#define CA_NO_ACTION 0 +#define CA_EXIT_PLAYER 1 +#define CA_KILL_PLAYER 2 +#define CA_RESTART_LEVEL 3 +#define CA_SHOW_ENVELOPE 4 +#define CA_ADD_KEY 5 +#define CA_DEL_KEY 6 +#define CA_SET_PLAYER_SPEED 7 +#define CA_SET_GEMS 8 +#define CA_SET_SCORE 9 +#define CA_SET_TIME 10 +#define CA_SET_COUNTER 11 +#define CA_SET_DYNABOMB_NUMBER 12 +#define CA_SET_DYNABOMB_SIZE 13 +#define CA_SET_DYNABOMB_POWER 14 +#define CA_TOGGLE_PLAYER_GRAVITY 15 +#define CA_ENABLE_PLAYER_GRAVITY 16 +#define CA_DISABLE_PLAYER_GRAVITY 17 + +/* values for change action mode for custom elements */ +#define CA_MODE_UNDEFINED 0 +#define CA_MODE_ADD 1 +#define CA_MODE_SUBTRACT 2 +#define CA_MODE_MULTIPLY 3 +#define CA_MODE_DIVIDE 4 +#define CA_MODE_SET 5 + +/* values for change action parameters for custom elements */ +#define CA_ARG_0 0 +#define CA_ARG_1 1 +#define CA_ARG_2 2 +#define CA_ARG_3 3 +#define CA_ARG_4 4 +#define CA_ARG_5 5 +#define CA_ARG_6 6 +#define CA_ARG_7 7 +#define CA_ARG_8 8 +#define CA_ARG_9 9 +#define CA_ARG_10 10 +#define CA_ARG_20 20 +#define CA_ARG_25 25 +#define CA_ARG_50 50 +#define CA_ARG_100 100 +#define CA_ARG_1000 1000 +#define CA_ARG_PLAYER 20000 +#define CA_ARG_PLAYER_HEADLINE (CA_ARG_PLAYER + 0) +#define CA_ARG_PLAYER_1 (CA_ARG_PLAYER + CH_PLAYER_1) +#define CA_ARG_PLAYER_2 (CA_ARG_PLAYER + CH_PLAYER_2) +#define CA_ARG_PLAYER_3 (CA_ARG_PLAYER + CH_PLAYER_3) +#define CA_ARG_PLAYER_4 (CA_ARG_PLAYER + CH_PLAYER_4) +#define CA_ARG_PLAYER_ANY (CA_ARG_PLAYER + CH_PLAYER_ANY) +#define CA_ARG_PLAYER_TRIGGER (CA_ARG_PLAYER + CH_PLAYER_TRIGGER) +#define CA_ARG_NUMBER 30000 +#define CA_ARG_NUMBER_HEADLINE (CA_ARG_NUMBER + 0) +#define CA_ARG_NUMBER_MIN (CA_ARG_NUMBER + 1) +#define CA_ARG_NUMBER_MAX (CA_ARG_NUMBER + 2) +#define CA_ARG_NUMBER_NORMAL (CA_ARG_NUMBER + 3) +#define CA_ARG_NUMBER_RESET (CA_ARG_NUMBER + 4) +#define CA_ARG_NUMBER_COUNT (CA_ARG_NUMBER + 5) +#define CA_ARG_UNDEFINED 30999 + /* values for custom move patterns (bits 0 - 3: basic move directions) */ #define MV_BIT_TOWARDS_PLAYER 4 #define MV_BIT_AWAY_FROM_PLAYER 5 @@ -1829,6 +1894,11 @@ struct ElementChangeInfo boolean explode; /* explode instead of change */ + boolean use_change_action; /* execute change action after change */ + int change_action; /* type of change action after change */ + int change_action_mode; /* mode of change action after change */ + int change_action_arg; /* parameter of change action after change */ + /* ---------- internal values used at runtime when playing ---------- */ /* functions that are called before, while and after the change of an @@ -1930,6 +2000,8 @@ struct ElementInfo int explosion_delay; /* duration of explosion of this element */ int ignition_delay; /* delay for explosion by other explosion */ + int counter_initial; /* initial value of generic CE counter */ + struct ElementChangeInfo *change_page; /* actual list of change pages */ struct ElementChangeInfo *change; /* pointer to current change page */ @@ -1956,6 +2028,8 @@ struct ElementInfo boolean can_leave_element_last; #endif + int counter; /* current value of generic CE counter */ + /* ---------- internal values used in level editor ---------- */ int access_type; /* walkable or passable */