Converted VScript library to DLL

This commit is contained in:
Blixibon 2021-04-22 01:36:41 -05:00
parent 30bc88375a
commit df918b3d88
11 changed files with 52 additions and 10 deletions

View File

@ -459,6 +459,9 @@ public:
{ {
AddAppSystem( "soundemittersystem" DLL_EXT_STRING, SOUNDEMITTERSYSTEM_INTERFACE_VERSION ); AddAppSystem( "soundemittersystem" DLL_EXT_STRING, SOUNDEMITTERSYSTEM_INTERFACE_VERSION );
AddAppSystem( "scenefilecache" DLL_EXT_STRING, SCENE_FILE_CACHE_INTERFACE_VERSION ); AddAppSystem( "scenefilecache" DLL_EXT_STRING, SCENE_FILE_CACHE_INTERFACE_VERSION );
#ifdef MAPBASE
AddAppSystem( "vscript_mapbase" DLL_EXT_STRING, VSCRIPT_INTERFACE_VERSION );
#endif
} }
virtual int Count() virtual int Count()
@ -971,10 +974,18 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi
{ {
scriptmanager = (IScriptManager *)appSystemFactory( VSCRIPT_INTERFACE_VERSION, NULL ); scriptmanager = (IScriptManager *)appSystemFactory( VSCRIPT_INTERFACE_VERSION, NULL );
if (scriptmanager == NULL)
{
Error( "Can't load script manager" );
return false;
}
/*
if (scriptmanager == nullptr) if (scriptmanager == nullptr)
{ {
scriptmanager = (IScriptManager*)Sys_GetFactoryThis()(VSCRIPT_INTERFACE_VERSION, NULL); scriptmanager = (IScriptManager*)Sys_GetFactoryThis()(VSCRIPT_INTERFACE_VERSION, NULL);
} }
*/
} }
#ifdef WORKSHOP_IMPORT_ENABLED #ifdef WORKSHOP_IMPORT_ENABLED

View File

@ -83,7 +83,7 @@ $Project
$Folder "Link Libraries" $Folder "Link Libraries"
{ {
$Lib "vscript" [$MAPBASE_VSCRIPT] $ImpLib "vscript_mapbase" [$MAPBASE_VSCRIPT]
$Lib "raytrace" $Lib "raytrace"
} }
} }

View File

@ -3540,6 +3540,9 @@ public:
{ {
AddAppSystem( "soundemittersystem" DLL_EXT_STRING, SOUNDEMITTERSYSTEM_INTERFACE_VERSION ); AddAppSystem( "soundemittersystem" DLL_EXT_STRING, SOUNDEMITTERSYSTEM_INTERFACE_VERSION );
AddAppSystem( "scenefilecache" DLL_EXT_STRING, SCENE_FILE_CACHE_INTERFACE_VERSION ); AddAppSystem( "scenefilecache" DLL_EXT_STRING, SCENE_FILE_CACHE_INTERFACE_VERSION );
#ifdef MAPBASE
AddAppSystem( "vscript_mapbase" DLL_EXT_STRING, VSCRIPT_INTERFACE_VERSION );
#endif
} }
virtual int Count() virtual int Count()

View File

@ -110,7 +110,7 @@ $Project
$Folder "Link Libraries" $Folder "Link Libraries"
{ {
$Lib "vscript" [$MAPBASE_VSCRIPT] $ImpLib "vscript_mapbase" [$MAPBASE_VSCRIPT]
$Lib "responserules" [$NEW_RESPONSE_SYSTEM] $Lib "responserules" [$NEW_RESPONSE_SYSTEM]
} }
} }

View File

@ -36,8 +36,8 @@ extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
#ifdef MAPBASE_VSCRIPT #ifdef MAPBASE_VSCRIPT
// This is to ensure a dependency exists between the vscript library and the game DLLs // This is to ensure a dependency exists between the vscript library and the game DLLs
extern int vscript_token; //extern int vscript_token;
int vscript_token_hack = vscript_token; //int vscript_token_hack = vscript_token;
#endif #endif

View File

@ -1643,6 +1643,10 @@ struct ScriptHook_t
return false; return false;
} }
}; };
// TEMP LOCATION
extern template VSCRIPT_CLASS ScriptClassDesc_t* GetScriptDesc<matrix3x4_t>( matrix3x4_t* );
extern template VSCRIPT_CLASS ScriptClassDesc_t* GetScriptDesc<Color>( Color* );
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -1397,9 +1397,20 @@ int RunVBSP( int argc, char **argv )
#ifdef MAPBASE_VSCRIPT #ifdef MAPBASE_VSCRIPT
if (g_iScripting) if (g_iScripting)
{ {
scriptmanager = (IScriptManager*)Sys_GetFactoryThis()(VSCRIPT_INTERFACE_VERSION, NULL); static CSysModule *pVScriptModule = NULL;
CreateInterfaceFn vscriptFactory = NULL;
if ( !pVScriptModule )
{
pVScriptModule = g_pFullFileSystem->LoadModule( "vscript_mapbase.dll" );
vscriptFactory = Sys_GetFactory( pVScriptModule );
}
if (vscriptFactory)
{
scriptmanager = (IScriptManager*)vscriptFactory( VSCRIPT_INTERFACE_VERSION, NULL );
VScriptVBSPInit(); VScriptVBSPInit();
}
} }
#endif #endif

View File

@ -189,7 +189,7 @@ $Project "Vbsp"
$Lib mathlib $Lib mathlib
$Lib tier2 $Lib tier2
$Lib vtf $Lib vtf
$Lib vscript [$MAPBASE_VSCRIPT] $ImpLib "vscript_mapbase" [$MAPBASE_VSCRIPT]
} }
$File "notes.txt" $File "notes.txt"

View File

@ -40,8 +40,8 @@ extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
#endif // VMPROFILE #endif // VMPROFILE
// This is to ensure a dependency exists between the vscript library and the game DLLs // This is to ensure a dependency exists between the vscript library and the game DLLs
extern int vscript_token; //extern int vscript_token;
int vscript_token_hack = vscript_token; //int vscript_token_hack = vscript_token;
HSCRIPT VScriptCompileScript( const char *pszScriptName, bool bWarnMissing ) HSCRIPT VScriptCompileScript( const char *pszScriptName, bool bWarnMissing )
{ {

View File

@ -18,6 +18,9 @@ IScriptVM* makeSquirrelVM();
int vscript_token = 0; int vscript_token = 0;
// HACKHACK: The last-created script VM (for accessing VM from bound functions)
IScriptVM *g_pScriptVM;
class CScriptManager : public CTier1AppSystem<IScriptManager> class CScriptManager : public CTier1AppSystem<IScriptManager>
{ {
public: public:
@ -47,6 +50,8 @@ public:
// Register base bindings for all VMs // Register base bindings for all VMs
RegisterBaseBindings( pScriptVM ); RegisterBaseBindings( pScriptVM );
g_pScriptVM = pScriptVM;
return pScriptVM; return pScriptVM;
} }

View File

@ -5,14 +5,17 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
$macro SRCDIR ".." $macro SRCDIR ".."
$Macro OUTBINNAME "vscript_mapbase"
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
$include "$SRCDIR\vpc_scripts\source_lib_base.vpc" $include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$Configuration $Configuration
{ {
$Compiler $Compiler
{ {
$AdditionalIncludeDirectories "$BASE;.\squirrel\include" $AdditionalIncludeDirectories "$BASE;.\squirrel\include"
$PreprocessorDefinitions "$BASE;VSCRIPT_DLL_EXPORT"
$PreprocessorDefinitions "$BASE;MAPBASE_VSCRIPT" [$MAPBASE_VSCRIPT] $PreprocessorDefinitions "$BASE;MAPBASE_VSCRIPT" [$MAPBASE_VSCRIPT]
} }
} }
@ -66,4 +69,9 @@ $Project "VScript"
} }
} }
} }
$Folder "Link Libraries"
{
$Lib mathlib
}
} }