From: Holger Schemel Date: Fri, 25 Nov 2005 16:56:40 +0000 (+0100) Subject: rnd-20051125-1-src X-Git-Tag: 3.1.2^2~49 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=9b360b977c0c1988c9a9bd63bb6d3f3991d1a650;p=rocksndiamonds.git rnd-20051125-1-src --- diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 9aa3e6bb..66b5af44 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -4161,6 +4161,10 @@ struct ConfigInfo image_config[] = { "background.EDITOR", UNDEFINED_FILENAME }, { "background.INFO", UNDEFINED_FILENAME }, { "background.INFO[ELEMENTS]", UNDEFINED_FILENAME }, + { "background.INFO[MUSIC]", UNDEFINED_FILENAME }, + { "background.INFO[CREDITS]", UNDEFINED_FILENAME }, + { "background.INFO[PROGRAM]", UNDEFINED_FILENAME }, + { "background.INFO[LEVELSET]", UNDEFINED_FILENAME }, { "background.SETUP", UNDEFINED_FILENAME }, { "background.DOOR", UNDEFINED_FILENAME }, diff --git a/src/conf_gfx.h b/src/conf_gfx.h index 2d2cc45f..191d0538 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -1495,9 +1495,13 @@ #define IMG_BACKGROUND_EDITOR 1474 #define IMG_BACKGROUND_INFO 1475 #define IMG_BACKGROUND_INFO_ELEMENTS 1476 -#define IMG_BACKGROUND_SETUP 1477 -#define IMG_BACKGROUND_DOOR 1478 +#define IMG_BACKGROUND_INFO_MUSIC 1477 +#define IMG_BACKGROUND_INFO_CREDITS 1478 +#define IMG_BACKGROUND_INFO_PROGRAM 1479 +#define IMG_BACKGROUND_INFO_LEVELSET 1480 +#define IMG_BACKGROUND_SETUP 1481 +#define IMG_BACKGROUND_DOOR 1482 -#define NUM_IMAGE_FILES 1479 +#define NUM_IMAGE_FILES 1483 #endif /* CONF_GFX_H */ diff --git a/src/conftime.h b/src/conftime.h index ab6708a4..9c17eddb 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2005-11-22 23:49]" +#define COMPILE_DATE_STRING "[2005-11-25 10:58]" diff --git a/src/editor.c b/src/editor.c index 9e3f01e5..2558453c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -556,7 +556,7 @@ #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_USE_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 36) +#define GADGET_ID_CHANGE_HAS_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) @@ -768,7 +768,7 @@ #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_CHECKBUTTON_ID_CHANGE_HAS_ACTION 37 #define ED_NUM_CHECKBUTTONS 38 @@ -783,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_ACTION +#define ED_CHECKBUTTON_ID_CHANGE_LAST ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION /* values for radiobutton gadgets */ #define ED_RADIOBUTTON_ID_PERCENTAGE 0 @@ -2366,8 +2366,8 @@ static struct }, { ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13), - GADGET_ID_CHANGE_USE_ACTION, GADGET_ID_NONE, - &custom_element_change.use_action, + GADGET_ID_CHANGE_HAS_ACTION, GADGET_ID_NONE, + &custom_element_change.has_action, NULL, NULL, "execute action on specified condition" }, }; diff --git a/src/files.c b/src/files.c index 8d3cbc99..f5275728 100644 --- a/src/files.c +++ b/src/files.c @@ -114,7 +114,7 @@ void setElementChangeInfoToDefaults(struct ElementChangeInfo *change) change->random_percentage = 100; change->replace_when = CP_WHEN_EMPTY; - change->use_action = FALSE; + change->has_action = FALSE; change->action_type = CA_NO_ACTION; change->action_mode = CA_MODE_UNDEFINED; change->action_arg = CA_ARG_UNDEFINED; @@ -1307,7 +1307,7 @@ static int LoadLevel_CUS4(FILE *file, int chunk_size, struct LevelInfo *level) CH_PAGE_ANY : (1 << change->trigger_page)); #if 1 - change->use_action = getFile8Bit(file); + change->has_action = getFile8Bit(file); change->action_type = getFile8Bit(file); change->action_mode = getFile8Bit(file); change->action_arg = getFile16BitBE(file); @@ -3411,7 +3411,7 @@ static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element) #if 1 - putFile8Bit(file, change->use_action); + putFile8Bit(file, change->has_action); putFile8Bit(file, change->action_type); putFile8Bit(file, change->action_mode); putFile16BitBE(file, change->action_arg); diff --git a/src/game.c b/src/game.c index d8039785..23667a16 100644 --- a/src/game.c +++ b/src/game.c @@ -60,6 +60,8 @@ #define USE_BACK_WALKABLE_BUGFIX (TRUE * USE_NEW_STUFF * 1) +#define TEST_NEW_STUFF (TRUE) + /* for DigField() */ #define DF_NO_PUSH 0 @@ -369,9 +371,9 @@ static boolean CheckElementChangeExt(int, int, int, int, int, int, int, int); #define CheckElementChange(x, y, e, te, ev) \ CheckElementChangeExt(x, y, e, te, ev, CH_PLAYER_ANY, CH_SIDE_ANY, -1) #define CheckElementChangeByPlayer(x, y, e, ev, p, s) \ - CheckElementChangeExt(x, y, e, EL_EMPTY, ev, p, s, CH_PAGE_ANY) + CheckElementChangeExt(x, y, e, EL_EMPTY, ev, p, s, -1) #define CheckElementChangeBySide(x, y, e, te, ev, s) \ - CheckElementChangeExt(x, y, e, te, ev, CH_PLAYER_ANY, s, CH_PAGE_ANY) + CheckElementChangeExt(x, y, e, te, ev, CH_PLAYER_ANY, s, -1) #define CheckElementChangeByPage(x, y, e, te, ev, p) \ CheckElementChangeExt(x, y, e, te, ev, CH_PLAYER_ANY, CH_SIDE_ANY, p) @@ -1493,6 +1495,20 @@ static void InitGameEngine() } #endif + /* ---------- initialize internal run-time variables ------------- */ + + for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) + { + struct ElementInfo *ei = &element_info[EL_CUSTOM_START + i]; + + for (j = 0; j < ei->num_change_pages; j++) + { + ei->change_page[j].can_change_or_has_action = + (ei->change_page[j].can_change | + ei->change_page[j].has_action); + } + } + /* ---------- initialize run-time trigger player and element ------------- */ for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) @@ -7907,6 +7923,9 @@ static void ExecuteCustomElementAction(int element, int page) int action_arg = change->action_arg; int i; + if (!change->has_action) + return; + /* ---------- determine action paramater values ---------- */ int action_arg_element = @@ -8264,7 +8283,7 @@ static void ChangeElementNowExt(struct ElementChangeInfo *change, #endif #if 0 - if (change->use_action) + if (change->has_action) ExecuteCustomElementAction(...); #endif } @@ -8557,8 +8576,8 @@ static void ChangeElement(int x, int y, int page) return; } -#if 1 - if (change->use_action) +#if 0 + if (change->has_action) ExecuteCustomElementAction(element, page); #endif @@ -8587,17 +8606,19 @@ static boolean CheckTriggeredElementChangeExt(int lx, int ly, { int element = EL_CUSTOM_START + i; + boolean change_found = FALSE; boolean change_element = FALSE; int page = 0; - if (!CAN_CHANGE(element) || !HAS_ANY_CHANGE_EVENT(element, trigger_event)) + if (!CAN_CHANGE_OR_HAS_ACTION(element) || + !HAS_ANY_CHANGE_EVENT(element, trigger_event)) continue; for (j = 0; j < element_info[element].num_change_pages; j++) { struct ElementChangeInfo *change = &element_info[element].change_page[j]; - if (change->can_change && + if (change->can_change_or_has_action && change->has_event[trigger_event] && change->trigger_side & trigger_side && change->trigger_player & trigger_player && @@ -8610,6 +8631,28 @@ static boolean CheckTriggeredElementChangeExt(int lx, int ly, trigger_element-EL_CUSTOM_START+1, i+1, j, trigger_event); #endif +#if 1 + change->actual_trigger_element = trigger_element; + change->actual_trigger_player = EL_PLAYER_1 + log_2(trigger_player); + + if (change->can_change && !change_found) + { + change_found = TRUE; + + for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++) + { + if (Feld[x][y] == element) + { + ChangeDelay[x][y] = 1; + ChangeEvent[x][y] = trigger_event; + ChangeElement(x, y, j); + } + } + } + + if (change->has_action) + ExecuteCustomElementAction(element, j); +#else change_element = TRUE; page = j; @@ -8617,9 +8660,11 @@ static boolean CheckTriggeredElementChangeExt(int lx, int ly, change->actual_trigger_player = EL_PLAYER_1 + log_2(trigger_player); break; +#endif } } +#if 0 if (!change_element) continue; @@ -8637,6 +8682,7 @@ static boolean CheckTriggeredElementChangeExt(int lx, int ly, ChangeElement(x, y, page); } } +#endif } return TRUE; @@ -8673,6 +8719,103 @@ static boolean CheckElementChangeExt(int x, int y, } #endif +#if 1 + if (trigger_page < 0) + { + boolean change_element = FALSE; + int i; + + for (i = 0; i < element_info[element].num_change_pages; i++) + { + struct ElementChangeInfo *change = &element_info[element].change_page[i]; + + boolean check_trigger_element = + (trigger_event == CE_TOUCHING_X || + trigger_event == CE_HITTING_X || + trigger_event == CE_HIT_BY_X); + + if (change->can_change && + change->has_event[trigger_event] && + change->trigger_side & trigger_side && + change->trigger_player & trigger_player +#if 1 + && + (!check_trigger_element || + IS_EQUAL_OR_IN_GROUP(trigger_element, change->trigger_element)) +#endif + ) + { + change_element = TRUE; + trigger_page = i; + + change->actual_trigger_element = trigger_element; + change->actual_trigger_player = EL_PLAYER_1 + log_2(trigger_player); + + break; + } + } + + if (!change_element) + return FALSE; + } + else + { + struct ElementInfo *ei = &element_info[element]; + struct ElementChangeInfo *change = &ei->change_page[trigger_page]; + + change->actual_trigger_element = trigger_element; + change->actual_trigger_player = EL_PLAYER_1; /* unused */ + } + +#else + + /* !!! this check misses pages with same event, but different side !!! */ + + if (trigger_page < 0) + trigger_page = element_info[element].event_page_nr[trigger_event]; + + if (!(element_info[element].change_page[trigger_page].trigger_side & trigger_side)) + return FALSE; +#endif + + ChangeDelay[x][y] = 1; + ChangeEvent[x][y] = trigger_event; + ChangeElement(x, y, trigger_page); + + return TRUE; +} + +static boolean CheckElementChangeExtTEST(int x, int y, + int element, + int trigger_element, + int trigger_event, + int trigger_player, + int trigger_side, + int trigger_page) +{ + if (!CAN_CHANGE(element) || !HAS_ANY_CHANGE_EVENT(element, trigger_event)) + return FALSE; + + if (Feld[x][y] == EL_BLOCKED) + { + Blocked2Moving(x, y, &x, &y); + element = Feld[x][y]; + } + +#if 1 + if (Feld[x][y] != element) /* check if element has already changed */ + { +#if 0 + printf("::: %d ('%s') != %d ('%s') [%d]\n", + Feld[x][y], element_info[Feld[x][y]].token_name, + element, element_info[element].token_name, + trigger_event); +#endif + + return FALSE; + } +#endif + #if 1 if (trigger_page < 0) { @@ -8686,7 +8829,8 @@ static boolean CheckElementChangeExt(int x, int y, if (change->can_change && change->has_event[trigger_event] && change->trigger_side & trigger_side && - change->trigger_player & trigger_player) + change->trigger_player & trigger_player && + IS_EQUAL_OR_IN_GROUP(trigger_element, change->trigger_element)) { change_element = TRUE; trigger_page = i; @@ -11043,6 +11187,18 @@ void TestIfElementTouchesCustomElement(int x, int y) else continue; /* center and border element do not touch */ +#if TEST_NEW_STUFF + + /* check for change of center element (but change it only once) */ + if (!change_center_element) + change_center_element = + CheckElementChangeBySide(x, y, center_element, border_element, + CE_TOUCHING_X, border_side); + + /* -> CheckElementChangeExtTEST */ + +#else + /* check for change of center element (but change it only once) */ if (IS_CUSTOM_ELEMENT(center_element) && HAS_ANY_CHANGE_EVENT(center_element, CE_TOUCHING_X) && @@ -11072,6 +11228,16 @@ void TestIfElementTouchesCustomElement(int x, int y) } } +#endif + +#if TEST_NEW_STUFF + + /* check for change of border element */ + CheckElementChangeBySide(xx, yy, border_element, center_element, + CE_TOUCHING_X, center_side); + +#else + /* check for change of border element */ if (IS_CUSTOM_ELEMENT(border_element) && HAS_ANY_CHANGE_EVENT(border_element, CE_TOUCHING_X)) @@ -11101,8 +11267,13 @@ void TestIfElementTouchesCustomElement(int x, int y) } } } + +#endif + } +#if !TEST_NEW_STUFF + if (change_center_element) { #if 0 @@ -11112,6 +11283,9 @@ void TestIfElementTouchesCustomElement(int x, int y) CheckElementChangeByPage(x, y, center_element, border_trigger_element, CE_TOUCHING_X, center_element_change_page); } + +#endif + } void TestIfElementHitsCustomElement(int x, int y, int direction) @@ -11171,6 +11345,13 @@ void TestIfElementHitsCustomElement(int x, int y, int direction) CE_HIT_BY_SOMETHING, opposite_direction); #endif +#if TEST_NEW_STUFF + + CheckElementChangeBySide(x, y, hitting_element, touched_element, + CE_HITTING_X, touched_side); + +#else + if (IS_CUSTOM_ELEMENT(hitting_element) && HAS_ANY_CHANGE_EVENT(hitting_element, CE_HITTING_X)) { @@ -11197,6 +11378,14 @@ void TestIfElementHitsCustomElement(int x, int y, int direction) } } +#endif + +#if TEST_NEW_STUFF + + CheckElementChangeBySide(hitx, hity, touched_element, + hitting_element, CE_HIT_BY_X, hitting_side); +#else + if (IS_CUSTOM_ELEMENT(touched_element) && HAS_ANY_CHANGE_EVENT(touched_element, CE_HIT_BY_X)) { @@ -11222,6 +11411,8 @@ void TestIfElementHitsCustomElement(int x, int y, int direction) } } +#endif + #if USE_HIT_BY_SOMETHING_BUGFIX CheckElementChangeBySide(hitx, hity, touched_element, hitting_element, CE_HIT_BY_SOMETHING, opposite_direction); @@ -11289,6 +11480,12 @@ void TestIfElementSmashesCustomElement(int x, int y, int direction) CheckElementChangeBySide(hitx, hity, touched_element, hitting_element, CE_SMASHED_BY_SOMETHING, opposite_direction); +#if TEST_NEW_STUFF + + CheckElementChangeBySide(x, y, hitting_element, touched_element, + CE_OTHER_IS_SMASHING, touched_side); +#else + if (IS_CUSTOM_ELEMENT(hitting_element) && HAS_ANY_CHANGE_EVENT(hitting_element, CE_OTHER_IS_SMASHING)) { @@ -11315,6 +11512,14 @@ void TestIfElementSmashesCustomElement(int x, int y, int direction) } } +#endif + +#if TEST_NEW_STUFF + + CheckElementChangeBySide(hitx, hity, touched_element, hitting_element, + CE_OTHER_GETS_SMASHED, hitting_side); +#else + if (IS_CUSTOM_ELEMENT(touched_element) && HAS_ANY_CHANGE_EVENT(touched_element, CE_OTHER_GETS_SMASHED)) { @@ -11339,6 +11544,9 @@ void TestIfElementSmashesCustomElement(int x, int y, int direction) } } } + +#endif + } } } diff --git a/src/init.c b/src/init.c index 60f11d76..9fcad891 100644 --- a/src/init.c +++ b/src/init.c @@ -3952,9 +3952,13 @@ void InitElementPropertiesEngine(int engine_version) /* ---------- HAS_ACTION ----------------------------------------------- */ SET_PROPERTY(i, EP_HAS_ACTION, FALSE); /* default: has no action */ for (j = 0; j < element_info[i].num_change_pages; j++) - if (element_info[i].change_page[j].use_action) + if (element_info[i].change_page[j].has_action) SET_PROPERTY(i, EP_HAS_ACTION, TRUE); + /* ---------- CAN_CHANGE_OR_HAS_ACTION --------------------------------- */ + SET_PROPERTY(i, EP_CAN_CHANGE_OR_HAS_ACTION, (CAN_CHANGE(i) || + HAS_ACTION(i))); + /* ---------- GFX_CRUMBLED --------------------------------------------- */ #if 1 SET_PROPERTY(i, EP_GFX_CRUMBLED, diff --git a/src/main.h b/src/main.h index c8aca94a..fcfbf320 100644 --- a/src/main.h +++ b/src/main.h @@ -157,8 +157,9 @@ /* values for internal purpose only (game engine) */ #define EP_HAS_ACTION 83 +#define EP_CAN_CHANGE_OR_HAS_ACTION 84 -#define NUM_ELEMENT_PROPERTIES 84 +#define NUM_ELEMENT_PROPERTIES 85 #define NUM_EP_BITFIELDS ((NUM_ELEMENT_PROPERTIES + 31) / 32) #define EP_BITFIELD_BASE 0 @@ -510,6 +511,8 @@ #define COULD_MOVE_INTO_ACID(e) HAS_PROPERTY(e, EP_COULD_MOVE_INTO_ACID) #define MAYBE_DONT_COLLIDE_WITH(e) HAS_PROPERTY(e, EP_MAYBE_DONT_COLLIDE_WITH) #define HAS_ACTION(e) HAS_PROPERTY(e, EP_HAS_ACTION) +#define CAN_CHANGE_OR_HAS_ACTION(e) \ + HAS_PROPERTY(e, EP_CAN_CHANGE_OR_HAS_ACTION) /* special macros used in game engine */ #define IS_CUSTOM_ELEMENT(e) ((e) >= EL_CUSTOM_START && \ @@ -1918,7 +1921,7 @@ struct ElementChangeInfo boolean explode; /* explode instead of change */ - boolean use_action; /* execute action on specified condition */ + boolean has_action; /* execute action on specified condition */ int action_type; /* type of action */ int action_mode; /* mode of action */ int action_arg; /* parameter of action */ @@ -1934,6 +1937,8 @@ struct ElementChangeInfo short actual_trigger_element; /* element that actually triggered change */ int actual_trigger_player; /* player which actually triggered change */ + boolean can_change_or_has_action; /* can_change | has_action */ + /* ---------- internal values used in level editor ---------- */ int direct_action; /* change triggered by actions on element */ diff --git a/src/screens.c b/src/screens.c index c8bcf368..43a9b607 100644 --- a/src/screens.c +++ b/src/screens.c @@ -750,7 +750,10 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init) for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++) infoscreen_step[i] = infoscreen_frame[i] = 0; +#if 0 SetMainBackgroundImage(IMG_BACKGROUND_INFO); +#endif + ClearWindow(); DrawHeadline(); @@ -896,6 +899,8 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) void DrawInfoScreen_Elements() { + SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS); + LoadHelpAnimInfo(); LoadHelpTextInfo(); @@ -971,6 +976,8 @@ void HandleInfoScreen_Elements(int button) void DrawInfoScreen_Music() { + SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC); + ClearWindow(); DrawHeadline(); @@ -1103,6 +1110,8 @@ void DrawInfoScreen_Credits() int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; + SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS); + FadeSoundsAndMusic(); ClearWindow(); @@ -1151,6 +1160,8 @@ void DrawInfoScreen_Program() int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; + SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM); + ClearWindow(); DrawHeadline(); @@ -1228,6 +1239,8 @@ void DrawInfoScreen_LevelSet() int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width; int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1; + SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET); + ClearWindow(); DrawHeadline(); diff --git a/src/tools.c b/src/tools.c index eedf5d60..883a670f 100644 --- a/src/tools.c +++ b/src/tools.c @@ -425,6 +425,12 @@ void FadeToFront() BackToFront(); } +void SetMainBackgroundImageIfDefined(int graphic) +{ + if (graphic_info[graphic].bitmap) + SetMainBackgroundImage(graphic); +} + void SetMainBackgroundImage(int graphic) { SetMainBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL : diff --git a/src/tools.h b/src/tools.h index f41b0f83..8d288b8a 100644 --- a/src/tools.h +++ b/src/tools.h @@ -65,6 +65,7 @@ void RedrawPlayfield(boolean, int, int, int, int); void BackToFront(); void FadeToFront(); void ClearWindow(); +void SetMainBackgroundImageIfDefined(int); void SetMainBackgroundImage(int); void SetDoorBackgroundImage(int); void DrawBackground(int, int, int, int);