Organize scripts and add TWS plugins with HTTP timeouts

Vendor pinned T5 and T6 plugin sources under the new plugins layout. Add native HTTP deadlines, status and timing diagnostics, telemetry integration, and build/test tooling.
This commit is contained in:
2026-10-09 11:02:20 -04:00
parent b172086301
commit 1121b44857
253 changed files with 28028 additions and 59 deletions
@@ -0,0 +1,35 @@
#pragma once
#include "../plugin.hpp"
class component_interface
{
public:
virtual ~component_interface()
{
}
virtual void on_startup([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void on_dvar_init([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void on_after_dvar_init([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void on_game_init([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void on_shutdown([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual bool is_supported()
{
return true;
}
};
@@ -0,0 +1,72 @@
#include <stdinc.hpp>
#include "component_loader.hpp"
void component_loader::register_component(const std::string& name, std::unique_ptr<component_interface>&& component_)
{
get_components().push_back(std::make_pair(name, std::move(component_)));
}
#define ON_CALLBACK(__name__) \
void component_loader::__name__() \
{ \
static auto handled = false; \
if (handled) \
{ \
return; \
} \
\
handled = true; \
\
for (const auto& component_ : get_components()) \
{ \
try \
{ \
component_.second->__name__(plugin::get()); \
} \
catch (const std::exception& e) \
{ \
printf("error executing component \"%s\" callback \"%s\": %s\n", component_.first.data(), #__name__, e.what()); \
} \
} \
} \
ON_CALLBACK(on_startup);
ON_CALLBACK(on_dvar_init);
ON_CALLBACK(on_after_dvar_init);
ON_CALLBACK(on_shutdown);
void component_loader::clean()
{
auto& components = get_components();
for (auto i = components.begin(); i != components.end();)
{
if (!(*i).second->is_supported())
{
(*i).second->on_shutdown(plugin::get());
i = components.erase(i);
}
else
{
++i;
}
}
}
void component_loader::trigger_premature_shutdown()
{
throw premature_shutdown_trigger();
}
std::vector<std::pair<std::string, std::unique_ptr<component_interface>>>& component_loader::get_components()
{
using component_vector = std::vector<std::pair<std::string, std::unique_ptr<component_interface>>>;
using component_vector_container = std::unique_ptr<component_vector, std::function<void(component_vector*)>>;
static component_vector_container components(new component_vector, [](component_vector* component_vector)
{
on_shutdown();
delete component_vector;
});
return *components;
}
@@ -0,0 +1,61 @@
#pragma once
#include "component_interface.hpp"
class component_loader final
{
public:
class premature_shutdown_trigger final : public std::exception
{
[[nodiscard]] const char* what() const noexcept override
{
return "Premature shutdown requested";
}
};
template <typename T>
class installer final
{
static_assert(std::is_base_of<component_interface, T>::value, "component has invalid base class");
public:
installer(const std::string& name)
{
register_component(name, std::make_unique<T>());
}
};
template <typename T>
static T* get()
{
for (const auto& component_ : get_components())
{
if (typeid(*component_.get()) == typeid(T))
{
return reinterpret_cast<T*>(component_.get());
}
}
return nullptr;
}
static void register_component(const std::string& name, std::unique_ptr<component_interface>&& component);
static void on_startup();
static void on_dvar_init();
static void on_after_dvar_init();
static void on_shutdown();
static void clean();
static void* load_import(const std::string& library, const std::string& function);
static void trigger_premature_shutdown();
private:
static std::vector<std::pair<std::string, std::unique_ptr<component_interface>>>& get_components();
};
#define REGISTER_COMPONENT(name) \
namespace \
{ \
static component_loader::installer<name> __component(#name); \
}