]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/entity/plugin.cpp
more eol-style
[xonotic/netradiant.git] / plugins / entity / plugin.cpp
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 //
23 // Model Plugin
24 //
25
26 #include "plugin.h"
27 #include "entity.h"
28 #include "entity_entitymodel.h"
29 #include "light.h"
30
31 // =============================================================================
32 // Globals
33
34 // function tables
35 _QERFuncTable_1 g_FuncTable;
36 _QERQglTable g_QglTable;
37 _QERBrushTable __BRUSHTABLENAME;
38 _QERUndoTable __UNDOTABLENAME;
39 _EClassManagerTable __ECLASSMANAGERTABLENAME;
40
41 // =============================================================================
42 // SYNAPSE
43
44 class CSynapseClientEntity : public CSynapseClient
45 {
46 public:
47   // CSynapseClient API
48   bool RequestAPI(APIDescriptor_t *pAPI);
49   const char* GetInfo();
50   
51   CSynapseClientEntity() { }
52   virtual ~CSynapseClientEntity() { }
53 };
54
55
56 CSynapseServer* g_pSynapseServer = NULL;
57 CSynapseClientEntity g_SynapseClient;
58
59 #if __GNUC__ >= 4
60 #pragma GCC visibility push(default)
61 #endif
62 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
63 #if __GNUC__ >= 4
64 #pragma GCC visibility pop
65 #endif
66   if (strcmp(version, SYNAPSE_VERSION))
67   {
68     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
69     return NULL;
70   }
71   g_pSynapseServer = pServer;
72   g_pSynapseServer->IncRef();
73   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
74   
75   g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(_QEREntityTable));
76   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
77   g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
78   g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(__BRUSHTABLENAME), SYN_REQUIRE, &__BRUSHTABLENAME);
79   g_SynapseClient.AddAPI(UNDO_MAJOR, NULL, sizeof(__UNDOTABLENAME), SYN_REQUIRE, &__UNDOTABLENAME);
80   g_SynapseClient.AddAPI(ECLASSMANAGER_MAJOR, NULL, sizeof(__ECLASSMANAGERTABLENAME), SYN_REQUIRE, &__ECLASSMANAGERTABLENAME);
81
82   return &g_SynapseClient;
83 }
84
85 bool CSynapseClientEntity::RequestAPI(APIDescriptor_t *pAPI)
86 {
87   if (!strcmp(pAPI->major_name, ENTITY_MAJOR))
88   {
89     _QEREntityTable* pTable= static_cast<_QEREntityTable*>(pAPI->mpTable);
90     pTable->m_pfnEntity_Alloc = &Entity_Alloc;
91     pTable->m_pfnEntity_Free = &Entity_Free;
92     pTable->m_pfnEntity_Clone = &Entity_Clone;
93     pTable->m_pfnSetKeyValue = &SetKeyValue;
94     pTable->m_pfnDeleteKey = &DeleteKey;
95     pTable->m_pfnValueForKey = &ValueForKey;
96     pTable->m_pfnFloatForKey = &FloatForKey;
97     pTable->m_pfnIntForKey = &IntForKey;
98     pTable->m_pfnGetVectorForKey = &GetVectorForKey;
99     pTable->m_pfnEntity_AddToList = &Entity_AddToList;
100     pTable->m_pfnEntity_RemoveFromList = &Entity_RemoveFromList;
101     pTable->m_pfnEntity_LinkBrush = &Entity_LinkBrush;
102     pTable->m_pfnEntity_UnlinkBrush = &Entity_UnlinkBrush;
103     pTable->m_pfnDrawLight = &DrawLight;
104     pTable->m_pfnEntity_MemorySize = &Entity_MemorySize;
105     pTable->m_pfnAllocateEpair = &Entity_AllocateEpair;
106     pTable->m_pfnGetEntityKeyValList = &Entity_GetKeyValList;
107     pTable->m_pfnSetEntityKeyValList = &Entity_SetKeyValList;
108
109     return true;
110   }
111
112   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
113   return false;
114 }
115
116 #include "version.h"
117
118 const char* CSynapseClientEntity::GetInfo()
119 {
120   return "Entity module built " __DATE__ " " RADIANT_VERSION;
121 }