From: Holger Schemel Date: Mon, 12 May 2003 23:11:12 +0000 (+0200) Subject: rnd-20030513-1-src X-Git-Tag: 3.0.0^2~64 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=5f9fbeb32ecd4c70ed6d6df8809719af619b40c0;p=rocksndiamonds.git rnd-20030513-1-src --- diff --git a/src/conftime.h b/src/conftime.h index c4519f2d..20910069 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-05-11 03:13]" +#define COMPILE_DATE_STRING "[2003-05-13 00:55]" diff --git a/src/editor.c b/src/editor.c index 6553ee4f..ef1394ac 100644 --- a/src/editor.c +++ b/src/editor.c @@ -331,12 +331,13 @@ #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 2) #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 0) -#define GADGET_ID_CUSTOM_WALKABLE_LAYER (GADGET_ID_SELECTBOX_FIRST + 1) -#define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 2) -#define GADGET_ID_CHANGE_CAUSE (GADGET_ID_SELECTBOX_FIRST + 3) +#define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 1) +#define GADGET_ID_CUSTOM_WALKABLE_LAYER (GADGET_ID_SELECTBOX_FIRST + 2) +#define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 3) +#define GADGET_ID_CHANGE_CAUSE (GADGET_ID_SELECTBOX_FIRST + 4) /* textbutton identifiers */ -#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 4) +#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 5) #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0) #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1) @@ -448,14 +449,15 @@ #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR /* values for selectbox gadgets */ -#define ED_SELECTBOX_ID_CUSTOM_WALK_TO_OBJECT 0 -#define ED_SELECTBOX_ID_CUSTOM_WALKABLE_LAYER 1 -#define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 2 -#define ED_SELECTBOX_ID_CHANGE_CAUSE 3 +#define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 0 +#define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 1 +#define ED_SELECTBOX_ID_CUSTOM_WALKABLE_LAYER 2 +#define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 3 +#define ED_SELECTBOX_ID_CHANGE_CAUSE 4 -#define ED_NUM_SELECTBOX 4 +#define ED_NUM_SELECTBOX 5 -#define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM_WALK_TO_OBJECT +#define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION #define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM_WALKABLE_LAYER #define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS @@ -675,7 +677,7 @@ static struct MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS, GADGET_ID_ELEMENT_CONTENT_DOWN, GADGET_ID_ELEMENT_CONTENT_UP, GADGET_ID_ELEMENT_CONTENT_TEXT, - &level.num_yam_contents, + &level.num_yamyam_contents, "element content", NULL }, { @@ -730,6 +732,23 @@ static struct ValueTextInfo options_walk_to_action[] = }; static int index_walk_to_action = 0; +static struct ValueTextInfo options_move_direction[] = +{ + { EP_DIGGABLE, "left" }, + { EP_COLLECTIBLE, "right" }, + { EP_PUSHABLE, "up" }, + { EP_PUSHABLE, "down" }, + { EP_PUSHABLE, "horizontal" }, + { EP_PUSHABLE, "vertical" }, + { EP_PUSHABLE, "all directions" }, + { EP_PUSHABLE, "towards player" }, + { EP_PUSHABLE, "away from player" }, + { EP_PUSHABLE, "along left side" }, + { EP_PUSHABLE, "along right side" }, + { -1, NULL } +}; +static int index_move_direction = 0; + static struct ValueTextInfo options_walkable_layer[] = { { EP_WALKABLE_OVER, "over" }, @@ -774,7 +793,15 @@ static struct 0, options_walk_to_action, &index_walk_to_action, &custom_element.walk_to_action, - NULL, "diggable, collectible or pushable" + NULL, "diggable/collectible/pushable" + }, + { + ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(5), + GADGET_ID_CUSTOM_MOVE_DIRECTION, + 0, + options_move_direction, &index_move_direction, + &custom_element.move_direction, + "can move", "element move direction" }, { ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(10), @@ -993,7 +1020,7 @@ static struct ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(5), GADGET_ID_CUSTOM_CAN_MOVE, &custom_element_properties[EP_CAN_MOVE], - "can move", "element can move in some direction" + NULL, "element can move in some direction" }, { ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(6), @@ -1029,7 +1056,7 @@ static struct ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2), GADGET_ID_CUSTOM_USE_GRAPHIC, &custom_element.use_gfx_element, - "use graphic of element:", "use optional custom graphic element" + "use graphic of element:", "use graphic for custom element" }, { ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1), @@ -1103,7 +1130,6 @@ static int last_drawing_function = GADGET_ID_SINGLE_ITEMS; static boolean draw_with_brush = FALSE; static int properties_element = 0; -static short ElementContent[MAX_ELEMENT_CONTENTS][3][3]; static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY]; static int undo_buffer_position = 0; @@ -3394,10 +3420,8 @@ static void DrawRandomPlacementBackgroundArea() int area_sx = SX + ED_AREA_RANDOM_BACKGROUND_XPOS; int area_sy = SY + ED_AREA_RANDOM_BACKGROUND_YPOS; - ElementContent[0][0][0] = random_placement_background_element; - DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE); - DrawMiniElement(area_x, area_y, ElementContent[0][0][0]); + DrawMiniElement(area_x, area_y, random_placement_background_element); MapDrawingArea(GADGET_ID_RANDOM_BACKGROUND); } @@ -3502,10 +3526,8 @@ static void DrawAmoebaContentArea() int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS; int area_sy = SY + ED_AREA_ELEM_CONTENT_YPOS; - ElementContent[0][0][0] = level.amoeba_content; - DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE); - DrawMiniElement(area_x, area_y, ElementContent[0][0][0]); + DrawMiniElement(area_x, area_y, level.amoeba_content); DrawText(area_sx + TILEX, area_sy + 1, "Content of amoeba", FONT_TEXT_1); @@ -3538,21 +3560,9 @@ static void DrawCustomGraphicElementArea() return; } - ElementContent[0][0][0] = custom_element.gfx_element; - DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE); -#if 1 - DrawMiniGraphicExt(drawto, - gi->x, - gi->y, - el2edimg(ElementContent[0][0][0])); -#else - DrawMiniElement(area_x, area_y, ElementContent[0][0][0]); -#endif - -#if 0 - DrawText(area_sx + TILEX, area_sy + 1, "Element after change", FONT_TEXT_1); -#endif + DrawMiniGraphicExt(drawto, gi->x, gi->y, + el2edimg(custom_element.gfx_element)); MapDrawingArea(GADGET_ID_CUSTOM_GRAPHIC); } @@ -3572,22 +3582,12 @@ static void DrawCustomContentArea() return; } - for (y=0; y<3; y++) - for (x=0; x<3; x++) - ElementContent[0][x][y] = custom_element.content[x][y]; - DrawElementBorder(area_sx, area_sy, 3 * MINI_TILEX, 3 * MINI_TILEY, TRUE); for (y=0; y<3; y++) for (x=0; x<3; x++) -#if 1 - DrawMiniGraphicExt(drawto, - gi->x + x * MINI_TILEX, - gi->y + y * MINI_TILEY, - el2edimg(ElementContent[0][0][0])); -#else - DrawMiniElement(area_x + x, area_y + y, ElementContent[0][x][y]); -#endif + DrawMiniGraphicExt(drawto, gi->x + x * MINI_TILEX,gi->y + y * MINI_TILEY, + el2edimg(custom_element.content[x][y])); MapDrawingArea(GADGET_ID_CUSTOM_CONTENT); } @@ -3618,21 +3618,9 @@ static void DrawCustomChangedArea() return; } - ElementContent[0][0][0] = custom_element.change.successor; - DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY, TRUE); -#if 1 - DrawMiniGraphicExt(drawto, - gi->x, - gi->y, - el2edimg(ElementContent[0][0][0])); -#else - DrawMiniElement(area_x, area_y, ElementContent[0][0][0]); -#endif - -#if 0 - DrawText(area_sx + TILEX, area_sy + 1, "Element after change", FONT_TEXT_1); -#endif + DrawMiniGraphicExt(drawto, gi->x, gi->y, + el2edimg(custom_element.change.successor)); MapDrawingArea(GADGET_ID_CUSTOM_CHANGED); } @@ -3648,11 +3636,6 @@ static void DrawElementContentAreas() int yoffset_right = ED_BORDER_SIZE; int i, x, y; - for (i=0; i= GADGET_ID_ELEMENT_CONTENT_0 && id <= GADGET_ID_ELEMENT_CONTENT_7) - level.yam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy] = + level.yamyam_content[id - GADGET_ID_ELEMENT_CONTENT_0][sx][sy] = new_element; } break; @@ -5889,7 +5879,10 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) "Amoeba content"); else if (id == GADGET_ID_CUSTOM_GRAPHIC) DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, - "Optional custom graphic element"); + "Custom graphic element"); + else if (id == GADGET_ID_CUSTOM_CONTENT) + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, + "Custom element content position: %d, %d", sx, sy); else if (id == GADGET_ID_CUSTOM_CHANGED) DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "New element after change"); diff --git a/src/files.c b/src/files.c index ce657d22..6a9cb746 100644 --- a/src/files.c +++ b/src/files.c @@ -84,11 +84,11 @@ static void setLevelInfoToDefaults() for(i=0; iscore[i] = fgetc(file); - level->num_yam_contents = STD_ELEMENT_CONTENTS; + level->num_yamyam_contents = STD_ELEMENT_CONTENTS; for(i=0; iyam_content[i][x][y] = checkLevelElement(fgetc(file)); + level->yamyam_content[i][x][y] = checkLevelElement(fgetc(file)); level->amoeba_speed = fgetc(file); level->time_magic_wall = fgetc(file); @@ -270,19 +275,19 @@ static int LoadLevel_CONT(FILE *file, int chunk_size, struct LevelInfo *level) } fgetc(file); - level->num_yam_contents = fgetc(file); + level->num_yamyam_contents = fgetc(file); fgetc(file); fgetc(file); /* correct invalid number of content fields -- should never happen */ - if (level->num_yam_contents < 1 || - level->num_yam_contents > MAX_ELEMENT_CONTENTS) - level->num_yam_contents = STD_ELEMENT_CONTENTS; + if (level->num_yamyam_contents < 1 || + level->num_yamyam_contents > MAX_ELEMENT_CONTENTS) + level->num_yamyam_contents = STD_ELEMENT_CONTENTS; for(i=0; iyam_content[i][x][y] = + level->yamyam_content[i][x][y] = checkLevelElement(level->encoding_16bit_field ? getFile16BitBE(file) : fgetc(file)); return chunk_size; @@ -312,12 +317,12 @@ static int LoadLevel_CNT2(FILE *file, int chunk_size, struct LevelInfo *level) if (element == EL_YAMYAM) { - level->num_yam_contents = num_contents; + level->num_yamyam_contents = num_contents; for(i=0; iyam_content[i][x][y] = content_array[i][x][y]; + level->yamyam_content[i][x][y] = content_array[i][x][y]; } else if (element == EL_BD_AMOEBA) { @@ -622,7 +627,7 @@ static void SaveLevel_HEAD(FILE *file, struct LevelInfo *level) for(y=0; y<3; y++) for(x=0; x<3; x++) fputc((level->encoding_16bit_yamyam ? EL_EMPTY : - level->yam_content[i][x][y]), + level->yamyam_content[i][x][y]), file); fputc(level->amoeba_speed, file); fputc(level->time_magic_wall, file); @@ -663,7 +668,7 @@ static void SaveLevel_CONT(FILE *file, struct LevelInfo *level) int i, x, y; fputc(EL_YAMYAM, file); - fputc(level->num_yam_contents, file); + fputc(level->num_yamyam_contents, file); fputc(0, file); fputc(0, file); @@ -671,9 +676,9 @@ static void SaveLevel_CONT(FILE *file, struct LevelInfo *level) for(y=0; y<3; y++) for(x=0; x<3; x++) if (level->encoding_16bit_field) - putFile16BitBE(file, level->yam_content[i][x][y]); + putFile16BitBE(file, level->yamyam_content[i][x][y]); else - fputc(level->yam_content[i][x][y], file); + fputc(level->yamyam_content[i][x][y], file); } #endif @@ -685,14 +690,14 @@ static void SaveLevel_CNT2(FILE *file, struct LevelInfo *level, int element) if (element == EL_YAMYAM) { - num_contents = level->num_yam_contents; + num_contents = level->num_yamyam_contents; content_xsize = 3; content_ysize = 3; for(i=0; iyam_content[i][x][y]; + content_array[i][x][y] = level->yamyam_content[i][x][y]; } else if (element == EL_BD_AMOEBA) { @@ -809,10 +814,10 @@ void SaveLevel(int level_nr) /* check yamyam content for 16-bit elements */ level.encoding_16bit_yamyam = FALSE; - for(i=0; i 255) + if (level.yamyam_content[i][x][y] > 255) level.encoding_16bit_yamyam = TRUE; /* check amoeba content for 16-bit elements */ @@ -850,7 +855,7 @@ void SaveLevel(int level_nr) SaveLevel_BODY(file, &level); if (level.encoding_16bit_yamyam || - level.num_yam_contents != STD_ELEMENT_CONTENTS) + level.num_yamyam_contents != STD_ELEMENT_CONTENTS) { putFileChunkBE(file, "CNT2", LEVEL_CHUNK_CNT2_SIZE); SaveLevel_CNT2(file, &level, EL_YAMYAM); diff --git a/src/game.c b/src/game.c index ccf0d477..e259a025 100644 --- a/src/game.c +++ b/src/game.c @@ -836,7 +836,7 @@ void InitGame() AllPlayersGone = FALSE; - game.yam_content_nr = 0; + game.yamyam_content_nr = 0; game.magic_wall_active = FALSE; game.magic_wall_time_left = 0; game.light_time_left = 0; @@ -1654,7 +1654,7 @@ void Explode(int ex, int ey, int phase, int mode) Feld[ex][ey] = center_element; } - for (y=ey-1; y<=ey+1; y++) for(x=ex-1; x<=ex+1; x++) + for (y = ey - 1; y <= ey + 1; y++) for(x = ex - 1; x <= ex + 1; x++) { int element; @@ -1734,10 +1734,14 @@ void Explode(int ex, int ey, int phase, int mode) Store[x][y] = EL_BD_DIAMOND; else if (center_element == EL_SP_ELECTRON) Store[x][y] = EL_SP_INFOTRON; - else if (center_element == EL_YAMYAM) - Store[x][y] = level.yam_content[game.yam_content_nr][x-ex+1][y-ey+1]; else if (center_element == EL_AMOEBA_TO_DIAMOND) Store[x][y] = level.amoeba_content; + else if (center_element == EL_YAMYAM) + Store[x][y] = + level.yamyam_content[game.yamyam_content_nr][x - ex + 1][y - ey + 1]; + else if (IS_CUSTOM_ELEMENT(center_element)) + Store[x][y] = + CUSTOM_ELEMENT_INFO(center_element).content[x - ex + 1][y - ey + 1]; else if (element == EL_WALL_EMERALD) Store[x][y] = EL_EMERALD; else if (element == EL_WALL_DIAMOND) @@ -1779,7 +1783,8 @@ void Explode(int ex, int ey, int phase, int mode) } if (center_element == EL_YAMYAM) - game.yam_content_nr = (game.yam_content_nr + 1) % level.num_yam_contents; + game.yamyam_content_nr = + (game.yamyam_content_nr + 1) % level.num_yamyam_contents; return; } diff --git a/src/main.h b/src/main.h index 4b69a028..dc4b8fa3 100644 --- a/src/main.h +++ b/src/main.h @@ -1035,6 +1035,8 @@ struct CustomElementInfo boolean use_gfx_element; short gfx_element; /* optional custom graphic element */ + int move_direction; /* direction movable element moves to */ + int walk_to_action; /* only for level editor; not stored */ int walkable_layer; /* only for level editor; not stored */ @@ -1059,8 +1061,8 @@ struct LevelInfo char name[MAX_LEVEL_NAME_LEN + 1]; char author[MAX_LEVEL_AUTHOR_LEN + 1]; int score[LEVEL_SCORE_ELEMENTS]; - int yam_content[MAX_ELEMENT_CONTENTS][3][3]; - int num_yam_contents; + int yamyam_content[MAX_ELEMENT_CONTENTS][3][3]; + int num_yamyam_contents; int amoeba_speed; int amoeba_content; int time_magic_wall; @@ -1118,7 +1120,7 @@ struct GameInfo int initial_move_delay_value; /* variable within running game */ - int yam_content_nr; + int yamyam_content_nr; boolean magic_wall_active; int magic_wall_time_left; int light_time_left;