From b17705c5e8242e7769094e538b52c52c3c1687d0 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 9 Aug 2003 01:37:40 +0200 Subject: [PATCH] rnd-20030809-1-src --- CHANGES | 7 +- src/conf_chr.c | 12 +++ src/conf_chr.h | 12 +++ src/conf_cus.c | 12 +++ src/conf_cus.h | 12 +++ src/conf_e2g.c | 12 +++ src/conf_e2s.c | 12 +++ src/conf_esg.c | 12 +++ src/conf_fnt.c | 12 +++ src/conf_gfx.h | 12 +++ src/conf_snd.h | 12 +++ src/conftime.h | 2 +- src/editor.c | 44 +++++++--- src/game.c | 229 +++++++++++++++++++++++++++++++++++++------------ src/init.c | 3 + src/main.h | 13 +-- 16 files changed, 343 insertions(+), 75 deletions(-) diff --git a/CHANGES b/CHANGES index 10ebc7f0..93391c90 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ +Release Version 3.0.1 [?? ??? ????] +----------------------------------- + - fixed bug with missing graphic for active red disk bomb + - added custom element property for dropping collected elements + Release Version 3.0.0 [05 AUG 2003] ------------------------------------------- +----------------------------------- - final version bumped to 3.0.0 due to the massive changes - graphics and sounds now completely and dynamically customizable - custom elements now have lots of configurable properties diff --git a/src/conf_chr.c b/src/conf_chr.c index 00fe6994..506c8b27 100644 --- a/src/conf_chr.c +++ b/src/conf_chr.c @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_chr.c * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_chr.h b/src/conf_chr.h index 373ef0de..8cee2724 100644 --- a/src/conf_chr.h +++ b/src/conf_chr.h @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_chr.h * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_cus.c b/src/conf_cus.c index 7c68e072..82144cd2 100644 --- a/src/conf_cus.c +++ b/src/conf_cus.c @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_cus.c * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_cus.h b/src/conf_cus.h index 3fa751d6..425334be 100644 --- a/src/conf_cus.h +++ b/src/conf_cus.h @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_cus.h * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_e2g.c b/src/conf_e2g.c index 32c104a0..18eafe77 100644 --- a/src/conf_e2g.c +++ b/src/conf_e2g.c @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_e2g.c * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_e2s.c b/src/conf_e2s.c index f17b1b3e..6e229df2 100644 --- a/src/conf_e2s.c +++ b/src/conf_e2s.c @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_e2s.c * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_esg.c b/src/conf_esg.c index ed2369a3..b2180fb3 100644 --- a/src/conf_esg.c +++ b/src/conf_esg.c @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_esg.c * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_fnt.c b/src/conf_fnt.c index 0c9256b5..0a191dda 100644 --- a/src/conf_fnt.c +++ b/src/conf_fnt.c @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_fnt.c * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_gfx.h b/src/conf_gfx.h index 528d73d0..45e49bc3 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_gfx.h * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conf_snd.h b/src/conf_snd.h index bfb6db88..94366024 100644 --- a/src/conf_snd.h +++ b/src/conf_snd.h @@ -1,3 +1,15 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* (c) 1995-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* conf_snd.h * +***********************************************************/ /* ----- this file was automatically generated -- do not edit by hand ----- */ diff --git a/src/conftime.h b/src/conftime.h index 37e51f60..a28d19fe 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-08-08 19:58]" +#define COMPILE_DATE_STRING "[2003-08-09 01:35]" diff --git a/src/editor.c b/src/editor.c index bd466026..31066e69 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1020,7 +1020,8 @@ static struct ValueTextInfo options_deadliness[] = static struct ValueTextInfo options_consistency[] = { - { EP_CAN_EXPLODE, "can explode" }, + { EP_CAN_EXPLODE_3X3, "can explode 3x3" }, + { EP_CAN_EXPLODE_1X1, "can explode 1x1" }, { EP_INDESTRUCTIBLE, "indestructible" }, { -1, NULL } }; @@ -3868,6 +3869,21 @@ static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY], dst[x][y] = src[x][y]; } +static int SetSelectboxValue(int selectbox_id, int new_value) +{ + int new_index_value = 0; + int i; + + for(i=0; selectbox_info[selectbox_id].options[i].text != NULL; i++) + if (selectbox_info[selectbox_id].options[i].value == new_value) + new_index_value = i; + + *selectbox_info[selectbox_id].value = + selectbox_info[selectbox_id].options[new_index_value].value; + + return new_index_value; +} + static void CopyCustomElementPropertiesToEditor(int element) { int i; @@ -3877,6 +3893,10 @@ static void CopyCustomElementPropertiesToEditor(int element) custom_element = element_info[element]; + /* needed to initially set selectbox value variables to reliable defaults */ + for (i=0; i < ED_NUM_SELECTBOX; i++) + SetSelectboxValue(i, *selectbox_info[i].value); + for (i=0; i < NUM_ELEMENT_PROPERTIES; i++) custom_element_properties[i] = HAS_PROPERTY(element, i); @@ -3938,11 +3958,13 @@ static void CopyCustomElementPropertiesToEditor(int element) /* set consistency selectbox help value */ custom_element.consistency = (IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE : - CAN_EXPLODE(element) ? EP_CAN_EXPLODE : + CAN_EXPLODE_1X1(element) ? EP_CAN_EXPLODE_1X1 : + CAN_EXPLODE_3X3(element) ? EP_CAN_EXPLODE_3X3 : custom_element.consistency); custom_element_properties[EP_EXPLODE_RESULT] = (IS_INDESTRUCTIBLE(element) || - CAN_EXPLODE(element)); + CAN_EXPLODE_1X1(element) || + CAN_EXPLODE_3X3(element)); /* special case: sub-settings dependent from main setting */ if (CAN_EXPLODE_BY_FIRE(element)) @@ -4047,7 +4069,8 @@ static void CopyCustomElementPropertiesToGame(int element) /* set consistency property from checkbox and selectbox */ custom_element_properties[EP_INDESTRUCTIBLE] = FALSE; - custom_element_properties[EP_CAN_EXPLODE] = FALSE; + custom_element_properties[EP_CAN_EXPLODE_1X1] = FALSE; + custom_element_properties[EP_CAN_EXPLODE_3X3] = FALSE; 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; @@ -4055,7 +4078,8 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_properties[EP_EXPLODE_RESULT]; /* special case: sub-settings dependent from main setting */ - if (custom_element_properties[EP_CAN_EXPLODE]) + if (custom_element_properties[EP_CAN_EXPLODE_3X3] || + custom_element_properties[EP_CAN_EXPLODE_1X1]) { custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = custom_element.can_explode_by_fire; @@ -4290,15 +4314,7 @@ static void ModifyEditorSelectbox(int selectbox_id, int new_value) { int gadget_id = selectbox_info[selectbox_id].gadget_id; struct GadgetInfo *gi = level_editor_gadget[gadget_id]; - int new_index_value = 0; - int i; - - for(i=0; selectbox_info[selectbox_id].options[i].text != NULL; i++) - if (selectbox_info[selectbox_id].options[i].value == new_value) - new_index_value = i; - - *selectbox_info[selectbox_id].value = - selectbox_info[selectbox_id].options[new_index_value].value; + int new_index_value = SetSelectboxValue(selectbox_id, new_value); ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END); } diff --git a/src/game.c b/src/game.c index 32311aa5..46151883 100644 --- a/src/game.c +++ b/src/game.c @@ -495,62 +495,71 @@ static int getBeltDirFromBeltSwitchElement(int element) return belt_move_dir[belt_dir_nr]; } -static void InitField(int x, int y, boolean init_game) +static void InitPlayerField(int x, int y, int element, boolean init_game) { - int element = Feld[x][y]; - - switch (element) + if (element == EL_SP_MURPHY) { - case EL_SP_MURPHY: - if (init_game) + if (init_game) + { + if (stored_player[0].present) { - if (stored_player[0].present) - { - Feld[x][y] = EL_SP_MURPHY_CLONE; - break; - } - else - { - stored_player[0].use_murphy_graphic = TRUE; - } + Feld[x][y] = EL_SP_MURPHY_CLONE; - Feld[x][y] = EL_PLAYER_1; + return; } - /* no break! */ - case EL_PLAYER_1: - case EL_PLAYER_2: - case EL_PLAYER_3: - case EL_PLAYER_4: - if (init_game) + else { - struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_PLAYER_1]; - int jx = player->jx, jy = player->jy; + stored_player[0].use_murphy_graphic = TRUE; + } - player->present = TRUE; + Feld[x][y] = EL_PLAYER_1; + } + } - if (!options.network || player->connected) - { - player->active = TRUE; + if (init_game) + { + struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_PLAYER_1]; + int jx = player->jx, jy = player->jy; - /* remove potentially duplicate players */ - if (StorePlayer[jx][jy] == Feld[x][y]) - StorePlayer[jx][jy] = 0; + player->present = TRUE; - StorePlayer[x][y] = Feld[x][y]; + if (!options.network || player->connected) + { + player->active = TRUE; - if (options.debug) - { - printf("Player %d activated.\n", player->element_nr); - printf("[Local player is %d and currently %s.]\n", - local_player->element_nr, - local_player->active ? "active" : "not active"); - } - } + /* remove potentially duplicate players */ + if (StorePlayer[jx][jy] == Feld[x][y]) + StorePlayer[jx][jy] = 0; - Feld[x][y] = EL_EMPTY; - player->jx = player->last_jx = x; - player->jy = player->last_jy = y; + StorePlayer[x][y] = Feld[x][y]; + + if (options.debug) + { + printf("Player %d activated.\n", player->element_nr); + printf("[Local player is %d and currently %s.]\n", + local_player->element_nr, + local_player->active ? "active" : "not active"); } + } + + Feld[x][y] = EL_EMPTY; + player->jx = player->last_jx = x; + player->jy = player->last_jy = y; + } +} + +static void InitField(int x, int y, boolean init_game) +{ + int element = Feld[x][y]; + + switch (element) + { + case EL_SP_MURPHY: + case EL_PLAYER_1: + case EL_PLAYER_2: + case EL_PLAYER_3: + case EL_PLAYER_4: + InitPlayerField(x, y, element, init_game); break; case EL_STONEBLOCK: @@ -1207,16 +1216,88 @@ void InitGame() if (lev_fieldy + (SBY_Upper == -1 ? 2 : 0) <= SCR_FIELDY) SBY_Upper = SBY_Lower = -1 * (SCR_FIELDY - lev_fieldy) / 2; - scroll_x = SBX_Left; - scroll_y = SBY_Upper; - if (local_player->jx >= SBX_Left + MIDPOSX) - scroll_x = (local_player->jx <= SBX_Right + MIDPOSX ? - local_player->jx - MIDPOSX : - SBX_Right); - if (local_player->jy >= SBY_Upper + MIDPOSY) - scroll_y = (local_player->jy <= SBY_Lower + MIDPOSY ? - local_player->jy - MIDPOSY : - SBY_Lower); + /* if local player not found, look for custom element that might create + the player (make some assumptions about the right custom element) */ + if (!local_player->present) + { + int start_x = 0, start_y = 0; + int found_rating = 0; + + for(y=0; y < lev_fieldy; y++) + { + for(x=0; x < lev_fieldx; x++) + { + int element = Feld[x][y]; + + if (IS_CUSTOM_ELEMENT(element)) + { + int xx, yy; + + for(yy=0; yy < 3; yy++) + { + for(xx=0; xx < 3; xx++) + { + int content; + boolean is_player; + + content = element_info[element].content[xx][yy]; + is_player = (ELEM_IS_PLAYER(content) || content == EL_SP_MURPHY); + + if (is_player && found_rating < 2) + { + start_x = x + xx - 1; + start_y = y + yy - 1; + + found_rating = 2; + } + + content = element_info[element].change.content[xx][yy]; + is_player = (ELEM_IS_PLAYER(content) || content == EL_SP_MURPHY); + + if (is_player && found_rating < 1) + { + start_x = x + xx - 1; + start_y = y + yy - 1; + + found_rating = 1; + } + } + } + } + } + } + + scroll_x = (start_x < SBX_Left + MIDPOSX ? SBX_Left : + start_x > SBX_Right + MIDPOSX ? SBX_Right : + start_x - MIDPOSX); + + scroll_y = (start_y < SBY_Upper + MIDPOSY ? SBY_Upper : + start_y > SBY_Lower + MIDPOSY ? SBY_Lower : + start_y - MIDPOSY); + } + else + { +#if 1 + scroll_x = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left : + local_player->jx > SBX_Right + MIDPOSX ? SBX_Right : + local_player->jx - MIDPOSX); + + scroll_y = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper : + local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower : + local_player->jy - MIDPOSY); +#else + scroll_x = SBX_Left; + scroll_y = SBY_Upper; + if (local_player->jx >= SBX_Left + MIDPOSX) + scroll_x = (local_player->jx <= SBX_Right + MIDPOSX ? + local_player->jx - MIDPOSX : + SBX_Right); + if (local_player->jy >= SBY_Upper + MIDPOSY) + scroll_y = (local_player->jy <= SBY_Lower + MIDPOSY ? + local_player->jy - MIDPOSY : + SBY_Lower); +#endif + } CloseDoor(DOOR_CLOSE_1); @@ -1863,6 +1944,40 @@ void CheckDynamite(int x, int y) Bang(x, y); } +void RelocatePlayer(int x, int y, int element) +{ + struct PlayerInfo *player = &stored_player[element - EL_PLAYER_1]; + + if (player->present) + { + while (player->MovPos) + { + ScrollFigure(player, SCROLL_GO_ON); + ScrollScreen(NULL, SCROLL_GO_ON); + FrameCounter++; + DrawAllPlayers(); + BackToFront(); + } + + RemoveField(player->jx, player->jy); + } + + InitPlayerField(x, y, element, TRUE); + + if (player == local_player) + { + scroll_x = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left : + local_player->jx > SBX_Right + MIDPOSX ? SBX_Right : + local_player->jx - MIDPOSX); + + scroll_y = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper : + local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower : + local_player->jy - MIDPOSY); + } + + DrawLevel(); +} + void Explode(int ex, int ey, int phase, int mode) { int x, y; @@ -2142,6 +2257,9 @@ void Explode(int ex, int ey, int phase, int mode) if (IS_PLAYER(x, y) && !PLAYERINFO(x,y)->present) StorePlayer[x][y] = 0; + + if (ELEM_IS_PLAYER(element)) + RelocatePlayer(x, y, element); } else if (phase >= delay && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { @@ -2290,7 +2408,10 @@ void Bang(int x, int y) Explode(x, y, EX_PHASE_START, EX_CENTER); break; default: - Explode(x, y, EX_PHASE_START, EX_NORMAL); + if (CAN_EXPLODE_1X1(element)) + Explode(x, y, EX_PHASE_START, EX_CENTER); + else + Explode(x, y, EX_PHASE_START, EX_NORMAL); break; } diff --git a/src/init.c b/src/init.c index 7132ab78..cde94b12 100644 --- a/src/init.c +++ b/src/init.c @@ -2777,6 +2777,9 @@ void InitElementPropertiesEngine(int engine_version) CAN_EXPLODE_SMASHED(i) || CAN_EXPLODE_IMPACT(i))); + /* ---------- CAN_EXPLODE_3X3 ------------------------------------------ */ + SET_PROPERTY(i, EP_CAN_EXPLODE_3X3, !CAN_EXPLODE_1X1(i)); + /* ---------- CAN_BE_CRUMBLED ------------------------------------------ */ SET_PROPERTY(i, EP_CAN_BE_CRUMBLED, element_info[i].crumbled[ACTION_DEFAULT] != IMG_EMPTY); diff --git a/src/main.h b/src/main.h index 601b0a71..cbd5c554 100644 --- a/src/main.h +++ b/src/main.h @@ -85,7 +85,7 @@ #define EP_PASSABLE_INSIDE 20 #define EP_PASSABLE_UNDER 21 #define EP_DROPPABLE 22 -#define EP_UNUSED_23 23 +#define EP_CAN_EXPLODE_1X1 23 #define EP_PUSHABLE 24 /* values for special configurable properties (depending on level settings) */ @@ -134,13 +134,14 @@ #define EP_EXPLOSION_PROOF 68 #define EP_CAN_SMASH 69 #define EP_CAN_EXPLODE 70 +#define EP_CAN_EXPLODE_3X3 71 /* values for internal purpose only (level editor) */ -#define EP_EXPLODE_RESULT 71 -#define EP_WALK_TO_OBJECT 72 -#define EP_DEADLY 73 +#define EP_EXPLODE_RESULT 72 +#define EP_WALK_TO_OBJECT 73 +#define EP_DEADLY 74 -#define NUM_ELEMENT_PROPERTIES 74 +#define NUM_ELEMENT_PROPERTIES 75 #define NUM_EP_BITFIELDS ((NUM_ELEMENT_PROPERTIES + 31) / 32) #define EP_BITFIELD_BASE 0 @@ -248,6 +249,7 @@ #define IS_PASSABLE_INSIDE(e) HAS_PROPERTY(e, EP_PASSABLE_INSIDE) #define IS_PASSABLE_UNDER(e) HAS_PROPERTY(e, EP_PASSABLE_UNDER) #define IS_DROPPABLE(e) HAS_PROPERTY(e, EP_DROPPABLE) +#define CAN_EXPLODE_1X1(e) HAS_PROPERTY(e, EP_CAN_EXPLODE_1X1) #define IS_PUSHABLE(e) HAS_PROPERTY(e, EP_PUSHABLE) /* macros for special configurable properties */ @@ -296,6 +298,7 @@ #define IS_EXPLOSION_PROOF(e) HAS_PROPERTY(e, EP_EXPLOSION_PROOF) #define CAN_SMASH(e) HAS_PROPERTY(e, EP_CAN_SMASH) #define CAN_EXPLODE(e) HAS_PROPERTY(e, EP_CAN_EXPLODE) +#define CAN_EXPLODE_3X3(e) HAS_PROPERTY(e, EP_CAN_EXPLODE_3X3) /* special macros used in game engine */ #define IS_CUSTOM_ELEMENT(e) ((e) >= EL_CUSTOM_START && \ -- 2.34.1