]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/imagewal/imagewal.cpp
uncrustify! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / plugins / imagewal / imagewal.cpp
1 /*
2    Copyright (C) 1999-2007 id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #include <stdio.h>
23 #include "imagewal.h"
24
25 // =============================================================================
26 // global tables
27
28 _QERFuncTable_1 g_FuncTable; // Radiant function table
29 _QERFileSystemTable g_FileSystemTable;
30
31 // =============================================================================
32 // SYNAPSE
33
34 CSynapseServer* g_pSynapseServer = NULL;
35 CSynapseClientImage g_SynapseClient;
36
37 static const XMLConfigEntry_t entries[] =
38 {
39         { VFS_MAJOR, SYN_REQUIRE, sizeof( _QERFileSystemTable ), &g_FileSystemTable },
40         { NULL, SYN_UNKNOWN, 0, NULL }
41 };
42
43 #if __GNUC__ >= 4
44 #pragma GCC visibility push(default)
45 #endif
46 extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
47 #if __GNUC__ >= 4
48 #pragma GCC visibility pop
49 #endif
50         if ( strcmp( version, SYNAPSE_VERSION ) ) {
51                 Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
52                 return NULL;
53         }
54         g_pSynapseServer = pServer;
55         g_pSynapseServer->IncRef();
56         Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
57
58         g_SynapseClient.AddAPI( IMAGE_MAJOR, "wal", sizeof( _QERPlugImageTable ) );
59         g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ), SYN_REQUIRE, &g_FuncTable );
60
61         if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {
62                 return NULL;
63         }
64
65         return &g_SynapseClient;
66 }
67
68 bool CSynapseClientImage::RequestAPI( APIDescriptor_t *pAPI ){
69         if ( !strcmp( pAPI->major_name, IMAGE_MAJOR ) ) {
70                 _QERPlugImageTable* pTable = static_cast<_QERPlugImageTable*>( pAPI->mpTable );
71                 if ( !strcmp( pAPI->minor_name, "wal" ) ) {
72                         pTable->m_pfnLoadImage = &LoadWAL;
73                         return true;
74                 }
75         }
76
77         Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
78         return false;
79 }
80
81 bool CSynapseClientImage::OnActivate() {
82         if ( !g_FileSystemTable.m_nSize ) {
83                 Syn_Printf( "ERROR: VFS_MAJOR table was not initialized before OnActivate in '%s' - incomplete synapse.config?\n", GetInfo() );
84                 return false;
85         }
86         return true;
87 }
88
89 #include "version.h"
90
91 const char* CSynapseClientImage::GetInfo(){
92         return "WAL formats module built " __DATE__ " " RADIANT_VERSION;
93 }