some updates to the Linux build system - obtained a core binary and all required...
[xonotic/netradiant.git] / plugins / mapxml / plugin.cpp
1 #include "plugin.h"\r
2 \r
3 // =============================================================================\r
4 // Globals\r
5 \r
6 // function tables\r
7 _QERFuncTable_1 g_FuncTable;\r
8 _QERShadersTable g_ShadersTable;\r
9 _QEREntityTable g_EntityTable;\r
10 _QERBrushTable g_BrushTable;\r
11 _QERPatchTable g_PatchTable;\r
12 \r
13 // =============================================================================\r
14 // SYNAPSE\r
15 \r
16 CSynapseServer* g_pSynapseServer = NULL;\r
17 CSynapseClientXMap g_SynapseClient;\r
18 \r
19 static const XMLConfigEntry_t entries[] = \r
20   { \r
21     { SHADERS_MAJOR, SYN_REQUIRE, sizeof(g_ShadersTable), &g_ShadersTable },    \r
22     { NULL, SYN_UNKNOWN, 0, NULL } };\r
23   \r
24 #if __GNUC__ >= 4\r
25 #pragma GCC visibility push(default)\r
26 #endif\r
27 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {\r
28 #if __GNUC__ >= 4\r
29 #pragma GCC visibility pop\r
30 #endif\r
31   if (strcmp(version, SYNAPSE_VERSION))\r
32   {\r
33     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
34     return NULL;\r
35   }\r
36   g_pSynapseServer = pServer;\r
37   g_pSynapseServer->IncRef();\r
38   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
39   \r
40   g_SynapseClient.AddAPI(MAP_MAJOR, "mapxml", sizeof(_QERPlugMapTable));\r
41   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);\r
42   g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);\r
43   g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(g_BrushTable), SYN_REQUIRE, &g_BrushTable);\r
44   g_SynapseClient.AddAPI(PATCH_MAJOR, NULL, sizeof(g_PatchTable), SYN_REQUIRE, &g_PatchTable);\r
45 \r
46   if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {\r
47     return NULL;\r
48   }\r
49   \r
50   return &g_SynapseClient;\r
51 }\r
52 \r
53 bool CSynapseClientXMap::RequestAPI(APIDescriptor_t *pAPI)\r
54 {\r
55   if (!strcmp(pAPI->major_name, MAP_MAJOR))\r
56   {\r
57     _QERPlugMapTable* pTable= static_cast<_QERPlugMapTable*>(pAPI->mpTable);\r
58     pTable->m_pfnMap_Read = &Map_Read;\r
59     pTable->m_pfnMap_Write = &Map_Write;\r
60     \r
61     return true;\r
62   }\r
63 \r
64   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
65   return false;\r
66 }\r
67 \r
68 #include "version.h"\r
69 \r
70 const char* CSynapseClientXMap::GetInfo()\r
71 {\r
72   return "XMAP module built " __DATE__ " " RADIANT_VERSION;\r
73 }\r
74 \r
75 const char* CSynapseClientXMap::GetName()\r
76 {\r
77   return "xmap";\r
78 }\r