From: Holger Schemel Date: Fri, 16 Dec 2005 04:05:26 +0000 (+0100) Subject: rnd-20051216-1-src X-Git-Tag: 3.1.2^2~24 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e990d1036d8657377f18d8da3dbe446395a26b57;p=rocksndiamonds.git rnd-20051216-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 2b2874ac..d1c14d04 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2005-12-15 01:12]" +#define COMPILE_DATE_STRING "[2005-12-16 05:03]" diff --git a/src/editor.c b/src/editor.c index 79e58746..8341f924 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1570,27 +1570,39 @@ static struct ValueTextInfo options_action_type[] = { 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_TIME, "set time" }, { CA_SET_SCORE, "set score" }, { CA_SET_CE_SCORE, "set CE score" }, { CA_SET_CE_COUNT, "set CE count" }, + { CA_SET_PLAYER_SPEED, "set player speed" }, + { CA_SET_PLAYER_GRAVITY, "set gravity" }, + { CA_SET_WIND_DIRECTION, "set wind dir." }, #if 0 { CA_SET_DYNABOMB_NUMBER, "set bomb number" }, { CA_SET_DYNABOMB_SIZE, "set bomb size" }, { CA_SET_DYNABOMB_POWER, "set bomb power" }, #endif - { CA_TOGGLE_PLAYER_GRAVITY, "toggle gravity" }, - { CA_ENABLE_PLAYER_GRAVITY, "enable gravity" }, - { CA_DISABLE_PLAYER_GRAVITY, "disable gravity" }, { -1, NULL } }; -static struct ValueTextInfo options_action_mode[] = +static struct ValueTextInfo options_action_mode_none[] = +{ + { CA_ARG_UNDEFINED, " " }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_mode_set[] = +{ + { CA_MODE_SET, "=" }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_mode_calc[] = { - { CA_MODE_UNDEFINED, " " }, { CA_MODE_SET, "=" }, { CA_MODE_ADD, "+" }, { CA_MODE_SUBTRACT, "-" }, @@ -1601,7 +1613,14 @@ static struct ValueTextInfo options_action_mode[] = { -1, NULL } }; -static struct ValueTextInfo options_action_arg[] = +static struct ValueTextInfo options_action_arg_none[] = +{ + { CA_ARG_UNDEFINED, " " }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_arg_player[] = { { CA_ARG_PLAYER_HEADLINE, "[player]" }, { CA_ARG_PLAYER_1, "1" }, @@ -1610,7 +1629,12 @@ static struct ValueTextInfo options_action_arg[] = { CA_ARG_PLAYER_4, "4" }, { CA_ARG_PLAYER_ANY, "any" }, { CA_ARG_PLAYER_TRIGGER, "trigger" }, - { CA_ARG_UNDEFINED, " " }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_arg_number[] = +{ { CA_ARG_NUMBER_HEADLINE, "[number]" }, { CA_ARG_0, "0" }, { CA_ARG_1, "1" }, @@ -1624,15 +1648,72 @@ static struct ValueTextInfo options_action_arg[] = { CA_ARG_UNDEFINED, " " }, { CA_ARG_NUMBER_MIN, "min" }, { CA_ARG_NUMBER_MAX, "max" }, - { CA_ARG_NUMBER_NORMAL, "normal" }, + { CA_ARG_UNDEFINED, " " }, { CA_ARG_NUMBER_RESET, "reset" }, + { CA_ARG_UNDEFINED, " " }, { CA_ARG_NUMBER_CE_SCORE, "CE score" }, { CA_ARG_NUMBER_CE_COUNT, "CE count" }, { CA_ARG_NUMBER_CE_DELAY, "CE delay" }, - { CA_ARG_UNDEFINED, " " }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_arg_element[] = +{ { CA_ARG_ELEMENT_HEADLINE, "[element]" }, { CA_ARG_ELEMENT_TARGET, "target" }, { CA_ARG_ELEMENT_TRIGGER, "trigger" }, + { CA_ARG_UNDEFINED, " " }, + { CA_ARG_NUMBER_HEADLINE, "[number]" }, + { 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" }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_arg_speed[] = +{ + { CA_ARG_SPEED_HEADLINE, "[speed]" }, + { CA_ARG_SPEED_VERY_SLOW, "very slow" }, + { CA_ARG_SPEED_SLOW, "slow" }, + { CA_ARG_SPEED_NORMAL, "normal" }, + { CA_ARG_SPEED_FAST, "fast" }, + { CA_ARG_SPEED_VERY_FAST, "very fast" }, + { CA_ARG_SPEED_EVEN_FASTER, "ultrafast" }, + { CA_ARG_UNDEFINED, " " }, + { CA_ARG_SPEED_SLOWER, "slower" }, + { CA_ARG_SPEED_FASTER, "faster" }, + { CA_ARG_UNDEFINED, " " }, + { CA_ARG_SPEED_RESET, "reset" }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_arg_gravity[] = +{ + { CA_ARG_GRAVITY_HEADLINE, "[gravity]" }, + { CA_ARG_GRAVITY_ON, "on" }, + { CA_ARG_GRAVITY_OFF, "off" }, + { CA_ARG_GRAVITY_TOGGLE, "toggle" }, + + { -1, NULL } +}; + +static struct ValueTextInfo options_action_arg_direction[] = +{ + { CA_ARG_DIRECTION_HEADLINE, "[dir.]" }, + { CA_ARG_DIRECTION_NONE, "none" }, + { CA_ARG_DIRECTION_LEFT, "left" }, + { CA_ARG_DIRECTION_RIGHT, "right" }, + { CA_ARG_DIRECTION_UP, "up" }, + { CA_ARG_DIRECTION_DOWN, "down" }, + { CA_ARG_DIRECTION_TRIGGER, "trigger" }, { -1, NULL } }; @@ -1654,6 +1735,40 @@ static struct ValueTextInfo options_group_choice_mode[] = { -1, NULL } }; +static struct ValueTextInfo *action_arg_modes[] = +{ + options_action_mode_none, + options_action_mode_set, + options_action_mode_calc, +}; + +static struct +{ + int value; + int mode; + struct ValueTextInfo *options; +} +action_arg_options[] = +{ + { CA_NO_ACTION, 0, options_action_arg_none, }, + { CA_EXIT_PLAYER, 0, options_action_arg_player, }, + { CA_KILL_PLAYER, 0, options_action_arg_player, }, + { CA_RESTART_LEVEL, 0, options_action_arg_none, }, + { CA_SHOW_ENVELOPE, 0, options_action_arg_element, }, + { CA_ADD_KEY, 0, options_action_arg_element, }, + { CA_DEL_KEY, 0, options_action_arg_element, }, + { CA_SET_PLAYER_SPEED, 1, options_action_arg_speed, }, + { CA_SET_GEMS, 2, options_action_arg_number, }, + { CA_SET_TIME, 2, options_action_arg_number, }, + { CA_SET_SCORE, 2, options_action_arg_number, }, + { CA_SET_CE_SCORE, 2, options_action_arg_number, }, + { CA_SET_CE_COUNT, 2, options_action_arg_number, }, + { CA_SET_PLAYER_GRAVITY, 1, options_action_arg_gravity, }, + { CA_SET_WIND_DIRECTION, 1, options_action_arg_direction, }, + + { -1, FALSE, NULL } +}; + static struct { int x, y; @@ -1874,7 +1989,7 @@ static struct -1, ED_ELEMENT_SETTINGS_YPOS(13), GADGET_ID_ACTION_MODE, GADGET_ID_ACTION_TYPE, -1, - options_action_mode, + options_action_mode_none, &custom_element_change.action_mode, NULL, NULL, "action operator" }, @@ -1882,7 +1997,7 @@ static struct -1, ED_ELEMENT_SETTINGS_YPOS(13), GADGET_ID_ACTION_ARG, GADGET_ID_ACTION_MODE, -1, - options_action_arg, + options_action_arg_none, &custom_element_change.action_arg, NULL, NULL, "action parameter" }, @@ -2632,7 +2747,8 @@ static int new_element3 = EL_SAND; /* forward declaration for internal use */ static void ModifyEditorCounterValue(int, int); static void ModifyEditorCounterLimits(int, int, int); -static void ModifyEditorSelectbox(int, int); +static void ModifyEditorSelectboxValue(int, int); +static void ModifyEditorSelectboxOptions(int, struct ValueTextInfo *); static void ModifyEditorDrawingArea(int, int, int); static void ModifyEditorElementList(); static void RedrawDrawingElements(); @@ -5445,7 +5561,7 @@ static void MapSelectboxGadget(int id) if (selectbox_info[id].text_right) DrawText(x_right, y, selectbox_info[id].text_right, FONT_TEXT_1); - ModifyEditorSelectbox(id, *selectbox_info[id].value); + ModifyEditorSelectboxValue(id, *selectbox_info[id].value); MapGadget(gi); } @@ -6405,7 +6521,7 @@ static void ModifyEditorCounterLimits(int counter_id, int min, int max) ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END); } -static void ModifyEditorSelectbox(int selectbox_id, int new_value) +static void ModifyEditorSelectboxValue(int selectbox_id, int new_value) { int gadget_id = selectbox_info[selectbox_id].gadget_id; struct GadgetInfo *gi = level_editor_gadget[gadget_id]; @@ -6414,6 +6530,19 @@ static void ModifyEditorSelectbox(int selectbox_id, int new_value) ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END); } +static void ModifyEditorSelectboxOptions(int selectbox_id, + struct ValueTextInfo *options) +{ + int gadget_id = selectbox_info[selectbox_id].gadget_id; + struct GadgetInfo *gi = level_editor_gadget[gadget_id]; + + selectbox_info[selectbox_id].options = options; + + /* set index to zero -- list may be shorter now (correct later, if needed) */ + ModifyGadget(gi, GDI_SELECTBOX_INDEX, 0, + GDI_SELECTBOX_OPTIONS, options, GDI_END); +} + static void ModifyEditorDrawingArea(int drawingarea_id, int xsize, int ysize) { int gadget_id = drawingarea_info[drawingarea_id].gadget_id; @@ -7265,6 +7394,24 @@ static void DrawPropertiesChange() { int i; + for (i = 0; action_arg_options[i].value != -1; i++) + { + if (action_arg_options[i].value == custom_element_change.action_type) + { + int mode = action_arg_options[i].mode; + + ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_MODE, + action_arg_modes[mode]); + ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_MODE, + custom_element_change.action_mode); + + ModifyEditorSelectboxOptions(ED_SELECTBOX_ID_ACTION_ARG, + action_arg_options[i].options); + ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG, + custom_element_change.action_arg); + } + } + /* draw stickybutton gadget */ MapCheckbuttonGadget(ED_CHECKBUTTON_ID_STICK_ELEMENT); @@ -8509,9 +8656,9 @@ static void HandleTextAreaGadgets(struct GadgetInfo *gi) static void HandleSelectboxGadgets(struct GadgetInfo *gi) { int type_id = gi->custom_type_id; + int value_new = selectbox_info[type_id].options[gi->selectbox.index].value; - *selectbox_info[type_id].value = - selectbox_info[type_id].options[gi->selectbox.index].value; + *selectbox_info[type_id].value = value_new; if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE) { @@ -8525,6 +8672,9 @@ static void HandleSelectboxGadgets(struct GadgetInfo *gi) type_id <= ED_SELECTBOX_ID_CHANGE_LAST) || (type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE)) { + if (type_id == ED_SELECTBOX_ID_ACTION_TYPE) + DrawPropertiesChange(); + CopyElementPropertiesToGame(properties_element); level.changed = TRUE; diff --git a/src/game.c b/src/game.c index 84de452c..07585bb6 100644 --- a/src/game.c +++ b/src/game.c @@ -1320,6 +1320,7 @@ static void InitGameEngine() { ei->change_page[j].actual_trigger_element = EL_EMPTY; ei->change_page[j].actual_trigger_player = EL_PLAYER_1; + ei->change_page[j].actual_trigger_side = CH_SIDE_NONE; } } @@ -6575,16 +6576,14 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) action_type == CA_SET_CE_COUNT ? ei->collect_count_initial : 0); - int action_arg_number_normal = - (action_type == CA_SET_PLAYER_SPEED ? MOVE_STEPSIZE_NORMAL : - action_arg_number_reset); - int action_arg_number = (action_arg <= CA_ARG_MAX ? action_arg : + action_arg >= CA_ARG_SPEED_VERY_SLOW && + action_arg <= CA_ARG_SPEED_EVEN_FASTER ? (action_arg - CA_ARG_SPEED) : + action_arg == CA_ARG_SPEED_RESET ? action_arg_number_reset : action_arg == CA_ARG_NUMBER_MIN ? action_arg_number_min : action_arg == CA_ARG_NUMBER_MAX ? action_arg_number_max : action_arg == CA_ARG_NUMBER_RESET ? action_arg_number_reset : - action_arg == CA_ARG_NUMBER_NORMAL ? action_arg_number_normal : action_arg == CA_ARG_NUMBER_CE_SCORE ? ei->collect_score : #if USE_NEW_COLLECT_COUNT action_arg == CA_ARG_NUMBER_CE_COUNT ? Count[x][y] : @@ -6715,45 +6714,6 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) break; } - case CA_SET_PLAYER_SPEED: - { - for (i = 0; i < MAX_PLAYERS; i++) - { - if (trigger_player_bits & (1 << i)) - { - int move_stepsize = TILEX / stored_player[i].move_delay_value; - - if (action_mode == CA_MODE_ADD || action_mode == CA_MODE_SUBTRACT) - { - /* translate "+" and "-" to "*" and "/" with powers of two */ - action_arg_number = 1 << action_arg_number; - action_mode = (action_mode == CA_MODE_ADD ? CA_MODE_MULTIPLY : - CA_MODE_DIVIDE); - } - - move_stepsize = - getModifiedActionNumber(move_stepsize, - action_mode, - action_arg_number, - action_arg_number_min, - action_arg_number_max); - - /* make sure that value is power of 2 */ - move_stepsize = (1 << log_2(move_stepsize)); - - /* do no immediately change -- the player might just be moving */ - stored_player[i].move_delay_value_next = TILEX / move_stepsize; - -#if 0 - printf("::: move_delay_value == %d [%d]\n", - stored_player[i].move_delay_value_next, action_arg_number); -#endif - } - } - - break; - } - case CA_SET_GEMS: { local_player->gems_still_needed = action_arg_number_new; @@ -6820,47 +6780,129 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) break; } - case CA_SET_DYNABOMB_NUMBER: +#if 1 + case CA_SET_PLAYER_SPEED: { - printf("::: CA_SET_DYNABOMB_NUMBER -- not yet implemented\n"); + for (i = 0; i < MAX_PLAYERS; i++) + { + if (trigger_player_bits & (1 << i)) + { + int move_stepsize = TILEX / stored_player[i].move_delay_value; + + if (action_arg == CA_ARG_SPEED_SLOWER || + action_arg == CA_ARG_SPEED_FASTER) + { + action_arg_number = 2; + action_mode = (action_arg == CA_ARG_SPEED_SLOWER ? CA_MODE_DIVIDE : + CA_MODE_MULTIPLY); + } + + move_stepsize = + getModifiedActionNumber(move_stepsize, + action_mode, + action_arg_number, + action_arg_number_min, + action_arg_number_max); + + /* make sure that value is power of 2 */ + move_stepsize = (1 << log_2(move_stepsize)); + + /* do no immediately change -- the player might just be moving */ + stored_player[i].move_delay_value_next = TILEX / move_stepsize; + +#if 0 + printf("::: move_delay_value == %d [%d]\n", + stored_player[i].move_delay_value_next, action_arg_number); +#endif + } + } break; } - - case CA_SET_DYNABOMB_SIZE: +#else + case CA_SET_PLAYER_SPEED: { - printf("::: CA_SET_DYNABOMB_SIZE -- not yet implemented\n"); + for (i = 0; i < MAX_PLAYERS; i++) + { + if (trigger_player_bits & (1 << i)) + { + int move_stepsize = TILEX / stored_player[i].move_delay_value; + + if (action_mode == CA_MODE_ADD || action_mode == CA_MODE_SUBTRACT) + { + /* translate "+" and "-" to "*" and "/" with powers of two */ + action_arg_number = 1 << action_arg_number; + action_mode = (action_mode == CA_MODE_ADD ? CA_MODE_MULTIPLY : + CA_MODE_DIVIDE); + } + + move_stepsize = + getModifiedActionNumber(move_stepsize, + action_mode, + action_arg_number, + action_arg_number_min, + action_arg_number_max); + + /* make sure that value is power of 2 */ + move_stepsize = (1 << log_2(move_stepsize)); + + /* do no immediately change -- the player might just be moving */ + stored_player[i].move_delay_value_next = TILEX / move_stepsize; + +#if 0 + printf("::: move_delay_value == %d [%d]\n", + stored_player[i].move_delay_value_next, action_arg_number); +#endif + } + } break; } +#endif - case CA_SET_DYNABOMB_POWER: + case CA_SET_PLAYER_GRAVITY: { - printf("::: CA_SET_DYNABOMB_POWER -- not yet implemented\n"); + game.gravity = (action_arg == CA_ARG_GRAVITY_OFF ? FALSE : + action_arg == CA_ARG_GRAVITY_ON ? TRUE : + action_arg == CA_ARG_GRAVITY_TOGGLE ? !game.gravity : + game.gravity); + break; + } + + case CA_SET_WIND_DIRECTION: + { + game.wind_direction = (action_arg >= CA_ARG_DIRECTION_NONE && + action_arg <= CA_ARG_DIRECTION_DOWN ? + action_arg - CA_ARG_DIRECTION : + action_arg == CA_ARG_DIRECTION_TRIGGER ? + MV_DIR_OPPOSITE(change->actual_trigger_side) : + game.wind_direction); break; } - case CA_TOGGLE_PLAYER_GRAVITY: +#if 0 + case CA_SET_DYNABOMB_NUMBER: { - game.gravity = !game.gravity; + printf("::: CA_SET_DYNABOMB_NUMBER -- not yet implemented\n"); break; } - case CA_ENABLE_PLAYER_GRAVITY: + case CA_SET_DYNABOMB_SIZE: { - game.gravity = TRUE; + printf("::: CA_SET_DYNABOMB_SIZE -- not yet implemented\n"); break; } - case CA_DISABLE_PLAYER_GRAVITY: + case CA_SET_DYNABOMB_POWER: { - game.gravity = FALSE; + printf("::: CA_SET_DYNABOMB_POWER -- not yet implemented\n"); break; } +#endif default: break; @@ -6936,6 +6978,7 @@ static boolean ChangeElementNow(int x, int y, int element, int page) /* reset actual trigger element, trigger player and action element */ change->actual_trigger_element = EL_EMPTY; change->actual_trigger_player = EL_PLAYER_1; + change->actual_trigger_side = CH_SIDE_NONE; } #if 1 @@ -7294,6 +7337,7 @@ static boolean CheckTriggeredElementChangeExt(int trigger_element, { change->actual_trigger_element = trigger_element; change->actual_trigger_player = EL_PLAYER_1 + log_2(trigger_player); + change->actual_trigger_side = trigger_side; if ((change->can_change && !change_done) || change->has_action) { @@ -7379,6 +7423,7 @@ static boolean CheckElementChangeExt(int x, int y, { change->actual_trigger_element = trigger_element; change->actual_trigger_player = EL_PLAYER_1 + log_2(trigger_player); + change->actual_trigger_side = trigger_side; if (change->can_change && !change_done) { diff --git a/src/main.h b/src/main.h index 7805f349..d7bbde09 100644 --- a/src/main.h +++ b/src/main.h @@ -29,145 +29,145 @@ #include "conf_snd.h" /* include auto-generated data structure definitions */ #include "conf_mus.h" /* include auto-generated data structure definitions */ -#define IMG_UNDEFINED (-1) -#define IMG_EMPTY IMG_EMPTY_SPACE -#define IMG_SP_EMPTY IMG_SP_EMPTY_SPACE -#define IMG_EXPLOSION IMG_DEFAULT_EXPLODING -#define IMG_CHAR_START IMG_CHAR_SPACE -#define IMG_CUSTOM_START IMG_CUSTOM_1 - -#define SND_UNDEFINED (-1) -#define MUS_UNDEFINED (-1) - -#define WIN_XSIZE 672 -#define WIN_YSIZE 560 - -#define SCR_FIELDX 17 -#define SCR_FIELDY 17 -#define MAX_BUF_XSIZE (SCR_FIELDX + 2) -#define MAX_BUF_YSIZE (SCR_FIELDY + 2) -#define MIN_LEV_FIELDX 3 -#define MIN_LEV_FIELDY 3 -#define STD_LEV_FIELDX 64 -#define STD_LEV_FIELDY 32 -#define MAX_LEV_FIELDX 128 -#define MAX_LEV_FIELDY 128 - -#define SCREENX(a) ((a) - scroll_x) -#define SCREENY(a) ((a) - scroll_y) -#define LEVELX(a) ((a) + scroll_x) -#define LEVELY(a) ((a) + scroll_y) +#define IMG_UNDEFINED (-1) +#define IMG_EMPTY IMG_EMPTY_SPACE +#define IMG_SP_EMPTY IMG_SP_EMPTY_SPACE +#define IMG_EXPLOSION IMG_DEFAULT_EXPLODING +#define IMG_CHAR_START IMG_CHAR_SPACE +#define IMG_CUSTOM_START IMG_CUSTOM_1 + +#define SND_UNDEFINED (-1) +#define MUS_UNDEFINED (-1) + +#define WIN_XSIZE 672 +#define WIN_YSIZE 560 + +#define SCR_FIELDX 17 +#define SCR_FIELDY 17 +#define MAX_BUF_XSIZE (SCR_FIELDX + 2) +#define MAX_BUF_YSIZE (SCR_FIELDY + 2) +#define MIN_LEV_FIELDX 3 +#define MIN_LEV_FIELDY 3 +#define STD_LEV_FIELDX 64 +#define STD_LEV_FIELDY 32 +#define MAX_LEV_FIELDX 128 +#define MAX_LEV_FIELDY 128 + +#define SCREENX(a) ((a) - scroll_x) +#define SCREENY(a) ((a) - scroll_y) +#define LEVELX(a) ((a) + scroll_x) +#define LEVELY(a) ((a) + scroll_y) #define IN_VIS_FIELD(x,y) ((x)>=0 && (x)=0 &&(y)=BX1 && (x)<=BX2 && (y)>=BY1 &&(y)<=BY2) #define IN_LEV_FIELD(x,y) ((x)>=0 && (x)=0 &&(y)has_event[c]) -#define CH_ANY_EVENT_VAR(e,c) (element_info[e].has_change_event[c]) - -#define PAGE_HAS_CHANGE_EVENT(p,c) ((p)->has_event[c]) -#define HAS_CHANGE_EVENT(e,c) (IS_CUSTOM_ELEMENT(e) && \ - CH_EVENT_VAR(e,c)) -#define HAS_ANY_CHANGE_EVENT(e,c) (IS_CUSTOM_ELEMENT(e) && \ - CH_ANY_EVENT_VAR(e,c)) - -#define SET_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ? \ - CH_EVENT_VAR(e,c) = (v) : 0) -#define SET_ANY_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ? \ - CH_ANY_EVENT_VAR(e,c) = (v) : 0) +#define CE_DELAY 0 +#define CE_TOUCHED_BY_PLAYER 1 +#define CE_PRESSED_BY_PLAYER 2 +#define CE_PUSHED_BY_PLAYER 3 +#define CE_DROPPED_BY_PLAYER 4 +#define CE_HITTING_SOMETHING 5 +#define CE_IMPACT 6 +#define CE_SMASHED 7 +#define CE_TOUCHING_X 8 +#define CE_CHANGE_OF_X 9 +#define CE_EXPLOSION_OF_X 10 +#define CE_PLAYER_TOUCHES_X 11 +#define CE_PLAYER_PRESSES_X 12 +#define CE_PLAYER_PUSHES_X 13 +#define CE_PLAYER_COLLECTS_X 14 +#define CE_PLAYER_DROPS_X 15 +#define CE_COUNT_AT_ZERO 16 +#define CE_COUNT_AT_ZERO_OF_X 17 +#define CE_BY_OTHER_ACTION 18 +#define CE_BY_DIRECT_ACTION 19 +#define CE_PLAYER_DIGS_X 20 +#define CE_ENTERED_BY_PLAYER 21 +#define CE_LEFT_BY_PLAYER 22 +#define CE_PLAYER_ENTERS_X 23 +#define CE_PLAYER_LEAVES_X 24 +#define CE_SWITCHED 25 +#define CE_SWITCH_OF_X 26 +#define CE_HIT_BY_SOMETHING 27 +#define CE_HITTING_X 28 +#define CE_HIT_BY_X 29 +#define CE_BLOCKED 30 + +#define NUM_CHANGE_EVENTS 31 + +#define CE_BITMASK_DEFAULT 0 + +#define CH_EVENT_VAR(e,c) (element_info[e].change->has_event[c]) +#define CH_ANY_EVENT_VAR(e,c) (element_info[e].has_change_event[c]) + +#define PAGE_HAS_CHANGE_EVENT(p,c) ((p)->has_event[c]) +#define HAS_CHANGE_EVENT(e,c) (IS_CUSTOM_ELEMENT(e) && \ + CH_EVENT_VAR(e,c)) +#define HAS_ANY_CHANGE_EVENT(e,c) (IS_CUSTOM_ELEMENT(e) && \ + CH_ANY_EVENT_VAR(e,c)) + +#define SET_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ? \ + CH_EVENT_VAR(e,c) = (v) : 0) +#define SET_ANY_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ? \ + CH_ANY_EVENT_VAR(e,c) = (v) : 0) /* values for player bitmasks */ -#define PLAYER_BITS_NONE 0 -#define PLAYER_BITS_1 (1 << 0) -#define PLAYER_BITS_2 (1 << 1) -#define PLAYER_BITS_3 (1 << 2) -#define PLAYER_BITS_4 (1 << 3) -#define PLAYER_BITS_ANY (PLAYER_BITS_1 | \ - PLAYER_BITS_2 | \ - PLAYER_BITS_3 | \ - PLAYER_BITS_4) -#define PLAYER_BITS_TRIGGER (1 << 4) +#define PLAYER_BITS_NONE 0 +#define PLAYER_BITS_1 (1 << 0) +#define PLAYER_BITS_2 (1 << 1) +#define PLAYER_BITS_3 (1 << 2) +#define PLAYER_BITS_4 (1 << 3) +#define PLAYER_BITS_ANY (PLAYER_BITS_1 | \ + PLAYER_BITS_2 | \ + PLAYER_BITS_3 | \ + PLAYER_BITS_4) +#define PLAYER_BITS_TRIGGER (1 << 4) /* values for change side for custom elements */ -#define CH_SIDE_NONE MV_NONE -#define CH_SIDE_LEFT MV_LEFT -#define CH_SIDE_RIGHT MV_RIGHT -#define CH_SIDE_TOP MV_UP -#define CH_SIDE_BOTTOM MV_DOWN -#define CH_SIDE_LEFT_RIGHT MV_HORIZONTAL -#define CH_SIDE_TOP_BOTTOM MV_VERTICAL -#define CH_SIDE_ANY MV_ANY_DIRECTION +#define CH_SIDE_NONE MV_NONE +#define CH_SIDE_LEFT MV_LEFT +#define CH_SIDE_RIGHT MV_RIGHT +#define CH_SIDE_TOP MV_UP +#define CH_SIDE_BOTTOM MV_DOWN +#define CH_SIDE_LEFT_RIGHT MV_HORIZONTAL +#define CH_SIDE_TOP_BOTTOM MV_VERTICAL +#define CH_SIDE_ANY MV_ANY_DIRECTION /* values for change player for custom elements */ -#define CH_PLAYER_NONE PLAYER_BITS_NONE -#define CH_PLAYER_1 PLAYER_BITS_1 -#define CH_PLAYER_2 PLAYER_BITS_2 -#define CH_PLAYER_3 PLAYER_BITS_3 -#define CH_PLAYER_4 PLAYER_BITS_4 -#define CH_PLAYER_ANY PLAYER_BITS_ANY +#define CH_PLAYER_NONE PLAYER_BITS_NONE +#define CH_PLAYER_1 PLAYER_BITS_1 +#define CH_PLAYER_2 PLAYER_BITS_2 +#define CH_PLAYER_3 PLAYER_BITS_3 +#define CH_PLAYER_4 PLAYER_BITS_4 +#define CH_PLAYER_ANY PLAYER_BITS_ANY /* values for change page for custom elements */ -#define CH_PAGE_ANY_FILE (0xff) -#define CH_PAGE_ANY (0xffffffff) +#define CH_PAGE_ANY_FILE (0xff) +#define CH_PAGE_ANY (0xffffffff) /* values for change power for custom elements */ -#define CP_WHEN_EMPTY 0 -#define CP_WHEN_DIGGABLE 1 -#define CP_WHEN_DESTRUCTIBLE 2 -#define CP_WHEN_COLLECTIBLE 3 -#define CP_WHEN_REMOVABLE 4 -#define CP_WHEN_WALKABLE 5 +#define CP_WHEN_EMPTY 0 +#define CP_WHEN_DIGGABLE 1 +#define CP_WHEN_DESTRUCTIBLE 2 +#define CP_WHEN_COLLECTIBLE 3 +#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_TIME 9 -#define CA_SET_SCORE 10 -#define CA_SET_CE_SCORE 11 -#define CA_SET_CE_COUNT 12 -#define CA_SET_DYNABOMB_NUMBER 13 -#define CA_SET_DYNABOMB_SIZE 14 -#define CA_SET_DYNABOMB_POWER 15 -#define CA_TOGGLE_PLAYER_GRAVITY 16 -#define CA_ENABLE_PLAYER_GRAVITY 17 -#define CA_DISABLE_PLAYER_GRAVITY 18 +#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_GEMS 7 +#define CA_SET_TIME 8 +#define CA_SET_SCORE 9 +#define CA_SET_CE_SCORE 10 +#define CA_SET_CE_COUNT 11 +#define CA_SET_PLAYER_SPEED 12 +#define CA_SET_PLAYER_GRAVITY 13 +#define CA_SET_WIND_DIRECTION 14 +#if 0 +#define CA_SET_DYNABOMB_NUMBER 15 +#define CA_SET_DYNABOMB_SIZE 16 +#define CA_SET_DYNABOMB_POWER 17 +#endif /* values for change action mode for custom elements */ -#define CA_MODE_UNDEFINED 0 -#define CA_MODE_SET 1 -#define CA_MODE_ADD 2 -#define CA_MODE_SUBTRACT 3 -#define CA_MODE_MULTIPLY 4 -#define CA_MODE_DIVIDE 5 -#define CA_MODE_MODULO 6 +#define CA_MODE_UNDEFINED 0 +#define CA_MODE_SET 1 +#define CA_MODE_ADD 2 +#define CA_MODE_SUBTRACT 3 +#define CA_MODE_MULTIPLY 4 +#define CA_MODE_DIVIDE 5 +#define CA_MODE_MODULO 6 /* values for change action parameters for custom elements */ -#define CA_ARG_MIN 0 -#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_10 10 -#define CA_ARG_100 100 -#define CA_ARG_1000 1000 -#define CA_ARG_MAX 9999 -#define CA_ARG_PLAYER 10000 -#define CA_ARG_PLAYER_HEADLINE (CA_ARG_PLAYER + 0) -#define CA_ARG_PLAYER_1 (CA_ARG_PLAYER + PLAYER_BITS_1) -#define CA_ARG_PLAYER_2 (CA_ARG_PLAYER + PLAYER_BITS_2) -#define CA_ARG_PLAYER_3 (CA_ARG_PLAYER + PLAYER_BITS_3) -#define CA_ARG_PLAYER_4 (CA_ARG_PLAYER + PLAYER_BITS_4) -#define CA_ARG_PLAYER_ANY (CA_ARG_PLAYER + PLAYER_BITS_ANY) -#define CA_ARG_PLAYER_TRIGGER (CA_ARG_PLAYER + PLAYER_BITS_TRIGGER) -#define CA_ARG_NUMBER 20000 -#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_CE_SCORE (CA_ARG_NUMBER + 5) -#define CA_ARG_NUMBER_CE_COUNT (CA_ARG_NUMBER + 6) -#define CA_ARG_NUMBER_CE_DELAY (CA_ARG_NUMBER + 7) -#define CA_ARG_ELEMENT 30000 -#define CA_ARG_ELEMENT_HEADLINE (CA_ARG_ELEMENT + 0) -#define CA_ARG_ELEMENT_TARGET (CA_ARG_ELEMENT + 1) -#define CA_ARG_ELEMENT_TRIGGER (CA_ARG_ELEMENT + 2) -#define CA_ARG_UNDEFINED 30999 +#define CA_ARG_MIN 0 +#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_100 100 +#define CA_ARG_1000 1000 +#define CA_ARG_MAX 9999 +#define CA_ARG_PLAYER 10000 +#define CA_ARG_PLAYER_1 (CA_ARG_PLAYER + PLAYER_BITS_1) +#define CA_ARG_PLAYER_2 (CA_ARG_PLAYER + PLAYER_BITS_2) +#define CA_ARG_PLAYER_3 (CA_ARG_PLAYER + PLAYER_BITS_3) +#define CA_ARG_PLAYER_4 (CA_ARG_PLAYER + PLAYER_BITS_4) +#define CA_ARG_PLAYER_ANY (CA_ARG_PLAYER + PLAYER_BITS_ANY) +#define CA_ARG_PLAYER_TRIGGER (CA_ARG_PLAYER + PLAYER_BITS_TRIGGER) +#define CA_ARG_PLAYER_HEADLINE (CA_ARG_PLAYER + 999) +#define CA_ARG_NUMBER 11000 +#define CA_ARG_NUMBER_MIN (CA_ARG_NUMBER + 0) +#define CA_ARG_NUMBER_MAX (CA_ARG_NUMBER + 1) +#define CA_ARG_NUMBER_RESET (CA_ARG_NUMBER + 2) +#define CA_ARG_NUMBER_CE_SCORE (CA_ARG_NUMBER + 3) +#define CA_ARG_NUMBER_CE_COUNT (CA_ARG_NUMBER + 4) +#define CA_ARG_NUMBER_CE_DELAY (CA_ARG_NUMBER + 5) +#define CA_ARG_NUMBER_HEADLINE (CA_ARG_NUMBER + 999) +#define CA_ARG_ELEMENT 12000 +#define CA_ARG_ELEMENT_TARGET (CA_ARG_ELEMENT + 0) +#define CA_ARG_ELEMENT_TRIGGER (CA_ARG_ELEMENT + 1) +#define CA_ARG_ELEMENT_HEADLINE (CA_ARG_ELEMENT + 999) +#define CA_ARG_SPEED 13000 +#define CA_ARG_SPEED_VERY_SLOW (CA_ARG_SPEED + 1) +#define CA_ARG_SPEED_SLOW (CA_ARG_SPEED + 2) +#define CA_ARG_SPEED_NORMAL (CA_ARG_SPEED + 4) +#define CA_ARG_SPEED_FAST (CA_ARG_SPEED + 8) +#define CA_ARG_SPEED_VERY_FAST (CA_ARG_SPEED + 16) +#define CA_ARG_SPEED_EVEN_FASTER (CA_ARG_SPEED + 32) +#define CA_ARG_SPEED_SLOWER (CA_ARG_SPEED + 50) +#define CA_ARG_SPEED_FASTER (CA_ARG_SPEED + 200) +#define CA_ARG_SPEED_RESET (CA_ARG_SPEED + 0) +#define CA_ARG_SPEED_HEADLINE (CA_ARG_SPEED + 999) +#define CA_ARG_GRAVITY 14000 +#define CA_ARG_GRAVITY_OFF (CA_ARG_GRAVITY + 0) +#define CA_ARG_GRAVITY_ON (CA_ARG_GRAVITY + 1) +#define CA_ARG_GRAVITY_TOGGLE (CA_ARG_GRAVITY + 2) +#define CA_ARG_GRAVITY_HEADLINE (CA_ARG_GRAVITY + 999) +#define CA_ARG_DIRECTION 15000 +#define CA_ARG_DIRECTION_NONE (CA_ARG_DIRECTION + MV_NONE) +#define CA_ARG_DIRECTION_LEFT (CA_ARG_DIRECTION + MV_LEFT) +#define CA_ARG_DIRECTION_RIGHT (CA_ARG_DIRECTION + MV_RIGHT) +#define CA_ARG_DIRECTION_UP (CA_ARG_DIRECTION + MV_UP) +#define CA_ARG_DIRECTION_DOWN (CA_ARG_DIRECTION + MV_DOWN) +#define CA_ARG_DIRECTION_TRIGGER (CA_ARG_DIRECTION + MV_ANY_DIRECTION) +#define CA_ARG_DIRECTION_HEADLINE (CA_ARG_DIRECTION + 999) +#define CA_ARG_UNDEFINED 19999 /* values for custom move patterns (bits 0 - 3: basic move directions) */ -#define MV_BIT_TOWARDS_PLAYER 4 -#define MV_BIT_AWAY_FROM_PLAYER 5 -#define MV_BIT_ALONG_LEFT_SIDE 6 -#define MV_BIT_ALONG_RIGHT_SIDE 7 -#define MV_BIT_TURNING_LEFT 8 -#define MV_BIT_TURNING_RIGHT 9 -#define MV_BIT_WHEN_PUSHED 10 -#define MV_BIT_MAZE_RUNNER 11 -#define MV_BIT_MAZE_HUNTER 12 -#define MV_BIT_WHEN_DROPPED 13 -#define MV_BIT_TURNING_LEFT_RIGHT 14 -#define MV_BIT_TURNING_RIGHT_LEFT 15 -#define MV_BIT_TURNING_RANDOM 16 -#define MV_BIT_WIND_DIRECTION 17 +#define MV_BIT_TOWARDS_PLAYER 4 +#define MV_BIT_AWAY_FROM_PLAYER 5 +#define MV_BIT_ALONG_LEFT_SIDE 6 +#define MV_BIT_ALONG_RIGHT_SIDE 7 +#define MV_BIT_TURNING_LEFT 8 +#define MV_BIT_TURNING_RIGHT 9 +#define MV_BIT_WHEN_PUSHED 10 +#define MV_BIT_MAZE_RUNNER 11 +#define MV_BIT_MAZE_HUNTER 12 +#define MV_BIT_WHEN_DROPPED 13 +#define MV_BIT_TURNING_LEFT_RIGHT 14 +#define MV_BIT_TURNING_RIGHT_LEFT 15 +#define MV_BIT_TURNING_RANDOM 16 +#define MV_BIT_WIND_DIRECTION 17 /* values for custom move patterns */ -#define MV_TOWARDS_PLAYER (1 << MV_BIT_TOWARDS_PLAYER) -#define MV_AWAY_FROM_PLAYER (1 << MV_BIT_AWAY_FROM_PLAYER) -#define MV_ALONG_LEFT_SIDE (1 << MV_BIT_ALONG_LEFT_SIDE) -#define MV_ALONG_RIGHT_SIDE (1 << MV_BIT_ALONG_RIGHT_SIDE) -#define MV_TURNING_LEFT (1 << MV_BIT_TURNING_LEFT) -#define MV_TURNING_RIGHT (1 << MV_BIT_TURNING_RIGHT) -#define MV_WHEN_PUSHED (1 << MV_BIT_WHEN_PUSHED) -#define MV_MAZE_RUNNER (1 << MV_BIT_MAZE_RUNNER) -#define MV_MAZE_HUNTER (1 << MV_BIT_MAZE_HUNTER) -#define MV_MAZE_RUNNER_STYLE (MV_MAZE_RUNNER | MV_MAZE_HUNTER) -#define MV_WHEN_DROPPED (1 << MV_BIT_WHEN_DROPPED) -#define MV_TURNING_LEFT_RIGHT (1 << MV_BIT_TURNING_LEFT_RIGHT) -#define MV_TURNING_RIGHT_LEFT (1 << MV_BIT_TURNING_RIGHT_LEFT) -#define MV_TURNING_RANDOM (1 << MV_BIT_TURNING_RANDOM) -#define MV_WIND_DIRECTION (1 << MV_BIT_WIND_DIRECTION) +#define MV_TOWARDS_PLAYER (1 << MV_BIT_TOWARDS_PLAYER) +#define MV_AWAY_FROM_PLAYER (1 << MV_BIT_AWAY_FROM_PLAYER) +#define MV_ALONG_LEFT_SIDE (1 << MV_BIT_ALONG_LEFT_SIDE) +#define MV_ALONG_RIGHT_SIDE (1 << MV_BIT_ALONG_RIGHT_SIDE) +#define MV_TURNING_LEFT (1 << MV_BIT_TURNING_LEFT) +#define MV_TURNING_RIGHT (1 << MV_BIT_TURNING_RIGHT) +#define MV_WHEN_PUSHED (1 << MV_BIT_WHEN_PUSHED) +#define MV_MAZE_RUNNER (1 << MV_BIT_MAZE_RUNNER) +#define MV_MAZE_HUNTER (1 << MV_BIT_MAZE_HUNTER) +#define MV_MAZE_RUNNER_STYLE (MV_MAZE_RUNNER | MV_MAZE_HUNTER) +#define MV_WHEN_DROPPED (1 << MV_BIT_WHEN_DROPPED) +#define MV_TURNING_LEFT_RIGHT (1 << MV_BIT_TURNING_LEFT_RIGHT) +#define MV_TURNING_RIGHT_LEFT (1 << MV_BIT_TURNING_RIGHT_LEFT) +#define MV_TURNING_RANDOM (1 << MV_BIT_TURNING_RANDOM) +#define MV_WIND_DIRECTION (1 << MV_BIT_WIND_DIRECTION) /* values for initial move direction (bits 0 - 3: basic move directions) */ -#define MV_START_BIT_PREVIOUS 4 +#define MV_START_BIT_PREVIOUS 4 /* values for initial move direction */ -#define MV_START_NONE (MV_NONE) -#define MV_START_AUTOMATIC (MV_NONE) -#define MV_START_LEFT (MV_LEFT) -#define MV_START_RIGHT (MV_RIGHT) -#define MV_START_UP (MV_UP) -#define MV_START_DOWN (MV_DOWN) -#define MV_START_RANDOM (MV_ALL_DIRECTIONS) -#define MV_START_PREVIOUS (1 << MV_START_BIT_PREVIOUS) +#define MV_START_NONE (MV_NONE) +#define MV_START_AUTOMATIC (MV_NONE) +#define MV_START_LEFT (MV_LEFT) +#define MV_START_RIGHT (MV_RIGHT) +#define MV_START_UP (MV_UP) +#define MV_START_DOWN (MV_DOWN) +#define MV_START_RANDOM (MV_ALL_DIRECTIONS) +#define MV_START_PREVIOUS (1 << MV_START_BIT_PREVIOUS) /* values for elements left behind by custom elements */ -#define LEAVE_TYPE_UNLIMITED 0 -#define LEAVE_TYPE_LIMITED 1 +#define LEAVE_TYPE_UNLIMITED 0 +#define LEAVE_TYPE_LIMITED 1 /* values for slippery property for custom elements */ -#define SLIPPERY_ANY_RANDOM 0 -#define SLIPPERY_ANY_LEFT_RIGHT 1 -#define SLIPPERY_ANY_RIGHT_LEFT 2 -#define SLIPPERY_ONLY_LEFT 3 -#define SLIPPERY_ONLY_RIGHT 4 +#define SLIPPERY_ANY_RANDOM 0 +#define SLIPPERY_ANY_LEFT_RIGHT 1 +#define SLIPPERY_ANY_RIGHT_LEFT 2 +#define SLIPPERY_ONLY_LEFT 3 +#define SLIPPERY_ONLY_RIGHT 4 /* values for explosion type for custom elements */ -#define EXPLODES_3X3 0 -#define EXPLODES_1X1 1 -#define EXPLODES_CROSS 2 +#define EXPLODES_3X3 0 +#define EXPLODES_1X1 1 +#define EXPLODES_CROSS 2 /* macros for configurable properties */ #define IS_DIGGABLE(e) HAS_PROPERTY(e, EP_DIGGABLE) @@ -1925,6 +1953,7 @@ struct ElementChangeInfo void (*post_change_function)(int x, int y); short actual_trigger_element; /* element that actually triggered change */ + int actual_trigger_side; /* el.side that actually triggered change */ int actual_trigger_player; /* player which actually triggered change */ boolean can_change_or_has_action; /* can_change | has_action */