make enum style consistent

This commit is contained in:
Martin Michelsen
2022-03-26 16:11:59 -07:00
parent bd8aadb09f
commit fa07ce457b
20 changed files with 275 additions and 275 deletions
+19 -19
View File
@@ -363,7 +363,7 @@ static void check_is_game(shared_ptr<Lobby> l, bool is_game) {
}
static void check_is_ep3(shared_ptr<Client> c, bool is_ep3) {
if (!!(c->flags & ClientFlag::Episode3Games) != is_ep3) {
if (!!(c->flags & ClientFlag::EPISODE_3_GAMES) != is_ep3) {
throw precondition_failed(is_ep3 ?
u"$C6This command can only\nbe used in Episode 3." :
u"$C6This command cannot\nbe used in Episode 3.");
@@ -371,7 +371,7 @@ static void check_is_ep3(shared_ptr<Client> c, bool is_ep3) {
}
static void check_cheats_enabled(shared_ptr<Lobby> l) {
if (!(l->flags & LobbyFlag::CheatsEnabled)) {
if (!(l->flags & LobbyFlag::CHEATS_ENABLED)) {
throw precondition_failed(u"$C6This command can\nonly be used in\ncheat mode.");
}
}
@@ -405,7 +405,7 @@ static void command_lobby_info(shared_ptr<ServerState>, shared_ptr<Lobby> l,
send_text_message_printf(c, "$C6Game ID: %08X\n%s\nSection ID: %s\nCheat mode: %s",
l->lobby_id, level_string.c_str(),
name_for_section_id(l->section_id).c_str(),
(l->flags & LobbyFlag::CheatsEnabled) ? "on" : "off");
(l->flags & LobbyFlag::CHEATS_ENABLED) ? "on" : "off");
} else {
size_t num_clients = l->count_clients();
@@ -417,14 +417,14 @@ static void command_lobby_info(shared_ptr<ServerState>, shared_ptr<Lobby> l,
static void command_ax(shared_ptr<ServerState>, shared_ptr<Lobby>,
shared_ptr<Client> c, const char16_t* args) {
check_privileges(c, Privilege::Announce);
check_privileges(c, Privilege::ANNOUNCE);
string message = encode_sjis(args);
log(INFO, "[Client message from %010u] %s\n", c->license->serial_number, message.c_str());
}
static void command_announce(shared_ptr<ServerState> s, shared_ptr<Lobby>,
shared_ptr<Client> c, const char16_t* args) {
check_privileges(c, Privilege::Announce);
check_privileges(c, Privilege::ANNOUNCE);
send_text_message(s, args);
}
@@ -445,12 +445,12 @@ static void command_cheat(shared_ptr<ServerState>, shared_ptr<Lobby> l,
check_is_game(l, true);
check_is_leader(l, c);
l->flags ^= LobbyFlag::CheatsEnabled;
l->flags ^= LobbyFlag::CHEATS_ENABLED;
send_text_message_printf(l, "Cheat mode %s",
(l->flags & LobbyFlag::CheatsEnabled) ? "enabled" : "disabled");
(l->flags & LobbyFlag::CHEATS_ENABLED) ? "enabled" : "disabled");
// if cheat mode was disabled, turn off all the cheat features that were on
if (!(l->flags & LobbyFlag::CheatsEnabled)) {
if (!(l->flags & LobbyFlag::CHEATS_ENABLED)) {
for (size_t x = 0; x < l->max_clients; x++) {
auto c = l->clients[x];
if (!c) {
@@ -466,7 +466,7 @@ static void command_cheat(shared_ptr<ServerState>, shared_ptr<Lobby> l,
static void command_lobby_event(shared_ptr<ServerState>, shared_ptr<Lobby> l,
shared_ptr<Client> c, const char16_t* args) {
check_is_game(l, false);
check_privileges(c, Privilege::ChangeEvent);
check_privileges(c, Privilege::CHANGE_EVENT);
uint8_t new_event = event_for_name(args);
if (new_event == 0xFF) {
@@ -480,7 +480,7 @@ static void command_lobby_event(shared_ptr<ServerState>, shared_ptr<Lobby> l,
static void command_lobby_event_all(shared_ptr<ServerState> s, shared_ptr<Lobby>,
shared_ptr<Client> c, const char16_t* args) {
check_privileges(c, Privilege::ChangeEvent);
check_privileges(c, Privilege::CHANGE_EVENT);
uint8_t new_event = event_for_name(args);
if (new_event == 0xFF) {
@@ -489,7 +489,7 @@ static void command_lobby_event_all(shared_ptr<ServerState> s, shared_ptr<Lobby>
}
for (auto l : s->all_lobbies()) {
if (l->is_game() || !(l->flags & LobbyFlag::Default)) {
if (l->is_game() || !(l->flags & LobbyFlag::DEFAULT)) {
continue;
}
@@ -501,7 +501,7 @@ static void command_lobby_event_all(shared_ptr<ServerState> s, shared_ptr<Lobby>
static void command_lobby_type(shared_ptr<ServerState>, shared_ptr<Lobby> l,
shared_ptr<Client> c, const char16_t* args) {
check_is_game(l, false);
check_privileges(c, Privilege::ChangeEvent);
check_privileges(c, Privilege::CHANGE_EVENT);
uint8_t new_type = lobby_type_for_name(args);
if (new_type == 0x80) {
@@ -510,7 +510,7 @@ static void command_lobby_type(shared_ptr<ServerState>, shared_ptr<Lobby> l,
}
l->type = new_type;
if (l->type < ((l->flags & LobbyFlag::Episode3) ? 20 : 15)) {
if (l->type < ((l->flags & LobbyFlag::EPISODE_3) ? 20 : 15)) {
l->type = l->block - 1;
}
@@ -701,7 +701,7 @@ static void command_convert_char_to_bb(shared_ptr<ServerState> s,
static void command_silence(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
shared_ptr<Client> c, const char16_t* args) {
check_privileges(c, Privilege::SilenceUser);
check_privileges(c, Privilege::SILENCE_USER);
auto target = s->find_client(args);
if (!target->license) {
@@ -710,7 +710,7 @@ static void command_silence(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
return;
}
if (target->license->privileges & Privilege::Moderator) {
if (target->license->privileges & Privilege::MODERATOR) {
send_text_message(c, u"$C6You do not have\nsufficient privileges.");
return;
}
@@ -723,7 +723,7 @@ static void command_silence(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
static void command_kick(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
shared_ptr<Client> c, const char16_t* args) {
check_privileges(c, Privilege::KickUser);
check_privileges(c, Privilege::KICK_USER);
auto target = s->find_client(args);
if (!target->license) {
@@ -732,7 +732,7 @@ static void command_kick(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
return;
}
if (target->license->privileges & Privilege::Moderator) {
if (target->license->privileges & Privilege::MODERATOR) {
send_text_message(c, u"$C6You do not have\nsufficient privileges.");
return;
}
@@ -745,7 +745,7 @@ static void command_kick(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
static void command_ban(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
shared_ptr<Client> c, const char16_t* args) {
check_privileges(c, Privilege::BanUser);
check_privileges(c, Privilege::BAN_USER);
u16string args_str(args);
size_t space_pos = args_str.find(L' ');
@@ -761,7 +761,7 @@ static void command_ban(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
return;
}
if (target->license->privileges & Privilege::BanUser) {
if (target->license->privileges & Privilege::BAN_USER) {
send_text_message(c, u"$C6You do not have\nsufficient privileges.");
return;
}
+5 -5
View File
@@ -11,11 +11,11 @@
enum class ServerBehavior {
SplitReconnect = 0,
LoginServer,
LobbyServer,
DataServerBB,
PatchServer,
SPLIT_RECONNECT = 0,
LOGIN_SERVER,
LOBBY_SERVER,
DATA_SERVER_BB,
PATCH_SERVER,
};
struct ClientConfig {
+1 -1
View File
@@ -944,7 +944,7 @@ void IPStackSimulator::on_server_error(
void IPStackSimulator::log_frame(const string& data) const {
if (this->pcap_text_log_file) {
print_data(this->pcap_text_log_file, data, 0, nullptr,
PrintDataFlags::SkipSeparator);
PrintDataFlags::SKIP_SEPARATOR);
fputc('\n', this->pcap_text_log_file);
fflush(this->pcap_text_log_file);
}
+12 -12
View File
@@ -6,25 +6,25 @@
#include <memory>
enum Privilege {
KickUser = 0x00000001,
BanUser = 0x00000002,
SilenceUser = 0x00000004,
ChangeLobbyInfo = 0x00000008,
ChangeEvent = 0x00000010,
Announce = 0x00000020,
FreeJoinGames = 0x00000040,
UnlockGames = 0x00000080,
KICK_USER = 0x00000001,
BAN_USER = 0x00000002,
SILENCE_USER = 0x00000004,
CHANGE_LOBBY_INFO = 0x00000008,
CHANGE_EVENT = 0x00000010,
ANNOUNCE = 0x00000020,
FREE_JOIN_GAMES = 0x00000040,
UNLOCK_GAMES = 0x00000080,
Moderator = 0x00000007,
Administrator = 0x0000003F,
Root = 0xFFFFFFFF,
MODERATOR = 0x00000007,
ADMINISTRATOR = 0x0000003F,
ROOT = 0xFFFFFFFF,
};
enum LicenseVerifyAction {
BB = 0x00,
GC = 0x01,
PC = 0x02,
SerialNumber = 0x03,
SERIAL_NUMBER = 0x03,
};
struct License {
+2 -2
View File
@@ -27,7 +27,7 @@ Lobby::Lobby() : lobby_id(0), min_level(0), max_level(0xFFFFFFFF),
}
bool Lobby::is_game() const {
return this->flags & LobbyFlag::IsGame;
return this->flags & LobbyFlag::IS_GAME;
}
void Lobby::reassign_leader_on_client_departure(size_t leaving_client_index) {
@@ -48,7 +48,7 @@ bool Lobby::any_client_loading() const {
if (!this->clients[x].get()) {
continue;
}
if (this->clients[x]->flags & ClientFlag::Loading) {
if (this->clients[x]->flags & ClientFlag::LOADING) {
return true;
}
}
+8 -8
View File
@@ -10,14 +10,14 @@
#include "RareItemSet.hh"
enum LobbyFlag {
IsGame = 0x01,
CheatsEnabled = 0x02, // game only
Public = 0x04, // lobby only
Episode3 = 0x08, // lobby & game
QuestInProgress = 0x10, // game only
JoinableQuestInProgress = 0x20, // game only
Default = 0x40, // lobby only; not set for games and private lobbies
Persistent = 0x80, // if not set, lobby is deleted when empty
IS_GAME = 0x01,
CHEATS_ENABLED = 0x02, // game only
PUBLIC = 0x04, // lobby only
EPISODE_3 = 0x08, // lobby & game
QUEST_IN_PROGRESS = 0x10, // game only
JOINABLE_QUEST_IN_PROGRESS = 0x20, // game only
DEFAULT = 0x40, // lobby only; not set for games and private lobbies
PERSISTENT = 0x80, // if not set, lobby is deleted when empty
};
struct Lobby {
+23 -23
View File
@@ -31,26 +31,26 @@ FileContentsCache file_cache;
static const unordered_map<string, PortConfiguration> default_port_to_behavior({
{"gc-jp10", {9000, GameVersion::GC, ServerBehavior::LoginServer}},
{"gc-jp11", {9001, GameVersion::GC, ServerBehavior::LoginServer}},
{"gc-jp3", {9003, GameVersion::GC, ServerBehavior::LoginServer}},
{"gc-us10", {9100, GameVersion::PC, ServerBehavior::SplitReconnect}},
{"gc-us3", {9103, GameVersion::GC, ServerBehavior::LoginServer}},
{"gc-eu10", {9200, GameVersion::GC, ServerBehavior::LoginServer}},
{"gc-eu11", {9201, GameVersion::GC, ServerBehavior::LoginServer}},
{"gc-eu3", {9203, GameVersion::GC, ServerBehavior::LoginServer}},
{"pc-login", {9300, GameVersion::PC, ServerBehavior::LoginServer}},
{"pc-patch", {10000, GameVersion::Patch, ServerBehavior::PatchServer}},
{"bb-patch", {11000, GameVersion::Patch, ServerBehavior::PatchServer}},
{"bb-data", {12000, GameVersion::BB, ServerBehavior::DataServerBB}},
{"gc-jp10", {9000, GameVersion::GC, ServerBehavior::LOGIN_SERVER}},
{"gc-jp11", {9001, GameVersion::GC, ServerBehavior::LOGIN_SERVER}},
{"gc-jp3", {9003, GameVersion::GC, ServerBehavior::LOGIN_SERVER}},
{"gc-us10", {9100, GameVersion::PC, ServerBehavior::SPLIT_RECONNECT}},
{"gc-us3", {9103, GameVersion::GC, ServerBehavior::LOGIN_SERVER}},
{"gc-eu10", {9200, GameVersion::GC, ServerBehavior::LOGIN_SERVER}},
{"gc-eu11", {9201, GameVersion::GC, ServerBehavior::LOGIN_SERVER}},
{"gc-eu3", {9203, GameVersion::GC, ServerBehavior::LOGIN_SERVER}},
{"pc-login", {9300, GameVersion::PC, ServerBehavior::LOGIN_SERVER}},
{"pc-patch", {10000, GameVersion::PATCH, ServerBehavior::PATCH_SERVER}},
{"bb-patch", {11000, GameVersion::PATCH, ServerBehavior::PATCH_SERVER}},
{"bb-data", {12000, GameVersion::BB, ServerBehavior::DATA_SERVER_BB}},
// these aren't hardcoded in any games; user can override them
{"bb-data1", {12004, GameVersion::BB, ServerBehavior::DataServerBB}},
{"bb-data2", {12005, GameVersion::BB, ServerBehavior::DataServerBB}},
{"bb-login", {12008, GameVersion::BB, ServerBehavior::LoginServer}},
{"pc-lobby", {9420, GameVersion::PC, ServerBehavior::LobbyServer}},
{"gc-lobby", {9421, GameVersion::GC, ServerBehavior::LobbyServer}},
{"bb-lobby", {9422, GameVersion::BB, ServerBehavior::LobbyServer}},
{"bb-data1", {12004, GameVersion::BB, ServerBehavior::DATA_SERVER_BB}},
{"bb-data2", {12005, GameVersion::BB, ServerBehavior::DATA_SERVER_BB}},
{"bb-login", {12008, GameVersion::BB, ServerBehavior::LOGIN_SERVER}},
{"pc-lobby", {9420, GameVersion::PC, ServerBehavior::LOBBY_SERVER}},
{"gc-lobby", {9421, GameVersion::GC, ServerBehavior::LOBBY_SERVER}},
{"bb-lobby", {9422, GameVersion::BB, ServerBehavior::LOBBY_SERVER}},
});
@@ -105,7 +105,7 @@ void populate_state_from_config(shared_ptr<ServerState> s,
for (const auto& item : d.at("InformationMenuContents")->as_list()) {
auto& v = item->as_list();
information_menu->emplace_back(item_id, decode_sjis(v.at(0)->as_string()),
decode_sjis(v.at(1)->as_string()), MenuItemFlag::RequiresMessageBoxes);
decode_sjis(v.at(1)->as_string()), MenuItemFlag::REQUIRES_MESSAGE_BOXES);
information_contents->emplace_back(decode_sjis(v.at(2)->as_string()));
item_id++;
}
@@ -177,8 +177,8 @@ void populate_state_from_config(shared_ptr<ServerState> s,
try {
bool run_shell = d.at("RunInteractiveShell")->as_bool();
s->run_shell_behavior = run_shell ?
ServerState::RunShellBehavior::Always :
ServerState::RunShellBehavior::Never;
ServerState::RunShellBehavior::ALWAYS :
ServerState::RunShellBehavior::NEVER;
} catch (const out_of_range&) { }
}
@@ -314,8 +314,8 @@ int main(int argc, char* argv[]) {
drop_privileges(state->username);
}
bool should_run_shell = (state->run_shell_behavior == ServerState::RunShellBehavior::Always);
if (state->run_shell_behavior == ServerState::RunShellBehavior::Default) {
bool should_run_shell = (state->run_shell_behavior == ServerState::RunShellBehavior::ALWAYS);
if (state->run_shell_behavior == ServerState::RunShellBehavior::DEFAULT) {
should_run_shell = isatty(fileno(stdin));
}
+6 -6
View File
@@ -7,12 +7,12 @@
enum MenuItemFlag {
InvisibleOnDC = 0x01,
InvisibleOnPC = 0x02,
InvisibleOnGC = 0x04,
InvisibleOnGCEpisode3 = 0x08,
InvisibleOnBB = 0x10,
RequiresMessageBoxes = 0x20,
INVISIBLE_ON_DC = 0x01,
INVISIBLE_ON_PC = 0x02,
INVISIBLE_ON_GC = 0x04,
INVISIBLE_ON_GC_EPISODE_3 = 0x08,
INVISIBLE_ON_BB = 0x10,
REQUIRES_MESSAGE_BOXES = 0x20,
};
struct MenuItem {
+3 -3
View File
@@ -12,7 +12,7 @@ uint16_t PSOCommandHeader::command(GameVersion version) const {
case GameVersion::GC:
return reinterpret_cast<const PSOCommandHeaderDCGC*>(this)->command;
case GameVersion::PC:
case GameVersion::Patch:
case GameVersion::PATCH:
return reinterpret_cast<const PSOCommandHeaderPC*>(this)->command;
case GameVersion::BB:
return reinterpret_cast<const PSOCommandHeaderBB*>(this)->command;
@@ -26,7 +26,7 @@ uint16_t PSOCommandHeader::size(GameVersion version) const {
case GameVersion::GC:
return reinterpret_cast<const PSOCommandHeaderDCGC*>(this)->size;
case GameVersion::PC:
case GameVersion::Patch:
case GameVersion::PATCH:
return reinterpret_cast<const PSOCommandHeaderPC*>(this)->size;
case GameVersion::BB:
return reinterpret_cast<const PSOCommandHeaderBB*>(this)->size;
@@ -40,7 +40,7 @@ uint32_t PSOCommandHeader::flag(GameVersion version) const {
case GameVersion::GC:
return reinterpret_cast<const PSOCommandHeaderDCGC*>(this)->flag;
case GameVersion::PC:
case GameVersion::Patch:
case GameVersion::PATCH:
return reinterpret_cast<const PSOCommandHeaderPC*>(this)->flag;
case GameVersion::BB:
return reinterpret_cast<const PSOCommandHeaderBB*>(this)->flag;
+36 -36
View File
@@ -27,40 +27,40 @@ struct PSODownloadQuestHeader {
bool category_is_mode(QuestCategory category) {
return (category == QuestCategory::Battle) ||
(category == QuestCategory::Challenge) ||
(category == QuestCategory::Episode3);
return (category == QuestCategory::BATTLE) ||
(category == QuestCategory::CHALLENGE) ||
(category == QuestCategory::EPISODE_3);
}
const char* name_for_category(QuestCategory category) {
switch (category) {
case QuestCategory::Retrieval:
case QuestCategory::RETRIEVAL:
return "Retrieval";
case QuestCategory::Extermination:
case QuestCategory::EXTERMINATION:
return "Extermination";
case QuestCategory::Event:
case QuestCategory::EVENT:
return "Event";
case QuestCategory::Shop:
case QuestCategory::SHOP:
return "Shop";
case QuestCategory::VR:
return "VR";
case QuestCategory::Tower:
case QuestCategory::TOWER:
return "Tower";
case QuestCategory::GovernmentEpisode1:
case QuestCategory::GOVERNMENT_EPISODE_1:
return "GovernmentEpisode1";
case QuestCategory::GovernmentEpisode2:
case QuestCategory::GOVERNMENT_EPISODE_2:
return "GovernmentEpisode2";
case QuestCategory::GovernmentEpisode4:
case QuestCategory::GOVERNMENT_EPISODE_4:
return "GovernmentEpisode4";
case QuestCategory::Download:
case QuestCategory::DOWNLOAD:
return "Download";
case QuestCategory::Battle:
case QuestCategory::BATTLE:
return "Battle";
case QuestCategory::Challenge:
case QuestCategory::CHALLENGE:
return "Challenge";
case QuestCategory::Solo:
case QuestCategory::SOLO:
return "Solo";
case QuestCategory::Episode3:
case QuestCategory::EPISODE_3:
return "Episode3";
default:
return "Unknown";
@@ -141,7 +141,7 @@ struct PSOQuestHeaderBB {
Quest::Quest(const string& bin_filename)
: quest_id(-1),
category(QuestCategory::Unknown),
category(QuestCategory::UNKNOWN),
episode(0),
is_dcv1(false),
joinable(false),
@@ -178,11 +178,11 @@ Quest::Quest(const string& bin_filename)
}
if (basename[0] == 'b') {
this->category = QuestCategory::Battle;
this->category = QuestCategory::BATTLE;
} else if (basename[0] == 'c') {
this->category = QuestCategory::Challenge;
this->category = QuestCategory::CHALLENGE;
} else if (basename[0] == 'e') {
this->category = QuestCategory::Episode3;
this->category = QuestCategory::EPISODE_3;
} else if (basename[0] != 'q') {
throw invalid_argument("filename does not indicate mode");
}
@@ -190,7 +190,7 @@ Quest::Quest(const string& bin_filename)
// if the quest category is still unknown, expect 3 tokens (one of them will
// tell us the category)
vector<string> tokens = split(basename, '-');
if (tokens.size() != (2 + (this->category == QuestCategory::Unknown))) {
if (tokens.size() != (2 + (this->category == QuestCategory::UNKNOWN))) {
throw invalid_argument("incorrect filename format");
}
@@ -198,27 +198,27 @@ Quest::Quest(const string& bin_filename)
this->quest_id = strtoull(tokens[0].c_str() + 1, nullptr, 10);
// get the category from the second token if needed
if (this->category == QuestCategory::Unknown) {
if (this->category == QuestCategory::UNKNOWN) {
if (tokens[1] == "gov") {
if (this->episode == 0) {
this->category = QuestCategory::GovernmentEpisode1;
this->category = QuestCategory::GOVERNMENT_EPISODE_1;
} else if (this->episode == 1) {
this->category = QuestCategory::GovernmentEpisode2;
this->category = QuestCategory::GOVERNMENT_EPISODE_2;
} else if (this->episode == 2) {
this->category = QuestCategory::GovernmentEpisode4;
this->category = QuestCategory::GOVERNMENT_EPISODE_4;
} else {
throw invalid_argument("government quest has incorrect episode");
}
} else {
static const unordered_map<std::string, QuestCategory> name_to_category({
{"ret", QuestCategory::Retrieval},
{"ext", QuestCategory::Extermination},
{"evt", QuestCategory::Event},
{"shp", QuestCategory::Shop},
{"ret", QuestCategory::RETRIEVAL},
{"ext", QuestCategory::EXTERMINATION},
{"evt", QuestCategory::EVENT},
{"shp", QuestCategory::SHOP},
{"vr", QuestCategory::VR},
{"twr", QuestCategory::Tower},
{"dl", QuestCategory::Download},
{"1p", QuestCategory::Solo},
{"twr", QuestCategory::TOWER},
{"dl", QuestCategory::DOWNLOAD},
{"1p", QuestCategory::SOLO},
});
this->category = name_to_category.at(tokens[1]);
}
@@ -242,7 +242,7 @@ Quest::Quest(const string& bin_filename)
auto bin_decompressed = prs_decompress(*bin_compressed);
switch (this->version) {
case GameVersion::Patch:
case GameVersion::PATCH:
throw invalid_argument("patch server quests are not valid");
break;
@@ -274,7 +274,7 @@ Quest::Quest(const string& bin_filename)
}
case GameVersion::GC: {
if (this->category == QuestCategory::Episode3) {
if (this->category == QuestCategory::EPISODE_3) {
// these all appear to be the same size
if (bin_decompressed.size() != sizeof(PSOQuestHeaderGCEpisode3)) {
throw invalid_argument("file is incorrect size");
@@ -487,7 +487,7 @@ static string create_download_quest_file(const string& compressed_data,
}
shared_ptr<Quest> Quest::create_download_quest() const {
if (this->category == QuestCategory::Download) {
if (this->category == QuestCategory::DOWNLOAD) {
throw invalid_argument("quest is already a download quest");
}
@@ -510,7 +510,7 @@ shared_ptr<Quest> Quest::create_download_quest() const {
}
shared_ptr<Quest> dlq(new Quest(*this));
dlq->category = QuestCategory::Download;
dlq->category = QuestCategory::DOWNLOAD;
dlq->bin_contents_ptr.reset(new string(create_download_quest_file(
prs_compress(decompressed_bin), decompressed_bin.size())));
+14 -14
View File
@@ -12,21 +12,21 @@
enum class QuestCategory {
Unknown = -1,
Retrieval = 0,
Extermination,
Event,
Shop,
UNKNOWN = -1,
RETRIEVAL = 0,
EXTERMINATION,
EVENT,
SHOP,
VR,
Tower,
GovernmentEpisode1,
GovernmentEpisode2,
GovernmentEpisode4,
Download,
Battle,
Challenge,
Solo,
Episode3,
TOWER,
GOVERNMENT_EPISODE_1,
GOVERNMENT_EPISODE_2,
GOVERNMENT_EPISODE_4,
DOWNLOAD,
BATTLE,
CHALLENGE,
SOLO,
EPISODE_3,
};
bool category_is_mode(QuestCategory category);
+67 -67
View File
@@ -24,55 +24,55 @@ using namespace std;
enum ClientStateBB {
// initial connection. server will redirect client to another port.
InitialLogin = 0x00,
INITIAL_LOGIN = 0x00,
// second connection. server will send client game data and account data.
DownloadData = 0x01,
DOWNLOAD_DATA = 0x01,
// third connection. choose character menu
ChoosePlayer = 0x02,
CHOOSE_PLAYER = 0x02,
// fourth connection, used for saving characters only. if you do not create a
// character, server sets this state in order to skip it.
SavePlayer = 0x03,
SAVE_PLAYER = 0x03,
// last connection. redirects client to login server.
ShipSelect = 0x04,
SHIP_SELECT = 0x04,
};
vector<MenuItem> quest_categories_menu({
MenuItem(static_cast<uint32_t>(QuestCategory::Retrieval), u"Retrieval", u"$E$C6Quests that involve\nretrieving an object", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::Extermination), u"Extermination", u"$E$C6Quests that involve\ndestroying all\nmonsters", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::Event), u"Events", u"$E$C6Quests that are part\nof an event", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::Shop), u"Shops", u"$E$C6Quests that contain\nshops", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::VR), u"Virtual Reality", u"$E$C6Quests that are\ndone in a simulator", MenuItemFlag::InvisibleOnDC | MenuItemFlag::InvisibleOnPC),
MenuItem(static_cast<uint32_t>(QuestCategory::Tower), u"Control Tower", u"$E$C6Quests that take\nplace at the Control\nTower", MenuItemFlag::InvisibleOnDC | MenuItemFlag::InvisibleOnPC),
MenuItem(static_cast<uint32_t>(QuestCategory::RETRIEVAL), u"Retrieval", u"$E$C6Quests that involve\nretrieving an object", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::EXTERMINATION), u"Extermination", u"$E$C6Quests that involve\ndestroying all\nmonsters", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::EVENT), u"Events", u"$E$C6Quests that are part\nof an event", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::SHOP), u"Shops", u"$E$C6Quests that contain\nshops", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::VR), u"Virtual Reality", u"$E$C6Quests that are\ndone in a simulator", MenuItemFlag::INVISIBLE_ON_DC | MenuItemFlag::INVISIBLE_ON_PC),
MenuItem(static_cast<uint32_t>(QuestCategory::TOWER), u"Control Tower", u"$E$C6Quests that take\nplace at the Control\nTower", MenuItemFlag::INVISIBLE_ON_DC | MenuItemFlag::INVISIBLE_ON_PC),
});
vector<MenuItem> quest_battle_menu({
MenuItem(static_cast<uint32_t>(QuestCategory::Battle), u"Battle", u"$E$C6Battle mode rule\nsets", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::BATTLE), u"Battle", u"$E$C6Battle mode rule\nsets", 0),
});
vector<MenuItem> quest_challenge_menu({
MenuItem(static_cast<uint32_t>(QuestCategory::Challenge), u"Challenge", u"$E$C6Challenge mode\nquests", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::CHALLENGE), u"Challenge", u"$E$C6Challenge mode\nquests", 0),
});
vector<MenuItem> quest_solo_menu({
MenuItem(static_cast<uint32_t>(QuestCategory::Solo), u"Solo Quests", u"$E$C6Quests that require\na single player", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::SOLO), u"Solo Quests", u"$E$C6Quests that require\na single player", 0),
});
vector<MenuItem> quest_government_menu({
MenuItem(static_cast<uint32_t>(QuestCategory::GovernmentEpisode1), u"Hero in Red",u"$E$CG-Red Ring Rico-\n$C6Quests that follow\nthe Episode 1\nstoryline", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::GovernmentEpisode2), u"The Military's Hero",u"$E$CG-Heathcliff Flowen-\n$C6Quests that follow\nthe Episode 2\nstoryline", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::GovernmentEpisode4), u"The Meteor Impact Incident", u"$E$C6Quests that follow\nthe Episode 4\nstoryline", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::GOVERNMENT_EPISODE_1), u"Hero in Red",u"$E$CG-Red Ring Rico-\n$C6Quests that follow\nthe Episode 1\nstoryline", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::GOVERNMENT_EPISODE_2), u"The Military's Hero",u"$E$CG-Heathcliff Flowen-\n$C6Quests that follow\nthe Episode 2\nstoryline", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::GOVERNMENT_EPISODE_4), u"The Meteor Impact Incident", u"$E$C6Quests that follow\nthe Episode 4\nstoryline", 0),
});
vector<MenuItem> quest_download_menu({
MenuItem(static_cast<uint32_t>(QuestCategory::Retrieval), u"Retrieval", u"$E$C6Quests that involve\nretrieving an object", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::Extermination), u"Extermination", u"$E$C6Quests that involve\ndestroying all\nmonsters", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::Event), u"Events", u"$E$C6Quests that are part\nof an event", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::Shop), u"Shops", u"$E$C6Quests that contain\nshops", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::VR), u"Virtual Reality", u"$E$C6Quests that are\ndone in a simulator", MenuItemFlag::InvisibleOnDC | MenuItemFlag::InvisibleOnPC),
MenuItem(static_cast<uint32_t>(QuestCategory::Tower), u"Control Tower", u"$E$C6Quests that take\nplace at the Control\nTower", MenuItemFlag::InvisibleOnDC | MenuItemFlag::InvisibleOnPC),
MenuItem(static_cast<uint32_t>(QuestCategory::Download), u"Download", u"$E$C6Quests to download\nto your Memory Card", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::RETRIEVAL), u"Retrieval", u"$E$C6Quests that involve\nretrieving an object", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::EXTERMINATION), u"Extermination", u"$E$C6Quests that involve\ndestroying all\nmonsters", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::EVENT), u"Events", u"$E$C6Quests that are part\nof an event", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::SHOP), u"Shops", u"$E$C6Quests that contain\nshops", 0),
MenuItem(static_cast<uint32_t>(QuestCategory::VR), u"Virtual Reality", u"$E$C6Quests that are\ndone in a simulator", MenuItemFlag::INVISIBLE_ON_DC | MenuItemFlag::INVISIBLE_ON_PC),
MenuItem(static_cast<uint32_t>(QuestCategory::TOWER), u"Control Tower", u"$E$C6Quests that take\nplace at the Control\nTower", MenuItemFlag::INVISIBLE_ON_DC | MenuItemFlag::INVISIBLE_ON_PC),
MenuItem(static_cast<uint32_t>(QuestCategory::DOWNLOAD), u"Download", u"$E$C6Quests to download\nto your Memory Card", 0),
});
@@ -81,7 +81,7 @@ vector<MenuItem> quest_download_menu({
void process_connect(std::shared_ptr<ServerState> s, std::shared_ptr<Client> c) {
switch (c->server_behavior) {
case ServerBehavior::SplitReconnect: {
case ServerBehavior::SPLIT_RECONNECT: {
uint16_t pc_port = s->named_port_configuration.at("pc-login").port;
uint16_t gc_port = s->named_port_configuration.at("gc-jp10").port;
send_pc_gc_split_reconnect(c, s->connect_address_for_client(c), pc_port, gc_port);
@@ -89,9 +89,9 @@ void process_connect(std::shared_ptr<ServerState> s, std::shared_ptr<Client> c)
break;
}
case ServerBehavior::LoginServer: {
case ServerBehavior::LOGIN_SERVER: {
if (!s->welcome_message.empty()) {
c->flags |= ClientFlag::AtWelcomeMessage;
c->flags |= ClientFlag::AT_WELCOME_MESSAGE;
}
send_server_init(s, c, true);
if (s->pre_lobby_event) {
@@ -100,9 +100,9 @@ void process_connect(std::shared_ptr<ServerState> s, std::shared_ptr<Client> c)
break;
}
case ServerBehavior::LobbyServer:
case ServerBehavior::DataServerBB:
case ServerBehavior::PatchServer:
case ServerBehavior::LOBBY_SERVER:
case ServerBehavior::DATA_SERVER_BB:
case ServerBehavior::PATCH_SERVER:
send_server_init(s, c, false);
break;
@@ -113,22 +113,22 @@ void process_connect(std::shared_ptr<ServerState> s, std::shared_ptr<Client> c)
}
void process_login_complete(shared_ptr<ServerState> s, shared_ptr<Client> c) {
if (c->server_behavior == ServerBehavior::LoginServer) {
if (c->server_behavior == ServerBehavior::LOGIN_SERVER) {
// on the login server, send the ep3 updates and the main menu or welcome
// message
if (c->flags & ClientFlag::Episode3Games) {
if (c->flags & ClientFlag::EPISODE_3_GAMES) {
send_ep3_card_list_update(c);
send_ep3_rank_update(c);
}
if (s->welcome_message.empty() || (c->flags & ClientFlag::NoMessageBoxCloseConfirmation)) {
c->flags &= ~ClientFlag::AtWelcomeMessage;
if (s->welcome_message.empty() || (c->flags & ClientFlag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION)) {
c->flags &= ~ClientFlag::AT_WELCOME_MESSAGE;
send_menu(c, s->name.c_str(), MAIN_MENU_ID, s->main_menu, false);
} else {
send_message_box(c, s->welcome_message.c_str());
}
} else if (c->server_behavior == ServerBehavior::LobbyServer) {
} else if (c->server_behavior == ServerBehavior::LOBBY_SERVER) {
// if the client is BB, load thair player and account data
if (c->version == GameVersion::BB) {
@@ -371,7 +371,7 @@ void process_login_d_e_pc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
c->bb_player_index = 0;
}
if ((c->flags & ClientFlag::Episode3Games) && (s->ep3_menu_song >= 0)) {
if ((c->flags & ClientFlag::EPISODE_3_GAMES) && (s->ep3_menu_song >= 0)) {
send_ep3_change_music(c, s->ep3_menu_song);
}
@@ -415,13 +415,13 @@ void process_login_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
send_client_init_bb(c, 0);
switch (c->bb_game_state) {
case ClientStateBB::InitialLogin:
case ClientStateBB::INITIAL_LOGIN:
// first login? send them to the other port
send_reconnect(c, s->connect_address_for_client(c),
s->named_port_configuration.at("bb-data1").port);
break;
case ClientStateBB::DownloadData: {
case ClientStateBB::DOWNLOAD_DATA: {
// download data? send them their account data and player previews
string account_filename = filename_for_account_bb(c->license->username);
try {
@@ -432,12 +432,12 @@ void process_login_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
break;
}
case ClientStateBB::ChoosePlayer:
case ClientStateBB::SavePlayer:
case ClientStateBB::CHOOSE_PLAYER:
case ClientStateBB::SAVE_PLAYER:
// just wait; the command handlers will handle it
break;
case ClientStateBB::ShipSelect:
case ClientStateBB::SHIP_SELECT:
// this happens on the login server and later
process_login_complete(s, c);
break;
@@ -483,7 +483,7 @@ void process_ep3_jukebox(shared_ptr<ServerState> s, shared_ptr<Client> c,
OutputCmd out_cmd = {1000000, 0x80E8, in_cmd->unknown_token};
auto l = s->find_lobby(c->lobby_id);
if (!l || !(l->flags & LobbyFlag::Episode3)) {
if (!l || !(l->flags & LobbyFlag::EPISODE_3)) {
return;
}
@@ -502,7 +502,7 @@ void process_ep3_server_data_request(shared_ptr<ServerState> s, shared_ptr<Clien
const PSOSubcommand* cmds = reinterpret_cast<const PSOSubcommand*>(data);
auto l = s->find_lobby(c->lobby_id);
if (!l || !(l->flags & LobbyFlag::Episode3) || !l->is_game()) {
if (!l || !(l->flags & LobbyFlag::EPISODE_3) || !l->is_game()) {
c->should_disconnect = true;
return;
}
@@ -588,11 +588,11 @@ void process_ep3_server_data_request(shared_ptr<ServerState> s, shared_ptr<Clien
void process_message_box_closed(shared_ptr<ServerState> s, shared_ptr<Client> c,
uint16_t, uint32_t, uint16_t, const void*) { // D6
if (c->flags & ClientFlag::InInformationMenu) {
if (c->flags & ClientFlag::IN_INFORMATION_MENU) {
send_menu(c, u"Information", INFORMATION_MENU_ID, *s->information_menu, false);
} else if (c->flags & ClientFlag::AtWelcomeMessage) {
} else if (c->flags & ClientFlag::AT_WELCOME_MESSAGE) {
send_menu(c, s->name.c_str(), MAIN_MENU_ID, s->main_menu, false);
c->flags &= ~ClientFlag::AtWelcomeMessage;
c->flags &= ~ClientFlag::AT_WELCOME_MESSAGE;
}
}
@@ -687,7 +687,7 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
case MAIN_MENU_INFORMATION:
send_menu(c, u"Information", INFORMATION_MENU_ID,
*s->information_menu, false);
c->flags |= ClientFlag::InInformationMenu;
c->flags |= ClientFlag::IN_INFORMATION_MENU;
break;
case MAIN_MENU_DOWNLOAD_QUESTS:
@@ -707,7 +707,7 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
case INFORMATION_MENU_ID: {
if (cmd->item_id == INFORMATION_MENU_GO_BACK) {
c->flags &= ~ClientFlag::InInformationMenu;
c->flags &= ~ClientFlag::IN_INFORMATION_MENU;
send_menu(c, s->name.c_str(), MAIN_MENU_ID, s->main_menu, false);
} else {
@@ -735,11 +735,11 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
break;
}
if ((game->version != c->version) ||
(!(game->flags & LobbyFlag::Episode3) != !(c->flags & LobbyFlag::Episode3))) {
(!(game->flags & LobbyFlag::EPISODE_3) != !(c->flags & LobbyFlag::EPISODE_3))) {
send_lobby_message_box(c, u"$C6You cannot join this\ngame because it is\nfor a different\nversion of PSO.");
break;
}
if (game->flags & LobbyFlag::QuestInProgress) {
if (game->flags & LobbyFlag::QUEST_IN_PROGRESS) {
send_lobby_message_box(c, u"$C6You cannot join this\ngame because a\nquest is already\nin progress.");
break;
}
@@ -752,7 +752,7 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
break;
}
if (!(c->license->privileges & Privilege::FreeJoinGames)) {
if (!(c->license->privileges & Privilege::FREE_JOIN_GAMES)) {
char16_t password[0x10];
if (size > sizeof(Cmd)) {
if (uses_unicode) {
@@ -777,7 +777,7 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
}
s->change_client_lobby(c, game);
c->flags |= ClientFlag::Loading;
c->flags |= ClientFlag::LOADING;
if (c->version == GameVersion::BB) {
game->assign_item_ids_for_player(c->lobby_client_id, c->player.inventory);
}
@@ -791,7 +791,7 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
}
shared_ptr<Lobby> l = c->lobby_id ? s->find_lobby(c->lobby_id) : nullptr;
auto quests = s->quest_index->filter(c->version,
c->flags & ClientFlag::IsDCv1,
c->flags & ClientFlag::IS_DCV1,
static_cast<QuestCategory>(cmd->item_id & 0xFF),
l.get() ? (l->episode - 1) : -1);
if (quests.empty()) {
@@ -834,9 +834,9 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
if (l) {
if (q->joinable) {
l->flags |= LobbyFlag::JoinableQuestInProgress;
l->flags |= LobbyFlag::JOINABLE_QUEST_IN_PROGRESS;
} else {
l->flags |= LobbyFlag::QuestInProgress;
l->flags |= LobbyFlag::QUEST_IN_PROGRESS;
}
l->loading_quest_id = q->quest_id;
for (size_t x = 0; x < l->max_clients; x++) {
@@ -851,7 +851,7 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
send_quest_file(l->clients[x], bin_basename, *bin_contents, false, false);
send_quest_file(l->clients[x], dat_basename, *dat_contents, false, false);
l->clients[x]->flags |= ClientFlag::Loading;
l->clients[x]->flags |= ClientFlag::LOADING;
}
} else {
@@ -890,7 +890,7 @@ void process_change_lobby(shared_ptr<ServerState> s, shared_ptr<Client> c,
return;
}
if ((new_lobby->flags & LobbyFlag::Episode3) && !(c->flags & ClientFlag::Episode3Games)) {
if ((new_lobby->flags & LobbyFlag::EPISODE_3) && !(c->flags & ClientFlag::EPISODE_3_GAMES)) {
send_lobby_message_box(c, u"$C6Can't change lobby\n\n$C7The lobby is for\nEpisode 3 only.");
return;
}
@@ -969,7 +969,7 @@ void process_quest_ready(shared_ptr<ServerState> s, shared_ptr<Client> c,
return;
}
c->flags &= ~ClientFlag::Loading;
c->flags &= ~ClientFlag::LOADING;
// check if any client is still loading
// TODO: we need to handle clients disconnecting while loading. probably
@@ -979,7 +979,7 @@ void process_quest_ready(shared_ptr<ServerState> s, shared_ptr<Client> c,
if (!l->clients[x]) {
continue;
}
if (l->clients[x]->flags & ClientFlag::Loading) {
if (l->clients[x]->flags & ClientFlag::LOADING) {
break;
}
}
@@ -1066,7 +1066,7 @@ void process_player_data(shared_ptr<ServerState> s, shared_ptr<Client> c,
}
// if the client isn't in a lobby, add them to an available lobby
if (!c->lobby_id && (c->server_behavior == ServerBehavior::LobbyServer)) {
if (!c->lobby_id && (c->server_behavior == ServerBehavior::LOBBY_SERVER)) {
s->add_client_to_available_lobby(c);
}
}
@@ -1171,7 +1171,7 @@ void process_player_preview_request_bb(shared_ptr<ServerState>, shared_ptr<Clien
check_size(size, sizeof(Cmd));
const auto* cmd = reinterpret_cast<const Cmd*>(data);
if (c->bb_game_state == ClientStateBB::ChoosePlayer) {
if (c->bb_game_state == ClientStateBB::CHOOSE_PLAYER) {
c->bb_player_index = cmd->player_index;
c->bb_game_state++;
send_client_init_bb(c, 0);
@@ -1558,7 +1558,7 @@ shared_ptr<Lobby> create_game_generic(shared_ptr<ServerState> s,
game->event = Lobby::game_event_for_lobby_event(current_lobby->event);
game->block = 0xFF;
game->max_clients = 4;
game->flags = (is_ep3 ? LobbyFlag::Episode3 : 0) | LobbyFlag::IsGame;
game->flags = (is_ep3 ? LobbyFlag::EPISODE_3 : 0) | LobbyFlag::IS_GAME;
game->min_level = min_level;
game->max_level = 0xFFFFFFFF;
@@ -1642,7 +1642,7 @@ void process_create_game_pc(shared_ptr<ServerState> s, shared_ptr<Client> c,
s->add_lobby(game);
s->change_client_lobby(c, game);
c->flags |= ClientFlag::Loading;
c->flags |= ClientFlag::LOADING;
}
void process_create_game_dc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
@@ -1660,7 +1660,7 @@ void process_create_game_dc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
const auto* cmd = reinterpret_cast<const Cmd*>(data);
// only allow EC from Ep3 clients
bool client_is_ep3 = c->flags & ClientFlag::Episode3Games;
bool client_is_ep3 = c->flags & ClientFlag::EPISODE_3_GAMES;
if ((command == 0xEC) && !client_is_ep3) {
return;
}
@@ -1681,7 +1681,7 @@ void process_create_game_dc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
s->add_lobby(game);
s->change_client_lobby(c, game);
c->flags |= ClientFlag::Loading;
c->flags |= ClientFlag::LOADING;
}
void process_create_game_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
@@ -1706,7 +1706,7 @@ void process_create_game_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
s->add_lobby(game);
s->change_client_lobby(c, game);
c->flags |= ClientFlag::Loading;
c->flags |= ClientFlag::LOADING;
game->assign_item_ids_for_player(c->lobby_client_id, c->player.inventory);
}
@@ -1730,7 +1730,7 @@ void process_client_ready(shared_ptr<ServerState> s, shared_ptr<Client> c,
// go home client; you're drunk
throw invalid_argument("ready command cannot be sent outside game");
}
c->flags &= (~ClientFlag::Loading);
c->flags &= (~ClientFlag::LOADING);
// tell the other players to stop waiting for the new player to load
send_resume_game(l, c);
+9 -9
View File
@@ -62,7 +62,7 @@ void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
// if the command is an Ep3-only command, make sure an Ep3 client sent it
bool command_is_ep3 = (command & 0xF0) == 0xC0;
if (command_is_ep3 && !(c->flags & ClientFlag::Episode3Games)) {
if (command_is_ep3 && !(c->flags & ClientFlag::EPISODE_3_GAMES)) {
return;
}
@@ -74,7 +74,7 @@ void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
if (!target) {
return;
}
if (command_is_ep3 && !(target->flags & ClientFlag::Episode3Games)) {
if (command_is_ep3 && !(target->flags & ClientFlag::EPISODE_3_GAMES)) {
return;
}
send_command(target, command, flag, p, count * 4);
@@ -82,7 +82,7 @@ void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
} else {
if (command_is_ep3) {
for (auto& target : l->clients) {
if (!target || (target == c) || !(target->flags & ClientFlag::Episode3Games)) {
if (!target || (target == c) || !(target->flags & ClientFlag::EPISODE_3_GAMES)) {
continue;
}
send_command(target, command, flag, p, count * 4);
@@ -182,8 +182,8 @@ static void process_subcommand_hit_by_monster(shared_ptr<ServerState>,
return;
}
forward_subcommand(l, c, command, flag, p, count);
if ((l->flags & LobbyFlag::CheatsEnabled) && c->infinite_hp) {
send_player_stats_change(l, c, PlayerStatsChange::AddHP, 1020);
if ((l->flags & LobbyFlag::CHEATS_ENABLED) && c->infinite_hp) {
send_player_stats_change(l, c, PlayerStatsChange::ADD_HP, 1020);
}
}
@@ -195,8 +195,8 @@ static void process_subcommand_use_technique(shared_ptr<ServerState>,
return;
}
forward_subcommand(l, c, command, flag, p, count);
if ((l->flags & LobbyFlag::CheatsEnabled) && c->infinite_hp) {
send_player_stats_change(l, c, PlayerStatsChange::AddTP, 255);
if ((l->flags & LobbyFlag::CHEATS_ENABLED) && c->infinite_hp) {
send_player_stats_change(l, c, PlayerStatsChange::ADD_TP, 255);
}
}
@@ -362,7 +362,7 @@ static void process_subcommand_use_item(shared_ptr<ServerState>,
static void process_subcommand_open_shop_or_ep3_unknown(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const PSOSubcommand* p, size_t count) {
if (l->flags & LobbyFlag::Episode3) {
if (l->flags & LobbyFlag::EPISODE_3) {
check_size(count, 2, 0xFFFF);
forward_subcommand(l, c, command, flag, p, count);
@@ -877,7 +877,7 @@ static void process_subcommand_forward_check_size_game(shared_ptr<ServerState>,
static void process_subcommand_forward_check_size_ep3_lobby(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const PSOSubcommand* p, size_t count) {
if (!(l->flags & LobbyFlag::Episode3) || l->is_game() || (p->byte[1] != count)) {
if (!(l->flags & LobbyFlag::EPISODE_3) || l->is_game() || (p->byte[1] != count)) {
return;
}
forward_subcommand(l, c, command, flag, p, count);
+25 -25
View File
@@ -44,7 +44,7 @@ void send_command(shared_ptr<Client> c, uint16_t command, uint32_t flag,
}
case GameVersion::PC:
case GameVersion::Patch: {
case GameVersion::PATCH: {
PSOCommandHeaderPC header;
header.size = sizeof(header) + size;
header.command = command;
@@ -222,7 +222,7 @@ void send_server_init(shared_ptr<ServerState> s, shared_ptr<Client> c,
bool initial_connection) {
if (c->version == GameVersion::PC) {
send_server_init_pc(c, initial_connection);
} else if (c->version == GameVersion::Patch) {
} else if (c->version == GameVersion::PATCH) {
send_server_init_patch(c, initial_connection);
} else if (c->version == GameVersion::GC) {
send_server_init_gc(c, initial_connection);
@@ -501,7 +501,7 @@ static void send_large_message_dc_gc(shared_ptr<Client> c, uint8_t command,
static void send_large_message(shared_ptr<Client> c, uint8_t command,
const char16_t* text, uint32_t from_serial_number, bool include_header) {
if (c->version == GameVersion::PC || c->version == GameVersion::Patch ||
if (c->version == GameVersion::PC || c->version == GameVersion::PATCH ||
c->version == GameVersion::BB) {
send_large_message_pc_patch_bb(c, command, text, from_serial_number, include_header);
} else {
@@ -510,7 +510,7 @@ static void send_large_message(shared_ptr<Client> c, uint8_t command,
}
void send_message_box(shared_ptr<Client> c, const char16_t* text) {
return send_large_message(c, (c->version == GameVersion::Patch) ? 0x13 : 0x1A,
return send_large_message(c, (c->version == GameVersion::PATCH) ? 0x13 : 0x1A,
text, 0, false);
}
@@ -640,7 +640,7 @@ static void send_info_board_dc_gc(shared_ptr<Client> c, shared_ptr<Lobby> l) {
}
void send_info_board(shared_ptr<Client> c, shared_ptr<Lobby> l) {
if (c->version == GameVersion::PC || c->version == GameVersion::Patch ||
if (c->version == GameVersion::PC || c->version == GameVersion::PATCH ||
c->version == GameVersion::BB) {
send_info_board_pc_bb(c, l);
} else {
@@ -888,14 +888,14 @@ static void send_menu_pc_bb(shared_ptr<Client> c, const char16_t* menu_name,
}
for (const auto& item : items) {
if ((c->version == GameVersion::BB) && (item.flags & MenuItemFlag::InvisibleOnBB)) {
if ((c->version == GameVersion::BB) && (item.flags & MenuItemFlag::INVISIBLE_ON_BB)) {
continue;
}
if ((c->version == GameVersion::PC) && (item.flags & MenuItemFlag::InvisibleOnPC)) {
if ((c->version == GameVersion::PC) && (item.flags & MenuItemFlag::INVISIBLE_ON_PC)) {
continue;
}
if ((item.flags & MenuItemFlag::RequiresMessageBoxes) &&
(c->flags & ClientFlag::NoMessageBoxCloseConfirmation)) {
if ((item.flags & MenuItemFlag::REQUIRES_MESSAGE_BOXES) &&
(c->flags & ClientFlag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION)) {
continue;
}
@@ -930,17 +930,17 @@ static void send_menu_dc_gc(shared_ptr<Client> c, const char16_t* menu_name,
}
for (const auto& item : items) {
if ((c->version == GameVersion::DC) && (item.flags & MenuItemFlag::InvisibleOnDC)) {
if ((c->version == GameVersion::DC) && (item.flags & MenuItemFlag::INVISIBLE_ON_DC)) {
continue;
}
if ((c->version == GameVersion::GC) && (item.flags & MenuItemFlag::InvisibleOnGC)) {
if ((c->version == GameVersion::GC) && (item.flags & MenuItemFlag::INVISIBLE_ON_GC)) {
continue;
}
if ((c->flags & ClientFlag::Episode3Games) && (item.flags & MenuItemFlag::InvisibleOnGCEpisode3)) {
if ((c->flags & ClientFlag::EPISODE_3_GAMES) && (item.flags & MenuItemFlag::INVISIBLE_ON_GC_EPISODE_3)) {
continue;
}
if ((item.flags & MenuItemFlag::RequiresMessageBoxes) &&
(c->flags & ClientFlag::NoMessageBoxCloseConfirmation)) {
if ((item.flags & MenuItemFlag::REQUIRES_MESSAGE_BOXES) &&
(c->flags & ClientFlag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION)) {
continue;
}
@@ -957,7 +957,7 @@ static void send_menu_dc_gc(shared_ptr<Client> c, const char16_t* menu_name,
void send_menu(shared_ptr<Client> c, const char16_t* menu_name,
uint32_t menu_id, const vector<MenuItem>& items, bool is_info_menu) {
if (c->version == GameVersion::PC || c->version == GameVersion::Patch ||
if (c->version == GameVersion::PC || c->version == GameVersion::PATCH ||
c->version == GameVersion::BB) {
send_menu_pc_bb(c, menu_name, menu_id, items, is_info_menu);
} else {
@@ -1043,10 +1043,10 @@ static void send_game_menu_gc(shared_ptr<Client> c, shared_ptr<ServerState> s) {
e.menu_id = GAME_MENU_ID;
e.game_id = l->lobby_id;
e.difficulty_tag = ((l->flags & LobbyFlag::Episode3) ? 0x0A : (l->difficulty + 0x22));
e.difficulty_tag = ((l->flags & LobbyFlag::EPISODE_3) ? 0x0A : (l->difficulty + 0x22));
e.num_players = l->count_clients();
e.episode = 0;
if (l->flags & LobbyFlag::Episode3) {
if (l->flags & LobbyFlag::EPISODE_3) {
e.flags = (l->password[0] ? 2 : 0);
} else {
e.flags = ((l->episode << 6) | (l->mode << 4) | (l->password[0] ? 2 : 0));
@@ -1298,10 +1298,10 @@ void send_lobby_list(shared_ptr<Client> c, shared_ptr<ServerState> s) {
vector<Entry> entries;
for (shared_ptr<Lobby> l : s->all_lobbies()) {
if (!(l->flags & LobbyFlag::Default)) {
if (!(l->flags & LobbyFlag::DEFAULT)) {
continue;
}
if ((l->flags & LobbyFlag::Episode3) && !(c->flags & ClientFlag::Episode3Games)) {
if ((l->flags & LobbyFlag::EPISODE_3) && !(c->flags & ClientFlag::EPISODE_3_GAMES)) {
continue;
}
@@ -1405,7 +1405,7 @@ static void send_join_game_gc(shared_ptr<Client> c, shared_ptr<Lobby> l) {
cmd.lobby_data[x].ip_address = 0x7F000001;
cmd.lobby_data[x].client_id = c->lobby_client_id;
encode_sjis(cmd.lobby_data[x].name, l->clients[x]->player.disp.name, 0x10);
if (l->flags & LobbyFlag::Episode3) {
if (l->flags & LobbyFlag::EPISODE_3) {
cmd.player[x].inventory = l->clients[x]->player.inventory;
cmd.player[x].disp = l->clients[x]->player.disp.to_pcgc();
}
@@ -1426,7 +1426,7 @@ static void send_join_game_gc(shared_ptr<Client> c, shared_ptr<Lobby> l) {
// player data is only sent in Episode III games; in other versions, the
// players send each other their data using 62/6D commands during loading
size_t data_size = (l->flags & LobbyFlag::Episode3)
size_t data_size = (l->flags & LobbyFlag::EPISODE_3)
? sizeof(cmd) : (sizeof(cmd) - sizeof(cmd.player));
send_command(c, 0x64, player_count, &cmd, data_size);
}
@@ -1529,7 +1529,7 @@ static void send_join_lobby_pc(shared_ptr<Client> c, shared_ptr<Lobby> l) {
static void send_join_lobby_gc(shared_ptr<Client> c, shared_ptr<Lobby> l) {
uint8_t lobby_type = l->type;
if (c->flags & ClientFlag::Episode3Games) {
if (c->flags & ClientFlag::EPISODE_3_GAMES) {
if ((l->type > 0x14) && (l->type < 0xE9)) {
lobby_type = l->block - 1;
}
@@ -1657,9 +1657,9 @@ void send_join_lobby(shared_ptr<Client> c, shared_ptr<Lobby> l) {
// If the client will stop sending message box close confirmations after
// joining any lobby, set the appropriate flag and update the client config
if ((c->flags & (ClientFlag::NoMessageBoxCloseConfirmationAfterLobbyJoin | ClientFlag::NoMessageBoxCloseConfirmation))
== ClientFlag::NoMessageBoxCloseConfirmationAfterLobbyJoin) {
c->flags |= ClientFlag::NoMessageBoxCloseConfirmation;
if ((c->flags & (ClientFlag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION_AFTER_LOBBY_JOIN | ClientFlag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION))
== ClientFlag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION_AFTER_LOBBY_JOIN) {
c->flags |= ClientFlag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION;
send_update_client_config(c);
}
}
+5 -5
View File
@@ -147,11 +147,11 @@ void send_resume_game(std::shared_ptr<Lobby> l,
std::shared_ptr<Client> ready_client);
enum PlayerStatsChange {
SubtractHP = 0,
SubtractTP = 1,
SubtractMeseta = 2,
AddHP = 3,
AddTP = 4,
SUBTRACT_HP = 0,
SUBTRACT_TP = 1,
SUBTRACT_MESETA = 2,
ADD_HP = 3,
ADD_TP = 4,
};
void send_player_stats_change(std::shared_ptr<Lobby> l, std::shared_ptr<Client> c,
+3 -3
View File
@@ -127,11 +127,11 @@ Commands:\n\
if (mask == "normal") {
l->privileges = 0;
} else if (mask == "mod") {
l->privileges = Privilege::Moderator;
l->privileges = Privilege::MODERATOR;
} else if (mask == "admin") {
l->privileges = Privilege::Administrator;
l->privileges = Privilege::ADMINISTRATOR;
} else if (mask == "root") {
l->privileges = Privilege::Root;
l->privileges = Privilege::ROOT;
} else {
l->privileges = stoul(mask);
}
+7 -7
View File
@@ -17,7 +17,7 @@ ServerState::ServerState()
: dns_server_port(0),
ip_stack_debug(false),
allow_unregistered_users(false),
run_shell_behavior(RunShellBehavior::Default), next_lobby_id(1),
run_shell_behavior(RunShellBehavior::DEFAULT), next_lobby_id(1),
pre_lobby_event(0),
ep3_menu_song(-1) {
memset(&this->default_key_file, 0, sizeof(this->default_key_file));
@@ -25,7 +25,7 @@ ServerState::ServerState()
this->main_menu.emplace_back(MAIN_MENU_GO_TO_LOBBY, u"Go to lobby",
u"Join the lobby.", 0);
this->main_menu.emplace_back(MAIN_MENU_INFORMATION, u"Information",
u"View server information.", MenuItemFlag::RequiresMessageBoxes);
u"View server information.", MenuItemFlag::REQUIRES_MESSAGE_BOXES);
this->main_menu.emplace_back(MAIN_MENU_DOWNLOAD_QUESTS, u"Download quests",
u"Download quests.", 0);
this->main_menu.emplace_back(MAIN_MENU_DISCONNECT, u"Disconnect",
@@ -34,8 +34,8 @@ ServerState::ServerState()
for (size_t x = 0; x < 20; x++) {
auto lobby_name = decode_sjis(string_printf("LOBBY%zu", x + 1));
shared_ptr<Lobby> l(new Lobby());
l->flags |= LobbyFlag::Public | LobbyFlag::Default | LobbyFlag::Persistent |
((x > 14) ? LobbyFlag::Episode3 : 0);
l->flags |= LobbyFlag::PUBLIC | LobbyFlag::DEFAULT | LobbyFlag::PERSISTENT |
((x > 14) ? LobbyFlag::EPISODE_3 : 0);
l->block = x + 1;
l->type = x;
char16cpy(l->name, lobby_name.c_str(), 0x24);
@@ -47,7 +47,7 @@ ServerState::ServerState()
void ServerState::add_client_to_available_lobby(shared_ptr<Client> c) {
auto it = this->id_to_lobby.lower_bound(0);
for (; it != this->id_to_lobby.end(); it++) {
if (!(it->second->flags & LobbyFlag::Public)) {
if (!(it->second->flags & LobbyFlag::PUBLIC)) {
continue;
}
try {
@@ -67,7 +67,7 @@ void ServerState::add_client_to_available_lobby(shared_ptr<Client> c) {
void ServerState::remove_client_from_lobby(shared_ptr<Client> c) {
auto l = this->id_to_lobby.at(c->lobby_id);
l->remove_client(c);
if (!(l->flags & LobbyFlag::Persistent) && (l->count_clients() == 0)) {
if (!(l->flags & LobbyFlag::PERSISTENT) && (l->count_clients() == 0)) {
this->remove_lobby(l->lobby_id);
} else {
send_player_leave_notification(l, c->lobby_client_id);
@@ -90,7 +90,7 @@ void ServerState::change_client_lobby(shared_ptr<Client> c, shared_ptr<Lobby> ne
}
if (current_lobby) {
if (!(current_lobby->flags & LobbyFlag::Persistent) && (current_lobby->count_clients() == 0)) {
if (!(current_lobby->flags & LobbyFlag::PERSISTENT) && (current_lobby->count_clients() == 0)) {
this->remove_lobby(current_lobby->lobby_id);
} else {
send_player_leave_notification(current_lobby, old_lobby_client_id);
+3 -3
View File
@@ -26,9 +26,9 @@ struct PortConfiguration {
struct ServerState {
enum class RunShellBehavior {
Default = 0,
Always,
Never,
DEFAULT = 0,
ALWAYS,
NEVER,
};
std::u16string name;
+11 -11
View File
@@ -13,34 +13,34 @@ uint16_t flags_for_version(GameVersion version, uint8_t sub_version) {
case 0x00: // initial check (before 9E recognition)
switch (version) {
case GameVersion::DC:
return ClientFlag::DefaultV2DC;
return ClientFlag::DEFAULT_V2_DC;
case GameVersion::GC:
return ClientFlag::DefaultV3GC;
return ClientFlag::DEFAULT_V3_GC;
case GameVersion::PC:
return ClientFlag::DefaultV2PC;
case GameVersion::Patch:
return ClientFlag::DefaultV2PC;
return ClientFlag::DEFAULT_V2_PC;
case GameVersion::PATCH:
return ClientFlag::DEFAULT_V2_PC;
case GameVersion::BB:
return ClientFlag::DefaultV3BB;
return ClientFlag::DEFAULT_V3_BB;
}
break;
case 0x29: // PSO PC
return ClientFlag::DefaultV2PC;
return ClientFlag::DEFAULT_V2_PC;
case 0x30: // ???
case 0x31: // PSO Ep1&2 US10, US11, EU10, JP10
case 0x33: // PSO Ep1&2 EU50HZ
case 0x34: // PSO Ep1&2 JP11
return ClientFlag::DefaultV3GC;
return ClientFlag::DEFAULT_V3_GC;
case 0x32: // PSO Ep1&2 US12, JP12
case 0x35: // PSO Ep1&2 US12, JP12
case 0x36: // PSO Ep1&2 US12, JP12
case 0x39: // PSO Ep1&2 US12, JP12
return ClientFlag::DefaultV3GCPlus;
return ClientFlag::DEFAULT_V3_GC_PLUS;
case 0x40: // PSO Ep3 trial
case 0x41: // PSO Ep3 US
case 0x42: // PSO Ep3 JP
case 0x43: // PSO Ep3 UK
return ClientFlag::DefaultV4;
return ClientFlag::DEFAULT_V4;
}
return 0;
}
@@ -55,7 +55,7 @@ const char* name_for_version(GameVersion version) {
return "BB";
case GameVersion::DC:
return "DC";
case GameVersion::Patch:
case GameVersion::PATCH:
return "Patch";
default:
return "Unknown";
+16 -16
View File
@@ -7,39 +7,39 @@
enum class GameVersion {
DC = 0,
PC,
Patch,
PATCH,
GC,
BB,
};
enum ClientFlag {
// After joining a lobby, client will no longer send D6 commands when they close message boxes
NoMessageBoxCloseConfirmationAfterLobbyJoin = 0x0004,
NO_MESSAGE_BOX_CLOSE_CONFIRMATION_AFTER_LOBBY_JOIN = 0x0004,
// Client has the above flag and has already joined a lobby
NoMessageBoxCloseConfirmation = 0x0008,
NO_MESSAGE_BOX_CLOSE_CONFIRMATION = 0x0008,
// Client can see Ep3 lobbies
CanSeeExtraLobbies = 0x0010,
CAN_SEE_EPISODE_3_LOBBIES = 0x0010,
// Client is episode 3 and should use its game mechanic
Episode3Games = 0x0020,
EPISODE_3_GAMES = 0x0020,
// Client is DC v1 (disables some features)
IsDCv1 = 0x0040,
IS_DCV1 = 0x0040,
// Client is loading into a game
Loading = 0x0080,
LOADING = 0x0080,
// Client is in the information menu (login server only)
InInformationMenu = 0x0100,
IN_INFORMATION_MENU = 0x0100,
// Client is at the welcome message (login server only)
AtWelcomeMessage = 0x0200,
AT_WELCOME_MESSAGE = 0x0200,
// Note: There isn't a good way to detect Episode 3 until the player data is
// sent (via a 61 command), so the Episode3Games flag is set in that handler
DefaultV1 = IsDCv1,
DefaultV2DC = 0x0000,
DefaultV2PC = 0x0000,
DefaultV3GC = 0x0000,
DefaultV3GCPlus = NoMessageBoxCloseConfirmationAfterLobbyJoin,
DefaultV3BB = NoMessageBoxCloseConfirmationAfterLobbyJoin | NoMessageBoxCloseConfirmation,
DefaultV4 = NoMessageBoxCloseConfirmationAfterLobbyJoin | CanSeeExtraLobbies | Episode3Games,
DEFAULT_V1 = IS_DCV1,
DEFAULT_V2_DC = 0x0000,
DEFAULT_V2_PC = 0x0000,
DEFAULT_V3_GC = 0x0000,
DEFAULT_V3_GC_PLUS = NO_MESSAGE_BOX_CLOSE_CONFIRMATION_AFTER_LOBBY_JOIN,
DEFAULT_V3_BB = NO_MESSAGE_BOX_CLOSE_CONFIRMATION_AFTER_LOBBY_JOIN | NO_MESSAGE_BOX_CLOSE_CONFIRMATION,
DEFAULT_V4 = NO_MESSAGE_BOX_CLOSE_CONFIRMATION_AFTER_LOBBY_JOIN | EPISODE_3_GAMES | CAN_SEE_EPISODE_3_LOBBIES,
};
uint16_t flags_for_version(GameVersion version, uint8_t sub_version);