]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/map/plugin.cpp
some updates to the Linux build system - obtained a core binary and all required...
[xonotic/netradiant.git] / plugins / map / plugin.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 "plugin.h"\r
23 \r
24 // =============================================================================\r
25 // Globals\r
26 \r
27 // function tables\r
28 _QERFuncTable_1 g_FuncTable;\r
29 _QERScripLibTable g_ScripLibTable;\r
30 _QERShadersTable g_ShadersTable;\r
31 _QEREntityTable __ENTITYTABLENAME;\r
32 _QERBrushTable g_BrushTable;\r
33 _QERPatchTable g_PatchTable;\r
34 _QERFileSystemTable g_FileSystemTable;\r
35 /*!\r
36 the map version we have been initialized with: Q1/Q2/Q3\r
37 we provide all three formats in the same module\r
38 */\r
39 int g_MapVersion;\r
40 \r
41 // =============================================================================\r
42 // SYNAPSE\r
43 \r
44 CSynapseServer* g_pSynapseServer = NULL;\r
45 CSynapseClientMap g_SynapseClient;\r
46 \r
47 static const XMLConfigEntry_t entries[] = \r
48   { \r
49     { SHADERS_MAJOR, SYN_REQUIRE, sizeof(g_ShadersTable), &g_ShadersTable },\r
50     { NULL, SYN_UNKNOWN, 0, NULL } };    \r
51 \r
52 #if __GNUC__ >= 4\r
53 #pragma GCC visibility push(default)\r
54 #endif\r
55 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {\r
56 #if __GNUC__ >= 4\r
57 #pragma GCC visibility pop\r
58 #endif\r
59   if (strcmp(version, SYNAPSE_VERSION))\r
60   {\r
61     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
62     return NULL;\r
63   }\r
64   g_pSynapseServer = pServer;\r
65   g_pSynapseServer->IncRef();\r
66   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
67   \r
68   g_SynapseClient.AddAPI(MAP_MAJOR, "mapq3", sizeof(_QERPlugMapTable));\r
69   g_SynapseClient.AddAPI(MAP_MAJOR, "maphl", sizeof(_QERPlugMapTable));\r
70   g_SynapseClient.AddAPI(MAP_MAJOR, "mapq2", sizeof(_QERPlugMapTable));\r
71   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);\r
72   g_SynapseClient.AddAPI(SCRIPLIB_MAJOR, NULL, sizeof(g_ScripLibTable), SYN_REQUIRE, &g_ScripLibTable);\r
73   \r
74   // same trick as bobtoolz, see bug #828\r
75   g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable );\r
76 \r
77   if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {\r
78     return NULL;\r
79   }\r
80   \r
81   g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(__ENTITYTABLENAME), SYN_REQUIRE, &__ENTITYTABLENAME);\r
82   g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(g_BrushTable), SYN_REQUIRE, &g_BrushTable);\r
83   g_SynapseClient.AddAPI(PATCH_MAJOR, NULL, sizeof(g_PatchTable), SYN_REQUIRE, &g_PatchTable);\r
84   \r
85   return &g_SynapseClient;\r
86 }\r
87 \r
88 bool CSynapseClientMap::RequestAPI(APIDescriptor_t *pAPI)\r
89 {\r
90   if (!strcmp(pAPI->major_name, MAP_MAJOR))\r
91   {\r
92     _QERPlugMapTable* pTable= static_cast<_QERPlugMapTable*>(pAPI->mpTable);\r
93     if (!strcmp(pAPI->minor_name, "mapq3"))\r
94     {\r
95       pTable->m_pfnMap_Read = &Map_ReadQ3;\r
96       pTable->m_pfnMap_Write = &Map_WriteQ3;\r
97       return true;\r
98     }\r
99     if (!strcmp(pAPI->minor_name, "maphl"))\r
100     {\r
101       pTable->m_pfnMap_Read = &Map_ReadHL;\r
102       pTable->m_pfnMap_Write = &Map_WriteHL;\r
103       mbMapHL = true;\r
104       return true;\r
105     }\r
106     if (!strcmp(pAPI->minor_name, "mapq2"))\r
107     {\r
108       pTable->m_pfnMap_Read = &Map_ReadQ2;\r
109       pTable->m_pfnMap_Write = &Map_WriteQ2;\r
110       return true;\r
111     }      \r
112     Syn_Printf("ERROR: RequestAPI( Major: '%s' Minor: '%s' ) not found in '%s'\n", pAPI->major_name, pAPI->minor_name, GetInfo());\r
113     return false;\r
114   }\r
115   \r
116   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
117   return false;\r
118 }\r
119 \r
120 bool CSynapseClientMap::OnActivate() {\r
121   return true;\r
122 }\r
123 \r
124 #include "version.h"\r
125 \r
126 const char* CSynapseClientMap::GetInfo()\r
127 {\r
128   return "MAP format module built " __DATE__ " " RADIANT_VERSION;\r
129 }\r
130 \r
131 const char* CSynapseClientMap::GetName()\r
132 {\r
133   return "map";\r
134 }\r