Пример #1
0
static void JPLua_LoadPluginDir( qboolean inPK3 ) {
	static char folderList[16384];
	char *folderName = folderList;
	int i, numFolders;

	memset( folderList, 0, sizeof(folderList) );
	numFolders = trap->FS_GetFileList( pluginDir, inPK3 ? "" : "/", folderList, sizeof(folderList) );
	for ( i = 0; i < numFolders; i++ ) {
		size_t skipLenFolder = inPK3 ? 1 : 0, folderLen = 0;
		qboolean skip = qfalse;
		char *s;
		jplua_plugin_t *plugin = NULL;

		if ( folderName[0] == '.' )
			skip = qtrue;

		// check for loading the same plugin twice
		// this can happen when listing plugins outside of PK3s when plugins have written files using the Serialiser
		while ( JPLua_IteratePluginsTemp( &plugin ) ) {
			if ( !Q_stricmp( folderName, plugin->name ) )
				skip = qtrue;
		}

		if ( (s = (char *)Q_strchrs( folderName, "/\\" )) ) {
			if ( !s[1] )
				skip = qtrue;
			*s = '\0';
			skipLenFolder = strlen( ++s ) + 1;
		}
		folderLen = strlen( folderName ) + 1;
		if ( !skip ) {
			static char fileList[16384];
			char *fileName = fileList;
			int j, numFiles;

			memset( fileList, 0, sizeof(fileList) );
			numFiles = trap->FS_GetFileList( va( "%s%s", pluginDir, folderName ), JPLUA_EXTENSION, fileList, sizeof(fileList) );

			for ( j = 0; j < numFiles; j++ ) {
				size_t skipLenFile = inPK3 ? 1 : 0, fileLen = 0;
				if ( (s = (char *)Q_strchrs( fileName, "/\\" )) ) {
					*s = '\0';
					skipLenFile = strlen( ++s ) + 1;
				}
				fileLen = strlen( fileName ) + 1;
				if ( !Q_stricmp( fileName, "plugin" JPLUA_EXTENSION ) ) {
					JPLua_LoadPlugin( folderName, fileName );
					break;
				}
				fileName += fileLen + skipLenFile;
			}
		}
		folderName += folderLen + skipLenFolder;
	}
}
Пример #2
0
static void JPLua_PostInit( lua_State *L )
{
	char folderList[16384] = {0}, *folderName = NULL;
	int i=0, numFolders=0, folderLen=0;

	trap->Print( "^5**************** ^3JA++ Lua (SV) is initialising ^5****************\n" );
	
	JPLua_LoadFile( L, JPLUA_DIRECTORY"init"JPLUA_EXTENSION );
	lua_getfield( L, LUA_GLOBALSINDEX, "JPLua" );
	lua_getfield( L, -1, "version" );
	JPLua.version = lua_tointeger( L, -1 );
	lua_pop( L, 1 );

	trap->Print( "%-15s%-32s%-8s%s\n", "               ", "Name", "Version", "Unique ID" );

	numFolders = trap->FS_GetFileList( JPLUA_DIRECTORY, "/", folderList, sizeof( folderList ) );
	folderName = folderList;
	for ( i=0; i<numFolders; i++ )
	{
		Q_strstrip( folderName, "/\\", NULL );
		folderLen = strlen( folderName );
		//folderName[folderLen] = '\0'; // not necessary?
		if ( Q_stricmp( folderName, "." ) && Q_stricmp( folderName, ".." ) )
		{
			char fileList[16384] = {0}, *fileName = NULL;
			int j=0, numFiles=0, fileLen=0;
			
			numFiles = trap->FS_GetFileList( va( JPLUA_DIRECTORY"%s", folderName ), JPLUA_EXTENSION, fileList, sizeof( fileList ) );
			fileName = fileList;

			for ( j=0; j<numFiles; j++ )
			{
				Q_strstrip( fileName, "/\\", NULL );
				fileLen = strlen( fileName );
			//	fileName[fileLen] = '\0'; // not necessary?
				if ( !Q_stricmp( fileName, "plugin"JPLUA_EXTENSION ) )
				{
					JPLua_LoadPlugin( folderName, fileName );
					break;
				}
				fileName += fileLen+1;
			}
		}
		folderName += folderLen+1;
	}

	trap->Print( "^5**************** ^2JA++ Lua (SV) is initialised ^5****************\n" );

	return;
}