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