fix bug
This commit is contained in:
parent
e4b135c5ff
commit
fd49ece911
@ -446,6 +446,17 @@ namespace gsc
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game::native::gentity_s* get_entity(game::native::scr_entref_t entref)
|
||||||
|
{
|
||||||
|
if (entref.classnum != 0)
|
||||||
|
{
|
||||||
|
scr_error("not an entity");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &game::native::g_entities[entref.entnum];
|
||||||
|
}
|
||||||
|
|
||||||
class error final : public module
|
class error final : public module
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -16,5 +16,7 @@ namespace gsc
|
|||||||
int scr_get_type(unsigned int index);
|
int scr_get_type(unsigned int index);
|
||||||
const char* scr_get_type_name(unsigned int index);
|
const char* scr_get_type_name(unsigned int index);
|
||||||
|
|
||||||
|
game::native::gentity_s* get_entity(game::native::scr_entref_t entref);
|
||||||
|
|
||||||
void scr_error(const char* error);
|
void scr_error(const char* error);
|
||||||
}
|
}
|
||||||
|
@ -172,8 +172,8 @@ namespace gsc
|
|||||||
}
|
}
|
||||||
|
|
||||||
++scr_func_max_id;
|
++scr_func_max_id;
|
||||||
custom_functions.push_back({ name, scr_func_max_id, func });
|
custom_functions.push_back({ lowered_name, scr_func_max_id, func });
|
||||||
cxt->func_add(name, scr_func_max_id);
|
cxt->func_add(lowered_name, scr_func_max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_method(const std::string& name, const game::native::BuiltinMethod& meth)
|
void register_method(const std::string& name, const game::native::BuiltinMethod& meth)
|
||||||
@ -192,8 +192,8 @@ namespace gsc
|
|||||||
}
|
}
|
||||||
|
|
||||||
++scr_meth_max_id;
|
++scr_meth_max_id;
|
||||||
custom_methods.push_back({ name, scr_meth_max_id, meth });
|
custom_methods.push_back({ lowered_name, scr_meth_max_id, meth });
|
||||||
cxt->meth_add(name, scr_meth_max_id);
|
cxt->meth_add(lowered_name, scr_meth_max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* get_code_pos(int index)
|
const char* get_code_pos(int index)
|
||||||
@ -253,7 +253,7 @@ namespace gsc
|
|||||||
|
|
||||||
static void add_gsc_functions()
|
static void add_gsc_functions()
|
||||||
{
|
{
|
||||||
register_function("replacefunc", []
|
register_function("ReplaceFunc", []
|
||||||
{
|
{
|
||||||
if (scr_get_type(0) != game::native::VAR_FUNCTION || scr_get_type(1) != game::native::VAR_FUNCTION)
|
if (scr_get_type(0) != game::native::VAR_FUNCTION || scr_get_type(1) != game::native::VAR_FUNCTION)
|
||||||
{
|
{
|
||||||
|
@ -3,14 +3,17 @@
|
|||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
#include "game/dvars.hpp"
|
#include "game/dvars.hpp"
|
||||||
|
|
||||||
|
#include "command.hpp"
|
||||||
|
#include "console.hpp"
|
||||||
|
#include "scheduler.hpp"
|
||||||
|
#include "test_clients.hpp"
|
||||||
|
|
||||||
|
#include "gsc/script_error.hpp"
|
||||||
|
#include "gsc/script_extension.hpp"
|
||||||
|
|
||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
#include "test_clients.hpp"
|
|
||||||
#include "command.hpp"
|
|
||||||
#include "scheduler.hpp"
|
|
||||||
#include "console.hpp"
|
|
||||||
|
|
||||||
bool test_clients::can_add()
|
bool test_clients::can_add()
|
||||||
{
|
{
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
@ -72,7 +75,7 @@ game::native::gentity_s* test_clients::sv_add_test_client()
|
|||||||
|
|
||||||
if (game::native::mp::svs_clients[idx].header.netchan.remoteAddress.type == adr.type
|
if (game::native::mp::svs_clients[idx].header.netchan.remoteAddress.type == adr.type
|
||||||
&& game::native::mp::svs_clients[idx].header.netchan.remoteAddress.port == adr.port)
|
&& game::native::mp::svs_clients[idx].header.netchan.remoteAddress.port == adr.port)
|
||||||
break; // Found them
|
break; // Found the bot
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx == *game::native::svs_clientCount)
|
if (idx == *game::native::svs_clientCount)
|
||||||
@ -228,6 +231,18 @@ void test_clients::patch_mp()
|
|||||||
|
|
||||||
// Replace nullsubbed gsc func "GScr_AddTestClient" with our spawn
|
// Replace nullsubbed gsc func "GScr_AddTestClient" with our spawn
|
||||||
utils::hook::set<void(*)()>(0x8AC8DC, gscr_add_test_client);
|
utils::hook::set<void(*)()>(0x8AC8DC, gscr_add_test_client);
|
||||||
|
|
||||||
|
gsc::register_method("IsTestClient", [](const game::native::scr_entref_t entref)
|
||||||
|
{
|
||||||
|
gsc::get_entity(entref);
|
||||||
|
|
||||||
|
if (game::native::g_entities[entref.entnum].client == nullptr)
|
||||||
|
{
|
||||||
|
gsc::scr_error("IsTestClient: entity must be a player entity");
|
||||||
|
}
|
||||||
|
|
||||||
|
game::native::Scr_AddInt(game::native::SV_IsTestClient(entref.entnum));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_MODULE(test_clients);
|
REGISTER_MODULE(test_clients);
|
||||||
|
Loading…
Reference in New Issue
Block a user