1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Remove RWops from check_file_paths

This commit is contained in:
Ted John
2017-02-09 21:48:44 +00:00
parent fbe0e2504a
commit 4ea74ad526
5 changed files with 40 additions and 40 deletions

View File

@@ -17,6 +17,8 @@
#include <string>
#include "core/Console.hpp"
#include "core/Guard.hpp"
#include "core/File.h"
#include "core/FileStream.hpp"
#include "core/String.hpp"
#include "FileClassifier.h"
#include "network/network.h"
@@ -44,6 +46,7 @@ extern "C"
#include "object_list.h"
#include "platform/platform.h"
#include "rct1.h"
#include "rct2.h"
#include "rct2/interop.h"
}
@@ -320,6 +323,36 @@ extern "C"
{
OpenRCT2::_finished = true;
}
bool check_file_path(sint32 pathId)
{
const utf8 * path = get_file_path(pathId);
switch (pathId) {
case PATH_ID_G1:
if (!File::Exists(path))
{
Console::Error::WriteLine("Unable to find '%s'", path);
return false;
}
break;
case PATH_ID_CUSTOM1:
case PATH_ID_CUSTOM2:
if (File::Exists(path))
{
try
{
auto fs = FileStream(path, FILE_MODE_OPEN);
sint32 index = 36 + (pathId - PATH_ID_CUSTOM1);
gRideMusicInfoList[index]->length = fs.GetLength();
}
catch (const Exception &)
{
}
}
break;
}
return true;
}
}
namespace OpenRCT2

View File

@@ -27,6 +27,11 @@ extern "C"
namespace File
{
bool Exists(const std::string &path)
{
return platform_file_exists(path.c_str());
}
bool Copy(const std::string &srcPath, const std::string &dstPath, bool overwrite)
{
return platform_file_copy(srcPath.c_str(), dstPath.c_str(), overwrite);

View File

@@ -21,6 +21,7 @@
namespace File
{
bool Exists(const std::string &path);
bool Copy(const std::string &srcPath, const std::string &dstPath, bool overwrite);
bool Delete(const std::string &path);
bool Move(const std::string &srcPath, const std::string &dstPath);

View File

@@ -377,45 +377,6 @@ sint32 check_file_paths()
return 1;
}
/**
*
* rct2: 0x00674CA5
*/
sint32 check_file_path(sint32 pathId)
{
const utf8* path = get_file_path(pathId);
SDL_RWops *file = SDL_RWFromFile(path, "rb");
switch (pathId) {
case PATH_ID_G1:
if (file == NULL) {
log_fatal("Could not find file %s", path);
return 0;
}
break;
case PATH_ID_CUSTOM1:
if (file != NULL) {
// Store file size in music_custom1_size @ 0x009AF164
gRideMusicInfoList[36]->length = (uint32)SDL_RWsize(file);
}
break;
case PATH_ID_CUSTOM2:
if (file != NULL) {
// Store file size in music_custom2_size @ 0x009AF16E
gRideMusicInfoList[37]->length = (uint32)SDL_RWsize(file);
}
break;
}
if (file != NULL) {
SDL_RWclose(file);
}
return 1;
}
void rct2_update()
{
sint32 tickCount = SDL_GetTicks();

View File

@@ -180,7 +180,7 @@ void rct2_update();
void substitute_path(char *dest, size_t size, const char *path, const char *filename);
sint32 check_mutex();
sint32 check_file_paths();
sint32 check_file_path(sint32 pathId);
bool check_file_path(sint32 pathId);
sint32 check_files_integrity();
const char *get_file_path(sint32 pathId);
void rct2_quit();