Merge pull request #48 from Joelrau/some-changes

Some changes
This commit is contained in:
Dss0 2020-12-04 22:39:06 +01:00 committed by GitHub
commit 5f221e77cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 12 deletions

View File

@ -160,6 +160,10 @@ namespace Components
{
AssertSize(Game::cmd_function_t, 24);
static int toastDurationShort = 1000;
static int toastDurationMedium = 2500;
static int toastDurationLong = 5000;
// Disable native noclip command
Utils::Hook::Nop(0x474846, 5);
@ -169,21 +173,21 @@ namespace Components
if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client)
{
Logger::Print("You are not hosting a match!\n");
Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", 3000);
Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", toastDurationMedium);
return;
}
if (!Dvar::Var("sv_cheats").get<bool>())
{
Logger::Print("Cheats disabled!\n");
Toast::Show("cardicon_stop", "Error", "Cheats disabled!", 3000);
Toast::Show("cardicon_stop", "Error", "Cheats disabled!", toastDurationMedium);
return;
}
Game::g_entities[clientNum].client->flags ^= Game::PLAYER_FLAG_NOCLIP;
Logger::Print("Noclip toggled\n");
Toast::Show("cardicon_abduction", "Success", "Noclip toggled", 3000);
Toast::Show("cardicon_abduction", "Success", "Noclip toggled", toastDurationShort);
});
Command::Add("ufo", [](Command::Params*)
@ -192,21 +196,21 @@ namespace Components
if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client)
{
Logger::Print("You are not hosting a match!\n");
Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", 3000);
Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", toastDurationMedium);
return;
}
if (!Dvar::Var("sv_cheats").get<bool>())
{
Logger::Print("Cheats disabled!\n");
Toast::Show("cardicon_stop", "Error", "Cheats disabled!", 3000);
Toast::Show("cardicon_stop", "Error", "Cheats disabled!", toastDurationMedium);
return;
}
Game::g_entities[clientNum].client->flags ^= Game::PLAYER_FLAG_UFO;
Logger::Print("UFO toggled\n");
Toast::Show("cardicon_abduction", "Success", "UFO toggled", 3000);
Toast::Show("cardicon_abduction", "Success", "UFO toggled", toastDurationShort);
});
Command::Add("setviewpos", [](Command::Params* params)
@ -215,21 +219,21 @@ namespace Components
if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client)
{
Logger::Print("You are not hosting a match!\n");
Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", 3000);
Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", toastDurationMedium);
return;
}
if (!Dvar::Var("sv_cheats").get<bool>())
{
Logger::Print("Cheats disabled!\n");
Toast::Show("cardicon_stop", "Error", "Cheats disabled!", 3000);
Toast::Show("cardicon_stop", "Error", "Cheats disabled!", toastDurationMedium);
return;
}
if (params->length() != 4 && params->length() != 6)
{
Logger::Print("Invalid coordinate specified!\n");
Toast::Show("cardicon_stop", "Error", "Invalid coordinate specified!", 3000);
Toast::Show("cardicon_stop", "Error", "Invalid coordinate specified!", toastDurationMedium);
return;
}
@ -250,7 +254,7 @@ namespace Components
// Logging that will spam the console and screen if people use cinematics
//Logger::Print("Successfully teleported player!\n");
//Toast::Show("cardicon_abduction", "Success", "You have been teleported!", 3000);
//Toast::Show("cardicon_abduction", "Success", "You have been teleported!", toastDurationShort);
});
Command::Add("openLink", [](Command::Params* params)

View File

@ -169,7 +169,7 @@ namespace Components
{
if (Dedicated::IsEnabled() && Dvar::Var("sv_lanOnly").get<bool>()) return;
if (!Dedicated::IsEnabled() && Game::CL_IsCgameInitialized())
if (!Dedicated::IsEnabled() && *Game::clcState > 0)
{
wasIngame = true;
return; // don't run while ingame because it can still cause lag spikes on lower end PCs

View File

@ -411,6 +411,8 @@ namespace Game
ScriptContainer* scriptContainer = reinterpret_cast<ScriptContainer*>(0x2040D00);
clientstate_t* clcState = reinterpret_cast<clientstate_t*>(0xB2C540);
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
{
int elSize = DB_GetXAssetSizeHandlers[type]();

View File

@ -840,6 +840,8 @@ namespace Game
extern ScriptContainer* scriptContainer;
extern clientstate_t* clcState;
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
void Menu_FreeItemMemory(Game::itemDef_s* item);
const char* TableLookup(StringTable* stringtable, int row, int column);

View File

@ -121,6 +121,16 @@ namespace Game
DVAR_TYPE_COUNT = 0xA,
} dvar_type;
typedef enum
{
CS_FREE = 0x0,
CS_UNKNOWN1 = 0x1,
CS_UNKNOWN2 = 0x2,
CS_CONNECTED = 0x3,
CS_CLIENTLOADING = 0x4,
CS_ACTIVE = 0x5,
} clientstate_t;
struct FxEffectDef;
struct pathnode_t;
struct pathnode_tree_t;
@ -4469,7 +4479,7 @@ namespace Game
typedef struct client_s
{
// 0
int state;
clientstate_t state;
// 4
char pad[36];
// 40