Support custom sv param construction

This commit is contained in:
momo5502 2023-04-02 18:41:40 +02:00
parent f75da130da
commit 8fd5a82153
3 changed files with 30 additions and 1 deletions

View File

@ -110,6 +110,21 @@ namespace command
assert(this->nesting_ < game::CMD_MAX_NESTING);
}
params_sv::params_sv(const std::string& text)
: needs_end_(true)
{
game::SV_Cmd_TokenizeString(text.data());
this->nesting_ = game::sv_cmd_args->nesting;
}
params_sv::~params_sv()
{
if (this->needs_end_)
{
game::SV_Cmd_EndTokenizedString();
}
}
int params_sv::size() const
{
return game::sv_cmd_args->argc[this->nesting_];

View File

@ -33,6 +33,14 @@ namespace command
{
public:
params_sv();
params_sv(const std::string& text);
~params_sv();
params_sv(params_sv&&) = delete;
params_sv(const params_sv&) = delete;
params_sv& operator=(params_sv&&) = delete;
params_sv& operator=(const params_sv&) = delete;
[[nodiscard]] int size() const;
[[nodiscard]] const char* get(int index) const;
@ -44,6 +52,7 @@ namespace command
}
private:
bool needs_end_{false};
int nesting_;
};

View File

@ -159,12 +159,17 @@ namespace game
// SV
WEAK symbol<bool()> SV_Loaded{0x142252250, 0x140535460};
WEAK symbol<void*()> SV_AddTestClient{0x142248F40, 0x14052E3E0};
WEAK symbol<void(int clientNum, svscmd_type type, const char* text)> SV_GameSendServerCommand{0x14224F580, 0x140532CA0};
WEAK symbol<void (netadr_t from)> SV_DirectConnect{0x142249880, 0x14052EC60};
WEAK symbol<void(int clientNum, svscmd_type type, const char* text)> SV_GameSendServerCommand{
0x14224F580, 0x140532CA0
};
WEAK symbol<void(client_s* cl_0, svscmd_type type, const char* fmt, ...)> SV_SendServerCommand{0x0, 0x140537F10};
WEAK symbol<bool(int clientNum)> SV_IsTestClient{0x14224AB60, 0x14052FF40};
WEAK symbol<void(int controllerIndex, const char* server, MapPreload preload, bool savegame)> SV_SpawnServer{
0x1422528C0, 0x140535B20
};
WEAK symbol<void(const char* text_in)> SV_Cmd_TokenizeString{0x1420EF130, 0x1404FA6C0};
WEAK symbol<void()> SV_Cmd_EndTokenizedString{0x1420EF0E0, 0x1404FA670};
// Utils
WEAK symbol<const char*(char* str)> I_CleanStr{0x1422E9050, 0x140580E80};