Add addCommand function

This commit is contained in:
Federico Cecchetto
2021-06-17 16:31:35 +02:00
parent 4185224323
commit ee109d622a
11 changed files with 219 additions and 52 deletions

View File

@ -140,6 +140,7 @@ namespace scripting
{
const auto id = entity.get_entity_id();
stack_isolation _;
for (auto i = arguments.rbegin(); i != arguments.rend(); ++i)
{
push_value(*i);
@ -149,16 +150,9 @@ namespace scripting
const auto local_id = game::AllocThread(id);
const auto result = game::VM_Execute(local_id, pos, arguments.size());
game::RemoveRefToObject(result);
const auto value = get_return_value();
game::RemoveRefToValue(game::scr_VmPub->top->type, game::scr_VmPub->top->u);
game::scr_VmPub->top->type = (game::scriptType_e)0;
--game::scr_VmPub->top;
--game::scr_VmPub->inparamcount;
return value;
return get_return_value();
}
script_value call_script_function(const entity& entity, const std::string& filename,

View File

@ -17,6 +17,15 @@ namespace game
int flags;
};
struct CmdArgs
{
int nesting;
int localClientNum[8];
int controllerIndex[8];
int argc[8];
const char** argv[8];
};
struct msg_t
{
int overflowed;

View File

@ -18,8 +18,9 @@ namespace game
WEAK symbol<const char*(int index)> ConcatArgs{0x502150};
WEAK symbol<void(int localClientNum, const char* text)> Cbuf_AddText{0x545680};
WEAK symbol<void(const char* cmdName, void(), cmd_function_t* allocedCmd)> Cmd_AddCommandInternal{0x0};
WEAK symbol<const char*(int index)> Cmd_Argv{0x0};
WEAK symbol<void(const char* cmdName, void(), cmd_function_t* allocedCmd)> Cmd_AddCommandInternal{0x545DF0};
WEAK symbol<void(const char* cmdName)> Cmd_RemoveCommand{0x545E20};
WEAK symbol<const char*(int index)> Cmd_Argv{0x467600};
WEAK symbol<const dvar_t*(const char*)> Dvar_FindVar{0x5BDCC0};
@ -60,6 +61,8 @@ namespace game
// Variables
WEAK symbol<CmdArgs> cmd_args{0x1C978D0};
WEAK symbol<int> g_script_error_level{0x20B21FC};
WEAK symbol<jmp_buf> g_script_error{0x20B4218};