Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dragon randomness, 1.x slimes, and reset/load on entry. #403

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ USERS
now invokes the macro instead of just inserting a line.
+ Fixed a bug where stdio redirect could generate corrupted log
files on the Nintendo DS due to poor freopen support.
+ Reset Board on Entry and load charset/palette on entry now
optionally will be performed even if re-entering a board from
itself (enabled by default).
+ Fixed a Reset Board on Entry bug where a temporary board would
not be generated when loading the title screen or if the
starting board is the title board.
Expand Down Expand Up @@ -275,6 +278,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 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
45 changes: 33 additions & 12 deletions src/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ static int save_board_info(struct board *cur_board, struct zip_archive *zp,
tmp = cur_board->palette_path ? cur_board->palette_path : "";
save_prop_s(BPROP_PALETTE_PATH, tmp, &mf);

if(world_version >= V293)
{
save_prop_c(BPROP_RESET_ON_ENTRY_SAME_BOARD,
cur_board->reset_on_entry_same_board, &mf);
save_prop_c(BPROP_DRAGONS_CAN_RANDOMLY_MOVE,
cur_board->dragons_can_randomly_move, &mf);
}

if(savegame)
{
save_prop_w(BPROP_SCROLL_X, cur_board->scroll_x, &mf);
Expand Down Expand Up @@ -251,7 +259,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 +277,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 +327,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 +421,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 +633,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 +812,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 +823,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 +1238,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
Loading