]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/imagewal/imagewal.cpp
merge branch work back into trunk
[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 #if __GNUC__ >= 4
43 #pragma GCC visibility push(default)
44 #endif
45 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
46 #if __GNUC__ >= 4
47 #pragma GCC visibility pop
48 #endif
49   if (strcmp(version, SYNAPSE_VERSION))
50   {
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 {
70   if (!strcmp(pAPI->major_name, IMAGE_MAJOR ))
71   {    
72     _QERPlugImageTable* pTable= static_cast<_QERPlugImageTable*>(pAPI->mpTable);
73     if (!strcmp(pAPI->minor_name, "wal"))
74     {      
75       pTable->m_pfnLoadImage = &LoadWAL;
76       return true;
77     }
78   }
79
80   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
81   return false;
82 }
83
84 bool CSynapseClientImage::OnActivate() {
85   if (!g_FileSystemTable.m_nSize) {
86     Syn_Printf("ERROR: VFS_MAJOR table was not initialized before OnActivate in '%s' - incomplete synapse.config?\n", GetInfo());
87     return false;
88   }
89   return true;
90 }
91
92 #include "version.h"
93
94 const char* CSynapseClientImage::GetInfo()
95 {
96   return "WAL formats module built " __DATE__ " " RADIANT_VERSION;
97 }