]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/imagewal/imagewal.cpp
9468e76eefdf8641804d5dc9d8cfe6a4f241e319
[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 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)\r
43 {\r
44   if (strcmp(version, SYNAPSE_VERSION))\r
45   {\r
46     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
47     return NULL;\r
48   }\r
49   g_pSynapseServer = pServer;\r
50   g_pSynapseServer->IncRef();\r
51   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
52 \r
53   g_SynapseClient.AddAPI(IMAGE_MAJOR, "wal", sizeof(_QERPlugImageTable));\r
54   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);\r
55   \r
56   if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {\r
57     return NULL;\r
58   }\r
59   \r
60   return &g_SynapseClient;\r
61 }\r
62 \r
63 bool CSynapseClientImage::RequestAPI(APIDescriptor_t *pAPI)\r
64 {\r
65   if (!strcmp(pAPI->major_name, IMAGE_MAJOR ))\r
66   {    \r
67     _QERPlugImageTable* pTable= static_cast<_QERPlugImageTable*>(pAPI->mpTable);\r
68     if (!strcmp(pAPI->minor_name, "wal"))\r
69     {      \r
70       pTable->m_pfnLoadImage = &LoadWAL;\r
71       return true;\r
72     }\r
73   }\r
74 \r
75   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
76   return false;\r
77 }\r
78 \r
79 bool CSynapseClientImage::OnActivate() {\r
80   if (!g_FileSystemTable.m_nSize) {\r
81     Syn_Printf("ERROR: VFS_MAJOR table was not initialized before OnActivate in '%s' - incomplete synapse.config?\n", GetInfo());\r
82     return false;\r
83   }\r
84   return true;\r
85 }\r
86 \r
87 #include "version.h"\r
88 \r
89 const char* CSynapseClientImage::GetInfo()\r
90 {\r
91   return "WAL formats module built " __DATE__ " " RADIANT_VERSION;\r
92 }\r