Refactor sp commands

This commit is contained in:
FutureRave 2022-05-13 10:59:11 +01:00
parent 52d0326562
commit b14d21d9a1
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
3 changed files with 12 additions and 5 deletions

View File

@ -122,6 +122,8 @@ namespace game
namespace sp
{
sp::IsServerRunning_t IsServerRunning;
sp::gentity_s* g_entities;
}
@ -732,6 +734,8 @@ namespace game
native::Sys_IsServerThread = native::Sys_IsServerThread_t(SELECT_VALUE(0x4CC5A0, 0x55F9A0, 0x0));
native::sp::IsServerRunning = native::sp::IsServerRunning_t(0x45D310);
native::XUIDToString = native::XUIDToString_t(SELECT_VALUE(0x4FAA30, 0x55CC20, 0x0));
native::SEH_LocalizeTextMessage = native::SEH_LocalizeTextMessage_t(

View File

@ -184,6 +184,9 @@ namespace game
namespace sp
{
typedef bool (*IsServerRunning_t)();
extern IsServerRunning_t IsServerRunning;
extern sp::gentity_s* g_entities;
}

View File

@ -235,7 +235,7 @@ void command::add_sp_commands()
{
add("noclip", []()
{
if (!game::native::Dvar_FindVar("sv_running")->current.enabled)
if (!game::native::sp::IsServerRunning())
return;
const auto* ent = &game::native::sp::g_entities[0];
@ -253,7 +253,7 @@ void command::add_sp_commands()
add("ufo", []()
{
if (!game::native::Dvar_FindVar("sv_running")->current.enabled)
if (!game::native::sp::IsServerRunning())
return;
const auto* ent = &game::native::sp::g_entities[0];
@ -271,7 +271,7 @@ void command::add_sp_commands()
add("god", []()
{
if (!game::native::Dvar_FindVar("sv_running")->current.enabled)
if (!game::native::sp::IsServerRunning())
return;
auto* ent = &game::native::sp::g_entities[0];
@ -289,7 +289,7 @@ void command::add_sp_commands()
add("demigod", []()
{
if (!game::native::Dvar_FindVar("sv_running")->current.enabled)
if (!game::native::sp::IsServerRunning())
return;
auto* ent = &game::native::sp::g_entities[0];
@ -307,7 +307,7 @@ void command::add_sp_commands()
add("notarget", []()
{
if (!game::native::Dvar_FindVar("sv_running")->current.enabled)
if (!game::native::sp::IsServerRunning())
return;
auto* ent = &game::native::sp::g_entities[0];