]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/map/plugin.cpp
eol style
[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 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)\r
53 {\r
54   if (strcmp(version, SYNAPSE_VERSION))\r
55   {\r
56     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
57     return NULL;\r
58   }\r
59   g_pSynapseServer = pServer;\r
60   g_pSynapseServer->IncRef();\r
61   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
62   \r
63   g_SynapseClient.AddAPI(MAP_MAJOR, "mapq3", sizeof(_QERPlugMapTable));\r
64   g_SynapseClient.AddAPI(MAP_MAJOR, "maphl", sizeof(_QERPlugMapTable));\r
65   g_SynapseClient.AddAPI(MAP_MAJOR, "mapq2", sizeof(_QERPlugMapTable));\r
66   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);\r
67   g_SynapseClient.AddAPI(SCRIPLIB_MAJOR, NULL, sizeof(g_ScripLibTable), SYN_REQUIRE, &g_ScripLibTable);\r
68   \r
69   // same trick as bobtoolz, see bug #828\r
70   g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof(g_FileSystemTable), SYN_REQUIRE, &g_FileSystemTable );\r
71 \r
72   if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {\r
73     return NULL;\r
74   }\r
75   \r
76   g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(__ENTITYTABLENAME), SYN_REQUIRE, &__ENTITYTABLENAME);\r
77   g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(g_BrushTable), SYN_REQUIRE, &g_BrushTable);\r
78   g_SynapseClient.AddAPI(PATCH_MAJOR, NULL, sizeof(g_PatchTable), SYN_REQUIRE, &g_PatchTable);\r
79   \r
80   return &g_SynapseClient;\r
81 }\r
82 \r
83 bool CSynapseClientMap::RequestAPI(APIDescriptor_t *pAPI)\r
84 {\r
85   if (!strcmp(pAPI->major_name, MAP_MAJOR))\r
86   {\r
87     _QERPlugMapTable* pTable= static_cast<_QERPlugMapTable*>(pAPI->mpTable);\r
88     if (!strcmp(pAPI->minor_name, "mapq3"))\r
89     {\r
90       pTable->m_pfnMap_Read = &Map_ReadQ3;\r
91       pTable->m_pfnMap_Write = &Map_WriteQ3;\r
92       return true;\r
93     }\r
94     if (!strcmp(pAPI->minor_name, "maphl"))\r
95     {\r
96       pTable->m_pfnMap_Read = &Map_ReadHL;\r
97       pTable->m_pfnMap_Write = &Map_WriteHL;\r
98       mbMapHL = true;\r
99       return true;\r
100     }\r
101     if (!strcmp(pAPI->minor_name, "mapq2"))\r
102     {\r
103       pTable->m_pfnMap_Read = &Map_ReadQ2;\r
104       pTable->m_pfnMap_Write = &Map_WriteQ2;\r
105       return true;\r
106     }      \r
107     Syn_Printf("ERROR: RequestAPI( Major: '%s' Minor: '%s' ) not found in '%s'\n", pAPI->major_name, pAPI->minor_name, GetInfo());\r
108     return false;\r
109   }\r
110   \r
111   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
112   return false;\r
113 }\r
114 \r
115 bool CSynapseClientMap::OnActivate() {\r
116   return true;\r
117 }\r
118 \r
119 #include "version.h"\r
120 \r
121 const char* CSynapseClientMap::GetInfo()\r
122 {\r
123   return "MAP format module built " __DATE__ " " RADIANT_VERSION;\r
124 }\r
125 \r
126 const char* CSynapseClientMap::GetName()\r
127 {\r
128   return "map";\r
129 }\r