mirror of
https://github.com/citra-emu/citra-nightly.git
synced 2024-12-23 23:05:26 +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"
|
||||
"--web-api-url Citra Web API url\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"
|
||||
"-v, --version Output version information and exit\n";
|
||||
}
|
||||
|
@ -148,6 +149,7 @@ int main(int argc, char** argv) {
|
|||
u64 preferred_game_id = 0;
|
||||
u32 port = Network::DefaultRoomPort;
|
||||
u32 max_members = 16;
|
||||
bool enable_citra_mods = false;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"room-name", required_argument, 0, 'n'},
|
||||
|
@ -161,6 +163,7 @@ int main(int argc, char** argv) {
|
|||
{"token", required_argument, 0, 't'},
|
||||
{"web-api-url", required_argument, 0, 'a'},
|
||||
{"ban-list-file", required_argument, 0, 'b'},
|
||||
{"enable-citra-mods", no_argument, 0, 'e'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0},
|
||||
|
@ -203,6 +206,9 @@ int main(int argc, char** argv) {
|
|||
case 'b':
|
||||
ban_list_file.assign(optarg);
|
||||
break;
|
||||
case 'e':
|
||||
enable_citra_mods = true;
|
||||
break;
|
||||
case 'h':
|
||||
PrintHelp(argv[0]);
|
||||
return 0;
|
||||
|
@ -261,6 +267,10 @@ int main(int argc, char** argv) {
|
|||
Settings::values.citra_username = username;
|
||||
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
|
||||
Network::Room::BanList ban_list;
|
||||
|
@ -284,7 +294,8 @@ int main(int argc, char** argv) {
|
|||
Network::Init();
|
||||
if (std::shared_ptr<Network::Room> room = Network::GetRoom().lock()) {
|
||||
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";
|
||||
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 {
|
||||
if (room_information.host_username.empty())
|
||||
return false; // This room does not support moderation
|
||||
std::lock_guard<std::mutex> lock(member_mutex);
|
||||
const auto sending_member =
|
||||
std::find_if(members.begin(), members.end(),
|
||||
|
@ -598,10 +596,16 @@ bool Room::RoomImpl::HasModPermission(const ENetPeer* client) const {
|
|||
if (sending_member == members.end()) {
|
||||
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;
|
||||
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 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 std::string& preferred_game, u64 preferred_game_id,
|
||||
std::unique_ptr<VerifyUser::Backend> verify_backend,
|
||||
const Room::BanList& ban_list) {
|
||||
const Room::BanList& ban_list, bool enable_citra_mods) {
|
||||
ENetAddress address;
|
||||
address.host = ENET_HOST_ANY;
|
||||
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_id = preferred_game_id;
|
||||
room_impl->room_information.host_username = host_username;
|
||||
room_impl->room_information.enable_citra_mods = enable_citra_mods;
|
||||
room_impl->password = password;
|
||||
room_impl->verify_backend = std::move(verify_backend);
|
||||
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
|
||||
u64 preferred_game_id; ///< Title ID for the advertised game
|
||||
std::string host_username; ///< Forum username of the host
|
||||
bool enable_citra_mods; ///< Allow Citra Moderators to moderate on this room
|
||||
};
|
||||
|
||||
struct GameInfo {
|
||||
|
@ -147,7 +148,7 @@ public:
|
|||
const std::string& host_username = "", const std::string& preferred_game = "",
|
||||
u64 preferred_game_id = 0,
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue