From: Holger Schemel Date: Sun, 26 Jun 2005 18:16:43 +0000 (+0200) Subject: rnd-20050626-1-src X-Git-Tag: 3.1.1^2~7 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=098ef036131fbf9cdcd77d1b985abae78df7cb3c;p=rocksndiamonds.git rnd-20050626-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 1e306b0f..e4df14d9 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2005-06-16 20:25]" +#define COMPILE_DATE_STRING "[2005-06-26 20:02]" diff --git a/src/files.c b/src/files.c index 66860dca..1ed2f7de 100644 --- a/src/files.c +++ b/src/files.c @@ -88,11 +88,12 @@ void setElementChangePages(struct ElementInfo *ei, int change_pages) void setElementChangeInfoToDefaults(struct ElementChangeInfo *change) { - int x, y; + int i, x, y; change->can_change = FALSE; - change->events = CE_BITMASK_DEFAULT; + for (i = 0; i < NUM_CHANGE_EVENTS; i++) + change->has_event[i] = FALSE; change->trigger_player = CH_PLAYER_ANY; change->trigger_side = CH_SIDE_ANY; @@ -1090,6 +1091,7 @@ static int LoadLevel_CUS3(FILE *file, int chunk_size, struct LevelInfo *level) for (i = 0; i < num_changed_custom_elements; i++) { int element = getFile16BitBE(file); + unsigned long event_bits; if (!IS_CUSTOM_ELEMENT(element)) { @@ -1128,7 +1130,10 @@ static int LoadLevel_CUS3(FILE *file, int chunk_size, struct LevelInfo *level) element_info[element].content[x][y] = getMappedElement(getFile16BitBE(file)); - element_info[element].change->events = getFile32BitBE(file); + event_bits = getFile32BitBE(file); + for (j = 0; j < NUM_CHANGE_EVENTS; j++) + if (event_bits & (1 << j)) + element_info[element].change->has_event[j] = TRUE; element_info[element].change->target_element = getMappedElement(getFile16BitBE(file)); @@ -1170,7 +1175,7 @@ static int LoadLevel_CUS4(FILE *file, int chunk_size, struct LevelInfo *level) struct ElementInfo *ei; int chunk_size_expected; int element; - int i, x, y; + int i, j, x, y; element = getFile16BitBE(file); @@ -1252,11 +1257,15 @@ static int LoadLevel_CUS4(FILE *file, int chunk_size, struct LevelInfo *level) for (i = 0; i < ei->num_change_pages; i++) { struct ElementChangeInfo *change = &ei->change_page[i]; + unsigned long event_bits; /* always start with reliable default values */ setElementChangeInfoToDefaults(change); - change->events = getFile32BitBE(file); + event_bits = getFile32BitBE(file); + for (j = 0; j < NUM_CHANGE_EVENTS; j++) + if (event_bits & (1 << j)) + change->has_event[j] = TRUE; change->target_element = getMappedElement(getFile16BitBE(file)); @@ -3269,7 +3278,7 @@ static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level, static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element) { struct ElementInfo *ei = &element_info[element]; - int i, x, y; + int i, j, x, y; putFile16BitBE(file, element); @@ -3331,8 +3340,13 @@ static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element) for (i = 0; i < ei->num_change_pages; i++) { struct ElementChangeInfo *change = &ei->change_page[i]; + unsigned long event_bits = 0; + + for (j = 0; j < NUM_CHANGE_EVENTS; j++) + if (change->has_event[j]) + event_bits |= (1 << j); - putFile32BitBE(file, change->events); + putFile32BitBE(file, event_bits); putFile16BitBE(file, change->target_element); diff --git a/src/game.c b/src/game.c index a383c690..ed511ad6 100644 --- a/src/game.c +++ b/src/game.c @@ -28,26 +28,28 @@ #define USE_NEW_AMOEBA_CODE FALSE /* EXPERIMENTAL STUFF */ -#define USE_NEW_STUFF (TRUE * 1) +#define USE_NEW_STUFF (TRUE * 1) -#define USE_NEW_MOVE_STYLE (TRUE * USE_NEW_STUFF * 1) -#define USE_NEW_MOVE_DELAY (TRUE * USE_NEW_STUFF * 1) -#define USE_NEW_PUSH_DELAY (TRUE * USE_NEW_STUFF * 1) -#define USE_NEW_BLOCK_STYLE (TRUE * USE_NEW_STUFF * 1) -#define USE_NEW_SP_SLIPPERY (TRUE * USE_NEW_STUFF * 1) -#define USE_NEW_RANDOMIZE (TRUE * USE_NEW_STUFF * 1) +#define USE_NEW_MOVE_STYLE (TRUE * USE_NEW_STUFF * 1) +#define USE_NEW_MOVE_DELAY (TRUE * USE_NEW_STUFF * 1) +#define USE_NEW_PUSH_DELAY (TRUE * USE_NEW_STUFF * 1) +#define USE_NEW_BLOCK_STYLE (TRUE * USE_NEW_STUFF * 1) +#define USE_NEW_SP_SLIPPERY (TRUE * USE_NEW_STUFF * 1) +#define USE_NEW_RANDOMIZE (TRUE * USE_NEW_STUFF * 1) -#define USE_CAN_MOVE_NOT_MOVING (TRUE * USE_NEW_STUFF * 1) -#define USE_PREVIOUS_MOVE_DIR (TRUE * USE_NEW_STUFF * 1) +#define USE_CAN_MOVE_NOT_MOVING (TRUE * USE_NEW_STUFF * 1) +#define USE_PREVIOUS_MOVE_DIR (TRUE * USE_NEW_STUFF * 1) -#define USE_PUSH_BUGFIX (TRUE * USE_NEW_STUFF * 1) +#define USE_PUSH_BUGFIX (TRUE * USE_NEW_STUFF * 1) #if 0 -#define USE_BLOCK_DELAY_BUGFIX (TRUE * USE_NEW_STUFF * 1) +#define USE_BLOCK_DELAY_BUGFIX (TRUE * USE_NEW_STUFF * 1) #endif -#define USE_GRAVITY_BUGFIX_NEW (TRUE * USE_NEW_STUFF * 1) -#define USE_GRAVITY_BUGFIX_OLD (TRUE * USE_NEW_STUFF * 0) +#define USE_GRAVITY_BUGFIX_NEW (TRUE * USE_NEW_STUFF * 1) +#define USE_GRAVITY_BUGFIX_OLD (TRUE * USE_NEW_STUFF * 0) -#define USE_PENGUIN_COLLECT_BUG (TRUE * USE_NEW_STUFF * 1) +#define USE_PENGUIN_COLLECT_BUGFIX (TRUE * USE_NEW_STUFF * 1) + +#define USE_IMPACT_BUGFIX (TRUE * USE_NEW_STUFF * 1) /* for DigField() */ @@ -672,10 +674,9 @@ access_direction_list[] = { EL_UNDEFINED, MV_NO_MOVING } }; -static unsigned long trigger_events[MAX_NUM_ELEMENTS]; +static boolean trigger_events[MAX_NUM_ELEMENTS][NUM_CHANGE_EVENTS]; -#define IS_AUTO_CHANGING(e) (element_info[e].change_events & \ - CH_EVENT_BIT(CE_DELAY)) +#define IS_AUTO_CHANGING(e) (element_info[e].has_change_event[CE_DELAY]) #define IS_JUST_CHANGING(x, y) (ChangeDelay[x][y] != 0) #define IS_CHANGING(x, y) (IS_AUTO_CHANGING(Feld[x][y]) || \ IS_JUST_CHANGING(x, y)) @@ -1269,7 +1270,7 @@ static void resolve_group_element(int group_element, int recursion_depth) static void InitGameEngine() { - int i, j, k; + int i, j, k, l; /* set game engine from tape file when re-playing, else from level file */ game.engine_version = (tape.playing ? tape.engine_version : @@ -1408,9 +1409,10 @@ static void InitGameEngine() ei->change->delay_frames = 1; } - ei->change_events = CE_BITMASK_DEFAULT; for (j = 0; j < NUM_CHANGE_EVENTS; j++) { + ei->has_change_event[j] = FALSE; + ei->event_page_nr[j] = 0; ei->event_page[j] = &ei->change_page[0]; } @@ -1429,7 +1431,7 @@ static void InitGameEngine() ei->change->change_function = ch_delay->change_function; ei->change->post_change_function = ch_delay->post_change_function; - ei->change_events |= CH_EVENT_BIT(CE_DELAY); + ei->has_change_event[CE_DELAY] = TRUE; #if 1 SET_PROPERTY(ch_delay->element, EP_CAN_CHANGE, TRUE); @@ -1450,10 +1452,10 @@ static void InitGameEngine() for (k = 0; k < NUM_CHANGE_EVENTS; k++) { /* only add event page for the first page found with this event */ - if (ei->change_page[j].events & CH_EVENT_BIT(k) && - !(ei->change_events & CH_EVENT_BIT(k))) + if (ei->change_page[j].has_event[k] && !(ei->has_change_event[k])) { - ei->change_events |= CH_EVENT_BIT(k); + ei->has_change_event[k] = TRUE; + ei->event_page_nr[k] = j; ei->event_page[k] = &ei->change_page[j]; } @@ -1470,7 +1472,7 @@ static void InitGameEngine() /* only add custom elements that change after fixed/random frame delay */ if (CAN_CHANGE(element) && HAS_CHANGE_EVENT(element, CE_DELAY)) - element_info[element].change_events |= CH_EVENT_BIT(CE_DELAY); + element_info[element].has_change_event[CE_DELAY] = TRUE; } #endif @@ -1491,7 +1493,8 @@ static void InitGameEngine() /* initialize trigger events information */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) - trigger_events[i] = EP_BITMASK_DEFAULT; + for (j = 0; j < NUM_CHANGE_EVENTS; j++) + trigger_events[i][j] = FALSE; #if 1 /* add trigger events from element change event properties */ @@ -1504,20 +1507,26 @@ static void InitGameEngine() if (!ei->change_page[j].can_change) continue; - if (ei->change_page[j].events & CH_EVENT_BIT(CE_BY_OTHER_ACTION)) + if (ei->change_page[j].has_event[CE_BY_OTHER_ACTION]) { int trigger_element = ei->change_page[j].trigger_element; - if (IS_GROUP_ELEMENT(trigger_element)) + for (k = 0; k < NUM_CHANGE_EVENTS; k++) { - struct ElementGroupInfo *group = element_info[trigger_element].group; + if (ei->change_page[j].has_event[k]) + { + if (IS_GROUP_ELEMENT(trigger_element)) + { + struct ElementGroupInfo *group = + element_info[trigger_element].group; - for (k = 0; k < group->num_elements_resolved; k++) - trigger_events[group->element_resolved[k]] - |= ei->change_page[j].events; + for (l = 0; l < group->num_elements_resolved; l++) + trigger_events[group->element_resolved[l]][k] = TRUE; + } + else + trigger_events[trigger_element][k] = TRUE; + } } - else - trigger_events[trigger_element] |= ei->change_page[j].events; } } } @@ -1525,8 +1534,9 @@ static void InitGameEngine() /* add trigger events from element change event properties */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) if (HAS_CHANGE_EVENT(i, CE_BY_OTHER_ACTION)) - trigger_events[element_info[i].change->trigger_element] |= - element_info[i].change->events; + for (j = 0; j < NUM_CHANGE_EVENTS; j++) + if (element_info[i].change->has_event[j]) + trigger_events[element_info[i].change->trigger_element][j] = TRUE; #endif /* ---------- initialize push delay -------------------------------------- */ @@ -1857,8 +1867,8 @@ void InitGame() Stop[x][y] = FALSE; Pushed[x][y] = FALSE; - Changed[x][y] = CE_BITMASK_DEFAULT; - ChangeEvent[x][y] = CE_BITMASK_DEFAULT; + Changed[x][y] = FALSE; + ChangeEvent[x][y] = -1; ExplodePhase[x][y] = 0; ExplodeDelay[x][y] = 0; @@ -5561,6 +5571,15 @@ void StartMoving(int x, int y) else if ((game.engine_version >= VERSION_IDENT(3,1,0,0) && CheckCollision[x][y] && !IS_FREE(x, y + 1)) || +#if USE_IMPACT_BUGFIX + (game.engine_version >= VERSION_IDENT(3,0,7,0) && + CAN_FALL(element) && WasJustFalling[x][y] && + (Feld[x][y + 1] == EL_BLOCKED || IS_PLAYER(x, y + 1))) || + + (game.engine_version < VERSION_IDENT(2,2,0,7) && + CAN_FALL(element) && WasJustMoving[x][y] && !Pushed[x][y + 1] && + (Feld[x][y + 1] == EL_BLOCKED))) +#else (game.engine_version >= VERSION_IDENT(3,0,7,0) && CAN_SMASH(element) && WasJustFalling[x][y] && (Feld[x][y + 1] == EL_BLOCKED || IS_PLAYER(x, y + 1))) || @@ -5568,6 +5587,7 @@ void StartMoving(int x, int y) (game.engine_version < VERSION_IDENT(2,2,0,7) && CAN_SMASH(element) && WasJustMoving[x][y] && !Pushed[x][y + 1] && (Feld[x][y + 1] == EL_BLOCKED))) +#endif #else #if 1 @@ -6565,8 +6585,8 @@ void ContinueMoving(int x, int y) ChangeDelay[x][y] = 0; ChangePage[x][y] = -1; - Changed[x][y] = CE_BITMASK_DEFAULT; - ChangeEvent[x][y] = CE_BITMASK_DEFAULT; + Changed[x][y] = FALSE; + ChangeEvent[x][y] = -1; /* copy animation control values to new field */ GfxFrame[newx][newy] = GfxFrame[x][y]; @@ -6731,7 +6751,7 @@ void ContinueMoving(int x, int y) /* give the player one last chance (one more frame) to move away */ if (CAN_FALL(element) && direction == MV_DOWN && (newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1)) && - (!IS_PLAYER(x, newy + 1) || + ((newy < lev_fieldy - 1 && !IS_PLAYER(x, newy + 1)) || game.engine_version < VERSION_IDENT(3,1,1,0))) Impact(x, newy); #else @@ -6824,7 +6844,7 @@ void ContinueMoving(int x, int y) &element_info[hitting_element].change_page[i]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_IS_HITTING) && + change->has_event[CE_OTHER_IS_HITTING] && change->trigger_side & touched_side && change->trigger_element == touched_element) { @@ -6844,7 +6864,7 @@ void ContinueMoving(int x, int y) &element_info[touched_element].change_page[i]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_GETS_HIT) && + change->has_event[CE_OTHER_GETS_HIT] && change->trigger_side & hitting_side && change->trigger_element == hitting_element) { @@ -7879,6 +7899,8 @@ static void ChangeElementNowExt(int x, int y, int target_element) RelocatePlayer(x, y, target_element); #if 1 + Changed[x][y] = TRUE; /* ignore all further changes in this frame */ +#else Changed[x][y] |= ChangeEvent[x][y]; /* ignore same changes in this frame */ #endif @@ -7896,26 +7918,31 @@ static boolean ChangeElementNow(int x, int y, int element, int page) int old_element = Feld[x][y]; /* always use default change event to prevent running into a loop */ - if (ChangeEvent[x][y] == CE_BITMASK_DEFAULT) - ChangeEvent[x][y] = CH_EVENT_BIT(CE_DELAY); + if (ChangeEvent[x][y] == -1) + ChangeEvent[x][y] = CE_DELAY; - if (ChangeEvent[x][y] == CH_EVENT_BIT(CE_DELAY)) + if (ChangeEvent[x][y] == CE_DELAY) { /* reset actual trigger element and player */ change->actual_trigger_element = EL_EMPTY; change->actual_trigger_player = EL_PLAYER_1; } - /* do not change already changed elements with same change event */ -#if 0 - if (Changed[x][y] & ChangeEvent[x][y]) +#if 1 + /* do not change any elements that have already changed in this frame */ + if (Changed[x][y]) return FALSE; #else - if (Changed[x][y]) + /* do not change already changed elements with same change event */ + if (Changed[x][y] & ChangeEvent[x][y]) return FALSE; #endif +#if 1 + Changed[x][y] = TRUE; /* ignore all further changes in this frame */ +#else Changed[x][y] |= ChangeEvent[x][y]; /* ignore same changes in this frame */ +#endif #if 0 /* !!! indirect change before direct change !!! */ @@ -8186,7 +8213,7 @@ static boolean CheckTriggeredElementChangeExt(int lx, int ly, int i, j, x, y; int trigger_page_bits = (trigger_page < 0 ? CH_PAGE_ANY : 1 << trigger_page); - if (!(trigger_events[trigger_element] & CH_EVENT_BIT(trigger_event))) + if (!(trigger_events[trigger_element][trigger_event])) return FALSE; for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) @@ -8204,14 +8231,14 @@ static boolean CheckTriggeredElementChangeExt(int lx, int ly, struct ElementChangeInfo *change = &element_info[element].change_page[j]; if (change->can_change && - change->events & CH_EVENT_BIT(trigger_event) && + change->has_event[trigger_event] && change->trigger_side & trigger_side && change->trigger_player & trigger_player && change->trigger_page & trigger_page_bits && IS_EQUAL_OR_IN_GROUP(trigger_element, change->trigger_element)) { #if 0 - if (!(change->events & CH_EVENT_BIT(trigger_event))) + if (!(change->has_event[trigger_event])) printf("::: !!! %d triggers %d: using wrong page %d [event %d]\n", trigger_element-EL_CUSTOM_START+1, i+1, j, trigger_event); #endif @@ -8239,7 +8266,7 @@ static boolean CheckTriggeredElementChangeExt(int lx, int ly, if (Feld[x][y] == element) { ChangeDelay[x][y] = 1; - ChangeEvent[x][y] = CH_EVENT_BIT(trigger_event); + ChangeEvent[x][y] = trigger_event; ChangeElement(x, y, page); } } @@ -8290,7 +8317,7 @@ static boolean CheckElementChangeExt(int x, int y, struct ElementChangeInfo *change = &element_info[element].change_page[i]; if (change->can_change && - change->events & CH_EVENT_BIT(trigger_event) && + change->has_event[trigger_event] && change->trigger_side & trigger_side && change->trigger_player & trigger_player) { @@ -8328,7 +8355,7 @@ static boolean CheckElementChangeExt(int x, int y, #endif ChangeDelay[x][y] = 1; - ChangeEvent[x][y] = CH_EVENT_BIT(trigger_event); + ChangeEvent[x][y] = trigger_event; ChangeElement(x, y, trigger_page); return TRUE; @@ -8956,8 +8983,8 @@ void GameActions() for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++) { - Changed[x][y] = CE_BITMASK_DEFAULT; - ChangeEvent[x][y] = CE_BITMASK_DEFAULT; + Changed[x][y] = FALSE; + ChangeEvent[x][y] = -1; #if USE_NEW_BLOCK_STYLE /* this must be handled before main playfield loop */ @@ -10660,7 +10687,7 @@ void TestIfElementTouchesCustomElement(int x, int y) &element_info[center_element].change_page[j]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_IS_TOUCHING) && + change->has_event[CE_OTHER_IS_TOUCHING] && change->trigger_side & border_side && #if 1 IS_EQUAL_OR_IN_GROUP(border_element, change->trigger_element) @@ -10688,7 +10715,7 @@ void TestIfElementTouchesCustomElement(int x, int y) &element_info[border_element].change_page[j]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_IS_TOUCHING) && + change->has_event[CE_OTHER_IS_TOUCHING] && change->trigger_side & center_side && #if 1 IS_EQUAL_OR_IN_GROUP(center_element, change->trigger_element) @@ -10781,7 +10808,7 @@ void TestIfElementHitsCustomElement(int x, int y, int direction) &element_info[hitting_element].change_page[i]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_IS_HITTING) && + change->has_event[CE_OTHER_IS_HITTING] && change->trigger_side & touched_side && #if 1 @@ -10807,7 +10834,7 @@ void TestIfElementHitsCustomElement(int x, int y, int direction) &element_info[touched_element].change_page[i]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_GETS_HIT) && + change->has_event[CE_OTHER_GETS_HIT] && change->trigger_side & hitting_side && #if 1 IS_EQUAL_OR_IN_GROUP(hitting_element, change->trigger_element) @@ -10888,7 +10915,7 @@ void TestIfElementSmashesCustomElement(int x, int y, int direction) &element_info[hitting_element].change_page[i]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_IS_SMASHING) && + change->has_event[CE_OTHER_IS_SMASHING] && change->trigger_side & touched_side && #if 1 @@ -10914,7 +10941,7 @@ void TestIfElementSmashesCustomElement(int x, int y, int direction) &element_info[touched_element].change_page[i]; if (change->can_change && - change->events & CH_EVENT_BIT(CE_OTHER_GETS_SMASHED) && + change->has_event[CE_OTHER_GETS_SMASHED] && change->trigger_side & hitting_side && #if 1 IS_EQUAL_OR_IN_GROUP(hitting_element, change->trigger_element) @@ -12191,7 +12218,7 @@ int DigField(struct PlayerInfo *player, player->push_delay = 0; #endif -#if USE_PENGUIN_COLLECT_BUG +#if USE_PENGUIN_COLLECT_BUGFIX if (is_player) /* function can also be called by EL_PENGUIN */ #endif { @@ -12388,7 +12415,7 @@ boolean DropElement(struct PlayerInfo *player) #if 1 /* needed if previous element just changed to "empty" in the last frame */ - Changed[dropx][dropy] = 0; /* allow another change */ + Changed[dropx][dropy] = FALSE; /* allow another change */ #endif #if 1 @@ -12458,7 +12485,7 @@ boolean DropElement(struct PlayerInfo *player) nexty = dropy + GET_DY_FROM_DIR(move_direction); #if 1 - Changed[dropx][dropy] = 0; /* allow another change */ + Changed[dropx][dropy] = FALSE; /* allow another change */ CheckCollision[dropx][dropy] = 2; #else @@ -12477,7 +12504,7 @@ boolean DropElement(struct PlayerInfo *player) /* !!! commented out from 3.1.0-4 to 3.1.0-5 !!! */ else { - Changed[dropx][dropy] = 0; /* allow another change */ + Changed[dropx][dropy] = FALSE; /* allow another change */ #if 1 TestIfElementHitsCustomElement(dropx, dropy, move_direction); diff --git a/src/main.c b/src/main.c index 6df9c61e..f2db9290 100644 --- a/src/main.c +++ b/src/main.c @@ -56,8 +56,8 @@ short StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short Back[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; boolean Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; boolean Pushed[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -unsigned long Changed[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -unsigned long ChangeEvent[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +boolean Changed[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short ChangeEvent[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short WasJustMoving[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short WasJustFalling[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short CheckCollision[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; diff --git a/src/main.h b/src/main.h index 7f6e8c6c..af3e7b4e 100644 --- a/src/main.h +++ b/src/main.h @@ -207,6 +207,24 @@ #define CE_BITMASK_DEFAULT 0 +#if 1 + +#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) + +#else + #define CH_EVENT_BIT(c) (1 << (c)) #define CH_EVENT_VAR(e) (element_info[e].change->events) #define CH_ANY_EVENT_VAR(e) (element_info[e].change_events) @@ -219,6 +237,11 @@ ((v) ? \ (CH_EVENT_VAR(e) |= CH_EVENT_BIT(c)) : \ (CH_EVENT_VAR(e) &= ~CH_EVENT_BIT(c))) : 0) +#define SET_ANY_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ? \ + ((v) ? \ + (CH_ANY_EVENT_VAR(e) |= CH_EVENT_BIT(c)) : \ + (CH_ANY_EVENT_VAR(e) &= ~CH_EVENT_BIT(c))) : 0) +#endif /* values for change side for custom elements */ #define CH_SIDE_NONE MV_NO_MOVING @@ -1765,7 +1788,11 @@ struct ElementChangeInfo { boolean can_change; /* use or ignore this change info */ +#if 1 + boolean has_event[NUM_CHANGE_EVENTS]; /* change events */ +#else unsigned long events; /* change events */ +#endif int trigger_player; /* player triggering change */ int trigger_side; /* side triggering change */ @@ -1899,7 +1926,11 @@ struct ElementInfo /* ---------- internal values used at runtime when playing ---------- */ +#if 1 + boolean has_change_event[NUM_CHANGE_EVENTS]; +#else unsigned long change_events; /* bitfield for combined change events */ +#endif int event_page_nr[NUM_CHANGE_EVENTS]; /* page number for each event */ struct ElementChangeInfo *event_page[NUM_CHANGE_EVENTS]; /* page for event */ @@ -2079,8 +2110,8 @@ extern short StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short Back[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern boolean Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern boolean Pushed[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern unsigned long Changed[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; -extern unsigned long ChangeEvent[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern boolean Changed[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short ChangeEvent[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short WasJustMoving[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short WasJustFalling[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short CheckCollision[MAX_LEV_FIELDX][MAX_LEV_FIELDY];