2023-05-06 16:23:56 +02:00
|
|
|
//===============================================================================//
|
|
|
|
//
|
|
|
|
// Purpose: VSquirrel VM
|
|
|
|
//
|
|
|
|
//===============================================================================//
|
|
|
|
#include "core/stdafx.h"
|
|
|
|
#include "vscript/vscript.h"
|
|
|
|
#include "pluginsystem/modsystem.h"
|
2023-05-10 00:05:38 +02:00
|
|
|
#include "vsquirrel.h"
|
2023-05-06 16:23:56 +02:00
|
|
|
|
2023-07-18 00:17:49 +02:00
|
|
|
// Callbacks for registering abstracted script functions.
|
|
|
|
void(*ServerScriptRegister_Callback)(CSquirrelVM* s) = nullptr;
|
|
|
|
void(*ClientScriptRegister_Callback)(CSquirrelVM* s) = nullptr;
|
|
|
|
void(*UiScriptRegister_Callback)(CSquirrelVM* s) = nullptr;
|
|
|
|
|
2024-03-25 01:41:52 +01:00
|
|
|
// Callbacks for registering script enums.
|
|
|
|
void(*ServerScriptRegisterEnum_Callback)(CSquirrelVM* const s) = nullptr;
|
|
|
|
void(*ClientScriptRegisterEnum_Callback)(CSquirrelVM* const s) = nullptr;
|
|
|
|
void(*UIScriptRegisterEnum_Callback)(CSquirrelVM* const s) = nullptr;
|
|
|
|
|
2023-07-19 02:12:56 +02:00
|
|
|
// Admin panel functions, NULL on client only builds.
|
|
|
|
void(*CoreServerScriptRegister_Callback)(CSquirrelVM* s) = nullptr;
|
|
|
|
void(*AdminPanelScriptRegister_Callback)(CSquirrelVM* s) = nullptr;
|
|
|
|
|
2023-07-19 18:52:00 +02:00
|
|
|
// Registering constants in scripts.
|
|
|
|
void(*ScriptConstantRegister_Callback)(CSquirrelVM* s) = nullptr;
|
|
|
|
|
2023-05-06 16:23:56 +02:00
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: Initialises a Squirrel VM instance
|
|
|
|
// Output : True on success, false on failure
|
|
|
|
//---------------------------------------------------------------------------------
|
2023-11-26 13:21:20 +01:00
|
|
|
bool CSquirrelVM::Init(CSquirrelVM* s, SQCONTEXT context, SQFloat curTime)
|
2023-05-06 16:23:56 +02:00
|
|
|
{
|
|
|
|
// original func always returns true, added check just in case.
|
2024-01-02 15:21:36 +01:00
|
|
|
if (!CSquirrelVM__Init(s, context, curTime))
|
2023-05-06 16:23:56 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg((eDLL_T)context, "Created %s VM: '0x%p'\n", s->GetVM()->_sharedstate->_contextname, s);
|
2023-05-06 16:23:56 +02:00
|
|
|
|
|
|
|
switch (context)
|
|
|
|
{
|
|
|
|
case SQCONTEXT::SERVER:
|
|
|
|
g_pServerScript = s;
|
2023-07-19 02:12:56 +02:00
|
|
|
|
2023-07-18 00:17:49 +02:00
|
|
|
if (ServerScriptRegister_Callback)
|
|
|
|
ServerScriptRegister_Callback(s);
|
|
|
|
|
2023-05-06 16:23:56 +02:00
|
|
|
break;
|
|
|
|
case SQCONTEXT::CLIENT:
|
|
|
|
g_pClientScript = s;
|
2023-07-19 02:12:56 +02:00
|
|
|
|
2023-07-18 00:17:49 +02:00
|
|
|
if (ClientScriptRegister_Callback)
|
|
|
|
ClientScriptRegister_Callback(s);
|
|
|
|
|
2023-05-06 16:23:56 +02:00
|
|
|
break;
|
|
|
|
case SQCONTEXT::UI:
|
|
|
|
g_pUIScript = s;
|
2023-07-19 02:12:56 +02:00
|
|
|
|
2023-07-18 00:17:49 +02:00
|
|
|
if (UiScriptRegister_Callback)
|
|
|
|
UiScriptRegister_Callback(s);
|
|
|
|
|
2023-07-19 02:12:56 +02:00
|
|
|
if (CoreServerScriptRegister_Callback)
|
|
|
|
CoreServerScriptRegister_Callback(s);
|
|
|
|
if (AdminPanelScriptRegister_Callback)
|
|
|
|
AdminPanelScriptRegister_Callback(s);
|
|
|
|
|
2023-05-06 16:23:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: destroys the signal entry list head
|
|
|
|
// Input : *s -
|
|
|
|
// v -
|
|
|
|
// f -
|
|
|
|
// Output : true on success, false otherwise
|
|
|
|
//---------------------------------------------------------------------------------
|
2023-11-26 13:21:20 +01:00
|
|
|
bool CSquirrelVM::DestroySignalEntryListHead(CSquirrelVM* s, HSQUIRRELVM v, SQFloat f)
|
2023-05-06 16:23:56 +02:00
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
SQBool result = CSquirrelVM__DestroySignalEntryListHead(s, v, f);
|
2023-05-06 16:23:56 +02:00
|
|
|
s->RegisterConstant("DEVELOPER", developer->GetInt());
|
2023-07-19 18:52:00 +02:00
|
|
|
|
|
|
|
// Must have one.
|
|
|
|
Assert(ScriptConstantRegister_Callback);
|
|
|
|
ScriptConstantRegister_Callback(s);
|
|
|
|
|
2023-05-06 16:23:56 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: registers a global constant
|
|
|
|
// Input : *name -
|
|
|
|
// value -
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
SQRESULT CSquirrelVM::RegisterConstant(const SQChar* name, SQInteger value)
|
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
return CSquirrelVM__RegisterConstant(this, name, value);
|
2023-05-06 16:23:56 +02:00
|
|
|
}
|
|
|
|
|
2024-04-19 13:12:35 +02:00
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: runs text as script on the VM
|
|
|
|
// Input : *script -
|
|
|
|
// Output : true on success, false otherwise
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
bool CSquirrelVM::Run(const SQChar* const script)
|
|
|
|
{
|
|
|
|
Assert(m_hVM);
|
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
SQBufState bufState(script);
|
|
|
|
|
|
|
|
if (SQ_SUCCEEDED(sq_compilebuffer(m_hVM, &bufState, "unnamed", -1, SQTrue)))
|
|
|
|
{
|
|
|
|
SQObject hScript;
|
|
|
|
sq_getstackobj(m_hVM, -1, &hScript);
|
|
|
|
|
|
|
|
sq_addref(m_hVM, &hScript);
|
|
|
|
sq_pop(m_hVM, 1);
|
|
|
|
|
|
|
|
if (ExecuteFunction((HSCRIPT)&hScript, NULL, 0, NULL, NULL) == SCRIPT_DONE)
|
|
|
|
success = true;
|
|
|
|
|
|
|
|
sq_release(m_hVM, &hScript);
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2024-04-19 12:44:43 +02:00
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: executes a function by handle
|
|
|
|
// Input : hFunction -
|
|
|
|
// *pArgs -
|
|
|
|
// nArgs -
|
|
|
|
// *pReturn -
|
|
|
|
// hScope -
|
|
|
|
// Output : SCRIPT_DONE on success, SCRIPT_ERROR otherwise
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
ScriptStatus_t CSquirrelVM::ExecuteFunction(HSCRIPT hFunction, void** pArgs, unsigned int nArgs, void* pReturn, HSCRIPT hScope)
|
|
|
|
{
|
|
|
|
// NOTE: pArgs and pReturn are most likely of type 'ScriptVariant_t', needs to be reversed.
|
|
|
|
return CSquirrelVM__ExecuteFunction(this, hFunction, pArgs, nArgs, pReturn, hScope);
|
2024-04-03 14:51:44 +02:00
|
|
|
}
|
|
|
|
|
2024-04-19 13:14:35 +02:00
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: executes a code callback
|
|
|
|
// Input : *name -
|
|
|
|
// Output : true on success, false otherwise
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
bool CSquirrelVM::ExecuteCodeCallback(const SQChar* const name)
|
|
|
|
{
|
|
|
|
return CSquirrelVM__ExecuteCodeCallback(this, name);
|
|
|
|
}
|
|
|
|
|
2023-05-06 16:23:56 +02:00
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: registers a code function
|
|
|
|
// Input : *s -
|
|
|
|
// *scriptName -
|
|
|
|
// *nativeName -
|
|
|
|
// *helpString -
|
|
|
|
// *returnString -
|
|
|
|
// *parameters -
|
|
|
|
// *function -
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
SQRESULT CSquirrelVM::RegisterFunction(const SQChar* scriptName, const SQChar* nativeName,
|
|
|
|
const SQChar* helpString, const SQChar* returnString, const SQChar* parameters, void* function)
|
|
|
|
{
|
|
|
|
ScriptFunctionBinding_t binding;
|
|
|
|
binding.Init(scriptName, nativeName, helpString, returnString, parameters, 5, function);
|
|
|
|
|
2024-01-02 15:21:36 +01:00
|
|
|
SQRESULT results = CSquirrelVM__RegisterFunction(this, &binding, 1);
|
2023-05-06 16:23:56 +02:00
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: sets current VM as the global precompiler
|
|
|
|
// Input : *name -
|
|
|
|
// value -
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
void CSquirrelVM::SetAsCompiler(RSON::Node_t* rson)
|
|
|
|
{
|
|
|
|
const SQCONTEXT context = GetContext();
|
|
|
|
switch (context)
|
|
|
|
{
|
|
|
|
case SQCONTEXT::SERVER:
|
|
|
|
{
|
|
|
|
v_Script_SetServerPrecompiler(context, rson);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SQCONTEXT::CLIENT:
|
|
|
|
case SQCONTEXT::UI:
|
|
|
|
{
|
|
|
|
v_Script_SetClientPrecompiler(context, rson);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: Precompiles mod scripts
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
void CSquirrelVM::CompileModScripts()
|
|
|
|
{
|
2024-01-21 21:29:23 +01:00
|
|
|
FOR_EACH_VEC(ModSystem()->GetModList(), i)
|
2023-05-06 16:23:56 +02:00
|
|
|
{
|
2024-01-21 21:29:23 +01:00
|
|
|
const CModSystem::ModInstance_t* mod = ModSystem()->GetModList()[i];
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
|
|
|
|
if (!mod->IsEnabled())
|
2023-05-06 16:23:56 +02:00
|
|
|
continue;
|
|
|
|
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
if (!mod->m_bHasScriptCompileList)
|
2023-05-06 16:23:56 +02:00
|
|
|
continue;
|
|
|
|
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
// allocs parsed rson buffer
|
|
|
|
RSON::Node_t* rson = mod->LoadScriptCompileList();
|
2023-05-06 16:23:56 +02:00
|
|
|
|
|
|
|
if (!rson)
|
2024-03-25 01:41:52 +01:00
|
|
|
Error(GetNativeContext(), NO_ERROR,
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
"%s: Failed to load RSON file '%s'\n",
|
|
|
|
__FUNCTION__, mod->GetScriptCompileListPath().Get());
|
2023-05-06 16:23:56 +02:00
|
|
|
|
|
|
|
const char* scriptPathArray[MAX_PRECOMPILED_SCRIPTS];
|
|
|
|
int scriptCount = 0;
|
|
|
|
|
|
|
|
SetAsCompiler(rson);
|
|
|
|
|
|
|
|
if (Script_ParseScriptList(
|
|
|
|
GetContext(),
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
mod->GetScriptCompileListPath().Get(),
|
2023-05-06 16:23:56 +02:00
|
|
|
rson,
|
|
|
|
(char**)scriptPathArray, &scriptCount,
|
|
|
|
nullptr, 0))
|
|
|
|
{
|
|
|
|
std::vector<char*> newScriptPaths;
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
for (int j = 0; j < scriptCount; ++j)
|
2023-05-06 16:23:56 +02:00
|
|
|
{
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
// add "::MOD::" to the start of the script path so it can be
|
|
|
|
// identified from Script_LoadScript later, this is so we can
|
|
|
|
// avoid script naming conflicts by removing the engine's
|
|
|
|
// forced directory of "scripts/vscripts/" and adding the mod
|
|
|
|
// path to the start
|
|
|
|
CUtlString scriptPath;
|
|
|
|
scriptPath.Format("%s%s%s%s",
|
|
|
|
MOD_SCRIPT_PATH_IDENTIFIER, mod->GetBasePath().Get(),
|
|
|
|
GAME_SCRIPT_PATH, scriptPathArray[j]);
|
|
|
|
|
|
|
|
char* pszScriptPath = _strdup(scriptPath.Get());
|
2023-05-06 16:23:56 +02:00
|
|
|
|
|
|
|
// normalise slash direction
|
|
|
|
V_FixSlashes(pszScriptPath);
|
|
|
|
|
|
|
|
newScriptPaths.emplace_back(pszScriptPath);
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
scriptPathArray[j] = pszScriptPath;
|
2023-05-06 16:23:56 +02:00
|
|
|
}
|
|
|
|
|
2024-03-25 01:41:52 +01:00
|
|
|
switch (GetContext())
|
2023-05-06 16:23:56 +02:00
|
|
|
{
|
|
|
|
case SQCONTEXT::SERVER:
|
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
CSquirrelVM__PrecompileServerScripts(this, GetContext(), (char**)scriptPathArray, scriptCount);
|
2023-05-06 16:23:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SQCONTEXT::CLIENT:
|
|
|
|
case SQCONTEXT::UI:
|
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
CSquirrelVM__PrecompileClientScripts(this, GetContext(), (char**)scriptPathArray, scriptCount);
|
2023-05-06 16:23:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clean up our allocated script paths
|
|
|
|
for (char* path : newScriptPaths)
|
|
|
|
{
|
Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
|
|
|
free(path);
|
2023-05-06 16:23:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-10 13:50:05 +02:00
|
|
|
RSON_Free(rson, AlignedMemAlloc());
|
|
|
|
AlignedMemAlloc()->Free(rson);
|
2023-05-06 16:23:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
2023-11-26 13:21:20 +01:00
|
|
|
void VSquirrel::Detour(const bool bAttach) const
|
2023-05-06 16:23:56 +02:00
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
DetourSetup(&CSquirrelVM__Init, &CSquirrelVM::Init, bAttach);
|
|
|
|
DetourSetup(&CSquirrelVM__DestroySignalEntryListHead, &CSquirrelVM::DestroySignalEntryListHead, bAttach);
|
2023-05-06 16:23:56 +02:00
|
|
|
}
|