maint: cleanup

This commit is contained in:
6arelyFuture 2023-10-30 09:59:20 +01:00
parent 7f2683ebea
commit 940752950e
Signed by: Future
GPG Key ID: FA77F074E98D98A5
10 changed files with 31 additions and 83 deletions

View File

@ -24,7 +24,7 @@ jobs:
- Release
steps:
- name: Check out files
uses: actions/checkout@v3.5.2
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
@ -44,7 +44,7 @@ jobs:
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=Win32 build/black-ops-plugin.sln
- name: Upload ${{matrix.configuration}} binaries
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v3.1.3
with:
name: ${{matrix.configuration}} binaries
path: |

View File

@ -92,8 +92,6 @@ targetname "black-ops-plugin"
pchheader "std_include.hpp"
pchsource "src/client/std_include.cpp"
linkoptions {"/IGNORE:4254", "/PDBCompress"}
files {"./src/client/**.hpp", "./src/client/**.cpp"}
includedirs {"./src/client", "./src/common", "%{prj.location}/src"}

View File

@ -44,10 +44,10 @@ public:
game::select(0x355E69C, 0x243FB1C));
cmd_vstr_f_var->function = cmd_vstr_f;
if (game::environment::is_sp()) {
if (game::environment::is_sp()) {
// Fix (client) crash from SV_DropClient (server side)
utils::hook::set<std::uint8_t>(0x634C1D, 0xEB);
}
}
}
};
} // namespace command_additions

View File

@ -2,11 +2,11 @@
#include "cryptography.hpp"
namespace jenkins_one_at_a_time {
unsigned int jenkins_one_at_a_time::compute(const std::string& data) {
unsigned int compute(const std::string& data) {
return compute(data.data(), data.size());
}
unsigned int jenkins_one_at_a_time::compute(const char* key, const size_t len) {
unsigned int compute(const char* key, const size_t len) {
unsigned int hash, i;
for (hash = i = 0; i < len; ++i) {
hash += key[i];

View File

@ -11,8 +11,8 @@ public:
info_string(const std::string_view& buffer);
void set(const std::string& key, const std::string& value);
std::string get(const std::string& key) const;
std::string build() const;
[[nodiscard]] std::string get(const std::string& key) const;
[[nodiscard]] std::string build() const;
private:
std::unordered_map<std::string, std::string> key_value_pairs_{};

View File

@ -55,7 +55,7 @@ bool read_file(const std::string& file, std::string* data) {
stream.seekg(0, std::ios::beg);
if (size > -1) {
data->resize(static_cast<uint32_t>(size));
data->resize(static_cast<std::size_t>(size));
stream.read(data->data(), size);
stream.close();
return true;

View File

@ -6,7 +6,7 @@ library library::load(const std::string& name) {
}
library library::load(const std::filesystem::path& path) {
return library::load(path.generic_string());
return load(path.generic_string());
}
library library::get_by_address(void* address) {
@ -98,7 +98,7 @@ bool library::is_valid() const {
std::string library::get_name() const {
if (!this->is_valid())
return "";
return {};
auto path = this->get_path();
const auto pos = path.find_last_of("/\\");
@ -110,9 +110,9 @@ std::string library::get_name() const {
std::string library::get_path() const {
if (!this->is_valid())
return "";
return {};
char name[MAX_PATH] = {0};
char name[MAX_PATH]{};
GetModuleFileNameA(this->module_, name, sizeof name);
return name;
@ -120,7 +120,7 @@ std::string library::get_path() const {
std::string library::get_folder() const {
if (!this->is_valid())
return "";
return {};
const auto path = std::filesystem::path(this->get_path());
return path.parent_path().generic_string();
@ -221,7 +221,7 @@ void relaunch_self() {
ZeroMemory(&process_info, sizeof(process_info));
startup_info.cb = sizeof(startup_info);
char current_dir[MAX_PATH];
char current_dir[MAX_PATH]{};
GetCurrentDirectoryA(sizeof(current_dir), current_dir);
auto* const command_line = GetCommandLineA();

View File

@ -32,21 +32,21 @@ public:
bool operator!=(const library& obj) const { return !(*this == obj); };
bool operator==(const library& obj) const;
operator bool() const;
operator HMODULE() const;
[[nodiscard]] operator bool() const;
[[nodiscard]] operator HMODULE() const;
void unprotect() const;
void* get_entry_point() const;
size_t get_relative_entry_point() const;
[[nodiscard]] void* get_entry_point() const;
[[nodiscard]] size_t get_relative_entry_point() const;
bool is_valid() const;
std::string get_name() const;
std::string get_path() const;
std::string get_folder() const;
std::uint8_t* get_ptr() const;
[[nodiscard]] bool is_valid() const;
[[nodiscard]] std::string get_name() const;
[[nodiscard]] std::string get_path() const;
[[nodiscard]] std::string get_folder() const;
[[nodiscard]] std::uint8_t* get_ptr() const;
void free();
HMODULE get_handle() const;
[[nodiscard]] HMODULE get_handle() const;
template <typename T> T get_proc(const std::string& process) const {
if (!this->is_valid())
@ -85,14 +85,14 @@ public:
return T();
}
std::vector<PIMAGE_SECTION_HEADER> get_section_headers() const;
[[nodiscard]] std::vector<PIMAGE_SECTION_HEADER> get_section_headers() const;
PIMAGE_NT_HEADERS get_nt_headers() const;
PIMAGE_DOS_HEADER get_dos_header() const;
PIMAGE_OPTIONAL_HEADER get_optional_header() const;
[[nodiscard]] PIMAGE_NT_HEADERS get_nt_headers() const;
[[nodiscard]] PIMAGE_DOS_HEADER get_dos_header() const;
[[nodiscard]] PIMAGE_OPTIONAL_HEADER get_optional_header() const;
void** get_iat_entry(const std::string& module_name,
const std::string& proc_name) const;
[[nodiscard]] void** get_iat_entry(const std::string& module_name,
const std::string& proc_name) const;
private:
HMODULE module_;

View File

@ -93,51 +93,6 @@ std::string get_clipboard_data() {
return {};
}
void strip(const char* in, char* out, size_t max) {
if (!in || !out)
return;
max--;
size_t current = 0;
while (*in != 0 && current < max) {
const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48);
if (*in == '^' && (color_index != 7 || *(in + 1) == '7')) {
++in;
} else {
*out = *in;
++out;
++current;
}
++in;
}
*out = '\0';
}
std::string convert(const std::wstring& wstr) {
std::string result;
result.reserve(wstr.size());
for (const auto& chr : wstr) {
result.push_back(static_cast<char>(chr));
}
return result;
}
std::wstring convert(const std::string& str) {
std::wstring result;
result.reserve(str.size());
for (const auto& chr : str) {
result.push_back(static_cast<wchar_t>(chr));
}
return result;
}
std::string replace(std::string str, const std::string& from,
const std::string& to) {
if (from.empty()) {

View File

@ -87,11 +87,6 @@ std::string dump_hex(const std::string& data,
std::string get_clipboard_data();
void strip(const char* in, char* out, size_t max);
std::string convert(const std::wstring& wstr);
std::wstring convert(const std::string& str);
std::string replace(std::string str, const std::string& from,
const std::string& to);
} // namespace utils::string