]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - plugins/entity/plugin.cpp
Merge pull request #47 from mrwonko/MapLoading
[xonotic/netradiant.git] / plugins / entity / plugin.cpp
index 947befb3fe9829107fd7728d4488b69019e78df5..41b7ed03a8382df76b75ccfc0b964e8584b49da0 100644 (file)
 /*
-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.
+   This file is part of GtkRadiant.
 
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   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
-{
-};
-
-class EntityQ3API : public TypeSystemRef
-{
-  EntityCreator* m_entityq3;
-public:
-  typedef EntityCreator Type;
-  STRING_CONSTANT(Name, "quake3");
-
-  EntityQ3API()
-  {
-    Entity_Construct();
-
-    m_entityq3 = &GetEntityCreator();
-
-    GlobalReferenceCache().setEntityCreator(*m_entityq3);
-  }
-  ~EntityQ3API()
-  {
-    Entity_Destroy();
-  }
-  EntityCreator* getTable()
-  {
-    return m_entityq3;
-  }
-};
+#include "entity_entitymodel.h"
+#include "light.h"
 
-typedef SingletonModule<EntityQ3API, EntityDependencies> EntityQ3Module;
+// =============================================================================
+// Globals
 
-EntityQ3Module g_EntityQ3Module;
+// function tables
+_QERFuncTable_1 g_FuncTable;
+_QERQglTable g_QglTable;
+_QERBrushTable __BRUSHTABLENAME;
+_QERUndoTable __UNDOTABLENAME;
+_EClassManagerTable __ECLASSMANAGERTABLENAME;
 
+// =============================================================================
+// SYNAPSE
 
-class EntityWolfAPI : public TypeSystemRef
+class CSynapseClientEntity : public CSynapseClient
 {
-  EntityCreator* m_entitywolf;
 public:
-  typedef EntityCreator Type;
-  STRING_CONSTANT(Name, "wolf");
-
-  EntityWolfAPI()
-  {
-    Entity_Construct(eGameTypeRTCW);
-
-    m_entitywolf = &GetEntityCreator();
-
-    GlobalReferenceCache().setEntityCreator(*m_entitywolf);
-  }
-  ~EntityWolfAPI()
-  {
-    Entity_Destroy();
-  }
-  EntityCreator* getTable()
-  {
-    return m_entitywolf;
-  }
-};
-
-typedef SingletonModule<EntityWolfAPI, EntityDependencies> EntityWolfModule;
-
-EntityWolfModule g_EntityWolfModule;
+// CSynapseClient API
+bool RequestAPI( APIDescriptor_t *pAPI );
+const char* GetInfo();
 
-
-class EntityDoom3API : public TypeSystemRef
-{
-  EntityCreator* m_entitydoom3;
-public:
-  typedef EntityCreator Type;
-  STRING_CONSTANT(Name, "doom3");
-
-  EntityDoom3API()
-  {
-    Entity_Construct(eGameTypeDoom3);
-
-    m_entitydoom3 = &GetEntityCreator();
-
-    GlobalReferenceCache().setEntityCreator(*m_entitydoom3);
-  }
-  ~EntityDoom3API()
-  {
-    Entity_Destroy();
-  }
-  EntityCreator* getTable()
-  {
-    return m_entitydoom3;
-  }
+CSynapseClientEntity() { }
+virtual ~CSynapseClientEntity() { }
 };
 
-typedef SingletonModule<EntityDoom3API, EntityDependencies> EntityDoom3Module;
 
-EntityDoom3Module g_EntityDoom3Module;
+CSynapseServer* g_pSynapseServer = NULL;
+CSynapseClientEntity g_SynapseClient;
+
+#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 ) ) {
+               Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
+               return NULL;
+       }
+       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;
+}
 
+bool CSynapseClientEntity::RequestAPI( APIDescriptor_t *pAPI ){
+       if ( !strcmp( pAPI->major_name, ENTITY_MAJOR ) ) {
+               _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;
+       }
+
+       Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
+       return false;
+}
 
-extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
-{
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
-
-  g_EntityQ3Module.selfRegister();
-  g_EntityWolfModule.selfRegister();
-  g_EntityDoom3Module.selfRegister();
-  Doom3ModelSkinCacheModule_selfRegister(server);
+#include "version.h"
+
+const char* CSynapseClientEntity::GetInfo(){
+       return "Entity module built " __DATE__ " " RADIANT_VERSION;
 }