some updates to the Linux build system - obtained a core binary and all required...
[xonotic/netradiant.git] / plugins / entity / 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 //\r
23 // Model Plugin\r
24 //\r
25 \r
26 #include "plugin.h"\r
27 #include "entity.h"\r
28 #include "entity_entitymodel.h"\r
29 #include "light.h"\r
30 \r
31 // =============================================================================\r
32 // Globals\r
33 \r
34 // function tables\r
35 _QERFuncTable_1 g_FuncTable;\r
36 _QERQglTable g_QglTable;\r
37 _QERBrushTable __BRUSHTABLENAME;\r
38 _QERUndoTable __UNDOTABLENAME;\r
39 _EClassManagerTable __ECLASSMANAGERTABLENAME;\r
40 \r
41 // =============================================================================\r
42 // SYNAPSE\r
43 \r
44 class CSynapseClientEntity : public CSynapseClient\r
45 {\r
46 public:\r
47   // CSynapseClient API\r
48   bool RequestAPI(APIDescriptor_t *pAPI);\r
49   const char* GetInfo();\r
50   \r
51   CSynapseClientEntity() { }\r
52   virtual ~CSynapseClientEntity() { }\r
53 };\r
54 \r
55 \r
56 CSynapseServer* g_pSynapseServer = NULL;\r
57 CSynapseClientEntity g_SynapseClient;\r
58 \r
59 #if __GNUC__ >= 4\r
60 #pragma GCC visibility push(default)\r
61 #endif\r
62 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {\r
63 #if __GNUC__ >= 4\r
64 #pragma GCC visibility pop\r
65 #endif\r
66   if (strcmp(version, SYNAPSE_VERSION))\r
67   {\r
68     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
69     return NULL;\r
70   }\r
71   g_pSynapseServer = pServer;\r
72   g_pSynapseServer->IncRef();\r
73   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
74   \r
75   g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(_QEREntityTable));\r
76   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);\r
77   g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);\r
78   g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(__BRUSHTABLENAME), SYN_REQUIRE, &__BRUSHTABLENAME);\r
79   g_SynapseClient.AddAPI(UNDO_MAJOR, NULL, sizeof(__UNDOTABLENAME), SYN_REQUIRE, &__UNDOTABLENAME);\r
80   g_SynapseClient.AddAPI(ECLASSMANAGER_MAJOR, NULL, sizeof(__ECLASSMANAGERTABLENAME), SYN_REQUIRE, &__ECLASSMANAGERTABLENAME);\r
81 \r
82   return &g_SynapseClient;\r
83 }\r
84 \r
85 bool CSynapseClientEntity::RequestAPI(APIDescriptor_t *pAPI)\r
86 {\r
87   if (!strcmp(pAPI->major_name, ENTITY_MAJOR))\r
88   {\r
89     _QEREntityTable* pTable= static_cast<_QEREntityTable*>(pAPI->mpTable);\r
90     pTable->m_pfnEntity_Alloc = &Entity_Alloc;\r
91     pTable->m_pfnEntity_Free = &Entity_Free;\r
92     pTable->m_pfnEntity_Clone = &Entity_Clone;\r
93     pTable->m_pfnSetKeyValue = &SetKeyValue;\r
94     pTable->m_pfnDeleteKey = &DeleteKey;\r
95     pTable->m_pfnValueForKey = &ValueForKey;\r
96     pTable->m_pfnFloatForKey = &FloatForKey;\r
97     pTable->m_pfnIntForKey = &IntForKey;\r
98     pTable->m_pfnGetVectorForKey = &GetVectorForKey;\r
99     pTable->m_pfnEntity_AddToList = &Entity_AddToList;\r
100     pTable->m_pfnEntity_RemoveFromList = &Entity_RemoveFromList;\r
101     pTable->m_pfnEntity_LinkBrush = &Entity_LinkBrush;\r
102     pTable->m_pfnEntity_UnlinkBrush = &Entity_UnlinkBrush;\r
103     pTable->m_pfnDrawLight = &DrawLight;\r
104     pTable->m_pfnEntity_MemorySize = &Entity_MemorySize;\r
105     pTable->m_pfnAllocateEpair = &Entity_AllocateEpair;\r
106     pTable->m_pfnGetEntityKeyValList = &Entity_GetKeyValList;\r
107     pTable->m_pfnSetEntityKeyValList = &Entity_SetKeyValList;\r
108 \r
109     return true;\r
110   }\r
111 \r
112   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
113   return false;\r
114 }\r
115 \r
116 #include "version.h"\r
117 \r
118 const char* CSynapseClientEntity::GetInfo()\r
119 {\r
120   return "Entity module built " __DATE__ " " RADIANT_VERSION;\r
121 }\r