Example #1
0
bool CSynapseClient::ConfigXML( CSynapseServer *pServer, const char *client_name, const XMLConfigEntry_t entries[] ) {

    if ( !client_name ) {
        client_name = GetName();
    }

    Syn_Printf( "Dynamic APIs for client '%s'\n", GetInfo() );
    if ( !pServer->SelectClientConfig( client_name ) ) {
        Syn_Printf( "Failed to select synapse client config '%s'\n", client_name );
        return false;
    }

    int i = 0;
    while ( entries[i].type != SYN_UNKNOWN ) { // don't test pTable, for a SYN_PROVIDE it will be empty
        char *minor;
        if ( !pServer->GetConfigForAPI( entries[i].api, &minor ) ) {
            Syn_Printf( "GetConfigForAPI '%s' failed - invalid XML config file?\n", entries[i].api );
            return false;
        }
        AddAPI( entries[i].api, minor, entries[i].size, entries[i].type, entries[i].pTable );
        i++;
    }
    Syn_Printf( "%d dynamic interfaces parsed for '%s'\n", i, client_name );
    return true;
}
Example #2
0
bool CSynapseServer::DoResolve( CSynapseClient *pClient ) {
    list<CSynapseClientSlot>::iterator iSlot;
    for ( iSlot = mClients.begin(); iSlot != mClients.end(); iSlot++ )
    {
        if ( ( *iSlot ).mpClient == pClient ) {
            break;
        }
    }
    if ( iSlot == mClients.end() ) {
        Syn_Printf( "CSynapserServer::Resolve adding new client slot '%s'\n", pClient->GetInfo() );
        CSynapseClientSlot slot;
        slot.mpClient = pClient;
        slot.mFileName = "local client";
        // make it active so we can request the interfaces already
        pClient->ForceSetActive();
        mClients.push_front( slot );
    }
    else
    {
        // make it active so we can request the interfaces already
        ( *iSlot ).mpClient->ForceSetActive();
    }

    // push the interfaces that need to be resolved for this client
    // NOTE: this doesn't take care of the SYN_REQUIRE_ANY interfaces
    PushRequired( pClient );
    // start resolving now
    // working till the stack is emptied or till we reach a dead end situation
    // we do a depth first traversal, we will grow the interface stack to be resolved till we start finding solutions
    list<APIDescriptor_t*>::iterator iCurrent;
    mbStackChanged = true; // init to true so we try the first elem
    while ( !mStack.empty() )
    {
        //DumpStack();
        if ( !mbStackChanged ) {
            // the stack didn't change last loop
            iCurrent++;
            if ( iCurrent == mStack.end() ) {
                Syn_Printf( "ERROR: CSynapseServer::Resolve, failed to resolve\n" );
                DumpStack();
                return false;
            }
            if ( ResolveAPI( *iCurrent ) ) {
                iCurrent = mStack.erase( iCurrent );
                mbStackChanged = true;
            }
        }
        else
        {
            // the stack changed at last loop
            mbStackChanged = false;
            iCurrent = mStack.begin();
            if ( ResolveAPI( *iCurrent ) ) {
                iCurrent = mStack.erase( iCurrent );
                mbStackChanged = true;
            }
        }
    }
    return true;
}
Example #3
0
void CSynapseClientSlot::ReleaseSO() {
    if ( !mpDLL ) {
        Syn_Printf( "ERROR: no shared object handle for client '%s' in CSynapseClientSlot::ReleaseSO\n", mpClient->GetInfo() );
        return;
    }
    Syn_Printf( "FreeLibrary '%s'\n", mpClient->GetInfo() );
    if ( !FreeLibrary( mpDLL ) ) {
        Syn_Printf( " FreeLibrary failed: GetLastError: '%s'\n", CSynapseServer::FormatGetLastError() );
    }
    mpDLL = NULL;
}
Example #4
0
bool CSynapseServer::Initialize( const char* conf_file, PFN_SYN_PRINTF_VA pf ) {
    // browse the paths to locate all potential modules

    Set_Syn_Printf( pf );

    if ( conf_file ) {
        // if a config file is specified and we fail to load it, we fail
        Syn_Printf( "loading synapse XML config file '%s'\n", conf_file );
        mpDoc = xmlParseFile( conf_file );
        if ( !mpDoc ) {
            Syn_Printf( "'%s' invalid/not found\n", conf_file );
            return false;
        }
    }

    for ( list<char *>::iterator iPath = mSearchPaths.begin(); iPath != mSearchPaths.end(); iPath++ )
    {
        const char* path = *iPath;

        Syn_Printf( "Synapse Scanning modules path: %s\n", path );

        GDir* dir = g_dir_open( path, 0, NULL );

        if ( dir != NULL ) {
            while ( 1 )
            {
                const gchar* name = g_dir_read_name( dir );
                if ( name == NULL ) {
                    break;
                }

                // too small to be isolated in win32/ and linux/ directories..
#if defined( _WIN32 )
                const char* ext_so = ".dll";
#elif defined ( __linux__ ) || defined ( __APPLE__ )
                const char* ext_so = ".so";
#endif
                const char* ext = strrchr( name, '.' );
                if ( ( ext == NULL ) || ( stricmp( ext, ext_so ) != 0 ) ) {
                    continue;
                }

                Str newModule;
                newModule.Format( "%s%s", path, name );
                Syn_Printf( "Found '%s'\n", newModule.GetBuffer() );
                EnumerateInterfaces( newModule );
            }

            g_dir_close( dir );
        }
    }
    return true;
}
Example #5
0
bool CSynapseServer::ResolveAPI( APIDescriptor_t* pAPI ) {
    //Syn_Printf("In ResolveAPI %s %p '%s' '%s'\n", APITypeName[pAPI->mType], pAPI, pAPI->major_name, pAPI->minor_name);
    // loop through active clients, search for a client providing what we are looking for
    list<CSynapseClientSlot>::iterator iClient;
    for ( iClient = mClients.begin(); iClient != mClients.end(); iClient++ )
    {
        // walk through interfaces on this client for a match
        CSynapseClient *pScanClient = ( *iClient ).mpClient;
        int i,max = pScanClient->GetAPICount();
        for ( i = 0; i < max; i++ )
        {
            APIDescriptor_t *pScanClientAPI = pScanClient->GetAPIDescriptor( i );
            if ( pScanClientAPI->mType == SYN_PROVIDE ) {
                if ( MatchAPI( pAPI, pScanClientAPI ) ) {
                    // can this client provide APIs yet
                    // it is possible that all of it's APIs have been filled and it's not been activated yet
                    pScanClient->CheckSetActive();
                    if ( pScanClient->IsActive() ) {
                        // make sure this interface has correct size (this is our version check)
                        if ( pAPI->mSize != pScanClientAPI->mSize ) {
                            Syn_Printf( "ERROR: version mismatch for API '%s' '%s' found in '%s' (size %d != %d)\n", pAPI->major_name, pAPI->minor_name, pScanClient->GetInfo(), pAPI->mSize, pScanClientAPI->mSize );
                            Syn_Printf( "  the module and the server are incompatible\n" );
                            // keep going to other APIs
                            continue;
                        }
                        // this is an active client, we can request
#ifdef SYNAPSE_VERBOSE
                        Syn_Printf( "RequestAPI '%s' '%s' from '%s' for API %p\n", pAPI->major_name, pAPI->minor_name, pScanClient->GetInfo(), pAPI );
#endif
                        if ( !pScanClient->RequestAPI( pAPI ) ) {
                            // this should never happen, means we think this module provides the API, but it answers that it doesn't
                            Syn_Printf( "ERROR: RequestAPI failed\n" );
                            return false;
                        }
                        pScanClientAPI->mRefCount++;
                        pAPI->mbTableInitDone = true;
                        return true; // job done
                    }
                    else
                    {
                        // this client is not active yet, some of it's required interfaces are not filled in
                        PushRequired( pScanClient );
                        // we will exit the scan through the APIDescriptor of this client and look at other clients
                        break;
                    }
                }
            }
        }
    }
    return false;
}
Example #6
0
void CSynapseServer::DumpActiveClients() {
    list<CSynapseClientSlot>::iterator iClient;
    for ( iClient = mClients.begin(); iClient != mClients.end(); iClient++ )
    {
        CSynapseClient *pClient = ( *iClient ).mpClient;
        Syn_Printf( "%s", pClient->GetInfo() );
        if ( pClient->IsActive() ) {
            Syn_Printf( "\n" );
        }
        else {
            Syn_Printf( " (not active)\n" );
        }
    }
}
Example #7
0
void CSynapseClientSlot::ReleaseSO() {
    if ( !mpDLL ) {
        Syn_Printf( "ERROR: no shared object handle for client '%s' in CSynapseClientSlot::ReleaseSO\n", mpClient->GetInfo() );
        return;
    }
    Syn_Printf( "dlclose '%s'\n", mpClient->GetInfo() );
    if ( dlclose( mpDLL ) ) {
        const char* error;
        if ( ( error = (char *)dlerror() ) == NULL ) {
            error = "Unknown";
        }
        Syn_Printf( "  dlclose failed: dlerror: '%s'\n", error );
    }
    mpDLL = NULL;
}
Example #8
0
bool CSynapseClient::CheckSetActive() {
    if ( mbActive ) {
        return true;
    }
    int i,max = GetAPICount();
    for ( i = 0; i < max; i++ )
    {
        APIDescriptor_t *pAPI = GetAPIDescriptor( i );
        if ( pAPI->mType == SYN_REQUIRE && !pAPI->mbTableInitDone ) {
            return false;
        }
    }
    // if we have managers with fixed list, those need to be completely filled in too
    vector<CSynapseAPIManager *>::iterator iManager;
    for ( iManager = mManagersList.begin(); iManager != mManagersList.end(); iManager++ )
    {
        if ( !( *iManager )->CheckSetActive() ) {
            return false; // one of the managers doesn't have all it needs yet
        }
    }
    // call OnActivate to let the client perform last minute checks
    // NOTE: this should be fatal instead of letting the engine try other combinations
    if ( !OnActivate() ) {
        return false;
    }
    // yes, all required interfaces have been initialized
    Syn_Printf( "'%s' activated\n", GetInfo() );
    mbActive = true;
    return true;
}
Example #9
0
extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer) 
{
#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif
	if (strcmp(version, SYNAPSE_VERSION)) {
		Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
		return NULL;
	}
	g_pSynapseServer = pServer;
	g_pSynapseServer->IncRef();
	Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());

	g_SynapseClient.AddAPI(TOOLBAR_MAJOR, SAMPLE_MINOR, sizeof(_QERPlugToolbarTable));
	g_SynapseClient.AddAPI(PLUGIN_MAJOR, SAMPLE_MINOR, sizeof(_QERPluginTable));
	
	g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
	g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
	g_SynapseClient.AddAPI(VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
	// get worldspawn
	g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);
	// selected brushes
	g_SynapseClient.AddAPI(DATA_MAJOR, NULL, sizeof(g_DataTable), SYN_REQUIRE, &g_DataTable);

	return &g_SynapseClient;
}
Example #10
0
bool CSynapseServer::MatchAPI( APIDescriptor_t *p1, APIDescriptor_t *p2 ) {
    int ret = MatchAPI( p1->major_name, p1->minor_name, p2->major_name, p2->minor_name );
    if ( ret == 2 ) {
        // find out if we can resolve the minor "*" situation
        APIDescriptor_t * any_minor_descriptor;
        APIDescriptor_t * provider_descriptor;
        if ( strcmp( p1->minor_name, "*" ) == 0 ) {
            any_minor_descriptor = p1;
            provider_descriptor = p2;
        } else {
            assert( strcmp( p2->minor_name, "*" ) == 0 );
            any_minor_descriptor = p2;
            provider_descriptor = p1;
        }
        assert( any_minor_descriptor->mType == SYN_REQUIRE );
        assert( provider_descriptor->mType == SYN_PROVIDE );
        APIDescriptor_t * search_major;
        int search_ret = FindActiveMajorClient( provider_descriptor->major_name, &search_major );
        if ( search_ret == 2 ) {
            // FIXME: ERROR
            Syn_Printf( "ERROR: Multiple modules active for major \"%s\": cannot resolve \"*\" for it\n", provider_descriptor->major_name );
            return false;
        }
        if ( search_ret == 0 ) {
            // can't resolve yet
            return false;
        }
        if ( search_major != provider_descriptor ) {
            // the provider_descriptor we were passed is likely not active yet, so just ignore
            return false;
        }
        return true; // this is a go, we have a unique match!
    }
    return ( ret != 0 );
}
Example #11
0
extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif
	if ( strcmp( version, SYNAPSE_VERSION ) ) {
		Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
		return NULL;
	}
	g_pSynapseServer = pServer;
	g_pSynapseServer->IncRef();
	Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );

	if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {
		return NULL;
	}

	g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ), SYN_REQUIRE, &g_FuncTable );
	g_SynapseClient.AddAPI( DATA_MAJOR, NULL, sizeof( _QERAppDataTable ), SYN_REQUIRE, &g_DataTable );
	g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( _QERQglTable ), SYN_REQUIRE, &g_QglTable );
	g_SynapseClient.AddAPI( APPSHADERS_MAJOR, NULL, sizeof( _QERAppShadersTable ), SYN_REQUIRE, &g_ShadersTable );
	g_SynapseClient.AddAPI( SCRIPLIB_MAJOR, NULL, sizeof( _QERScripLibTable ), SYN_REQUIRE, &g_ScripLibTable );
	g_SynapseClient.AddAPI( BRUSH_MAJOR, NULL, sizeof( _QERBrushTable ), SYN_REQUIRE, &g_BrushTable );

	return &g_SynapseClient;
}
Example #12
0
void CSynapseClient::Shutdown() {
    vector<APIDescriptor_t *>::iterator iAPI;
    for ( iAPI = mAPIDescriptors.begin(); iAPI != mAPIDescriptors.end(); iAPI++ )
    {
        APIDescriptor_t *pAPI = *iAPI;
        if ( pAPI->mRefCount != 0 ) {
            Syn_Printf( "WARNING: ~CSynapseClient '%s' has non-zero ref count for interface '%s' '%s'\n", GetInfo(), pAPI->major_name, pAPI->minor_name );
        }
        else {
            delete pAPI;
        }
        *iAPI = NULL;
    }
    mAPIDescriptors.clear();
    vector<CSynapseAPIManager *>::iterator iManager;
    for ( iManager = mManagersList.begin(); iManager != mManagersList.end(); iManager++ )
    {
        CSynapseAPIManager *pManager = *iManager;
        pManager->DecRef();
        *iManager = NULL;
    }
    mManagersList.clear();
    for ( iManager = mManagersMatch.begin(); iManager != mManagersMatch.end(); iManager++ )
    {
        CSynapseAPIManager *pManager = *iManager;
        pManager->DecRef();
        *iManager = NULL;
    }
    mManagersMatch.clear();
}
Example #13
0
extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif
	if ( strcmp( version, SYNAPSE_VERSION ) ) {
		Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
		return NULL;
	}
	g_pSynapseServer = pServer;
	g_pSynapseServer->IncRef();
	Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );

#ifdef USE_HLW
	g_SynapseClient.AddAPI( IMAGE_MAJOR, "hlw", sizeof( _QERPlugImageTable ) );
#endif
#ifdef USE_MIP
	g_SynapseClient.AddAPI( IMAGE_MAJOR, "mip", sizeof( _QERPlugImageTable ) );
#endif
#ifdef USE_IDSP
	g_SynapseClient.AddAPI( IMAGE_MAJOR, "spr", sizeof( _QERPlugImageTable ) );
#endif
	// this "wad" needs to be "*" for the VFS, we don't care what VFS we have, as long as we have one.
	g_SynapseClient.AddAPI( VFS_MAJOR, "wad", sizeof( _QERFileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );
	g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ), SYN_REQUIRE, &g_FuncTable );

	return &g_SynapseClient;
}
Example #14
0
extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif
	if ( strcmp( version, SYNAPSE_VERSION ) ) {
		Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
		return NULL;
	}
	g_pSynapseServer = pServer;
	g_pSynapseServer->IncRef();
	Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );

	initialise();

	add_model_apis( g_SynapseClient );
	g_SynapseClient.AddAPI( TOOLBAR_MAJOR, "model", sizeof( _QERPlugToolbarTable ) );
	g_SynapseClient.AddAPI( PLUGIN_MAJOR, "model", sizeof( _QERPluginTable ) );

	g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( g_FuncTable ), SYN_REQUIRE, &g_FuncTable );
	g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable );

	if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {
		return NULL;
	}

	return &g_SynapseClient;
}
Example #15
0
bool CSynapseClientImage::OnActivate() {
  if (!g_FileSystemTable.m_nSize) {
    Syn_Printf("ERROR: VFS_MAJOR table was not initialized before OnActivate in '%s' - incomplete synapse.config?\n", GetInfo());
    return false;
  }
  return true;
}
Example #16
0
extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif
    if ( strcmp( version, SYNAPSE_VERSION ) ) {
        Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
        return NULL;
    }
    g_pSynapseServer = pServer;
    g_pSynapseServer->IncRef();
    Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );

    g_SynapseClient.AddAPI( IMAGE_MAJOR, "jpg", sizeof( _QERPlugImageTable ) );
    g_SynapseClient.AddAPI( IMAGE_MAJOR, "tga", sizeof( _QERPlugImageTable ) );
    // NOTE: these two are for md2 support - check b_isQuake2 here?
    // instead of requesting them systematically, we could request them per-config before enabling Q2 support
    g_SynapseClient.AddAPI( IMAGE_MAJOR, "pcx", sizeof( _QERPlugImageTable ) );
    g_SynapseClient.AddAPI( IMAGE_MAJOR, "bmp", sizeof( _QERPlugImageTable ) );
    g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ), SYN_REQUIRE, &g_FuncTable );

    if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {
        return NULL;
    }

    return &g_SynapseClient;
}
Example #17
0
bool CSynapseClientShaders::RequestAPI(APIDescriptor_t *pAPI)
{
  if (!strcmp(pAPI->major_name, SHADERS_MAJOR))
  {
    _QERShadersTable* pTable= static_cast<_QERShadersTable*>(pAPI->mpTable);
    
    pTable->m_pfnFreeShaders = QERApp_FreeShaders;
    pTable->m_pfnReloadShaders = QERApp_ReloadShaders;
    pTable->m_pfnLoadShadersFromDir = QERApp_LoadShadersFromDir;
    pTable->m_pfnReloadShaderFile = QERApp_ReloadShaderFile;
    pTable->m_pfnLoadShaderFile = QERApp_LoadShaderFile;
    pTable->m_pfnHasShader = QERApp_HasShader;
    pTable->m_pfnTry_Shader_ForName = QERApp_Try_Shader_ForName;
    pTable->m_pfnShader_ForName = QERApp_Shader_ForName;
    pTable->m_pfnTry_Texture_ForName = QERApp_Try_Texture_ForName;
    pTable->m_pfnTexture_ForName = QERApp_Texture_ForName2;
    pTable->m_pfnGetActiveShaderCount = QERApp_GetActiveShaderCount;
    pTable->m_pfnColorShader_ForName = QERApp_ColorShader_ForName;
    pTable->m_pfnShader_ForName_NoLoad = QERApp_Shader_ForName_NoLoad;
    pTable->m_pfnActiveShaders_SetInUse = QERApp_ActiveShaders_SetInUse;
    pTable->m_pfnSortActiveShaders = QERApp_SortActiveShaders;
    pTable->m_pfnActiveShader_ForTextureName = QERApp_ActiveShader_ForTextureName;
    pTable->m_pfnCreateShader_ForTextureName = QERApp_CreateShader_ForTextureName;
    pTable->m_pfnActiveShaders_SetDisplayed = QERApp_ActiveShaders_SetDisplayed;
    pTable->m_pfnActiveShader_ForIndex = QERApp_ActiveShader_ForIndex;
    pTable->m_pfnCleanTextureName = QERApp_CleanTextureName;    
    
    return true;
  }

  Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
  return false;
}
Example #18
0
bool CSynapseClientModel::RequestAPI( APIDescriptor_t *pAPI ){
	if ( !strcmp( pAPI->major_name, MODEL_MAJOR ) ) {
		_QERPlugModelTable* pTable = static_cast<_QERPlugModelTable*>( pAPI->mpTable );

		if ( model_is_supported( pAPI->minor_name ) ) {
			pTable->m_pfnLoadModel = &LoadModel;
			return true;
		}
	}
	else if ( !strcmp( pAPI->major_name, TOOLBAR_MAJOR ) ) {
		_QERPlugToolbarTable* pTable = static_cast<_QERPlugToolbarTable*>( pAPI->mpTable );

		pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
		pTable->m_pfnGetToolbarButton = &GetToolbarButton;
		return true;
	}
	else if ( !strcmp( pAPI->major_name, PLUGIN_MAJOR ) ) {
		_QERPluginTable* pTable = static_cast<_QERPluginTable*>( pAPI->mpTable );

		pTable->m_pfnQERPlug_Init = QERPlug_Init;
		pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
		pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
		pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
		return true;
	}

	Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
	return false;
}
Example #19
0
bool Primitive_Parse( brush_t *pBrush ){
	char *token = Token();

	GetToken( true );
	if ( !strcmp( token, "patchDef2" ) ) {
		pBrush->patchBrush = true;
		pBrush->pPatch = Patch_Alloc();
		pBrush->pPatch->pSymbiot = pBrush;
		Patch_Parse( pBrush->pPatch );
		GetToken( true ); //}

		// A patchdef should never be loaded from a quake2 map file
		// so we just return false and the brush+patch gets freed
		// and the user gets told.
		if ( g_MapVersion != MAPVERSION_Q3 ) {
			// FIXME: Hydra - I wanted to write out a line number here, but I can't because there's no API to access the core's "scriptline" variable.
			Syn_Printf( "ERROR: patchDef2's are not supported in Quake%d format .map files!\n",g_MapVersion );
			abortcode = MAP_WRONGVERSION;
			return false;
		}
	}
	else if ( !strcmp( token, "brushDef" ) ) {
		pBrush->bBrushDef = true;
		GetToken( true ); // {
		while ( 1 )
		{
			face_t    *f = pBrush->brush_faces;
			pBrush->brush_faces = Face_Alloc();
			Face_Parse( pBrush->brush_faces, true );
			pBrush->brush_faces->next = f;
			// check for end of brush
			GetToken( true );
			if ( strcmp( token,"}" ) == 0 ) {
				break;
			}
			UnGetToken();
		}
		GetToken( true ); // }
	}
	else
	{
		UnGetToken();
		while ( 1 )
		{
			face_t    *f = pBrush->brush_faces;
			pBrush->brush_faces = Face_Alloc();
			Face_Parse( pBrush->brush_faces );
			pBrush->brush_faces->next = f;

			// check for end of brush
			GetToken( true );
			if ( strcmp( token,"}" ) == 0 ) {
				break;
			}
			UnGetToken();
		}
	}
	return true;
}
Example #20
0
void CSynapseServer::DumpStack() {
    list<APIDescriptor_t*>::iterator iCurrent;
    for ( iCurrent = mStack.begin(); iCurrent != mStack.end(); iCurrent++ )
    {
        APIDescriptor_t*pAPI = *iCurrent;
        Syn_Printf( "interface %s %p '%s' '%s'\n", APITypeName[pAPI->mType], pAPI, pAPI->major_name, pAPI->minor_name );
    }
}
Example #21
0
void CSynapseServer::EnumerateInterfaces( Str &soname ) {
    CSynapseClientSlot slot;
    slot.mpDLL = LoadLibrary( soname.GetBuffer() );
    if ( !slot.mpDLL ) {
        Syn_Printf( "LoadLibrary '%s' failed\n", soname.GetBuffer() );
        Syn_Printf( "  GetLastError: %s", FormatGetLastError() );
        return;
    }
    slot.mpEnumerate = (PFN_SYNAPSE_ENUMERATEINTERFACES)GetProcAddress( slot.mpDLL, NAME_SYNAPSE_ENUMERATEINTERFACES );
    if ( !slot.mpEnumerate ) {
        Syn_Printf( "GetProcAddress('%s') failed\n", NAME_SYNAPSE_ENUMERATEINTERFACES );
        Syn_Printf( "  GetLastError: %s", FormatGetLastError() );
        return;
    }
    Syn_Printf( "Enumerate interfaces on '%s'\n", soname.GetBuffer() );
    slot.mpClient = slot.mpEnumerate( SYNAPSE_VERSION, this );
    if ( !slot.mpClient ) {
        Syn_Printf( "Enumerate interfaces on '%s' returned NULL, unloading.\n", soname.GetBuffer() );
        if ( !FreeLibrary( slot.mpDLL ) ) {
            Syn_Printf( " FreeLibrary failed: GetLastError: '%s'\n", CSynapseServer::FormatGetLastError() );
        }
        return;
    }
    slot.mFileName = soname;
    mClients.push_front( slot );
}
Example #22
0
bool CBackgroundImage::Load( const char *filename ){
	qtexture_t *newtex;

	unsigned char *image = NULL; // gets allocated with what ? g_malloc
	int width = 0, height = 0;

	g_FuncTable.m_pfnLoadImage( filename,&image,&width,&height );

	if ( !image ) {
		Syn_Printf( MSG_WARN "load %s failed\n",filename );
		return false;
	}

// just in case we want to build for an old version
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=900
#ifdef BKGRND2D_JPG_WORKAROUND
	if ( strlen( filename ) > 4 && !strcmp( ".jpg",filename + strlen( filename ) - 4 ) ) {
		Syn_Printf( MSG_PREFIX ".jpg workaround, clearing alpha channel\n" );
		int size = width * height * 4;
		int i;
		for ( i = 3; i < size; i += 4 ) {
			image[i] = 255;
		}
	}
#endif

	//TODO bug for stored texture size
	//TODO whose gl context are we in, anyway ?
	newtex = g_FuncTable.m_pfnLoadTextureRGBA( image,width,height );

	g_free( image );

	if ( !newtex ) {
		Syn_Printf( MSG_WARN "image to texture failed\n" );
		return false;
	}

	Cleanup();
	m_tex = newtex;

	g_FuncTable.m_pfnSysUpdateWindows( W_XY );

	return true;
}
Example #23
0
CSynapseServer::~CSynapseServer() {
    if ( m_api_name ) {
        xmlFree( m_api_name );
        m_api_name = NULL;
    }
    if ( m_content ) {
        g_free( m_content );
    }
    Syn_Printf( "TODO: free API managers\n" );
}
Example #24
0
void CSynapseAPIManager::SetMatchAPI( const char *major, const char *minor ) {
    if ( strlen( minor ) > MAX_PATTERN_STRING ) {
        Syn_Printf( "ERROR: MAX_TOKEN_STRING exceeded in CSynapseAPIManager::SetMatchAPI: '%s'\n", minor );
        return;
    }
    strcpy( major_pattern, major );
    strcpy( minor_pattern, minor );
    if ( strcmp( minor, "*" ) ) {
        mType = API_LIST;
    }
}
Example #25
0
bool CSynapseClientImageHL::RequestAPI( APIDescriptor_t *pAPI ){
	if ( !strcmp( pAPI->major_name, "image" ) ) {
		_QERPlugImageTable* pTable = static_cast<_QERPlugImageTable*>( pAPI->mpTable );

		pTable->m_pfnLoadImage = &LoadImage;
		return true;
	}

	Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
	return false;
}
Example #26
0
bool CBackgroundImage::SetExtentsMM(){
	entity_s *worldentity;
	const char *val;
	int xmin = 0, ymin = 0, xmax = 0, ymax = 0;

	worldentity = (entity_s *)g_FuncTable.m_pfnGetEntityHandle( 0 );
	if ( !worldentity ) {
		Syn_Printf( MSG_WARN "SetExtentsMM worldspawn not found\n" );
		return false;
	}
	//TODO val is not NULL even if key does not exist
	val = g_EntityTable.m_pfnValueForKey( worldentity,"mapcoordsmins" );
	if ( !val || !val[0] ) {
		Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmins not found\n" );
		return false;
	}
// we could be more robust
// note contortions due to splashs strange idea of min and max
	if ( sscanf( val, "%d %d",&xmin,&ymax ) != 2 ) {
		Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmins malformed\n" );
		return false;
	}

	val = g_EntityTable.m_pfnValueForKey( worldentity,"mapcoordsmaxs" );
	if ( !val || !val[0] ) {
		Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmaxs not found\n" );
		return false;
	}
	if ( sscanf( val, "%d %d",&xmax,&ymin ) != 2 ) {
		Syn_Printf( MSG_WARN "SetExtentsMM mapcoordsmaxs malformed\n" );
		return false;
	}
	//might do sanity check before we commit
	m_xmin = (float)xmin;
	m_ymin = (float)ymin;
	m_xmax = (float)xmax;
	m_ymax = (float)ymax;

	g_FuncTable.m_pfnSysUpdateWindows( W_XY );
	return true;
}
Example #27
0
bool CSynapseClientXMap::RequestAPI( APIDescriptor_t *pAPI ){
	if ( !strcmp( pAPI->major_name, MAP_MAJOR ) ) {
		_QERPlugMapTable* pTable = static_cast<_QERPlugMapTable*>( pAPI->mpTable );
		pTable->m_pfnMap_Read = &Map_Read;
		pTable->m_pfnMap_Write = &Map_Write;

		return true;
	}

	Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
	return false;
}
Example #28
0
CSynapseAPIManager::~CSynapseAPIManager() {
    vector<APIDescriptor_t *>::iterator iAPI;
    for ( iAPI = mAPIs.begin(); iAPI != mAPIs.end(); iAPI++ )
    {
        APIDescriptor_t *pAPI = *iAPI;
        if ( pAPI->mRefCount != 0 ) {
            Syn_Printf( "WARNING: ~CSynapseAPIManager has non-zero ref count for interface '%s' '%s'\n", pAPI->major_name, pAPI->minor_name );
        }
        delete pAPI;
        *iAPI = NULL;
    }
}
Example #29
0
bool CSynapseClientModel::RequestAPI( APIDescriptor_t *pAPI ){
	if ( !strcmp( pAPI->major_name, MODEL_MAJOR ) ) {
		_QERPlugModelTable* pTable = static_cast<_QERPlugModelTable*>( pAPI->mpTable );

		if ( !strcmp( pAPI->minor_name, "sprite" ) ) {
			pTable->m_pfnLoadModel = &LoadSpriteModel;
			return true;
		}
	}

	Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
	return false;
}
Example #30
0
bool CSynapseClientFGD::RequestAPI( APIDescriptor_t *pAPI ){
	if ( !strcmp( pAPI->major_name, ECLASS_MAJOR ) ) {
		_EClassTable* pTable = static_cast<_EClassTable*>( pAPI->mpTable );

		pTable->m_pfnGetExtension = &EClass_GetExtension;
		pTable->m_pfnScanFile = &Eclass_ScanFile;

		return true;
	}

	Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
	return false;
}