mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-15 08:30:07 +00:00
network: Make citra mods optional and disabled by default
To avoid extra legal responsibility, this should actually only be used on our self-hosted rooms.
This commit is contained in:
parent
9d062d63da
commit
13ec2abbf6
@ -54,6 +54,7 @@ static void PrintHelp(const char* argv0) {
|
|||||||
"--token The token used for announce\n"
|
"--token The token used for announce\n"
|
||||||
"--web-api-url Citra Web API url\n"
|
"--web-api-url Citra Web API url\n"
|
||||||
"--ban-list-file The file for storing the room ban list\n"
|
"--ban-list-file The file for storing the room ban list\n"
|
||||||
|
"--enable-citra-mods Allow Citra Community Moderators to moderate on your room\n"
|
||||||
"-h, --help Display this help and exit\n"
|
"-h, --help Display this help and exit\n"
|
||||||
"-v, --version Output version information and exit\n";
|
"-v, --version Output version information and exit\n";
|
||||||
}
|
}
|
||||||
@ -148,6 +149,7 @@ int main(int argc, char** argv) {
|
|||||||
u64 preferred_game_id = 0;
|
u64 preferred_game_id = 0;
|
||||||
u32 port = Network::DefaultRoomPort;
|
u32 port = Network::DefaultRoomPort;
|
||||||
u32 max_members = 16;
|
u32 max_members = 16;
|
||||||
|
bool enable_citra_mods = false;
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"room-name", required_argument, 0, 'n'},
|
{"room-name", required_argument, 0, 'n'},
|
||||||
@ -161,6 +163,7 @@ int main(int argc, char** argv) {
|
|||||||
{"token", required_argument, 0, 't'},
|
{"token", required_argument, 0, 't'},
|
||||||
{"web-api-url", required_argument, 0, 'a'},
|
{"web-api-url", required_argument, 0, 'a'},
|
||||||
{"ban-list-file", required_argument, 0, 'b'},
|
{"ban-list-file", required_argument, 0, 'b'},
|
||||||
|
{"enable-citra-mods", no_argument, 0, 'e'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
@ -203,6 +206,9 @@ int main(int argc, char** argv) {
|
|||||||
case 'b':
|
case 'b':
|
||||||
ban_list_file.assign(optarg);
|
ban_list_file.assign(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
enable_citra_mods = true;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
@ -261,6 +267,10 @@ int main(int argc, char** argv) {
|
|||||||
Settings::values.citra_username = username;
|
Settings::values.citra_username = username;
|
||||||
Settings::values.citra_token = token;
|
Settings::values.citra_token = token;
|
||||||
}
|
}
|
||||||
|
if (!announce && enable_citra_mods) {
|
||||||
|
enable_citra_mods = false;
|
||||||
|
std::cout << "Can not enable Citra Moderators for private rooms\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Load the ban list
|
// Load the ban list
|
||||||
Network::Room::BanList ban_list;
|
Network::Room::BanList ban_list;
|
||||||
@ -284,7 +294,8 @@ int main(int argc, char** argv) {
|
|||||||
Network::Init();
|
Network::Init();
|
||||||
if (std::shared_ptr<Network::Room> room = Network::GetRoom().lock()) {
|
if (std::shared_ptr<Network::Room> room = Network::GetRoom().lock()) {
|
||||||
if (!room->Create(room_name, room_description, "", port, password, max_members, username,
|
if (!room->Create(room_name, room_description, "", port, password, max_members, username,
|
||||||
preferred_game, preferred_game_id, std::move(verify_backend), ban_list)) {
|
preferred_game, preferred_game_id, std::move(verify_backend), ban_list,
|
||||||
|
enable_citra_mods)) {
|
||||||
std::cout << "Failed to create room: \n\n";
|
std::cout << "Failed to create room: \n\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -589,8 +589,6 @@ bool Room::RoomImpl::IsValidConsoleId(const std::string& console_id_hash) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Room::RoomImpl::HasModPermission(const ENetPeer* client) const {
|
bool Room::RoomImpl::HasModPermission(const ENetPeer* client) const {
|
||||||
if (room_information.host_username.empty())
|
|
||||||
return false; // This room does not support moderation
|
|
||||||
std::lock_guard<std::mutex> lock(member_mutex);
|
std::lock_guard<std::mutex> lock(member_mutex);
|
||||||
const auto sending_member =
|
const auto sending_member =
|
||||||
std::find_if(members.begin(), members.end(),
|
std::find_if(members.begin(), members.end(),
|
||||||
@ -598,10 +596,16 @@ bool Room::RoomImpl::HasModPermission(const ENetPeer* client) const {
|
|||||||
if (sending_member == members.end()) {
|
if (sending_member == members.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (sending_member->user_data.moderator) // Community moderator
|
if (room_information.enable_citra_mods &&
|
||||||
|
sending_member->user_data.moderator) { // Community moderator
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
if (sending_member->user_data.username == room_information.host_username) // Room host
|
}
|
||||||
|
if (!room_information.host_username.empty() &&
|
||||||
|
sending_member->user_data.username == room_information.host_username) { // Room host
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -963,7 +967,7 @@ bool Room::Create(const std::string& name, const std::string& description,
|
|||||||
const u32 max_connections, const std::string& host_username,
|
const u32 max_connections, const std::string& host_username,
|
||||||
const std::string& preferred_game, u64 preferred_game_id,
|
const std::string& preferred_game, u64 preferred_game_id,
|
||||||
std::unique_ptr<VerifyUser::Backend> verify_backend,
|
std::unique_ptr<VerifyUser::Backend> verify_backend,
|
||||||
const Room::BanList& ban_list) {
|
const Room::BanList& ban_list, bool enable_citra_mods) {
|
||||||
ENetAddress address;
|
ENetAddress address;
|
||||||
address.host = ENET_HOST_ANY;
|
address.host = ENET_HOST_ANY;
|
||||||
if (!server_address.empty()) {
|
if (!server_address.empty()) {
|
||||||
@ -986,6 +990,7 @@ bool Room::Create(const std::string& name, const std::string& description,
|
|||||||
room_impl->room_information.preferred_game = preferred_game;
|
room_impl->room_information.preferred_game = preferred_game;
|
||||||
room_impl->room_information.preferred_game_id = preferred_game_id;
|
room_impl->room_information.preferred_game_id = preferred_game_id;
|
||||||
room_impl->room_information.host_username = host_username;
|
room_impl->room_information.host_username = host_username;
|
||||||
|
room_impl->room_information.enable_citra_mods = enable_citra_mods;
|
||||||
room_impl->password = password;
|
room_impl->password = password;
|
||||||
room_impl->verify_backend = std::move(verify_backend);
|
room_impl->verify_backend = std::move(verify_backend);
|
||||||
room_impl->username_ban_list = ban_list.first;
|
room_impl->username_ban_list = ban_list.first;
|
||||||
|
@ -32,6 +32,7 @@ struct RoomInformation {
|
|||||||
std::string preferred_game; ///< Game to advertise that you want to play
|
std::string preferred_game; ///< Game to advertise that you want to play
|
||||||
u64 preferred_game_id; ///< Title ID for the advertised game
|
u64 preferred_game_id; ///< Title ID for the advertised game
|
||||||
std::string host_username; ///< Forum username of the host
|
std::string host_username; ///< Forum username of the host
|
||||||
|
bool enable_citra_mods; ///< Allow Citra Moderators to moderate on this room
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameInfo {
|
struct GameInfo {
|
||||||
@ -147,7 +148,7 @@ public:
|
|||||||
const std::string& host_username = "", const std::string& preferred_game = "",
|
const std::string& host_username = "", const std::string& preferred_game = "",
|
||||||
u64 preferred_game_id = 0,
|
u64 preferred_game_id = 0,
|
||||||
std::unique_ptr<VerifyUser::Backend> verify_backend = nullptr,
|
std::unique_ptr<VerifyUser::Backend> verify_backend = nullptr,
|
||||||
const BanList& ban_list = {});
|
const BanList& ban_list = {}, bool enable_citra_mods = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the verification GUID of the room.
|
* Sets the verification GUID of the room.
|
||||||
|
Loading…
Reference in New Issue
Block a user