Skip to content

Commit

Permalink
Board settings for dragon movement, reset on entry hack.
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLR committed Dec 20, 2023
1 parent 04236b5 commit ba2d42f
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 81 deletions.
6 changes: 4 additions & 2 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ USERS
FWRITE_APPEND) is now stored in save files. This fixes a bug
where the output file would be reopened in the wrong mode (ab)
when reloading a saved game.
+ Fixed dragon random movement behavior. A compatibility check
has been added for 2.80 to 2.92 non-random dragon movement.
+ Fixed dragon 1/8th chance of random movement, which has been
broken since 2.80. The original DOS behavior (random movement)
or the 2.80 behavior (no random movement) can be selected via
the new board setting "Dragons randomly move".
+ save_slots is now enabled by default for consoles. (Spectere)
+ editor_show_thing_toggles is now enabled by default.
- board_editor_hide_help and robot_editor_hide_help are no
Expand Down
37 changes: 25 additions & 12 deletions src/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ int save_board(struct world *mzx_world, struct board *cur_board,
return -1;
}

static void default_board(struct board *cur_board)
void default_board_settings(struct world *mzx_world, struct board *cur_board)
{
cur_board->mod_playing[0] = 0;
cur_board->viewport_x = 0;
Expand All @@ -269,12 +269,15 @@ static void default_board(struct board *cur_board)
cur_board->forest_becomes = 0;
cur_board->collect_bombs = 0;
cur_board->fire_burns = 0;
cur_board->board_dir[0] = 0;
cur_board->board_dir[1] = 0;
cur_board->board_dir[2] = 0;
cur_board->board_dir[3] = 0;
cur_board->dragons_can_randomly_move =
(mzx_world->version < VERSION_PORT || mzx_world->version >= V293) ? true : false;
cur_board->board_dir[0] = NO_BOARD;
cur_board->board_dir[1] = NO_BOARD;
cur_board->board_dir[2] = NO_BOARD;
cur_board->board_dir[3] = NO_BOARD;
cur_board->restart_if_zapped = 0;
cur_board->reset_on_entry = 0;
cur_board->reset_on_entry_same_board = (mzx_world->version >= V293);
cur_board->time_limit = 0;
cur_board->charset_path = NULL;
cur_board->palette_path = NULL;
Expand Down Expand Up @@ -316,15 +319,15 @@ static void default_board(struct board *cur_board)
#endif
}

void dummy_board(struct board *cur_board)
void dummy_board(struct world *mzx_world, struct board *cur_board)
{
// Allocate placeholder data for broken boards so they will run
int size = 2000;
cur_board->overlay_mode = 0;
cur_board->board_width = 80;
cur_board->board_height = 25;

default_board(cur_board);
default_board_settings(mzx_world, cur_board);

cur_board->level_id = ccalloc(1, size);
cur_board->level_color = ccalloc(1, size);
Expand Down Expand Up @@ -410,8 +413,8 @@ __editor_maybe_static void board_set_palette_path(struct board *cur_board,

#define err_if_missing(expected) if(last_ident < expected) { goto err_free; }

static int load_board_info(struct board *cur_board, struct zip_archive *zp,
int savegame, int *file_version)
static int load_board_info(struct world *mzx_world, struct board *cur_board,
struct zip_archive *zp, int savegame, int *file_version)
{
char *buffer;
size_t actual_size;
Expand Down Expand Up @@ -622,6 +625,16 @@ static int load_board_info(struct board *cur_board, struct zip_archive *zp,
board_set_palette_path(cur_board, (const char *)prop.start, size);
break;

case BPROP_RESET_ON_ENTRY_SAME_BOARD:
if(*file_version >= V293 && mzx_world->version >= V293)
cur_board->reset_on_entry_same_board = load_prop_boolean(&prop);
break;

case BPROP_DRAGONS_CAN_RANDOMLY_MOVE:
if(*file_version >= V293 && mzx_world->version >= V293)
cur_board->dragons_can_randomly_move = load_prop_boolean(&prop);
break;


// Savegame only
case BPROP_SCROLL_X:
Expand Down Expand Up @@ -791,7 +804,7 @@ int load_board_direct(struct world *mzx_world, struct board *cur_board,
int has_och = 0;
int has_oco = 0;

default_board(cur_board);
default_board_settings(mzx_world, cur_board);

while(ZIP_SUCCESS == zip_get_next_mzx_file_id(zp, &file_id, &board_id_read, &robot_id_read))
{
Expand All @@ -802,7 +815,7 @@ int load_board_direct(struct world *mzx_world, struct board *cur_board,
{
case FILE_ID_BOARD_INFO:
{
if(load_board_info(cur_board, zp, savegame, &file_version))
if(load_board_info(mzx_world, cur_board, zp, savegame, &file_version))
goto err_invalid;

has_base = 1;
Expand Down Expand Up @@ -1217,7 +1230,7 @@ int load_board_direct(struct world *mzx_world, struct board *cur_board,

err_invalid:
error_message(E_ZIP_BOARD_CORRUPT, (int)board_id, NULL);
dummy_board(cur_board);
dummy_board(mzx_world, cur_board);

return VAL_INVALID;
}
Expand Down
3 changes: 2 additions & 1 deletion src/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ CORE_LIBSPEC void clear_board(struct board *cur_board);
struct board *duplicate_board(struct world *mzx_world,
struct board *src_board);

void dummy_board(struct board *cur_board);
void default_board_settings(struct world *mzx_world, struct board *cur_board);
void dummy_board(struct world *mzx_world, struct board *cur_board);

int find_board(struct world *mzx_world, char *name);

Expand Down
2 changes: 2 additions & 0 deletions src/board_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ struct board
int forest_becomes;
int collect_bombs;
int fire_burns;
int dragons_can_randomly_move;
int board_dir[4];
int restart_if_zapped;
int reset_on_entry;
int reset_on_entry_same_board;
int time_limit;
int last_key;
int num_input;
Expand Down
2 changes: 1 addition & 1 deletion src/configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ typedef void (*config_function)(struct config_info *conf, char *name,

struct config_entry
{
char option_name[OPTION_NAME_LEN];
const char *option_name;
config_function change_option;
boolean allow_in_game_config;
};
Expand Down
2 changes: 0 additions & 2 deletions src/configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ __M_BEGIN_DECLS

#include <stdint.h>

#define OPTION_NAME_LEN 33

enum config_type
{
SYSTEM_CNF,
Expand Down
2 changes: 2 additions & 0 deletions src/editor/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,15 @@ struct board *create_blank_board(struct editor_config_info *conf)
cur_board->forest_becomes = conf->forest_to_floor;
cur_board->collect_bombs = conf->collect_bombs;
cur_board->fire_burns = conf->fire_burns_forever;
cur_board->dragons_can_randomly_move = conf->dragons_can_randomly_move;

for(i = 0; i < 4; i++)
{
cur_board->board_dir[i] = NO_BOARD;
}

cur_board->reset_on_entry = conf->reset_on_entry;
cur_board->reset_on_entry_same_board = conf->reset_on_entry_same_board;
cur_board->restart_if_zapped = conf->restart_if_hurt;
cur_board->time_limit = conf->time_limit;
cur_board->last_key = '?';
Expand Down
22 changes: 21 additions & 1 deletion src/editor/configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ static const struct editor_config_info editor_conf_default =
0, // fire_burns_forever
1, // forest_to_floor
1, // collect_bombs
true, // dragons_can_randomly_move
0, // restart_if_hurt
0, // reset_on_entry
true, // reset_on_entry_same_board
0, // player_locked_ns
0, // player_locked_ew
0, // player_locked_att
Expand Down Expand Up @@ -109,7 +111,7 @@ typedef void (* editor_config_function)(struct editor_config_info *conf,

struct editor_config_entry
{
char option_name[OPTION_NAME_LEN];
const char *option_name;
editor_config_function change_option;
};

Expand Down Expand Up @@ -623,6 +625,12 @@ static void config_board_collect_bombs(struct editor_config_info *conf,
config_boolean(&conf->collect_bombs, value);
}

static void config_board_dragons_random_move(struct editor_config_info *conf,
char *name, char *value, char *extended_data)
{
config_boolean(&conf->dragons_can_randomly_move, value);
}

static void config_board_restart(struct editor_config_info *conf,
char *name, char *value, char *extended_data)
{
Expand All @@ -635,6 +643,12 @@ static void config_board_reset_on_entry(struct editor_config_info *conf,
config_boolean(&conf->reset_on_entry, value);
}

static void config_board_reset_on_entry_same(struct editor_config_info *conf,
char *name, char *value, char *extended_data)
{
config_boolean(&conf->reset_on_entry_same_board, value);
}

static void config_board_locked_ns(struct editor_config_info *conf,
char *name, char *value, char *extended_data)
{
Expand Down Expand Up @@ -714,6 +728,7 @@ static const struct editor_config_entry editor_config_options[] =
{ "board_default_can_shoot", config_board_can_shoot },
{ "board_default_charset_path", config_board_charset },
{ "board_default_collect_bombs", config_board_collect_bombs },
{ "board_default_dragons_can_randomly_move", config_board_dragons_random_move },
{ "board_default_explosions_leave", config_board_explosions },
{ "board_default_fire_burns_brown", config_board_fire_brown },
{ "board_default_fire_burns_fakes", config_board_fire_fakes },
Expand All @@ -728,6 +743,7 @@ static const struct editor_config_entry editor_config_options[] =
{ "board_default_player_locked_ew", config_board_locked_ew },
{ "board_default_player_locked_ns", config_board_locked_ns },
{ "board_default_reset_on_entry", config_board_reset_on_entry },
{ "board_default_reset_on_entry_same_board", config_board_reset_on_entry_same },
{ "board_default_restart_if_hurt", config_board_restart },
{ "board_default_saving", config_board_saving },
{ "board_default_time_limit", config_board_time_limit },
Expand Down Expand Up @@ -965,8 +981,12 @@ void save_local_editor_config(struct editor_config_info *conf,
vf_printf(vf, "board_default_fire_burns_forever = %d\n", conf->fire_burns_forever);
vf_printf(vf, "board_default_forest_to_floor = %d\n", conf->forest_to_floor);
vf_printf(vf, "board_default_collect_bombs = %d\n", conf->collect_bombs);
vf_printf(vf, "board_default_dragons_can_randomly_move = %d\n",
conf->dragons_can_randomly_move);
vf_printf(vf, "board_default_restart_if_hurt = %d\n", conf->restart_if_hurt);
vf_printf(vf, "board_default_reset_on_entry = %d\n", conf->reset_on_entry);
vf_printf(vf, "board_default_reset_on_entry_same_board = %d\n",
conf->reset_on_entry_same_board);
vf_printf(vf, "board_default_player_locked_ns = %d\n", conf->player_locked_ns);
vf_printf(vf, "board_default_player_locked_ew = %d\n", conf->player_locked_ew);
vf_printf(vf, "board_default_player_locked_att = %d\n", conf->player_locked_att);
Expand Down
2 changes: 2 additions & 0 deletions src/editor/configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ struct editor_config_info
boolean fire_burns_forever;
boolean forest_to_floor;
boolean collect_bombs;
boolean dragons_can_randomly_move;
boolean restart_if_hurt;
boolean reset_on_entry;
boolean reset_on_entry_same_board;
boolean player_locked_ns;
boolean player_locked_ew;
boolean player_locked_att;
Expand Down
60 changes: 40 additions & 20 deletions src/editor/edit_di.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,8 @@ int size_pos_vlayer(struct world *mzx_world)
// [ ] Fire burns brown ( ) Can't save
// [ ] Forest to floor ( ) Can save on sensors
// [ ] Collect bombs
// [ ] Fire burns forever ( ) No overlay
// [ ] Fire burns forever
// [ ] Dragons randomly move ( ) No overlay
// [ ] Restart if hurt ( ) Normal overlay
// [ ] Reset board on entry ( ) Static overlay
// [ ] Player locked N/S ( ) Transparent overlay
Expand All @@ -866,6 +867,7 @@ int size_pos_vlayer(struct world *mzx_world)
//
// Charset to load- Palette to load-
// _______________________[v] _______________________[v] //
// [ ] Reset/load when entering from the same board
//
// _OK_ _Cancel_ _Set as defaults_ //
//
Expand All @@ -876,26 +878,37 @@ void board_info(struct world *mzx_world)
{
struct board *src_board = mzx_world->current_board;
int dialog_result;
struct element *elements[11];
struct element *elements[12];
struct dialog di;
int check_box_results[14] =
int check_box_results[15] =
{
src_board->can_shoot, src_board->can_bomb,
src_board->fire_burn_space, src_board->fire_burn_fakes,
src_board->fire_burn_trees, src_board->fire_burn_brown,
src_board->forest_becomes, src_board->collect_bombs,
src_board->fire_burns, src_board->restart_if_zapped,
src_board->fire_burns,
src_board->dragons_can_randomly_move,
src_board->restart_if_zapped,
src_board->reset_on_entry, src_board->player_ns_locked,
src_board->player_ew_locked, src_board->player_attack_locked
};
int check_box_results_2[] =
{
src_board->reset_on_entry_same_board,
};
const char *check_box_strings[] =
{
"Can shoot", "Can bomb", "Fire burns space",
"Fire burns fakes", "Fire burns trees", "Fire burns brown",
"Forest to floor", "Collect bombs", "Fire burns forever",
"Dragons move randomly",
"Restart if hurt", "Reset board on entry", "Player locked N/S",
"Player locked E/W", "Player attack locked"
};
const char *check_box_strings_2[] =
{
"Reset/load when entering from the same board"
};
const char *radio_strings_1[] =
{
"Explosions to space", "Explosions to ash",
Expand Down Expand Up @@ -950,15 +963,15 @@ void board_info(struct world *mzx_world)

do
{
elements[0] = construct_button(13, 21, "OK", 0);
elements[1] = construct_button(19, 21, "Cancel", -1);
elements[2] = construct_button(29, 21, "Set as defaults", 1);
elements[0] = construct_button(13, 22, "OK", 0);
elements[1] = construct_button(19, 22, "Cancel", -1);
elements[2] = construct_button(29, 22, "Set as defaults", 1);

elements[3] = construct_input_box(7, 1, "Board name- ",
BOARD_NAME_SIZE - 1, title_string);

elements[4] = construct_check_box(3, 3, check_box_strings,
14, 20, check_box_results);
elements[4] = construct_check_box(3, 2, check_box_strings,
15, 21, check_box_results);

elements[5] = construct_radio_button(31, 3, radio_strings_1,
3, 19, &radio_result_1);
Expand All @@ -978,8 +991,11 @@ void board_info(struct world *mzx_world)
"Select a palette...", palette_exts, "(none)", 23, 1, "",
palette_string, 2);

elements[11] = construct_check_box(6, 20, check_box_strings_2,
1, 46, check_box_results_2);

construct_dialog(&di, "Board Settings", 10, 0, 60, 24,
elements, 11, pos);
elements, ARRAY_SIZE(elements), pos);

dialog_result = run_dialog(mzx_world, &di);
pos = di.current_element;
Expand All @@ -1001,11 +1017,13 @@ void board_info(struct world *mzx_world)
conf->forest_to_floor = check_box_results[6];
conf->collect_bombs = check_box_results[7];
conf->fire_burns_forever = check_box_results[8];
conf->restart_if_hurt = check_box_results[9];
conf->reset_on_entry = check_box_results[10];
conf->player_locked_ns = check_box_results[11];
conf->player_locked_ew = check_box_results[12];
conf->player_locked_att = check_box_results[13];
conf->dragons_can_randomly_move = check_box_results[9];
conf->restart_if_hurt = check_box_results[10];
conf->reset_on_entry = check_box_results[11];
conf->player_locked_ns = check_box_results[12];
conf->player_locked_ew = check_box_results[13];
conf->player_locked_att = check_box_results[14];
conf->reset_on_entry_same_board = check_box_results_2[0];
conf->explosions_leave = radio_result_1;
conf->saving_enabled = radio_result_2;
conf->overlay_enabled = radio_result_3;
Expand All @@ -1030,11 +1048,13 @@ void board_info(struct world *mzx_world)
src_board->forest_becomes = check_box_results[6];
src_board->collect_bombs = check_box_results[7];
src_board->fire_burns = check_box_results[8];
src_board->restart_if_zapped = check_box_results[9];
src_board->reset_on_entry = check_box_results[10];
src_board->player_ns_locked = check_box_results[11];
src_board->player_ew_locked = check_box_results[12];
src_board->player_attack_locked = check_box_results[13];
src_board->dragons_can_randomly_move = check_box_results[9];
src_board->restart_if_zapped = check_box_results[10];
src_board->reset_on_entry = check_box_results[11];
src_board->player_ns_locked = check_box_results[12];
src_board->player_ew_locked = check_box_results[13];
src_board->player_attack_locked = check_box_results[14];
src_board->reset_on_entry_same_board = check_box_results_2[0];
src_board->explosions_leave = radio_result_1;
src_board->save_mode = radio_result_2;

Expand Down
3 changes: 1 addition & 2 deletions src/game_update_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,7 @@ void update_board(context *ctx)
level_param[level_offset] = current_param & 0xE7;

// One out of 8 moves is random
// This was broken in the port for a long time.
if(mzx_world->version < VERSION_PORT || mzx_world->version >= V293)
if(src_board->dragons_can_randomly_move)
rval = Random(8);

if(!(rval & 0x07))
Expand Down
Loading

0 comments on commit ba2d42f

Please sign in to comment.