mirror of
https://github.com/diamante0018/MW3ServerFreezer.git
synced 2025-04-19 11:42:53 +00:00
Fix some things
This commit is contained in:
parent
9e1ad47a6b
commit
c6fecc308b
@ -15,7 +15,7 @@ void __declspec(naked) draw_red_box_stub() {
|
||||
__asm {
|
||||
push eax
|
||||
mov eax, cl_EnableCheats
|
||||
cmp byte ptr [eax + 12], 1
|
||||
cmp byte ptr [eax + 0xC], 1
|
||||
pop eax
|
||||
|
||||
je draw
|
||||
@ -35,7 +35,7 @@ void __declspec(naked) blind_eye_check_stub() {
|
||||
__asm {
|
||||
push eax
|
||||
mov eax, cl_EnableCheats
|
||||
cmp byte ptr [eax + 12], 1
|
||||
cmp byte ptr [eax + 0xC], 1
|
||||
pop eax
|
||||
|
||||
je draw
|
||||
|
@ -100,9 +100,9 @@ private:
|
||||
console::info("{} doesn't exist", dvar_name);
|
||||
return;
|
||||
}
|
||||
if (dvar->type != game::dvar_type::DVAR_TYPE_STRING &&
|
||||
dvar->type != game::dvar_type::DVAR_TYPE_ENUM) {
|
||||
console::info("{} is not a string-based dvar\n", dvar->name);
|
||||
if (dvar->type != game::DVAR_TYPE_STRING &&
|
||||
dvar->type != game::DVAR_TYPE_ENUM) {
|
||||
console::info("{} is not a string-based dvar", dvar->name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ private:
|
||||
|
||||
void initialize() {
|
||||
this->console_thread_ =
|
||||
utils::thread::create_named_thread("Console", [this]() {
|
||||
utils::thread::create_named_thread("Console", [this] {
|
||||
if (!utils::flags::has_flag("noconsole")) {
|
||||
game::Sys_ShowConsole();
|
||||
}
|
||||
@ -92,7 +92,7 @@ private:
|
||||
}
|
||||
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
DispatchMessageA(&msg);
|
||||
} else {
|
||||
this->log_messages();
|
||||
std::this_thread::sleep_for(1ms);
|
||||
@ -145,17 +145,12 @@ private:
|
||||
|
||||
HWND get_window() { return *reinterpret_cast<HWND*>(0x5A86330); }
|
||||
|
||||
#ifdef _DEBUG
|
||||
void print(const std::source_location& location, std::string_view fmt,
|
||||
std::format_args&& args) {
|
||||
#else
|
||||
void print(std::string_view fmt, std::format_args&& args) {
|
||||
#endif
|
||||
void print(std::string_view fmt, std::format_args&& args,
|
||||
const std::source_location& loc) {
|
||||
#ifdef _DEBUG
|
||||
const auto msg = std::vformat(fmt, args);
|
||||
const auto line =
|
||||
std::format("Debug:\n {}\nFile: {}\nFunction: {}\n\n", msg,
|
||||
location.file_name(), location.function_name());
|
||||
const auto line = std::format("Debug:\n {}\nFile: {}\nLine: {}\n",
|
||||
msg, loc.file_name(), loc.line());
|
||||
#else
|
||||
const auto line = std::vformat(fmt, args) + "\n";
|
||||
#endif
|
||||
|
@ -3,28 +3,17 @@
|
||||
namespace console {
|
||||
HWND get_window();
|
||||
|
||||
#ifdef _DEBUG
|
||||
void print(const std::source_location& location,
|
||||
void print(std::string_view fmt, std::format_args&& args,
|
||||
const std::source_location& loc);
|
||||
|
||||
std::string_view fmt, std::format_args&& args);
|
||||
#else
|
||||
void print(std::string_view fmt, std::format_args&& args);
|
||||
#endif
|
||||
|
||||
static inline void console_log(std::string_view fmt, std::format_args&& args) {
|
||||
#ifdef _DEBUG
|
||||
print(std::source_location::current(), fmt, std::move(args));
|
||||
#else
|
||||
print(fmt, std::move(args));
|
||||
#endif
|
||||
}
|
||||
template <typename... Args> class info {
|
||||
public:
|
||||
info(std::string_view fmt, const Args&... args,
|
||||
const std::source_location& loc = std::source_location::current()) {
|
||||
print(fmt, std::make_format_args(args...), loc);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
static inline void info(std::string_view fmt, Args&&... args) {
|
||||
console_log(fmt, std::make_format_args(args...));
|
||||
}
|
||||
|
||||
static inline void info(std::string_view fmt) {
|
||||
console_log(fmt, std::make_format_args(0));
|
||||
}
|
||||
info(std::string_view fmt, const Args&... args) -> info<Args...>;
|
||||
} // namespace console
|
||||
|
@ -9,10 +9,10 @@ namespace dvar_patches {
|
||||
namespace {
|
||||
void dvar_set_from_string_by_name_stub(const char* dvar_name,
|
||||
const char* string) {
|
||||
console::info("Server tried setting {} with value {}", dvar_name, string);
|
||||
console::info("Server tried setting '{}' with value '{}'", dvar_name, string);
|
||||
}
|
||||
|
||||
void dvar_override_cheat_protection_stub(bool /*a1*/) {
|
||||
void dvar_override_cheat_protection_stub(bool /*cheat_override*/) {
|
||||
*game::isCheatOverride = true;
|
||||
}
|
||||
} // namespace
|
||||
|
@ -70,7 +70,7 @@ private:
|
||||
|
||||
key_catcher::on_key_press(
|
||||
"L", []([[maybe_unused]] const game::LocalClientNum_t& local_client) {
|
||||
command::execute("undo_exploit");
|
||||
command::execute("undoExploit");
|
||||
});
|
||||
|
||||
key_catcher::on_key_press(
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#include "console.hpp"
|
||||
|
||||
namespace patches {
|
||||
namespace {
|
||||
constexpr auto max_fps = 125; // Meme
|
||||
@ -15,12 +17,36 @@ void __declspec(naked) get_com_max_fps() {
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
void bd_log_message_stub(const game::bdLogMessageType /*type*/,
|
||||
const char* const /*base_channel*/,
|
||||
const char* const /*channel*/,
|
||||
const char* const /*file*/,
|
||||
const char* const /*function*/,
|
||||
const unsigned int /*line*/, const char* format, ...) {
|
||||
char buf[4096] = {0};
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf_s(buf, _TRUNCATE, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
console::info("{}", buf);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class component final : public component_interface {
|
||||
void post_unpack() override {
|
||||
utils::hook(0x4E470D, get_com_max_fps, HOOK_JUMP).install()->quick();
|
||||
utils::hook::nop(0x4E4712, 4);
|
||||
|
||||
utils::hook(0x6EA960, bd_log_message_stub, HOOK_JUMP).install()->quick();
|
||||
|
||||
// Another meme
|
||||
static const auto* my_cg_fov = game::Dvar_RegisterFloat(
|
||||
"my_cg_fov", 100.0f, 65.0f, 160.0f, game::DVAR_INIT, "");
|
||||
utils::hook::set<const game::dvar_t**>(0x54BAF8, &my_cg_fov);
|
||||
utils::hook::set<const game::dvar_t**>(0x54BC35, &my_cg_fov);
|
||||
utils::hook::set<const game::dvar_t**>(0x5711C4, &my_cg_fov);
|
||||
}
|
||||
};
|
||||
} // namespace patches
|
||||
|
@ -64,9 +64,8 @@ private:
|
||||
void merge_callbacks() {
|
||||
callbacks_.access([&](task_list& tasks) {
|
||||
new_callbacks_.access([&](task_list& new_tasks) {
|
||||
tasks.insert(tasks.end(),
|
||||
std::move_iterator<task_list::iterator>(new_tasks.begin()),
|
||||
std::move_iterator<task_list::iterator>(new_tasks.end()));
|
||||
tasks.insert(tasks.end(), std::move_iterator(new_tasks.begin()),
|
||||
std::move_iterator(new_tasks.end()));
|
||||
new_tasks = {};
|
||||
});
|
||||
});
|
||||
@ -137,7 +136,7 @@ unsigned int thread_id;
|
||||
class component final : public component_interface {
|
||||
public:
|
||||
void post_unpack() override {
|
||||
thread = utils::thread::create_named_thread("Async Scheduler", []() {
|
||||
thread = utils::thread::create_named_thread("Async Scheduler", [] {
|
||||
while (!kill) {
|
||||
execute(pipeline::async);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
@ -12,7 +12,7 @@ enum pipeline {
|
||||
static const bool cond_continue = false;
|
||||
static const bool cond_end = true;
|
||||
|
||||
void clear_tasks(const pipeline type);
|
||||
void clear_tasks(pipeline type);
|
||||
|
||||
void schedule(const std::function<bool()>& callback,
|
||||
pipeline type = pipeline::client,
|
||||
|
@ -9,6 +9,12 @@ typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4];
|
||||
|
||||
enum bdLogMessageType {
|
||||
BD_LOG_INFO,
|
||||
BD_LOG_WARNING,
|
||||
BD_LOG_ERROR,
|
||||
};
|
||||
|
||||
struct cmd_function_t {
|
||||
cmd_function_t* next;
|
||||
const char* name;
|
||||
@ -166,8 +172,8 @@ enum dvar_flags : std::uint16_t {
|
||||
DVAR_CODINFO = 1 << 3,
|
||||
DVAR_SCRIPTINFO = 1 << 4,
|
||||
DVAR_SERVERINFO = 1 << 10,
|
||||
DVAR_WRITEPROTECTED = 1 << 11,
|
||||
DVAR_READONLY = 1 << 13,
|
||||
DVAR_INIT = 1 << 11,
|
||||
DVAR_ROM = 1 << 13,
|
||||
DVAR_AUTOEXEC = 1 << 15,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user