| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,26 @@ | |||
| 37 | 37 | #include ENGINE_INCLUDE_PATH(entities_datamaps_wrap.h) | |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | + // ============================================================================ | ||
| 41 | + // >> GetEntityFactoryDictionary | ||
| 42 | + // ============================================================================ | ||
| 43 | + // TODO: Move this to entities_factories.cpp | ||
| 44 | + CEntityFactoryDictionary* GetEntityFactoryDictionary() | ||
| 45 | + { | ||
| 46 | + static CEntityFactoryDictionary* entity_factory_dictionary = NULL; | ||
| 47 | + if (entity_factory_dictionary != NULL) | ||
| 48 | + return entity_factory_dictionary; | ||
| 49 | + | ||
| 50 | + entity_factory_dictionary = extract<CEntityFactoryDictionary*>( | ||
| 51 | + boost::python::import("entities.factories").attr("factory_dictionary")); | ||
| 52 | + | ||
| 53 | + if (!entity_factory_dictionary) | ||
| 54 | + BOOST_RAISE_EXCEPTION(PyExc_ValueError, "factory_dictionary is NULL.") | ||
| 55 | + | ||
| 56 | + return entity_factory_dictionary; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 40 | 60 | // ============================================================================ | |
| 41 | 61 | // >> CBaseEntityWrapper | |
| 42 | 62 | // ============================================================================ | |
@@ -86,12 +106,7 @@ CBaseEntity* CBaseEntityWrapper::find_or_create(const char* name) | |||
| 86 | 106 | ||
| 87 | 107 | IEntityFactory* CBaseEntityWrapper::get_factory(const char* name) | |
| 88 | 108 | { | |
| 89 | - IEntityFactoryDictionary* factories = extract<CEntityFactoryDictionary*>( | ||
| 90 | - boost::python::import("entities.factories").attr("factory_dictionary")); | ||
| 91 | - if (!factories) | ||
| 92 | - BOOST_RAISE_EXCEPTION(PyExc_ValueError, "factory_dictionary is NULL.") | ||
| 93 | - | ||
| 94 | - IEntityFactory* pFactory = factories->FindFactory(name); | ||
| 109 | + IEntityFactory* pFactory = GetEntityFactoryDictionary()->FindFactory(name); | ||
| 95 | 110 | if (!pFactory) | |
| 96 | 111 | BOOST_RAISE_EXCEPTION(PyExc_ValueError, "'%s' is not a valid entity class name.", name) | |
| 97 | 112 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,8 @@ class CEntityFactoryDictionary : public IEntityFactoryDictionary | |||
| 46 | 46 | CUtlDict<IEntityFactory *, unsigned short> m_Factories; | |
| 47 | 47 | }; | |
| 48 | 48 | ||
| 49 | + CEntityFactoryDictionary* GetEntityFactoryDictionary(); | ||
| 50 | + | ||
| 49 | 51 | ||
| 50 | 52 | //----------------------------------------------------------------------------- | |
| 51 | 53 | // CEntityFactoryDictionary extension class. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments