Skip to content

Commit

Permalink
Add v1 effect durations tests, fix title board edge case.
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLR committed Dec 2, 2023
1 parent 44bf5d7 commit 09c2582
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 13 deletions.
8 changes: 8 additions & 0 deletions src/utils/downver.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ static void convert_293_to_292_board_info(struct downver_state *dv,
save_prop_s_to_asciiz(ident, BOARD_NAME_SIZE, &prop, dest);
break;

case BPROP_BLIND_DUR:
case BPROP_FIREWALKER_DUR:
case BPROP_FREEZE_TIME_DUR:
case BPROP_SLOW_TIME_DUR:
case BPROP_WIND_DUR:
/* Added in 2.93 */
break;

default:
save_prop_p(ident, &prop, dest);
break;
Expand Down
41 changes: 28 additions & 13 deletions src/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -2508,7 +2508,8 @@ static int load_world_zip(struct world *mzx_world, struct zip_archive *zp,


// Hack- forward declaration since this should stay near change_board.
static void synchronize_current_board(struct world *mzx_world);
static void v1_store_globals_to_board(struct world *mzx_world);
static void v1_load_globals_from_board(struct world *mzx_world);

int save_world(struct world *mzx_world, const char *file, boolean savegame,
int world_version)
Expand Down Expand Up @@ -2577,7 +2578,7 @@ int save_world(struct world *mzx_world, const char *file, boolean savegame,
}

// Synchronize global variables in the current board.
synchronize_current_board(mzx_world);
v1_store_globals_to_board(mzx_world);

#ifdef CONFIG_EDITOR
if(world_version == MZX_VERSION_PREV)
Expand Down Expand Up @@ -2928,6 +2929,8 @@ static void load_world(struct world *mzx_world, struct zip_archive *zp,
mzx_world->current_board = NULL;
set_current_board_ext(mzx_world,
mzx_world->board_list[mzx_world->current_board_id]);
// change_board expects this to have been done, if applicable.
v1_load_globals_from_board(mzx_world);
}

// If this is a pre-port world, limit the number of samples
Expand Down Expand Up @@ -3169,7 +3172,7 @@ void try_load_world(struct world *mzx_world, struct zip_archive **zp,
}


static void synchronize_current_board(struct world *mzx_world)
static void v1_store_globals_to_board(struct world *mzx_world)
{
struct board *cur_board = mzx_world->current_board;

Expand All @@ -3185,12 +3188,28 @@ static void synchronize_current_board(struct world *mzx_world)
}
}

static void v1_load_globals_from_board(struct world *mzx_world)
{
struct board *cur_board = mzx_world->current_board;

// MegaZeux 1.x- status durations were board local, restore the saved copies.
if(mzx_world->version < V200 && cur_board)
{
mzx_world->blind_dur = cur_board->blind_dur_v1;
mzx_world->firewalker_dur = cur_board->firewalker_dur_v1;
mzx_world->freeze_time_dur = cur_board->freeze_time_dur_v1;
mzx_world->slow_time_dur = cur_board->slow_time_dur_v1;
mzx_world->wind_dur = cur_board->wind_dur_v1;
}
}

void change_board(struct world *mzx_world, int board_id)
{
// Set the current board during gameplay.
struct board *cur_board = mzx_world->current_board;

synchronize_current_board(mzx_world);
// Save globals back to the current board.
v1_store_globals_to_board(mzx_world);

// Is this board temporary? Clear it
if(mzx_world->temporary_board)
Expand Down Expand Up @@ -3219,15 +3238,8 @@ void change_board(struct world *mzx_world, int board_id)
cur_board = dup_board;
}

// MegaZeux 1.x- status durations were board local, restore the saved copies.
if(mzx_world->version < V200)
{
mzx_world->blind_dur = cur_board->blind_dur_v1;
mzx_world->firewalker_dur = cur_board->firewalker_dur_v1;
mzx_world->freeze_time_dur = cur_board->freeze_time_dur_v1;
mzx_world->slow_time_dur = cur_board->slow_time_dur_v1;
mzx_world->wind_dur = cur_board->wind_dur_v1;
}
// Load globals from the current board.
v1_load_globals_from_board(mzx_world);
}

void change_board_set_values(struct world *mzx_world)
Expand Down Expand Up @@ -3423,6 +3435,9 @@ boolean reload_world(struct world *mzx_world, const char *file, boolean *faded)
default_global_data(mzx_world);
*faded = false;

// Hack: 1.x seems to not clear some things...
v1_load_globals_from_board(mzx_world);

// Now that the world's loaded, fix the save path.
{
char save_name[MAX_PATH];
Expand Down
Binary file added testworlds/1.00/006 firewalker_dur.mzx
Binary file not shown.
3 changes: 3 additions & 0 deletions testworlds/1.00/006 firewalker_dur.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Title: Firewalker Duration Test
Author: Alice Rowan
Desc: Make sure the board firewalker duration value is loaded.
Binary file added testworlds/1.00/007 wind_dur.mzx
Binary file not shown.
3 changes: 3 additions & 0 deletions testworlds/1.00/007 wind_dur.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Title: Wind Duration Test
Author: Alice Rowan
Desc: Make sure the board wind duration value is loaded.

0 comments on commit 09c2582

Please sign in to comment.