From 24134e1e4ef7e3d582ac4827eb8740261bf5d1b6 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 11 Feb 2006 16:21:18 +0100 Subject: [PATCH] rnd-20060211-1-src --- src/conftime.h | 2 +- src/editor.c | 4 +++ src/events.c | 6 +++- src/files.c | 49 +++++++++++++++++++++++++++ src/game.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 2 ++ src/main.h | 8 +++++ src/screens.c | 5 +++ 8 files changed, 163 insertions(+), 2 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index 288e2df1..f131772c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-02-10 02:10]" +#define COMPILE_DATE_STRING "[2006-02-11 15:23]" diff --git a/src/editor.c b/src/editor.c index 07043c5e..6c51c6dc 100644 --- a/src/editor.c +++ b/src/editor.c @@ -6358,8 +6358,12 @@ static void copy_custom_element_settings(int element_from, int element_to) ei_to->description[i] = ei_from->description[i]; /* ---------- copy element base properties ---------- */ +#if 1 + ei_to->properties[EP_BITFIELD_BASE] = ei_from->properties[EP_BITFIELD_BASE]; +#else Properties[element_to][EP_BITFIELD_BASE] = Properties[element_from][EP_BITFIELD_BASE]; +#endif /* ---------- copy custom property values ---------- */ diff --git a/src/events.c b/src/events.c index 410c34c2..95b9e9f0 100644 --- a/src/events.c +++ b/src/events.c @@ -682,7 +682,8 @@ void HandleKey(Key key, int key_status) return; } - if (game_status == GAME_MODE_MAIN && key == setup.shortcut.toggle_pause) + if (game_status == GAME_MODE_MAIN && + (key == setup.shortcut.toggle_pause || key == KSYM_space)) { StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE); @@ -719,7 +720,10 @@ void HandleKey(Key key, int key_status) case GAME_MODE_INFO: switch(key) { +#if 0 + /* !!! only use "space" key to start game from main menu !!! */ case KSYM_space: +#endif case KSYM_Return: if (game_status == GAME_MODE_MAIN) HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE); diff --git a/src/files.c b/src/files.c index ea169389..af9ac437 100644 --- a/src/files.c +++ b/src/files.c @@ -718,8 +718,13 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) /* !!! now done in InitElementPropertiesStatic() (see above) !!! */ /* !!! (else properties set there will be overwritten here) !!! */ /* start with no properties at all */ +#if 1 + for (j = 0; j < NUM_EP_BITFIELDS; j++) + ei->properties[j] = EP_BITMASK_DEFAULT; +#else for (j = 0; j < NUM_EP_BITFIELDS; j++) Properties[element][j] = EP_BITMASK_DEFAULT; +#endif #endif /* now set default properties */ @@ -800,9 +805,15 @@ static void setFileInfoToDefaults(struct LevelFileInfo *level_file_info) static void ActivateLevelTemplate() { +#if 1 + /* Currently there is no special action needed to activate the template + data, because 'element_info' property settings overwrite the original + level data, while all other variables do not change. */ +#else /* Currently there is no special action needed to activate the template data, because 'element_info' and 'Properties' overwrite the original level data, while all other variables do not change. */ +#endif } static char *getLevelFilenameFromBasename(char *basename) @@ -1381,10 +1392,17 @@ static int LoadLevel_CUS1(FILE *file, int chunk_size, struct LevelInfo *level) int element = getFile16BitBE(file); int properties = getFile32BitBE(file); +#if 1 + if (IS_CUSTOM_ELEMENT(element)) + element_info[element].properties[EP_BITFIELD_BASE] = properties; + else + Error(ERR_WARN, "invalid custom element number %d", element); +#else if (IS_CUSTOM_ELEMENT(element)) Properties[element][EP_BITFIELD_BASE] = properties; else Error(ERR_WARN, "invalid custom element number %d", element); +#endif } return chunk_size; @@ -1445,7 +1463,11 @@ static int LoadLevel_CUS3(FILE *file, int chunk_size, struct LevelInfo *level) ei->description[j] = getFile8Bit(file); ei->description[MAX_ELEMENT_NAME_LEN] = 0; +#if 1 + ei->properties[EP_BITFIELD_BASE] = getFile32BitBE(file); +#else Properties[element][EP_BITFIELD_BASE] = getFile32BitBE(file); +#endif /* some free bytes for future properties and padding */ ReadUnusedBytesFromFile(file, 7); @@ -1532,7 +1554,11 @@ static int LoadLevel_CUS4(FILE *file, int chunk_size, struct LevelInfo *level) ei->description[i] = getFile8Bit(file); ei->description[MAX_ELEMENT_NAME_LEN] = 0; +#if 1 + ei->properties[EP_BITFIELD_BASE] = getFile32BitBE(file); +#else Properties[element][EP_BITFIELD_BASE] = getFile32BitBE(file); +#endif ReadUnusedBytesFromFile(file, 4); /* reserved for more base properties */ ei->num_change_pages = getFile8Bit(file); @@ -3629,6 +3655,20 @@ static void SaveLevel_CUS1(FILE *file, struct LevelInfo *level, { int element = EL_CUSTOM_START + i; +#if 1 + struct ElementInfo *ei = &element_info[element]; + + if (ei->properties[EP_BITFIELD_BASE] != EP_BITMASK_DEFAULT) + { + if (check < num_changed_custom_elements) + { + putFile16BitBE(file, element); + putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]); + } + + check++; + } +#else if (Properties[element][EP_BITFIELD_BASE] != EP_BITMASK_DEFAULT) { if (check < num_changed_custom_elements) @@ -3639,6 +3679,7 @@ static void SaveLevel_CUS1(FILE *file, struct LevelInfo *level, check++; } +#endif } if (check != num_changed_custom_elements) /* should not happen */ @@ -3697,7 +3738,11 @@ static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level, for (j = 0; j < MAX_ELEMENT_NAME_LEN; j++) putFile8Bit(file, ei->description[j]); +#if 1 + putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]); +#else putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]); +#endif /* some free bytes for future properties and padding */ WriteUnusedBytesToFile(file, 7); @@ -3770,7 +3815,11 @@ static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element) for (i = 0; i < MAX_ELEMENT_NAME_LEN; i++) putFile8Bit(file, ei->description[i]); +#if 1 + putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]); +#else putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]); +#endif WriteUnusedBytesToFile(file, 4); /* reserved for more base properties */ putFile8Bit(file, ei->num_change_pages); diff --git a/src/game.c b/src/game.c index fc7a5bfc..9c0dcf99 100644 --- a/src/game.c +++ b/src/game.c @@ -10176,7 +10176,94 @@ void TestIfPlayerTouchesCustomElement(int x, int y) } } +#if 1 + void TestIfElementTouchesCustomElement(int x, int y) +{ + static int xy[4][2] = + { + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } + }; + static int trigger_sides[4][2] = + { + /* center side border side */ + { CH_SIDE_TOP, CH_SIDE_BOTTOM }, /* check top */ + { CH_SIDE_LEFT, CH_SIDE_RIGHT }, /* check left */ + { CH_SIDE_RIGHT, CH_SIDE_LEFT }, /* check right */ + { CH_SIDE_BOTTOM, CH_SIDE_TOP } /* check bottom */ + }; + static int touch_dir[4] = + { + MV_LEFT | MV_RIGHT, + MV_UP | MV_DOWN, + MV_UP | MV_DOWN, + MV_LEFT | MV_RIGHT + }; + boolean change_center_element = FALSE; + int center_element = Feld[x][y]; /* should always be non-moving! */ + int border_element_old[NUM_DIRECTIONS]; + int i; + + for (i = 0; i < NUM_DIRECTIONS; i++) + { + int xx = x + xy[i][0]; + int yy = y + xy[i][1]; + int border_element; + + border_element_old[i] = -1; + + if (!IN_LEV_FIELD(xx, yy)) + continue; + + if (game.engine_version < VERSION_IDENT(3,0,7,0)) + border_element = Feld[xx][yy]; /* may be moving! */ + else if (!IS_MOVING(xx, yy) && !IS_BLOCKED(xx, yy)) + border_element = Feld[xx][yy]; + else if (MovDir[xx][yy] & touch_dir[i]) /* elements are touching */ + border_element = MovingOrBlocked2Element(xx, yy); + else + continue; /* center and border element do not touch */ + + border_element_old[i] = border_element; + } + + for (i = 0; i < NUM_DIRECTIONS; i++) + { + int xx = x + xy[i][0]; + int yy = y + xy[i][1]; + int center_side = trigger_sides[i][0]; + int border_element = border_element_old[i]; + + if (border_element == -1) + continue; + + /* check for change of border element */ + CheckElementChangeBySide(xx, yy, border_element, center_element, + CE_TOUCHING_X, center_side); + } + + for (i = 0; i < NUM_DIRECTIONS; i++) + { + int border_side = trigger_sides[i][1]; + int border_element = border_element_old[i]; + + if (border_element == -1) + continue; + + /* 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); + } +} + +#else + +void TestIfElementTouchesCustomElement_OLD(int x, int y) { static int xy[4][2] = { @@ -10236,6 +10323,8 @@ void TestIfElementTouchesCustomElement(int x, int y) } } +#endif + void TestIfElementHitsCustomElement(int x, int y, int direction) { int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); diff --git a/src/main.c b/src/main.c index afae3f2c..280c7628 100644 --- a/src/main.c +++ b/src/main.c @@ -64,7 +64,9 @@ short ExplodeDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; int RunnerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; int PlayerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +#if 0 unsigned long Properties[MAX_NUM_ELEMENTS][NUM_EP_BITFIELDS]; +#endif int GfxFrame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; int GfxRandom[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; diff --git a/src/main.h b/src/main.h index b8941add..3fcf5c17 100644 --- a/src/main.h +++ b/src/main.h @@ -171,7 +171,11 @@ #define EP_BITMASK_DEFAULT 0 #define PROPERTY_BIT(p) (1 << ((p) % 32)) +#if 1 +#define PROPERTY_VAR(e,p) (element_info[e].properties[(p) / 32]) +#else #define PROPERTY_VAR(e,p) (Properties[e][(p) / 32]) +#endif #define HAS_PROPERTY(e,p) ((PROPERTY_VAR(e, p) & PROPERTY_BIT(p)) != 0) #define SET_PROPERTY(e,p,v) ((v) ? \ (PROPERTY_VAR(e,p) |= PROPERTY_BIT(p)) : \ @@ -2199,6 +2203,8 @@ struct ElementInfo /* ---------- special element property values ---------- */ + unsigned long properties[NUM_EP_BITFIELDS]; /* element base properties */ + boolean use_gfx_element; /* use custom graphic element */ int gfx_element; /* optional custom graphic element */ @@ -2436,7 +2442,9 @@ extern short ExplodeDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern int RunnerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern int PlayerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +#if 0 extern unsigned long Properties[MAX_NUM_ELEMENTS][NUM_EP_BITFIELDS]; +#endif extern int GfxFrame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern int GfxRandom[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; diff --git a/src/screens.c b/src/screens.c index 999e933e..90b987f3 100644 --- a/src/screens.c +++ b/src/screens.c @@ -452,6 +452,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { if (dx && choice == 1) x = (dx < 0 ? 10 : 14); + else if (dx > 0) + { + if (choice == 4 || choice == 6) + button = MB_MENU_CHOICE; + } else if (dy) y = choice + dy; } -- 2.34.1