mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-07-03 01:31:53 +00:00
Compare commits
1 Commits
0cd113b33f
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
3f48155510 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -29,6 +29,3 @@
|
|||||||
[submodule "deps/SQLiteCpp"]
|
[submodule "deps/SQLiteCpp"]
|
||||||
path = deps/SQLiteCpp
|
path = deps/SQLiteCpp
|
||||||
url = https://github.com/SRombauts/SQLiteCpp
|
url = https://github.com/SRombauts/SQLiteCpp
|
||||||
[submodule "deps/plutonium-sdk"]
|
|
||||||
path = deps/plutonium-sdk
|
|
||||||
url = https://github.com/plutoniummod/plutonium-sdk.git
|
|
||||||
|
12
README.md
12
README.md
@ -9,9 +9,6 @@ Detours and reimplements the entire GSC VM + compiler.
|
|||||||
|
|
||||||
Adds custom GSC functions.
|
Adds custom GSC functions.
|
||||||
|
|
||||||
# Installation
|
|
||||||
Move the `t4sp-server-plugin.dll` to `%LOCALAPPDATA%\Plutonium\plugins\`, the plugin will be loaded when you start up a dedicated server for Plutonium T4SP.
|
|
||||||
|
|
||||||
## FileIO
|
## FileIO
|
||||||
This plugin provides FileIO interface to GSC for reading and writing files, this is exact to [CoD4x's](https://github.com/callofduty4x/CoD4x_Server/blob/master/scriptdocumentation/script_functions_reference.md#file-operations) interface.
|
This plugin provides FileIO interface to GSC for reading and writing files, this is exact to [CoD4x's](https://github.com/callofduty4x/CoD4x_Server/blob/master/scriptdocumentation/script_functions_reference.md#file-operations) interface.
|
||||||
|
|
||||||
@ -20,7 +17,7 @@ However, all reads and writes will take place strictly and only in the `scriptda
|
|||||||
All files will be closed upon GSC restart (map_restart or fast_restart or missionfailed, etc), only a maximum of 10 files may be opened at once.
|
All files will be closed upon GSC restart (map_restart or fast_restart or missionfailed, etc), only a maximum of 10 files may be opened at once.
|
||||||
|
|
||||||
* `<bool> FS_TestFile(<filename string>)` Returns `true` if the file exists, `false` otherwise.
|
* `<bool> FS_TestFile(<filename string>)` Returns `true` if the file exists, `false` otherwise.
|
||||||
* `<bool> FS_Remove(<filename string>, <(optional) use_global bool>)` Deletes the file, return `true` if successful, `false` otherwise. `use_global` will use non mod specific folder.
|
* `<bool> FS_Remove(<filename string>)` Deletes the file, return `true` if successful, `false` otherwise.
|
||||||
```gsc
|
```gsc
|
||||||
// test to see if "scriptdata/test.txt" file exists
|
// test to see if "scriptdata/test.txt" file exists
|
||||||
if (FS_TestFile("test.txt")) // not a typo, all file io will take place inside the "scriptdata" folder
|
if (FS_TestFile("test.txt")) // not a typo, all file io will take place inside the "scriptdata" folder
|
||||||
@ -42,7 +39,7 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio
|
|||||||
FS_FCloseAll(); // close them all
|
FS_FCloseAll(); // close them all
|
||||||
```
|
```
|
||||||
|
|
||||||
* `<int> FS_FOpen(<filename string>, <mode string>, <(optional) use_global bool>)` Tries to open the file, mode must be one of `read`, `write` (clears the file), `append` (appends to the file), returns the filehandle. Will return `0` if failed to open. `use_global` will use non mod specific folder (only applies to `write` mode).
|
* `<int> FS_FOpen(<filename string>, <mode string>)` Tries to open the file, mode must be one of `read`, `write` (clears the file), `append` (appends to the file), returns the filehandle. Will return `0` if failed to open.
|
||||||
* `FS_FClose(<filehandle int>)` Closes the file pointed by the filehandle given, which was returned from `FS_FOpen`.
|
* `FS_FClose(<filehandle int>)` Closes the file pointed by the filehandle given, which was returned from `FS_FOpen`.
|
||||||
```gsc
|
```gsc
|
||||||
// opens "scriptdata/test.txt", all io will take place inside the "scriptdata" folder
|
// opens "scriptdata/test.txt", all io will take place inside the "scriptdata" folder
|
||||||
@ -106,9 +103,8 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `<int> FS_Length(<filehandle int>)` Returns the length in bytes of the open'd file.
|
# Installation
|
||||||
* `<int> FS_GetSeek(<filehandle int>)` Returns the seek of the open'd file (only for reading).
|
Move the `t4sp-server-plugin.dll` to `%LOCALAPPDATA%\Plutonium\storage\t4\plugins\`, the plugin will be loaded when you start up a dedicated server for Plutonium T4SP.
|
||||||
* `<int> FS_Seek(<filehandle int>, <seek int>)` Sets the seek of the open'd file (only for reading).
|
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
- momo5502 (https://github.com/momo5502)
|
- momo5502 (https://github.com/momo5502)
|
||||||
|
2
deps/curl
vendored
2
deps/curl
vendored
Submodule deps/curl updated: 78a1814b33...1356028f2c
1
deps/plutonium-sdk
vendored
1
deps/plutonium-sdk
vendored
Submodule deps/plutonium-sdk deleted from 17e9a0a4d5
18
deps/premake/plutonium-sdk.lua
vendored
18
deps/premake/plutonium-sdk.lua
vendored
@ -1,18 +0,0 @@
|
|||||||
plutonium_sdk = {
|
|
||||||
source = path.join(dependencies.basePath, "plutonium-sdk"),
|
|
||||||
}
|
|
||||||
|
|
||||||
function plutonium_sdk.import()
|
|
||||||
plutonium_sdk.includes()
|
|
||||||
end
|
|
||||||
|
|
||||||
function plutonium_sdk.includes()
|
|
||||||
includedirs {
|
|
||||||
plutonium_sdk.source,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function plutonium_sdk.project()
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(dependencies, plutonium_sdk)
|
|
@ -34,16 +34,15 @@ namespace fileio
|
|||||||
|
|
||||||
bool validate_scr_path(const std::string& fpath)
|
bool validate_scr_path(const std::string& fpath)
|
||||||
{
|
{
|
||||||
auto toks = utils::string::split(fpath, '/');
|
if (fpath.empty())
|
||||||
|
|
||||||
for (const auto& tok : toks)
|
|
||||||
{
|
{
|
||||||
if (tok == "." || tok == "..")
|
return true;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok.find(":") != std::string::npos)
|
constexpr static std::array bad_strings { R"(..)", R"(../)", R"(..\)" };
|
||||||
|
for (auto i = 0u; i < bad_strings.size(); i++)
|
||||||
|
{
|
||||||
|
if (fpath.find(bad_strings[i]) != std::string::npos)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -52,21 +51,17 @@ namespace fileio
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string build_base_path(const std::string& path_)
|
std::string build_base_path(const std::string& path)
|
||||||
{
|
{
|
||||||
auto path = path_;
|
|
||||||
std::replace(path.begin(), path.end(), '\\', '/');
|
|
||||||
|
|
||||||
if (!validate_scr_path(path))
|
if (!validate_scr_path(path))
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, utils::string::va("Invalid path: %s", path_.c_str()));
|
game::Scr_Error(utils::string::va("Invalid path: %s", path.c_str()), game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// its sandboxed, but what about symlinks?
|
|
||||||
return path.starts_with("scriptdata/") ? path : "scriptdata/" + path;
|
return path.starts_with("scriptdata/") ? path : "scriptdata/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path build_full_path(const std::string& path, bool use_global)
|
std::filesystem::path build_full_path(const std::string& path)
|
||||||
{
|
{
|
||||||
static game::dvar_s* fs_localAppData = nullptr;
|
static game::dvar_s* fs_localAppData = nullptr;
|
||||||
static game::dvar_s* fs_gamedir = nullptr;
|
static game::dvar_s* fs_gamedir = nullptr;
|
||||||
@ -81,7 +76,7 @@ namespace fileio
|
|||||||
fs_gamedir = game::Dvar_FindVar("fs_game");
|
fs_gamedir = game::Dvar_FindVar("fs_game");
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::filesystem::path(fs_localAppData->current.string) / (!use_global && *fs_gamedir->current.string ? fs_gamedir->current.string : "raw") / path;
|
return std::filesystem::path(fs_localAppData->current.string) / (*fs_gamedir->current.string ? fs_gamedir->current.string : "raw") / path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_scr_fh(scr_fh_t& scr_fh)
|
void free_scr_fh(scr_fh_t& scr_fh)
|
||||||
@ -107,25 +102,18 @@ namespace fileio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int scr_get_fh()
|
void fwrite_to_file(bool append_newline)
|
||||||
{
|
{
|
||||||
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
|
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
|
||||||
|
|
||||||
if (fh < 0 || fh >= max_fhs)
|
if (fh < 0 || fh >= max_fhs)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "fs_fwrite: invalid filehandle");
|
game::Scr_Error("fs_fwrite: invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void fwrite_to_file(bool append_newline)
|
|
||||||
{
|
|
||||||
auto fh = scr_get_fh();
|
|
||||||
|
|
||||||
if (scr_fhs[fh].type != scr_fh_type_e::WRITE && scr_fhs[fh].type != scr_fh_type_e::APPEND)
|
if (scr_fhs[fh].type != scr_fh_type_e::WRITE && scr_fhs[fh].type != scr_fh_type_e::APPEND)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File not opened for writing");
|
game::Scr_Error("File not opened for writing", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string to_write = game::Scr_GetString(1, game::SCRIPTINSTANCE_SERVER);
|
std::string to_write = game::Scr_GetString(1, game::SCRIPTINSTANCE_SERVER);
|
||||||
@ -182,7 +170,7 @@ namespace fileio
|
|||||||
{
|
{
|
||||||
if (scr_fd.type != scr_fh_type_e::UNUSED && scr_fd.base_path == fpath)
|
if (scr_fd.type != scr_fh_type_e::UNUSED && scr_fd.base_path == fpath)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File already opened");
|
game::Scr_Error("File already opened", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +186,7 @@ namespace fileio
|
|||||||
|
|
||||||
if (i >= max_fhs)
|
if (i >= max_fhs)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "Too many files opened");
|
game::Scr_Error("Too many files opened", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check mode
|
// check mode
|
||||||
@ -237,7 +225,7 @@ namespace fileio
|
|||||||
}
|
}
|
||||||
else if (mode == "write"s || mode == "append"s)
|
else if (mode == "write"s || mode == "append"s)
|
||||||
{
|
{
|
||||||
auto full_path = build_full_path(fpath, game::Scr_GetNumParam(game::SCRIPTINSTANCE_SERVER) >= 3 && game::Scr_GetType(game::SCRIPTINSTANCE_SERVER, 2) == game::VAR_INTEGER && game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 2));
|
auto full_path = build_full_path(fpath);
|
||||||
|
|
||||||
if (!utils::io::write_file(full_path.string(), "", (mode == "append"s)))
|
if (!utils::io::write_file(full_path.string(), "", (mode == "append"s)))
|
||||||
{
|
{
|
||||||
@ -252,7 +240,7 @@ namespace fileio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(1, game::SCRIPTINSTANCE_SERVER, utils::string::va("Invalid mode: %s", mode));
|
game::Scr_Error(utils::string::va("Invalid mode: %s", mode), game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -273,11 +261,16 @@ namespace fileio
|
|||||||
|
|
||||||
gsc::function::add("fs_readline", []()
|
gsc::function::add("fs_readline", []()
|
||||||
{
|
{
|
||||||
auto fh = scr_get_fh();
|
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
|
||||||
|
|
||||||
|
if (fh < 0 || fh >= max_fhs)
|
||||||
|
{
|
||||||
|
game::Scr_Error("Invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (scr_fhs[fh].type != scr_fh_type_e::READ)
|
if (scr_fhs[fh].type != scr_fh_type_e::READ)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File not opened for reading");
|
game::Scr_Error("File not opened for reading", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// file is completed being read
|
// file is completed being read
|
||||||
@ -326,11 +319,16 @@ namespace fileio
|
|||||||
|
|
||||||
gsc::function::add("fs_read", []()
|
gsc::function::add("fs_read", []()
|
||||||
{
|
{
|
||||||
auto fh = scr_get_fh();
|
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
|
||||||
|
|
||||||
|
if (fh < 0 || fh >= max_fhs)
|
||||||
|
{
|
||||||
|
game::Scr_Error("Invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (scr_fhs[fh].type != scr_fh_type_e::READ)
|
if (scr_fhs[fh].type != scr_fh_type_e::READ)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File not opened for reading");
|
game::Scr_Error("File not opened for reading", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// file is completed being read
|
// file is completed being read
|
||||||
@ -347,7 +345,7 @@ namespace fileio
|
|||||||
|
|
||||||
if (bytes_to_read <= 0)
|
if (bytes_to_read <= 0)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(1, game::SCRIPTINSTANCE_SERVER, "Trying to read <1 bytes");
|
game::Scr_Error("Trying to read <1 bytes", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,11 +370,16 @@ namespace fileio
|
|||||||
|
|
||||||
gsc::function::add("fs_fclose", []()
|
gsc::function::add("fs_fclose", []()
|
||||||
{
|
{
|
||||||
auto fh = scr_get_fh();
|
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
|
||||||
|
|
||||||
|
if (fh < 0 || fh >= max_fhs)
|
||||||
|
{
|
||||||
|
game::Scr_Error("Invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (scr_fhs[fh].type == scr_fh_type_e::UNUSED)
|
if (scr_fhs[fh].type == scr_fh_type_e::UNUSED)
|
||||||
{
|
{
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File not opened");
|
game::Scr_Error("File not opened", game::SCRIPTINSTANCE_SERVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_scr_fh(scr_fhs[fh]);
|
free_scr_fh(scr_fhs[fh]);
|
||||||
@ -384,48 +387,10 @@ namespace fileio
|
|||||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
|
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
gsc::function::add("fs_length", []()
|
|
||||||
{
|
|
||||||
auto fh = scr_get_fh();
|
|
||||||
|
|
||||||
if (scr_fhs[fh].type == scr_fh_type_e::UNUSED)
|
|
||||||
{
|
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File not opened");
|
|
||||||
}
|
|
||||||
|
|
||||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, scr_fhs[fh].file_length);
|
|
||||||
});
|
|
||||||
|
|
||||||
gsc::function::add("fs_getseek", []()
|
|
||||||
{
|
|
||||||
auto fh = scr_get_fh();
|
|
||||||
|
|
||||||
// write seek would require completely redoing how we write files...
|
|
||||||
if (scr_fhs[fh].type != scr_fh_type_e::READ)
|
|
||||||
{
|
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File not opened for reading");
|
|
||||||
}
|
|
||||||
|
|
||||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, scr_fhs[fh].seek);
|
|
||||||
});
|
|
||||||
|
|
||||||
gsc::function::add("fs_seek", []()
|
|
||||||
{
|
|
||||||
auto fh = scr_get_fh();
|
|
||||||
|
|
||||||
if (scr_fhs[fh].type != scr_fh_type_e::READ)
|
|
||||||
{
|
|
||||||
game::Scr_ParamError(0, game::SCRIPTINSTANCE_SERVER, "File not opened for reading");
|
|
||||||
}
|
|
||||||
|
|
||||||
scr_fhs[fh].seek = std::clamp(game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 1), 0, scr_fhs[fh].file_length);
|
|
||||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
gsc::function::add("fs_remove", []()
|
gsc::function::add("fs_remove", []()
|
||||||
{
|
{
|
||||||
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
|
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
|
||||||
auto full_path = build_full_path(fpath, game::Scr_GetNumParam(game::SCRIPTINSTANCE_SERVER) >= 2 && game::Scr_GetType(game::SCRIPTINSTANCE_SERVER, 1) == game::VAR_INTEGER && game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 1));
|
auto full_path = build_full_path(fpath);
|
||||||
|
|
||||||
if (!utils::io::remove_file(full_path.string()))
|
if (!utils::io::remove_file(full_path.string()))
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,40 @@
|
|||||||
#include <stdinc.hpp>
|
#include <stdinc.hpp>
|
||||||
|
#include "loader/component_loader.hpp"
|
||||||
|
#include "component/signatures.hpp"
|
||||||
|
|
||||||
PLUTONIUM_API plutonium::sdk::plugin* PLUTONIUM_CALLBACK on_initialize()
|
#include <utils/hook.hpp>
|
||||||
{
|
|
||||||
return plugin::get();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD ul_reason_for_call, LPVOID /*reserved_*/)
|
BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD ul_reason_for_call, LPVOID /*reserved_*/)
|
||||||
{
|
{
|
||||||
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||||
|
{
|
||||||
|
if (game::environment::t4sp())
|
||||||
|
{
|
||||||
|
if (!signatures::process())
|
||||||
|
{
|
||||||
|
MessageBoxA(NULL,
|
||||||
|
std::format("This version of t4sp-server-plugin is outdated.\n" \
|
||||||
|
"Download the latest dll from here: https://github.com/JezuzLizard/T4SP-Server-Plugin/releases\n" \
|
||||||
|
"'{}' failed", signatures::get_err_reason()).c_str(),
|
||||||
|
"ERROR", MB_ICONERROR);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (game::plutonium::printf.get() != nullptr)
|
||||||
|
{
|
||||||
|
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), game::plutonium::printf);
|
||||||
|
}
|
||||||
|
|
||||||
|
component_loader::post_unpack();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBoxA(nullptr, "Unsupported game executable. (t4sp is only supported)", "ERROR, BRO!", 0);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
@ -1,73 +0,0 @@
|
|||||||
#include <stdinc.hpp>
|
|
||||||
#include "component/signatures.hpp"
|
|
||||||
|
|
||||||
#include <utils/hook.hpp>
|
|
||||||
#include "loader/component_loader.hpp"
|
|
||||||
|
|
||||||
namespace plugin
|
|
||||||
{
|
|
||||||
std::uint32_t plugin::plugin_version()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* plugin::plugin_name()
|
|
||||||
{
|
|
||||||
return "t4sp-server-plugin";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool plugin::is_game_supported(plutonium::sdk::game game)
|
|
||||||
{
|
|
||||||
return game == plutonium::sdk::game::t4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void plugin::on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game)
|
|
||||||
{
|
|
||||||
this->interface_ = interface_ptr;
|
|
||||||
this->game_ = game;
|
|
||||||
|
|
||||||
if (!game::environment::t4sp())
|
|
||||||
{
|
|
||||||
MessageBoxA(nullptr, "Unsupported game executable. (t4sp is only supported)", "ERROR, BRO!", 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!signatures::process())
|
|
||||||
{
|
|
||||||
MessageBoxA(NULL,
|
|
||||||
std::format("This version of t4sp-server-plugin is outdated.\n" \
|
|
||||||
"Download the latest dll from here: https://github.com/JezuzLizard/T4SP-Server-Plugin/releases\n" \
|
|
||||||
"'{}' failed", signatures::get_err_reason()).c_str(),
|
|
||||||
"ERROR", MB_ICONERROR);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game::plutonium::printf.get() != nullptr)
|
|
||||||
{
|
|
||||||
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), game::plutonium::printf);
|
|
||||||
}
|
|
||||||
|
|
||||||
component_loader::post_unpack();
|
|
||||||
}
|
|
||||||
|
|
||||||
void plugin::on_shutdown()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
plutonium::sdk::iinterface* plugin::get_interface()
|
|
||||||
{
|
|
||||||
return this->interface_;
|
|
||||||
}
|
|
||||||
|
|
||||||
plutonium::sdk::game plugin::get_game()
|
|
||||||
{
|
|
||||||
return this->game_;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin* get()
|
|
||||||
{
|
|
||||||
static plugin instance;
|
|
||||||
return &instance;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <plutonium_sdk.hpp>
|
|
||||||
|
|
||||||
namespace plugin
|
|
||||||
{
|
|
||||||
class plugin : public plutonium::sdk::plugin
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
~plugin() = default;
|
|
||||||
|
|
||||||
std::uint32_t plugin_version() override;
|
|
||||||
const char* plugin_name() override;
|
|
||||||
|
|
||||||
bool is_game_supported(plutonium::sdk::game game) override;
|
|
||||||
|
|
||||||
void on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game) override;
|
|
||||||
void on_shutdown() override;
|
|
||||||
|
|
||||||
plutonium::sdk::iinterface* get_interface();
|
|
||||||
plutonium::sdk::game get_game();
|
|
||||||
|
|
||||||
private:
|
|
||||||
plutonium::sdk::iinterface* interface_{};
|
|
||||||
plutonium::sdk::game game_{};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
plugin* get();
|
|
||||||
}
|
|
@ -71,8 +71,6 @@
|
|||||||
#include "game/structs.hpp"
|
#include "game/structs.hpp"
|
||||||
#include "game/symbols.hpp"
|
#include "game/symbols.hpp"
|
||||||
|
|
||||||
#include "plugin.hpp"
|
|
||||||
|
|
||||||
std::string build_gsc_dump(game::scriptInstance_t inst);
|
std::string build_gsc_dump(game::scriptInstance_t inst);
|
||||||
void push_opcode_history(game::scriptInstance_t inst, game::OpcodeVM op);
|
void push_opcode_history(game::scriptInstance_t inst, game::OpcodeVM op);
|
||||||
void push_builtin_history(game::scriptInstance_t inst, int idx);
|
void push_builtin_history(game::scriptInstance_t inst, int idx);
|
||||||
|
Reference in New Issue
Block a user