Browse Source

Added case handling for when a leaving_level_movie already exists, and a file is in the default movie's pending position. This case may occur when overwriting an existing installation (using a patcher or otherwise).

master
Jessica James 9 years ago
parent
commit
d868aa2ee9
  1. 26
      Rx_SetStartupMovie/Rx_SetStartupMovie.c

26
Rx_SetStartupMovie/Rx_SetStartupMovie.c

@ -145,10 +145,20 @@ __declspec(dllexport) void SetStartupMovie(wchar_t *in_leaving_level, wchar_t *i
{
fclose(file);
// A level-specific movie is currently in position; move it
strcpy(leaving_level_movie_filename, movie_prefix);
strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1, leaving_level);
strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1 + leaving_level_length, movie_file_extension);
// Check if leaving_level_movie already exists
file = fopen(leaving_level_movie_filename, "rb");
if (file != NULL)
{
fclose(file);
// Assume the loaded movie is default (as would be the case after an update/reinstall); remove old default movie
remove(movie_prefix);
}
else // A level-specific movie is currently in position; move it
rename(movie_filename, leaving_level_movie_filename);
}
else // The default movie is currently in position; move it.
@ -165,15 +175,27 @@ __declspec(dllexport) void SetStartupMovie(wchar_t *in_leaving_level, wchar_t *i
{
fclose(file);
// A level-specific movie is currently in position; move it
strcpy(leaving_level_movie_filename, movie_prefix);
strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1, leaving_level);
strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1 + leaving_level_length, movie_file_extension);
// Check if leaving_level_movie already exists
file = fopen(leaving_level_movie_filename, "rb");
if (file != NULL)
{
fclose(file);
// Assume the loaded movie is default (as would be the case after an update/reinstall); remove old default movie
remove(movie_prefix);
}
else // A level-specific movie is currently in position; move it
{
rename(movie_filename, leaving_level_movie_filename);
// Move the default movie into position
rename(movie_prefix, movie_filename);
}
}
// else // Default movie is already in position; nothing to do
}
}

Loading…
Cancel
Save