]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/entity/plugin.cpp
dcc51e0e458e07aa9ecde2169333a0bcf4359ff1
[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 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)\r
60 {\r
61   if (strcmp(version, SYNAPSE_VERSION))\r
62   {\r
63     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
64     return NULL;\r
65   }\r
66   g_pSynapseServer = pServer;\r
67   g_pSynapseServer->IncRef();\r
68   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
69   \r
70   g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(_QEREntityTable));\r
71   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);\r
72   g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);\r
73   g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(__BRUSHTABLENAME), SYN_REQUIRE, &__BRUSHTABLENAME);\r
74   g_SynapseClient.AddAPI(UNDO_MAJOR, NULL, sizeof(__UNDOTABLENAME), SYN_REQUIRE, &__UNDOTABLENAME);\r
75   g_SynapseClient.AddAPI(ECLASSMANAGER_MAJOR, NULL, sizeof(__ECLASSMANAGERTABLENAME), SYN_REQUIRE, &__ECLASSMANAGERTABLENAME);\r
76 \r
77   return &g_SynapseClient;\r
78 }\r
79 \r
80 bool CSynapseClientEntity::RequestAPI(APIDescriptor_t *pAPI)\r
81 {\r
82   if (!strcmp(pAPI->major_name, ENTITY_MAJOR))\r
83   {\r
84     _QEREntityTable* pTable= static_cast<_QEREntityTable*>(pAPI->mpTable);\r
85     pTable->m_pfnEntity_Alloc = &Entity_Alloc;\r
86     pTable->m_pfnEntity_Free = &Entity_Free;\r
87     pTable->m_pfnEntity_Clone = &Entity_Clone;\r
88     pTable->m_pfnSetKeyValue = &SetKeyValue;\r
89     pTable->m_pfnDeleteKey = &DeleteKey;\r
90     pTable->m_pfnValueForKey = &ValueForKey;\r
91     pTable->m_pfnFloatForKey = &FloatForKey;\r
92     pTable->m_pfnIntForKey = &IntForKey;\r
93     pTable->m_pfnGetVectorForKey = &GetVectorForKey;\r
94     pTable->m_pfnEntity_AddToList = &Entity_AddToList;\r
95     pTable->m_pfnEntity_RemoveFromList = &Entity_RemoveFromList;\r
96     pTable->m_pfnEntity_LinkBrush = &Entity_LinkBrush;\r
97     pTable->m_pfnEntity_UnlinkBrush = &Entity_UnlinkBrush;\r
98     pTable->m_pfnDrawLight = &DrawLight;\r
99     pTable->m_pfnEntity_MemorySize = &Entity_MemorySize;\r
100     pTable->m_pfnAllocateEpair = &Entity_AllocateEpair;\r
101     pTable->m_pfnGetEntityKeyValList = &Entity_GetKeyValList;\r
102     pTable->m_pfnSetEntityKeyValList = &Entity_SetKeyValList;\r
103 \r
104     return true;\r
105   }\r
106 \r
107   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
108   return false;\r
109 }\r
110 \r
111 #include "version.h"\r
112 \r
113 const char* CSynapseClientEntity::GetInfo()\r
114 {\r
115   return "Entity module built " __DATE__ " " RADIANT_VERSION;\r
116 }\r