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