mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Use enum class instead of enum
This commit is contained in:
@@ -42,18 +42,18 @@ public:
|
||||
|
||||
std::string GetDirectoryPath(DIRBASE base, DIRID did) const override
|
||||
{
|
||||
const utf8 * basePath = _basePath[base].c_str();
|
||||
const utf8 * basePath = _basePath[(size_t)base].c_str();
|
||||
const utf8 * directoryName;
|
||||
switch (base) {
|
||||
default:
|
||||
case DIRBASE_RCT1:
|
||||
case DIRBASE::RCT1:
|
||||
throw Exception("Not implemented");
|
||||
case DIRBASE_RCT2:
|
||||
directoryName = DirectoryNamesRCT2[did];
|
||||
case DIRBASE::RCT2:
|
||||
directoryName = DirectoryNamesRCT2[(size_t)did];
|
||||
break;
|
||||
case DIRBASE_OPENRCT2:
|
||||
case DIRBASE_USER:
|
||||
directoryName = DirectoryNamesOpenRCT2[did];
|
||||
case DIRBASE::OPENRCT2:
|
||||
case DIRBASE::USER:
|
||||
directoryName = DirectoryNamesOpenRCT2[(size_t)did];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public:
|
||||
|
||||
std::string GetFilePath(PATHID pathid) const override
|
||||
{
|
||||
const utf8 * basePath = _basePath[DIRBASE_USER].c_str();
|
||||
const utf8 * fileName = FileNames[pathid];
|
||||
const utf8 * basePath = _basePath[(size_t)DIRBASE::USER].c_str();
|
||||
const utf8 * fileName = FileNames[(size_t)pathid];
|
||||
|
||||
utf8 path[260];
|
||||
String::Set(path, sizeof(path), basePath);
|
||||
@@ -84,58 +84,58 @@ IPlatformEnvironment * CreatePlatformEnvironment()
|
||||
{
|
||||
utf8 path[260];
|
||||
std::string basePaths[4];
|
||||
basePaths[DIRBASE_RCT2] = std::string(gRCT2AddressAppPath);
|
||||
basePaths[(size_t)DIRBASE::RCT2] = std::string(gRCT2AddressAppPath);
|
||||
platform_get_openrct_data_path(path, sizeof(path));
|
||||
basePaths[DIRBASE_OPENRCT2] = std::string(path);
|
||||
platform_get_user_directory(path, NULL, sizeof(path));
|
||||
basePaths[DIRBASE_USER] = std::string(path);
|
||||
basePaths[(size_t)DIRBASE::OPENRCT2] = std::string(path);
|
||||
platform_get_user_directory(path, nullptr, sizeof(path));
|
||||
basePaths[(size_t)DIRBASE::USER] = std::string(path);
|
||||
return new PlatformEnvironment(basePaths);
|
||||
}
|
||||
|
||||
const char * PlatformEnvironment::DirectoryNamesRCT2[] =
|
||||
{
|
||||
"Data", // DIRID_DATA
|
||||
"Landscapes", // DIRID_LANDSCAPE
|
||||
nullptr, // DIRID_LANGUAGE
|
||||
nullptr, // DIRID_LOG_CHAT
|
||||
nullptr, // DIRID_LOG_SERVER
|
||||
nullptr, // DIRID_NETWORK_KEY
|
||||
"ObjData", // DIRID_OBJECT
|
||||
"Saved Games", // DIRID_SAVE
|
||||
"Scenarios", // DIRID_SCENARIO
|
||||
nullptr, // DIRID_SCREENSHOT
|
||||
nullptr, // DIRID_SEQUENCE
|
||||
nullptr, // DIRID_SHADER
|
||||
nullptr, // DIRID_THEME
|
||||
"Tracks", // DIRID_TRACK
|
||||
"Data", // DATA
|
||||
"Landscapes", // LANDSCAPE
|
||||
nullptr, // LANGUAGE
|
||||
nullptr, // LOG_CHAT
|
||||
nullptr, // LOG_SERVER
|
||||
nullptr, // NETWORK_KEY
|
||||
"ObjData", // OBJECT
|
||||
"Saved Games", // SAVE
|
||||
"Scenarios", // SCENARIO
|
||||
nullptr, // SCREENSHOT
|
||||
nullptr, // SEQUENCE
|
||||
nullptr, // SHADER
|
||||
nullptr, // THEME
|
||||
"Tracks", // TRACK
|
||||
};
|
||||
|
||||
const char * PlatformEnvironment::DirectoryNamesOpenRCT2[] =
|
||||
{
|
||||
"data", // DIRID_DATA
|
||||
"landscape", // DIRID_LANDSCAPE
|
||||
"language", // DIRID_LANGUAGE
|
||||
"chatlogs", // DIRID_LOG_CHAT
|
||||
"serverlogs", // DIRID_LOG_SERVER
|
||||
"keys", // DIRID_NETWORK_KEY
|
||||
"object", // DIRID_OBJECT
|
||||
"save", // DIRID_SAVE
|
||||
"scenario", // DIRID_SCENARIO
|
||||
"screenshot", // DIRID_SCREENSHOT
|
||||
"sequence", // DIRID_SEQUENCE
|
||||
"shader", // DIRID_SHADER
|
||||
"themes", // DIRID_THEME
|
||||
"track", // DIRID_TRACK
|
||||
"data", // DATA
|
||||
"landscape", // LANDSCAPE
|
||||
"language", // LANGUAGE
|
||||
"chatlogs", // LOG_CHAT
|
||||
"serverlogs", // LOG_SERVER
|
||||
"keys", // NETWORK_KEY
|
||||
"object", // OBJECT
|
||||
"save", // SAVE
|
||||
"scenario", // SCENARIO
|
||||
"screenshot", // SCREENSHOT
|
||||
"sequence", // SEQUENCE
|
||||
"shader", // SHADER
|
||||
"themes", // THEME
|
||||
"track", // TRACK
|
||||
};
|
||||
|
||||
const char * PlatformEnvironment::FileNames[] =
|
||||
{
|
||||
"config.ini", // PATHID_CONFIG
|
||||
"hotkeys.dat", // PATHID_CONFIG_KEYBOARD
|
||||
"objects.idx", // PATHID_CACHE_OBJECTS
|
||||
"tracks.idx", // PATHID_CACHE_TRACKS
|
||||
"groups.json", // PATHID_NETWORK_GROUPS
|
||||
"servers.cfg", // PATHID_NETWORK_SERVERS
|
||||
"users.json", // PATHID_NETWORK_USERS
|
||||
"highscores.dat", // PATHID_SCORES
|
||||
"config.ini", // CONFIG
|
||||
"hotkeys.dat", // CONFIG_KEYBOARD
|
||||
"objects.idx", // CACHE_OBJECTS
|
||||
"tracks.idx", // CACHE_TRACKS
|
||||
"groups.json", // NETWORK_GROUPS
|
||||
"servers.cfg", // NETWORK_SERVERS
|
||||
"users.json", // NETWORK_USERS
|
||||
"highscores.dat", // SCORES
|
||||
};
|
||||
|
||||
@@ -19,42 +19,42 @@
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
|
||||
enum DIRBASE
|
||||
enum class DIRBASE
|
||||
{
|
||||
DIRBASE_RCT1, // Base directory for original RollerCoaster Tycoon 1 content.
|
||||
DIRBASE_RCT2, // Base directory for original RollerCoaster Tycoon 2 content.
|
||||
DIRBASE_OPENRCT2, // Base directory for OpenRCT2 installation.
|
||||
DIRBASE_USER, // Base directory for OpenRCT2 user content.
|
||||
RCT1, // Base directory for original RollerCoaster Tycoon 1 content.
|
||||
RCT2, // Base directory for original RollerCoaster Tycoon 2 content.
|
||||
OPENRCT2, // Base directory for OpenRCT2 installation.
|
||||
USER, // Base directory for OpenRCT2 user content.
|
||||
};
|
||||
|
||||
enum DIRID
|
||||
enum class DIRID
|
||||
{
|
||||
DIRID_DATA, // Contains g1.dat, music etc.
|
||||
DIRID_LANDSCAPE, // Contains scenario editor landscapes (SC6).
|
||||
DIRID_LANGUAGE, // Contains language packs.
|
||||
DIRID_LOG_CHAT, // Contains chat logs.
|
||||
DIRID_LOG_SERVER, // Contains server logs.
|
||||
DIRID_NETWORK_KEY, // Contains the user's public and private keys.
|
||||
DIRID_OBJECT, // Contains objects.
|
||||
DIRID_SAVE, // Contains saved games (SV6).
|
||||
DIRID_SCENARIO, // Contains scenarios (SC6).
|
||||
DIRID_SCREENSHOT, // Contains screenshots.
|
||||
DIRID_SEQUENCE, // Contains title sequences.
|
||||
DIRID_SHADER, // Contains OpenGL shaders.
|
||||
DIRID_THEME, // Contains interface themes.
|
||||
DIRID_TRACK, // Contains track designs.
|
||||
DATA, // Contains g1.dat, music etc.
|
||||
LANDSCAPE, // Contains scenario editor landscapes (SC6).
|
||||
LANGUAGE, // Contains language packs.
|
||||
LOG_CHAT, // Contains chat logs.
|
||||
LOG_SERVER, // Contains server logs.
|
||||
NETWORK_KEY, // Contains the user's public and private keys.
|
||||
OBJECT, // Contains objects.
|
||||
SAVE, // Contains saved games (SV6).
|
||||
SCENARIO, // Contains scenarios (SC6).
|
||||
SCREENSHOT, // Contains screenshots.
|
||||
SEQUENCE, // Contains title sequences.
|
||||
SHADER, // Contains OpenGL shaders.
|
||||
THEME, // Contains interface themes.
|
||||
TRACK, // Contains track designs.
|
||||
};
|
||||
|
||||
enum PATHID
|
||||
enum class PATHID
|
||||
{
|
||||
PATHID_CONFIG, // Main configuration (config.ini).
|
||||
PATHID_CONFIG_KEYBOARD, // Keyboard shortcuts. (hotkeys.cfg)
|
||||
PATHID_CACHE_OBJECTS, // Object repository cache (objects.idx).
|
||||
PATHID_CACHE_TRACKS, // Track repository cache (tracks.idx).
|
||||
PATHID_NETWORK_GROUPS, // Server groups with permissions (groups.json).
|
||||
PATHID_NETWORK_SERVERS, // Saved servers (servers.cfg).
|
||||
PATHID_NETWORK_USERS, // Users and their groups (users.json).
|
||||
PATHID_SCORES, // Scenario scores (highscores.dat).
|
||||
CONFIG, // Main configuration (config.ini).
|
||||
CONFIG_KEYBOARD, // Keyboard shortcuts. (hotkeys.cfg)
|
||||
CACHE_OBJECTS, // Object repository cache (objects.idx).
|
||||
CACHE_TRACKS, // Track repository cache (tracks.idx).
|
||||
NETWORK_GROUPS, // Server groups with permissions (groups.json).
|
||||
NETWORK_SERVERS, // Saved servers (servers.cfg).
|
||||
NETWORK_USERS, // Users and their groups (users.json).
|
||||
SCORES, // Scenario scores (highscores.dat).
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,8 +117,8 @@ public:
|
||||
|
||||
_queryDirectoryResult = { 0 };
|
||||
|
||||
const std::string &rct2Path = _env->GetDirectoryPath(DIRBASE_RCT2, DIRID_OBJECT);
|
||||
const std::string &openrct2Path = _env->GetDirectoryPath(DIRBASE_OPENRCT2, DIRID_OBJECT);
|
||||
const std::string &rct2Path = _env->GetDirectoryPath(DIRBASE::RCT2, DIRID::OBJECT);
|
||||
const std::string &openrct2Path = _env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT);
|
||||
QueryDirectory(&_queryDirectoryResult, rct2Path);
|
||||
QueryDirectory(&_queryDirectoryResult, openrct2Path);
|
||||
|
||||
@@ -251,8 +251,8 @@ private:
|
||||
auto stopwatch = Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
const std::string &rct2Path = _env->GetDirectoryPath(DIRBASE_RCT2, DIRID_OBJECT);
|
||||
const std::string &openrct2Path = _env->GetDirectoryPath(DIRBASE_OPENRCT2, DIRID_OBJECT);
|
||||
const std::string &rct2Path = _env->GetDirectoryPath(DIRBASE::RCT2, DIRID::OBJECT);
|
||||
const std::string &openrct2Path = _env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT);
|
||||
ScanDirectory(rct2Path);
|
||||
ScanDirectory(openrct2Path);
|
||||
|
||||
@@ -293,7 +293,7 @@ private:
|
||||
|
||||
bool Load()
|
||||
{
|
||||
const std::string &path = _env->GetFilePath(PATHID_CACHE_OBJECTS);
|
||||
const std::string &path = _env->GetFilePath(PATHID::CACHE_OBJECTS);
|
||||
try
|
||||
{
|
||||
auto fs = FileStream(path, FILE_MODE_OPEN);
|
||||
@@ -332,7 +332,7 @@ private:
|
||||
|
||||
void Save() const
|
||||
{
|
||||
const std::string &path = _env->GetFilePath(PATHID_CACHE_OBJECTS);
|
||||
const std::string &path = _env->GetFilePath(PATHID::CACHE_OBJECTS);
|
||||
try
|
||||
{
|
||||
auto fs = FileStream(path, FILE_MODE_WRITE);
|
||||
@@ -594,7 +594,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &userObjPath = _env->GetDirectoryPath(DIRBASE_USER, DIRID_OBJECT);
|
||||
const std::string &userObjPath = _env->GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT);
|
||||
String::Set(buffer, bufferSize, userObjPath.c_str());
|
||||
platform_ensure_directory_exists(buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user