From 9de8eede744c45187c7011543ef8097d1ebc879c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 3 Jul 2003 13:40:57 +0200 Subject: [PATCH] rnd-20030703-2-src --- src/conftime.h | 2 +- src/editor.c | 132 ++++++++++++++++++++----------------------------- src/events.c | 3 +- src/files.c | 14 ++++++ src/game.c | 118 ++++++++++--------------------------------- src/main.h | 16 ++++++ src/tools.c | 100 +++++++++++-------------------------- src/tools.h | 1 + 8 files changed, 143 insertions(+), 243 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index aeb860a4..a37bb49e 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-07-02 23:31]" +#define COMPILE_DATE_STRING "[2003-07-03 13:40]" diff --git a/src/editor.c b/src/editor.c index dd757b05..a0872472 100644 --- a/src/editor.c +++ b/src/editor.c @@ -890,7 +890,6 @@ static struct ValueTextInfo options_access_type[] = { EP_PASSABLE, "pass" }, { -1, NULL } }; -static int value_access_type = 0; static struct ValueTextInfo options_access_layer[] = { @@ -899,7 +898,6 @@ static struct ValueTextInfo options_access_layer[] = { EP_ACCESSIBLE_UNDER, "under" }, { -1, NULL } }; -static int value_access_layer = 0; static struct ValueTextInfo options_walk_to_action[] = { @@ -908,7 +906,6 @@ static struct ValueTextInfo options_walk_to_action[] = { EP_PUSHABLE, "pushable" }, { -1, NULL } }; -static int value_walk_to_action = 0; static struct ValueTextInfo options_move_pattern[] = { @@ -955,7 +952,6 @@ static struct ValueTextInfo options_smash_targets[] = { EP_CAN_SMASH_EVERYTHING, "everything" }, { -1, NULL } }; -static int value_smash_targets = 0; static struct ValueTextInfo options_deadliness[] = { @@ -964,7 +960,6 @@ static struct ValueTextInfo options_deadliness[] = { EP_DONT_TOUCH, "touching" }, { -1, NULL } }; -static int value_deadliness = 0; static struct ValueTextInfo options_consistency[] = { @@ -972,7 +967,6 @@ static struct ValueTextInfo options_consistency[] = { EP_INDESTRUCTIBLE, "indestructible" }, { -1, NULL } }; -static int value_consistency = 0; static struct ValueTextInfo options_time_units[] = { @@ -988,7 +982,6 @@ static struct ValueTextInfo options_change_player_action[] = { CE_PUSHED_BY_PLAYER, "pushed" }, { -1, NULL } }; -static int value_change_player_action = 0; static struct ValueTextInfo options_change_collide_action[] = { @@ -997,7 +990,6 @@ static struct ValueTextInfo options_change_collide_action[] = { CE_SMASHED, "when smashed" }, { -1, NULL } }; -static int value_change_collide_action = 0; static struct ValueTextInfo options_change_other_action[] = { @@ -1010,7 +1002,6 @@ static struct ValueTextInfo options_change_other_action[] = { CE_OTHER_GETS_COLLECTED, "player collects" }, { -1, NULL } }; -static int value_change_other_action = 0; static struct ValueTextInfo options_change_power[] = { @@ -1037,7 +1028,7 @@ static struct GADGET_ID_CUSTOM_ACCESS_TYPE, -1, options_access_type, - &value_access_type, + &custom_element.access_type, "player can", NULL, "type of access to this field" }, { @@ -1045,7 +1036,7 @@ static struct GADGET_ID_CUSTOM_ACCESS_LAYER, -1, options_access_layer, - &value_access_layer, + &custom_element.access_layer, NULL, NULL, "layer of access for this field" }, { @@ -1053,7 +1044,7 @@ static struct GADGET_ID_CUSTOM_WALK_TO_ACTION, -1, options_walk_to_action, - &value_walk_to_action, + &custom_element.walk_to_action, NULL, NULL, "diggable/collectible/pushable" }, { @@ -1085,7 +1076,7 @@ static struct GADGET_ID_CUSTOM_SMASH_TARGETS, -1, options_smash_targets, - &value_smash_targets, + &custom_element.smash_targets, "can smash", NULL, "elements that can be smashed" }, { @@ -1093,7 +1084,7 @@ static struct GADGET_ID_CUSTOM_DEADLINESS, -1, options_deadliness, - &value_deadliness, + &custom_element.deadliness, "deadly when", NULL, "deadliness of element" }, { @@ -1101,7 +1092,7 @@ static struct GADGET_ID_CUSTOM_CONSISTENCY, -1, options_consistency, - &value_consistency, + &custom_element.consistency, NULL, "explodes to:", "consistency/destructibility" }, @@ -1120,7 +1111,7 @@ static struct GADGET_ID_CHANGE_PLAYER_ACTION, -1, options_change_player_action, - &value_change_player_action, + &custom_element.change_player_action, NULL, "by player", "type of player contact" }, { @@ -1128,7 +1119,7 @@ static struct GADGET_ID_CHANGE_COLLIDE_ACTION, -1, options_change_collide_action, - &value_change_collide_action, + &custom_element.change_collide_action, NULL, NULL, "change after impact or smash" }, { @@ -1136,7 +1127,7 @@ static struct GADGET_ID_CHANGE_OTHER_ACTION, -1, options_change_other_action, - &value_change_other_action, + &custom_element.change_other_action, NULL, "element:", "type of other element action" }, { @@ -1287,10 +1278,6 @@ static struct } }; -static boolean can_explode_by_fire = FALSE; -static boolean can_explode_smashed = FALSE; -static boolean can_explode_impact = FALSE; - static struct { int x, y; @@ -1388,19 +1375,19 @@ static struct { ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(13), GADGET_ID_CUSTOM_EXPLODE_FIRE, - &can_explode_by_fire, + &custom_element.can_explode_by_fire, "by fire", "element can explode by fire/explosion" }, { ED_SETTINGS_XPOS(7), ED_SETTINGS_YPOS(13), GADGET_ID_CUSTOM_EXPLODE_SMASH, - &can_explode_smashed, + &custom_element.can_explode_smashed, "smashed", "element can explode when smashed" }, { ED_SETTINGS_XPOS(13), ED_SETTINGS_YPOS(13), GADGET_ID_CUSTOM_EXPLODE_IMPACT, - &can_explode_impact, + &custom_element.can_explode_impact, "impact", "element can explode on impact" }, @@ -3632,88 +3619,88 @@ static void CopyCustomElementPropertiesToEditor(int element) /* ---------- element settings: configure (custom elements) ------------- */ /* set accessible layer selectbox help value */ - value_access_type = + custom_element.access_type = (IS_WALKABLE(element) ? EP_WALKABLE : IS_PASSABLE(element) ? EP_PASSABLE : - value_access_type); - value_access_layer = + custom_element.access_type); + custom_element.access_layer = (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER : IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE : IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER : - value_access_layer); + custom_element.access_layer); custom_element_properties[EP_ACCESSIBLE] = (IS_ACCESSIBLE_OVER(element) || IS_ACCESSIBLE_INSIDE(element) || IS_ACCESSIBLE_UNDER(element)); /* set walk-to-object action selectbox help value */ - value_walk_to_action = + custom_element.walk_to_action = (IS_DIGGABLE(element) ? EP_DIGGABLE : IS_COLLECTIBLE(element) ? EP_COLLECTIBLE : IS_PUSHABLE(element) ? EP_PUSHABLE : - value_walk_to_action); + custom_element.walk_to_action); custom_element_properties[EP_WALK_TO_OBJECT] = (IS_DIGGABLE(element) || IS_COLLECTIBLE(element) || IS_PUSHABLE(element)); /* set smash targets selectbox help value */ - value_smash_targets = + custom_element.smash_targets = (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING : CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES : CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER : - value_smash_targets); + custom_element.smash_targets); custom_element_properties[EP_CAN_SMASH] = (CAN_SMASH_EVERYTHING(element) || CAN_SMASH_ENEMIES(element) || CAN_SMASH_PLAYER(element)); /* set deadliness selectbox help value */ - value_deadliness = + custom_element.deadliness = (DONT_TOUCH(element) ? EP_DONT_TOUCH : DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH : DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO : - value_deadliness); + custom_element.deadliness); custom_element_properties[EP_DEADLY] = (DONT_TOUCH(element) || DONT_COLLIDE_WITH(element) || DONT_RUN_INTO(element)); /* set consistency selectbox help value */ - value_consistency = + custom_element.consistency = (IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE : CAN_EXPLODE(element) ? EP_CAN_EXPLODE : - value_consistency); + custom_element.consistency); custom_element_properties[EP_EXPLODE_RESULT] = (IS_INDESTRUCTIBLE(element) || CAN_EXPLODE(element)); /* special case: sub-settings dependent from main setting */ - if (CAN_EXPLODE(element)) - { - can_explode_by_fire = CAN_EXPLODE_BY_FIRE(element); - can_explode_smashed = CAN_EXPLODE_SMASHED(element); - can_explode_impact = CAN_EXPLODE_IMPACT(element); - }; + if (CAN_EXPLODE_BY_FIRE(element)) + custom_element.can_explode_by_fire = TRUE; + if (CAN_EXPLODE_SMASHED(element)) + custom_element.can_explode_smashed = TRUE; + if (CAN_EXPLODE_IMPACT(element)) + custom_element.can_explode_impact = TRUE; /* ---------- element settings: advanced (custom elements) --------------- */ /* set change by player selectbox help value */ - value_change_player_action = + custom_element.change_player_action = (HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER : HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER : HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER : - value_change_player_action); + custom_element.change_player_action); /* set change by collision selectbox help value */ - value_change_collide_action = + custom_element.change_collide_action = (HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED : HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT : HAS_CHANGE_EVENT(element, CE_COLLISION) ? CE_COLLISION : - value_change_collide_action); + custom_element.change_collide_action); /* set change by other element action selectbox help value */ - value_change_other_action = + custom_element.change_other_action = (HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED : HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED : HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PRESSED) ? CE_OTHER_GETS_PRESSED : @@ -3721,12 +3708,13 @@ static void CopyCustomElementPropertiesToEditor(int element) HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING : HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING : HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING : - value_change_other_action); + custom_element.change_other_action); } static void CopyCustomElementPropertiesToGame(int element) { int i; + int access_type_and_layer; element_info[properties_element] = custom_element; @@ -3739,30 +3727,31 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_properties[EP_PASSABLE_OVER] = FALSE; custom_element_properties[EP_PASSABLE_INSIDE] = FALSE; custom_element_properties[EP_PASSABLE_UNDER] = FALSE; - custom_element_properties[((value_access_type == EP_WALKABLE ? - EP_WALKABLE_OVER : EP_PASSABLE_OVER) + - (value_access_layer - EP_ACCESSIBLE_OVER))] = + access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ? + EP_WALKABLE_OVER : EP_PASSABLE_OVER) + + (custom_element.access_layer - EP_ACCESSIBLE_OVER)); + custom_element_properties[access_type_and_layer] = custom_element_properties[EP_ACCESSIBLE]; /* set walk-to-object property from checkbox and selectbox */ custom_element_properties[EP_DIGGABLE] = FALSE; custom_element_properties[EP_COLLECTIBLE] = FALSE; custom_element_properties[EP_PUSHABLE] = FALSE; - custom_element_properties[value_walk_to_action] = + custom_element_properties[custom_element.walk_to_action] = custom_element_properties[EP_WALK_TO_OBJECT]; /* set smash property from checkbox and selectbox */ custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE; custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE; custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE; - custom_element_properties[value_smash_targets] = + custom_element_properties[custom_element.smash_targets] = custom_element_properties[EP_CAN_SMASH]; /* set deadliness property from checkbox and selectbox */ custom_element_properties[EP_DONT_RUN_INTO] = FALSE; custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE; custom_element_properties[EP_DONT_TOUCH] = FALSE; - custom_element_properties[value_deadliness] = + custom_element_properties[custom_element.deadliness] = custom_element_properties[EP_DEADLY]; /* set consistency property from checkbox and selectbox */ @@ -3771,15 +3760,18 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = FALSE; custom_element_properties[EP_CAN_EXPLODE_SMASHED] = FALSE; custom_element_properties[EP_CAN_EXPLODE_IMPACT] = FALSE; - custom_element_properties[value_consistency] = + custom_element_properties[custom_element.consistency] = custom_element_properties[EP_EXPLODE_RESULT]; /* special case: sub-settings dependent from main setting */ if (custom_element_properties[EP_CAN_EXPLODE]) { - custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = can_explode_by_fire; - custom_element_properties[EP_CAN_EXPLODE_SMASHED] = can_explode_smashed; - custom_element_properties[EP_CAN_EXPLODE_IMPACT] = can_explode_impact; + custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = + custom_element.can_explode_by_fire; + custom_element_properties[EP_CAN_EXPLODE_SMASHED] = + custom_element.can_explode_smashed; + custom_element_properties[EP_CAN_EXPLODE_IMPACT] = + custom_element.can_explode_impact; } /* ---------- element settings: advanced (custom elements) --------------- */ @@ -3788,14 +3780,14 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE; custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE; custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE; - custom_element_change_events[value_change_player_action] = + custom_element_change_events[custom_element.change_player_action] = custom_element_change_events[CE_BY_PLAYER]; /* set collision change event from checkbox and selectbox */ custom_element_change_events[CE_COLLISION] = FALSE; custom_element_change_events[CE_IMPACT] = FALSE; custom_element_change_events[CE_SMASHED] = FALSE; - custom_element_change_events[value_change_collide_action] = + custom_element_change_events[custom_element.change_collide_action] = custom_element_change_events[CE_BY_COLLISION]; /* set other element action change event from checkbox and selectbox */ @@ -3806,7 +3798,7 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_change_events[CE_OTHER_GETS_PRESSED] = FALSE; custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE; custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE; - custom_element_change_events[value_change_other_action] = + custom_element_change_events[custom_element.change_other_action] = custom_element_change_events[CE_BY_OTHER]; for (i=0; i < NUM_ELEMENT_PROPERTIES; i++) @@ -4528,19 +4520,9 @@ static void DrawPropertiesTabulatorGadgets() int gd_y = gd->y + gd_gi->height - 1; Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y); int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO; -#if 1 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG; -#else - int id_last = ED_TEXTBUTTON_ID_PROPERTIES_INFO; -#endif int i; -#if 0 - /* draw additional "configure" tabulator for configurable elements */ - if (checkPropertiesConfig()) - id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG; -#endif - /* draw additional "advanced" tabulator for custom elements */ if (IS_CUSTOM_ELEMENT(properties_element)) id_last = ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED; @@ -4928,12 +4910,6 @@ static void DrawPropertiesWindow() !IS_CUSTOM_ELEMENT(properties_element)) edit_mode_properties = ED_MODE_PROPERTIES_CONFIG; -#if 0 - if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG && - !checkPropertiesConfig()) - edit_mode_properties = ED_MODE_PROPERTIES_INFO; -#endif - if (IS_CUSTOM_ELEMENT(properties_element)) CopyCustomElementPropertiesToEditor(properties_element); diff --git a/src/events.c b/src/events.c index 61bdf6be..b1c15e9f 100644 --- a/src/events.c +++ b/src/events.c @@ -422,7 +422,8 @@ void HandleButton(int mx, int my, int button) if (!IN_LEV_FIELD(x, y)) break; - printf(" Feld[%d][%d] == %d\n", x,y, Feld[x][y]); + printf(" Feld[%d][%d] == %d ('%s')\n", x,y, Feld[x][y], + element_info[Feld[x][y]].token_name); printf(" Store[%d][%d] == %d\n", x,y, Store[x][y]); printf(" Store2[%d][%d] == %d\n", x,y, Store2[x][y]); printf(" StorePlayer[%d][%d] == %d\n", x,y, StorePlayer[x][y]); diff --git a/src/files.c b/src/files.c index ebdd7afd..e0538955 100644 --- a/src/files.c +++ b/src/files.c @@ -144,6 +144,20 @@ static void setLevelInfoToDefaults() for(y=0; y<3; y++) element_info[element].change.content[x][y] = EL_EMPTY_SPACE; + element_info[element].access_type = 0; + element_info[element].access_layer = 0; + element_info[element].walk_to_action = 0; + element_info[element].smash_targets = 0; + element_info[element].deadliness = 0; + element_info[element].consistency = 0; + element_info[element].change_player_action = 0; + element_info[element].change_collide_action = 0; + element_info[element].change_other_action = 0; + + element_info[element].can_explode_by_fire = FALSE; + element_info[element].can_explode_smashed = FALSE; + element_info[element].can_explode_impact = FALSE; + /* start with no properties at all */ for (j=0; j < NUM_EP_BITFIELDS; j++) Properties[element][j] = EP_BITMASK_DEFAULT; diff --git a/src/game.c b/src/game.c index 1b6251b6..3051f5ac 100644 --- a/src/game.c +++ b/src/game.c @@ -169,7 +169,7 @@ static void KillHeroUnlessProtected(int, int); static void TestIfPlayerTouchesCustomElement(int, int); static void TestIfElementTouchesCustomElement(int, int); -static boolean CheckTriggeredElementChange(int, int); +static boolean CheckTriggeredElementChange(int, int, int, int); static boolean CheckElementChange(int, int, int, int); static void ChangeElementNow(int, int, int); @@ -2256,7 +2256,7 @@ void Bang(int x, int y) break; } - CheckTriggeredElementChange(element, CE_OTHER_IS_EXPLODING); + CheckTriggeredElementChange(x, y, element, CE_OTHER_IS_EXPLODING); } void SplashAcid(int x, int y) @@ -4003,47 +4003,22 @@ void ContinueMoving(int x, int y) int direction = MovDir[x][y]; int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); - int horiz_move = (dx != 0); int newx = x + dx, newy = y + dy; int nextx = newx + dx, nexty = newy + dy; -#if 1 + int horiz_move = (dx != 0); int sign = (horiz_move ? dx : dy); int step = sign * element_info[element].move_stepsize; -#else - int step = (horiz_move ? dx : dy) * MOVE_STEPSIZE_NORMAL; -#endif boolean pushed = Pushed[x][y]; -#if 1 - if (CAN_FALL(element) && horiz_move && - y < lev_fieldy - 1 && IS_BELT_ACTIVE(Feld[x][y + 1])) - step = sign * MOVE_STEPSIZE_NORMAL / 2; - else if (element == EL_SPRING && horiz_move) - step = sign * MOVE_STEPSIZE_NORMAL * 2; -#else - if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DROPPING) - step /= 2; - else if (element == EL_QUICKSAND_FILLING || - element == EL_QUICKSAND_EMPTYING) - step /= 4; - else if (element == EL_MAGIC_WALL_FILLING || - element == EL_BD_MAGIC_WALL_FILLING || - element == EL_MAGIC_WALL_EMPTYING || - element == EL_BD_MAGIC_WALL_EMPTYING) - step /= 2; - else if (CAN_FALL(element) && horiz_move && - y < lev_fieldy-1 && IS_BELT_ACTIVE(Feld[x][y+1])) - step /= 2; - else if (element == EL_SPRING && horiz_move) - step *= 2; - else if (IS_CUSTOM_ELEMENT(element)) - step = SIGN(step) * element_info[element].move_stepsize; - -#if OLD_GAME_BEHAVIOUR - else if (CAN_FALL(element) && horiz_move && !IS_SP_ELEMENT(element)) - step*=2; -#endif -#endif + /* special values for move stepsize for spring and things on conveyor belt */ + if (horiz_move) + { + if (CAN_FALL(element) && + y < lev_fieldy - 1 && IS_BELT_ACTIVE(Feld[x][y + 1])) + step = sign * MOVE_STEPSIZE_NORMAL / 2; + else if (element == EL_SPRING) + step = sign * MOVE_STEPSIZE_NORMAL * 2; + } MovPos[x][y] += step; @@ -4058,31 +4033,11 @@ void ContinueMoving(int x, int y) if (element == EL_MOLE) { - int i; - static int xy[4][2] = - { - { 0, -1 }, - { -1, 0 }, - { +1, 0 }, - { 0, +1 } - }; - Feld[x][y] = EL_SAND; - DrawLevelField(x, y); - for(i=0; i<4; i++) - { - int xx, yy; - - xx = x + xy[i][0]; - yy = y + xy[i][1]; - - if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_SAND) - DrawLevelField(xx, yy); /* for "crumbled sand" */ - } + DrawLevelFieldCrumbledSandNeighbours(x, y); } - - if (element == EL_QUICKSAND_FILLING) + else if (element == EL_QUICKSAND_FILLING) { element = Feld[newx][newy] = get_next_element(element); Store[newx][newy] = Store[x][y]; @@ -5117,40 +5072,14 @@ static void ChangeElementNowExt(int x, int y, int target_element) DrawLevelField(x, y); if (CAN_BE_CRUMBLED(Feld[x][y])) - { - int sx = SCREENX(x), sy = SCREENY(y); - static int xy[4][2] = - { - { 0, -1 }, - { -1, 0 }, - { +1, 0 }, - { 0, +1 } - }; - int i; - - for(i=0; i<4; i++) - { - int xx = x + xy[i][0]; - int yy = y + xy[i][1]; - int sxx = sx + xy[i][0]; - int syy = sy + xy[i][1]; - - if (!IN_LEV_FIELD(xx, yy) || - !IN_SCR_FIELD(sxx, syy) || - !CAN_BE_CRUMBLED(Feld[xx][yy]) || - IS_MOVING(xx, yy)) - continue; - - DrawLevelField(xx, yy); - } - } + DrawLevelFieldCrumbledSandNeighbours(x, y); } static void ChangeElementNow(int x, int y, int element) { struct ElementChangeInfo *change = &element_info[element].change; - CheckTriggeredElementChange(Feld[x][y], CE_OTHER_IS_CHANGING); + CheckTriggeredElementChange(x, y, Feld[x][y], CE_OTHER_IS_CHANGING); if (change->explode) { @@ -5318,7 +5247,7 @@ static void ChangeElement(int x, int y) } } -static boolean CheckTriggeredElementChange(int trigger_element, +static boolean CheckTriggeredElementChange(int lx, int ly, int trigger_element, int trigger_event) { int i, x, y; @@ -5334,6 +5263,9 @@ static boolean CheckTriggeredElementChange(int trigger_element, for (y=0; ypush_delay_value = GET_NEW_PUSH_DELAY(element); - CheckTriggeredElementChange(element, CE_OTHER_GETS_PUSHED); + CheckTriggeredElementChange(x, y, element, CE_OTHER_GETS_PUSHED); CheckElementChange(x, y, element, CE_PUSHED_BY_PLAYER); break; } else { - CheckTriggeredElementChange(element, CE_OTHER_GETS_PRESSED); + CheckTriggeredElementChange(x, y, element, CE_OTHER_GETS_PRESSED); CheckElementChange(x, y, element, CE_PRESSED_BY_PLAYER); } diff --git a/src/main.h b/src/main.h index 7e70d87f..255a6475 100644 --- a/src/main.h +++ b/src/main.h @@ -1240,6 +1240,22 @@ struct ElementInfo int content[3][3]; /* new elements after explosion */ struct ElementChangeInfo change; + + /* ---------- internal values used in level editor ---------- */ + + int access_type; /* walkable or passable */ + int access_layer; /* accessible over/inside/under */ + int walk_to_action; /* diggable/collectible/pushable */ + int smash_targets; /* can smash player/enemies/everything */ + int deadliness; /* deadly when running/colliding/touching */ + int consistency; /* indestructible/can explode */ + int change_player_action; /* touched/pressed/pushed by player */ + int change_collide_action; /* collision/impact/smashed */ + int change_other_action; /* various change actions */ + + boolean can_explode_by_fire; /* element explodes by fire */ + boolean can_explode_smashed; /* element explodes when smashed */ + boolean can_explode_impact; /* element explodes on impact */ }; struct FontInfo diff --git a/src/tools.c b/src/tools.c index 97476511..e5d2985a 100644 --- a/src/tools.c +++ b/src/tools.c @@ -846,36 +846,13 @@ void DrawGraphic(int x, int y, int graphic, int frame) MarkTileDirty(x, y); } -#if 0 -void DrawOldGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic) -{ - Bitmap *src_bitmap; - int src_x, src_y; - - getOldGraphicSource(graphic, &src_bitmap, &src_x, &src_y); - BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y); -} -#endif - void DrawGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, int frame) { -#if 1 Bitmap *src_bitmap; int src_x, src_y; getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); -#else - Bitmap *src_bitmap = graphic_info[graphic].bitmap; - int src_x = graphic_info[graphic].src_x; - int src_y = graphic_info[graphic].src_y; - int offset_x = graphic_info[graphic].offset_x; - int offset_y = graphic_info[graphic].offset_y; - - src_x += frame * offset_x; - src_y += frame * offset_y; -#endif - BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y); } @@ -1119,27 +1096,6 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, frame = graphic_info[graphic].anim_frames - 1; } } -#if 0 - else if (IS_AMOEBOID(element) || element == EL_AMOEBA_DROPPING) - { - graphic = (element == EL_BD_AMOEBA ? IMG_BD_AMOEBA_PART1 : - element == EL_AMOEBA_WET ? IMG_AMOEBA_WET_PART1 : - element == EL_AMOEBA_DRY ? IMG_AMOEBA_DRY_PART1 : - element == EL_AMOEBA_FULL ? IMG_AMOEBA_FULL_PART1 : - IMG_AMOEBA_DEAD_PART1); - - graphic += (x + 2 * y + 4) % 4; - } -#endif - -#if 0 - if (IS_AMOEBOID(element) || element == EL_AMOEBA_DROPPING) - { - if (Feld[lx][ly] == EL_AMOEBA_DROPPING) - printf("---> %d -> %d / %d [%d]\n", - element, graphic, frame, GfxRandom[lx][ly]); - } -#endif if (dx || dy) DrawGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, mask_mode); @@ -1169,18 +1125,6 @@ void DrawLevelElementShifted(int x, int y, int dx, int dy, int element, DrawLevelElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING); } -#if 0 -void DrawOldScreenElementThruMask(int x, int y, int element) -{ - DrawOldScreenElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); -} - -void DrawScreenElementThruMask(int x, int y, int element) -{ - DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); -} -#endif - void DrawLevelElementThruMask(int x, int y, int element) { DrawLevelElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); @@ -1225,7 +1169,7 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) int xx = x + xy[i][0]; int yy = y + xy[i][1]; - element = (IN_LEV_FIELD(xx, yy) ? Feld[xx][yy] : EL_STEELWALL); + element = (IN_LEV_FIELD(xx, yy) ? Feld[xx][yy] : BorderElement); /* check if neighbour field is of same type */ if (CAN_BE_CRUMBLED(element) && !IS_MOVING(xx, yy)) @@ -1310,6 +1254,35 @@ void DrawLevelFieldCrumbledSandDigging(int x, int y, int direction, DrawLevelFieldCrumbledSandExt(x, y, graphic2, frame2); } +void DrawLevelFieldCrumbledSandNeighbours(int x, int y) +{ + int sx = SCREENX(x), sy = SCREENY(y); + static int xy[4][2] = + { + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } + }; + int i; + + for(i=0; i<4; i++) + { + int xx = x + xy[i][0]; + int yy = y + xy[i][1]; + int sxx = sx + xy[i][0]; + int syy = sy + xy[i][1]; + + if (!IN_LEV_FIELD(xx, yy) || + !IN_SCR_FIELD(sxx, syy) || + !CAN_BE_CRUMBLED(Feld[xx][yy]) || + IS_MOVING(xx, yy)) + continue; + + DrawLevelField(xx, yy); + } +} + static int getBorderElement(int x, int y) { int border[7][2] = @@ -1485,19 +1458,6 @@ void getMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) int src_x = mini_startx + graphic_info[graphic].src_x / 8; int src_y = mini_starty + graphic_info[graphic].src_y / 8; -#if 0 - if (src_x + MICRO_TILEX > src_bitmap->width || - src_y + MICRO_TILEY > src_bitmap->height) - { - /* graphic of desired size seems not to be contained in this image; - dirty workaround: get it from the middle of the normal sized image */ - - getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); - src_x += (TILEX / 2 - MICRO_TILEX / 2); - src_y += (TILEY / 2 - MICRO_TILEY / 2); - } -#endif - *bitmap = src_bitmap; *x = src_x; *y = src_y; diff --git a/src/tools.h b/src/tools.h index 2dae59b5..e7a65872 100644 --- a/src/tools.h +++ b/src/tools.h @@ -104,6 +104,7 @@ void DrawLevelElementThruMask(int, int, int); void DrawLevelFieldThruMask(int, int); void DrawLevelFieldCrumbledSand(int, int); void DrawLevelFieldCrumbledSandDigging(int, int, int, int); +void DrawLevelFieldCrumbledSandNeighbours(int, int); void DrawScreenElement(int, int, int); void DrawLevelElement(int, int, int); void DrawScreenField(int, int); -- 2.34.1