/*
-Copyright (C) 2001-2006, William Joseph.
-All Rights Reserved.
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
-#include "debugging/debugging.h"
-
-#include "iscenegraph.h"
-#include "irender.h"
-#include "iselection.h"
-#include "ientity.h"
-#include "iundo.h"
-#include "ieclass.h"
-#include "igl.h"
-#include "ireference.h"
-#include "ifilter.h"
-#include "preferencesystem.h"
-#include "qerplugin.h"
-#include "namespace.h"
-#include "modelskin.h"
-
-#include "typesystem.h"
+//
+// Model Plugin
+//
+#include "plugin.h"
#include "entity.h"
-#include "skincache.h"
-
-#include "modulesystem/singletonmodule.h"
-
-class EntityDependencies :
- public GlobalRadiantModuleRef,
- public GlobalOpenGLModuleRef,
- public GlobalUndoModuleRef,
- public GlobalSceneGraphModuleRef,
- public GlobalShaderCacheModuleRef,
- public GlobalSelectionModuleRef,
- public GlobalReferenceModuleRef,
- public GlobalFilterModuleRef,
- public GlobalPreferenceSystemModuleRef,
- public GlobalNamespaceModuleRef,
- public GlobalModelSkinCacheModuleRef
-{
-};
+#include "entity_entitymodel.h"
+#include "light.h"
-class EntityQ3API : public TypeSystemRef
-{
- EntityCreator* m_entityq3;
-public:
- typedef EntityCreator Type;
- STRING_CONSTANT(Name, "quake3");
+// =============================================================================
+// Globals
- EntityQ3API()
- {
- Entity_Construct();
+// function tables
+_QERFuncTable_1 g_FuncTable;
+_QERQglTable g_QglTable;
+_QERBrushTable __BRUSHTABLENAME;
+_QERUndoTable __UNDOTABLENAME;
+_EClassManagerTable __ECLASSMANAGERTABLENAME;
- m_entityq3 = &GetEntityCreator();
+// =============================================================================
+// SYNAPSE
- GlobalReferenceCache().setEntityCreator(*m_entityq3);
- }
- ~EntityQ3API()
- {
- Entity_Destroy();
- }
- EntityCreator* getTable()
- {
- return m_entityq3;
- }
-};
-
-typedef SingletonModule<EntityQ3API, EntityDependencies> EntityQ3Module;
-
-EntityQ3Module g_EntityQ3Module;
-
-
-class EntityWolfAPI : public TypeSystemRef
+class CSynapseClientEntity : public CSynapseClient
{
- EntityCreator* m_entitywolf;
public:
- typedef EntityCreator Type;
- STRING_CONSTANT(Name, "wolf");
+ // CSynapseClient API
+ bool RequestAPI(APIDescriptor_t *pAPI);
+ const char* GetInfo();
+
+ CSynapseClientEntity() { }
+ virtual ~CSynapseClientEntity() { }
+};
- EntityWolfAPI()
- {
- Entity_Construct(eGameTypeRTCW);
- m_entitywolf = &GetEntityCreator();
+CSynapseServer* g_pSynapseServer = NULL;
+CSynapseClientEntity g_SynapseClient;
- GlobalReferenceCache().setEntityCreator(*m_entitywolf);
- }
- ~EntityWolfAPI()
- {
- Entity_Destroy();
- }
- EntityCreator* getTable()
+#if __GNUC__ >= 4
+#pragma GCC visibility push(default)
+#endif
+extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
+#if __GNUC__ >= 4
+#pragma GCC visibility pop
+#endif
+ if (strcmp(version, SYNAPSE_VERSION))
{
- return m_entitywolf;
+ Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
+ return NULL;
}
-};
-
-typedef SingletonModule<EntityWolfAPI, EntityDependencies> EntityWolfModule;
-
-EntityWolfModule g_EntityWolfModule;
-
+ g_pSynapseServer = pServer;
+ g_pSynapseServer->IncRef();
+ Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
+
+ g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(_QEREntityTable));
+ g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
+ g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
+ g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(__BRUSHTABLENAME), SYN_REQUIRE, &__BRUSHTABLENAME);
+ g_SynapseClient.AddAPI(UNDO_MAJOR, NULL, sizeof(__UNDOTABLENAME), SYN_REQUIRE, &__UNDOTABLENAME);
+ g_SynapseClient.AddAPI(ECLASSMANAGER_MAJOR, NULL, sizeof(__ECLASSMANAGERTABLENAME), SYN_REQUIRE, &__ECLASSMANAGERTABLENAME);
+
+ return &g_SynapseClient;
+}
-class EntityDoom3API : public TypeSystemRef
+bool CSynapseClientEntity::RequestAPI(APIDescriptor_t *pAPI)
{
- EntityCreator* m_entitydoom3;
-public:
- typedef EntityCreator Type;
- STRING_CONSTANT(Name, "doom3");
-
- EntityDoom3API()
+ if (!strcmp(pAPI->major_name, ENTITY_MAJOR))
{
- Entity_Construct(eGameTypeDoom3);
-
- m_entitydoom3 = &GetEntityCreator();
-
- GlobalReferenceCache().setEntityCreator(*m_entitydoom3);
- }
- ~EntityDoom3API()
- {
- Entity_Destroy();
- }
- EntityCreator* getTable()
- {
- return m_entitydoom3;
+ _QEREntityTable* pTable= static_cast<_QEREntityTable*>(pAPI->mpTable);
+ pTable->m_pfnEntity_Alloc = &Entity_Alloc;
+ pTable->m_pfnEntity_Free = &Entity_Free;
+ pTable->m_pfnEntity_Clone = &Entity_Clone;
+ pTable->m_pfnSetKeyValue = &SetKeyValue;
+ pTable->m_pfnDeleteKey = &DeleteKey;
+ pTable->m_pfnValueForKey = &ValueForKey;
+ pTable->m_pfnFloatForKey = &FloatForKey;
+ pTable->m_pfnIntForKey = &IntForKey;
+ pTable->m_pfnGetVectorForKey = &GetVectorForKey;
+ pTable->m_pfnEntity_AddToList = &Entity_AddToList;
+ pTable->m_pfnEntity_RemoveFromList = &Entity_RemoveFromList;
+ pTable->m_pfnEntity_LinkBrush = &Entity_LinkBrush;
+ pTable->m_pfnEntity_UnlinkBrush = &Entity_UnlinkBrush;
+ pTable->m_pfnDrawLight = &DrawLight;
+ pTable->m_pfnEntity_MemorySize = &Entity_MemorySize;
+ pTable->m_pfnAllocateEpair = &Entity_AllocateEpair;
+ pTable->m_pfnGetEntityKeyValList = &Entity_GetKeyValList;
+ pTable->m_pfnSetEntityKeyValList = &Entity_SetKeyValList;
+
+ return true;
}
-};
-
-typedef SingletonModule<EntityDoom3API, EntityDependencies> EntityDoom3Module;
-EntityDoom3Module g_EntityDoom3Module;
+ Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
+ return false;
+}
+#include "version.h"
-extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
+const char* CSynapseClientEntity::GetInfo()
{
- initialiseModule(server);
-
- g_EntityQ3Module.selfRegister();
- g_EntityWolfModule.selfRegister();
- g_EntityDoom3Module.selfRegister();
- Doom3ModelSkinCacheModule_selfRegister(server);
+ return "Entity module built " __DATE__ " " RADIANT_VERSION;
}