[Script]: IW3 compiler behaviour (#880)
This commit is contained in:
parent
6224728d4b
commit
6006c58c86
@ -179,7 +179,7 @@ namespace Components
|
||||
{
|
||||
GSC::Script::AddMethMultiple(GScr_isTestClient, false, {"IsTestClient", "IsBot"}); // Usage: self IsTestClient();
|
||||
|
||||
GSC::Script::AddMethod("BotStop", [](Game::scr_entref_t entref) // Usage: <bot> BotStop();
|
||||
GSC::Script::AddMethod("BotStop", [](const Game::scr_entref_t entref) // Usage: <bot> BotStop();
|
||||
{
|
||||
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||
if (!Game::SV_IsTestClient(ent->s.number))
|
||||
@ -193,7 +193,7 @@ namespace Components
|
||||
g_botai[entref.entnum].active = true;
|
||||
});
|
||||
|
||||
GSC::Script::AddMethod("BotWeapon", [](Game::scr_entref_t entref) // Usage: <bot> BotWeapon(<str>);
|
||||
GSC::Script::AddMethod("BotWeapon", [](const Game::scr_entref_t entref) // Usage: <bot> BotWeapon(<str>);
|
||||
{
|
||||
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||
if (!Game::SV_IsTestClient(ent->s.number))
|
||||
@ -214,7 +214,7 @@ namespace Components
|
||||
g_botai[entref.entnum].active = true;
|
||||
});
|
||||
|
||||
GSC::Script::AddMethod("BotAction", [](Game::scr_entref_t entref) // Usage: <bot> BotAction(<str action>);
|
||||
GSC::Script::AddMethod("BotAction", [](const Game::scr_entref_t entref) // Usage: <bot> BotAction(<str action>);
|
||||
{
|
||||
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||
if (!Game::SV_IsTestClient(ent->s.number))
|
||||
@ -253,7 +253,7 @@ namespace Components
|
||||
Game::Scr_ParamError(0, "BotAction: Unknown action");
|
||||
});
|
||||
|
||||
GSC::Script::AddMethod("BotMovement", [](Game::scr_entref_t entref) // Usage: <bot> BotMovement(<int>, <int>);
|
||||
GSC::Script::AddMethod("BotMovement", [](const Game::scr_entref_t entref) // Usage: <bot> BotMovement(<int>, <int>);
|
||||
{
|
||||
const auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||
if (!Game::SV_IsTestClient(ent->s.number))
|
||||
|
@ -61,31 +61,8 @@ namespace Components
|
||||
|
||||
void ClientCommand::AddCheatCommands()
|
||||
{
|
||||
Add("noclip", [](Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||
{
|
||||
if (!CheatsOk(ent))
|
||||
return;
|
||||
|
||||
ent->client->flags ^= Game::PF_NOCLIP;
|
||||
|
||||
const auto entNum = ent->s.number;
|
||||
Logger::Debug("Noclip toggled for entity {}", entNum);
|
||||
|
||||
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
|
||||
});
|
||||
|
||||
Add("ufo", [](Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||
{
|
||||
if (!CheatsOk(ent))
|
||||
return;
|
||||
|
||||
ent->client->flags ^= Game::PF_UFO;
|
||||
|
||||
const auto entNum = ent->s.number;
|
||||
Logger::Debug("UFO toggled for entity {}", entNum);
|
||||
|
||||
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
|
||||
});
|
||||
Add("noclip", Cmd_Noclip_f);
|
||||
Add("ufo", Cmd_UFO_f);
|
||||
|
||||
Add("god", [](Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||
{
|
||||
@ -369,6 +346,21 @@ namespace Components
|
||||
});
|
||||
}
|
||||
|
||||
void ClientCommand::AddScriptMethods()
|
||||
{
|
||||
GSC::Script::AddMethod("Noclip", [](const Game::scr_entref_t entref) // gsc: self Noclip();
|
||||
{
|
||||
auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||
Cmd_Noclip_f(ent, nullptr);
|
||||
});
|
||||
|
||||
GSC::Script::AddMethod("Ufo", [](const Game::scr_entref_t entref) // gsc: self Ufo();
|
||||
{
|
||||
auto* ent = GSC::Script::Scr_GetPlayerEntity(entref);
|
||||
Cmd_UFO_f(ent, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
const char* ClientCommand::EntInfoLine(const int entNum)
|
||||
{
|
||||
const auto* ent = &Game::g_entities[entNum];
|
||||
@ -477,6 +469,32 @@ namespace Components
|
||||
Logger::Print(Game::CON_CHANNEL_SERVER, "Done writing file.\n");
|
||||
}
|
||||
|
||||
void ClientCommand::Cmd_Noclip_f(Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||
{
|
||||
if (!CheatsOk(ent))
|
||||
return;
|
||||
|
||||
ent->client->flags ^= Game::PF_NOCLIP;
|
||||
|
||||
const auto entNum = ent->s.number;
|
||||
Logger::Debug("Noclip toggled for entity {}", entNum);
|
||||
|
||||
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
|
||||
}
|
||||
|
||||
void ClientCommand::Cmd_UFO_f(Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||
{
|
||||
if (!CheatsOk(ent))
|
||||
return;
|
||||
|
||||
ent->client->flags ^= Game::PF_UFO;
|
||||
|
||||
const auto entNum = ent->s.number;
|
||||
Logger::Debug("UFO toggled for entity {}", entNum);
|
||||
|
||||
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
|
||||
}
|
||||
|
||||
ClientCommand::ClientCommand()
|
||||
{
|
||||
AssertOffset(Game::playerState_s, stats, 0x150);
|
||||
@ -486,6 +504,7 @@ namespace Components
|
||||
|
||||
AddCheatCommands();
|
||||
AddScriptFunctions();
|
||||
AddScriptMethods();
|
||||
#ifdef _DEBUG
|
||||
AddDevelopmentCommands();
|
||||
#endif
|
||||
|
@ -16,10 +16,15 @@ namespace Components
|
||||
static void ClientCommandStub(int clientNum);
|
||||
static void AddCheatCommands();
|
||||
static void AddDevelopmentCommands();
|
||||
|
||||
static void AddScriptFunctions();
|
||||
static void AddScriptMethods();
|
||||
|
||||
static const char* EntInfoLine(int entNum);
|
||||
static void G_DumpEntityDebugInfoToConsole(bool logfileOnly);
|
||||
static void G_DumpEntityDebugInfoToCSV(const char* filenameSuffix);
|
||||
|
||||
static void Cmd_Noclip_f(Game::gentity_s* ent, const Command::ServerParams* params);
|
||||
static void Cmd_UFO_f(Game::gentity_s* ent, const Command::ServerParams* params);
|
||||
};
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include <mongoose.h>
|
||||
|
||||
#define MG_OVERRIDE_LOG_FN
|
||||
|
||||
namespace Components
|
||||
{
|
||||
static mg_mgr Mgr;
|
||||
@ -689,7 +691,10 @@ namespace Components
|
||||
mg_log_set(MG_LL_ERROR);
|
||||
#endif
|
||||
|
||||
#ifdef MG_OVERRIDE_LOG_FN
|
||||
mg_log_set_fn(LogFn, nullptr);
|
||||
#endif
|
||||
|
||||
mg_mgr_init(&Mgr);
|
||||
|
||||
Network::OnStart([]
|
||||
|
@ -284,5 +284,10 @@ namespace Components::GSC
|
||||
Utils::Hook(0x4EC8DD, BuiltIn_GetMethodStub, HOOK_CALL).install()->quick(); // Scr_GetMethod
|
||||
|
||||
Utils::Hook(0x5F41A3, SetExpFogStub, HOOK_CALL).install()->quick();
|
||||
|
||||
// Restore IW3's compiler behaviour when dealing with 'overriding builtin function'
|
||||
Utils::Hook::Nop(0x613EDA, 2);
|
||||
Utils::Hook::Nop(0x613EF0, 2);
|
||||
Utils::Hook::Set<std::uint8_t>(0x613EF9, 0xEB);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ namespace Components::GSC
|
||||
});
|
||||
|
||||
// Func present on IW5
|
||||
Script::AddFunction("CastFloat", [] // gsc: CastFloat()
|
||||
Script::AddFunction("Float", [] // gsc: Float()
|
||||
{
|
||||
switch (Game::Scr_GetType(0))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user