Thread names + some fixes

This commit is contained in:
Federico Cecchetto 2021-09-26 17:54:48 +02:00
parent 0b1efab69e
commit cb7517e583
3 changed files with 68 additions and 26 deletions

View File

@ -50,27 +50,6 @@ namespace patches
dvars::register_float("jump_height", 39, 0, 1000, game::DVAR_FLAG_REPLICATED); dvars::register_float("jump_height", 39, 0, 1000, game::DVAR_FLAG_REPLICATED);
dvars::register_float("g_gravity", 800, 1, 1000, game::DVAR_FLAG_REPLICATED); dvars::register_float("g_gravity", 800, 1, 1000, game::DVAR_FLAG_REPLICATED);
dvars::register_int("g_speed", 190, 0, 1000, game::DVAR_FLAG_REPLICATED); dvars::register_int("g_speed", 190, 0, 1000, game::DVAR_FLAG_REPLICATED);
dvars::register_bool("sf_use_martyr_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_precision_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_greenberet_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_slowmo", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_fortitude_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_desperation_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_polterghost_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_wolf_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_attraction_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_starvation_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_ignoreammo", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_pineapple_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_football_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_tire_explosion", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_clustergrenade", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_pomegrenade_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_pinata_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_chaplin", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_edge_mode", false, game::DVAR_FLAG_NONE);
dvars::register_bool("sf_use_bw", false, game::DVAR_FLAG_NONE);
} }
}; };
} }

View File

@ -0,0 +1,60 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include "game/game.hpp"
#include <utils/thread.hpp>
namespace thread_names
{
namespace
{
void set_thread_names()
{
static std::unordered_map<int, std::string> thread_names =
{
{game::THREAD_CONTEXT_MAIN, "Main"},
{game::THREAD_CONTEXT_BACKEND, "Backend"}, // Renderer
{game::THREAD_CONTEXT_WORKER0, "Worker0"},
{game::THREAD_CONTEXT_WORKER1, "Worker1"},
{game::THREAD_CONTEXT_WORKER2, "Worker2"},
{game::THREAD_CONTEXT_WORKER3, "Worker3"},
{game::THREAD_CONTEXT_WORKER4, "Worker4"},
{game::THREAD_CONTEXT_WORKER5, "Worker5"},
{game::THREAD_CONTEXT_WORKER6, "Worker6"},
{game::THREAD_CONTEXT_WORKER7, "Worker7"},
{game::THREAD_CONTEXT_SERVER, "Server"},
{game::THREAD_CONTEXT_CINEMATIC, "Cinematic"},
{game::THREAD_CONTEXT_DATABASE, "Database"},
{game::THREAD_CONTEXT_STREAM, "Stream"},
{game::THREAD_CONTEXT_SNDSTREAMPACKETCALLBACK, "Snd stream packet callback"},
{game::THREAD_CONTEXT_STATS_WRITE, "Stats write"},
};
for (const auto& thread_name : thread_names)
{
const auto id = game::threadIds[thread_name.first];
if (id)
{
utils::thread::set_name(id, thread_name.second);
}
}
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
set_thread_names();
scheduler::once(set_thread_names, scheduler::pipeline::main);
scheduler::once(set_thread_names, scheduler::pipeline::renderer);
scheduler::once(set_thread_names, scheduler::pipeline::server);
}
};
}
REGISTER_COMPONENT(thread_names::component)

View File

@ -119,6 +119,8 @@ namespace ui_scripting
int style, float* color, float* second_color, float* glow_color) int style, float* color, float* second_color, float* glow_color)
{ {
const auto result = (uint64_t)game::R_AddCmdDrawText(text, 0x7FFFFFFF, font, x, y, x_scale, y_scale, rotation, color, style); const auto result = (uint64_t)game::R_AddCmdDrawText(text, 0x7FFFFFFF, font, x, y, x_scale, y_scale, rotation, color, style);
if (result)
{
*reinterpret_cast<float*>(result + 188) = glow_color[0]; *reinterpret_cast<float*>(result + 188) = glow_color[0];
*reinterpret_cast<float*>(result + 192) = glow_color[1]; *reinterpret_cast<float*>(result + 192) = glow_color[1];
*reinterpret_cast<float*>(result + 196) = glow_color[2]; *reinterpret_cast<float*>(result + 196) = glow_color[2];
@ -126,6 +128,7 @@ namespace ui_scripting
*reinterpret_cast<game::rgba*>(result + 228) = float_to_rgba(second_color); *reinterpret_cast<game::rgba*>(result + 228) = float_to_rgba(second_color);
} }
} }
}
element::element() element::element()
: id(next_id++) : id(next_id++)