* feat(Commands): Prototype command system
* feat(Commands): Chat commands
* refactor(Toxic): convert most options into commands
* feat(Protections): block breakup kicks on other players as host
* refactor(Kicks): convert most options into commands
* refactor(Commands): add labels and descriptions to all commands
* feat(Commands): cleanup on unload
* refactor(Troll): convert most options into commands
* refactor(Misc): convert most options into commands
* refactor(Teleport): convert most options into commands
* feat(Commands): Variadic commands and toggleable bools
* feat(Hotkeys): hotkeys now use commands
* fix(Chat): fix the chat window locking up when a message is sent
* fix(Commands): properly handle spoofed username
* fix(Spam): update filter

Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
This commit is contained in:
maybegreat48
2022-12-22 21:23:32 +00:00
committed by GitHub
parent f44859a973
commit 79e5e7a30b
143 changed files with 3194 additions and 1458 deletions

View File

@ -2,10 +2,10 @@
namespace big
{
hotkey::hotkey(rage::joaat_t name_hash, key_t key, hotkey_func func, std::optional<std::chrono::high_resolution_clock::duration> cooldown) :
hotkey::hotkey(rage::joaat_t name_hash, key_t key, rage::joaat_t command_hash, std::optional<std::chrono::high_resolution_clock::duration> cooldown) :
m_name_hash(name_hash),
m_key(key),
m_func(func),
m_command_hash(command_hash),
m_cooldown(cooldown),
m_wakeup()
{
@ -22,7 +22,7 @@ namespace big
if (m_cooldown.has_value())
m_wakeup = std::chrono::high_resolution_clock::now() + m_cooldown.value();
m_func();
command::get(m_command_hash)->call(std::vector<std::uint64_t>());
}
rage::joaat_t hotkey::name_hash() const

View File

@ -1,16 +1,16 @@
#pragma once
#include "common.hpp"
#include "rage/joaat.hpp"
#include "backend/command.hpp"
namespace big
{
using hotkey_func = std::function<void()>;
using key_t = unsigned int;
class hotkey final
{
public:
hotkey(rage::joaat_t name_hash, key_t key, hotkey_func func, std::optional<std::chrono::high_resolution_clock::duration> cooldown = std::nullopt);
hotkey(rage::joaat_t name_hash, key_t key, rage::joaat_t command_hash, std::optional<std::chrono::high_resolution_clock::duration> cooldown = std::nullopt);
virtual ~hotkey() = default;
bool can_exec() const;
@ -23,7 +23,7 @@ namespace big
rage::joaat_t m_name_hash;
key_t m_key;
hotkey_func m_func;
rage::joaat_t m_command_hash;
std::optional<std::chrono::high_resolution_clock::duration> m_cooldown;
std::chrono::high_resolution_clock::time_point m_wakeup;

View File

@ -1,14 +0,0 @@
#include "common.hpp"
#include "hotkey_functions.hpp"
#include "services/notifications/notification_service.hpp"
namespace big::hotkey_funcs
{
void toggle_noclip()
{
const auto state = !g.self.noclip;
g_notification_service->push("Noclip", std::format("Noclip has been {}.", state ? "enabled" : "disabled"));
g.self.noclip = state;
}
}

View File

@ -1,6 +0,0 @@
#pragma once
namespace big::hotkey_funcs
{
extern void toggle_noclip();
}

View File

@ -1,7 +1,6 @@
#include "hotkey_service.hpp"
#include "fiber_pool.hpp"
#include "util/teleport.hpp"
#include "hotkey_functions.hpp"
#include "renderer.hpp"
#include "network/ChatData.hpp"
@ -11,9 +10,9 @@ namespace big
{
hotkey_service::hotkey_service()
{
register_hotkey("waypoint", g.settings.hotkeys.teleport_waypoint, teleport::to_waypoint);
register_hotkey("objective", g.settings.hotkeys.teleport_objective, teleport::to_objective);
register_hotkey("noclip", g.settings.hotkeys.noclip, hotkey_funcs::toggle_noclip);
register_hotkey("waypoint", g.settings.hotkeys.teleport_waypoint, RAGE_JOAAT("waypointtp"));
register_hotkey("objective", g.settings.hotkeys.teleport_objective, RAGE_JOAAT("objectivetp"));
register_hotkey("noclip", g.settings.hotkeys.noclip, RAGE_JOAAT("noclip"));
g_renderer->add_wndproc_callback([this](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
@ -28,9 +27,9 @@ namespace big
g_hotkey_service = nullptr;
}
void hotkey_service::register_hotkey(const std::string_view name, key_t key, hotkey_func func, eKeyState state, std::optional<std::chrono::high_resolution_clock::duration> cooldown)
void hotkey_service::register_hotkey(const std::string_view name, key_t key, rage::joaat_t command_hash, eKeyState state, std::optional<std::chrono::high_resolution_clock::duration> cooldown)
{
m_hotkeys[state == eKeyState::RELEASE].emplace(key, hotkey(rage::joaat(name), key, func, cooldown));
m_hotkeys[state == eKeyState::RELEASE].emplace(key, hotkey(rage::joaat(name), key, command_hash, cooldown));
}
bool hotkey_service::update_hotkey(const std::string_view name, const key_t key)

View File

@ -26,7 +26,7 @@ namespace big
void register_hotkey(
const std::string_view name,
const key_t initial_key,
const hotkey_func func,
const rage::joaat_t command_hash,
const eKeyState state = eKeyState::RELEASE,
std::optional<std::chrono::high_resolution_clock::duration> cooldown = std::nullopt);
bool update_hotkey(const std::string_view name, const key_t new_key);

View File

@ -13,6 +13,7 @@ namespace big
int block_join_reason = 1;
bool is_modder = false;
std::unordered_set<int> infractions;
std::optional<CommandAccessLevel> command_access_level = std::nullopt;
};
static void to_json(nlohmann::json& j, const persistent_player& player)
@ -23,8 +24,11 @@ namespace big
{ "block_join", player.block_join },
{ "block_join_reason", player.block_join_reason },
{ "is_modder", player.is_modder },
{ "infractions", player.infractions },
{ "infractions", player.infractions }
};
if (player.command_access_level.has_value())
j["command_access_level"] = player.command_access_level.value();
};
static void from_json(const nlohmann::json& j, persistent_player& player)
@ -35,5 +39,8 @@ namespace big
set_from_key_or_default(j, "block_join_reason", player.block_join_reason);
set_from_key_or_default(j, "is_modder", player.is_modder);
set_from_key_or_default(j, "infractions", player.infractions);
if (j.contains("command_access_level") && j["command_access_level"].is_string())
player.command_access_level = j["command_access_level"].get<CommandAccessLevel>();
}
};

View File

@ -47,6 +47,8 @@ namespace big
[[nodiscard]] bool is_host() const;
[[nodiscard]] bool is_valid() const;
std::optional<CommandAccessLevel> command_access_level = std::nullopt;
bool off_radar = false;
bool never_wanted = false;
bool semi_godmode = false;

View File

@ -66,6 +66,7 @@ namespace big
if (!m_self_ptr || !m_self_ptr->equals(*m_self))
{
m_self_ptr = std::make_shared<player>(*m_self);
m_self_ptr->command_access_level = CommandAccessLevel::ADMIN;
}
return m_self_ptr;