refactor GameVersion and QuestScriptVersion into a single enum
This commit is contained in:
+100
-17
@@ -2,18 +2,104 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <phosg/Types.hh>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
enum class GameVersion {
|
||||
PATCH = 0,
|
||||
DC = 1,
|
||||
PC = 2,
|
||||
GC = 3,
|
||||
XB = 4,
|
||||
BB = 5,
|
||||
enum class Version {
|
||||
PC_PATCH = 0,
|
||||
BB_PATCH = 1,
|
||||
DC_NTE = 2,
|
||||
DC_V1_12_2000_PROTOTYPE = 3,
|
||||
DC_V1 = 4,
|
||||
DC_V2 = 5,
|
||||
PC_V2 = 6,
|
||||
GC_NTE = 7,
|
||||
GC_V3 = 8,
|
||||
GC_EP3_TRIAL_EDITION = 9,
|
||||
GC_EP3 = 10,
|
||||
XB_V3 = 11,
|
||||
BB_V4 = 12,
|
||||
UNKNOWN = 15,
|
||||
};
|
||||
|
||||
template <>
|
||||
const char* name_for_enum<Version>(Version v);
|
||||
template <>
|
||||
Version enum_for_name<Version>(const char* name);
|
||||
|
||||
inline bool is_patch(Version version) {
|
||||
return (version == Version::PC_PATCH) || (version == Version::BB_PATCH);
|
||||
}
|
||||
inline bool is_v1(Version version) {
|
||||
return (version == Version::DC_NTE) || (version == Version::DC_V1_12_2000_PROTOTYPE) || (version == Version::DC_V1);
|
||||
}
|
||||
inline bool is_v2(Version version) {
|
||||
return (version == Version::DC_V2) || (version == Version::PC_V2) || (version == Version::GC_NTE);
|
||||
}
|
||||
inline bool is_v1_or_v2(Version version) {
|
||||
return is_v1(version) || is_v2(version);
|
||||
}
|
||||
inline bool is_v3(Version version) {
|
||||
return (version == Version::GC_V3) ||
|
||||
(version == Version::GC_EP3_TRIAL_EDITION) ||
|
||||
(version == Version::GC_EP3) ||
|
||||
(version == Version::XB_V3);
|
||||
}
|
||||
inline bool is_v4(Version version) {
|
||||
return (version == Version::BB_V4);
|
||||
}
|
||||
|
||||
inline bool is_ep3(Version version) {
|
||||
return (version == Version::GC_EP3_TRIAL_EDITION) || (version == Version::GC_EP3);
|
||||
}
|
||||
|
||||
inline bool is_dc(Version version) {
|
||||
return (version == Version::DC_NTE) ||
|
||||
(version == Version::DC_V1_12_2000_PROTOTYPE) ||
|
||||
(version == Version::DC_V1) ||
|
||||
(version == Version::DC_V2);
|
||||
}
|
||||
inline bool is_gc(Version version) {
|
||||
return (version == Version::GC_NTE) ||
|
||||
(version == Version::GC_V3) ||
|
||||
(version == Version::GC_EP3_TRIAL_EDITION) ||
|
||||
(version == Version::GC_EP3);
|
||||
}
|
||||
|
||||
inline bool is_big_endian(Version version) {
|
||||
return (version == Version::GC_NTE) ||
|
||||
(version == Version::GC_V3) ||
|
||||
(version == Version::GC_EP3_TRIAL_EDITION) ||
|
||||
(version == Version::GC_EP3);
|
||||
}
|
||||
inline bool uses_v2_encryption(Version version) {
|
||||
return (version == Version::PC_PATCH) ||
|
||||
(version == Version::BB_PATCH) ||
|
||||
(version == Version::DC_NTE) ||
|
||||
(version == Version::DC_V1) ||
|
||||
(version == Version::DC_V2) ||
|
||||
(version == Version::PC_V2) ||
|
||||
(version == Version::GC_NTE);
|
||||
}
|
||||
inline bool uses_v3_encryption(Version version) {
|
||||
return (version == Version::GC_V3) ||
|
||||
(version == Version::XB_V3) ||
|
||||
(version == Version::GC_EP3);
|
||||
}
|
||||
inline bool uses_v4_encryption(Version version) {
|
||||
return (version == Version::BB_V4);
|
||||
}
|
||||
|
||||
inline bool uses_utf16(Version version) {
|
||||
return (version == Version::PC_PATCH) ||
|
||||
(version == Version::BB_PATCH) ||
|
||||
(version == Version::PC_V2) ||
|
||||
(version == Version::BB_V4);
|
||||
}
|
||||
|
||||
uint32_t default_specific_version_for_version(Version version, int64_t sub_version);
|
||||
|
||||
enum class ServerBehavior {
|
||||
PC_CONSOLE_DETECT = 0,
|
||||
LOGIN_SERVER,
|
||||
@@ -24,14 +110,11 @@ enum class ServerBehavior {
|
||||
PROXY_SERVER,
|
||||
};
|
||||
|
||||
extern const std::vector<std::string> version_to_login_port_name;
|
||||
extern const std::vector<std::string> version_to_lobby_port_name;
|
||||
extern const std::vector<std::string> version_to_proxy_port_name;
|
||||
const char* login_port_name_for_version(Version v);
|
||||
const char* lobby_port_name_for_version(Version v);
|
||||
const char* proxy_port_name_for_version(Version v);
|
||||
|
||||
const char* name_for_version(GameVersion version);
|
||||
GameVersion version_for_name(const char* name);
|
||||
|
||||
const char* name_for_server_behavior(ServerBehavior behavior);
|
||||
ServerBehavior server_behavior_for_name(const char* name);
|
||||
|
||||
uint32_t default_specific_version_for_version(GameVersion version, int64_t sub_version);
|
||||
template <>
|
||||
const char* name_for_enum<ServerBehavior>(ServerBehavior behavior);
|
||||
template <>
|
||||
ServerBehavior enum_for_name<ServerBehavior>(const char* name);
|
||||
|
||||
Reference in New Issue
Block a user